Search in sources :

Example 1 with TaskEditableState

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;
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) TaskEditableState(com.evolveum.midpoint.web.page.admin.server.dto.TaskEditableState) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)1 TaskEditableState (com.evolveum.midpoint.web.page.admin.server.dto.TaskEditableState)1