Finish Hotfix-1
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -20,6 +20,12 @@ public class EntityException extends Exception {
|
||||
this.mInnerException = innerException;
|
||||
}
|
||||
|
||||
public EntityException(String message, Exception innerException) {
|
||||
super(message + "\n" + innerException.getMessage());
|
||||
|
||||
this.mInnerException = innerException;
|
||||
}
|
||||
|
||||
public EntityException(Exception e, EntityBase entity, String query) {
|
||||
super("Impossibile salvare la entity " + entity.getTableName() + ".\n " +
|
||||
e.getMessage() + "\n" +
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package it.integry.ems.system.exchange.service;
|
||||
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.dto.Result;
|
||||
import it.integry.ems.expansion.RunnableThrowable;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
@@ -15,9 +13,13 @@ import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.DtbDoct;
|
||||
import it.integry.ems_model.entity.MtbColr;
|
||||
import it.integry.ems_model.entity.MtbColt;
|
||||
import it.integry.ems_model.exception.EntityException;
|
||||
import it.integry.ems_model.service.SetupGest;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.*;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityList;
|
||||
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;
|
||||
@@ -25,7 +27,10 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -123,7 +128,7 @@ public class ExchangeColliImportService {
|
||||
|
||||
LocalDate startDate = startDateTimeStamp.toLocalDate();
|
||||
// LocalDate startDate = LocalDate.of(2024, 7, 1);
|
||||
Result<Object> firstErrorObjectIfPresent = null;
|
||||
final Exception[] firstExceptionToThrow = {null};
|
||||
|
||||
|
||||
|
||||
@@ -164,12 +169,9 @@ public class ExchangeColliImportService {
|
||||
((MtbColt) x).getMtbColr().forEach(y -> y.setOperation(y.getOperation() == OperationType.INSERT ? OperationType.INSERT_OR_UPDATE : y.getOperation()));
|
||||
});
|
||||
|
||||
|
||||
List<RunnableThrowable> calls = new ArrayList<>();
|
||||
for (EquatableEntityInterface dataToSave : allMtbColts) {
|
||||
|
||||
String finalLogType = logType;
|
||||
calls.add(() -> {
|
||||
|
||||
logger.debug("Importati {} colli di " + finalLogType + " di {}", importedCounter.incrementAndGet(), dataCount);
|
||||
try (MultiDBTransactionManager exchangeMultiDbThread = new MultiDBTransactionManager(exchangeMultiDb.getPrimaryDatasource().getProfile(), false);
|
||||
@@ -201,29 +203,20 @@ public class ExchangeColliImportService {
|
||||
exchangeMultiDbThread.commitAll();
|
||||
} catch (Exception ex) {
|
||||
MtbColt collo = (MtbColt) dataToSave;
|
||||
|
||||
logger.error("Errore durante l'importazione del collo di " + finalLogType +
|
||||
Exception newException = new EntityException("Errore durante l'importazione del collo di " + finalLogType +
|
||||
" [num: " + collo.getNumCollo() + ", " +
|
||||
"data: " + UtilityLocalDate.formatDate(collo.getDataCollo(), CommonConstants.DATE_FORMAT_DMY) + ", " +
|
||||
"serie: " + collo.getSerCollo() + ", " +
|
||||
"gestione: " + collo.getGestione() + "]",
|
||||
ex);
|
||||
"gestione: " + collo.getGestione() + "]", ex);
|
||||
|
||||
throw ex;
|
||||
if (firstExceptionToThrow[0] == null) firstExceptionToThrow[0] = newException;
|
||||
logger.error(newException);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final ArrayList<Result<Object>> results = UtilityThread.executeParallel(calls);
|
||||
|
||||
firstErrorObjectIfPresent = results.stream()
|
||||
.filter(x -> x instanceof Result.Error)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
if (firstErrorObjectIfPresent != null) throw ((Result.Error) firstErrorObjectIfPresent).getError();
|
||||
if (firstExceptionToThrow[0] != null) throw firstExceptionToThrow[0];
|
||||
} finally {
|
||||
if (useTempTable)
|
||||
exchangeImportSchemaManagerService.deleteTempTables(exchangeMultiDb.getPrimaryConnection(), colliSchemaType);
|
||||
|
||||
Reference in New Issue
Block a user