Search in sources :

Example 11 with IdItemPathSegment

use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.

the class PrismContainer method find.

@Override
public Object find(ItemPath path) {
    if (path == null || path.isEmpty()) {
        return this;
    }
    IdItemPathSegment idSegment = ItemPath.getFirstIdSegment(path);
    PrismContainerValue<C> cval = findValue(idSegment);
    if (cval == null) {
        return null;
    }
    // descent to the correct value
    ItemPath rest = ItemPath.pathRestStartingWithName(path);
    return cval.find(rest);
}
Also used : IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 12 with IdItemPathSegment

use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.

the class ContainerDelta method getSubDelta.

@Override
public ItemDelta<?, ?> getSubDelta(ItemPath path) {
    if (path.isEmpty()) {
        return this;
    }
    Long id = null;
    ItemPathSegment first = path.first();
    if (first instanceof IdItemPathSegment) {
        id = ((IdItemPathSegment) first).getId();
        path = path.rest();
    }
    ItemDefinition itemDefinition = getDefinition().findItemDefinition(path);
    if (itemDefinition == null) {
        throw new IllegalStateException("No definition of " + path + " in " + getDefinition());
    }
    ItemDelta<?, ?> itemDelta = itemDefinition.createEmptyDelta(getPath().subPath(path));
    itemDelta.addValuesToAdd(findItemValues(id, path, getValuesToAdd()));
    itemDelta.addValuesToDelete(findItemValues(id, path, getValuesToDelete()));
    itemDelta.setValuesToReplace(findItemValues(id, path, getValuesToReplace()));
    if (itemDelta.isEmpty()) {
        return null;
    }
    return itemDelta;
}
Also used : ItemPathSegment(com.evolveum.midpoint.prism.path.ItemPathSegment) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment)

Example 13 with IdItemPathSegment

use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.

the class AccCertCaseOperationsHelper method markCaseAsRemedied.

// TODO temporary implementation - should be done somehow in batches in order to improve performance
void markCaseAsRemedied(@NotNull String campaignOid, long caseId, Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, SecurityViolationException {
    PropertyDelta<XMLGregorianCalendar> reviewRemediedDelta = PropertyDelta.createModificationReplaceProperty(new ItemPath(new NameItemPathSegment(F_CASE), new IdItemPathSegment(caseId), new NameItemPathSegment(AccessCertificationCaseType.F_REMEDIED_TIMESTAMP)), generalHelper.getCampaignObjectDefinition(), XmlTypeConverter.createXMLGregorianCalendar(new Date()));
    updateHelper.modifyObjectViaModel(AccessCertificationCampaignType.class, campaignOid, Collections.singletonList(reviewRemediedDelta), task, parentResult);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 14 with IdItemPathSegment

use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method modifyAssignmentConstruction.

protected void modifyAssignmentConstruction(LensContext<UserType> context, UserType jack, String attributeName, String value, boolean add) throws SchemaException {
    assertEquals("jack's assignments", 1, jack.getAssignment().size());
    PrismPropertyDefinition<ResourceAttributeDefinitionType> attributeDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).findPropertyDefinition(new ItemPath(UserType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE));
    assertNotNull("no attributeDef", attributeDef);
    Long assignmentId = jack.getAssignment().get(0).getId();
    PropertyDelta<ResourceAttributeDefinitionType> attributeDelta = new PropertyDelta<ResourceAttributeDefinitionType>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION), new NameItemPathSegment(ConstructionType.F_ATTRIBUTE)), attributeDef, prismContext);
    ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType();
    attributeDefinitionType.setRef(new ItemPathType(new ItemPath(new QName(RESOURCE_DUMMY_NAMESPACE, attributeName))));
    MappingType outbound = new MappingType();
    // to see changes on the resource
    outbound.setStrength(MappingStrengthType.STRONG);
    ExpressionType expression = new ExpressionType();
    expression.getExpressionEvaluator().add(new ObjectFactory().createValue(value));
    outbound.setExpression(expression);
    attributeDefinitionType.setOutbound(outbound);
    if (add) {
        attributeDelta.addValueToAdd(new PrismPropertyValue<>(attributeDefinitionType));
    } else {
        attributeDelta.addValueToDelete(new PrismPropertyValue<>(attributeDefinitionType));
    }
    ObjectDelta<UserType> userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext);
    userDelta.setOid(USER_JACK_OID);
    userDelta.addModification(attributeDelta);
    addFocusDeltaToContext(context, userDelta);
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 15 with IdItemPathSegment

use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method modifyAssignmentValidity.

protected void modifyAssignmentValidity(LensContext<UserType> context, UserType jack, XMLGregorianCalendar validFrom, XMLGregorianCalendar validTo) throws SchemaException {
    assertEquals("jack's assignments", 1, jack.getAssignment().size());
    PrismContainerDefinition<ActivationType> activationDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).findContainerDefinition(new ItemPath(UserType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION));
    assertNotNull("no activationDef", activationDef);
    Long assignmentId = jack.getAssignment().get(0).getId();
    PrismPropertyDefinition<XMLGregorianCalendar> validFromDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_FROM);
    PropertyDelta<XMLGregorianCalendar> validFromDelta = new PropertyDelta<>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_FROM)), validFromDef, prismContext);
    validFromDelta.setValueToReplace(new PrismPropertyValue<>(validFrom));
    PrismPropertyDefinition<XMLGregorianCalendar> validToDef = activationDef.findPropertyDefinition(ActivationType.F_VALID_TO);
    PropertyDelta<XMLGregorianCalendar> validToDelta = new PropertyDelta<>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_TO)), validToDef, prismContext);
    validToDelta.setValueToReplace(new PrismPropertyValue<>(validTo));
    ObjectDelta<UserType> userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext);
    userDelta.setOid(USER_JACK_OID);
    userDelta.addModification(validFromDelta);
    userDelta.addModification(validToDelta);
    addFocusDeltaToContext(context, userDelta);
}
Also used : NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)35 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)27 Test (org.testng.annotations.Test)17 QName (javax.xml.namespace.QName)8 UserType (com.evolveum.midpoint.prism.foo.UserType)6 ItemPathSegment (com.evolveum.midpoint.prism.path.ItemPathSegment)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)5 AssignmentType (com.evolveum.midpoint.prism.foo.AssignmentType)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 ObjectReferencePathSegment (com.evolveum.midpoint.prism.path.ObjectReferencePathSegment)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)2