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));
;
}
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;
}
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);
}
}
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);
}
}
}
}
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");
}
Aggregations