diff --git a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/IMDGApplication.java b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/IMDGApplication.java index b80d8ce63..6b0c77f97 100644 --- a/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/IMDGApplication.java +++ b/clearing-parent/imdg/src/main/java/ru/spcex/clearing/imdg/IMDGApplication.java @@ -6,6 +6,17 @@ import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.ConfigurableApplicationContext; +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 java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; @SpringBootApplication public class IMDGApplication { @@ -14,12 +25,35 @@ public class IMDGApplication { try { SpringApplicationBuilder builder = new SpringApplicationBuilder(IMDGApplication.class); ConfigurableApplicationContext configurableApplicationContext = builder.run(args); + + List nameTables = new ArrayList<>(); + Connection jdbcConnection = DriverManager.getConnection("jdbc:postgresql://10.200.200.133:5432/postgres", "clearing", "Aa111111"); + DatabaseMetaData md = jdbcConnection.getMetaData(); + ResultSet rs = md.getTables(null, "clearing", "%", new String[]{"TABLE"}); + while (rs.next()) { + nameTables.add(rs.getString(3)); + } + HazelcastInstance hazelcastInstance = configurableApplicationContext.getBean(HazelcastInstance.class); hazelcastInstance.getMap(""); for (String mapName : hazelcastInstance.getConfig().getMapConfigs().keySet()) { MapStoreConfig mapStoreConfig = hazelcastInstance.getConfig().getMapConfig(mapName).getMapStoreConfig(); Object mapStore = mapStoreConfig.getImplementation(); + String tableName = mapStore == null ? "Не получилось сопоставить mapStore: is null" : "Не получилось сопоставить: " + mapStore.getClass() + " с таблицей"; + if (mapStore instanceof TemplateMapStore) { + tableName = ((TemplateMapStore) mapStore).getTableName(); + } else if (mapStore instanceof DictionaryMapStore) { + tableName = ((DictionaryMapStore) mapStore).getTableName(); + } else if (mapStore instanceof TemplateEventMapStore) { + tableName = ((TemplateEventMapStore) mapStore).getTableName(); + } else if (mapStore instanceof BusinessObjectMapStore) { + tableName = ((BusinessObjectMapStore) mapStore).getTableName(); + } else if (mapName.equals("default")) { + continue; + } + nameTables.remove(tableName.toLowerCase()); } + nameTables.forEach(System.out::println); } catch (Throwable e) { LoggerFactory.getLogger(IMDGApplication.class).error("STORAGE start failed: {} -> {}", e.getClass().getSimpleName(), e.getMessage());