use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class PrismPropertyPanel method hasPendingModification.
private boolean hasPendingModification(IModel<IW> model) {
ItemWrapper propertyWrapper = model.getObject();
ContainerWrapper containerWrapper = propertyWrapper.getContainer();
if (containerWrapper == null) {
// TODO - ok?
return false;
}
ObjectWrapper objectWrapper = containerWrapper.getObject();
if (objectWrapper == null) {
return false;
}
PrismObject prismObject = objectWrapper.getObject();
if (!ShadowType.class.isAssignableFrom(prismObject.getCompileTimeClass())) {
return false;
}
PrismProperty objectChange = prismObject.findProperty(ShadowType.F_OBJECT_CHANGE);
if (objectChange == null || objectChange.getValue() == null) {
return false;
}
ItemPath path = propertyWrapper.getItem().getPath();
ObjectDeltaType delta = (ObjectDeltaType) objectChange.getValue().getValue();
try {
for (ItemDeltaType itemDelta : delta.getItemDelta()) {
ItemDelta iDelta = DeltaConvertor.createItemDelta(itemDelta, (Class<? extends Objectable>) prismObject.getCompileTimeClass(), prismObject.getPrismContext());
if (iDelta.getPath().equivalent(path)) {
return true;
}
}
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check if property has pending modification", ex);
}
return false;
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class ContainerWrapper method computePropertyDeltas.
private ItemDelta computePropertyDeltas(PropertyWrapper propertyWrapper, ItemPath containerPath) {
ItemDefinition itemDef = propertyWrapper.getItemDefinition();
ItemDelta pDelta = itemDef.createEmptyDelta(containerPath.subPath(itemDef.getName()));
addItemDelta(propertyWrapper, pDelta, itemDef, containerPath);
return pDelta;
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class ResourceRelatedHandlerDto method getDeltasToExecute.
@NotNull
@Override
public Collection<ItemDelta<?, ?>> getDeltasToExecute(HandlerDtoEditableState origState, HandlerDtoEditableState currState, PrismContext prismContext) throws SchemaException {
List<ItemDelta<?, ?>> rv = new ArrayList<>();
// we can safely assume this; also that both are non-null
ResourceRelatedHandlerDto orig = (ResourceRelatedHandlerDto) origState;
ResourceRelatedHandlerDto curr = (ResourceRelatedHandlerDto) currState;
String origResourceOid = orig.getResourceRef() != null ? orig.getResourceRef().getOid() : null;
String currResourceOid = curr.getResourceRef() != null ? curr.getResourceRef().getOid() : null;
if (!StringUtils.equals(origResourceOid, currResourceOid)) {
ObjectReferenceType resourceObjectRef = new ObjectReferenceType();
resourceObjectRef.setOid(curr.getResourceRef().getOid());
resourceObjectRef.setType(ResourceType.COMPLEX_TYPE);
rv.add(DeltaBuilder.deltaFor(TaskType.class, prismContext).item(TaskType.F_OBJECT_REF).replace(resourceObjectRef.asReferenceValue()).asItemDelta());
}
if (orig.isDryRun() != curr.isDryRun()) {
addExtensionDelta(rv, SchemaConstants.MODEL_EXTENSION_DRY_RUN, curr.isDryRun(), prismContext);
}
if (orig.isRetryUnhandledErr() != curr.isRetryUnhandledErr()) {
addExtensionDelta(rv, SchemaConstants.SYNC_TOKEN_RETRY_UNHANDLED, curr.isRetryUnhandledErr(), prismContext);
}
if (orig.getKind() != curr.getKind()) {
addExtensionDelta(rv, SchemaConstants.MODEL_EXTENSION_KIND, curr.getKind(), prismContext);
}
if (!StringUtils.equals(orig.getIntent(), curr.getIntent())) {
addExtensionDelta(rv, SchemaConstants.MODEL_EXTENSION_INTENT, curr.getIntent(), prismContext);
}
if (!StringUtils.equals(orig.getObjectClass(), curr.getObjectClass())) {
QName objectClassQName = null;
for (QName q : getObjectClassList()) {
if (q.getLocalPart().equals(objectClass)) {
objectClassQName = q;
}
}
addExtensionDelta(rv, SchemaConstants.OBJECTCLASS_PROPERTY_NAME, objectClassQName, prismContext);
}
return rv;
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class AccCertUpdateHelper method getDeltasForStageClose.
List<ItemDelta<?, ?>> getDeltasForStageClose(AccessCertificationCampaignType campaign, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
XMLGregorianCalendar now = XmlTypeConverter.createXMLGregorianCalendar(new Date());
List<ItemDelta<?, ?>> rv = caseHelper.createOutcomeDeltas(campaign, result);
rv.add(createStateDelta(REVIEW_STAGE_DONE));
rv.add(createStageEndTimeDelta(campaign, now));
rv.add(createTriggerDeleteDelta());
rv.addAll(createWorkItemsCloseDeltas(campaign, now, result));
return rv;
}
use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.
the class AccCertCaseOperationsHelper method recordDecision.
void recordDecision(String campaignOid, long caseId, long workItemId, AccessCertificationResponseType response, String comment, Task task, OperationResult result) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
AccessCertificationCaseType _case = queryHelper.getCase(campaignOid, caseId, task, result);
if (_case == null) {
throw new ObjectNotFoundException("Case " + caseId + " was not found in campaign " + campaignOid);
}
AccessCertificationCampaignType campaign = CertCampaignTypeUtil.getCampaign(_case);
if (campaign == null) {
throw new IllegalStateException("No owning campaign present in case " + _case);
}
AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(_case, workItemId);
if (workItem == null) {
throw new ObjectNotFoundException("Work item " + workItemId + " was not found in campaign " + toShortString(campaign) + ", case " + caseId);
}
if (response == AccessCertificationResponseType.NO_RESPONSE) {
response = null;
}
ObjectReferenceType responderRef = ObjectTypeUtil.createObjectRef(securityEnforcer.getPrincipal().getUser());
XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
ItemPath workItemPath = new ItemPath(F_CASE, caseId, F_WORK_ITEM, workItemId);
Collection<ItemDelta<?, ?>> deltaList = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(workItemPath.subPath(AccessCertificationWorkItemType.F_OUTPUT)).replace(new AbstractWorkItemOutputType().outcome(OutcomeUtils.toUri(response)).comment(comment)).item(workItemPath.subPath(AccessCertificationWorkItemType.F_OUTPUT_CHANGE_TIMESTAMP)).replace(now).item(workItemPath.subPath(AccessCertificationWorkItemType.F_PERFORMER_REF)).replace(responderRef).asItemDeltas();
ItemDelta.applyTo(deltaList, campaign.asPrismContainerValue());
String newCurrentOutcome = OutcomeUtils.toUri(computationHelper.computeOutcomeForStage(_case, campaign, campaign.getStageNumber()));
if (!ObjectUtils.equals(newCurrentOutcome, _case.getCurrentStageOutcome())) {
deltaList.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_CURRENT_STAGE_OUTCOME).replace(newCurrentOutcome).asItemDelta());
}
String newOverallOutcome = OutcomeUtils.toUri(computationHelper.computeOverallOutcome(_case, campaign, newCurrentOutcome));
if (!ObjectUtils.equals(newOverallOutcome, _case.getOutcome())) {
deltaList.add(DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, _case.asPrismContainerValue().getId(), F_OUTCOME).replace(newOverallOutcome).asItemDelta());
}
updateHelper.modifyObjectViaModel(AccessCertificationCampaignType.class, campaignOid, deltaList, task, result);
}
Aggregations