refactoring
This commit is contained in:
parent
df511e1894
commit
a7a057c4d4
31 changed files with 169 additions and 270 deletions
|
|
@ -21,7 +21,10 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-classes-base</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package ru.clearing.classes.StaticData.Company;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
/**
|
||||
* DB: COMPANY_ROLE_SET
|
||||
*/
|
||||
public class CompanyRoleSet extends ObjectBase {
|
||||
public class CompanyRoleSet extends SpcexObjectBase {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package ru.clearing.classes.StaticData.Company;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
/**
|
||||
* DB: COMPANY_SYMBOLS
|
||||
*/
|
||||
public class CompanySymbols extends ObjectBase {
|
||||
public class CompanySymbols extends SpcexObjectBase {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@ package ru.clearing.classes.StaticData.Company;
|
|||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* DB: COMPANY_UPDATE
|
||||
*/
|
||||
public class CompanyUpdate extends BusinessEvent<Company> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Company object;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package ru.clearing.classes.StaticData.Profile;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
/**
|
||||
* DB: COMPANY_INFO
|
||||
*/
|
||||
public class CompanyInfo extends ObjectBase {
|
||||
public class CompanyInfo extends SpcexObjectBase {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId; // Company.CompanyInfo.companyId = CompanyInfo.id todo company_id=id - эти поля можно не добавлять в объект, их администрирует мапстор. И в базе получается они задублируются-лишнее поле company_id.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package ru.clearing.classes.StaticData.Profile;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
/**
|
||||
* DB: CONTACT
|
||||
*/
|
||||
public class Contact extends ObjectBase {
|
||||
public class Contact extends SpcexObjectBase {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package ru.clearing.classes.StaticData.Profile;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* DB: PROFILE_DOCUMENT
|
||||
*/
|
||||
public class ProfileDocument extends ObjectBase {
|
||||
public class ProfileDocument extends SpcexObjectBase {
|
||||
private static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Long companyId;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
package ru.clearing.classes.objects;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* Журнал изменения таблиц с BusinessObject
|
||||
*/
|
||||
public abstract class BusinessEvent<T extends BusinessObject> extends ObjectBase {
|
||||
static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
public abstract class BusinessEvent<T extends BusinessObject> extends SpcexObjectBase {
|
||||
|
||||
private Instant eventTime;
|
||||
private Long userId; // event_user_id
|
||||
|
||||
public BusinessEvent() {
|
||||
}
|
||||
private Long userId;
|
||||
|
||||
public Instant getEventTime() {
|
||||
return eventTime;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
package ru.clearing.classes.objects;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* UUID - Long based with field object
|
||||
*/
|
||||
public abstract class BusinessObject extends ObjectBase {
|
||||
public abstract class BusinessObject extends SpcexObjectBase {
|
||||
static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
|
||||
private Instant created; // CREATED_AT
|
||||
private Instant updated; // UPDATED_AT
|
||||
private Instant created;
|
||||
private Instant updated;
|
||||
|
||||
public Instant getCreated() {
|
||||
return created;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.5.2</version>
|
||||
<version>0.9.5.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- IMDG для MapStore -->
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ package ru.spcex.clearing.storage.base;
|
|||
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.clearing.classes.objects.BusinessEvent;
|
||||
import ru.clearing.classes.objects.BusinessObject;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BusinessEventMapStore<T extends BusinessEvent> extends ObjectBaseMapStore<T> {
|
||||
public abstract class BusinessEventMapStore<T extends BusinessEvent<? extends BusinessObject>> extends ObjectBaseMapStore<T> {
|
||||
|
||||
public BusinessEventMapStore(JdbcTemplate jdbcTemplate) {
|
||||
super(jdbcTemplate);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public abstract class DictionaryMapStore<T extends Dictionary> implements MapLoa
|
|||
List<Long> list = Collections.singletonList(id);
|
||||
try {
|
||||
rows = loadCollection(list);
|
||||
} catch (Throwable e) { // one retry
|
||||
} catch (Throwable e) {
|
||||
log.trace("Retry load after {}", e.toString());
|
||||
rows = loadCollection(list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,86 +0,0 @@
|
|||
package ru.spcex.clearing.storage.base;
|
||||
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
import com.hazelcast.core.MapLoaderLifecycleSupport;
|
||||
import com.hazelcast.core.MapStore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.lang.NonNull;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* MapStore записывающий изменения в файл
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class LoggingMapStore<T extends ObjectBase> implements MapStore<Long, T>, MapLoaderLifecycleSupport {
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
// private CSVWriter csvWriter; todo подключить OpenCSV и настройку про логирование данных добавить
|
||||
|
||||
// private Supplier<String> recoveryPath = () -> DfaConfig.get().getRoot().getSettings().getRecoveryLogPath();
|
||||
|
||||
@Override
|
||||
public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) {
|
||||
// try {
|
||||
// String recoveryLogPath = recoveryPath.get();
|
||||
// if (recoveryLogPath != null) {
|
||||
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
// File recoveryDir = new File(recoveryLogPath + File.separator + simpleDateFormat.format(new Date()));
|
||||
// recoveryDir.mkdirs();
|
||||
// File recoveryFile = new File(recoveryDir, getTableName() + ".csv");
|
||||
// csvWriter = new CSVWriter(new BufferedWriter(new FileWriter(recoveryFile)), ';');
|
||||
// log.info("recovery log started {}", recoveryFile);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("", e);
|
||||
// }
|
||||
}
|
||||
|
||||
// public void setRecoveryPath(Supplier<String> recoveryPath) {
|
||||
// this.recoveryPath = recoveryPath;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// try {
|
||||
// if (csvWriter != null)
|
||||
// csvWriter.close();
|
||||
// } catch (IOException e) {
|
||||
// log.error("", e);
|
||||
// }
|
||||
}
|
||||
|
||||
public abstract String getTableName();
|
||||
|
||||
protected void logHeaders(@NonNull String[] headers) {
|
||||
try {
|
||||
// if (csvWriter != null) {
|
||||
// csvWriter.writeNext(headers);
|
||||
// csvWriter.flush();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void logValues(@NonNull List<Object[]> valuesList) {
|
||||
try {
|
||||
// if (csvWriter != null) {
|
||||
// for (Object[] values : valuesList) {
|
||||
// String[] nextLine = new String[values.length];
|
||||
// for (int i = 0; i < values.length; i++) {
|
||||
// nextLine[i] = String.valueOf(values[i]);
|
||||
// }
|
||||
// csvWriter.writeNext(nextLine);
|
||||
// }
|
||||
// csvWriter.flush();
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package ru.spcex.clearing.storage.base;
|
||||
|
||||
import org.springframework.dao.support.DataAccessUtils;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.clearing.storage.utils.DbUtilsHelper;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -11,20 +11,7 @@ import java.sql.Timestamp;
|
|||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class ObjectBaseMapStore<T extends ObjectBase> extends SimpleObjectMapStore<T> {
|
||||
/**
|
||||
* См. legalEntityProfileToSQLArgs()
|
||||
*/
|
||||
protected static final String LEGAL_ENTITY_PROFILE_STATEMENT_ARGUMENT =
|
||||
"description, domicilecountrycodeid, isprofessional, organizationtypeid, ogrn, name," +
|
||||
" fullname, nameeng, fullnameeng, kpp, contactphone, contactemail, tsedallowedid, edomail," +
|
||||
" nsdallowedid, otcmonitorallowedid, otcmonitorobligedid";
|
||||
|
||||
protected static final String insertChargeDefinitionStatement = DbUtilsHelper.fillValuesBlock(
|
||||
"UPDATE OR INSERT INTO CHARGEDEFINITION (id, chargeamount, chargedirectionid, " +
|
||||
" chargesettlementamount, chargetypeid, netincluded, currencycodeid, moexexchangecommission, userid, partyid)" +
|
||||
" values %values_block% matching (id);"
|
||||
);
|
||||
public abstract class ObjectBaseMapStore<T extends SpcexObjectBase> extends SimpleObjectMapStore<T> {
|
||||
public static final int MAX_IN_CLAUSE_SIZE = 1000;
|
||||
|
||||
protected NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
|
@ -34,12 +21,6 @@ public abstract class ObjectBaseMapStore<T extends ObjectBase> extends SimpleObj
|
|||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
// this.jdbcTemplate = jdbcTemplate;
|
||||
// this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public T load(Long id) {
|
||||
if (!isLoadable(id)) return null;
|
||||
|
|
@ -100,75 +81,4 @@ public abstract class ObjectBaseMapStore<T extends ObjectBase> extends SimpleObj
|
|||
Timestamp date = rs.getTimestamp(column);
|
||||
return date != null ? date.toInstant() : null;
|
||||
}
|
||||
|
||||
/* todo реfакторинг:
|
||||
protected LegalEntityProfile getLegalEntityProfile(Long id) {
|
||||
if (id == null)
|
||||
return null;
|
||||
List<LegalEntityProfile> results = jdbcTemplate.query(
|
||||
"SELECT * FROM legalentityprofile WHERE id = ?", new Object[]{id},
|
||||
(rs, rowNum) -> {
|
||||
LegalEntityProfile legalEntityProfile = new LegalEntityProfile();
|
||||
legalEntityProfile.setDescription(rs.getString("description"));
|
||||
legalEntityProfile.setDomicileCountryCodeId(rs.getObject("domicilecountrycodeid", Long.class));
|
||||
legalEntityProfile.setProfessional(rs.getObject("isprofessional", Boolean.class));
|
||||
legalEntityProfile.setOrganizationTypeId(rs.getObject("organizationtypeid", Long.class));
|
||||
legalEntityProfile.setOgrn(rs.getString("ogrn"));
|
||||
legalEntityProfile.setShortName(rs.getString("name"));
|
||||
legalEntityProfile.setFullName(rs.getString("fullname"));
|
||||
legalEntityProfile.setNameEng(rs.getString("nameeng"));
|
||||
legalEntityProfile.setFullNameEng(rs.getString("fullnameeng"));
|
||||
legalEntityProfile.setKpp(rs.getString("kpp"));
|
||||
legalEntityProfile.setContactPhone(rs.getString("contactphone"));
|
||||
legalEntityProfile.setContactEMail(rs.getString("contactemail"));
|
||||
legalEntityProfile.setTsedAllowedId(rs.getObject("tsedallowedid", Long.class));
|
||||
legalEntityProfile.setEdoMail(rs.getString("edomail"));
|
||||
legalEntityProfile.setNsdAllowedId(rs.getObject("nsdallowedid", Long.class));
|
||||
legalEntityProfile.setOtcMonitorAllowedId(rs.getObject("otcmonitorallowedid", Long.class));
|
||||
legalEntityProfile.setOtcMonitorObligedId(rs.getObject("otcmonitorobligedid", Long.class));
|
||||
legalEntityProfile.setId(getLong(rs, "id"));
|
||||
return legalEntityProfile;
|
||||
}
|
||||
);
|
||||
LegalEntityProfile onceObject = DataAccessUtils.singleResult(results);
|
||||
if (onceObject == null) {
|
||||
log.warn("No row in table legalentityprofile where id={}. Create empty ", id);
|
||||
onceObject = new LegalEntityProfile();
|
||||
onceObject.setId(id); // чтобы не потерять id
|
||||
}
|
||||
return onceObject;
|
||||
}
|
||||
*/
|
||||
|
||||
// /**
|
||||
// * Без ID перечисление значений полей LegalEntityProfile.
|
||||
// * См. LegalentityprofileStatementArgument
|
||||
// *
|
||||
// * @param legalEntityProfile
|
||||
// * @return
|
||||
// */
|
||||
// protected List<Object> legalEntityProfileToSQLArgs(@NonNull LegalEntityProfile legalEntityProfile) {
|
||||
// List<Object> legalEntityArgs = new ArrayList<>(Arrays.asList(
|
||||
//// legalEntityProfile.getId(),
|
||||
// legalEntityProfile.getDescription(),
|
||||
// legalEntityProfile.getDomicileCountryCodeId(),
|
||||
// legalEntityProfile.getProfessional(),
|
||||
// legalEntityProfile.getOrganizationTypeId(),
|
||||
// legalEntityProfile.getOgrn(),
|
||||
// legalEntityProfile.getShortName(),
|
||||
// legalEntityProfile.getFullName(),
|
||||
// legalEntityProfile.getNameEng(),
|
||||
// legalEntityProfile.getFullNameEng(),
|
||||
// legalEntityProfile.getKpp(),
|
||||
// legalEntityProfile.getContactPhone(),
|
||||
// legalEntityProfile.getContactEMail(),
|
||||
// legalEntityProfile.getTsedAllowedId(),
|
||||
// legalEntityProfile.getEdoMail(),
|
||||
// legalEntityProfile.getNsdAllowedId(),
|
||||
// legalEntityProfile.getOtcMonitorAllowedId(),
|
||||
// legalEntityProfile.getOtcMonitorObligedId()
|
||||
// ));
|
||||
// return legalEntityArgs;
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ru.spcex.clearing.storage.base;
|
||||
|
||||
import com.hazelcast.core.MapStore;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -7,8 +8,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
import org.springframework.jdbc.core.StatementCreatorUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import ru.clearing.classes.objects.ObjectBase;
|
||||
import ru.spcex.clearing.storage.utils.BigDecimalUtil;
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -24,17 +25,15 @@ import java.util.*;
|
|||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class SimpleObjectMapStore<T extends ObjectBase> extends LoggingMapStore<T>
|
||||
{
|
||||
public abstract class SimpleObjectMapStore<T extends SpcexObjectBase> implements MapStore<Long, T> {
|
||||
protected final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected SimpleDateFormat FIREBIRD_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd"); // не делать static.
|
||||
protected SimpleDateFormat FIREBIRD_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd");
|
||||
protected final JdbcTemplate jdbcTemplate;
|
||||
private final int bathSize = 1000;
|
||||
|
||||
protected SimpleObjectMapStore(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
logHeaders(getFields());
|
||||
}
|
||||
|
||||
public abstract String getTableName();
|
||||
|
|
@ -146,7 +145,6 @@ public abstract class SimpleObjectMapStore<T extends ObjectBase> extends Logging
|
|||
|
||||
protected void batchInsertUpdate(@NonNull String insertStatement, @NonNull List<Object[]> args) {
|
||||
try {
|
||||
logValues(args);
|
||||
int[][] ret = jdbcTemplate.batchUpdate(insertStatement, args, bathSize, (ps, params) -> {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
int type = ps.getParameterMetaData().getParameterType(i + 1);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public class CompanyUpdateMapStore extends BusinessEventMapStore<CompanyUpdate>
|
|||
public String[] getFieldsForCompanyInfo() {
|
||||
return new String[]{
|
||||
"id", "event_time", "event_user_id",
|
||||
|
||||
"company_info_id", "company_id", "clearing_member_category", "corporation_sole_type", "country_code", "description",
|
||||
"professional_sign", "legal_kind", "organization_type", "residence", "short_name", "full_name",
|
||||
"short_name_eng", "full_name_eng"
|
||||
|
|
@ -71,10 +70,9 @@ public class CompanyUpdateMapStore extends BusinessEventMapStore<CompanyUpdate>
|
|||
};
|
||||
batchArgs.add(args);
|
||||
if (company.getProfile() != null) {
|
||||
company.getProfile().setId(company.getId());//todo для точного соответствия id = company.id
|
||||
company.getProfile().setId(company.getId());
|
||||
company.getProfile().setCompanyId(company.getId());
|
||||
List<Object> companyInfoArgs = new ArrayList<>();
|
||||
companyInfoArgs.addAll(companyInfoToSQLArgs(company.getProfile(), companyUpdate));
|
||||
List<Object> companyInfoArgs = new ArrayList<>(companyInfoToSQLArgs(company.getProfile(), companyUpdate));
|
||||
|
||||
batchCompanyInfoArgs.add(companyInfoArgs.toArray());
|
||||
}
|
||||
|
|
@ -91,7 +89,7 @@ public class CompanyUpdateMapStore extends BusinessEventMapStore<CompanyUpdate>
|
|||
* @return
|
||||
*/
|
||||
protected List<Object> companyInfoToSQLArgs(@NonNull CompanyInfo companyInfo, CompanyUpdate rootUpdate) {
|
||||
List<Object> companyInfoArgs = new ArrayList<>(Arrays.asList(
|
||||
return new ArrayList<>(Arrays.asList(
|
||||
rootUpdate.getId(),
|
||||
TimeUtil.fromInstant(rootUpdate.getEventTime()),
|
||||
rootUpdate.getUserId(),
|
||||
|
|
@ -111,6 +109,5 @@ public class CompanyUpdateMapStore extends BusinessEventMapStore<CompanyUpdate>
|
|||
companyInfo.getShortNameEng(),
|
||||
companyInfo.getFullNameEng()
|
||||
));
|
||||
return companyInfoArgs;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
package ru.spcex.clearing.storage.config;
|
||||
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import ru.spcex.clearing.storage.error.ModuleInitializeException;
|
||||
import ru.spcex.clearing.storage.utils.DbDefaultConfig;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
|
@ -26,30 +24,26 @@ public class DbConnectionConfig {
|
|||
String login = configRoot.getDatabase().getLogin();
|
||||
String password = configRoot.getDatabase().getPassword();
|
||||
String logTimeoutPart = "";
|
||||
String dbPath;
|
||||
if (StringUtils.isEmpty(configRoot.getDatabase().getEmbeddedFilePath())) {
|
||||
dbPath = configRoot.getDatabase().getJdbcConnectionString();
|
||||
int timeoutSec = configRoot.getDatabase().getConnectionAcquireTimeoutSeconds();
|
||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||
try {
|
||||
cpds.setDriverClass(configRoot.getDatabase().getDriver());
|
||||
} catch (Exception ue) { // fixme не компилится из-за PropertyVetoException
|
||||
throw new RuntimeException(ue);
|
||||
}
|
||||
cpds.setJdbcUrl(dbPath);
|
||||
cpds.setUser(login);
|
||||
cpds.setPassword(password);
|
||||
cpds.setInitialPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMinPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMaxPoolSize(configRoot.getDatabase().getMaxPoolSize());
|
||||
cpds.setNumHelperThreads(configRoot.getDatabase().getNumHelperThreads());
|
||||
cpds.setCheckoutTimeout(timeoutSec * 1000/*todo common 1000==ConstsCommon.SECOND*/);
|
||||
logTimeoutPart = String.format(" (timeout=%ds)", timeoutSec);
|
||||
result = cpds;
|
||||
} else {
|
||||
dbPath = configRoot.getDatabase().getEmbeddedFilePath();
|
||||
result = DbDefaultConfig.getEmbeddedDatabase(dbPath);
|
||||
String dbPath = configRoot.getDatabase().getJdbcConnectionString();
|
||||
int timeoutSec = configRoot.getDatabase().getConnectionAcquireTimeoutSeconds();
|
||||
|
||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||
try {
|
||||
cpds.setDriverClass(configRoot.getDatabase().getDriver());
|
||||
} catch (Exception ue) { // fixme не компилится из-за PropertyVetoException
|
||||
throw new RuntimeException(ue);
|
||||
}
|
||||
cpds.setJdbcUrl(dbPath);
|
||||
cpds.setUser(login);
|
||||
cpds.setPassword(password);
|
||||
cpds.setInitialPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMinPoolSize(configRoot.getDatabase().getMinPoolSize());
|
||||
cpds.setMaxPoolSize(configRoot.getDatabase().getMaxPoolSize());
|
||||
cpds.setNumHelperThreads(configRoot.getDatabase().getNumHelperThreads());
|
||||
cpds.setCheckoutTimeout(timeoutSec * 1000/*todo common 1000==ConstsCommon.SECOND*/);
|
||||
logTimeoutPart = String.format(" (timeout=%ds)", timeoutSec);
|
||||
result = cpds;
|
||||
|
||||
String OPERATION_DATABASE_CONNECTION_CHECK = String.format("Database [%s] connection check", dbPath);
|
||||
try {
|
||||
Connection conn = result.getConnection();
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
package ru.spcex.clearing.storage.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = "com.moex.platform.storage")
|
||||
public class PlatformStorageBeans {
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.*;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
//todo почистить класс
|
||||
public abstract class AbstractHazelcastLifecycleSupport implements InitializingBean, DisposableBean {
|
||||
/**
|
||||
* Рабочая версия БД. Треьуется вручную сверять с DDL.sql и накручивать эту переменную.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ import ru.spcex.clearing.storage.utils.IMDGDistributedNames;
|
|||
|
||||
import java.time.Instant;
|
||||
|
||||
public abstract class AbstractUpdateMapService implements InitializingBean, EntryAddedListener<Long, Object>, EntryUpdatedListener<Long, Object>, EntryRemovedListener<Long, Object> {
|
||||
public abstract class AbstractUpdateMapService implements InitializingBean,
|
||||
EntryAddedListener<Long, Object>, EntryUpdatedListener<Long, Object>, EntryRemovedListener<Long, Object> {
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected final String EVENT_CREATE="CREATE";
|
||||
|
|
@ -28,8 +29,6 @@ public abstract class AbstractUpdateMapService implements InitializingBean, Entr
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
// if (!HazelcastCommon.otcSystem_getStorageState(hazelcastServerInstance))
|
||||
// log.warn("UpdateMapService started before Storage had ready!");
|
||||
addingListenersToCards();
|
||||
log.debug("UpdateMapService started.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//todo зарефакторить
|
||||
public class DbUtilsHelper {
|
||||
|
||||
private static String generateValuesBlock(int querySignCount) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import java.util.Date;
|
|||
* Для работы с java.util.Date
|
||||
* И конвертация в новый формат
|
||||
* todo копипаст юниттеста нужен.
|
||||
* todo зарефакторить
|
||||
*/
|
||||
public class TimeUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(TimeUtil.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
hazelcast:
|
||||
network:
|
||||
join:
|
||||
multicast:
|
||||
enabled: true
|
||||
22
platform-parent/platform-classes-base/pom.xml
Normal file
22
platform-parent/platform-classes-base/pom.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>platform-classes-base</artifactId>
|
||||
<name>Platform classes base</name>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>platform-parent</artifactId>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,27 +1,15 @@
|
|||
package ru.clearing.classes.objects;
|
||||
package ru.spcex.platform.classes.base;
|
||||
|
||||
import ru.clearing.classes.ConstSerializable;
|
||||
import ru.clearing.common.interfaces.WithId;
|
||||
import ru.spcex.platform.classes.base.interfaces.WithId;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Long ID - based primary key object
|
||||
*/
|
||||
public abstract class ObjectBase implements WithId, Serializable {
|
||||
static final long serialVersionUID = ConstSerializable.serialVersionUID;
|
||||
public abstract class SpcexObjectBase implements WithId, Serializable {
|
||||
|
||||
protected Long id;
|
||||
public ObjectBase(){
|
||||
}
|
||||
|
||||
public ObjectBase(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Long getIdOrNull(WithId o) {
|
||||
return o == null ? null : o.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
|
|
@ -43,7 +31,7 @@ public abstract class ObjectBase implements WithId, Serializable {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ObjectBase otcObject = (ObjectBase) o;
|
||||
SpcexObjectBase otcObject = (SpcexObjectBase) o;
|
||||
|
||||
return id.equals(otcObject.id);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package ru.spcex.platform.classes.base.interfaces;
|
||||
|
||||
public interface WithId {
|
||||
Long getId();
|
||||
}
|
||||
29
platform-parent/platform-storage-api/pom.xml
Normal file
29
platform-parent/platform-storage-api/pom.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>platform-storage-api</artifactId>
|
||||
<name>Platform storage api</name>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>platform-parent</artifactId>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-classes-base</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package ru.spcex.platform.storage.api;
|
||||
|
||||
import ru.spcex.platform.classes.base.SpcexObjectBase;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface Storage {
|
||||
<T extends SpcexObjectBase> void insert(Class<T> paramClass, T paramT);
|
||||
|
||||
<T extends SpcexObjectBase> void update(Class<T> paramClass, T paramT);
|
||||
|
||||
<T extends SpcexObjectBase> void delete(Class<T> paramClass, T paramT);
|
||||
|
||||
Long nextIDSequenceFor();
|
||||
|
||||
<T> Collection<T> getCollectionObjectsBySQL(Class<T> paramClass, String paramString);
|
||||
|
||||
<T> T getSingleObjectBySQL(Class<T> paramClass, String paramString);
|
||||
|
||||
<T> T getSingleObjectByID(Class<T> paramClass, Long paramLong);
|
||||
|
||||
<T> Collection<Long> getCollectionIdsBySQL(Class<T> paramClass, String paramString);
|
||||
|
||||
<T> Collection<T> getAllValues(Class<T> paramClass);
|
||||
|
||||
<T, A> Collection<A> projectionsAttributeBySql(Class<T> paramClass, String paramString, String... paramVarArgs);
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-parent</artifactId>
|
||||
<name>_parent_platform</name>
|
||||
<description>PLATFORM parent</description>
|
||||
|
|
@ -17,6 +18,7 @@
|
|||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
<module>platform-storage-api</module>
|
||||
<module>platform-classes-base</module>
|
||||
</modules>
|
||||
</project>
|
||||
11
pom.xml
11
pom.xml
|
|
@ -65,6 +65,17 @@
|
|||
<artifactId>storage</artifactId>
|
||||
<version>${global.project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-classes-base</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-storage-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ ENV JAVA_VERSION jdk17.0.2+9
|
|||
|
||||
RUN set -eux; \
|
||||
ESUM='637a742591f75447eaab1f23942db038d411686f'; \
|
||||
BINARY_URL='https://download.bell-sw.com/java/17.0.2+9/bellsoft-jdk17.0.2+9-linux-amd64.tar.gz'; \
|
||||
BINARY_URL='https://download.bell-sw.com/java/17.0.2+9/bellsoft-jre17.0.2+9-linux-amd64.tar.gz'; \
|
||||
curl -LfsSo /tmp/bellsoft-jdk.tar.gz ${BINARY_URL}; \
|
||||
mkdir -p /opt/java/bellsoft-jdk; \
|
||||
cd /opt/java/bellsoft-jdk; \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue