use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class TestValidityRecomputeTask method test129JackAssignmentJudgeValidToSetValid.
@Test
public void test129JackAssignmentJudgeValidToSetValid() throws Exception {
final String TEST_NAME = "test129JackAssignmentJudgeValidToSetValid";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assertNoDummyAccount(null, USER_JACK_USERNAME);
AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID);
XMLGregorianCalendar validTo = clock.currentTimeXMLGregorianCalendar();
// one hour ahead
validTo.add(XmlTypeConverter.createDuration(60 * 60 * 1000));
// WHEN
TestUtil.displayWhen(TEST_NAME);
modifyObjectReplaceProperty(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_VALID_TO)), task, result, validTo);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismObject<UserType> user = getUser(USER_JACK_OID);
display("User after", user);
assertDummyAccount(null, USER_JACK_USERNAME);
assert11xUserOk(user);
// CLEANUP
unassignAllRoles(USER_JACK_OID);
assertNoDummyAccount(null, USER_JACK_USERNAME);
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class GeneralNotifier method formatPath.
private String formatPath(ItemDelta itemDelta) {
if (itemDelta.getDefinition() != null && itemDelta.getDefinition().getDisplayName() != null) {
return itemDelta.getDefinition().getDisplayName();
}
StringBuilder sb = new StringBuilder();
for (ItemPathSegment itemPathSegment : itemDelta.getPath().getSegments()) {
if (itemPathSegment instanceof NameItemPathSegment) {
NameItemPathSegment nameItemPathSegment = (NameItemPathSegment) itemPathSegment;
if (sb.length() > 0) {
sb.append("/");
}
sb.append(nameItemPathSegment.getName().getLocalPart());
}
}
return sb.toString();
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class SelectorOptions method isPathInSelected.
private static boolean isPathInSelected(ItemPath path, ItemPath selected) {
if (selected == null || path == null) {
return false;
}
if (path.isEmpty()) {
if (selected.isEmpty()) {
return true;
}
} else {
List<ItemPathSegment> pSegments = path.getSegments();
List<ItemPathSegment> sSegments = selected.getSegments();
for (int i = 0; i < pSegments.size(); i++) {
if (sSegments.size() <= i) {
return true;
}
NameItemPathSegment pSegment = (NameItemPathSegment) pSegments.get(i);
NameItemPathSegment sSegment = (NameItemPathSegment) sSegments.get(i);
if (!pSegment.equivalent(sSegment)) {
return false;
}
}
return true;
}
return false;
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class AbstractSearchExpressionEvaluator method evaluatePopulateExpression.
private <IV extends PrismValue, ID extends ItemDefinition, C extends Containerable> ItemDelta<IV, ID> evaluatePopulateExpression(PopulateItemType populateItem, ExpressionVariables variables, ExpressionEvaluationContext params, PrismContainerDefinition<C> objectDefinition, String contextDescription, boolean evaluateMinus, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
ExpressionType expressionType = populateItem.getExpression();
if (expressionType == null) {
LOGGER.warn("No expression in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
return null;
}
VariableBindingDefinitionType targetType = populateItem.getTarget();
if (targetType == null) {
LOGGER.warn("No target in populateObject in assignment expression in {}, " + "skipping. Subsequent operations will most likely fail", contextDescription);
return null;
}
ItemPathType itemPathType = targetType.getPath();
if (itemPathType == null) {
throw new SchemaException("No path in target definition in " + contextDescription);
}
ItemPath targetPath = itemPathType.getItemPath();
ID propOutputDefinition = ExpressionUtil.resolveDefinitionPath(targetPath, variables, objectDefinition, "target definition in " + contextDescription);
if (propOutputDefinition == null) {
throw new SchemaException("No target item that would conform to the path " + targetPath + " in " + contextDescription);
}
String expressionDesc = "expression in assignment expression in " + contextDescription;
ExpressionFactory expressionFactory = params.getExpressionFactory();
Expression<IV, ID> expression = expressionFactory.makeExpression(expressionType, propOutputDefinition, expressionDesc, task, result);
ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, expressionDesc, task, result);
context.setExpressionFactory(expressionFactory);
context.setStringPolicyResolver(params.getStringPolicyResolver());
context.setDefaultTargetContext(params.getDefaultTargetContext());
context.setSkipEvaluationMinus(true);
context.setSkipEvaluationPlus(false);
PrismValueDeltaSetTriple<IV> outputTriple = expression.evaluate(context);
LOGGER.trace("output triple: {}", outputTriple.debugDump());
Collection<IV> pvalues = outputTriple.getNonNegativeValues();
// Maybe not really clean but it works. TODO: refactor later
NameItemPathSegment first = (NameItemPathSegment) targetPath.first();
if (first.isVariable()) {
targetPath = targetPath.rest();
}
ItemDelta<IV, ID> itemDelta = propOutputDefinition.createEmptyDelta(targetPath);
itemDelta.addValuesToAdd(PrismValue.cloneCollection(pvalues));
LOGGER.trace("Item delta:\n{}", itemDelta.debugDump());
return itemDelta;
}
use of com.evolveum.midpoint.prism.path.NameItemPathSegment in project midpoint by Evolveum.
the class ObjectValuePolicyEvaluator method preparePassword.
private void preparePassword() {
if (!QNameUtil.match(UserType.F_CREDENTIALS, valueItemPath.getFirstName())) {
return;
}
ItemPathSegment secondPathSegment = valueItemPath.getSegments().get(1);
if (!(secondPathSegment instanceof NameItemPathSegment)) {
return;
}
credentialQName = ((NameItemPathSegment) secondPathSegment).getName();
if (!QNameUtil.match(CredentialsType.F_PASSWORD, credentialQName)) {
return;
}
credentialPolicy = SecurityUtil.getEffectivePasswordCredentialsPolicy(securityPolicy);
}
Aggregations