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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations