use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class TextFormatter method getItemPathLabel.
private String getItemPathLabel(ItemPath path, Definition deltaDefinition, PrismObjectDefinition objectDefinition) {
NameItemPathSegment lastNamedSegment = path.lastNamed();
StringBuilder sb = new StringBuilder();
for (ItemPathSegment segment : path.getSegments()) {
if (segment instanceof NameItemPathSegment) {
if (sb.length() > 0) {
sb.append("/");
}
Definition itemDefinition;
if (objectDefinition == null) {
if (segment == lastNamedSegment) {
// definition for last segment is the definition taken from delta
// this may be null but we don't care
itemDefinition = deltaDefinition;
} else {
// definitions for previous segments are unknown
itemDefinition = null;
}
} else {
// todo we could make this iterative (resolving definitions while walking down the path); but this is definitely simpler to implement and debug :)
itemDefinition = objectDefinition.findItemDefinition(path.allUpToIncluding(segment));
}
if (itemDefinition != null && itemDefinition.getDisplayName() != null) {
sb.append(resolve(itemDefinition.getDisplayName()));
} else {
sb.append(((NameItemPathSegment) segment).getName().getLocalPart());
}
} else if (segment instanceof IdItemPathSegment) {
sb.append("[").append(((IdItemPathSegment) segment).getId()).append("]");
}
}
return sb.toString();
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.
protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
if (task == null) {
task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget");
}
OperationResult result = task.getResult();
AssignmentType inducement = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(targetOid);
inducement.setTargetRef(targetRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT)), prismContext, inducement);
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcileAffected(reconcileAffected);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result);
result.computeStatus();
if (reconcileAffected) {
TestUtil.assertInProgressOrSuccess(result);
} else {
TestUtil.assertSuccess(result);
}
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddConstruction.
protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction");
OperationResult result = task.getResult();
ConstructionType construction = new ConstructionType();
ObjectReferenceType resourceRedRef = new ObjectReferenceType();
resourceRedRef.setOid(resourceOid);
construction.setResourceRef(resourceRedRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT), new IdItemPathSegment(inducementId), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), prismContext, construction);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class TestFind method testFindAssignment2Construction.
@Test
public void testFindAssignment2Construction() throws SchemaException, SAXException, IOException {
final String TEST_NAME = "testFindAssignment2ConstructionHowto";
System.out.println("===[ " + TEST_NAME + " ]===");
// GIVEN
ItemPath path = new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(USER_ASSIGNMENT_2_ID), new NameItemPathSegment(AssignmentType.F_ACCOUNT_CONSTRUCTION));
// WHEN
PrismProperty<AccountConstructionType> property = findUserProperty(path);
// THEN
assertEquals("Wrong property value (path=" + path + ")", "Just do it", property.getRealValue().getHowto());
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class TestPath method assertNormalizedPath.
private void assertNormalizedPath(ItemPath normalized, Object... expected) {
assertEquals("wrong path length", normalized.size(), expected.length);
for (int i = 0; i < normalized.size(); i += 2) {
ItemPathSegment nameSegment = normalized.getSegments().get(i);
assert nameSegment instanceof NameItemPathSegment : "Expected name segment but it was " + nameSegment.getClass();
QName name = ((NameItemPathSegment) nameSegment).getName();
assert name != null : "name is null";
assert name.getNamespaceURI().equals(NS) : "wrong namespace: " + name.getNamespaceURI();
assert name.getLocalPart().equals(expected[i]) : "wrong local name, expected " + expected[i] + ", was " + name.getLocalPart();
if (i + 1 < expected.length) {
ItemPathSegment idSegment = normalized.getSegments().get(i + 1);
assert idSegment instanceof IdItemPathSegment : "Expected is segment but it was " + nameSegment.getClass();
Long id = ((IdItemPathSegment) idSegment).getId();
assertId(id, (Long) expected[i + 1]);
}
}
}
Aggregations