Search in sources :

Example 21 with ObjectReferenceType

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 22 with ObjectReferenceType

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);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) QName(javax.xml.namespace.QName) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 23 with ObjectReferenceType

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");
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 24 with ObjectReferenceType

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;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 25 with ObjectReferenceType

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);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) Collection(java.util.Collection) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)225 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)100 Test (org.testng.annotations.Test)79 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)78 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)77 Task (com.evolveum.midpoint.task.api.Task)50 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)41 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)36 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)31 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 QName (javax.xml.namespace.QName)29 ArrayList (java.util.ArrayList)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)25 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)22 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)17