use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class ProjectionValuesProcessor method cleanupContext.
/**
* Remove the intermediate results of values processing such as secondary deltas.
*/
private void cleanupContext(LensProjectionContext accountContext) throws SchemaException {
// We must NOT clean up activation computation. This has happened before, it will not happen again
// and it does not depend on iteration
ObjectDelta<ShadowType> secondaryDelta = accountContext.getSecondaryDelta();
if (secondaryDelta != null) {
Collection<? extends ItemDelta> modifications = secondaryDelta.getModifications();
if (modifications != null) {
Iterator<? extends ItemDelta> iterator = modifications.iterator();
while (iterator.hasNext()) {
ItemDelta modification = iterator.next();
if (!new ItemPath(FocusType.F_ACTIVATION).equivalent(modification.getParentPath())) {
iterator.remove();
}
}
}
if (secondaryDelta.isEmpty()) {
accountContext.setSecondaryDelta(null);
}
}
accountContext.clearIntermediateResults();
accountContext.recompute();
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class ReconciliationProcessor method recordDelta.
private <T> void recordDelta(ValueMatcher<T> valueMatcher, LensProjectionContext projCtx, ItemPath parentPath, PrismPropertyDefinition<T> attrDef, ModificationType changeType, T value, ObjectType originObject, String reason) throws SchemaException {
ItemDelta existingDelta = null;
if (projCtx.getSecondaryDelta() != null) {
existingDelta = projCtx.getSecondaryDelta().findItemDelta(new ItemPath(parentPath, attrDef.getName()));
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Reconciliation will {} value of attribute {}: {} because {}", changeType, PrettyPrinter.prettyPrint(attrDef.getName()), value, reason);
}
PropertyDelta<T> attrDelta = new PropertyDelta<>(parentPath, attrDef.getName(), attrDef, prismContext);
PrismPropertyValue<T> pValue = new PrismPropertyValue<>(value, OriginType.RECONCILIATION, originObject);
if (changeType == ModificationType.ADD) {
attrDelta.addValueToAdd(pValue);
} else if (changeType == ModificationType.DELETE) {
if (!isToBeDeleted(existingDelta, valueMatcher, value)) {
attrDelta.addValueToDelete(pValue);
}
} else if (changeType == ModificationType.REPLACE) {
attrDelta.setValueToReplace(pValue);
} else {
throw new IllegalArgumentException("Unknown change type " + changeType);
}
projCtx.swallowToSecondaryDelta(attrDelta);
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class FocusConstraintsChecker method clearCacheForDelta.
public static void clearCacheForDelta(Collection<? extends ItemDelta> modifications) {
if (modifications == null) {
return;
}
for (ItemDelta itemDelta : modifications) {
if (new ItemPath(ObjectType.F_NAME).equivalent(itemDelta.getPath())) {
// these may present a conflict
clearCacheForValues(itemDelta.getValuesToAdd());
// so do these
clearCacheForValues(itemDelta.getValuesToReplace());
}
}
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class PageTaskController method savePerformed.
void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving new task.");
OperationResult result = new OperationResult(PageTaskEdit.OPERATION_SAVE_TASK);
TaskDto dto = parentPage.getTaskDto();
Task operationTask = parentPage.createSimpleTask(PageTaskEdit.OPERATION_SAVE_TASK);
try {
List<ItemDelta<?, ?>> itemDeltas = getDeltasToExecute(dto);
ObjectDelta<TaskType> delta = ObjectDelta.createModifyDelta(dto.getOid(), itemDeltas, TaskType.class, parentPage.getPrismContext());
final Collection<ObjectDelta<? extends ObjectType>> deltas = Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Saving task modifications:\n{}", DebugUtil.debugDump(deltas));
}
parentPage.getModelService().executeChanges(deltas, null, operationTask, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't save task.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task modifications", ex);
}
afterSave(target, result);
}
use of com.evolveum.midpoint.prism.delta.ItemDelta 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