use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PageAdminResources method deleteSyncTokenPerformed.
protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
// ResourceDto dto = model.getObject();
String resourceOid = resourceType.getOid();
String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(resourceOid);
PrismObject<TaskType> oldTask;
OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
if (taskList.size() != 1) {
error(getString("pageResource.message.invalidTaskSearch"));
} else {
oldTask = taskList.get(0);
saveTask(oldTask, result);
}
result.recomputeStatus();
showResult(result);
target.add(getFeedbackPanel());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignments.
public static <F extends FocusType> void assertAssignments(PrismObject<F> user, Class expectedType, int expectedNumber) {
F userType = user.asObjectable();
int actualAssignments = 0;
List<AssignmentType> assignments = userType.getAssignment();
for (AssignmentType assignment : assignments) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
QName type = targetRef.getType();
if (type != null) {
Class<? extends ObjectType> assignmentTargetClass = ObjectTypes.getObjectTypeFromTypeQName(type).getClassDefinition();
if (expectedType.isAssignableFrom(assignmentTargetClass)) {
actualAssignments++;
}
}
}
}
assertEquals("Unexepected number of assignments of type " + expectedType + " in " + user + ": " + userType.getAssignment(), expectedNumber, actualAssignments);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssignedResource.
public static <F extends FocusType> void assertAssignedResource(PrismObject<F> user, String resourceOid) {
F userType = user.asObjectable();
for (AssignmentType assignmentType : userType.getAssignment()) {
if (assignmentType.getConstruction() == null) {
continue;
}
ObjectReferenceType targetRef = assignmentType.getConstruction().getResourceRef();
if (targetRef != null) {
if (resourceOid.equals(targetRef.getOid())) {
return;
}
}
}
AssertJUnit.fail(user + " does NOT have assigned resource " + resourceOid + " while expecting it");
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class MidPointAsserts method assertAssigned.
public static <F extends FocusType> AssignmentType assertAssigned(PrismObject<F> user, String targetOid, QName refType) {
F userType = user.asObjectable();
for (AssignmentType assignmentType : userType.getAssignment()) {
ObjectReferenceType targetRef = assignmentType.getTargetRef();
if (targetRef != null) {
if (refType.equals(targetRef.getType())) {
if (targetOid.equals(targetRef.getOid())) {
return assignmentType;
}
}
}
}
AssertJUnit.fail(user + " does not have assigned " + refType.getLocalPart() + " " + targetOid);
// not reachable
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class OperationalDataManager method applyMetadataModify.
public <T extends ObjectType, F extends ObjectType> void applyMetadataModify(ObjectDelta<T> objectDelta, LensElementContext<T> objectContext, Class objectTypeClass, XMLGregorianCalendar now, Task task, LensContext<F> context, OperationResult result) throws SchemaException {
String channel = LensUtil.getChannel(context, task);
PrismObjectDefinition<T> def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectTypeClass);
ItemDelta.mergeAll(objectDelta.getModifications(), createModifyMetadataDeltas(context, new ItemPath(ObjectType.F_METADATA), def, now, task));
List<PrismReferenceValue> approverReferenceValues = new ArrayList<PrismReferenceValue>();
if (workflowManager != null) {
for (ObjectReferenceType approverRef : workflowManager.getApprovedBy(task, result)) {
approverReferenceValues.add(new PrismReferenceValue(approverRef.getOid()));
}
}
if (!approverReferenceValues.isEmpty()) {
ReferenceDelta refDelta = ReferenceDelta.createModificationReplace((new ItemPath(ObjectType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF)), def, approverReferenceValues);
((Collection) objectDelta.getModifications()).add(refDelta);
} else {
if (objectContext != null && objectContext.getObjectOld() != null) {
if (objectContext.getObjectOld().asObjectable().getMetadata() != null) {
List<ObjectReferenceType> existingModifyApproverRefs = objectContext.getObjectOld().asObjectable().getMetadata().getModifyApproverRef();
LOGGER.trace("Original values of MODIFY_APPROVER_REF: {}", existingModifyApproverRefs);
if (!existingModifyApproverRefs.isEmpty()) {
List<PrismReferenceValue> valuesToDelete = new ArrayList<PrismReferenceValue>();
for (ObjectReferenceType approverRef : objectContext.getObjectOld().asObjectable().getMetadata().getModifyApproverRef()) {
valuesToDelete.add(approverRef.asReferenceValue().clone());
}
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete((new ItemPath(ObjectType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF)), def, valuesToDelete);
((Collection) objectDelta.getModifications()).add(refDelta);
}
}
}
}
if (FocusType.class.isAssignableFrom(objectTypeClass)) {
applyAssignmentMetadataDelta((LensContext) context, (ObjectDelta) objectDelta, now, task, result);
}
}
Aggregations