use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createReplaceAccountConstructionUserDelta.
protected ObjectDelta<UserType> createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException {
PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION);
ContainerDelta<ConstructionType> acDelta = new ContainerDelta<ConstructionType>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(id), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), pcd, prismContext);
// ContainerDelta.createDelta(prismContext, ConstructionType.class, AssignmentType.F_CONSTRUCTION);
acDelta.setValueToReplace(newValue.asPrismContainerValue());
// PropertyDelta.createModificationReplaceProperty(
// new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(id), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)),
// ppd,
// newValue);
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add(acDelta);
ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(userOid, modifications, UserType.class, prismContext);
return userDelta;
}
use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.
the class ConcurrencyTest method concurrency004_TwoWriters_TwoAttributesEach__OneReader.
@Test(enabled = true)
public void concurrency004_TwoWriters_TwoAttributesEach__OneReader() throws Exception {
ModifierThread[] mts = new ModifierThread[] { new ModifierThread(1, new ItemPath(UserType.F_GIVEN_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), true), new ModifierThread(2, new ItemPath(UserType.F_FAMILY_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), true) };
Checker checker = new Checker() {
@Override
public void check(int iteration, String oid) throws Exception {
PrismObject<UserType> userRetrieved = repositoryService.getObject(UserType.class, oid, null, new OperationResult("dummy"));
String givenName = userRetrieved.asObjectable().getGivenName().getOrig();
String familyName = userRetrieved.asObjectable().getFamilyName().getOrig();
String assignmentDescription = userRetrieved.asObjectable().getAssignment().get(0).getDescription();
String referenceDescription = userRetrieved.asObjectable().getAssignment().get(0).getConstruction().getDescription();
LOGGER.info("[" + iteration + "] givenName = " + givenName + ", assignment description = " + assignmentDescription + ", familyName = " + familyName + ", referenceDescription = " + referenceDescription);
if (!givenName.equals(assignmentDescription)) {
String msg = "Inconsistent object state: GivenName = " + givenName + ", assignment description = " + assignmentDescription;
LOGGER.error(msg);
throw new AssertionError(msg);
}
if (!familyName.equals(referenceDescription)) {
String msg = "Inconsistent object state: FamilyName = " + familyName + ", account construction description = " + referenceDescription;
LOGGER.error(msg);
throw new AssertionError(msg);
}
}
};
concurrencyUniversal("Test4", 60000L, 0L, mts, checker);
}
use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.
the class ConcurrencyTest method concurrency003_OneWriter_TwoAttributes__OneReader.
@Test(enabled = true)
public void concurrency003_OneWriter_TwoAttributes__OneReader() throws Exception {
ModifierThread[] mts = new ModifierThread[] { new ModifierThread(1, new ItemPath(UserType.F_GIVEN_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), true) };
Checker checker = new Checker() {
@Override
public void check(int iteration, String oid) throws Exception {
PrismObject<UserType> userRetrieved = repositoryService.getObject(UserType.class, oid, null, new OperationResult("dummy"));
String givenName = userRetrieved.asObjectable().getGivenName().getOrig();
String assignmentDescription = userRetrieved.asObjectable().getAssignment().get(0).getDescription();
LOGGER.info("[" + iteration + "] givenName = " + givenName + ", assignment description = " + assignmentDescription);
if (!givenName.equals(assignmentDescription)) {
String msg = "Inconsistent object state: GivenName = " + givenName + ", assignment description = " + assignmentDescription;
LOGGER.error(msg);
throw new AssertionError(msg);
}
}
};
concurrencyUniversal("Test3", 60000L, 0L, mts, checker);
}
use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.
the class JpaEntityDefinition method nextLinkDefinition.
@Override
public DataSearchResult<?> nextLinkDefinition(ItemPath path, ItemDefinition<?> itemDefinition, PrismContext prismContext) throws QueryException {
if (ItemPath.isNullOrEmpty(path)) {
// doesn't fulfill precondition
return null;
}
ItemPathSegment first = path.first();
if (first instanceof IdItemPathSegment) {
throw new QueryException("ID item path segments are not allowed in query: " + path);
} else if (first instanceof ObjectReferencePathSegment) {
throw new QueryException("'@' path segment cannot be used in the context of an entity " + this);
}
JpaLinkDefinition<?> link = findRawLinkDefinition(path, JpaDataNodeDefinition.class, false);
if (link == null) {
return null;
} else {
link.resolveEntityPointer();
return new DataSearchResult<>(link, path.tail(link.getItemPath().size()));
}
}
use of com.evolveum.midpoint.prism.path.IdItemPathSegment in project midpoint by Evolveum.
the class ComplexTypeDefinitionImpl method findItemDefinition.
@Override
public <ID extends ItemDefinition> ID findItemDefinition(@NotNull ItemPath path, @NotNull Class<ID> clazz) {
for (; ; ) {
if (path.isEmpty()) {
throw new IllegalArgumentException("Cannot resolve empty path on complex type definition " + this);
}
ItemPathSegment first = path.first();
if (first instanceof NameItemPathSegment) {
QName firstName = ((NameItemPathSegment) first).getName();
return findNamedItemDefinition(firstName, path.rest(), clazz);
} else if (first instanceof IdItemPathSegment) {
path = path.rest();
} else if (first instanceof ParentPathSegment) {
ItemPath rest = path.rest();
ComplexTypeDefinition parent = getSchemaRegistry().determineParentDefinition(this, rest);
if (rest.isEmpty()) {
// requires that the parent is defined as an item (container, object)
return (ID) getSchemaRegistry().findItemDefinitionByType(parent.getTypeName());
} else {
return parent.findItemDefinition(rest, clazz);
}
} else if (first instanceof ObjectReferencePathSegment) {
throw new IllegalStateException("Couldn't use '@' path segment in this context. CTD=" + getTypeName() + ", path=" + path);
} else {
throw new IllegalStateException("Unexpected path segment: " + first + " in " + path);
}
}
}
Aggregations