use of eu.bcvsolutions.idm.acc.domain.OperationResultType in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method initSyncActionLog.
/**
* Init sync action log
*
* @param actionType
* @param resultType
* @param logItem
* @param log
* @param actionLogs
*/
protected void initSyncActionLog(SynchronizationActionType actionType, OperationResultType resultType, SysSyncItemLogDto logItem, SysSyncLogDto log, List<SysSyncActionLogDto> actionLogs, boolean interateCount) {
if (logItem == null || actionLogs == null) {
// maybe)
return;
}
if (this.existItemLogInActions(actionLogs, logItem)) {
if (OperationResultType.ERROR != resultType && OperationResultType.WARNING != resultType) {
return;
}
Pair<SysSyncActionLogDto, SysSyncItemLogDto> actionWithItemLog = getActionLogThatContains(actionLogs, logItem);
if (OperationResultType.ERROR == resultType && OperationResultType.ERROR == actionWithItemLog.getLeft().getOperationResult()) {
return;
}
if (OperationResultType.WARNING == resultType && OperationResultType.WARNING == actionWithItemLog.getLeft().getOperationResult()) {
return;
}
}
SysSyncActionLogDto actionLog = null;
Optional<SysSyncActionLogDto> optionalActionLog = actionLogs.stream().filter(al -> {
return actionType == al.getSyncAction() && resultType == al.getOperationResult();
}).findFirst();
if (optionalActionLog.isPresent()) {
actionLog = optionalActionLog.get();
} else {
actionLog = new SysSyncActionLogDto();
actionLog.setOperationResult(resultType);
actionLog.setSyncAction(actionType);
actionLog.setSyncLog(log.getId());
actionLogs.add(actionLog);
}
actionLog.addLogItems(logItem);
if (interateCount) {
actionLog.setOperationCount(actionLog.getOperationCount() + 1);
addToItemLog(logItem, MessageFormat.format("Operation count for [{0}] is [{1}]", actionLog.getSyncAction(), actionLog.getOperationCount()));
}
}
Aggregations