Creato prima sistema di retrieve dello storico delle transazioni
This commit is contained in:
@@ -4,16 +4,13 @@ import java.util.Date;
|
||||
|
||||
public class TransactionDTO {
|
||||
|
||||
public String publicationId;
|
||||
public int transactionId;
|
||||
public Date transactionDate;
|
||||
public String username;
|
||||
public String entityName;
|
||||
public String errorMsg;
|
||||
public String esito;
|
||||
public Date execDate;
|
||||
public String transactionJson;
|
||||
public int transactionGroupId;
|
||||
private String publicationId;
|
||||
private int transactionId;
|
||||
private Date transactionDate;
|
||||
private String username;
|
||||
private String entityName;
|
||||
private String transactionJson;
|
||||
private int transactionGroupId;
|
||||
|
||||
public String getPublicationId() {
|
||||
return publicationId;
|
||||
@@ -60,33 +57,6 @@ public class TransactionDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public TransactionDTO setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEsito() {
|
||||
return esito;
|
||||
}
|
||||
|
||||
public TransactionDTO setEsito(String esito) {
|
||||
this.esito = esito;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getExecDate() {
|
||||
return execDate;
|
||||
}
|
||||
|
||||
public TransactionDTO setExecDate(Date execDate) {
|
||||
this.execDate = execDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTransactionJson() {
|
||||
return transactionJson;
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ public class AsyncServiceNew {
|
||||
final List<Integer> transactionsIDGroups = new ArrayList<>();
|
||||
|
||||
for (TransactionDTO dto : transactionDTOS) {
|
||||
if (!transactionsIDGroups.contains(dto.transactionGroupId))
|
||||
transactionsIDGroups.add(dto.transactionGroupId);
|
||||
if (!transactionsIDGroups.contains(dto.getTransactionGroupId()))
|
||||
transactionsIDGroups.add(dto.getTransactionGroupId());
|
||||
}
|
||||
|
||||
//Per ogni transaction group trovato mi prendo tutte le transactions
|
||||
@@ -143,7 +143,7 @@ public class AsyncServiceNew {
|
||||
List<EntityBase> entitiesToImport = new ArrayList<EntityBase>();
|
||||
|
||||
for (TransactionDTO transaction : transactionsToImport) {
|
||||
EntityBase entity = jsonObjectMapper.readValue(transaction.transactionJson, EntityBase.class);
|
||||
EntityBase entity = jsonObjectMapper.readValue(transaction.getTransactionJson(), EntityBase.class);
|
||||
entitiesToImport.add(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityHierarchyDTO {
|
||||
|
||||
private Class<? extends EntityBase> clazz;
|
||||
private String entityName;
|
||||
private String tableName;
|
||||
private List<EntityHierarchyDTO> children;
|
||||
|
||||
public Class<? extends EntityBase> getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public EntityHierarchyDTO setClazz(Class<? extends EntityBase> clazz) {
|
||||
this.clazz = clazz;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
@@ -39,18 +39,25 @@ public class Migration_20240124171059 extends BaseMigration implements Migration
|
||||
|
||||
|
||||
for (HashMap<String, Object> oldStbPublicationDetail : oldStbPublicationsDetails) {
|
||||
String active = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "syncronize");
|
||||
String oldId = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "publication_id");
|
||||
String entityName = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "entity_name");
|
||||
String whereCondSql = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "where_cond_sql");
|
||||
String recalcColumns = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "recalc_columns");
|
||||
String syncronize = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "syncronize");
|
||||
String whereCond = UtilityHashMap.getValueIfExists(oldStbPublicationDetail, "where_cond");
|
||||
|
||||
Long newParentId = getNewGeneratedIdFromOldKey(oldId, oldStbPublications);
|
||||
|
||||
String insertSql = Query.format("INSERT INTO stb_publications_detail " +
|
||||
"(stb_publication_id, entity_name, where_cond_sql, recalc_columns, syncronize, where_cond) " +
|
||||
"VALUES (%s, %s, %s, %s, %s, %s)", newParentId, entityName, whereCondSql, recalcColumns, syncronize.equalsIgnoreCase("S") || syncronize.equalsIgnoreCase("R"), whereCond);
|
||||
"(stb_publication_id, entity_name, where_cond_sql, recalc_columns, syncronize, where_cond, ready_to_transmit) " +
|
||||
"VALUES (%s, %s, %s, %s, %s, %s, %s)",
|
||||
newParentId,
|
||||
entityName,
|
||||
whereCondSql,
|
||||
recalcColumns,
|
||||
active.equalsIgnoreCase("S") || active.equalsIgnoreCase("R"),
|
||||
whereCond,
|
||||
true);
|
||||
long generatedId = executeInsertStatement(advancedDataSource.getConnection(), insertSql);
|
||||
oldStbPublicationDetail.putIfAbsent("id", generatedId);
|
||||
}
|
||||
@@ -91,9 +98,10 @@ public class Migration_20240124171059 extends BaseMigration implements Migration
|
||||
" CONSTRAINT stb_publications_detail_stb_publications_id_fk\n" +
|
||||
" REFERENCES dbo.stb_publications (id),\n" +
|
||||
" entity_name VARCHAR(40) NOT NULL,\n" +
|
||||
" active BIT DEFAULT 1 NOT NULL,\n" +
|
||||
" ready_to_transmit BIT DEFAULT 0 NOT NULL,\n" +
|
||||
" where_cond_sql VARCHAR(MAX),\n" +
|
||||
" recalc_columns VARCHAR(MAX),\n" +
|
||||
" syncronize BIT DEFAULT 1 NOT NULL,\n" +
|
||||
" where_cond VARCHAR(MAX)" +
|
||||
")";
|
||||
executeStatement(connection, createSql);
|
||||
|
||||
@@ -993,7 +993,7 @@ public class EmsServices {
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityMapping() {
|
||||
return entityPropertyHolder.getEntityMapping();
|
||||
return entityPropertyHolder.getEntityHierarchyMap();
|
||||
}
|
||||
|
||||
public List<EntityFieldDTO> getEntityDetails(String entityName) {
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
package it.integry.ems.sync;
|
||||
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.JSONObjectMapper;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.sync.dto.ExportHistoryItemDTO;
|
||||
import it.integry.ems.sync.dto.PublicationDTO;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.entity.StbTransactionLogDb;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class AsyncHistoryManager {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private LooperService looperService;
|
||||
|
||||
@Autowired
|
||||
private EntityPropertyHolder entityPropertyHolder;
|
||||
|
||||
@Autowired
|
||||
private JSONObjectMapper jsonObjectMapper;
|
||||
|
||||
//Implement check list like distribuzione
|
||||
private final HashMap<Long, List<ExportHistoryItemDTO>> currentlyInExecution = new HashMap<>();
|
||||
|
||||
|
||||
@PostContextConstruct
|
||||
public void init() {
|
||||
this.looperService.add(this::consumeRetrieveQueue, 10 * 1000, "async-history-read");
|
||||
this.looperService.add(this::consumeProcessedQueue, 10 * 1000, "async-history-save");
|
||||
}
|
||||
|
||||
public void addToExportQueue(DataSource dataSource, long groupId, PublicationDTO publication) throws Exception {
|
||||
|
||||
tryAddInExecutionList(groupId, new ExportHistoryItemDTO()
|
||||
.setPublication(publication)
|
||||
.setDataSource(dataSource));
|
||||
}
|
||||
|
||||
private void tryAddInExecutionList(long groupId, ExportHistoryItemDTO exportHistoryItemDTO) throws Exception {
|
||||
currentlyInExecution.putIfAbsent(groupId, new ArrayList<>());
|
||||
|
||||
List<ExportHistoryItemDTO> list = currentlyInExecution.get(groupId);
|
||||
final boolean alreadyRegistered = list.stream()
|
||||
.anyMatch(x -> x.getPublication().getId() == exportHistoryItemDTO.getPublication().getId());
|
||||
|
||||
if (alreadyRegistered) {
|
||||
throw new Exception("Il sistema sta già elaborando questa publication");
|
||||
}
|
||||
|
||||
exportHistoryItemDTO.setTotalItemCount(countExistingItems(exportHistoryItemDTO));
|
||||
|
||||
list.add(exportHistoryItemDTO);
|
||||
}
|
||||
|
||||
private void consumeRetrieveQueue() {
|
||||
final List<Long> currentlyInExecutionKeys = new ArrayList<>(currentlyInExecution.keySet());
|
||||
|
||||
for (long currentGroupId : currentlyInExecutionKeys) {
|
||||
List<ExportHistoryItemDTO> entitiesToExport = currentlyInExecution.get(currentGroupId);
|
||||
|
||||
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
||||
try {
|
||||
internalExportEntity(entityToExport);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void internalExportEntity(ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||
|
||||
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(entityHistoryToExport.getDataSource().getProfile())) {
|
||||
retrieveEntitiesByChunk(newConnection.getPrimaryConnection(), entityHistoryToExport, entityClass);
|
||||
}
|
||||
}
|
||||
|
||||
private long countExistingItems(ExportHistoryItemDTO entityHistoryToExport) throws Exception {
|
||||
final Class<? extends EntityBase> entityClass = entityPropertyHolder.getEntityClassFromTableName(entityHistoryToExport.getPublication().getEntityName());
|
||||
|
||||
try (MultiDBTransactionManager newConnection = new MultiDBTransactionManager(entityHistoryToExport.getDataSource().getProfile())) {
|
||||
String sql = "SELECT CONVERT(BIGINT, COUNT(*)) FROM " + entityClass.newInstance().getTableName();
|
||||
return UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(newConnection.getPrimaryConnection(), sql);
|
||||
}
|
||||
}
|
||||
|
||||
private void retrieveEntitiesByChunk(Connection connection, ExportHistoryItemDTO exportHistoryItem, Class<? extends EntityBase> entityClass) throws Exception {
|
||||
|
||||
long totalItemCount = exportHistoryItem.getTotalItemCount();
|
||||
int chunkSize = 10000;
|
||||
|
||||
for (int chunkIndex = 0; chunkIndex < (totalItemCount / chunkSize) + 1; chunkIndex++) {
|
||||
|
||||
String innerSql = "SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS row_number " +
|
||||
"FROM " + exportHistoryItem.getPublication().getEntityName();
|
||||
|
||||
innerSql = UtilityDB.addwhereCond(innerSql, exportHistoryItem.getPublication().getWhereCond(), true);
|
||||
|
||||
String sql = "WITH TempResult AS (\n" +
|
||||
innerSql + ")\n" +
|
||||
"SELECT TempResult.*\n" +
|
||||
"FROM TempResult\n" +
|
||||
"ORDER BY row_number\n" +
|
||||
"OFFSET (" + chunkIndex + ") * " + chunkSize + " ROWS FETCH NEXT " + chunkSize + " ROWS ONLY";
|
||||
|
||||
final List<? extends EntityBase> selectedChunk = UtilityDB.executeSimpleQueryDTO(connection, sql, entityClass);
|
||||
|
||||
if (selectedChunk == null || selectedChunk.isEmpty()) continue;
|
||||
|
||||
exportHistoryItem.setProcessedItemCount(exportHistoryItem.getProcessedItemCount() + selectedChunk.size());
|
||||
logger.debug("COUNT: " + exportHistoryItem.getProcessedItemCount());
|
||||
|
||||
selectedChunk.forEach(x -> exportHistoryItem.getToProcessQueue().add(x));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void consumeProcessedQueue() {
|
||||
final List<Long> currentlyInExecutionKeys = new ArrayList<>(currentlyInExecution.keySet());
|
||||
|
||||
for (long currentGroupId : currentlyInExecutionKeys) {
|
||||
List<ExportHistoryItemDTO> entitiesToExport = currentlyInExecution.get(currentGroupId);
|
||||
|
||||
for (ExportHistoryItemDTO entityToExport : entitiesToExport) {
|
||||
try {
|
||||
internalProcessQueue(entityToExport);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void internalProcessQueue(ExportHistoryItemDTO entityToExport) throws Exception {
|
||||
logger.debug("TBS COUNT: " + entityToExport.getToProcessQueue().size());
|
||||
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(entityToExport.getDataSource().getProfile())) {
|
||||
|
||||
EntityBase entity;
|
||||
while ((entity = entityToExport.getToProcessQueue().poll()) != null) {
|
||||
|
||||
StbTransactionLogDb stbTransactionLogDb = new StbTransactionLogDb()
|
||||
.setTransactionDate(UtilityLocalDate.getNowTime())
|
||||
.setTransactionJson(jsonObjectMapper.writeValueAsString(entity))
|
||||
.setTransactionGroupIdField(-1)
|
||||
.setEntityNameList(entityToExport.getPublication().getEntityName());
|
||||
|
||||
stbTransactionLogDb
|
||||
.setOperation(OperationType.INSERT);
|
||||
|
||||
stbTransactionLogDb.manageWithParentConnection(multiDBTransactionManager.getPrimaryConnection());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
@Scope("request")
|
||||
public class MultiDBTransactionManager {
|
||||
public class MultiDBTransactionManager implements AutoCloseable{
|
||||
|
||||
private final static Logger logger = LogManager.getLogger();
|
||||
|
||||
@@ -234,6 +234,11 @@ public class MultiDBTransactionManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
closeAll();
|
||||
}
|
||||
|
||||
public void closeAll() throws Exception {
|
||||
for (AdvancedDataSource advancedDataSource : dbDatasources) {
|
||||
if (!advancedDataSource.isClosed()) {
|
||||
@@ -333,4 +338,5 @@ public class MultiDBTransactionManager {
|
||||
!uri.contains("getOpenedSteps") &&
|
||||
!uri.contains("getCurrentPrintQueue");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package it.integry.ems.sync.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.service.RemoteSyncronizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("system/remote-sync")
|
||||
public class RemoteSyncronizationController {
|
||||
|
||||
@Autowired
|
||||
private RemoteSyncronizationService remoteSyncronizationService;
|
||||
|
||||
@RequestMapping(value = "publications/{groupId}/start", method = RequestMethod.GET)
|
||||
public ServiceRestResponse startPublication(@PathVariable long groupId) throws Exception {
|
||||
remoteSyncronizationService.startPublication(groupId);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
package it.integry.ems.system.controller;
|
||||
package it.integry.ems.sync.controller;
|
||||
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.system.dto.syncronization.InsertPublicationGroupRequestDTO;
|
||||
import it.integry.ems.system.service.RemoteSyncronizationSetupService;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import it.integry.ems.sync.dto.InsertPublicationGroupRequestDTO;
|
||||
import it.integry.ems.sync.dto.InsertPublicationItemResponseDTO;
|
||||
import it.integry.ems.sync.dto.PublicationDTO;
|
||||
import it.integry.ems.sync.service.RemoteSyncronizationSetupService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@Scope("request")
|
||||
@RequestMapping("system/remote-sync/setup")
|
||||
public class RemoteSyncronizationSetupController {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private RemoteSyncronizationSetupService remoteSyncronizationSetupService;
|
||||
|
||||
@@ -35,9 +30,13 @@ public class RemoteSyncronizationSetupController {
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "publications/insert", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertPublications() throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(remoteSyncronizationSetupService.retrievePublications());
|
||||
@RequestMapping(value = "publications/{groupId}/insert", method = RequestMethod.POST)
|
||||
public ServiceRestResponse insertPublications(@PathVariable long groupId, @RequestBody PublicationDTO publicationToInsert) throws Exception {
|
||||
InsertPublicationItemResponseDTO response = new InsertPublicationItemResponseDTO()
|
||||
.setId(remoteSyncronizationSetupService.addPublicationItem(groupId, publicationToInsert));
|
||||
|
||||
|
||||
return ServiceRestResponse.createPositiveResponse(response);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExportHistoryGroupDTO {
|
||||
|
||||
private long groupId;
|
||||
private List<ExportHistoryItemDTO> items;
|
||||
|
||||
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setGroupId(long groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<ExportHistoryItemDTO> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public ExportHistoryGroupDTO setItems(List<ExportHistoryItemDTO> items) {
|
||||
this.items = items;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class ExportHistoryItemDTO {
|
||||
|
||||
|
||||
private DataSource dataSource;
|
||||
private PublicationDTO publication;
|
||||
private long totalItemCount;
|
||||
private long processedItemCount;
|
||||
|
||||
private Queue<EntityBase> toProcessQueue = new ConcurrentLinkedQueue<EntityBase>();
|
||||
|
||||
|
||||
public DataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setDataSource(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PublicationDTO getPublication() {
|
||||
return publication;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setPublication(PublicationDTO publication) {
|
||||
this.publication = publication;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getTotalItemCount() {
|
||||
return totalItemCount;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setTotalItemCount(long totalItemCount) {
|
||||
this.totalItemCount = totalItemCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getProcessedItemCount() {
|
||||
return processedItemCount;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setProcessedItemCount(long processedItemCount) {
|
||||
this.processedItemCount = processedItemCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Queue<EntityBase> getToProcessQueue() {
|
||||
return toProcessQueue;
|
||||
}
|
||||
|
||||
public ExportHistoryItemDTO setToProcessQueue(Queue<EntityBase> toProcessQueue) {
|
||||
this.toProcessQueue = toProcessQueue;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.system.dto.syncronization;
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
public class InsertPublicationGroupRequestDTO {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.system.dto.syncronization;
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
public class InsertPublicationGroupResponseDTO {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
public class InsertPublicationItemResponseDTO {
|
||||
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public InsertPublicationItemResponseDTO setId(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
package it.integry.ems.system.dto.syncronization;
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||
|
||||
public class PublicationDTO {
|
||||
|
||||
@@ -6,9 +8,20 @@ public class PublicationDTO {
|
||||
private String entityName;
|
||||
private String whereCondSql;
|
||||
private String recalcColumns;
|
||||
private boolean syncronize;
|
||||
private boolean active;
|
||||
private String whereCond;
|
||||
|
||||
|
||||
public static PublicationDTO fromStbPublicationDetail(StbPublicationsDetail stbPublicationsDetail) {
|
||||
return new PublicationDTO()
|
||||
.setActive(stbPublicationsDetail.isActive())
|
||||
.setId(stbPublicationsDetail.getId())
|
||||
.setRecalcColumns(stbPublicationsDetail.getRecalcColumnsField())
|
||||
.setEntityName(stbPublicationsDetail.getEntityName())
|
||||
.setWhereCond(stbPublicationsDetail.getWhereCondField())
|
||||
.setWhereCondSql(stbPublicationsDetail.getWhereCondSql());
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -45,12 +58,12 @@ public class PublicationDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSyncronize() {
|
||||
return syncronize;
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public PublicationDTO setSyncronize(boolean syncronize) {
|
||||
this.syncronize = syncronize;
|
||||
public PublicationDTO setActive(boolean active) {
|
||||
this.active = active;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package it.integry.ems.system.dto.syncronization;
|
||||
package it.integry.ems.sync.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.integry.ems.sync.service;
|
||||
|
||||
import it.integry.ems.sync.AsyncHistoryManager;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.sync.dto.PublicationDTO;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.entity.StbPublicationsDetail;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Scope(value = "request")
|
||||
public class RemoteSyncronizationService {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
@Autowired
|
||||
private MultiDBTransactionManager multiDBTransactionManager;
|
||||
|
||||
@Autowired
|
||||
private AsyncHistoryManager asyncHistoryManager;
|
||||
|
||||
@Autowired
|
||||
private EntityPropertyHolder entityPropertyHolder;
|
||||
|
||||
public void startPublication(long groupId) throws Exception {
|
||||
|
||||
StbPublicationsDetail tmpStbPublicationsDetail = new StbPublicationsDetail();
|
||||
String whereCond = Query.format("stb_publication_id = %s", groupId);
|
||||
|
||||
final List<? extends EntityBase> select = tmpStbPublicationsDetail.select(multiDBTransactionManager.getPrimaryConnection(), whereCond);
|
||||
final List<StbPublicationsDetail> stbPublicationsDetails = UtilityEntity.toCustomEntity(select);
|
||||
|
||||
for (StbPublicationsDetail stbPublicationsDetail : stbPublicationsDetails) {
|
||||
asyncHistoryManager.addToExportQueue(multiDBTransactionManager.getPrimaryDatasource(),
|
||||
groupId,
|
||||
PublicationDTO.fromStbPublicationDetail(stbPublicationsDetail));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package it.integry.ems.system.service;
|
||||
package it.integry.ems.sync.service;
|
||||
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.system.dto.syncronization.PublicationDTO;
|
||||
import it.integry.ems.system.dto.syncronization.PublicationGroupDTO;
|
||||
import it.integry.ems.sync.dto.PublicationDTO;
|
||||
import it.integry.ems.sync.dto.PublicationGroupDTO;
|
||||
import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
@@ -55,6 +55,8 @@ public class RemoteSyncronizationSetupService {
|
||||
tmpStbPublicationsDetail.setOperation(OperationType.SELECT);
|
||||
tmpStbPublicationsDetail.setOnlyPkMaster(false);
|
||||
List<EntityBase> selectedStbPublicationsDetail = entityProcessor.processEntity(tmpStbPublicationsDetail, multiDBTransactionManager);
|
||||
if(selectedStbPublicationsDetail == null) selectedStbPublicationsDetail = new ArrayList<>();
|
||||
|
||||
List<StbPublicationsDetail> stbPublicationsDetails = UtilityEntity.toCustomEntity(selectedStbPublicationsDetail);
|
||||
|
||||
|
||||
@@ -70,13 +72,7 @@ public class RemoteSyncronizationSetupService {
|
||||
|
||||
final List<PublicationDTO> publications = stbPublicationsDetails.stream()
|
||||
.filter(x -> x.getStbPublicationId() == stbPublication.getId())
|
||||
.map(x -> new PublicationDTO()
|
||||
.setId(x.getId())
|
||||
.setSyncronize(x.isSyncronize())
|
||||
.setEntityName(x.getEntityName())
|
||||
.setWhereCond(x.getWhereCondField())
|
||||
.setWhereCondSql(x.getWhereCondSql())
|
||||
.setRecalcColumns(x.getRecalcColumnsField()))
|
||||
.map(PublicationDTO::fromStbPublicationDetail)
|
||||
.collect(toList());
|
||||
publicationGroupDTO.setPublications(publications);
|
||||
}
|
||||
@@ -95,22 +91,48 @@ public class RemoteSyncronizationSetupService {
|
||||
return stbPublications.getId();
|
||||
}
|
||||
|
||||
public void addPublications(long publicationId, @NotNull List<PublicationDTO> publications) throws Exception {
|
||||
|
||||
public long addPublicationItem(long groupId, @NotNull PublicationDTO publicationToInsert) throws Exception {
|
||||
final StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||
.setStbPublicationId(groupId)
|
||||
.setEntityName(publicationToInsert.getEntityName())
|
||||
.setWhereCondSql(publicationToInsert.getWhereCondSql())
|
||||
.setRecalcColumns(publicationToInsert.getRecalcColumns())
|
||||
.setActive(publicationToInsert.isActive())
|
||||
.setWhereCondField(publicationToInsert.getWhereCond());
|
||||
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
||||
|
||||
StbPublications stbPublications = new StbPublications()
|
||||
.setId(groupId);
|
||||
stbPublications.setOperation(OperationType.NO_OP);
|
||||
stbPublications.getStbPublicationsDetails().add(stbPublicationsDetail);
|
||||
|
||||
entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
||||
|
||||
return stbPublications.getStbPublicationsDetails().get(0).getId();
|
||||
}
|
||||
|
||||
public void addPublications(long groupId, @NotNull List<PublicationDTO> publications) throws Exception {
|
||||
final List<StbPublicationsDetail> stbPublicationsToInsert = publications.stream()
|
||||
.map(x -> new StbPublicationsDetail()
|
||||
.setStbPublicationId(publicationId)
|
||||
.setEntityName(x.getEntityName())
|
||||
.setWhereCondSql(x.getWhereCondSql())
|
||||
.setRecalcColumns(x.getRecalcColumns())
|
||||
.setSyncronize(x.isSyncronize())
|
||||
.setWhereCondField(x.getWhereCond()))
|
||||
.map(x -> {
|
||||
StbPublicationsDetail stbPublicationsDetail = new StbPublicationsDetail()
|
||||
.setStbPublicationId(groupId)
|
||||
.setEntityName(x.getEntityName())
|
||||
.setWhereCondSql(x.getWhereCondSql())
|
||||
.setRecalcColumns(x.getRecalcColumns())
|
||||
.setActive(x.isActive())
|
||||
.setWhereCondField(x.getWhereCond());
|
||||
stbPublicationsDetail.setOperation(OperationType.INSERT);
|
||||
return stbPublicationsDetail;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
StbPublications stbPublications = new StbPublications()
|
||||
.setId(publicationId);
|
||||
.setId(groupId)
|
||||
.setStbPublicationsDetails(stbPublicationsToInsert);
|
||||
stbPublications.setOperation(OperationType.NO_OP);
|
||||
|
||||
final List<EntityBase> savedEntities = entityProcessor.processEntityList(stbPublicationsToInsert, multiDBTransactionManager, true);
|
||||
final List<EntityBase> savedEntities = entityProcessor.processEntity(stbPublications, multiDBTransactionManager);
|
||||
|
||||
UtilityEntity.throwEntitiesException(savedEntities);
|
||||
}
|
||||
@@ -138,6 +160,4 @@ public class RemoteSyncronizationSetupService {
|
||||
final List<EntityBase> savedEntities = entityProcessor.processEntityList(stbPublications.get(), multiDBTransactionManager, true);
|
||||
UtilityEntity.throwEntitiesException(savedEntities);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -108,4 +108,11 @@ public class UtilityEntity {
|
||||
return StringUtils.join(fieldsPK, "~");
|
||||
}
|
||||
|
||||
|
||||
public <T extends EntityBase> String calculateWhereCond(T entity, boolean onlyPK) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1345,7 +1345,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
|
||||
Map<Integer, Object> mapLob = getFieldToQuery(fields, campi, valori);
|
||||
|
||||
if (campi.size() != 0) {
|
||||
if (!campi.isEmpty()) {
|
||||
String sql = "INSERT INTO " + getTableName() + "(" + StringUtils.join(campi, ",") + ") " + "VALUES (" + StringUtils.join(valori, ",") + ")";
|
||||
|
||||
boolean containsIdentity;
|
||||
@@ -1589,16 +1589,6 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
public void deleteAllEntities(Connection conn, EntityBase parent) throws Exception {
|
||||
String whereCondDel = parent.getWhereCondDelete();
|
||||
deleteAllEntities(conn, whereCondDel);
|
||||
// String sql = "DELETE " + getTableName() + " WHERE " + whereCondDel;
|
||||
//
|
||||
// if (logger.isTraceEnabled()) {
|
||||
// logger.trace("QUERY: " + sql);
|
||||
// }
|
||||
//
|
||||
// PreparedStatement pstm = conn.prepareStatement(sql);
|
||||
// pstm.setQueryTimeout(queryTimeoutSeconds);
|
||||
// pstm.executeUpdate();
|
||||
// pstm.close();
|
||||
}
|
||||
|
||||
private String getWhereCondDelete() throws Exception {
|
||||
@@ -2058,7 +2048,9 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
public void resetIdentiy(Connection connection) throws Exception {
|
||||
Field[] fields = this.getClass().getDeclaredFields();
|
||||
|
||||
Optional<Field> identityField = Stream.of(fields).filter(x -> x.isAnnotationPresent(Identity.class) && x.isAnnotationPresent(SqlField.class)).findFirst();
|
||||
Optional<Field> identityField = Stream.of(fields)
|
||||
.filter(x -> x.isAnnotationPresent(Identity.class) && x.isAnnotationPresent(SqlField.class))
|
||||
.findFirst();
|
||||
|
||||
if (identityField.isPresent()) {
|
||||
String tableName = this.getTableName();
|
||||
|
||||
@@ -36,6 +36,7 @@ public class EntityPropertyHolder {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private List<EntityHierarchyDTO> entityHierarchyMap;
|
||||
|
||||
private final HashMap<String, Class<?>> entityNameMap = new HashMap<>();
|
||||
private final HashMap<String, Object> classMap = new HashMap<>();
|
||||
@@ -55,8 +56,45 @@ public class EntityPropertyHolder {
|
||||
return entityNameMap.getOrDefault(entityName, null);
|
||||
}
|
||||
|
||||
public Class<? extends EntityBase> getEntityClassFromTableName(String tableName) {
|
||||
List<EntityHierarchyDTO> tempList = new ArrayList<>(entityHierarchyMap);
|
||||
tempList.addAll(tempList.stream().flatMap(x -> x.getChildren().stream()).collect(Collectors.toList()));
|
||||
|
||||
return tempList.stream()
|
||||
.filter(x -> x.getTableName().equalsIgnoreCase(tableName))
|
||||
.map(EntityHierarchyDTO::getClazz)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityHierarchyMap() {
|
||||
return entityHierarchyMap;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void scanEntityFields() {
|
||||
public void init() {
|
||||
scanEntityFields();
|
||||
entityHierarchyMap = scanEntityMapping();
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> scanEntityMapping() {
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
||||
Set<Class<? extends EntityBase>> classes = reflections.getSubTypesOf(EntityBase.class);
|
||||
for (Class<? extends EntityBase> entity : classes) {
|
||||
if (entity.isAnnotationPresent(Master.class)) {
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
dto.setClazz(entity);
|
||||
dto.setEntityName(entity.getSimpleName());
|
||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(entity));
|
||||
mapping.add(dto);
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
private void scanEntityFields() {
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
|
||||
List<Class<?>> clssList = new ArrayList<>(Stream.of(reflections.getSubTypesOf(EntityBase.class))
|
||||
@@ -471,22 +509,6 @@ public class EntityPropertyHolder {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityMapping() {
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
||||
Set<Class<? extends EntityBase>> classes = reflections.getSubTypesOf(EntityBase.class);
|
||||
for (Class<? extends EntityBase> entity : classes) {
|
||||
if (entity.isAnnotationPresent(Master.class)) {
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
dto.setEntityName(entity.getSimpleName());
|
||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(entity));
|
||||
mapping.add(dto);
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityChildren(Class<? extends EntityBase> entity) {
|
||||
List<EntityHierarchyDTO> children = new ArrayList<>();
|
||||
Field[] fields = entity.getDeclaredFields();
|
||||
@@ -510,6 +532,7 @@ public class EntityPropertyHolder {
|
||||
continue;
|
||||
}
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
dto.setClazz(childEntity);
|
||||
dto.setEntityName(childEntity.getSimpleName());
|
||||
dto.setTableName(childEntity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(childEntity));
|
||||
|
||||
@@ -26,12 +26,15 @@ public class StbPublicationsDetail extends EntityBase {
|
||||
@SqlField(value = "entity_name")
|
||||
private String entityName;
|
||||
|
||||
@SqlField(value = "active", defaultObjectValue="1", nullable = false)
|
||||
private boolean active;
|
||||
|
||||
@SqlField(value = "ready_to_transmit", defaultObjectValue="0", nullable = false)
|
||||
private boolean readyToTransmit;
|
||||
|
||||
@SqlField(value = "recalc_columns")
|
||||
private String recalcColumnsField;
|
||||
|
||||
@SqlField(value = "syncronize", defaultObjectValue="1", nullable = false)
|
||||
private boolean syncronize;
|
||||
|
||||
@SqlField(value = "where_cond_sql")
|
||||
private String whereCondSql;
|
||||
|
||||
@@ -64,6 +67,24 @@ public class StbPublicationsDetail extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public StbPublicationsDetail setActive(boolean active) {
|
||||
this.active = active;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isReadyToTransmit() {
|
||||
return readyToTransmit;
|
||||
}
|
||||
|
||||
public StbPublicationsDetail setReadyToTransmit(boolean readyToTransmit) {
|
||||
this.readyToTransmit = readyToTransmit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRecalcColumnsField() {
|
||||
return recalcColumnsField;
|
||||
}
|
||||
@@ -73,15 +94,6 @@ public class StbPublicationsDetail extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSyncronize() {
|
||||
return syncronize;
|
||||
}
|
||||
|
||||
public StbPublicationsDetail setSyncronize(boolean syncronize) {
|
||||
this.syncronize = syncronize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getWhereCondSql() {
|
||||
return whereCondSql;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@Table(StbTransactionLogDb.ENTITY)
|
||||
@JsonTypeName(StbTransactionLogDb.ENTITY)
|
||||
public class StbTransactionLogDb extends EntityBase {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ENTITY = "stb_transaction_log_db";
|
||||
|
||||
@PK
|
||||
@Identity
|
||||
@SqlField(value = "id", nullable = false)
|
||||
private long id;
|
||||
|
||||
@SqlField(value = "transaction_date")
|
||||
private LocalDateTime transactionDate;
|
||||
|
||||
@SqlField(value = "user_name")
|
||||
private String userName;
|
||||
|
||||
@SqlField(value = "entity_name_list")
|
||||
private String entityNameList;
|
||||
|
||||
// @SqlField(value = "error_msg")
|
||||
// private String errorMsg;
|
||||
|
||||
// @SqlField(value = "esito")
|
||||
// private String esito;
|
||||
|
||||
// @SqlField(value = "exec_date")
|
||||
// private LocalDateTime execDate;
|
||||
|
||||
@SqlField(value = "transaction_json")
|
||||
private String transactionJson;
|
||||
|
||||
@SqlField(value = "transaction_group_id")
|
||||
private int transactionGroupIdField;
|
||||
|
||||
@SqlField(value = "transaction_query")
|
||||
private String transactionQuery;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setId(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LocalDateTime getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setTransactionDate(LocalDateTime transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntityNameList() {
|
||||
return entityNameList;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setEntityNameList(String entityNameList) {
|
||||
this.entityNameList = entityNameList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTransactionJson() {
|
||||
return transactionJson;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setTransactionJson(String transactionJson) {
|
||||
this.transactionJson = transactionJson;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTransactionGroupIdField() {
|
||||
return transactionGroupIdField;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setTransactionGroupIdField(int transactionGroupIdField) {
|
||||
this.transactionGroupIdField = transactionGroupIdField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTransactionQuery() {
|
||||
return transactionQuery;
|
||||
}
|
||||
|
||||
public StbTransactionLogDb setTransactionQuery(String transactionQuery) {
|
||||
this.transactionQuery = transactionQuery;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -374,18 +374,8 @@ public class UtilityBarcodeEan128 {
|
||||
break;
|
||||
case COUNTRY_INITIAL_PROCESS:
|
||||
model.ShipToPostISO = convertToIsoValueModel(aiValue, 0, String.class,
|
||||
new Callable<String, String>() {
|
||||
@Override
|
||||
public String call(String input) {
|
||||
return input;
|
||||
}
|
||||
},
|
||||
new CallableII<String, Integer, String>() {
|
||||
@Override
|
||||
public String call(String input, Integer input2) {
|
||||
return input;
|
||||
}
|
||||
});
|
||||
input -> input,
|
||||
(input, input2) -> input);
|
||||
break;
|
||||
case COUNTRY_PROCESS:
|
||||
model.CountryProcess = aiValue;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class EntityTestDefaultVal {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
EntityPropertyHolder holder = new EntityPropertyHolder();
|
||||
holder.scanEntityFields();
|
||||
holder.init();
|
||||
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
Set<Class<? extends EntityBase>> clssList = reflections.getSubTypesOf(EntityBase.class);
|
||||
|
||||
@@ -5,11 +5,13 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.document.dto.*;
|
||||
import it.integry.ems.document.dto.CaricoLavorazioneDTO;
|
||||
import it.integry.ems.document.dto.ChiusuraLavorazioneDTO;
|
||||
import it.integry.ems.document.dto.RientroLavorazioneDTO;
|
||||
import it.integry.ems.document.dto.ScaricoLavorazioneDTO;
|
||||
import it.integry.ems.document.service.DocumentProdService;
|
||||
import it.integry.ems.exception.MissingDataException;
|
||||
import it.integry.ems.exception.PrimaryDatabaseNotPresentException;
|
||||
import it.integry.ems.object_storage.minio.sdk.errors.MinioException;
|
||||
import it.integry.ems.production.dto.*;
|
||||
import it.integry.ems.report.dto.JasperDTO;
|
||||
import it.integry.ems.report.dto.PairsDTO;
|
||||
@@ -23,7 +25,6 @@ import it.integry.ems.utility.UtilityEntity;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.db.ResultSetMapper;
|
||||
import it.integry.ems_model.entity.*;
|
||||
import it.integry.ems_model.exception.*;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
@@ -35,16 +36,12 @@ import org.apache.pdfbox.printing.Orientation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -425,7 +422,7 @@ public class MesProductionServiceV2 {
|
||||
UtilityEntity.throwEntitiesException(UtilityEntity.toEntityBaseList(dtbOrdtList));
|
||||
}
|
||||
|
||||
public void cambioFase(Date dataOrd, Integer numOrd, String gestioneOrd, String codJfas, Integer idStep, Integer idRiga, String newCodJfas) throws SQLException, IOException, PrimaryDatabaseNotPresentException, DataConverterNotFoundException, InstantiationException, IllegalAccessException, RulesNotCompiledException, MergeEntityDBToObjectException, MinioException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, NoSuchFieldException, FieldMissingException, InvocationTargetException, ConverterNotConfiguredException, EntityException {
|
||||
public void cambioFase(Date dataOrd, Integer numOrd, String gestioneOrd, String codJfas, Integer idStep, Integer idRiga, String newCodJfas) throws Exception {
|
||||
String whereCondCodJfas = "";
|
||||
String whereCondIdStep = "";
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ public class UtilityController {
|
||||
@RequestMapping(value = EmsRestConstants.PATH_MERGE_PDF, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse mergePDF(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody List<PdfDTO> pdfList) {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||
@RequestBody List<PdfDTO> pdfList) {
|
||||
ServiceRestResponse response = null;
|
||||
try {
|
||||
response = utilityService.mergePDF(pdfList);
|
||||
@@ -143,15 +143,8 @@ public class UtilityController {
|
||||
@RequestMapping(value = EmsRestConstants.PATH_DECODE_EAN_128, method = RequestMethod.GET)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse decodeEan128(HttpServletRequest request,
|
||||
@RequestParam("ean128") String ean128) {
|
||||
ServiceRestResponse response;
|
||||
try {
|
||||
response = ServiceRestResponse.createPositiveResponse(UtilityBarcodeEan128.decode(ean128.getBytes()));
|
||||
} catch (Exception e) {
|
||||
logger.error(request.getRequestURI(), e);
|
||||
response = new ServiceRestResponse(EsitoType.KO, "", e);
|
||||
}
|
||||
return response;
|
||||
@RequestParam("ean128") String ean128) throws Exception {
|
||||
return ServiceRestResponse.createPositiveResponse(UtilityBarcodeEan128.decode(ean128.getBytes()));
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_SQL_TO_EXCEL, method = RequestMethod.POST)
|
||||
@@ -170,6 +163,7 @@ public class UtilityController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_READ_REMOTE_FILE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) {
|
||||
@@ -248,8 +242,8 @@ public class UtilityController {
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_GET_RICORRENZE, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getRicorrenze(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "anno") String anno) throws Exception {
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam(value = "anno") String anno) throws Exception {
|
||||
|
||||
try {
|
||||
return ServiceRestResponse.createPositiveResponse(utilityService.getRicorrenze(anno));
|
||||
|
||||
Reference in New Issue
Block a user