add history mapstores
This commit is contained in:
parent
fae7a37424
commit
ba438187e5
16 changed files with 258 additions and 43 deletions
|
|
@ -2,12 +2,12 @@ package ru.spcex.clearing.historyimdg.index;
|
|||
|
||||
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithId;
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithTradingDay;
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithTradingDate;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class SearchProxy extends SpcexObjectBase implements SearchWithTradingDay, SearchWithId {
|
||||
public class SearchProxy extends SpcexObjectBase implements SearchWithTradingDate, SearchWithId {
|
||||
private LocalDate tradingDate;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package ru.spcex.clearing.historyimdg.index;
|
||||
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithTradingDate;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class SearchProxyExecutionDeposit extends SearchProxy implements SearchWithTradingDate {
|
||||
private LocalDate tradingDate;
|
||||
|
||||
@Override
|
||||
public LocalDate getTradingDate() {
|
||||
return tradingDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTradingDate(LocalDate tradingDate) {
|
||||
this.tradingDate = tradingDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package ru.spcex.clearing.historyimdg.index;
|
||||
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithCreated;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class SearchProxyMoneyBalanceRegister extends SearchProxy implements SearchWithCreated {
|
||||
private Instant created;
|
||||
|
||||
@Override
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreated(Instant created) {
|
||||
this.created = created;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package ru.spcex.clearing.historyimdg.index;
|
||||
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchWithClearingDate;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class SearchProxyMoneyPaymentInstructionRegister extends SearchProxy implements SearchWithClearingDate {
|
||||
private LocalDate clearingDate;
|
||||
|
||||
@Override
|
||||
public LocalDate getClearingDate() {
|
||||
return clearingDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClearingDate(LocalDate clearingDate) {
|
||||
this.clearingDate = clearingDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package ru.spcex.clearing.historyimdg.index;
|
||||
|
||||
import ru.spcex.clearing.historyimdg.index.field.SearchCompanyId;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class SearchProxyRegistry extends SearchProxy implements SearchCompanyId {
|
||||
private Long companyId;
|
||||
|
||||
@Override
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompanyId(Long companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTradingDate(LocalDate tradingDate) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package ru.spcex.clearing.historyimdg.index.field;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public interface SearchWithClearingDate {
|
||||
LocalDate getClearingDate();
|
||||
|
||||
void setClearingDate(LocalDate value);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package ru.spcex.clearing.historyimdg.index.field;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public interface SearchWithCreated {
|
||||
public Instant getCreated();
|
||||
|
||||
public void setCreated(Instant created);
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package ru.spcex.clearing.historyimdg.index.field;
|
|||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public interface SearchWithTradingDay {
|
||||
public interface SearchWithTradingDate {
|
||||
LocalDate getTradingDate();
|
||||
|
||||
void setTradingDate(LocalDate tradingDate);
|
||||
|
|
@ -11,6 +11,7 @@ import ru.spcex.platform.classes.base.interfaces.WithId;
|
|||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
|
|
@ -90,6 +91,11 @@ public abstract class AbstractSliceMapLoader<T extends WithId> implements Autoco
|
|||
return date != null ? date.toLocalDate() : null;
|
||||
}
|
||||
|
||||
protected Instant getInstantFromTimestamp(ResultSet rs, String column) throws SQLException {
|
||||
Timestamp date = rs.getTimestamp(column);
|
||||
return date != null ? date.toInstant() : null;
|
||||
}
|
||||
|
||||
protected abstract Collection<T> load(Collection<Long> keys);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ package ru.spcex.clearing.historyimdg.mapstores;
|
|||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.registry.Registry;
|
||||
import ru.spcex.clearing.imdg.businessobject.RegistryMapStore;
|
||||
import ru.clearing.classes.statics.data.execution.ExecutionDeposit;
|
||||
import ru.spcex.clearing.imdg.businessobject.ExecutionDepositMapStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Component
|
||||
public class RegistryHistoryMapStore extends RegistryMapStore {
|
||||
public RegistryHistoryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
public class ExecutionDepositHistoryMapStore extends ExecutionDepositMapStore {
|
||||
public ExecutionDepositHistoryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
|
|
@ -19,13 +19,13 @@ public class RegistryHistoryMapStore extends RegistryMapStore {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoadable(Registry obj) {
|
||||
protected boolean isLoadable(ExecutionDeposit obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Long> loadAllKeys() {
|
||||
log.debug("RegistryHistoryMapStore loadAllKeys is called");
|
||||
log.debug("ExecutionDeposit loadAllKeys is called");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.historyimdg.mapstores;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.register.MoneyBalanceRegister;
|
||||
import ru.spcex.clearing.imdg.businessobject.MoneyBalanceRegisterMapStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Component
|
||||
public class MoneyBalanceRegisterHistoryMapStore extends MoneyBalanceRegisterMapStore {
|
||||
public MoneyBalanceRegisterHistoryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoadable(Long id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoadable(MoneyBalanceRegister obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Long> loadAllKeys() {
|
||||
log.debug("MoneyBalanceRegisterHistoryMapStore loadAllKeys is called");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package ru.spcex.clearing.historyimdg.mapstores;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.clearing.classes.statics.data.register.MoneyPaymentInstructionRegister;
|
||||
import ru.spcex.clearing.imdg.businessobject.MoneyPaymentInstructionRegisterMapStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Component
|
||||
public class MoneyPaymentInstructionRegisterHistoryMapStore extends MoneyPaymentInstructionRegisterMapStore {
|
||||
public MoneyPaymentInstructionRegisterHistoryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoadable(Long id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoadable(MoneyPaymentInstructionRegister obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Long> loadAllKeys() {
|
||||
log.debug("MoneyPaymentInstructionRegisterHistoryMapStore loadAllKeys is called");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package ru.spcex.clearing.historyimdg.mapstores;
|
|||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.historyimdg.index.SearchProxyRegistry;
|
||||
import ru.spcex.clearing.historyimdg.index.SearchProxyExecutionDeposit;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -10,36 +10,35 @@ import java.util.Collections;
|
|||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SearchRegistryMapStore extends AbstractSliceMapLoader<SearchProxyRegistry> {
|
||||
public SearchRegistryMapStore(JdbcTemplate jdbcTemplate) {
|
||||
public class SearchExecutionDepositMapStore extends AbstractSliceMapLoader<SearchProxyExecutionDeposit> {
|
||||
public SearchExecutionDepositMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableName() {
|
||||
return "registry";
|
||||
return "execution_deposit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SearchProxyRegistry> load(Collection<Long> keys) {
|
||||
public Collection<SearchProxyExecutionDeposit> load(Collection<Long> keys) {
|
||||
Map<String, Collection<Long>> paramMap = Collections.singletonMap("ids", keys);
|
||||
return namedParameterJdbcTemplate.query("select * from " + getTableName() + " where id in (:ids)", paramMap,
|
||||
(rs, rowNum) -> {
|
||||
SearchProxyRegistry proxyRegistry = new SearchProxyRegistry();
|
||||
SearchProxyExecutionDeposit proxyRegistry = new SearchProxyExecutionDeposit();
|
||||
proxyRegistry.setId(rs.getObject("id", Long.class));
|
||||
proxyRegistry.setTradingDate(getLocalDateFromSqlDate(rs,"trading_date"));
|
||||
proxyRegistry.setCompanyId(rs.getObject("company_id", Long.class));
|
||||
return proxyRegistry;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return IMDGDistributedNames.Map_SearchRegistry;
|
||||
return IMDGDistributedNames.Map_SearchExecutionDeposit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIndexingField() {
|
||||
return new String[]{"companyId"};
|
||||
return new String[]{"tradingDate"};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.historyimdg.mapstores;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.historyimdg.index.SearchProxyMoneyBalanceRegister;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SearchMoneyBalanceRegisterMapStore extends AbstractSliceMapLoader<SearchProxyMoneyBalanceRegister> {
|
||||
public SearchMoneyBalanceRegisterMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableName() {
|
||||
return "money_balance_register";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SearchProxyMoneyBalanceRegister> load(Collection<Long> keys) {
|
||||
Map<String, Collection<Long>> paramMap = Collections.singletonMap("ids", keys);
|
||||
return namedParameterJdbcTemplate.query("select * from " + getTableName() + " where id in (:ids)", paramMap,
|
||||
(rs, rowNum) -> {
|
||||
SearchProxyMoneyBalanceRegister proxyRegistry = new SearchProxyMoneyBalanceRegister();
|
||||
proxyRegistry.setId(rs.getObject("id", Long.class));
|
||||
proxyRegistry.setCreated(getInstantFromTimestamp(rs, "CREATED_AT"));
|
||||
return proxyRegistry;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return IMDGDistributedNames.Map_SearchMoneyBalanceRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIndexingField() {
|
||||
return new String[]{"created"};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package ru.spcex.clearing.historyimdg.mapstores;
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import ru.spcex.clearing.historyimdg.index.SearchProxyMoneyPaymentInstructionRegister;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SearchMoneyPaymentInstructionRegisterMapStore extends AbstractSliceMapLoader<SearchProxyMoneyPaymentInstructionRegister> {
|
||||
public SearchMoneyPaymentInstructionRegisterMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTableName() {
|
||||
return "money_payment_instruction_register";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SearchProxyMoneyPaymentInstructionRegister> load(Collection<Long> keys) {
|
||||
Map<String, Collection<Long>> paramMap = Collections.singletonMap("ids", keys);
|
||||
return namedParameterJdbcTemplate.query("select * from " + getTableName() + " where id in (:ids)", paramMap,
|
||||
(rs, rowNum) -> {
|
||||
SearchProxyMoneyPaymentInstructionRegister proxyRegistry = new SearchProxyMoneyPaymentInstructionRegister();
|
||||
proxyRegistry.setId(rs.getObject("id", Long.class));
|
||||
proxyRegistry.setClearingDate(getLocalDateFromSqlDate(rs, "clearing_date"));
|
||||
return proxyRegistry;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapName() {
|
||||
return IMDGDistributedNames.Map_SearchMoneyPaymentInstructionRegister;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIndexingField() {
|
||||
return new String[]{"created"};
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +195,16 @@ public final class IMDGDistributedNames {
|
|||
public static final String Map_PriorityDictionary = "Map_PriorityDictionary";
|
||||
|
||||
//-------------------history and search tables
|
||||
public static final String Map_SearchRegistry = "Map_SearchRegistry";
|
||||
public static final String Map_SearchExecutionDeposit = "Map_SearchDeposit";
|
||||
public static final String Map_SearchExecutionFond = "Map_SearchExecutionFond";
|
||||
public static final String Map_SearchMoneyBalanceRegister = "Map_SearchMoneyBalanceRegister";
|
||||
public static final String Map_SearchAdmittedLiabilitiesRegister = "Map_SearchAdmittedLiabilitiesRegister";
|
||||
public static final String Map_SearchCoveredLiabilitiesRegister = "Map_SearchCoveredLiabilitiesRegister";
|
||||
public static final String Map_SearchMoneyPaymentInstructionRegister = "Map_SearchMoneyPaymentInstructionRegister";
|
||||
public static final String Map_SearchDepoPaymentInstructionRegister = "Map_SearchDepoPaymentInstructionRegister";
|
||||
public static final String Map_SearchExcludeLiabilitiesRegister = "Map_SearchExcludeLiabilitiesRegister";
|
||||
public static final String Map_SearchLiabilitiesRegister = "Map_SearchLiabilitiesRegister";
|
||||
public static final String Map_SearchExecutionRegister = "Map_SearchExecutionRegister";
|
||||
public static final String MAP_SEQUENCE_NAME = "MAP_SEQUENCE_NAME";
|
||||
|
||||
private IMDGDistributedNames() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue