Search in sources :

Example 91 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class TestUuid method assertLdapClient.

private void assertLdapClient(PrismObject<UserType> user, String firstName, String lastName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    assertLinks(user, 1);
    assertAssignments(user, RoleType.class, 1);
    assertAssignedRole(user, ROLE_CLIENT_OID);
    assertAccount(user, RESOURCE_OPENDJ_OID);
    PrismReferenceValue linkRef = getLinkRef(user, RESOURCE_OPENDJ_OID);
    PrismObject<ShadowType> shadow = getShadowModel(linkRef.getOid());
    display("OpenDJ shadow linked to " + user, shadow);
    IntegrationTestTools.assertSecondaryIdentifier(shadow, "uid=" + user.getOid() + ",ou=clients,dc=example,dc=com");
// TODO: cn, sn, givenName
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Example 92 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class RawTypeUtil method getParsedItem.

public static <IV extends PrismValue, ID extends ItemDefinition> Item<IV, ID> getParsedItem(ID itemDefinition, List<RawType> values, QName elementQName, PrismContainerDefinition containerDef) throws SchemaException {
    Item<IV, ID> subItem = null;
    List<IV> parsedValues = new ArrayList<IV>();
    for (RawType rawValue : values) {
        if (itemDefinition == null && containerDef != null) {
            itemDefinition = (ID) ((PrismContextImpl) containerDef.getPrismContext()).getPrismUnmarshaller().locateItemDefinition(containerDef, elementQName, rawValue.getXnode());
        }
        IV parsed = rawValue.getParsedValue(itemDefinition, elementQName);
        if (parsed != null) {
            parsedValues.add(parsed);
        }
    }
    PrismContext prismContext = null;
    if (containerDef != null) {
        prismContext = containerDef.getPrismContext();
    }
    if (prismContext == null && itemDefinition != null) {
        prismContext = itemDefinition.getPrismContext();
    }
    if (itemDefinition == null) {
        PrismProperty property = new PrismProperty(elementQName, prismContext);
        property.addAll(PrismValue.cloneCollection(parsedValues));
        return property;
    }
    if (itemDefinition instanceof PrismPropertyDefinition<?>) {
        // property
        PrismProperty<?> property = ((PrismPropertyDefinition<?>) itemDefinition).instantiate();
        for (IV val : parsedValues) {
            property.add((PrismPropertyValue) val.clone());
        }
        subItem = (Item<IV, ID>) property;
    } else if (itemDefinition instanceof PrismContainerDefinition<?>) {
        PrismContainer<?> container = ((PrismContainerDefinition<?>) itemDefinition).instantiate();
        for (IV val : parsedValues) {
            container.add((PrismContainerValue) val.clone());
        }
        subItem = (Item<IV, ID>) container;
    } else if (itemDefinition instanceof PrismReferenceDefinition) {
        // TODO
        PrismReference reference = ((PrismReferenceDefinition) itemDefinition).instantiate();
        for (IV val : parsedValues) {
            PrismReferenceValue ref;
            if (val instanceof PrismReferenceValue) {
                ref = (PrismReferenceValue) val.clone();
            } else if (val instanceof PrismContainerValue) {
                // this is embedded (full) object
                Containerable c = ((PrismContainerValue) val).asContainerable();
                if (!(c instanceof Objectable)) {
                    throw new IllegalStateException("Content of " + itemDefinition + " is a Containerable but not Objectable: " + c);
                }
                Objectable o = (Objectable) c;
                ref = new PrismReferenceValue();
                ref.setObject(o.asPrismObject());
            } else {
                throw new IllegalStateException("Content of " + itemDefinition + " is neither PrismReferenceValue nor PrismContainerValue: " + val);
            }
            reference.merge(ref);
        }
        subItem = (Item<IV, ID>) reference;
    } else {
        throw new IllegalArgumentException("Unsupported definition type " + itemDefinition.getClass());
    }
    return subItem;
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PrismContext(com.evolveum.midpoint.prism.PrismContext) ArrayList(java.util.ArrayList) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) Item(com.evolveum.midpoint.prism.Item) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) PrismReference(com.evolveum.midpoint.prism.PrismReference) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Example 93 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class PrismReferenceArrayList method remove.

@Override
public boolean remove(Object o) {
    T t = (T) o;
    PrismReferenceValue value = getValueFrom(t);
    return reference.getValues().remove(value);
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Example 94 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class PrismReferenceArrayList method clear.

/**
     * JAXB unmarshaller is calling clear() on lists even though they were just
     * created. As the references should be visible as two JAXB fields, clearing one
     * of them will also clear the other. Therefore we need this hack. Calling clear()
     * will only clear the values that naturally "belong" to the list.
     */
@Override
public void clear() {
    List<PrismReferenceValue> values = reference.getValues();
    if (values == null) {
        return;
    }
    Iterator<PrismReferenceValue> iterator = values.iterator();
    while (iterator.hasNext()) {
        PrismReferenceValue value = iterator.next();
        if (willClear(value)) {
            iterator.remove();
        }
    }
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Example 95 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class PrismReferenceArrayList method remove.

@Override
public T remove(int i) {
    testIndex(i);
    PrismReferenceValue value = reference.getValues().get(i);
    reference.getValues().remove(i);
    return createItem(value);
}
Also used : PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11