Added tests for businessobject MapStore
This commit is contained in:
parent
adca2cdd1a
commit
2e4107e461
28 changed files with 5107 additions and 212 deletions
|
|
@ -17,18 +17,6 @@ public class AccountBackendGetAll extends BasicSpcexResponse {
|
|||
@ApiModelProperty(value = "Полезная нагрузка")
|
||||
private AccountBackendPayload payload = new AccountBackendPayload();
|
||||
|
||||
private static class AccountBackendPayload {
|
||||
private List<AccountBackendGetFields> items = new ArrayList<>();
|
||||
|
||||
public List<AccountBackendGetFields> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<AccountBackendGetFields> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
||||
public AccountBackendPayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
|
@ -45,7 +33,7 @@ public class AccountBackendGetAll extends BasicSpcexResponse {
|
|||
singleItem.setAccount(account.getAccount());
|
||||
singleItem.setAccountType(account.getAccountType());
|
||||
singleItem.setRelationId(account.getRelationId());
|
||||
singleItem.setStatus(account.getStatus());
|
||||
singleItem.setStatus(account.getAccountStatus());
|
||||
singleItem.setProcessingSign(account.getProcessingSign());
|
||||
singleItem.setCreated(account.getCreated());
|
||||
singleItem.setUpdated(account.getUpdated());
|
||||
|
|
@ -53,4 +41,16 @@ public class AccountBackendGetAll extends BasicSpcexResponse {
|
|||
}
|
||||
}
|
||||
|
||||
private static class AccountBackendPayload {
|
||||
private List<AccountBackendGetFields> items = new ArrayList<>();
|
||||
|
||||
public List<AccountBackendGetFields> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<AccountBackendGetFields> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ public class Account extends BusinessObject {
|
|||
private String account;
|
||||
private String accountType;
|
||||
private Long relationId;
|
||||
private String status;
|
||||
private String accountStatus;
|
||||
private String processingSign;
|
||||
|
||||
public String getAccount() {
|
||||
|
|
@ -41,12 +41,12 @@ public class Account extends BusinessObject {
|
|||
this.relationId = value;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
public String getAccountStatus() {
|
||||
return accountStatus;
|
||||
}
|
||||
|
||||
public void setStatus(String value) {
|
||||
this.status = value;
|
||||
public void setAccountStatus(String value) {
|
||||
this.accountStatus = value;
|
||||
}
|
||||
|
||||
public String getProcessingSign() {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class AccountBalance extends BusinessObject {
|
|||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
private Long companyId;
|
||||
private Long accountId;
|
||||
private Long accountType;
|
||||
private String accountType;
|
||||
private String account;
|
||||
private BigDecimal openBalanceAmount;
|
||||
private BigDecimal startBalanceAmount;
|
||||
|
|
@ -49,11 +49,11 @@ public class AccountBalance extends BusinessObject {
|
|||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public Long getAccountType() {
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(Long accountType) {
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package ru.clearing.classes.statics.data.company.relation;
|
|||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
/**
|
||||
* Договорные отношения
|
||||
|
|
@ -15,8 +14,8 @@ public class Relation extends BusinessObject {
|
|||
private Long consumerId;
|
||||
private Long supplierId;
|
||||
private String serviceStatus;
|
||||
private Long service;
|
||||
private Long serviceProduct;
|
||||
private String service;
|
||||
private String serviceProduct;
|
||||
private String comment;
|
||||
|
||||
public Long getConsumerId() {
|
||||
|
|
@ -43,19 +42,19 @@ public class Relation extends BusinessObject {
|
|||
this.serviceStatus = value;
|
||||
}
|
||||
|
||||
public Long getService() {
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Long value) {
|
||||
public void setService(String value) {
|
||||
this.service = value;
|
||||
}
|
||||
|
||||
public Long getServiceProduct() {
|
||||
public String getServiceProduct() {
|
||||
return serviceProduct;
|
||||
}
|
||||
|
||||
public void setServiceProduct(Long value) {
|
||||
public void setServiceProduct(String value) {
|
||||
this.serviceProduct = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package ru.clearing.classes.statics.data.messages;
|
|||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Полные тексты ошибок
|
||||
|
|
@ -16,7 +16,7 @@ public class ErrorText extends BusinessObject {
|
|||
private String errorCode;
|
||||
private String text;
|
||||
private Long userId;
|
||||
private Instant clearingDate;
|
||||
private LocalDate clearingDate;
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
|
|
@ -42,11 +42,11 @@ public class ErrorText extends BusinessObject {
|
|||
this.userId = value;
|
||||
}
|
||||
|
||||
public Instant getClearingDate() {
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package ru.clearing.classes.statics.data.scheduler;
|
|||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* Расписание планировщика
|
||||
|
|
@ -15,8 +15,8 @@ public class Scheduler extends BusinessObject {
|
|||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private String task;
|
||||
private Instant taskTime;
|
||||
private Instant clearingDate;
|
||||
private LocalTime taskTime;
|
||||
private LocalDate clearingDate;
|
||||
private String market;
|
||||
private String taskStatus;
|
||||
private Long securityId;
|
||||
|
|
@ -30,19 +30,19 @@ public class Scheduler extends BusinessObject {
|
|||
this.task = value;
|
||||
}
|
||||
|
||||
public Instant getTaskTime() {
|
||||
public LocalTime getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
public void setTaskTime(Instant value) {
|
||||
public void setTaskTime(LocalTime value) {
|
||||
this.taskTime = value;
|
||||
}
|
||||
|
||||
public Instant getClearingDate() {
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package ru.clearing.classes.statics.data.scheduler;
|
|||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* Постоянное расписание операционного дня
|
||||
|
|
@ -14,7 +14,7 @@ public class Timetable extends BusinessObject {
|
|||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private String task;
|
||||
private Instant taskTime;
|
||||
private LocalTime taskTime;
|
||||
private String taskStatus;
|
||||
|
||||
public String getTask() {
|
||||
|
|
@ -25,11 +25,11 @@ public class Timetable extends BusinessObject {
|
|||
this.task = value;
|
||||
}
|
||||
|
||||
public Instant getTaskTime() {
|
||||
public LocalTime getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
public void setTaskTime(Instant value) {
|
||||
public void setTaskTime(LocalTime value) {
|
||||
this.taskTime = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package ru.clearing.classes.statics.data.scheduler;
|
|||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Торговые и неторговые дни
|
||||
|
|
@ -13,15 +13,15 @@ import java.time.Instant;
|
|||
public class TradingCalendar extends BusinessObject {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Instant clearingDate;
|
||||
private LocalDate clearingDate;
|
||||
private Long companyId;
|
||||
private String tradingStatus;
|
||||
|
||||
public Instant getClearingDate() {
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import ru.clearing.classes.ConstSerializable;
|
|||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Денежные средства от расчетной организации
|
||||
|
|
@ -16,16 +16,16 @@ public class Statement extends BusinessObject {
|
|||
|
||||
private Long addresseeId;
|
||||
private Long senderId;
|
||||
private Instant clearingDate;
|
||||
private Long statementTypeId;
|
||||
private LocalDate clearingDate;
|
||||
private String statementType;
|
||||
private String comment;
|
||||
private Long accountId;
|
||||
private Long account;
|
||||
private Long inOutDirection;
|
||||
private Instant settlementDate;
|
||||
private String account;
|
||||
private String inOutDirection;
|
||||
private LocalDate settlementDate;
|
||||
private BigDecimal amount;
|
||||
private String cashMovementCurrencyCode;
|
||||
private String status;
|
||||
private String operationStatus;
|
||||
private String errorCode;
|
||||
private String errorText;
|
||||
private Long inSDfId;
|
||||
|
|
@ -48,20 +48,20 @@ public class Statement extends BusinessObject {
|
|||
this.senderId = value;
|
||||
}
|
||||
|
||||
public Instant getClearingDate() {
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
public Long getStatementTypeId() {
|
||||
return statementTypeId;
|
||||
public String getStatementType() {
|
||||
return statementType;
|
||||
}
|
||||
|
||||
public void setStatementTypeId(Long value) {
|
||||
this.statementTypeId = value;
|
||||
public void setStatementType(String value) {
|
||||
this.statementType = value;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
|
|
@ -80,27 +80,27 @@ public class Statement extends BusinessObject {
|
|||
this.accountId = value;
|
||||
}
|
||||
|
||||
public Long getAccount() {
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Long value) {
|
||||
public void setAccount(String value) {
|
||||
this.account = value;
|
||||
}
|
||||
|
||||
public Long getInOutDirection() {
|
||||
public String getInOutDirection() {
|
||||
return inOutDirection;
|
||||
}
|
||||
|
||||
public void setInOutDirection(Long value) {
|
||||
public void setInOutDirection(String value) {
|
||||
this.inOutDirection = value;
|
||||
}
|
||||
|
||||
public Instant getSettlementDate() {
|
||||
public LocalDate getSettlementDate() {
|
||||
return settlementDate;
|
||||
}
|
||||
|
||||
public void setSettlementDate(Instant value) {
|
||||
public void setSettlementDate(LocalDate value) {
|
||||
this.settlementDate = value;
|
||||
}
|
||||
|
||||
|
|
@ -120,12 +120,12 @@ public class Statement extends BusinessObject {
|
|||
this.cashMovementCurrencyCode = value;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
public String getOperationStatus() {
|
||||
return operationStatus;
|
||||
}
|
||||
|
||||
public void setStatus(String value) {
|
||||
this.status = value;
|
||||
public void setOperationStatus(String value) {
|
||||
this.operationStatus = value;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package ru.clearing.classes.statics.data.user;
|
|||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Активность пользователей в системе
|
||||
|
|
@ -20,8 +20,8 @@ public class UserConnect extends BusinessObject {
|
|||
private String serverIP;
|
||||
private String clientIP;
|
||||
private String connectionState;
|
||||
private Instant clearingDate;
|
||||
private String errorCode;
|
||||
private LocalDate clearingDate;
|
||||
private Long errorCode;
|
||||
private String errorText;
|
||||
|
||||
public Long getUserId() {
|
||||
|
|
@ -72,19 +72,19 @@ public class UserConnect extends BusinessObject {
|
|||
this.connectionState = value;
|
||||
}
|
||||
|
||||
public Instant getClearingDate() {
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
public void setClearingDate(Instant value) {
|
||||
public void setClearingDate(LocalDate value) {
|
||||
this.clearingDate = value;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
public Long getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String value) {
|
||||
public void setErrorCode(Long value) {
|
||||
this.errorCode = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,69 +1,15 @@
|
|||
package ru.spcex.clearing.imdg;
|
||||
|
||||
import com.hazelcast.config.MapStoreConfig;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
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 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
SpringApplicationBuilder builder = new SpringApplicationBuilder(IMDGApplication.class);
|
||||
ConfigurableApplicationContext configurableApplicationContext = builder.run(args);
|
||||
|
||||
//Поиск таблиц которым нужно добавить mapStore и вывод результата в консоль
|
||||
List<String> 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;
|
||||
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;
|
||||
} else {
|
||||
System.out.println(mapStore == null ? "Не получилось сопоставить mapStore: is null" : "Не получилось сопоставить: " + mapStore.getClass() + " с таблицей");
|
||||
continue;
|
||||
}
|
||||
nameTables.remove(tableName.toLowerCase());
|
||||
}
|
||||
System.out.println("** Результата поиска таблиц которым нужно добавить mapStore **");
|
||||
nameTables.forEach(System.out::println);
|
||||
System.out.println("**************************************************************");
|
||||
} catch (Throwable e) {
|
||||
LoggerFactory.getLogger(IMDGApplication.class).error("STORAGE start failed: {} -> {}", e.getClass().getSimpleName(), e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
SpringApplicationBuilder builder = new SpringApplicationBuilder(IMDGApplication.class);
|
||||
ConfigurableApplicationContext configurableApplicationContext = builder.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ public class AccountHistoryMapStore extends TemplateEventMapStore<AccountHistory
|
|||
|
||||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{"ID","EVENT_TIME", "EVENT_USER_ID",
|
||||
"ACCOUNT_ID", "CREATED_AT", "UPDATED_AT", "ACCOUNT", "ACCOUNT_TYPE", "RELATION_ID", "STATUS", "PROCESSING_SIGN"
|
||||
return new String[]{"ID", "EVENT_TIME", "EVENT_USER_ID",
|
||||
"ACCOUNT_ID", "CREATED_AT", "UPDATED_AT", "ACCOUNT", "ACCOUNT_TYPE", "RELATION_ID", "STATUS", "PROCESSING_SIGN"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] objectToField(AccountHistory updateLog) {
|
||||
Account object=updateLog.getObject();
|
||||
Account object = updateLog.getObject();
|
||||
Object[] args = new Object[]{
|
||||
updateLog.getId(),
|
||||
updateLog.getEventTime(),
|
||||
|
|
@ -46,7 +46,7 @@ public class AccountHistoryMapStore extends TemplateEventMapStore<AccountHistory
|
|||
object.getAccount(),
|
||||
object.getAccountType(),
|
||||
object.getRelationId(),
|
||||
object.getStatus(),
|
||||
object.getAccountStatus(),
|
||||
object.getProcessingSign()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class UserConnectHistoryMapStore extends TemplateEventMapStore<UserConnec
|
|||
UserConnect object = historyLog.getObject();
|
||||
Object[] args = new Object[]{
|
||||
historyLog.getId(),
|
||||
historyLog.getEventTime(),
|
||||
TimeUtil.toDateFromInstant(historyLog.getEventTime()),
|
||||
historyLog.getUserId(),
|
||||
|
||||
object.getId(),
|
||||
|
|
@ -49,7 +49,7 @@ public class UserConnectHistoryMapStore extends TemplateEventMapStore<UserConnec
|
|||
object.getServerIP(),
|
||||
object.getClientIP(),
|
||||
object.getConnectionState(),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate()),
|
||||
object.getErrorCode(),
|
||||
object.getErrorText()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ public class AccountBalanceMapStore extends TemplateMapStore<AccountBalance> {
|
|||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setAccountId(resultSet.getObject("ACCOUNT_ID", Long.class));
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", Long.class));
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", String.class));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setOpenBalanceAmount(resultSet.getObject("OPEN_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setStartBalanceAmount(resultSet.getObject("START_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setCloseBalanceAmount(resultSet.getObject("CLOSE_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setTradeBalanceAmount(resultSet.getObject("TRADE_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setFreeBalanceAmount(resultSet.getObject("FREE_BALANCE_AMOU", BigDecimal.class));
|
||||
object.setFreeBalanceAmount(resultSet.getObject("FREE_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setChangeBalanceAmount(resultSet.getObject("CHANGE_BALANCE_AMOUNT", BigDecimal.class));
|
||||
object.setCreditAmount(resultSet.getObject("CREDIT_AMOUNT", BigDecimal.class));
|
||||
object.setDebitAmount(resultSet.getObject("DEBIT_AMOUNT", BigDecimal.class));
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class AccountMapStore extends TemplateMapStore<Account> {
|
|||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "ACCOUNT", "ACCOUNT_TYPE", "RELATION_ID", "STATUS", "PROCESSING_SIGN"
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "ACCOUNT", "ACCOUNT_TYPE", "RELATION_ID", "ACCOUNT_STATUS", "PROCESSING_SIGN"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ public class AccountMapStore extends TemplateMapStore<Account> {
|
|||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setAccountType(resultSet.getObject("ACCOUNT_TYPE", String.class));
|
||||
object.setRelationId(resultSet.getObject("RELATION_ID", Long.class));
|
||||
object.setStatus(resultSet.getObject("STATUS", String.class));
|
||||
object.setAccountStatus(resultSet.getObject("ACCOUNT_STATUS", String.class));
|
||||
object.setProcessingSign(resultSet.getObject("PROCESSING_SIGN", String.class));
|
||||
return object;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class AccountMapStore extends TemplateMapStore<Account> {
|
|||
object.getAccount(),
|
||||
object.getAccountType(),
|
||||
object.getRelationId(),
|
||||
object.getStatus(),
|
||||
object.getAccountStatus(),
|
||||
object.getProcessingSign()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class ErrorTextMapStore extends TemplateMapStore<ErrorText> {
|
|||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "ERROR_CODE", "TEXT", "USER_ID", "CLEARING_DATE"
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "ERROR_CODE", "TEXT", "USER_ID", "CLEARING_DATE"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ public class ErrorTextMapStore extends TemplateMapStore<ErrorText> {
|
|||
object.setErrorCode(resultSet.getObject("ERROR_CODE", String.class));
|
||||
object.setText(resultSet.getObject("TEXT", String.class));
|
||||
object.setUserId(resultSet.getObject("USER_ID", Long.class));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setClearingDate(getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class ErrorTextMapStore extends TemplateMapStore<ErrorText> {
|
|||
object.getErrorCode(),
|
||||
object.getText(),
|
||||
object.getUserId(),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate())
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate())
|
||||
};
|
||||
return args;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class RelationMapStore extends TemplateMapStore<Relation> {
|
|||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "CONSUMER_ID", "SUPPLIER_ID", "SERVICE_STATUS", "SERVICE", "SERVICE_PRODUCT", "COMMENT"
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "CONSUMER_ID", "SUPPLIER_ID", "SERVICE_STATUS", "SERVICE", "SERVICE_PRODUCT", "COMMENT"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -38,14 +38,14 @@ public class RelationMapStore extends TemplateMapStore<Relation> {
|
|||
public Relation objectReader(ResultSet resultSet) throws SQLException {
|
||||
Relation object = new Relation();
|
||||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setConsumerId(resultSet.getObject("CONSUMER_ID", Long.class));
|
||||
object.setSupplierId(resultSet.getObject("SUPPLIER_ID", Long.class));
|
||||
object.setServiceStatus(resultSet.getObject("SERVICE_STATUS", String.class));
|
||||
object.setService(resultSet.getObject("SERVICE", Long.class));
|
||||
object.setServiceProduct(resultSet.getObject("SERVICE_PRODUCT", Long.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setConsumerId(resultSet.getObject("CONSUMER_ID", Long.class));
|
||||
object.setSupplierId(resultSet.getObject("SUPPLIER_ID", Long.class));
|
||||
object.setServiceStatus(resultSet.getObject("SERVICE_STATUS", String.class));
|
||||
object.setService(resultSet.getObject("SERVICE", String.class));
|
||||
object.setServiceProduct(resultSet.getObject("SERVICE_PRODUCT", String.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public class SchedulerMapStore extends TemplateMapStore<Scheduler> {
|
|||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setTask(resultSet.getObject("TASK", String.class));
|
||||
object.setTaskTime(getInstantFromTimestamp(resultSet, "TASK_TIME"));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setTaskTime(getLocalTimeFromSqlTime(resultSet, "TASK_TIME"));
|
||||
object.setClearingDate(getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setMarket(resultSet.getObject("MARKET", String.class));
|
||||
object.setTaskStatus(resultSet.getObject("TASK_STATUS", String.class));
|
||||
object.setSecurityId(resultSet.getObject("SECURITY_ID", Long.class));
|
||||
|
|
@ -56,8 +56,8 @@ public class SchedulerMapStore extends TemplateMapStore<Scheduler> {
|
|||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getTask(),
|
||||
TimeUtil.toDateFromInstant(object.getTaskTime()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromLocalTime(object.getTaskTime()),
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate()),
|
||||
object.getMarket(),
|
||||
object.getTaskStatus(),
|
||||
object.getSecurityId()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class StatementMapStore extends TemplateMapStore<Statement> {
|
|||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "ADDRESSEE_ID", "SENDER_ID", "CREATED_AT", "UPDATED_AT", "CLEARING_DATE", "STATEMENT_TYPE_ID", "COMMENT", "ACCOUNT_ID", "ACCOUNT", "IN_OUT_DIRECTION", "SETTLEMENT_DATE", "AMOUNT", "CASH_MOVEMENT_CURRENCY_CODE", "STATUS", "ERROR_CODE", "ERROR_TEXT", "IN_S_DF_ID", "OUT_S_DF_ID", "IN_OUT_S_DF_TYPE"
|
||||
"ID", "ADDRESSEE_ID", "SENDER_ID", "CREATED_AT", "UPDATED_AT", "CLEARING_DATE", "STATEMENT_TYPE", "COMMENT", "ACCOUNT_ID", "ACCOUNT", "IN_OUT_DIRECTION", "SETTLEMENT_DATE", "AMOUNT", "CASH_MOVEMENT_CURRENCY_CODE", "OPERATION_STATUS", "ERROR_CODE", "ERROR_TEXT", "IN_S_DF_ID", "OUT_S_DF_ID", "IN_OUT_S_DF_TYPE"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -43,16 +43,16 @@ public class StatementMapStore extends TemplateMapStore<Statement> {
|
|||
object.setSenderId(resultSet.getObject("SENDER_ID", Long.class));
|
||||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setStatementTypeId(resultSet.getObject("STATEMENT_TYPE_ID", Long.class));
|
||||
object.setClearingDate(getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setStatementType(resultSet.getObject("STATEMENT_TYPE", String.class));
|
||||
object.setComment(resultSet.getObject("COMMENT", String.class));
|
||||
object.setAccountId(resultSet.getObject("ACCOUNT_ID", Long.class));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", Long.class));
|
||||
object.setInOutDirection(resultSet.getObject("IN_OUT_DIRECTION", Long.class));
|
||||
object.setSettlementDate(getInstantFromTimestamp(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setAccount(resultSet.getObject("ACCOUNT", String.class));
|
||||
object.setInOutDirection(resultSet.getObject("IN_OUT_DIRECTION", String.class));
|
||||
object.setSettlementDate(getLocalDateFromSqlDate(resultSet, "SETTLEMENT_DATE"));
|
||||
object.setAmount(resultSet.getObject("AMOUNT", BigDecimal.class));
|
||||
object.setCashMovementCurrencyCode(resultSet.getObject("CASH_MOVEMENT_CURRENCY_CODE", String.class));
|
||||
object.setStatus(resultSet.getObject("STATUS", String.class));
|
||||
object.setOperationStatus(resultSet.getObject("OPERATION_STATUS", String.class));
|
||||
object.setErrorCode(resultSet.getObject("ERROR_CODE", String.class));
|
||||
object.setErrorText(resultSet.getObject("ERROR_TEXT", String.class));
|
||||
object.setInSDfId(resultSet.getObject("IN_S_DF_ID", Long.class));
|
||||
|
|
@ -69,16 +69,16 @@ public class StatementMapStore extends TemplateMapStore<Statement> {
|
|||
object.getSenderId(),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
object.getStatementTypeId(),
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate()),
|
||||
object.getStatementType(),
|
||||
object.getComment(),
|
||||
object.getAccountId(),
|
||||
object.getAccount(),
|
||||
object.getInOutDirection(),
|
||||
TimeUtil.toDateFromInstant(object.getSettlementDate()),
|
||||
TimeUtil.toDateFromLocalDate(object.getSettlementDate()),
|
||||
object.getAmount(),
|
||||
object.getCashMovementCurrencyCode(),
|
||||
object.getStatus(),
|
||||
object.getOperationStatus(),
|
||||
object.getErrorCode(),
|
||||
object.getErrorText(),
|
||||
object.getInSDfId(),
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class TimetableMapStore extends TemplateMapStore<Timetable> {
|
|||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setTask(resultSet.getObject("TASK", String.class));
|
||||
object.setTaskTime(getInstantFromTimestamp(resultSet, "TASK_TIME"));
|
||||
object.setTaskTime(getLocalTimeFromSqlTime(resultSet, "TASK_TIME"));
|
||||
object.setTaskStatus(resultSet.getObject("TASK_STATUS", String.class));
|
||||
return object;
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class TimetableMapStore extends TemplateMapStore<Timetable> {
|
|||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
object.getTask(),
|
||||
TimeUtil.toDateFromInstant(object.getTaskTime()),
|
||||
TimeUtil.toDateFromLocalTime(object.getTaskTime()),
|
||||
object.getTaskStatus()
|
||||
};
|
||||
return args;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class TradingCalendarMapStore extends TemplateMapStore<TradingCalendar> {
|
|||
@Override
|
||||
public String[] getFields() {
|
||||
return new String[]{
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "CLEARING_DATE", "COMPANY_ID", "TRADING_STATUS"
|
||||
"ID", "CREATED_AT", "UPDATED_AT", "CLEARING_DATE", "COMPANY_ID", "TRADING_STATUS"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class TradingCalendarMapStore extends TemplateMapStore<TradingCalendar> {
|
|||
object.setId(resultSet.getObject("ID", Long.class));
|
||||
object.setCreated(getInstantFromTimestamp(resultSet, "CREATED_AT"));
|
||||
object.setUpdated(getInstantFromTimestamp(resultSet, "UPDATED_AT"));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setClearingDate(getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setCompanyId(resultSet.getObject("COMPANY_ID", Long.class));
|
||||
object.setTradingStatus(resultSet.getObject("TRADING_STATUS", String.class));
|
||||
return object;
|
||||
|
|
@ -52,7 +52,7 @@ public class TradingCalendarMapStore extends TemplateMapStore<TradingCalendar> {
|
|||
object.getId(),
|
||||
TimeUtil.toDateFromInstant(object.getCreated()),
|
||||
TimeUtil.toDateFromInstant(object.getUpdated()),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate()),
|
||||
object.getCompanyId(),
|
||||
object.getTradingStatus()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ public class UserConnectMapStore extends TemplateMapStore<UserConnect> {
|
|||
object.setServerIP(resultSet.getObject("SERVER_I_P", String.class));
|
||||
object.setClientIP(resultSet.getObject("CLIENT_I_P", String.class));
|
||||
object.setConnectionState(resultSet.getObject("CONNECTION_STATE", String.class));
|
||||
object.setClearingDate(getInstantFromTimestamp(resultSet, "CLEARING_DATE"));
|
||||
object.setErrorCode(resultSet.getObject("ERROR_CODE", String.class));
|
||||
object.setClearingDate(getLocalDateFromSqlDate(resultSet, "CLEARING_DATE"));
|
||||
object.setErrorCode(resultSet.getObject("ERROR_CODE", Long.class));
|
||||
object.setErrorText(resultSet.getObject("ERROR_TEXT", String.class));
|
||||
return object;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class UserConnectMapStore extends TemplateMapStore<UserConnect> {
|
|||
object.getServerIP(),
|
||||
object.getClientIP(),
|
||||
object.getConnectionState(),
|
||||
TimeUtil.toDateFromInstant(object.getClearingDate()),
|
||||
TimeUtil.toDateFromLocalDate(object.getClearingDate()),
|
||||
object.getErrorCode(),
|
||||
object.getErrorText()
|
||||
};
|
||||
|
|
|
|||
4834
clearing-parent/imdg/src/test/ddl.sql
Normal file
4834
clearing-parent/imdg/src/test/ddl.sql
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
|||
package ru.spcex.clearing.imdg;
|
||||
|
||||
import com.hazelcast.config.MapStoreConfig;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
import com.hazelcast.core.IMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
|
|
@ -26,6 +27,8 @@ import ru.spcex.platform.classes.base.SpcexObjectBase;
|
|||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.spcex.clearing.imdg.structure.GeneratorMapNamesForHazelcast.objectForCheckMapStores;
|
||||
|
|
@ -59,6 +62,50 @@ public class AllMapStoreTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAllMapStoreCreatedTest() throws SQLException {
|
||||
//Поиск таблиц которым нужно добавить mapStore и вывод результата в консоль
|
||||
List<String> 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_tester", "%", new String[]{"TABLE"});
|
||||
while (rs.next()) {
|
||||
String tableName = rs.getString("TABLE_NAME");
|
||||
//сущности для company_info и company_info_history включены соответсвенно в company и company_history
|
||||
if (tableName.equals("company_info") || tableName.equals("company_info_history")) {
|
||||
continue;
|
||||
}
|
||||
nameTables.add(tableName);
|
||||
}
|
||||
|
||||
HazelcastInstance hazelcastInstance = testConfig.getHazelcastInstance();
|
||||
hazelcastInstance.getMap("");
|
||||
for (String mapName : hazelcastInstance.getConfig().getMapConfigs().keySet()) {
|
||||
MapStoreConfig mapStoreConfig = hazelcastInstance.getConfig().getMapConfig(mapName).getMapStoreConfig();
|
||||
Object mapStore = mapStoreConfig.getImplementation();
|
||||
String tableName;
|
||||
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;
|
||||
} else {
|
||||
System.out.println(mapStore == null ? "Не получилось сопоставить mapStore: is null" : "Не получилось сопоставить: " + mapStore.getClass() + " с таблицей");
|
||||
continue;
|
||||
}
|
||||
nameTables.remove(tableName.toLowerCase());
|
||||
}
|
||||
System.out.println("** Результата поиска таблиц которым нужно добавить mapStore **");
|
||||
nameTables.forEach(System.out::println);
|
||||
System.out.println("**************************************************************");
|
||||
Assertions.assertEquals(0, nameTables.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkSavingForAllMapStoreTest() {
|
||||
saveObjectToMaps();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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.ResourceDatabasePopulator;
|
||||
import ru.spcex.clearing.imdg.error.ModuleInitializeException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
|
@ -16,7 +19,14 @@ import java.sql.Connection;
|
|||
public class DbTestConnectionConfig {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private ConfigurationRootElement configRoot = DfaConfig.get().getRoot();
|
||||
private final ConfigurationRootElement configRoot = DfaConfig.get().getRoot();
|
||||
|
||||
private DatabasePopulator createDatabasePopulator() {
|
||||
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
|
||||
databasePopulator.setContinueOnError(true);
|
||||
databasePopulator.addScript(new ClassPathResource("/ddl.sql"));
|
||||
return databasePopulator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
|
|
@ -24,7 +34,7 @@ public class DbTestConnectionConfig {
|
|||
String login = "clearing";
|
||||
String password = "Aa111111";
|
||||
String logTimeoutPart = "";
|
||||
String dbPath = "jdbc:postgresql://10.200.200.133:5432/postgres";
|
||||
String dbPath = "jdbc:postgresql://10.200.200.133:5432/postgres?currentSchema=clearing_tester";
|
||||
int timeoutSec = configRoot.getDatabase().getConnectionAcquireTimeoutSeconds();
|
||||
|
||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||
|
|
@ -42,6 +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);
|
||||
result = cpds;
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbPath);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,22 @@
|
|||
package ru.spcex.clearing.imdg.structure;
|
||||
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.AccountBalance;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.classes.statics.data.company.relation.Relation;
|
||||
import ru.clearing.classes.statics.data.messages.ErrorText;
|
||||
import ru.clearing.classes.statics.data.scheduler.Scheduler;
|
||||
import ru.clearing.classes.statics.data.scheduler.TaskRunner;
|
||||
import ru.clearing.classes.statics.data.scheduler.Timetable;
|
||||
import ru.clearing.classes.statics.data.scheduler.TradingCalendar;
|
||||
import ru.clearing.classes.statics.data.security.Security;
|
||||
import ru.clearing.classes.statics.data.statement.Statement;
|
||||
import ru.clearing.classes.statics.data.user.User;
|
||||
import ru.clearing.classes.statics.data.user.UserConnect;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.imdg.structure.ObjectForCheckMapStore.SettingOperation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class GeneratorMapNamesForHazelcast {
|
||||
|
|
@ -17,7 +31,22 @@ public class GeneratorMapNamesForHazelcast {
|
|||
private static void init() {
|
||||
objectForCheckMapStores = new LinkedList<>();
|
||||
|
||||
//businessobject
|
||||
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,
|
||||
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));
|
||||
// objectForCheckMapStores.add(new ObjectForCheckMapStore<>(IMDGDistributedNames.Map_UserConnectHistory, UserConnectHistory.class));
|
||||
}
|
||||
|
||||
public static Map<String, Class> createClassByMapStoreName() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ package ru.spcex.clearing.imdg.structure;
|
|||
import ru.spcex.clearing.imdg.utils.MatcherFactory.Matcher;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static ru.spcex.clearing.imdg.utils.MatcherFactory.usingIgnoringFieldsComparator;
|
||||
|
||||
public class ObjectForCheckMapStore<T> {
|
||||
|
|
@ -11,6 +14,7 @@ public class ObjectForCheckMapStore<T> {
|
|||
public final Matcher<T> MATCHER = usingIgnoringFieldsComparator();
|
||||
private final String mapName;
|
||||
private final Class<T> clazz;
|
||||
private SettingOperation settingOperation;
|
||||
|
||||
private SpcexObjectBase predictableObj;
|
||||
|
||||
|
|
@ -19,6 +23,12 @@ public class ObjectForCheckMapStore<T> {
|
|||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public ObjectForCheckMapStore(String mapName, Class<T> clazz, SettingOperation settingOperation) {
|
||||
this.mapName = mapName;
|
||||
this.clazz = clazz;
|
||||
this.settingOperation = settingOperation;
|
||||
}
|
||||
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
}
|
||||
|
|
@ -35,7 +45,35 @@ public class ObjectForCheckMapStore<T> {
|
|||
return predictableObj;
|
||||
}
|
||||
|
||||
public void setPredictableObj(SpcexObjectBase predictableObj) {
|
||||
public void setPredictableObj(SpcexObjectBase predictableObj) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
if (settingOperation != null) {
|
||||
Method method = clazz.getDeclaredMethod(settingOperation.getMethodName(), settingOperation.getParameterTypes());
|
||||
method.invoke(predictableObj, settingOperation.getParams());
|
||||
}
|
||||
this.predictableObj = predictableObj;
|
||||
}
|
||||
|
||||
public static class SettingOperation {
|
||||
private static String methodName;
|
||||
private static Class[] parameterTypes;
|
||||
private static Object[] params;
|
||||
|
||||
public SettingOperation(String methodName, Class[] parameterTypes, Object[] params) {
|
||||
SettingOperation.methodName = methodName;
|
||||
SettingOperation.parameterTypes = parameterTypes;
|
||||
SettingOperation.params = params;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public Class[] getParameterTypes() {
|
||||
return parameterTypes;
|
||||
}
|
||||
|
||||
public Object[] getParams() {
|
||||
return params;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
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;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -196,11 +198,13 @@ public final class DbDataUtils {
|
|||
} else if (typeField.equals(Integer.TYPE) || typeField.equals(Integer.class)) {
|
||||
field.set(object, 0);
|
||||
} else if (typeField.getName().equals(BigDecimal.class.getName())) {
|
||||
field.set(object, BigDecimal.valueOf(23.22));
|
||||
field.set(object, new BigDecimal("23.220000000000000000"));
|
||||
} else if (typeField.equals(Long.TYPE) || typeField.equals(Long.class)) {
|
||||
field.set(object, 0L);
|
||||
field.set(object, 1000000L);
|
||||
} else if (typeField.equals(LocalDate.class)) {
|
||||
field.set(object, LocalDate.of(2017, 11, 11));
|
||||
field.set(object, LocalDate.of(2022, 10, 7));
|
||||
} else if (typeField.equals(LocalTime.class)) {
|
||||
field.set(object, LocalTime.of(19, 0));
|
||||
} else if (typeField.getName().equals(Date.class.getName())) {
|
||||
field.set(object, new Date());
|
||||
} else if (typeField.getName().equals(Boolean.class.getName())) {
|
||||
|
|
@ -209,36 +213,23 @@ public final class DbDataUtils {
|
|||
field.set(object, UUID.randomUUID());
|
||||
} else if (typeField.getName().equals(Instant.class.getName())) {
|
||||
field.set(object, Instant.parse("2022-10-05T15:39:18.659Z"));
|
||||
// } else if (typeField.getSimpleName().equals(BusinessObjectRef.class.getSimpleName())) {
|
||||
// field.set(object, BusinessObjectRef.createFromId(0L, BusinessObject.class));
|
||||
// } else if (typeField.getName().equals(Set.class.getName())) {
|
||||
// Set<BusinessObjectRef> hashSet = new HashSet<>();
|
||||
// hashSet.add(BusinessObjectRef.createFromId(0L, BusinessObject.class));
|
||||
// field.set(object, hashSet);
|
||||
// } else if (typeField.getName().equals(Instant.class.getName())) {
|
||||
// field.set(object, Instant.now());
|
||||
// } else if (typeField.getName().equals(Party.class.getName())) {
|
||||
// Party party = new Party();
|
||||
// fillObjectDefaultValues(party, party.getClass());
|
||||
// field.set(object, party);
|
||||
// } else if (typeField.getName().equals(LegalEntityProfile.class.getName())) {
|
||||
// LegalEntityProfile legalEntityProfile = new LegalEntityProfile();
|
||||
// fillObjectDefaultValues(legalEntityProfile, legalEntityProfile.getClass());
|
||||
// legalEntityProfile.setId(1L);
|
||||
// field.set(object, legalEntityProfile);
|
||||
// } else if (typeField.getSimpleName().equals(CompanyInfo.class.getSimpleName())) {
|
||||
// CompanyInfo companyInfo = new CompanyInfo();
|
||||
// fillObjectDefaultValues(companyInfo, CompanyInfo.class);
|
||||
// field.set(object, companyInfo);
|
||||
// } else if (typeField.getSuperclass().getName().equals(SpcexObjectBase.class.getName())) {
|
||||
// Object objectField = typeField.getDeclaredConstructor().newInstance();
|
||||
// DbDataUtils.fillObjectDefaultValues(objectField, objectField.getClass());
|
||||
// field.set(object, objectField);
|
||||
} else {
|
||||
if (Collection.class.isAssignableFrom(field.getType())) {
|
||||
// ignore List, Set, etc.
|
||||
log.debug("Any collection variable skipped: {}", field.getName());
|
||||
} else if (typeField.getName().equalsIgnoreCase("[Z") && field.getName().equalsIgnoreCase("$jacocoData")) { // Массив объектов в переменной $jacocoData
|
||||
log.debug("Jacoco debug variable skipped: {}", field.getName());
|
||||
} else {
|
||||
log.error("Для данного поля (в объекте " + object.getClass().getName() + "->" + field.getName() + ") значение по умолчению не может быть определенно для типа: " + typeField.getName());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
Object objectField = typeField.getDeclaredConstructor().newInstance();
|
||||
fillObjectDefaultValues(objectField, objectField.getClass());
|
||||
field.set(object, objectField);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.info(e.getMessage());
|
||||
} catch (InvocationTargetException | InstantiationException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue