Merge branch 'master' into develop

This commit is contained in:
2024-02-21 12:38:31 +01:00

View File

@@ -2,6 +2,7 @@ package it.integry.ems_model.utility;
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_model.annotation.EntityChild;
import it.integry.ems_model.base.EntityBase; import it.integry.ems_model.base.EntityBase;
import it.integry.ems_model.base.EntityPropertyHolder; import it.integry.ems_model.base.EntityPropertyHolder;
import it.integry.ems_model.config.EmsRestConstants; import it.integry.ems_model.config.EmsRestConstants;
@@ -46,16 +47,16 @@ public class UtilityDB {
if (UtilityString.isNullOrEmpty(indexTableDTO.getIndexName())) if (UtilityString.isNullOrEmpty(indexTableDTO.getIndexName()))
throw new Exception("Nome indice non trovato"); throw new Exception("Nome indice non trovato");
if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0 ) if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0)
throw new Exception("Inserire l'elenco delle colonne su ci creare l'indice"); throw new Exception("Inserire l'elenco delle colonne su ci creare l'indice");
String sql = String sql =
Query.format( "SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName()); Query.format("SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName());
boolean existIndex = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql); boolean existIndex = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
List<String> sqls = new ArrayList<>(); List<String> sqls = new ArrayList<>();
if ( existIndex) { if (existIndex) {
if (indexTableDTO.isOverride()) { if (indexTableDTO.isOverride()) {
sql = String.format("DROP INDEX %s ON dbo.%s", indexTableDTO.getIndexName(), indexTableDTO.getTableName()); sql = String.format("DROP INDEX %s ON dbo.%s", indexTableDTO.getIndexName(), indexTableDTO.getTableName());
sqls.add(sql); sqls.add(sql);
@@ -86,7 +87,7 @@ public class UtilityDB {
sql = sql =
String.format( String.format(
"CREATE %s INDEX %s ON dbo.%s ( %s ) %s %s", "CREATE %s INDEX %s ON dbo.%s ( %s ) %s %s",
indexTableDTO.isClustered()?"CLUSTERED":"NONCLUSTERED", indexTableDTO.isClustered() ? "CLUSTERED" : "NONCLUSTERED",
indexTableDTO.getIndexName(), indexTableDTO.getIndexName(),
indexTableDTO.getTableName(), indexTableDTO.getTableName(),
indexTableDTO.getColumnsIndexString(), indexTableDTO.getColumnsIndexString(),
@@ -171,9 +172,14 @@ public class UtilityDB {
} }
} }
final EntityBase tmpChildEntity = rowClass.newInstance(); EntityChild childConstraintDetails = field.getAnnotation(EntityChild.class);
tmpChildEntity.setImportFromParent(testata, true); if (childConstraintDetails.copyPk()) {
list = tmpChildEntity.select(conn, whereCond); list = testata.selectEntityRowList(conn, testata, rowClass, keyType, whereCond);
} else {
final EntityBase tmpChildEntity = rowClass.newInstance();
tmpChildEntity.setImportFromParent(testata, true);
list = tmpChildEntity.select(conn, whereCond);
}
return list; return list;
} }
@@ -384,7 +390,7 @@ public class UtilityDB {
public static String listValueToString(List<String> lista) { public static String listValueToString(List<String> lista) {
lista = Stream.of(lista).map(UtilityDB::valueToString).toList(); lista = Stream.of(lista).map(UtilityDB::valueToString).toList();
return StringUtils.join(lista,","); return StringUtils.join(lista, ",");
} }
public static int countRow(ResultSet res) { public static int countRow(ResultSet res) {