diff --git a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateNewAction.java b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateNewAction.java index ce277be59..2cc0685b5 100644 --- a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateNewAction.java +++ b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateNewAction.java @@ -11,6 +11,7 @@ import ru.spcex.clearing.platform.messaging.domain.cud.utilities.KeyRateNewReque import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer; import ru.spcex.platform.utils.enumeration.EnumMessage; +import java.math.BigDecimal; import java.time.Instant; import java.util.Collection; import java.util.Collections; @@ -19,7 +20,7 @@ import java.util.List; public class KeyRateNewAction implements IAction { @ApiModelProperty(value = "Ключевая ставка ЦБ РФ", example = "12.5") @JsonProperty - public Double keyRate; + public BigDecimal keyRate; @ApiModelProperty(value = "Дата начала действия ключевой ставки", example = "2022-01-20") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow") @JsonDeserialize(using = InstantDeserializer.class) @@ -57,11 +58,11 @@ public class KeyRateNewAction implements IAction { return req; } - public Double getKeyRate() { + public BigDecimal getKeyRate() { return keyRate; } - public void setKeyRate(Double keyRate) { + public void setKeyRate(BigDecimal keyRate) { this.keyRate = keyRate; } diff --git a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateUpdateAction.java b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateUpdateAction.java index f15dfe623..d6d46fe6f 100644 --- a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateUpdateAction.java +++ b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/request/cud/utilities/KeyRateUpdateAction.java @@ -9,6 +9,7 @@ import ru.spcex.clearing.platform.messaging.domain.ActionType; import ru.spcex.clearing.platform.messaging.domain.cud.utilities.KeyRateUpdateRequest; import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer; +import java.math.BigDecimal; import java.time.Instant; public class KeyRateUpdateAction implements IAction { @@ -17,7 +18,7 @@ public class KeyRateUpdateAction implements IAction { public Long id; @ApiModelProperty(value = "Ключевая ставка ЦБ РФ", example = "12.5") @JsonProperty - public Double keyRate; + public BigDecimal keyRate; @ApiModelProperty(value = "Дата начала действия ключевой ставки", example = "2022-01-20") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow") @JsonDeserialize(using = InstantDeserializer.class) @@ -49,11 +50,11 @@ public class KeyRateUpdateAction implements IAction { return req; } - public Double getKeyRate() { + public BigDecimal getKeyRate() { return keyRate; } - public void setKeyRate(Double keyRate) { + public void setKeyRate(BigDecimal keyRate) { this.keyRate = keyRate; } @@ -77,6 +78,10 @@ public class KeyRateUpdateAction implements IAction { return document; } + public void setDocument(String document) { + this.document = document; + } + public Long getId() { return id; } @@ -84,8 +89,4 @@ public class KeyRateUpdateAction implements IAction { public void setId(Long id) { this.id = id; } - - public void setDocument(String document) { - this.document = document; - } } diff --git a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/response/entity/utilities/KeyRateBackendGetFields.java b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/response/entity/utilities/KeyRateBackendGetFields.java index d82f78ec4..93207aee6 100644 --- a/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/response/entity/utilities/KeyRateBackendGetFields.java +++ b/clearing-parent/backend-api/src/main/java/ru/spcex/clearing/backendapi/controller/response/entity/utilities/KeyRateBackendGetFields.java @@ -4,13 +4,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import ru.spcex.clearing.platform.messaging.domain.json.serialize.InstantSerializer; +import java.math.BigDecimal; import java.time.Instant; public class KeyRateBackendGetFields { @JsonProperty private Long id; @JsonProperty - private Double rate; + private BigDecimal rate; @JsonSerialize(using = InstantSerializer.class) @JsonProperty private Instant startDate; @@ -30,11 +31,11 @@ public class KeyRateBackendGetFields { this.id = id; } - public Double getRate() { + public BigDecimal getRate() { return rate; } - public void setRate(Double rate) { + public void setRate(BigDecimal rate) { this.rate = rate; } diff --git a/clearing-parent/classes/src/main/java/ru/clearing/classes/statics/data/misc/KeyRate.java b/clearing-parent/classes/src/main/java/ru/clearing/classes/statics/data/misc/KeyRate.java index d107be73e..5e7211360 100644 --- a/clearing-parent/classes/src/main/java/ru/clearing/classes/statics/data/misc/KeyRate.java +++ b/clearing-parent/classes/src/main/java/ru/clearing/classes/statics/data/misc/KeyRate.java @@ -2,25 +2,26 @@ package ru.clearing.classes.statics.data.misc; import ru.spcex.platform.classes.base.SpcexObjectBase; +import java.math.BigDecimal; import java.time.Instant; /** * Ключевая ставка ЦБ - * + *

* DB table: KEY_RATE **/ public class KeyRate extends SpcexObjectBase { - private Double rate; + private BigDecimal rate; private Instant startDate; private Instant endDate; private String document; private String workflowStatus; - public Double getRate() { + public BigDecimal getRate() { return rate; } - public void setRate(Double rate) { + public void setRate(BigDecimal rate) { this.rate = rate; } diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/base/DictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/base/DictionaryMapStore.java index 91414e4c5..1e8aff1d1 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/base/DictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/base/DictionaryMapStore.java @@ -18,11 +18,9 @@ import static ru.spcex.clearing.imdg.base.ObjectBaseMapStore.MAX_IN_CLAUSE_SIZE; * Store для словарей стандартных - из ID, CODE, NAME. */ public abstract class DictionaryMapStore implements MapLoader { - private static Logger log = LoggerFactory.getLogger(DictionaryMapStore.class); - - protected NamedParameterJdbcTemplate namedParameterJdbcTemplate; - + private static final Logger log = LoggerFactory.getLogger(DictionaryMapStore.class); protected final JdbcTemplate jdbcTemplate; + protected NamedParameterJdbcTemplate namedParameterJdbcTemplate; protected DictionaryMapStore(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/HazelcastConfiguration.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/HazelcastConfiguration.java index f589a29c4..913613d19 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/HazelcastConfiguration.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/HazelcastConfiguration.java @@ -12,9 +12,9 @@ import java.util.List; @Configuration public class HazelcastConfiguration { - private ConfigurationRootElement configRoot = DfaConfig.get().getRoot(); private final PoolMapConfigs poolMapConfigs; private final HazelcastServerElement hzSettings; + private final ConfigurationRootElement configRoot = DfaConfig.get().getRoot(); @Autowired public HazelcastConfiguration(PoolMapConfigs poolMapConfigs, ImdgSettings imdgSettings) { @@ -49,17 +49,6 @@ public class HazelcastConfiguration { ) ); - config.addMapConfig(poolMapConfigs.map_AllowedDictionary()); - config.addMapConfig(poolMapConfigs.map_CompanyRoleDictionary()); - config.addMapConfig(poolMapConfigs.map_CompanySymbolDictionary()); - config.addMapConfig(poolMapConfigs.map_ContactTypeDictionary()); - config.addMapConfig(poolMapConfigs.map_CorporationSoleTypeDictionary()); - config.addMapConfig(poolMapConfigs.map_CountryCodeDictionary()); - config.addMapConfig(poolMapConfigs.map_DocumentTypeDictionary()); - config.addMapConfig(poolMapConfigs.map_LegalKindDictionary()); - config.addMapConfig(poolMapConfigs.map_OrganizationTypeDictionary()); - config.addMapConfig(poolMapConfigs.map_WorkflowStatusDictionary()); - // config.addMapConfig(poolMapConfigs.map_CompanyRoleSet()); todo протестировать автоконфигуратор конфигурации мапсторов config.addMapConfig(poolMapConfigs.map_CompanySymbols()); config.addMapConfig(poolMapConfigs.map_ProfileDocument()); @@ -69,7 +58,7 @@ public class HazelcastConfiguration { // Автоподключение мап List autoMapCfg = poolMapConfigs.autoconfiguratorOfMapstorages(); - for (MapConfig cfg: autoMapCfg) { + for (MapConfig cfg : autoMapCfg) { config.addMapConfig(cfg); } diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/PoolMapConfigs.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/PoolMapConfigs.java index bcd1f09d9..7749e454d 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/PoolMapConfigs.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/config/PoolMapConfigs.java @@ -7,15 +7,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.clearing.imdg.base.AutoconfiguredMap; import ru.spcex.clearing.imdg.base.DictionaryTMapStore; import ru.spcex.clearing.imdg.businessevent.CompanyHistoryMapStore; import ru.spcex.clearing.imdg.businessobject.CompanyMapStore; -import ru.spcex.clearing.imdg.dictionary.*; import ru.spcex.clearing.imdg.object.CompanySymbolsMapStore; import ru.spcex.clearing.imdg.object.ContactMapStore; import ru.spcex.clearing.imdg.object.ProfileDocumentMapStore; -import ru.spcex.clearing.imdg.IMDGDistributedNames; import java.util.ArrayList; import java.util.Arrays; @@ -24,9 +23,21 @@ import java.util.List; @Configuration public class PoolMapConfigs { - private Logger log = LoggerFactory.getLogger(getClass()); + private final Logger log = LoggerFactory.getLogger(getClass()); - private ConfigurationRootElement configRoot = DfaConfig.get().getRoot(); + private final ConfigurationRootElement configRoot = DfaConfig.get().getRoot(); + @Autowired + private List> listOfAutopluginStores; + @Autowired + private CompanySymbolsMapStore companySymbolsMapStore; + @Autowired + private ProfileDocumentMapStore profileDocumentMapStore; + @Autowired + private ContactMapStore contactMapStore; + @Autowired + private CompanyMapStore companyMapStore; + // @Autowired + private CompanyHistoryMapStore companyHistoryMapStore; public PoolMapConfigs() { } @@ -34,7 +45,7 @@ public class PoolMapConfigs { private MapStoreConfig makeDefaultMapStoreConfig(MapLoader mapBean) { return new MapStoreConfig() .setImplementation(mapBean) -;//todo config: .setWriteDelaySeconds(configRoot.getIMDG().getDbSyncSeconds()); + ;//todo config: .setWriteDelaySeconds(configRoot.getIMDG().getDbSyncSeconds()); } public ScheduledExecutorConfig makeDefaultScheduledExecutorConfig(String name) { @@ -72,71 +83,6 @@ public class PoolMapConfigs { return makeMapIndexConfig(attributeName, false); } - - - @Autowired private AllowedDictionaryMapStore allowedDictionaryMapStore; - public MapConfig map_AllowedDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_AllowedDictionary, allowedDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private CompanyRoleDictionaryMapStore companyRoleDictionaryMapStore; - public MapConfig map_CompanyRoleDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_CompanyRoleDictionary, companyRoleDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private CompanySymbolDictionaryMapStore companySymbolDictionaryMapStore; - public MapConfig map_CompanySymbolDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_CompanySymbolDictionary, companySymbolDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private ContactTypeDictionaryMapStore contactTypeDictionaryMapStore; - public MapConfig map_ContactTypeDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_ContactTypeDictionary, contactTypeDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private CorporationSoleTypeDictionaryMapStore corporationSoleTypeDictionaryMapStore; - public MapConfig map_CorporationSoleTypeDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_CorporationSoleTypeDictionary, corporationSoleTypeDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private CountryCodeDictionaryMapStore countryCodeDictionaryMapStore; - public MapConfig map_CountryCodeDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_CountryCodeDictionary, countryCodeDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private DocumentTypeDictionaryMapStore documentTypeDictionaryMapStore; - public MapConfig map_DocumentTypeDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_DocumentTypeDictionary, documentTypeDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private LegalKindDictionaryMapStore legalKindDictionaryMapStore; - public MapConfig map_LegalKindDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_LegalKindDictionary, legalKindDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private OrganizationTypeDictionaryMapStore organizationTypeDictionaryMapStore; - public MapConfig map_OrganizationTypeDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_OrganizationTypeDictionary, organizationTypeDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - @Autowired private WorkflowStatusDictionaryMapStore workflowStatusDictionaryMapStore; - public MapConfig map_WorkflowStatusDictionary() { - return makeDefaultMapConfig(IMDGDistributedNames.Map_WorkflowStatusDictionary, workflowStatusDictionaryMapStore) - .setNearCacheConfig(makeDefaultNearCacheConfig()) - .addMapIndexConfig(makeMapIndexConfig("code")); - } - - - // @Autowired todo эксперимент с мапстором, см. ниже autoconfiguratorOfMapstorage. // private CompanyRoleSetMapStore companyRoleSetMapStore; // @@ -145,9 +91,6 @@ public class PoolMapConfigs { // .addMapIndexConfig(makeMapIndexConfig("companyId")); // } - @Autowired - private List> listOfAutopluginStores; - // @Qualifier("AutoconfiguredMapStore") public List autoconfiguratorOfMapstorages() { List out = new ArrayList<>(); @@ -177,52 +120,34 @@ public class PoolMapConfigs { } out.add(mapCfg); } catch (RuntimeException e) { - throw new RuntimeException("Can not configure MapStore " + mapStore.getMapName() + "(" + mapStore.toString() + "): " + e, e); + throw new RuntimeException("Can not configure MapStore " + mapStore.getMapName() + "(" + mapStore + "): " + e, e); } } log.debug("Configured {} mapStore's", out.size()); return out; } - - @Autowired - private CompanySymbolsMapStore companySymbolsMapStore; - public MapConfig map_CompanySymbols() { return makeDefaultMapConfig(IMDGDistributedNames.Map_CompanySymbols, companySymbolsMapStore) .addMapIndexConfig(makeMapIndexConfig("companyId")) .addMapIndexConfig(makeMapIndexConfig("companySymbol")); } - - @Autowired - private ProfileDocumentMapStore profileDocumentMapStore; - public MapConfig map_ProfileDocument() { return makeDefaultMapConfig(IMDGDistributedNames.Map_ProfileDocument, profileDocumentMapStore) .addMapIndexConfig(makeMapIndexConfig("companyId")); } - @Autowired - private ContactMapStore contactMapStore; - public MapConfig map_Contact() { return makeDefaultMapConfig(IMDGDistributedNames.Map_Contact, contactMapStore) .addMapIndexConfig(makeMapIndexConfig("companyId")); } - - @Autowired - private CompanyMapStore companyMapStore; - public MapConfig map_Company() { return makeDefaultMapConfig(IMDGDistributedNames.Map_Company, companyMapStore) .addMapIndexConfig(makeMapIndexConfig("Id")); } -// @Autowired - private CompanyHistoryMapStore companyHistoryMapStore; - public MapConfig map_CompanyUpdate() { return makeDefaultMapConfig(IMDGDistributedNames.Map_CompanyHistory, companyHistoryMapStore); } diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/AllowedDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/AllowedDictionaryMapStore.java index 55eaad879..97d083d89 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/AllowedDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/AllowedDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.AllowedDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class AllowedDictionaryMapStore extends DictionaryMapStore { +public class AllowedDictionaryMapStore extends DictionaryTMapStore { public AllowedDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_AllowedDictionary; + } + @Override public String getTableName() { return "ALLOWED_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanyRoleDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanyRoleDictionaryMapStore.java index dbde3714f..ca3ad6cd6 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanyRoleDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanyRoleDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.CompanyRoleDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class CompanyRoleDictionaryMapStore extends DictionaryMapStore { +public class CompanyRoleDictionaryMapStore extends DictionaryTMapStore { public CompanyRoleDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_CompanyRoleDictionary; + } + @Override public String getTableName() { return "COMPANY_ROLE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanySymbolDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanySymbolDictionaryMapStore.java index 2665f5e48..148c5de69 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanySymbolDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CompanySymbolDictionaryMapStore.java @@ -3,18 +3,24 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.CompanySymbolDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; import java.sql.ResultSet; import java.sql.SQLException; @Component -public class CompanySymbolDictionaryMapStore extends DictionaryMapStore { +public class CompanySymbolDictionaryMapStore extends DictionaryTMapStore { public CompanySymbolDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_CompanySymbolDictionary; + } + @Override public String getTableName() { return "COMPANY_SYMBOL_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/ContactTypeDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/ContactTypeDictionaryMapStore.java index 16da2c632..b4019a77b 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/ContactTypeDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/ContactTypeDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.ContactTypeDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class ContactTypeDictionaryMapStore extends DictionaryMapStore { +public class ContactTypeDictionaryMapStore extends DictionaryTMapStore { public ContactTypeDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_ContactTypeDictionary; + } + @Override public String getTableName() { return "CONTACT_TYPE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CorporationSoleTypeDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CorporationSoleTypeDictionaryMapStore.java index 5d324d7ac..3e1bd3d89 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CorporationSoleTypeDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CorporationSoleTypeDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.CorporationSoleTypeDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class CorporationSoleTypeDictionaryMapStore extends DictionaryMapStore { +public class CorporationSoleTypeDictionaryMapStore extends DictionaryTMapStore { public CorporationSoleTypeDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_CorporationSoleTypeDictionary; + } + @Override public String getTableName() { return "CORPORATION_SOLE_TYPE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CountryCodeDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CountryCodeDictionaryMapStore.java index e5eb27096..112dc2c67 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CountryCodeDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/CountryCodeDictionaryMapStore.java @@ -3,15 +3,22 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.CountryCodeDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; + @Component -public class CountryCodeDictionaryMapStore extends DictionaryMapStore { +public class CountryCodeDictionaryMapStore extends DictionaryTMapStore { public CountryCodeDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_CountryCodeDictionary; + } + @Override public String getTableName() { return "COUNTRY_CODE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/DocumentTypeDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/DocumentTypeDictionaryMapStore.java index f47fc5172..ca1bcd831 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/DocumentTypeDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/DocumentTypeDictionaryMapStore.java @@ -3,15 +3,22 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.DocumentTypeDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; + @Component -public class DocumentTypeDictionaryMapStore extends DictionaryMapStore { +public class DocumentTypeDictionaryMapStore extends DictionaryTMapStore { public DocumentTypeDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_DocumentTypeDictionary; + } + @Override public String getTableName() { return "DOCUMENT_TYPE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/LegalKindDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/LegalKindDictionaryMapStore.java index 9c7017659..da957260b 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/LegalKindDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/LegalKindDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.LegalKindDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class LegalKindDictionaryMapStore extends DictionaryMapStore { +public class LegalKindDictionaryMapStore extends DictionaryTMapStore { public LegalKindDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_LegalKindDictionary; + } + @Override public String getTableName() { return "LEGAL_KIND_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/OrganizationTypeDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/OrganizationTypeDictionaryMapStore.java index 56bde2298..32bae2307 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/OrganizationTypeDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/OrganizationTypeDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.OrganizationTypeDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class OrganizationTypeDictionaryMapStore extends DictionaryMapStore { +public class OrganizationTypeDictionaryMapStore extends DictionaryTMapStore { public OrganizationTypeDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_OrganizationTypeDictionary; + } + @Override public String getTableName() { return "ORGANIZATION_TYPE_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/WorkflowStatusDictionaryMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/WorkflowStatusDictionaryMapStore.java index 5d9a97501..b2634fbc8 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/WorkflowStatusDictionaryMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/dictionary/WorkflowStatusDictionaryMapStore.java @@ -3,15 +3,21 @@ package ru.spcex.clearing.imdg.dictionary; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import ru.clearing.platform.dictionary.WorkflowStatusDictionary; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; +import ru.spcex.clearing.imdg.IMDGDistributedNames; +import ru.spcex.clearing.imdg.base.DictionaryTMapStore; @Component -public class WorkflowStatusDictionaryMapStore extends DictionaryMapStore { +public class WorkflowStatusDictionaryMapStore extends DictionaryTMapStore { public WorkflowStatusDictionaryMapStore(JdbcTemplate jdbcTemplate) { super(jdbcTemplate); } + @Override + public String getMapName() { + return IMDGDistributedNames.Map_WorkflowStatusDictionary; + } + @Override public String getTableName() { return "WORKFLOW_STATUS_DICTIONARY"; diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/object/KeyRateMapStore.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/object/KeyRateMapStore.java index 8fe049f6b..9c4a6d234 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/object/KeyRateMapStore.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/object/KeyRateMapStore.java @@ -7,6 +7,7 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames; import ru.spcex.clearing.imdg.base.TemplateMapStore; import ru.spcex.platform.utils.time.TimeUtil; +import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.SQLException; @@ -41,8 +42,8 @@ public class KeyRateMapStore extends TemplateMapStore { protected KeyRate objectReader(ResultSet resultSet) throws SQLException { KeyRate keyRate = new KeyRate(); keyRate.setId(resultSet.getObject("ID", Long.class)); - keyRate.setRate(resultSet.getObject("RATE", Double.class)); - keyRate.setStartDate(getInstantFromTimestamp(resultSet,"START_DATE")); + keyRate.setRate(resultSet.getObject("RATE", BigDecimal.class)); + keyRate.setStartDate(getInstantFromTimestamp(resultSet, "START_DATE")); keyRate.setEndDate(getInstantFromTimestamp(resultSet, "END_DATE")); keyRate.setDocument(resultSet.getObject("DOCUMENT", String.class)); keyRate.setWorkflowStatus(resultSet.getObject("WORKFLOW_STATUS", String.class)); diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/AllMapStoreTest.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/AllMapStoreTest.java index 0d82ef029..05cc769c7 100644 --- a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/AllMapStoreTest.java +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/AllMapStoreTest.java @@ -3,6 +3,7 @@ package ru.spcex.clearing.imdg; import com.hazelcast.config.MapStoreConfig; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IMap; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; @@ -13,27 +14,32 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.support.DataAccessUtils; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.SqlTypeValue; +import org.springframework.jdbc.core.StatementCreatorUtils; +import org.springframework.lang.NonNull; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; -import ru.spcex.clearing.imdg.base.BusinessObjectMapStore; -import ru.spcex.clearing.imdg.base.DictionaryMapStore; -import ru.spcex.clearing.imdg.base.TemplateEventMapStore; -import ru.spcex.clearing.imdg.base.TemplateMapStore; +import ru.clearing.platform.dictionary.AbstractDictionary; +import ru.clearing.platform.dictionary.CompanySymbolDictionary; +import ru.spcex.clearing.imdg.base.*; import ru.spcex.clearing.imdg.config.DbTestConnectionConfig; import ru.spcex.clearing.imdg.config.TestConfiguration; -import ru.spcex.clearing.imdg.structure.ObjectForCheckMapStore; +import ru.spcex.clearing.imdg.structure.BusinessObjectAndBusinessEventForCheckMapStore; +import ru.spcex.clearing.imdg.structure.DictionaryObjectForCheckMapStore; import ru.spcex.clearing.imdg.utils.BusinessEventRowMapper; import ru.spcex.clearing.imdg.utils.DbDataUtils; import ru.spcex.platform.classes.base.SpcexObjectBase; +import ru.spcex.platform.utils.text.TextUtil; import javax.annotation.PostConstruct; import java.lang.reflect.InvocationTargetException; import java.sql.*; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; -import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.objectForCheckMapStores; +import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.businessObjectAndBusinessEventForCheckMapStores; +import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.dictionaryObjectForCheckMapStores; @ContextConfiguration(classes = { TestConfiguration.class, @@ -52,11 +58,16 @@ public class AllMapStoreTest { @PostConstruct public void initTestObjects() { try { - for (ObjectForCheckMapStore objectForCheck : objectForCheckMapStores) { + for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) { SpcexObjectBase object = objectForCheck.getClazz().getDeclaredConstructor().newInstance(); DbDataUtils.fillObjectDefaultValues(object, object.getClass()); objectForCheck.setPredictableObj(object); } + for (DictionaryObjectForCheckMapStore objectForCheck : dictionaryObjectForCheckMapStores) { + AbstractDictionary object = objectForCheck.getClazz().getDeclaredConstructor().newInstance(); + DbDataUtils.fillObjectDefaultValues(object, object.getClass()); + objectForCheck.setPredictableObj(object); + } } catch (InstantiationException | IllegalAccessException e) { log.error(e.getMessage()); } catch (InvocationTargetException | NoSuchMethodException e) { @@ -109,11 +120,12 @@ public class AllMapStoreTest { @Test public void checkSavingForAllMapStoreTest() { - saveObjectToMaps(); + saveBusinessObjectAndBusinessEventToMaps(); + saveDictionaryObjectToMaps(); testConfig.shutDownHazelcast(); testConfig.reinitHazlecastInstance(); - for (ObjectForCheckMapStore objectForCheck : objectForCheckMapStores) { + for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) { String mapName = objectForCheck.getMapName(); SpcexObjectBase actual; if (getMapStore(mapName) instanceof TemplateEventMapStore) { @@ -126,15 +138,22 @@ public class AllMapStoreTest { } objectForCheck.getMATCHER().assertMatch(actual, objectForCheck.getPredictableObj()); } + for (DictionaryObjectForCheckMapStore objectForCheck : dictionaryObjectForCheckMapStores) { + String mapName = objectForCheck.getMapName(); + AbstractDictionary actual; + IMap map = testConfig.getHazelcastInstance().getMap(mapName); + actual = map.get(ID); + objectForCheck.getMATCHER().assertMatch(actual, objectForCheck.getPredictableObj()); + } } //todo удалить если будет не нужна, пока не работает из-за "deleteIsSupported() return false" в SimpleObjectMapStore. @Test public void checkDeletingForAllMapStoreTest() { Assumptions.assumeTrue(false, "todo удалить если будет не нужна, пока не работает из-за \"deleteIsSupported() return false\" в SimpleObjectMapStore."); - saveObjectToMaps(); + saveBusinessObjectAndBusinessEventToMaps(); - for (ObjectForCheckMapStore objectForCheck : objectForCheckMapStores) { + for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) { IMap map = testConfig.getHazelcastInstance().getMap(objectForCheck.getMapName()); map.remove(ID); String sql = String.format("SELECT * FROM %s WHERE id = %d", getTableNameFromMapStore(objectForCheck.getMapName()), ID); @@ -166,14 +185,81 @@ public class AllMapStoreTest { return mapStoreConfig.getImplementation(); } - private void saveObjectToMaps() { - for (ObjectForCheckMapStore objectForCheck : objectForCheckMapStores) { + private void saveBusinessObjectAndBusinessEventToMaps() { + for (BusinessObjectAndBusinessEventForCheckMapStore objectForCheck : businessObjectAndBusinessEventForCheckMapStores) { String mapName = objectForCheck.getMapName(); - IMap map = testConfig.getHazelcastInstance().getMap(mapName); SpcexObjectBase spcexObjectBase = objectForCheck.getPredictableObj(); spcexObjectBase.setId(ID); log.info("Запись в мап {} объекта {}", mapName, spcexObjectBase); + Object mapStore = getMapStore(mapName); + IMap map = testConfig.getHazelcastInstance().getMap(mapName); map.put(spcexObjectBase.getId(), spcexObjectBase); } } + + private void saveDictionaryObjectToMaps() { + for (DictionaryObjectForCheckMapStore objectForCheck : dictionaryObjectForCheckMapStores) { + String mapName = objectForCheck.getMapName(); + AbstractDictionary dictionaryObj = objectForCheck.getPredictableObj(); + dictionaryObj.setId(ID); + log.info("Запись в мап {} объекта {}", mapName, dictionaryObj); + Object mapStore = getMapStore(mapName); + String[] fields; + Object[] args; + if (mapName.equals(IMDGDistributedNames.Map_CompanySymbolDictionary)) { + CompanySymbolDictionary companySymbolDictionary = (CompanySymbolDictionary) dictionaryObj; + fields = new String[]{"ID", "CODE", "NAME", "SHORTNAME"}; + args = new Object[]{companySymbolDictionary.getId(), companySymbolDictionary.getCode(), companySymbolDictionary.getName(), companySymbolDictionary.getShortname()}; + } else { + fields = new String[]{"ID", "CODE", "NAME"}; + args = new Object[]{dictionaryObj.getId(), dictionaryObj.getCode(), dictionaryObj.getName()}; + } + makeInsertSql(((DictionaryTMapStore) mapStore).getTableName(), fields, args, "id"); + } + } + + private void makeInsertSql(String tableName, String[] fields, Object[] args, String matchingKey) { + String INSERT_TEMPLATE = "INSERT INTO ${tableName} (${columnsEnumeration}) VALUES (${valuesEnumeration}) ON CONFLICT (${matchingKey}) DO UPDATE SET ${excludedColumns}"; + + String columnsEnumeration = Arrays.stream(fields).map(f -> "" + f.toUpperCase() + "").collect(Collectors.joining(", ")); + String valuesEnumeration = String.join(", ", Collections.nCopies(fields.length, "?")); + String excludedColumns = Arrays.stream(fields).filter(f -> !matchingKey.equalsIgnoreCase(f)). + map(f -> "" + f.toUpperCase() + "=EXCLUDED." + f.toUpperCase() + "").collect(Collectors.joining(", ")); + + Map params = new HashMap<>(); + params.put("tableName", tableName); + params.put("columnsEnumeration", columnsEnumeration); + params.put("valuesEnumeration", valuesEnumeration); + params.put("matchingKey", matchingKey.toUpperCase()); + params.put("excludedColumns", excludedColumns); + + String insertStatement = TextUtil.format(INSERT_TEMPLATE, params); + + List batchArgs = new ArrayList<>(); + if (args.length != args.length) { + throw new IllegalArgumentException("objectToField return " + args.length + " arguments, but expected " + args.length); + } + batchArgs.add(args); + batchInsertUpdate(insertStatement, batchArgs, tableName); + } + + private void batchInsertUpdate(@NonNull String insertStatement, @NonNull List args, String tableName) { + try { + int[][] ret = jdbcTemplate.batchUpdate(insertStatement, args, 1000, (ps, params) -> { + for (int i = 0; i < params.length; i++) { + Object value = params[i]; + try { + StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, value); + } catch (SQLException e) { + throw new SQLException("batchInsertUpdate, at prepare argument " + i + " value = " + value + "; SQL=" + insertStatement, e); + } + } + }); + int batchSize = ret.length > 0 ? ret[0].length : ret.length; + log.debug("{} {} rows stored", tableName, batchSize); + } catch (Exception e) { + log.error("SQL error at batch UPDATE OR INSERT INTO {}\n{}", tableName, ExceptionUtils.getStackTrace(e)); + throw e; + } + } } \ No newline at end of file diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/config/DbTestConnectionConfig.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/config/DbTestConnectionConfig.java index 2709151be..bdcaa1d6a 100644 --- a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/config/DbTestConnectionConfig.java +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/config/DbTestConnectionConfig.java @@ -8,7 +8,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.init.DatabasePopulator; -import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; import ru.spcex.clearing.imdg.error.ModuleInitializeException; @@ -53,7 +52,7 @@ public class DbTestConnectionConfig { cpds.setNumHelperThreads(configRoot.getDatabase().getNumHelperThreads()); cpds.setCheckoutTimeout(timeoutSec * 1000/*todo common 1000==ConstsCommon.SECOND*/); logTimeoutPart = String.format(" (timeout=%ds)", timeoutSec); - DatabasePopulatorUtils.execute(createDatabasePopulator(), cpds); +// DatabasePopulatorUtils.execute(createDatabasePopulator(), cpds); result = cpds; String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbPath); diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/ObjectForCheckMapStore.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/BusinessObjectAndBusinessEventForCheckMapStore.java similarity index 89% rename from clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/ObjectForCheckMapStore.java rename to clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/BusinessObjectAndBusinessEventForCheckMapStore.java index 9f90a89b0..7a6799c16 100644 --- a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/ObjectForCheckMapStore.java +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/BusinessObjectAndBusinessEventForCheckMapStore.java @@ -9,7 +9,7 @@ import java.lang.reflect.Method; import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator; -public class ObjectForCheckMapStore { +public class BusinessObjectAndBusinessEventForCheckMapStore { public final Matcher MATCHER = usingIgnoringFieldsComparator(); private final String mapName; @@ -18,12 +18,12 @@ public class ObjectForCheckMapStore { private SpcexObjectBase predictableObj; - public ObjectForCheckMapStore(String mapName, Class clazz) { + public BusinessObjectAndBusinessEventForCheckMapStore(String mapName, Class clazz) { this.mapName = mapName; this.clazz = clazz; } - public ObjectForCheckMapStore(String mapName, Class clazz, SettingOperation settingOperation) { + public BusinessObjectAndBusinessEventForCheckMapStore(String mapName, Class clazz, SettingOperation settingOperation) { this.mapName = mapName; this.clazz = clazz; this.settingOperation = settingOperation; diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/DictionaryObjectForCheckMapStore.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/DictionaryObjectForCheckMapStore.java new file mode 100644 index 000000000..8f34e25d7 --- /dev/null +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/DictionaryObjectForCheckMapStore.java @@ -0,0 +1,43 @@ +package ru.spcex.clearing.imdg.structure; + + +import ru.clearing.platform.dictionary.AbstractDictionary; +import ru.spcex.clearing.imdg.utils.MatcherFactory.Matcher; + +import java.lang.reflect.InvocationTargetException; + +import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator; + +public class DictionaryObjectForCheckMapStore { + + public final Matcher MATCHER = usingIgnoringFieldsComparator(); + private final String mapName; + private final Class clazz; + + private AbstractDictionary predictableObj; + + public DictionaryObjectForCheckMapStore(String mapName, Class clazz) { + this.mapName = mapName; + this.clazz = clazz; + } + + public String getMapName() { + return mapName; + } + + public Class getClazz() { + return clazz; + } + + public Matcher getMATCHER() { + return MATCHER; + } + + public AbstractDictionary getPredictableObj() { + return predictableObj; + } + + public void setPredictableObj(AbstractDictionary predictableObj) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + this.predictableObj = predictableObj; + } +} diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/GeneratorMapNamesForHazelcast.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/GeneratorMapNamesForHazelcast.java index 5e86ffb4c..02b8c39eb 100644 --- a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/GeneratorMapNamesForHazelcast.java +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/structure/GeneratorMapNamesForHazelcast.java @@ -16,70 +16,69 @@ import ru.clearing.classes.statics.data.user.User; import ru.clearing.classes.statics.data.user.UserConnect; import ru.clearing.classes.statics.data.user.UserConnectHistory; import ru.clearing.classes.statics.data.user.UserHistory; +import ru.clearing.platform.dictionary.*; import ru.spcex.clearing.imdg.IMDGDistributedNames; -import ru.spcex.clearing.imdg.structure.ObjectForCheckMapStore.SettingOperation; +import ru.spcex.clearing.imdg.structure.BusinessObjectAndBusinessEventForCheckMapStore.SettingOperation; import java.math.BigDecimal; -import java.util.*; +import java.util.LinkedList; +import java.util.List; public class GeneratorMapNamesForHazelcast { - public static Map mapStoreNameByClass; - public static List objectForCheckMapStores; + public static List businessObjectAndBusinessEventForCheckMapStores; + public static List dictionaryObjectForCheckMapStores; static { init(); - mapStoreNameByClass = createMapStoreNameByClass(); } private static void init() { - objectForCheckMapStores = new LinkedList<>(); + businessObjectAndBusinessEventForCheckMapStores = new LinkedList<>(); + dictionaryObjectForCheckMapStores = new LinkedList<>(); //business event - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalanceHistory, AccountBalanceHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountHistory, AccountHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountRoutingHistory, AccountRoutingHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_BankAccountHistory, BankAccountHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalanceHistory, AccountBalanceHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountHistory, AccountHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountRoutingHistory, AccountRoutingHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_BankAccountHistory, BankAccountHistory.class)); // objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_CompanyHistory, CompanyHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_InformationAccountHistory, InformationAccountHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_RelationHistory, RelationHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_SecurityHistory, SecurityHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_UserConnectHistory, UserConnectHistory.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_UserHistory, UserHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_InformationAccountHistory, InformationAccountHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_RelationHistory, RelationHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_SecurityHistory, SecurityHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserConnectHistory, UserConnectHistory.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserHistory, UserHistory.class)); + //business object - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Account, Account.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Company, Company.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_ErrorText, ErrorText.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Relation, Relation.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Scheduler, Scheduler.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Security, Security.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Statement, Statement.class, + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Account, Account.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_AccountBalance, AccountBalance.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Company, Company.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_ErrorText, ErrorText.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Relation, Relation.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Scheduler, Scheduler.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Security, Security.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Statement, Statement.class, new SettingOperation("setAmount", new Class[]{BigDecimal.class}, new Object[]{new BigDecimal("23.22")}))); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_TaskRunner, TaskRunner.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_Timetable, Timetable.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_TradingCalendar, TradingCalendar.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_UserConnect, UserConnect.class)); - objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_User, User.class)); - } + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_TaskRunner, TaskRunner.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_Timetable, Timetable.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_TradingCalendar, TradingCalendar.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_UserConnect, UserConnect.class)); + businessObjectAndBusinessEventForCheckMapStores.add(new BusinessObjectAndBusinessEventForCheckMapStore<>(IMDGDistributedNames.Map_User, User.class)); - public static Map createClassByMapStoreName() { - return Collections.unmodifiableMap( - new HashMap() {{ - objectForCheckMapStores.forEach(objectForCheckMapStore -> { - put(objectForCheckMapStore.getMapName(), objectForCheckMapStore.getClazz()); - }); - }} - ); + //dictionary + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountStatusDictionary, AccountStatusDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_AccountTypeDictionary, AccountTypeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_AllowedDictionary, AllowedDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_BalanceAccountTypeDictionary, BalanceAccountTypeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ChargeDirectionDictionary, ChargeDirectionDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ClearingStatusDictionary, ClearingStatusDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CompanyRoleDictionary, CompanyRoleDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CompanySymbolDictionary, CompanySymbolDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ConnectionStateDictionary, ConnectionStateDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_ContactTypeDictionary, ContactTypeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CorporationSoleTypeDictionary, CorporationSoleTypeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CountryCodeDictionary, CountryCodeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CourierTypeDictionary, CourierTypeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class)); + dictionaryObjectForCheckMapStores.add(new DictionaryObjectForCheckMapStore<>(IMDGDistributedNames.Map_DocumentTypeDictionary, DocumentTypeDictionary.class)); } - - public static Map createMapStoreNameByClass() { - return Collections.unmodifiableMap( - new HashMap() {{ - objectForCheckMapStores.forEach(objectForCheckMapStore -> { - put(objectForCheckMapStore.getClazz(), objectForCheckMapStore.getMapName()); - }); - }} - ); - } - } diff --git a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/utils/DbDataUtils.java b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/utils/DbDataUtils.java index d3ddbb8f6..7e98a96c5 100644 --- a/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/utils/DbDataUtils.java +++ b/clearing-parent/imdg/src/test/ru/spcex/clearing/imdg/utils/DbDataUtils.java @@ -1,7 +1,6 @@ package ru.spcex.clearing.imdg.utils; -import com.hazelcast.config.Config; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +10,6 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.math.BigDecimal; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Instant; import java.time.LocalDate; @@ -20,16 +18,11 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.createClassByMapStoreName; -import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.createMapStoreNameByClass; - /** * Утилитарный класс для работы с embedded базой. * Так же используется для заполнения значений классов для подготовки вставки в базу */ public final class DbDataUtils { - public final static Map classByMapStoreName = createClassByMapStoreName(); - public final static Map mapStoreNameByClass = createMapStoreNameByClass(); private static final Logger log = LoggerFactory.getLogger(DbDataUtils.class); /** * Паттерн который проверяет что исполняемый скрипт пересоздает таблицу (recreate table * (*)) @@ -232,40 +225,4 @@ public final class DbDataUtils { throw new RuntimeException(e); } } - - public static void setFieldDefaultValue(Field field, Object object, String value) { - Logger log = LoggerFactory.getLogger(DbDataUtils.class); - if (value == null || value.equals("null")) - return; - Class typeField = field.getType(); - try { - if (typeField.getName().equals(String.class.getName())) { - field.set(object, value); - } else if (typeField.equals(Integer.TYPE) || typeField.equals(Integer.class)) { - field.set(object, Integer.valueOf(value)); - } else if (typeField.getName().equals(BigDecimal.class.getName())) { - field.set(object, new BigDecimal(value)); - } else if (typeField.equals(Long.TYPE) || typeField.equals(Long.class)) { - field.set(object, Long.valueOf(value)); - } else if (typeField.getName().equals(Date.class.getName())) { - field.set(object, SIMPLE_DATE_FORMAT.parse(value)); - } else if (typeField.getName().equals(Boolean.class.getName())) { - field.set(object, Boolean.valueOf(value)); - } - } catch (IllegalAccessException e) { - log.info(e.getMessage()); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - public static List> setImplementsClasses(Config hazelcastConfig) { - List> mapStoreClasses = new ArrayList<>(); - for (String mapName : hazelcastConfig.getMapConfigs().keySet()) { - Class clazz = classByMapStoreName.get(mapName); - if (clazz != null) - mapStoreClasses.add(clazz); - } - return mapStoreClasses; - } }