IMDG refactoring
This commit is contained in:
parent
8066e6f270
commit
601417b833
8 changed files with 102 additions and 21 deletions
|
|
@ -0,0 +1,12 @@
|
|||
package ru.clearing.platform.dictionary;
|
||||
|
||||
/**
|
||||
* Справочник статусов возваращения процентов
|
||||
*
|
||||
* Dictionary DB table: INTEREST_STATUS_DICTIONARY
|
||||
**/
|
||||
public class InterestStatusDictionary extends AbstractDictionary {
|
||||
private static final long serialVersionUID = ConstDictionarySerializable.serialVersionUID;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,17 @@
|
|||
package ru.spcex.clearing.imdg.base;
|
||||
|
||||
public interface AutoconfiguredMap {
|
||||
import com.hazelcast.core.MapLoader;
|
||||
|
||||
public interface AutoconfiguredMap<T> extends MapLoader<Long, T> {
|
||||
/**
|
||||
*
|
||||
* @return IMDGDistributedNames.*
|
||||
*/
|
||||
String getMapName();
|
||||
|
||||
/**
|
||||
* Список индексируемых полей, для быстрого поиска
|
||||
* @return
|
||||
*/
|
||||
String[] getIndexingField();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.clearing.imdg.base;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.platform.dictionary.Dictionary;
|
||||
|
||||
/**
|
||||
* Store для автонастраиваемых map словарей
|
||||
*/
|
||||
public abstract class DictionaryTMapStore<T extends Dictionary> extends DictionaryMapStore<T> implements AutoconfiguredMap<T> {
|
||||
protected DictionaryTMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIndexingField() {
|
||||
return new String[]{"code"};
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import java.util.*;
|
|||
* MapStore для шаблонных бизнес-объектов
|
||||
* @Component
|
||||
*/
|
||||
public abstract class TemplateMapStore<T extends SpcexObjectBase> extends ObjectBaseMapStore<T> implements AutoconfiguredMap {
|
||||
public abstract class TemplateMapStore<T extends SpcexObjectBase> extends ObjectBaseMapStore<T> implements AutoconfiguredMap<T> {
|
||||
|
||||
protected final int validateSize = getFields().length;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ 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.base.TemplateMapStore;
|
||||
import ru.spcex.clearing.imdg.base.AutoconfiguredMap;
|
||||
import ru.spcex.clearing.imdg.base.DictionaryTMapStore;
|
||||
import ru.spcex.clearing.imdg.businessevent.CompanyUpdateMapStore;
|
||||
import ru.spcex.clearing.imdg.businessobject.CompanyMapStore;
|
||||
import ru.spcex.clearing.imdg.dictionary.*;
|
||||
|
|
@ -145,31 +146,39 @@ public class PoolMapConfigs {
|
|||
// }
|
||||
|
||||
@Autowired
|
||||
private List<TemplateMapStore<?>> listOfAutopluginStores;
|
||||
private List<AutoconfiguredMap<?>> listOfAutopluginStores;
|
||||
|
||||
// @Qualifier("AutoconfiguredMapStore")
|
||||
public List<MapConfig> autoconfiguratorOfMapstorages() {
|
||||
List<MapConfig> out = new ArrayList<>();
|
||||
HashSet<String> existMapStores = new HashSet<>();
|
||||
for (TemplateMapStore<?> mapStore : listOfAutopluginStores) {
|
||||
log.debug("Link mapstore {} to map {}", mapStore.toString(), mapStore.getMapName());
|
||||
if (StringUtils.isEmpty(mapStore.getMapName())) {
|
||||
throw new IllegalArgumentException("MapStore " + mapStore + " has empty mapName");
|
||||
}
|
||||
if (existMapStores.contains(mapStore.getMapName())) {
|
||||
throw new IllegalArgumentException("MapStore " + mapStore + " has wrong mapName=\"" + mapStore.getMapName() + "\" is duplicated");
|
||||
}
|
||||
existMapStores.add(mapStore.getMapName()); // IMDGDistributedNames
|
||||
MapConfig mapCfg = makeDefaultMapConfig(mapStore.getMapName(), mapStore);
|
||||
if (mapStore.getIndexingField() != null && mapStore.getIndexingField().length > 0) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Create indexing filed on {}: {}", mapStore.getMapName(), Arrays.toString(mapStore.getIndexingField()));
|
||||
for (AutoconfiguredMap<?> mapStore : listOfAutopluginStores) {
|
||||
try {
|
||||
log.debug("Link mapstore {} to map {}", mapStore.toString(), mapStore.getMapName());
|
||||
if (StringUtils.isEmpty(mapStore.getMapName())) {
|
||||
throw new IllegalArgumentException("MapStore " + mapStore + " has empty mapName");
|
||||
}
|
||||
for (String indexName : mapStore.getIndexingField()) {
|
||||
mapCfg.addMapIndexConfig(makeMapIndexConfig(indexName));
|
||||
if (existMapStores.contains(mapStore.getMapName())) {
|
||||
throw new IllegalArgumentException("MapStore " + mapStore + " has wrong mapName=\"" + mapStore.getMapName() + "\" is duplicated");
|
||||
}
|
||||
existMapStores.add(mapStore.getMapName()); // IMDGDistributedNames
|
||||
MapConfig mapCfg = makeDefaultMapConfig(mapStore.getMapName(), mapStore);
|
||||
if (mapStore.getIndexingField() != null && mapStore.getIndexingField().length > 0) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("Create indexing filed on {}: {}", mapStore.getMapName(), Arrays.toString(mapStore.getIndexingField()));
|
||||
}
|
||||
for (String indexName : mapStore.getIndexingField()) {
|
||||
mapCfg.addMapIndexConfig(makeMapIndexConfig(indexName));
|
||||
}
|
||||
}
|
||||
if (mapStore instanceof DictionaryTMapStore) {
|
||||
log.trace("Use near cache for {}", mapStore.getMapName());
|
||||
mapCfg.setNearCacheConfig(makeDefaultNearCacheConfig());
|
||||
}
|
||||
out.add(mapCfg);
|
||||
} catch (RuntimeException e) {
|
||||
throw new RuntimeException("Can not configure MapStore " + mapStore.getMapName() + "(" + mapStore.toString() + "): " + e, e);
|
||||
}
|
||||
out.add(mapCfg);
|
||||
}
|
||||
log.debug("Configured {} mapStore's", out.size());
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.imdg.dictionary;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.platform.dictionary.InterestStatusDictionary;
|
||||
import ru.spcex.clearing.imdg.base.DictionaryTMapStore;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
@Component
|
||||
public class InterestStatusDictionaryMapStore extends DictionaryTMapStore<InterestStatusDictionary> {
|
||||
|
||||
public InterestStatusDictionaryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return IMDGDistributedNames.Map_InterestStatusDictionary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return "INTEREST_STATUS_DICTIONARY";
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterestStatusDictionary getDictionaryObject() {
|
||||
return new InterestStatusDictionary();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ public class DbUtilsHelperTest {
|
|||
String sql = DbUtilsHelper.createUpdateOrInsert("ENERGY",
|
||||
new String[]{"id", "power", "circle", "of", "fantasy", "prime"}, "id");
|
||||
assertEquals(sql,
|
||||
"INSERT INTO ENERGY (\"ID\", \"POWER\", \"CIRCLE\", \"OF\", \"FANTASY\", \"PRIME\") values (?, ?, ?, ?, ?, ?) ON CONFLICT (ID) DO UPDATE SET \"POWER\"=EXCLUDED.\"POWER\", \"CIRCLE\"=EXCLUDED.\"CIRCLE\", \"OF\"=EXCLUDED.\"OF\", \"FANTASY\"=EXCLUDED.\"FANTASY\", \"PRIME\"=EXCLUDED.\"PRIME\""
|
||||
"INSERT INTO ENERGY (ID, POWER, CIRCLE, OF, FANTASY, PRIME) values (?, ?, ?, ?, ?, ?) ON CONFLICT (ID) DO UPDATE SET POWER=EXCLUDED.POWER, CIRCLE=EXCLUDED.CIRCLE, OF=EXCLUDED.OF, FANTASY=EXCLUDED.FANTASY, PRIME=EXCLUDED.PRIME"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ public final class IMDGDistributedNames {
|
|||
public static final String Map_Contact = "Map_Contact";
|
||||
public static final String Map_ProfileDocument = "Map_ProfileDocument";
|
||||
|
||||
public static final String Map_InterestStatusDictionary = "Map_InterestStatusDictionary";
|
||||
public static final String Map_AllowedDictionary = "Map_AllowedDictionary";
|
||||
public static final String Map_ClearingMemberCategoryDictionary = "Map_ClearingMemberCategoryDictionary";
|
||||
public static final String Map_CompanyRoleDictionary = "Map_CompanyRoleDictionary";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue