use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class DefaultGuiProgressListener method updateStatusItemState.
private void updateStatusItemState(ProgressReportActivityDto si, ProgressInformation progressInformation, ModelContext modelContext) {
si.setActivityType(progressInformation.getActivityType());
si.setResourceShadowDiscriminator(progressInformation.getResourceShadowDiscriminator());
if (progressInformation.getResourceShadowDiscriminator() != null) {
String resourceOid = progressInformation.getResourceShadowDiscriminator().getResourceOid();
String resourceName = resourceOid != null ? getResourceName(resourceOid) : "";
si.setResourceName(resourceName);
}
if (progressInformation.getStateType() == null) {
si.setStatus(null);
} else if (progressInformation.getStateType() == ENTERING) {
si.setStatus(OperationResultStatusType.IN_PROGRESS);
} else {
OperationResult result = progressInformation.getOperationResult();
if (result != null) {
OperationResultStatus status = result.getStatus();
if (status == OperationResultStatus.UNKNOWN) {
status = result.getComputeStatus();
}
si.setStatus(status.createStatusType());
} else {
si.setStatus(OperationResultStatusType.UNKNOWN);
}
}
// information about modifications on a resource
if (progressInformation.getActivityType() == RESOURCE_OBJECT_OPERATION && progressInformation.getStateType() == EXITING && progressInformation.getResourceShadowDiscriminator() != null && progressInformation.getResourceShadowDiscriminator().getResourceOid() != null) {
ModelProjectionContext mpc = modelContext.findProjectionContext(progressInformation.getResourceShadowDiscriminator());
if (mpc != null) {
// it shouldn't be null!
// operations performed (TODO aggregate them somehow?)
List<ResourceOperationResult> resourceOperationResultList = new ArrayList<>();
List<? extends ObjectDeltaOperation> executedDeltas = mpc.getExecutedDeltas();
for (ObjectDeltaOperation executedDelta : executedDeltas) {
ObjectDelta delta = executedDelta.getObjectDelta();
if (delta != null) {
OperationResult r = executedDelta.getExecutionResult();
OperationResultStatus status = r.getStatus();
if (status == OperationResultStatus.UNKNOWN) {
status = r.getComputeStatus();
}
resourceOperationResultList.add(new ResourceOperationResult(delta.getChangeType(), status));
}
}
si.setResourceOperationResultList(resourceOperationResultList);
// object name
PrismObject<ShadowType> object = mpc.getObjectNew();
if (object == null) {
object = mpc.getObjectOld();
}
String name = null;
if (object != null) {
if (object.asObjectable().getName() != null) {
name = PolyString.getOrig(object.asObjectable().getName());
} else {
// determine from attributes
ResourceAttribute nameAttribute = ShadowUtil.getNamingAttribute(object);
if (nameAttribute != null) {
name = String.valueOf(nameAttribute.getAnyRealValue());
}
}
}
if (name != null) {
si.setResourceObjectName(name);
}
}
}
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class PageUser method saveDelegationToUser.
private void saveDelegationToUser(UserType user, List<AssignmentEditorDto> assignmentEditorDtos) {
OperationResult result = new OperationResult(OPERATION_SAVE);
ObjectDelta<UserType> delta;
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
try {
delta = user.asPrismObject().createModifyDelta();
deltas.add(delta);
PrismContainerDefinition def = user.asPrismObject().getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT);
handleAssignmentDeltas(delta, assignmentEditorDtos, def, true);
getModelService().executeChanges(deltas, null, createSimpleTask(OPERATION_SAVE), result);
result.recordSuccess();
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Could not save assignments ", e);
error("Could not save assignments. Reason: " + e);
} finally {
result.recomputeStatus();
}
showResult(result);
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class OrgMemberPanel method addMembersPerformed.
@Override
protected void addMembersPerformed(QName type, QName relation, List selected, AjaxRequestTarget target) {
Task operationalTask = getPageBase().createSimpleTask(getTaskName("Add", null, false));
ObjectDelta delta = prepareDelta(MemberOperation.ADD, type, relation, operationalTask.getResult(), target);
if (delta == null) {
return;
}
executeMemberOperation(operationalTask, type, createQueryForAdd(selected), delta, TaskCategory.EXECUTE_CHANGES, target);
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class OrgMemberPanel method deleteMemberConfirmPerformed.
private void deleteMemberConfirmPerformed(QueryScope scope, QName relation, AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
Task operationalTask = getPageBase().createSimpleTask(getTaskName("Delete", scope, false));
ObjectDelta delta = ObjectDelta.createDeleteDelta(FocusType.class, "fakeOid", getPageBase().getPrismContext());
if (delta == null) {
return;
}
executeMemberOperation(operationalTask, FocusType.COMPLEX_TYPE, createQueryForMemberAction(scope, relation, true), delta, TaskCategory.EXECUTE_CHANGES, target);
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class OrgMemberPanel method createMemberDelta.
protected ObjectDelta createMemberDelta(MemberOperation operation, QName type, QName relation) throws SchemaException {
Class classType = WebComponentUtil.qnameToClass(getPageBase().getPrismContext(), type);
ObjectDelta delta = null;
switch(operation) {
case ADD:
if (isFocus(type)) {
delta = ObjectDelta.createModificationAddContainer(classType, "fakeOid", FocusType.F_ASSIGNMENT, getPageBase().getPrismContext(), createAssignmentToModify(relation));
} else {
delta = ObjectDelta.createModificationAddReference(classType, "fakeOid", ObjectType.F_PARENT_ORG_REF, getPageBase().getPrismContext(), createReference(relation).asReferenceValue());
}
break;
case REMOVE:
if (isFocus(type)) {
delta = ObjectDelta.createModificationDeleteContainer(classType, "fakeOid", FocusType.F_ASSIGNMENT, getPageBase().getPrismContext(), createAssignmentToModify(relation));
} else {
delta = ObjectDelta.createModificationDeleteReference(classType, "fakeOid", ObjectType.F_PARENT_ORG_REF, getPageBase().getPrismContext(), createReference(relation).asReferenceValue());
}
break;
default:
break;
}
return delta;
}
Aggregations