Skip to content

Commit

Permalink
fixing saving handlerUri + archetype for new task using "non-archetyp…
Browse files Browse the repository at this point in the history
…ed" task, fix for re-rendering form with relevant attributes. (MID-6150)
  • Loading branch information
katkav committed Apr 1, 2020
1 parent e0254e2 commit c9666f8
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -8,6 +8,10 @@

import java.util.*;

import com.evolveum.midpoint.prism.PrismProperty;

import com.evolveum.midpoint.web.component.prism.ValueStatus;

import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
Expand Down Expand Up @@ -92,6 +96,30 @@ protected void onUpdatePerformed(AjaxRequestTarget target) {
}
}

PrismObjectWrapperFactory<TaskType> wrapperFactory = TaskBasicTabPanel.this.getPageBase().findObjectWrapperFactory(getTask().asPrismObject().getDefinition());
Task task = getPageBase().createSimpleTask(OPERATION_UPDATE_WRAPPER);
OperationResult result = task.getResult();
WrapperContext ctx = new WrapperContext(task, result);
try {
wrapperFactory.updateWrapper(TaskBasicTabPanel.this.getModelObject(), ctx);

//TODO ugly hack: after updateWrapper method is called, both previously set items (handlerUri and assignments)
// are marked as NOT_CHANGED with the same value. We need to find a way how to force the ValueStatus
// or change the mechanism for computing deltas. Probably only the first will work
PrismPropertyWrapper<String> handlerWrapper = TaskBasicTabPanel.this.getModelObject().findProperty(ItemPath.create(TaskType.F_HANDLER_URI));
handlerWrapper.getValue().setStatus(ValueStatus.ADDED);

PrismContainerWrapper<AssignmentType> assignmentWrapper = TaskBasicTabPanel.this.getModelObject().findContainer(ItemPath.create(TaskType.F_ASSIGNMENT));
for (PrismContainerValueWrapper<AssignmentType> assignmentWrapperValue : assignmentWrapper.getValues()) {
if (WebComponentUtil.isArchetypeAssignment(assignmentWrapperValue.getRealValue())) {
assignmentWrapperValue.setStatus(ValueStatus.ADDED);
}
}

} catch (SchemaException e) {
LOGGER.error("Unexpected problem occurs during updating wrapper. Reason: {}", e.getMessage(), e);
}

updateHandlerPerformed(target);

}
Expand Down

0 comments on commit c9666f8

Please sign in to comment.