Merge branch 'develop' into feature/Spring5
# Conflicts: # pom.xml
This commit is contained in:
@@ -7,7 +7,7 @@ import it.integry.ems.Import.base.EntityImportResponse;
|
||||
import it.integry.ems.Import.dto.ImportRequestDTO;
|
||||
import it.integry.ems.download.DownloadFileHandlerService;
|
||||
import it.integry.ems.download.dto.DownloadFileDto;
|
||||
import it.integry.ems.dto.EntityHierarchyDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.export.base.EntityExportedFile;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -1153,7 +1153,7 @@ public class EmsController {
|
||||
public @ResponseBody
|
||||
ServiceRestResponse getEntityMapping(@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
|
||||
try {
|
||||
List<EntityHierarchyDTO> mapping = emsServices.getEntityMapping();
|
||||
List<EntityHierarchy> mapping = emsServices.getEntityMapping();
|
||||
return ServiceRestResponse.createPositiveResponse(mapping);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
||||
169
ems-core/src/main/java/it/integry/ems/dto/EntityHierarchy.java
Normal file
169
ems-core/src/main/java/it/integry/ems/dto/EntityHierarchy.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityHierarchy {
|
||||
|
||||
private Class<? extends EntityBase> clazz;
|
||||
private String entityName;
|
||||
private String tableName;
|
||||
private java.lang.reflect.Field parentField; //Used for entityChild
|
||||
private boolean master;
|
||||
private List<EntityHierarchy> children;
|
||||
private List<Field> fields;
|
||||
|
||||
public Class<? extends EntityBase> getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public EntityHierarchy setClazz(Class<? extends EntityBase> clazz) {
|
||||
this.clazz = clazz;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public void setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public java.lang.reflect.Field getParentField() {
|
||||
return parentField;
|
||||
}
|
||||
|
||||
public EntityHierarchy setParentField(java.lang.reflect.Field parentField) {
|
||||
this.parentField = parentField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public EntityHierarchy setMaster(boolean master) {
|
||||
this.master = master;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<EntityHierarchy> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<EntityHierarchy> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public void addChild(EntityHierarchy child) {
|
||||
this.children.add(child);
|
||||
}
|
||||
|
||||
public void removeChild(EntityHierarchy child) {
|
||||
this.children.remove(child);
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public EntityHierarchy setFields(List<Field> fields) {
|
||||
this.fields = fields;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static class Field {
|
||||
private java.lang.reflect.Field field;
|
||||
private Identity identity;
|
||||
private SqlField sqlField;
|
||||
private ObjectStorage objectStorage;
|
||||
private Blob blob;
|
||||
private Clob clob;
|
||||
|
||||
public java.lang.reflect.Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public Field setField(java.lang.reflect.Field field) {
|
||||
this.field = field;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSqlField() {
|
||||
return sqlField != null;
|
||||
}
|
||||
|
||||
public boolean isObjectStorage() {
|
||||
return objectStorage != null;
|
||||
}
|
||||
|
||||
public boolean isBlob() {
|
||||
return blob != null;
|
||||
}
|
||||
|
||||
public boolean isClob() {
|
||||
return clob != null;
|
||||
}
|
||||
|
||||
public boolean isIdentity() {
|
||||
return identity != null;
|
||||
}
|
||||
|
||||
public Identity getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public Field setIdentity(Identity identity) {
|
||||
this.identity = identity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SqlField getSqlField() {
|
||||
return sqlField;
|
||||
}
|
||||
|
||||
public Field setSqlField(SqlField sqlField) {
|
||||
this.sqlField = sqlField;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ObjectStorage getObjectStorage() {
|
||||
return objectStorage;
|
||||
}
|
||||
|
||||
public Field setObjectStorage(ObjectStorage objectStorage) {
|
||||
this.objectStorage = objectStorage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Blob getBlob() {
|
||||
return blob;
|
||||
}
|
||||
|
||||
public Field setBlob(Blob blob) {
|
||||
this.blob = blob;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Clob getClob() {
|
||||
return clob;
|
||||
}
|
||||
|
||||
public Field setClob(Clob clob) {
|
||||
this.clob = clob;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package it.integry.ems.dto;
|
||||
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityHierarchyDTO {
|
||||
|
||||
private Class<? extends EntityBase> clazz;
|
||||
private String entityName;
|
||||
private String tableName;
|
||||
private Field field;
|
||||
private boolean master;
|
||||
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;
|
||||
}
|
||||
|
||||
public void setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public EntityHierarchyDTO setField(Field field) {
|
||||
this.field = field;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMaster() {
|
||||
return master;
|
||||
}
|
||||
|
||||
public EntityHierarchyDTO setMaster(boolean master) {
|
||||
this.master = master;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<EntityHierarchyDTO> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public void addChild(EntityHierarchyDTO child) {
|
||||
this.children.add(child);
|
||||
}
|
||||
|
||||
public void removeChild(EntityHierarchyDTO child) {
|
||||
this.children.remove(child);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240509100435 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("alter table atb_list_imp_no_pref add qta_multipla_ordinabile numeric(20,5);");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240509103847 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
createOrUpdateView(
|
||||
"olvw_fabbisogni_sfusi",
|
||||
"CREATE VIEW dbo.olvw_fabbisogni_sfusi AS\n" +
|
||||
" --KG di olio impegnato da ordini di confezionamento\n" +
|
||||
"SELECT mtb_tipi.descrizione AS tipo,\n" +
|
||||
" mtb_stip.descrizione AS sottotipo,\n" +
|
||||
" dtb_ordt.cod_jfas AS linea,\n" +
|
||||
" dtb_ordt.cod_prod,\n" +
|
||||
" dtb_ordt.descrizione_prod,\n" +
|
||||
" '3.CONFEZIONAMENTO' AS causale,\n" +
|
||||
" dtb_ordt.data_cons_prod data,\n" +
|
||||
" 0 AS kg_giacenza_sfuso,\n" +
|
||||
" 0 AS kg_ord_ven_sfuso,\n" +
|
||||
" (dtb_ordt.qta_prod - dtb_ordt.qta_evasa_prod) * dtb_ordt.rap_conv_prod *\n" +
|
||||
" mtb_aart.peso_kg AS kg_ord_lav_conf,\n" +
|
||||
" 0 AS kg_ord_acq_sfuso,\n" +
|
||||
" -(dtb_ordt.qta_prod - dtb_ordt.qta_evasa_prod) * dtb_ordt.rap_conv_prod *\n" +
|
||||
" mtb_aart.peso_kg AS kg_disponibili\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordt.cod_prod = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_tipi ON mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" LEFT OUTER JOIN mtb_stip\n" +
|
||||
" ON mtb_aart.cod_mtip = mtb_stip.cod_mtip AND mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
"WHERE dtb_ordt.gestione = 'L'\n" +
|
||||
" AND dtb_ordt.flag_evaso_prod = 'I'\n" +
|
||||
" AND dtb_ordt.flag_evaso_forzato = 'N'\n" +
|
||||
" AND dtb_ordt.data_ord >= DATEADD(DAY, -60, GETDATE())\n" +
|
||||
"UNION ALL\n" +
|
||||
"--Giacenze olio sfuso\n" +
|
||||
"SELECT mtb_tipi.descrizione AS tipo,\n" +
|
||||
" mtb_stip.descrizione AS sottotipo,\n" +
|
||||
" mtb_part.cod_mdep AS linea,\n" +
|
||||
" mtb_aart.cod_mart AS cod_prod,\n" +
|
||||
" mtb_aart.descrizione_estesa AS descrizione_prod,\n" +
|
||||
" '1.GIACENZA' AS causale,\n" +
|
||||
" CONVERT(DATE, GETDATE()) AS data,\n" +
|
||||
" qta_esistente AS kg_giacenza_sfuso,\n" +
|
||||
" 0 AS kg_ord_ven_sfuso,\n" +
|
||||
" 0 AS kg_ord_lav_conf,\n" +
|
||||
" 0 AS kg_ord_acq_sfuso,\n" +
|
||||
" qta_esistente AS kg_disponibili\n" +
|
||||
"FROM mtb_part\n" +
|
||||
" INNER JOIN mtb_aart ON mtb_part.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" INNER JOIN mtb_tipi ON mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" INNER JOIN mtb_stip\n" +
|
||||
" ON mtb_aart.cod_mtip = mtb_stip.cod_mtip AND mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
"WHERE mtb_aart.cod_mgrp IN ('S', 'SO', 'SOR')\n" +
|
||||
" AND qta_esistente > 0\n" +
|
||||
"UNION ALL\n" +
|
||||
"--Impegni da ordine di vendita sfuso\n" +
|
||||
"SELECT mtb_tipi.descrizione AS tipo,\n" +
|
||||
" mtb_stip.descrizione AS sottotipo,\n" +
|
||||
" dtb_ordt.cod_mdep AS linea,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" '2.ORDINE DI VENDITA' AS causale,\n" +
|
||||
" dtb_ordr.data_cons AS data,\n" +
|
||||
" 0 AS kg_giacenza_sfuso,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * rap_conv * mtb_aart.peso_kg END AS kg_ord_ven_sfuso,\n" +
|
||||
" 0 AS kg_ord_lav_conf,\n" +
|
||||
" 0 AS kg_ord_acq_sfuso,\n" +
|
||||
" -CASE\n" +
|
||||
" WHEN (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * rap_conv * mtb_aart.peso_kg END AS kg_disponibili\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr\n" +
|
||||
" ON dtb_ordt.gestione = dtb_ordr.gestione AND dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_tipi ON mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" LEFT OUTER JOIN mtb_stip\n" +
|
||||
" ON mtb_aart.cod_mtip = mtb_stip.cod_mtip AND mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
"WHERE dtb_ordt.gestione = 'V'\n" +
|
||||
" AND dtb_ordr.flag_Evaso = 'I'\n" +
|
||||
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND dtb_ordt.data_ord >= DATEADD(DAY, -60, GETDATE())\n" +
|
||||
" AND mtb_aart.cod_mgrp IN ('S', 'SO', 'SOR')\n" +
|
||||
"UNION ALL\n" +
|
||||
"--Ordini a fornitori\n" +
|
||||
"SELECT mtb_tipi.descrizione AS tipo,\n" +
|
||||
" mtb_stip.descrizione AS sottotipo,\n" +
|
||||
" dtb_ordt.cod_mdep AS linea,\n" +
|
||||
" dtb_ordr.cod_mart,\n" +
|
||||
" mtb_aart.descrizione_estesa,\n" +
|
||||
" '4.ORDINE DI ACQUISTO' AS causale,\n" +
|
||||
" dtb_ordr.data_cons AS data,\n" +
|
||||
" 0 AS kg_giacenza_sfuso,\n" +
|
||||
" 0 AS kg_ord_ven_sfuso,\n" +
|
||||
" 0 AS kg_ord_lav_conf,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * rap_conv * mtb_aart.peso_kg END AS kg_ord_acq_sfuso,\n" +
|
||||
" CASE\n" +
|
||||
" WHEN (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) < 0 THEN 0\n" +
|
||||
" ELSE (dtb_ordr.qta_ord - dtb_ordr.qta_evasa) * rap_conv * mtb_aart.peso_kg END AS kg_disponibili\n" +
|
||||
"FROM dtb_ordt\n" +
|
||||
" INNER JOIN dtb_ordr\n" +
|
||||
" ON dtb_ordt.gestione = dtb_ordr.gestione AND dtb_ordt.data_ord = dtb_ordr.data_ord AND\n" +
|
||||
" dtb_ordt.num_ord = dtb_ordr.num_ord\n" +
|
||||
" INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart\n" +
|
||||
" LEFT OUTER JOIN mtb_tipi ON mtb_aart.cod_mtip = mtb_tipi.cod_mtip\n" +
|
||||
" LEFT OUTER JOIN mtb_stip\n" +
|
||||
" ON mtb_aart.cod_mtip = mtb_stip.cod_mtip AND mtb_aart.cod_mstp = mtb_stip.cod_mstp\n" +
|
||||
"WHERE dtb_ordt.gestione = 'A'\n" +
|
||||
" AND dtb_ordr.flag_Evaso = 'I'\n" +
|
||||
" AND dtb_ordt.flag_annulla = 'N'\n" +
|
||||
" AND dtb_ordt.data_ord >= DATEADD(DAY, -60, GETDATE())\n" +
|
||||
" AND mtb_aart.cod_mgrp IN ('S', 'SO', 'SOR')"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.dto.ApplicationInfoDTO;
|
||||
import it.integry.ems.dto.DatabaseEngineInfoDTO;
|
||||
import it.integry.ems.dto.DatabaseInfoDTO;
|
||||
import it.integry.ems.dto.EntityHierarchyDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.export.base.EntityExportResponse;
|
||||
import it.integry.ems.export.base.EntityExporterUtility;
|
||||
import it.integry.ems.export.base.IEntityExporter;
|
||||
@@ -997,7 +997,7 @@ public class EmsServices {
|
||||
return files;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityMapping() {
|
||||
public List<EntityHierarchy> getEntityMapping() {
|
||||
return entityPropertyHolder.getEntityHierarchyMap();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement;
|
||||
import io.minio.errors.ErrorResponseException;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.common.var.EmsDBConst;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.object_storage.minio.MinIONotEnabledException;
|
||||
import it.integry.ems.object_storage.minio.MinIOService;
|
||||
import it.integry.ems.rules.completing.CommonRules;
|
||||
@@ -35,6 +36,7 @@ import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityHashMap;
|
||||
import it.integry.ems_model.utility.UtilityString;
|
||||
import it.integry.ems_model.utility.UtilityZip;
|
||||
import kotlin.Triple;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
@@ -648,7 +650,8 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
|
||||
field.set(entity, columnValue);
|
||||
} catch (SQLException | MinIONotEnabledException | XmlPullParserException | NoSuchAlgorithmException |
|
||||
} catch (SQLException | MinIONotEnabledException | XmlPullParserException |
|
||||
NoSuchAlgorithmException |
|
||||
IOException | InvalidKeyException e) {
|
||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||
throw e;
|
||||
@@ -1170,7 +1173,7 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
public void applyDefault(String fieldName) throws IllegalAccessException, IOException {
|
||||
List<Field> fields = getEntityHolder().getFields(this.getClass());
|
||||
|
||||
if(!UtilityString.isNullOrEmpty(fieldName)) {
|
||||
if (!UtilityString.isNullOrEmpty(fieldName)) {
|
||||
fields = fields.stream()
|
||||
.filter(x -> x.getName().equalsIgnoreCase(fieldName))
|
||||
.collect(Collectors.toList());
|
||||
@@ -1353,11 +1356,19 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
|
||||
public void insertEntity() throws Exception {
|
||||
|
||||
if (!(connection instanceof SQLServerConnection)) {
|
||||
throw new Exception("Impossibile processare una entity su una connessione diversa da SQL Server");
|
||||
}
|
||||
|
||||
SQLServerConnection sqlServerConnection = (SQLServerConnection) connection;
|
||||
|
||||
if (nativeSql != null) {
|
||||
PreparedStatement pstm = connection.prepareStatement(nativeSql);
|
||||
SQLServerPreparedStatement pstm = (SQLServerPreparedStatement) sqlServerConnection.prepareStatement(nativeSql);
|
||||
pstm.setQueryTimeout(queryTimeoutSeconds);
|
||||
pstm.executeUpdate();
|
||||
pstm.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1365,41 +1376,42 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
ForeignKeyRules.chkConstraint(connection, this.getChkConstraintSql());
|
||||
UniqueKeyRules.chkConstraint(connection, this);
|
||||
|
||||
List<Field> fields = getEntityHolder().getFields(this.getClass());
|
||||
List<EntityHierarchy.Field> fields = getEntityHolder()
|
||||
.getEntitySqlFields(this.getClass());
|
||||
|
||||
final List<kotlin.Triple<String, Object, Boolean>> preparedFieldsToQuery = prepareFieldsToQuery(fields);
|
||||
// preparedField: 1 = sql_field_name, 2 = value_to_save, 3 = is_identity
|
||||
|
||||
List<String> campi = new ArrayList<>();
|
||||
List<String> valori = new ArrayList<>();
|
||||
List<Object> originalValues = new ArrayList<>();
|
||||
|
||||
Map<Integer, Object> mapLob = getFieldToQuery(fields, campi, valori, originalValues);
|
||||
|
||||
if (!campi.isEmpty()) {
|
||||
|
||||
|
||||
boolean containsIdentity = mapLob.containsKey(-1);
|
||||
boolean containsIdentity = false;
|
||||
String identityFieldName = null;
|
||||
|
||||
if (containsIdentity) {
|
||||
identityFieldName = (String) mapLob.get(-1);
|
||||
mapLob.remove(-1);
|
||||
}
|
||||
|
||||
long insertedIdentity = -1;
|
||||
|
||||
if (connection instanceof SQLServerConnection) {
|
||||
SQLServerConnection sqlServerConnection = (SQLServerConnection) connection;
|
||||
final Triple<String, Object, Boolean> identityData = preparedFieldsToQuery.stream()
|
||||
.filter(Triple::getThird)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if(identityData != null) {
|
||||
containsIdentity = true;
|
||||
identityFieldName = identityData.getFirst();
|
||||
}
|
||||
|
||||
final List<Triple<String, Object, Boolean>> fieldsWithoutIdentityAndNotNull = preparedFieldsToQuery.stream()
|
||||
.filter(x -> !x.getThird() && x.getSecond() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
StringBuilder insertSQL = new StringBuilder("INSERT INTO ")
|
||||
.append(getTableName())
|
||||
.append(" (")
|
||||
.append(StringUtils.join(campi, ","))
|
||||
.append(StringUtils.join(
|
||||
fieldsWithoutIdentityAndNotNull.stream().map(Triple::getFirst).collect(Collectors.toList()), ","))
|
||||
.append(") VALUES (");
|
||||
|
||||
for (int i = 0; i < campi.size(); i++) {
|
||||
for (int i = 0; i < fieldsWithoutIdentityAndNotNull.size(); i++) {
|
||||
insertSQL.append(" ?");
|
||||
|
||||
if (i < campi.size() - 1)
|
||||
if (i < fieldsWithoutIdentityAndNotNull.size() - 1)
|
||||
insertSQL.append(",");
|
||||
}
|
||||
|
||||
@@ -1410,8 +1422,8 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
insertSQL.toString(),
|
||||
containsIdentity ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS)) {
|
||||
|
||||
for (int i = 1; i <= originalValues.size(); i++) {
|
||||
insertBulkPs.setObject(i, SqlFieldHolder.getSqlValueFieldAsObject(originalValues.get(i - 1), true));
|
||||
for (int i = 1; i <= fieldsWithoutIdentityAndNotNull.size(); i++) {
|
||||
insertBulkPs.setObject(i, fieldsWithoutIdentityAndNotNull.get(i - 1).getSecond());
|
||||
}
|
||||
|
||||
long insertedRowCount = insertBulkPs.executeLargeUpdate();
|
||||
@@ -1422,36 +1434,6 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
String sql = "INSERT INTO " + getTableName() + "(" + StringUtils.join(campi, ",") + ") " + "VALUES (" + StringUtils.join(valori, ",") + ")";
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("QUERY: " + sql);
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement pstm = connection.prepareStatement(sql, containsIdentity ? Statement.RETURN_GENERATED_KEYS : Statement.NO_GENERATED_KEYS);
|
||||
setupBinaryParams(mapLob, pstm);
|
||||
|
||||
int insertedRowCount = pstm.executeUpdate();
|
||||
pstm.setQueryTimeout(queryTimeoutSeconds);
|
||||
|
||||
if (insertedRowCount > 0 && containsIdentity) {
|
||||
try (ResultSet rs = pstm.getGeneratedKeys()) {
|
||||
if (rs.next())
|
||||
insertedIdentity = rs.getLong(1);
|
||||
}
|
||||
}
|
||||
|
||||
pstm.close();
|
||||
} catch (SQLException e) {
|
||||
throw new EntityException(e, this, sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (containsIdentity) {
|
||||
if (insertedIdentity < 0)
|
||||
throw new Exception("Impossibile leggere il campo identity anche se è richiesto");
|
||||
@@ -1460,9 +1442,6 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
identityField.setAccessible(true);
|
||||
identityField.set(this, insertedIdentity);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Exception("Nessun campo valorizzato per la entity " + getTableName() + " (Controllare metodi get/set della entity)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1847,105 +1826,117 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
return whereCondOldPk;
|
||||
}
|
||||
|
||||
private Map<Integer, Object> getFieldToQuery(List<Field> fields, List<String> campi, List<String> valori, List<Object> originalValues) throws Exception {
|
||||
private List<kotlin.Triple<String, Object, Boolean>> prepareFieldsToQuery(List<EntityHierarchy.Field> fields) throws Exception {
|
||||
List<kotlin.Triple<String, Object, Boolean>> resultList = new ArrayList<>();
|
||||
|
||||
Map<Integer, Object> map = new HashMap<Integer, Object>();
|
||||
Integer counter = 1;
|
||||
for (Field field : fields) {
|
||||
for (EntityHierarchy.Field entityHierachyfield : fields) {
|
||||
Field field = entityHierachyfield.getField();
|
||||
field.setAccessible(true);
|
||||
Object obj = field.get(this);
|
||||
String defaultVal = null;
|
||||
int maxValueLength = -1;
|
||||
boolean nullableValue = true;
|
||||
|
||||
if (obj != null && (field.isAnnotationPresent(ObjectStorage.class))) {
|
||||
ObjectStorage objectStorage = field.getAnnotation(ObjectStorage.class);
|
||||
Object originalObject = field.get(this);
|
||||
|
||||
if (originalObject != null && entityHierachyfield.isObjectStorage()) {
|
||||
ObjectStorage objectStorage = entityHierachyfield.getObjectStorage();
|
||||
MinIOService minIOService = ContextLoader.getCurrentWebApplicationContext().getBean(MinIOService.class);
|
||||
|
||||
if (minIOService != null && minIOService.isEnabled() && !SettingsModel.getInstance().getMinioConfiguration().getExcludedEntities().contains(this.getTableName())) {
|
||||
|
||||
String refUuid = null;
|
||||
|
||||
if (obj instanceof String)
|
||||
refUuid = minIOService.uploadObject(Base64.decodeBase64((String) obj), connection);
|
||||
else if (obj instanceof byte[]) refUuid = minIOService.uploadObject((byte[]) obj, connection);
|
||||
byte[] dataToUpload = null;
|
||||
|
||||
if (originalObject instanceof String)
|
||||
dataToUpload = Base64.decodeBase64((String) originalObject);
|
||||
else if (originalObject instanceof byte[])
|
||||
dataToUpload = (byte[]) originalObject;
|
||||
|
||||
if (dataToUpload == null)
|
||||
continue;
|
||||
|
||||
refUuid = minIOService.uploadObject(dataToUpload, connection);
|
||||
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(refUuid)) {
|
||||
campi.add("ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : ""));
|
||||
valori.add(SqlFieldHolder.getSqlValueFieldAsString(refUuid).toString());
|
||||
originalValues.add(refUuid);
|
||||
final String refUuidFinalName = "ref_uuid" + (objectStorage.suffix() > 0 ? objectStorage.suffix() : "");
|
||||
final String refUuidContent = SqlFieldHolder.getSqlValueFieldAsString(refUuid);
|
||||
|
||||
resultList.add(new kotlin.Triple<>(refUuidFinalName, refUuidContent, false));
|
||||
}
|
||||
|
||||
if (!SettingsModel.getInstance().getMinioConfiguration().isEnableOldSave()) continue;
|
||||
}
|
||||
}
|
||||
|
||||
String defaultValue = null;
|
||||
int maxValueLength = -1;
|
||||
boolean nullableValue = true;
|
||||
|
||||
SqlField sqlField = field.getAnnotation(SqlField.class);
|
||||
if (sqlField != null) {
|
||||
defaultVal = sqlField.defaultObjectValue();
|
||||
SqlField sqlField = entityHierachyfield.getSqlField();
|
||||
|
||||
if (entityHierachyfield.isSqlField()) {
|
||||
defaultValue = sqlField.defaultObjectValue();
|
||||
|
||||
SimpleDateFormat sdf = null;
|
||||
if (CommonConstants.SYSDATE.equals(defaultVal)) sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
else if (CommonConstants.TIMESTAMP.equals(defaultVal))
|
||||
if (CommonConstants.SYSDATE.equals(defaultValue)) sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
else if (CommonConstants.TIMESTAMP.equals(defaultValue))
|
||||
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (sdf != null) defaultVal = sdf.format(new Date());
|
||||
if (sdf != null) defaultValue = sdf.format(new Date());
|
||||
|
||||
maxValueLength = sqlField.maxLength();
|
||||
nullableValue = sqlField.nullable();
|
||||
}
|
||||
|
||||
if (field.isAnnotationPresent(Identity.class) && field.isAnnotationPresent(SqlField.class)) {
|
||||
if (entityHierachyfield.isSqlField() && entityHierachyfield.isIdentity()) {
|
||||
|
||||
//Escludiamo il campo identity dalla insert
|
||||
map.put(-1, SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||
resultList.add(new Triple<>(SqlFieldHolder.getSqlValue(sqlField.value(), field), null, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (originalObject == null && UtilityString.isNullOrEmpty(defaultValue))
|
||||
continue;
|
||||
|
||||
//Questo ciclo non passa dai campi non valorizzati nella entity
|
||||
// if(obj == null && defaultVal == null && !nullableValue) {
|
||||
// throw new NonNullableFieldException(sqlField.value());
|
||||
// }
|
||||
if (!entityHierachyfield.isSqlField() || field.getName().startsWith("refUuid"))
|
||||
continue;
|
||||
|
||||
if ((obj != null || !UtilityString.isNullOrEmpty(defaultVal)) && (sqlField = field.getAnnotation(SqlField.class)) != null && !field.getName().startsWith("refUuid")) {
|
||||
// esclusione colonne per sincronizzazione
|
||||
if (excludedColumns != null && excludedColumns.contains(SqlFieldHolder.getSqlValue(sqlField.value(), field)))
|
||||
continue;
|
||||
if (field.getAnnotation(it.integry.ems_model.annotation.Clob.class) != null) {
|
||||
Clob clobData = setupClobData(counter, map, obj);
|
||||
valori.add("?");
|
||||
originalValues.add(clobData);
|
||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||
|
||||
counter++;
|
||||
} else if (field.getAnnotation(it.integry.ems_model.annotation.Blob.class) != null) {
|
||||
Blob blobData = setupBlobData(counter, map, obj);
|
||||
valori.add("?");
|
||||
originalValues.add(blobData);
|
||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||
if (entityHierachyfield.isClob()) {
|
||||
if (originalObject != null)
|
||||
resultList.add(new Triple<>(
|
||||
SqlFieldHolder.getSqlValue(sqlField.value(), field),
|
||||
prepareClobData(originalObject),
|
||||
false));
|
||||
|
||||
} else if (entityHierachyfield.isBlob()) {
|
||||
if (originalObject != null)
|
||||
resultList.add(new Triple<>(
|
||||
SqlFieldHolder.getSqlValue(sqlField.value(), field),
|
||||
prepareBlobData(originalObject),
|
||||
false));
|
||||
|
||||
counter++;
|
||||
} else {
|
||||
Object originalValue = obj == null ? defaultVal : obj;
|
||||
String value = SqlFieldHolder.getSqlValueFieldAsString(originalValue, sqlField.trimSpaces());
|
||||
Object finalValue = SqlFieldHolder.getSqlValueFieldAsObject(originalObject == null ? defaultValue : originalObject, sqlField.trimSpaces());
|
||||
|
||||
if (obj instanceof String) {
|
||||
value = value.replaceAll("\r", "' + CHAR(13) + '").replaceAll("\n", "' + CHAR(10) + '");
|
||||
if (maxValueLength >= 0 && !((String) obj).equalsIgnoreCase(EmsRestConstants.NULL) && ((String) obj).length() > maxValueLength)
|
||||
if (finalValue instanceof String) {
|
||||
if (maxValueLength >= 0 &&
|
||||
!((String) finalValue).equalsIgnoreCase(EmsRestConstants.NULL) &&
|
||||
((String) finalValue).length() > maxValueLength)
|
||||
throw new FieldLengthException(sqlField.value(), maxValueLength);
|
||||
|
||||
// finalValue = ((String) finalValue)
|
||||
// .replaceAll("\r", "' + CHAR(13) + '")
|
||||
// .replaceAll("\n", "' + CHAR(10) + '");
|
||||
}
|
||||
|
||||
valori.add(value);
|
||||
originalValues.add(originalValue);
|
||||
campi.add(SqlFieldHolder.getSqlValue(sqlField.value(), field));
|
||||
resultList.add(new Triple<>(SqlFieldHolder.getSqlValue(sqlField.value(), field), finalValue, false));
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private Map<Integer, Object> getFieldToUpdate(List<Field> fields, List<String> campi, List<String> where) throws Exception {
|
||||
Integer counter = 1;
|
||||
@@ -2023,32 +2014,40 @@ public abstract class EntityBase implements Serializable, Cloneable, EntityInter
|
||||
return mapLob;
|
||||
}
|
||||
|
||||
private Blob setupBlobData(Integer counter, Map<Integer, Object> mapLob, Object obj) throws SQLException {
|
||||
private Blob prepareBlobData(Object object) throws SQLException {
|
||||
Blob blobData = connection.createBlob();
|
||||
|
||||
byte[] blob;
|
||||
if (EmsRestConstants.NULL.equals(obj.toString())) blob = obj.toString().getBytes();
|
||||
if (EmsRestConstants.NULL.equals(object.toString())) blob = object.toString().getBytes();
|
||||
else
|
||||
// base64 conversion
|
||||
blob = Base64.decodeBase64(obj.toString());
|
||||
blob = Base64.decodeBase64(object.toString());
|
||||
|
||||
blobData.setBytes(1, blob);
|
||||
return blobData;
|
||||
}
|
||||
|
||||
private Blob setupBlobData(Integer counter, Map<Integer, Object> mapLob, Object obj) throws SQLException {
|
||||
Blob blobData = prepareBlobData(obj);
|
||||
mapLob.put(counter, blobData);
|
||||
|
||||
return blobData;
|
||||
}
|
||||
|
||||
|
||||
private Clob setupClobData(Integer counter, Map<Integer, Object> mapLob, Object obj) throws SQLException {
|
||||
private Clob prepareClobData(Object object) throws SQLException {
|
||||
Clob clobData = connection.createClob();
|
||||
|
||||
String clob;
|
||||
if (EmsRestConstants.NULL.equals(obj.toString())) clob = obj.toString();
|
||||
if (EmsRestConstants.NULL.equals(object.toString())) clob = object.toString();
|
||||
else
|
||||
// base64 conversion
|
||||
clob = new String(Base64.decodeBase64(obj.toString()));
|
||||
clob = new String(Base64.decodeBase64(object.toString()));
|
||||
|
||||
clobData.setString(1, clob);
|
||||
return clobData;
|
||||
}
|
||||
|
||||
private Clob setupClobData(Integer counter, Map<Integer, Object> mapLob, Object obj) throws SQLException {
|
||||
Clob clobData = prepareClobData(obj);
|
||||
mapLob.put(counter, clobData);
|
||||
return clobData;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package it.integry.ems_model.base;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import it.integry.ems.dto.EntityHierarchyDTO;
|
||||
import it.integry.ems.dto.EntityHierarchy;
|
||||
import it.integry.ems.object_storage.minio.MinIOService;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
@@ -38,7 +38,7 @@ public class EntityPropertyHolder {
|
||||
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private List<EntityHierarchyDTO> entityHierarchyMap;
|
||||
private List<EntityHierarchy> entityHierarchyMap;
|
||||
|
||||
private final HashMap<String, Class<?>> entityNameMap = new HashMap<>();
|
||||
private final HashMap<String, Object> classMap = new HashMap<>();
|
||||
@@ -59,27 +59,27 @@ public class EntityPropertyHolder {
|
||||
}
|
||||
|
||||
public Class<? extends EntityBase> getEntityClassFromTableName(String tableName) {
|
||||
List<EntityHierarchyDTO> tempList = new ArrayList<>(entityHierarchyMap);
|
||||
List<EntityHierarchy> 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)
|
||||
.map(EntityHierarchy::getClazz)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityHierarchyMap() {
|
||||
public List<EntityHierarchy> getEntityHierarchyMap() {
|
||||
return entityHierarchyMap;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
scanEntityFields();
|
||||
scanEntityFieldsOLD();
|
||||
entityHierarchyMap = scanEntityMapping();
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> scanEntityMapping() {
|
||||
List<EntityHierarchyDTO> mapping = new ArrayList<>();
|
||||
public List<EntityHierarchy> scanEntityMapping() {
|
||||
List<EntityHierarchy> mapping = new ArrayList<>();
|
||||
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
Set<Class<? extends EntityBase>> classes = reflections.get(SubTypes.of(EntityBase.class).asClass())
|
||||
@@ -89,20 +89,45 @@ public class EntityPropertyHolder {
|
||||
for (Class<? extends EntityBase> entity : classes) {
|
||||
if (!entity.isAnnotationPresent(Table.class)) continue;
|
||||
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
EntityHierarchy dto = new EntityHierarchy();
|
||||
dto.setClazz(entity);
|
||||
dto.setEntityName(entity.getSimpleName());
|
||||
dto.setTableName(entity.getAnnotation(Table.class).value());
|
||||
dto.setChildren(getEntityChildren(entity));
|
||||
dto.setMaster(entity.isAnnotationPresent(Master.class));
|
||||
dto.setFields(scanEntityHieracyFields(entity));
|
||||
|
||||
mapping.add(dto);
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
private List<EntityHierarchy.Field> scanEntityHieracyFields(Class<?> clazz) {
|
||||
final Field[] declaredFields = clazz.getDeclaredFields();
|
||||
|
||||
private void scanEntityFields() {
|
||||
List<EntityHierarchy.Field> analyzedFields = new ArrayList<>();
|
||||
|
||||
if (clazz.getSuperclass() != EntityBase.class) {
|
||||
analyzedFields.addAll(scanEntityHieracyFields(clazz.getSuperclass()));
|
||||
}
|
||||
|
||||
for (Field declaredField : declaredFields) {
|
||||
analyzedFields.add(new EntityHierarchy.Field()
|
||||
.setField(declaredField)
|
||||
.setIdentity(declaredField.getAnnotation(Identity.class))
|
||||
.setSqlField(declaredField.getAnnotation(SqlField.class))
|
||||
.setObjectStorage(declaredField.getAnnotation(ObjectStorage.class))
|
||||
.setClob(declaredField.getAnnotation(Clob.class))
|
||||
.setBlob(declaredField.getAnnotation(Blob.class)));
|
||||
}
|
||||
|
||||
|
||||
return analyzedFields;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
private void scanEntityFieldsOLD() {
|
||||
Reflections reflections = new Reflections("it.integry.ems_model.entity");
|
||||
List<Class<?>> clssList = new ArrayList<>(reflections.get(SubTypes.of(EntityBase.class).asClass()));
|
||||
|
||||
@@ -167,6 +192,7 @@ public class EntityPropertyHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ArrayList<Field> getFields(Class<?> clazz) {
|
||||
ArrayList<Field> fields = new ArrayList(Arrays.asList(clazz.getDeclaredFields()));
|
||||
|
||||
@@ -177,6 +203,7 @@ public class EntityPropertyHolder {
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Collection<String> getPkField(Class<? extends EntityBase> clazz) {
|
||||
|
||||
List<String> coll = ((List<String>) classMap.get(clazz.getSimpleName() + "_PK"));
|
||||
@@ -195,6 +222,7 @@ public class EntityPropertyHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<Field> getEntityChildField(Class<? extends EntityBase> clazz) {
|
||||
|
||||
List<Field> coll = ((List<Field>) classMap.get(clazz.getSimpleName() + "_CHILD"));
|
||||
@@ -213,16 +241,36 @@ public class EntityPropertyHolder {
|
||||
}
|
||||
|
||||
|
||||
public List<Field> getEntityChildFields(Class<? extends EntityBase> clazz) {
|
||||
public List<EntityHierarchy.Field> getEntityFields(Class<? extends EntityBase> clazz) {
|
||||
return this.entityHierarchyMap.stream()
|
||||
.filter(x -> x.getClazz().equals(clazz))
|
||||
.map(EntityHierarchyDTO::getChildren)
|
||||
.map(EntityHierarchy::getFields)
|
||||
.flatMap(Collection::stream)
|
||||
.map(EntityHierarchyDTO::getField)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public List<EntityHierarchy.Field> getEntitySqlFields(Class<? extends EntityBase> clazz) {
|
||||
return this.entityHierarchyMap.stream()
|
||||
.filter(x -> x.getClazz().equals(clazz))
|
||||
.map(EntityHierarchy::getFields)
|
||||
.flatMap(Collection::stream)
|
||||
.filter(EntityHierarchy.Field::isSqlField)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public List<Field> getEntityChildFields(Class<? extends EntityBase> clazz) {
|
||||
return this.entityHierarchyMap.stream()
|
||||
.filter(x -> x.getClazz().equals(clazz))
|
||||
.map(EntityHierarchy::getChildren)
|
||||
.flatMap(Collection::stream)
|
||||
.map(EntityHierarchy::getParentField)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public List<EntityBase> getEntityChain(List<? extends EntityBase> entityList, Connection conn, EntityBase testata) throws Exception {
|
||||
List<EntityBase> chain = new ArrayList<EntityBase>();
|
||||
|
||||
@@ -296,28 +344,18 @@ public class EntityPropertyHolder {
|
||||
return chain;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<EntityBase> getEntityChain(List<? extends EntityBase> entityList, Connection conn) throws Exception {
|
||||
return getEntityChain(entityList, conn, null);
|
||||
}
|
||||
|
||||
public Map<String, String> getOtherSetCondition(String otherSet) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
if (!"".equals(otherSet)) {
|
||||
String[] list = otherSet.split(",");
|
||||
for (String setCond : list) {
|
||||
String[] setter = setCond.split("=");
|
||||
if (setter.length == 2) {
|
||||
map.put(setter[0].trim(), setter[1].trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Field getFieldBySql(String className, String sqlFieldName) {
|
||||
return ((BiMap<Field, String>) getFieldToSqlMap(className)).inverse().get(sqlFieldName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Field getFieldByName(String className, String fieldName) {
|
||||
List<Field> fieldList = (List<Field>) classMap.get(className + "_FIELDS");
|
||||
|
||||
@@ -333,6 +371,7 @@ public class EntityPropertyHolder {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getWherePK(EntityBase entity) throws IllegalAccessException {
|
||||
List<String> where = new ArrayList<>();
|
||||
|
||||
@@ -412,10 +451,12 @@ public class EntityPropertyHolder {
|
||||
return StringUtils.join(where, " AND ");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getColumnList(Class clazz, String tableName) {
|
||||
return getColumnList(clazz, true, tableName, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getColumnList(Class clazz, boolean isSql, String tableName, boolean includeForcedRecalc) {
|
||||
List<String> colList = new ArrayList<String>();
|
||||
|
||||
@@ -464,6 +505,7 @@ public class EntityPropertyHolder {
|
||||
return StringUtils.join(colList, ", ");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public HashMap<String, String> getColumnMap(Class clazz, Boolean isSql) {
|
||||
|
||||
HashBiMap<Field, String> fieldToSqlMap =
|
||||
@@ -482,6 +524,7 @@ public class EntityPropertyHolder {
|
||||
return columnsMap;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Field getRigaField(Class clazz) {
|
||||
List<Field> list = (List<Field>) classMap.get(clazz.getSimpleName() + "_DETAIL_ID");
|
||||
if (!list.isEmpty())
|
||||
@@ -489,8 +532,8 @@ public class EntityPropertyHolder {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<EntityHierarchyDTO> getEntityChildren(Class<? extends EntityBase> entity) {
|
||||
List<EntityHierarchyDTO> children = new ArrayList<>();
|
||||
public List<EntityHierarchy> getEntityChildren(Class<? extends EntityBase> entity) {
|
||||
List<EntityHierarchy> children = new ArrayList<>();
|
||||
Field[] fields = entity.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getAnnotation(EntityChild.class) != null) {
|
||||
@@ -507,7 +550,7 @@ public class EntityPropertyHolder {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
EntityHierarchyDTO dto = new EntityHierarchyDTO();
|
||||
EntityHierarchy dto = new EntityHierarchy();
|
||||
dto.setClazz(childEntity);
|
||||
dto.setEntityName(childEntity.getSimpleName());
|
||||
dto.setTableName(childEntity.getAnnotation(Table.class).value());
|
||||
@@ -516,13 +559,15 @@ public class EntityPropertyHolder {
|
||||
//Prendo i fields solo delle entity non autoreferenziate
|
||||
dto.setChildren(getEntityChildren(childEntity));
|
||||
|
||||
dto.setField(field);
|
||||
dto.setParentField(field);
|
||||
children.add(dto);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public HashMap<String, List<String>> getObjectStorageFieldsMap() {
|
||||
final List<String> objStorClassKeys = classMap.keySet().stream().filter(x -> x.endsWith("_OBJ_STOR"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -131,6 +131,9 @@ public class AtbListImpNoPref extends EntityBase {
|
||||
@SqlField(value = "note_listino", maxLength = 255, nullable = true)
|
||||
private String noteListino;
|
||||
|
||||
@SqlField(value = "qta_multipla_ordinabile", nullable = true)
|
||||
private BigDecimal qtaMultiplaOrdinabile;
|
||||
|
||||
public Integer getIdRiga() {
|
||||
return idRiga;
|
||||
}
|
||||
@@ -437,6 +440,15 @@ public class AtbListImpNoPref extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaMultiplaOrdinabile() {
|
||||
return qtaMultiplaOrdinabile;
|
||||
}
|
||||
|
||||
public AtbListImpNoPref setQtaMultiplaOrdinabile(BigDecimal qtaMultiplaOrdinabile) {
|
||||
this.qtaMultiplaOrdinabile = qtaMultiplaOrdinabile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFlagAttivaArt() {
|
||||
return flagAttivaArt;
|
||||
}
|
||||
|
||||
@@ -4276,7 +4276,7 @@ public class DocumentProdService {
|
||||
" where data_fab = " + UtilityDB.valueDateToString(dataFabb, CommonConstants.DATE_FORMAT_YMD) + " and " +
|
||||
"num_fab = " + UtilityDB.valueToString(numFabb) + " and " +
|
||||
"flag_escludi_gruppo = 'S'" +
|
||||
"order by item";
|
||||
"order by item desc";
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
@@ -333,7 +333,7 @@ public class OrdiniEDIimportService {
|
||||
if ( flagDataCons ) {
|
||||
|
||||
// Se il cliente setDataConsClieCustom = true allora vuol dire che la data di consengna deve essere quella del cliente, piuttosto che quella calcolata
|
||||
boolean setDataConsClieCustom = UtilityHashMap.getValueIfExists(setup, "SET_DATA_CONS_CLIE_" + clienti.get(0), "N").equalsIgnoreCase("S");
|
||||
boolean setDataConsClieCustom = UtilityHashMap.getValueIfExists(setup, "SET_DATA_CONS_CLIE_" + codAnag, "N").equalsIgnoreCase("S");
|
||||
if (setDataConsClieCustom){
|
||||
if (UtilityDate.DaysAfter(dataOrd, dataConsClie) > 0) {
|
||||
dataInizTrasp = dataConsClie;
|
||||
|
||||
@@ -13,12 +13,11 @@ public class ListinoAcquistoSmetarDTO {
|
||||
private BigDecimal pesoKg;
|
||||
private String untMis;
|
||||
private BigDecimal qtaImballoStandard;
|
||||
private BigDecimal qtaImballoContainer;
|
||||
private BigDecimal importoEuro;
|
||||
|
||||
public String getCodArt() {
|
||||
return codArt;
|
||||
}
|
||||
private BigDecimal qtaMultiplaOrdinabile;
|
||||
|
||||
public ListinoAcquistoSmetarDTO setCodArt(String codArt) {
|
||||
this.codArt = codArt;
|
||||
@@ -97,15 +96,6 @@ public class ListinoAcquistoSmetarDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaImballoContainer() {
|
||||
return qtaImballoContainer;
|
||||
}
|
||||
|
||||
public ListinoAcquistoSmetarDTO setQtaImballoContainer(BigDecimal qtaImballoContainer) {
|
||||
this.qtaImballoContainer = qtaImballoContainer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getImportoEuro() {
|
||||
return importoEuro;
|
||||
}
|
||||
@@ -114,4 +104,13 @@ public class ListinoAcquistoSmetarDTO {
|
||||
this.importoEuro = importoEuro;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BigDecimal getQtaMultiplaOrdinabile() {
|
||||
return qtaMultiplaOrdinabile;
|
||||
}
|
||||
|
||||
public ListinoAcquistoSmetarDTO setQtaMultiplaOrdinabile(BigDecimal qtaMultiplaOrdinabile) {
|
||||
this.qtaMultiplaOrdinabile = qtaMultiplaOrdinabile;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@ public class ImportAnagListiniService {
|
||||
" flag_rap_conv_variabile, " +
|
||||
" unt_mis2, " +
|
||||
" flag_attiva_art, " +
|
||||
" note_listino " +
|
||||
" note_listino, " +
|
||||
" qta_multipla_ordinabile " +
|
||||
" FROM " + AtbListImpNoPref.ENTITY +
|
||||
" WHERE user_name = " + UtilityDB.valueToString(userName) + " " +
|
||||
" ORDER BY id_riga";
|
||||
@@ -277,7 +278,8 @@ public class ImportAnagListiniService {
|
||||
mtbAart = new MtbAart()
|
||||
.setCodMart(data.getCodMart())
|
||||
.setDataUltVar(new Date())
|
||||
.setIdArtEqui(idArtEqui);
|
||||
.setIdArtEqui(idArtEqui)
|
||||
.setQtaMultiplaOrd(data.getQtaMultiplaOrdinabile());
|
||||
|
||||
mtbAart.setOperation(OperationType.UPDATE);
|
||||
|
||||
@@ -433,7 +435,8 @@ public class ImportAnagListiniService {
|
||||
.setUntMis2(inputData.getUntMis2())
|
||||
.setValUltCar(valUltCar)
|
||||
.setIdArtEqui(null)
|
||||
.setMtbAartEqui_descrizione(null);
|
||||
.setMtbAartEqui_descrizione(null)
|
||||
.setQtaMultiplaOrd(inputData.getQtaMultiplaOrdinabile());
|
||||
|
||||
return mtbAart;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ImportListiniAcquistoFornitoriSmetarService {
|
||||
.setPesoKg(!UtilityString.isNullOrEmpty(lineData[8]) ? new BigDecimal(UtilityString.emptyStr2Null(lineData[8]).replace(",", ".").replaceAll("'", "")) : null)
|
||||
.setUntMis(UtilityString.emptyStr2Null(lineData[9]))
|
||||
.setQtaImballoStandard(!UtilityString.isNullOrEmpty(lineData[10]) ? new BigDecimal(UtilityString.emptyStr2Null(lineData[10]).replace(",", ".").replaceAll("'", "")) : null)
|
||||
.setQtaImballoContainer(!UtilityString.isNullOrEmpty(lineData[11]) ? new BigDecimal(UtilityString.emptyStr2Null(lineData[11]).replace(",", ".").replaceAll("'", "")) : null)
|
||||
.setQtaMultiplaOrdinabile(!UtilityString.isNullOrEmpty(lineData[11]) ? new BigDecimal(UtilityString.emptyStr2Null(lineData[11]).replace(",", ".").replaceAll("'", "")) : null)
|
||||
.setImportoEuro(!UtilityString.isNullOrEmpty(lineData[12]) ? new BigDecimal(UtilityString.emptyStr2Null(lineData[12]).replace(",", ".").replaceAll("'", "")) : null);
|
||||
})
|
||||
.filter(x -> x.getCodArt() != null && x.getDescrizioneArt() != null)
|
||||
@@ -174,7 +174,8 @@ public class ImportListiniAcquistoFornitoriSmetarService {
|
||||
.setCodCconRicavi(codCconRicavi)
|
||||
.setUserName(userName)
|
||||
.setErrorImp(errorMsg)
|
||||
.setNoteListino(noteListino);
|
||||
.setNoteListino(noteListino)
|
||||
.setQtaMultiplaOrdinabile(x.getQtaMultiplaOrdinabile() != null ? x.getQtaMultiplaOrdinabile() : BigDecimal.ZERO);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(errorMsg)) {
|
||||
atbListImp.setException(new EntityException(errorMsg));
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -36,7 +36,7 @@
|
||||
<drools.version>6.4.0.Final</drools.version>
|
||||
<spring.version>5.3.34</spring.version>
|
||||
<security.version>5.8.12</security.version>
|
||||
<jackson.version>2.17.0</jackson.version>
|
||||
<jackson.version>2.9.10</jackson.version>
|
||||
<resteasy.version>3.0.12.Final</resteasy.version>
|
||||
<swagger.version>3.0.0</swagger.version>
|
||||
<ems.war.name>ems</ems.war.name>
|
||||
|
||||
Reference in New Issue
Block a user