Search in sources :

Example 61 with ItemName

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

the class AbstractIntegrationTest method getIcfUid.

protected String getIcfUid(PrismObject<ShadowType> shadow) {
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    assertNotNull(attributesContainer, "Null attributes in " + shadow);
    assertFalse(attributesContainer.isEmpty(), "Empty attributes in " + shadow);
    PrismProperty<String> icfUidProp = attributesContainer.findProperty(new ItemName(SchemaConstants.NS_ICF_SCHEMA, "uid"));
    assertNotNull(icfUidProp, "No ICF name attribute in " + shadow);
    return icfUidProp.getRealValue();
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 62 with ItemName

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

the class AbstractHigherUnitTest method assertNoAttribute.

protected void assertNoAttribute(PrismObject<ResourceType> resource, ShadowType shadow, String attrName) {
    ItemName attrQname = new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName);
    assertNoAttribute(resource, shadow, attrQname);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 63 with ItemName

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

the class CredentialPolicyEvaluator method hasValueDelta.

private boolean hasValueDelta(ObjectDelta<F> focusDelta, ItemPath credentialsPath) {
    if (focusDelta == null) {
        return false;
    }
    for (PartiallyResolvedDelta<PrismValue, ItemDefinition> partialDelta : focusDelta.findPartial(credentialsPath)) {
        LOGGER.trace("Residual delta:\n{}", partialDelta.debugDumpLazily());
        ItemPath residualPath = partialDelta.getResidualPath();
        if (ItemPath.isEmpty(residualPath)) {
            continue;
        }
        LOGGER.trace("PATH: {}", residualPath);
        ItemName name = residualPath.firstName();
        LOGGER.trace("NAME: {}", name);
        if (isValueElement(name)) {
            return true;
        }
    }
    return false;
}
Also used : ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) ItemName(com.evolveum.midpoint.prism.path.ItemName) PrismValue(com.evolveum.midpoint.prism.PrismValue) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 64 with ItemName

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

the class ExpressionEvaluationHelper method evaluateExpression.

@SuppressWarnings("unchecked")
@NotNull
public <T> List<T> evaluateExpression(ExpressionType expressionType, VariablesMap variables, String contextDescription, Class<T> clazz, QName typeName, boolean multiValued, Function<Object, Object> additionalConvertor, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
    MutableItemDefinition<?> resultDef;
    ItemName resultName = new ItemName(SchemaConstants.NS_C, "result");
    if (QNameUtil.match(typeName, ObjectReferenceType.COMPLEX_TYPE)) {
        resultDef = prismContext.definitionFactory().createReferenceDefinition(resultName, typeName);
    } else {
        resultDef = prismContext.definitionFactory().createPropertyDefinition(resultName, typeName);
    }
    if (multiValued) {
        resultDef.setMaxOccurs(-1);
    }
    Expression<?, ?> expression = expressionFactory.makeExpression(expressionType, resultDef, MiscSchemaUtil.getExpressionProfile(), contextDescription, task, result);
    ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDescription, task);
    context.setAdditionalConvertor(additionalConvertor);
    PrismValueDeltaSetTriple<?> exprResultTriple = ModelExpressionThreadLocalHolder.evaluateAnyExpressionInContext(expression, context, task, result);
    List<T> list = new ArrayList<>();
    for (PrismValue pv : exprResultTriple.getZeroSet()) {
        T realValue;
        if (pv instanceof PrismReferenceValue) {
            // pv.getRealValue sometimes returns synthesized Referencable, not ObjectReferenceType
            // If we would stay with that we would need to make many changes throughout workflow module.
            // So it is safer to stay with ObjectReferenceType.
            ObjectReferenceType ort = new ObjectReferenceType();
            ort.setupReferenceValue((PrismReferenceValue) pv);
            realValue = (T) ort;
        } else {
            realValue = pv.getRealValue();
        }
        list.add(realValue);
    }
    return list;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ArrayList(java.util.ArrayList) ItemName(com.evolveum.midpoint.prism.path.ItemName) NotNull(org.jetbrains.annotations.NotNull)

Example 65 with ItemName

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

the class RUtil method stringToQName.

public static ItemName stringToQName(String text) {
    if (Strings.isNullOrEmpty(text)) {
        return null;
    }
    int index = text.lastIndexOf(QNAME_DELIMITER);
    String namespace = StringUtils.left(text, index);
    String localPart = StringUtils.right(text, text.length() - index - 1);
    if (Strings.isNullOrEmpty(localPart)) {
        return null;
    }
    return new ItemName(namespace, localPart);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) RPolyString(com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3