use of com.evolveum.midpoint.prism.query.OrgFilter.Scope in project midpoint by Evolveum.
the class QueryConvertor method parseOrgFilter.
private static <C extends Containerable> OrgFilter parseOrgFilter(MapXNode clauseXMap, PrismContainerDefinition<C> pcd, boolean preliminaryParsingOnly, PrismContext prismContext) throws SchemaException {
if (Boolean.TRUE.equals(clauseXMap.getParsedPrimitiveValue(ELEMENT_IS_ROOT, DOMUtil.XSD_BOOLEAN))) {
// TODO check if other content is present
if (preliminaryParsingOnly) {
return null;
} else {
return OrgFilter.createRootOrg();
}
}
XNode xorgrefnode = clauseXMap.get(ELEMENT_ORG_REF);
if (xorgrefnode == null) {
throw new SchemaException("No organization reference defined in the search query.");
}
MapXNode xorgrefmap = toMap(xorgrefnode);
String orgOid = xorgrefmap.getParsedPrimitiveValue(ELEMENT_OID, DOMUtil.XSD_STRING);
if (orgOid == null || StringUtils.isBlank(orgOid)) {
throw new SchemaException("No oid attribute defined in the organization reference element.");
}
// original (in my opinion incorrect) place
String scopeString = xorgrefmap.getParsedPrimitiveValue(ELEMENT_SCOPE, DOMUtil.XSD_STRING);
if (scopeString == null) {
// here it is placed by the serializer
scopeString = clauseXMap.getParsedPrimitiveValue(ELEMENT_SCOPE, DOMUtil.XSD_STRING);
}
Scope scope = scopeString != null ? Scope.valueOf(scopeString) : null;
if (preliminaryParsingOnly) {
return null;
} else {
return OrgFilter.createOrg(orgOid, scope);
}
}
Aggregations