use of com.evolveum.midpoint.web.page.admin.server.dto.TaskEditableState in project midpoint by Evolveum.
the class PageTaskController method getDeltasToExecute.
private List<ItemDelta<?, ?>> getDeltasToExecute(TaskDto dto) throws SchemaException {
List<ItemDelta<?, ?>> rv = new ArrayList<>();
TaskEditableState orig = dto.getOriginalEditableState();
TaskEditableState curr = dto.getCurrentEditableState();
if (!StringUtils.equals(orig.getName(), curr.getName())) {
String name = curr.getName() != null ? curr.getName() : "";
addDelta(rv, TaskType.F_NAME, new PolyString(name));
}
if (!StringUtils.equals(orig.getDescription(), curr.getDescription())) {
addDelta(rv, TaskType.F_DESCRIPTION, curr.getDescription());
}
ScheduleType origSchedule = orig.getScheduleType();
ScheduleType currSchedule = curr.getScheduleType();
if (!origSchedule.equals(currSchedule)) {
if (dto.getTaskType().getSchedule() != null) {
currSchedule.setLatestFinishTime(dto.getTaskType().getSchedule().getLatestFinishTime());
}
addDelta(rv, TaskType.F_SCHEDULE, currSchedule);
}
if (orig.isRecurring() != curr.isRecurring()) {
addDelta(rv, TaskType.F_RECURRENCE, curr.isRecurring() ? TaskRecurrenceType.RECURRING : TaskRecurrenceType.SINGLE);
}
if (orig.isBound() != curr.isBound()) {
addDelta(rv, TaskType.F_BINDING, curr.isBound() ? TaskBindingType.TIGHT : TaskBindingType.LOOSE);
}
if (orig.getThreadStopActionType() != curr.getThreadStopActionType()) {
addDelta(rv, TaskType.F_THREAD_STOP_ACTION, curr.getThreadStopActionType());
}
if (!ObjectUtils.equals(orig.getWorkerThreads(), curr.getWorkerThreads())) {
SchemaRegistry registry = parentPage.getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS);
rv.add(DeltaBuilder.deltaFor(TaskType.class, parentPage.getPrismContext()).item(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_WORKER_THREADS), def).replace(curr.getWorkerThreads()).asItemDelta());
}
rv.addAll(dto.getHandlerDto().getDeltasToExecute(orig.getHandlerSpecificState(), curr.getHandlerSpecificState(), parentPage.getPrismContext()));
return rv;
}
Aggregations