Skip to content

Commit

Permalink
initial set up of blaze persistance views
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Jan 29, 2024
1 parent e5ec510 commit de95299
Show file tree
Hide file tree
Showing 8 changed files with 251 additions and 1 deletion.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ dependencies {
runtimeOnly "com.h2database:h2"
runtimeOnly "org.postgresql:postgresql"
implementation "org.liquibase:liquibase-core"
implementation 'io.hypersistence:hypersistence-utils-hibernate-63:3.7.0'

// Blaze Persistance
implementation('com.blazebit:blaze-persistence-integration-spring-data-3.1')
implementation('com.blazebit:blaze-persistence-integration-hibernate-6.2')
implementation('com.blazebit:blaze-persistence-integration-entity-view-spring-6.0')

implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${springdoc_openapi_version}"
implementation "org.apache.commons:commons-lang3"
implementation "commons-io:commons-io:${commons_io_version}"
Expand Down Expand Up @@ -82,7 +89,7 @@ dependencies {

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${spring_cloud_version}"
mavenBom "com.blazebit:blaze-persistence-bom:${blaze_persistence_version}"
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jacoco_min_coverage_required=0.80

spring_boot_version=3.2.2
spring_cloud_version=2023.0.0
blaze_persistence_version=1.6.11
spring_dependency_management_version=1.1.4
commons_io_version=2.15.1
springdoc_openapi_version=2.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2014 - 2024 Blazebit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.learning.mfscreener.config;

import com.blazebit.persistence.Criteria;
import com.blazebit.persistence.CriteriaBuilderFactory;
import com.blazebit.persistence.integration.view.spring.EnableEntityViews;
import com.blazebit.persistence.spi.CriteriaBuilderConfiguration;
import com.blazebit.persistence.spring.data.repository.config.EnableBlazeRepositories;
import com.blazebit.persistence.view.EntityViewManager;
import com.blazebit.persistence.view.spi.EntityViewConfiguration;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.PersistenceUnit;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

@Configuration
@EnableEntityViews(basePackages = {"com.learning.mfscreener.models.entityviews"})
@EnableBlazeRepositories(basePackages = "com.learning.mfscreener.repository")
public class BlazePersistenceConfiguration {

@PersistenceUnit
private EntityManagerFactory entityManagerFactory;

@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy(false)
public CriteriaBuilderFactory createCriteriaBuilderFactory() {
CriteriaBuilderConfiguration config = Criteria.getDefault();
return config.createCriteriaBuilderFactory(entityManagerFactory);
}

@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Lazy(false)
public EntityViewManager createEntityViewManager(
CriteriaBuilderFactory cbf, EntityViewConfiguration entityViewConfiguration) {
return entityViewConfiguration.createEntityViewManager(cbf);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.learning.mfscreener.models.entityviews;

import com.blazebit.persistence.view.EntityView;
import com.blazebit.persistence.view.IdMapping;
import com.learning.mfscreener.entities.InvestorInfoEntity;
import java.time.LocalDateTime;

/**
* EntityView for {@link com.learning.mfscreener.entities.InvestorInfoEntity}
*/
@EntityView(InvestorInfoEntity.class)
public interface InvestorInfoEntityView {
String getCreatedBy();

LocalDateTime getCreatedDate();

String getLastModifiedBy();

LocalDateTime getLastModifiedDate();

@IdMapping
Long getId();

String getEmail();

String getName();

String getMobile();

String getAddress();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.learning.mfscreener.models.entityviews;

import com.blazebit.persistence.view.EntityView;
import com.blazebit.persistence.view.IdMapping;
import com.learning.mfscreener.entities.CasTypeEnum;
import com.learning.mfscreener.entities.FileTypeEnum;
import com.learning.mfscreener.entities.UserCASDetailsEntity;
import java.time.LocalDateTime;
import java.util.List;

/**
* EntityView for {@link com.learning.mfscreener.entities.UserCASDetailsEntity}
*/
@EntityView(UserCASDetailsEntity.class)
public interface UserCASDetailsEntityView {
String getCreatedBy();

LocalDateTime getCreatedDate();

String getLastModifiedBy();

LocalDateTime getLastModifiedDate();

@IdMapping
Long getId();

CasTypeEnum getCasTypeEnum();

FileTypeEnum getFileTypeEnum();

InvestorInfoEntityView getInvestorInfoEntity();

List<UserFolioDetailsEntityView> getFolioEntities();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.learning.mfscreener.models.entityviews;

import com.blazebit.persistence.view.EntityView;
import com.blazebit.persistence.view.IdMapping;
import com.learning.mfscreener.entities.UserFolioDetailsEntity;
import java.time.LocalDateTime;
import java.util.List;

/**
* EntityView for {@link com.learning.mfscreener.entities.UserFolioDetailsEntity}
*/
@EntityView(UserFolioDetailsEntity.class)
public interface UserFolioDetailsEntityView {
String getCreatedBy();

LocalDateTime getCreatedDate();

String getLastModifiedBy();

LocalDateTime getLastModifiedDate();

@IdMapping
Long getId();

String getFolio();

String getAmc();

String getPan();

String getKyc();

List<UserSchemeDetailsEntityView> getSchemeEntities();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.learning.mfscreener.models.entityviews;

import com.blazebit.persistence.view.EntityView;
import com.blazebit.persistence.view.IdMapping;
import com.learning.mfscreener.entities.UserSchemeDetailsEntity;
import java.time.LocalDateTime;
import java.util.List;

/**
* EntityView for {@link com.learning.mfscreener.entities.UserSchemeDetailsEntity}
*/
@EntityView(UserSchemeDetailsEntity.class)
public interface UserSchemeDetailsEntityView {
String getCreatedBy();

LocalDateTime getCreatedDate();

String getLastModifiedBy();

LocalDateTime getLastModifiedDate();

@IdMapping
Long getId();

String getScheme();

String getIsin();

String getAdvisor();

String getRtaCode();

String getRta();

String getType();

Long getAmfi();

String getMyopen();

String getClose();

String getCloseCalculated();

List<UserTransactionDetailsEntityView> getTransactionEntities();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.learning.mfscreener.models.entityviews;

import com.blazebit.persistence.view.EntityView;
import com.blazebit.persistence.view.IdMapping;
import com.learning.mfscreener.entities.UserTransactionDetailsEntity;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
* EntityView for {@link com.learning.mfscreener.entities.UserTransactionDetailsEntity}
*/
@EntityView(UserTransactionDetailsEntity.class)
public interface UserTransactionDetailsEntityView {
String getCreatedBy();

LocalDateTime getCreatedDate();

String getLastModifiedBy();

LocalDateTime getLastModifiedDate();

@IdMapping
Long getId();

LocalDate getTransactionDate();

String getDescription();

Double getAmount();

Double getUnits();

Double getNav();

Double getBalance();

String getType();

String getDividendRate();
}

0 comments on commit de95299

Please sign in to comment.