Fix su Change Tracking
This commit is contained in:
@@ -12,6 +12,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -174,16 +175,26 @@ public class DbmsChangeTracker {
|
|||||||
return result.stream()
|
return result.stream()
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
DetectedChangeDataDTO detectedChangeDataDTO = new DetectedChangeDataDTO()
|
DetectedChangeDataDTO detectedChangeDataDTO = new DetectedChangeDataDTO()
|
||||||
.setTableName(tableName)
|
.setTableName(tableName);
|
||||||
.setSysChangeVersion(UtilityHashMap.getValueIfExists(x, "SYS_CHANGE_VERSION"))
|
|
||||||
.setSysChangeCreationVersion(UtilityHashMap.getValueIfExists(x, "SYS_CHANGE_CREATION_VERSION"))
|
|
||||||
.setSysChangeOperation(DetectedChangeDataDTO.Operation.from(UtilityHashMap.<String>getValueIfExists(x, "SYS_CHANGE_OPERATION")));
|
|
||||||
|
|
||||||
x.remove("SYS_CHANGE_VERSION");
|
Long sysChangeVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_VERSION");
|
||||||
x.remove("SYS_CHANGE_CREATION_VERSION");
|
detectedChangeDataDTO.setSysChangeVersion(sysChangeVersion);
|
||||||
x.remove("SYS_CHANGE_OPERATION");
|
|
||||||
x.remove("SYS_CHANGE_COLUMNS");
|
|
||||||
x.remove("SYS_CHANGE_CONTEXT");
|
Long sysChangeCreationVersion = UtilityHashMap.<Long>getValueIfExists(x, "SYS_CHANGE_CREATION_VERSION");
|
||||||
|
detectedChangeDataDTO.setSysChangeCreationVersion(sysChangeCreationVersion);
|
||||||
|
|
||||||
|
detectedChangeDataDTO.setSysChangeOperation(DetectedChangeDataDTO.Operation.from(UtilityHashMap.<String>getValueIfExists(x, "SYS_CHANGE_OPERATION")));
|
||||||
|
|
||||||
|
List<String> keysToRemove = new ArrayList<>();
|
||||||
|
for (String colName : x.keySet()) {
|
||||||
|
if (colName.startsWith("SYS_"))
|
||||||
|
keysToRemove.add(colName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String colName : keysToRemove) {
|
||||||
|
x.remove(colName);
|
||||||
|
}
|
||||||
|
|
||||||
detectedChangeDataDTO.setPrimaryKey(x);
|
detectedChangeDataDTO.setPrimaryKey(x);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
|||||||
public class DetectedChangeDataDTO {
|
public class DetectedChangeDataDTO {
|
||||||
|
|
||||||
private long sysChangeVersion;
|
private long sysChangeVersion;
|
||||||
private long sysChangeCreationVersion;
|
private Long sysChangeCreationVersion;
|
||||||
private Operation sysChangeOperation;
|
private Operation sysChangeOperation;
|
||||||
|
|
||||||
private String tableName;
|
private String tableName;
|
||||||
@@ -24,11 +24,11 @@ public class DetectedChangeDataDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSysChangeCreationVersion() {
|
public Long getSysChangeCreationVersion() {
|
||||||
return sysChangeCreationVersion;
|
return sysChangeCreationVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DetectedChangeDataDTO setSysChangeCreationVersion(long sysChangeCreationVersion) {
|
public DetectedChangeDataDTO setSysChangeCreationVersion(Long sysChangeCreationVersion) {
|
||||||
this.sysChangeCreationVersion = sysChangeCreationVersion;
|
this.sysChangeCreationVersion = sysChangeCreationVersion;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import it.integry.ems_model.entity.WtbGestSetupUser;
|
|||||||
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
import it.integry.ems_model.exception.DataConverterNotFoundException;
|
||||||
import it.integry.ems_model.utility.UtilityDB;
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
import it.integry.ems_model.utility.UtilityQuery;
|
import it.integry.ems_model.utility.UtilityQuery;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -34,6 +36,8 @@ import java.util.stream.Collectors;
|
|||||||
@Component
|
@Component
|
||||||
public class EntityCacheComponent implements ApplicationListener {
|
public class EntityCacheComponent implements ApplicationListener {
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
private final DbmsChangeTrackerComponent dbmsChangeTrackerComponent;
|
private final DbmsChangeTrackerComponent dbmsChangeTrackerComponent;
|
||||||
private final EntityPropertyHolder entityPropertyHolder;
|
private final EntityPropertyHolder entityPropertyHolder;
|
||||||
|
|
||||||
@@ -67,6 +71,11 @@ public class EntityCacheComponent implements ApplicationListener {
|
|||||||
|
|
||||||
ConcurrentHashMap<HashMap<String, Object>, EntityBase> entities = retrieveEntityList(conn, tableName, clazz);
|
ConcurrentHashMap<HashMap<String, Object>, EntityBase> entities = retrieveEntityList(conn, tableName, clazz);
|
||||||
entityCache.get(customerDB).put(tableName, entities);
|
entityCache.get(customerDB).put(tableName, entities);
|
||||||
|
|
||||||
|
logger.trace(String.format("[%s] Cached %d records for entity %s",
|
||||||
|
customerDB.getValue(),
|
||||||
|
entities.size(),
|
||||||
|
clazz.getSimpleName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import com.annimon.stream.ComparatorCompat;
|
|||||||
import com.annimon.stream.Optional;
|
import com.annimon.stream.Optional;
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import it.integry.common.var.CommonConstants;
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems._context.ApplicationContextProvider;
|
||||||
|
import it.integry.ems.dynamic_cache.EntityCacheComponent;
|
||||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||||
|
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||||
import it.integry.ems_model.annotation.ReloadRow;
|
import it.integry.ems_model.annotation.ReloadRow;
|
||||||
import it.integry.ems_model.annotation.SqlField;
|
import it.integry.ems_model.annotation.SqlField;
|
||||||
@@ -690,10 +693,15 @@ public class CommonRules extends QueryRules {
|
|||||||
return barcode;
|
return barcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String completeFlagQtaCnfFissa(Connection connection, String codMart) throws Exception {
|
public static String completeFlagQtaCnfFissa(Connection connection, IntegryCustomerDB customerDB, String codMart) {
|
||||||
String sql = "select flag_qta_cnf_fissa from mtb_aart WHERE cod_mart = '" + codMart + "'";
|
final EntityCacheComponent entityCacheComponent = ApplicationContextProvider.getApplicationContext().getBean(EntityCacheComponent.class);
|
||||||
String flagQtaCnfFissa = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
|
|
||||||
return flagQtaCnfFissa;
|
final List<MtbAart> cachedMtbAarts = entityCacheComponent.getCachedEntitiesList(customerDB, MtbAart.ENTITY, x -> x.getCodMart().equals(codMart));
|
||||||
|
|
||||||
|
if (cachedMtbAarts == null || cachedMtbAarts.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return cachedMtbAarts.get(0).getFlagQtaCnfFissa();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getApplicationName(Connection connection) throws Exception {
|
public static String getApplicationName(Connection connection) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user