use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class AbstractBulkAction method end.
@Override
protected OperationResult end(OperationResult result, Exception ex) {
OperationResult end = null;
if (result != null && result.getException() != null) {
end = super.end(result, (Exception) result.getException());
} else {
end = super.end(result, ex);
}
//
// send message
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setIncludeItemCounts(true);
IdmLongRunningTaskDto task = getLongRunningTaskService().get(getLongRunningTaskId(), filter);
//
if (task.getCreatorId() != null) {
IdmIdentityDto identityDto = identityService.get(task.getCreatorId());
ConfigurationService configurationService = getConfigurationService();
if (identityDto != null) {
notificationManager.send(CoreModule.TOPIC_BULK_ACTION_END, new IdmMessageDto.Builder().addParameter("action", getAction()).addParameter("task", task).addParameter("owner", identityDto).addParameter("result", end).addParameter("detailUrl", configurationService.getFrontendUrl(String.format("scheduler/all-tasks/%s/detail", task.getId()))).addParameter("processItemslUrl", configurationService.getFrontendUrl(String.format("scheduler/all-tasks/%s/items", task.getId()))).build(), identityDto);
}
}
//
return end;
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class IdmLongRunningTaskController method getDto.
@Override
public IdmLongRunningTaskDto getDto(Serializable backendId) {
// FIXME: Propagate filter in GET method (in AbstractReadDto controller => requires lookup api improvement).
IdmLongRunningTaskFilter filter = toFilter(null);
//
IdmLongRunningTaskDto dto = getService().get(backendId, filter, IdmBasePermission.READ);
if (dto == null) {
return null;
}
dto.getEmbedded().put(IdmFormInstanceDto.PROPERTY_FORM_INSTANCE, longRunningTaskManager.getTaskFormInstance(dto));
//
return dto;
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class IdmLongRunningTaskController method toFilter.
@Override
protected IdmLongRunningTaskFilter toFilter(MultiValueMap<String, Object> parameters) {
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter(parameters, getParameterConverter());
// counters are loaded from controller all times
filter.setIncludeItemCounts(true);
//
return filter;
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method init.
/**
* Cancel all previously ran synchronizations
*/
@Override
@Transactional
public void init() {
String instanceId = configurationService.getInstanceId();
LOG.info("Cancel unprocessed synchronizations - tasks was interrupt during instance [{}] restart", instanceId);
//
// find all running sync on all instances
IdmLongRunningTaskFilter lrtFilter = new IdmLongRunningTaskFilter();
lrtFilter.setRunning(Boolean.TRUE);
lrtFilter.setTaskType(SynchronizationSchedulableTaskExecutor.class.getCanonicalName());
List<IdmLongRunningTaskDto> allRunningSynchronizations = longRunningTaskService.find(lrtFilter, null).getContent();
// stop logs on the same instance id
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setRunning(Boolean.TRUE);
synchronizationLogService.find(logFilter, null).forEach(sync -> {
boolean runningOnOtherInstance = allRunningSynchronizations.stream().anyMatch(lrt -> {
return !lrt.getInstanceId().equals(instanceId) && sync.getSynchronizationConfig().equals(lrt.getTaskProperties().get(PARAMETER_SYNCHRONIZATION_ID));
});
if (!runningOnOtherInstance) {
String message = MessageFormat.format("Cancel unprocessed synchronization [{0}] - tasks was interrupt during instance [{1}] restart", sync.getId(), instanceId);
LOG.info(message);
sync.addToLog(message);
sync.setRunning(false);
synchronizationLogService.save(sync);
}
});
// Clear the executor cache
this.idmCacheManager.evictCache(SYNC_EXECUTOR_CACHE_NAME);
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class LongRunningTaskMonitoringEvaluator method evaluate.
@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
IdmMonitoringResultDto result = new IdmMonitoringResultDto();
ResultModel resultModel;
//
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setOperationState(OperationState.EXCEPTION);
filter.setMonitoringIgnored(Boolean.FALSE);
Long givenNumberOfDays = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_NUMBER_OF_DAYS);
if (givenNumberOfDays != null) {
filter.setCreatedFrom(ZonedDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(givenNumberOfDays));
}
long count = longRunningTaskService.count(filter);
//
if (count > 0) {
resultModel = new DefaultResultModel(CoreResultCode.MONITORING_LONG_RUNNING_TASK_ERROR, ImmutableMap.of("count", Long.toString(count)));
} else {
resultModel = new DefaultResultModel(CoreResultCode.OK);
}
//
result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
result.setValue(String.valueOf(count));
//
return result;
}
Aggregations