Search in sources :

Example 36 with ItemPath

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

the class ResourceContentPanel method newTaskPerformed.

private void newTaskPerformed(String category, AjaxRequestTarget target) {
    TaskType taskType = new TaskType();
    PrismProperty<ShadowKindType> pKind;
    try {
        pKind = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        pKind.setRealValue(getKind());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismProperty<String> pIntent;
    try {
        pIntent = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        pIntent.setRealValue(getIntent());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismObject<ResourceType> resource = getResourceModel().getObject();
    taskType.setObjectRef(ObjectTypeUtil.createObjectRef(resource));
    taskType.setCategory(category);
    setResponsePage(new PageTaskAdd(taskType));
    ;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PageTaskAdd(com.evolveum.midpoint.web.page.admin.server.PageTaskAdd)

Example 37 with ItemPath

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

the class ItemPathTypeDeserializer method deserialize.

@Override
public ItemPathType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    if (jp.getCurrentToken() != JsonToken.VALUE_STRING) {
        throw new JsonParseException("Cannot parse path value. Expected that the value will be string but it is: " + jp.getCurrentTokenId(), jp.getCurrentLocation());
    }
    String path = jp.getText();
    if (StringUtils.isBlank(path)) {
        throw new IllegalStateException("Error while deserializing path. No path specified.");
    }
    //System.out.println("path: " + path);
    //		if (path.startsWith("declare.*")){
    XPathHolder holder = new XPathHolder(path);
    ItemPath itemPath = holder.toItemPath();
    ItemPathType itemPathType = new ItemPathType(itemPath);
    return itemPathType;
//		ItemPathType itemPathType = new ItemPathType();
//		itemPathType.getContent().add(jp.getText());
//		
//		return itemPathType;
}
Also used : XPathHolder(com.evolveum.midpoint.prism.marshaller.XPathHolder) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) JsonParseException(com.fasterxml.jackson.core.JsonParseException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 38 with ItemPath

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

the class QueryConvertor method parseExistsFilter.

private static ExistsFilter parseExistsFilter(MapXNode clauseXMap, PrismContainerDefinition pcd, boolean preliminaryParsingOnly, PrismContext prismContext) throws SchemaException {
    ItemPath path = getPath(clauseXMap);
    XNode subXFilter = clauseXMap.get(ELEMENT_FILTER);
    ObjectFilter subFilter = null;
    PrismContainerDefinition subPcd = pcd != null ? pcd.findContainerDefinition(path) : null;
    if (subXFilter != null && subXFilter instanceof MapXNode) {
        subFilter = parseFilterInternal((MapXNode) subXFilter, subPcd, preliminaryParsingOnly, prismContext);
    }
    if (preliminaryParsingOnly) {
        return null;
    } else {
        // to report exception only when the filter is really to be used
        checkExtraElements(clauseXMap, ELEMENT_PATH, ELEMENT_FILTER);
        return ExistsFilter.createExists(path, pcd, subFilter);
    }
}
Also used : ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 39 with ItemPath

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

the class QueryConvertor method parseRefFilter.

private static <C extends Containerable> RefFilter parseRefFilter(MapXNode clauseXMap, PrismContainerDefinition<C> pcd, boolean preliminaryParsingOnly, PrismContext prismContext) throws SchemaException {
    ItemPath itemPath = getPath(clauseXMap);
    if (itemPath == null || itemPath.isEmpty()) {
        throw new SchemaException("Cannot convert query, because query does not contain property path.");
    }
    QName itemName = ItemPath.getName(itemPath.last());
    ItemDefinition itemDefinition = null;
    if (pcd != null) {
        itemDefinition = pcd.findItemDefinition(itemPath);
        if (itemDefinition == null && !preliminaryParsingOnly) {
            throw new SchemaException("No definition for item " + itemPath + " in " + pcd);
        }
    }
    XNode valueXnode = clauseXMap.get(ELEMENT_VALUE);
    if (valueXnode != null) {
        if (preliminaryParsingOnly) {
            return null;
        }
        RootXNode valueRoot = new RootXNode(ELEMENT_VALUE, valueXnode);
        Item<?, ?> item = prismContext.parserFor(valueRoot).name(itemName).definition(itemDefinition).context(ParsingContext.allowMissingRefTypes()).parseItem();
        if (!(item instanceof PrismReference)) {
            throw new IllegalStateException("Expected PrismReference, got " + item);
        }
        PrismReference ref = (PrismReference) item;
        if (item.getValues().size() < 1) {
            throw new IllegalStateException("No values to search specified for item " + itemName);
        }
        return RefFilter.createReferenceEqual(itemPath, (PrismReferenceDefinition) itemDefinition, PrismValue.cloneCollection(ref.getValues()));
    } else {
        ExpressionWrapper expressionWrapper = parseExpression(clauseXMap, prismContext);
        if (expressionWrapper != null) {
            if (preliminaryParsingOnly) {
                return null;
            } else {
                return RefFilter.createReferenceEqual(itemPath, (PrismReferenceDefinition) itemDefinition, expressionWrapper);
            }
        } else {
            if (preliminaryParsingOnly) {
                return null;
            } else {
                return RefFilter.createReferenceEqual(itemPath, (PrismReferenceDefinition) itemDefinition, (ExpressionWrapper) null);
            }
        }
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 40 with ItemPath

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

the class XPathTest method testCanonicalizationSimple.

@Test
public void testCanonicalizationSimple() throws Exception {
    ItemPath path = new ItemPath(UserType.F_NAME);
    assertCanonical(path, null, "\\" + COMMON + "#name");
}
Also used : CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30