use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testShadowKindTypeQuery.
@Test
public void testShadowKindTypeQuery() throws Exception {
displayTestTitle("testShadowKindTypeQuery");
SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
ObjectQuery query;
try {
ObjectFilter kindFilter = QueryBuilder.queryFor(ShadowType.class, getPrismContext()).item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT).buildFilter();
query = ObjectQuery.createObjectQuery(kindFilter);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
assertTrue("filter is not an instance of type filter", filter instanceof EqualFilter);
EqualFilter typeFilter = (EqualFilter) filter;
assertEquals(typeFilter.getSingleValue().getRealValue(), ShadowKindType.ACCOUNT);
QueryType convertedQueryType = toQueryType(query);
toObjectQuery(ShadowType.class, convertedQueryType);
displayQueryType(convertedQueryType);
} catch (Exception ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
}
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method test430OrgFilterDefaultScope.
@Test
public void test430OrgFilterDefaultScope() throws Exception {
final String TEST_NAME = "test430OrgFilterDefaultScope";
displayTestTitle(TEST_NAME);
// default scope is SUBTREE
String queryXml = "<?xml version='1.0'?><query><filter><org>\n" + " <orgRef>\n" + " <oid>333</oid>\n" + " </orgRef>\n" + " </org></filter></query>";
QueryType queryJaxb = toQueryType(queryXml);
displayQueryType(queryJaxb);
ObjectQuery query = toObjectQuery(OrgType.class, queryJaxb);
displayQuery(query);
ObjectQuery expectedQuery = QueryBuilder.queryFor(OrgType.class, getPrismContext()).isChildOf("333").build();
// primitive way of comparing queries
assertEquals("Parsed query is wrong", expectedQuery.toString(), query.toString());
// now reserialize the parsed query and compare with XML - the XML contains explicit scope=SUBTREE (as this is set when parsing original queryXml)
checkQueryRoundtripFile(OrgType.class, query, TEST_NAME);
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testGenericQuery.
@Test
public void testGenericQuery() throws Exception {
displayTestTitle("testGenericQuery");
SearchFilterType queryType = unmarshalFilter(FILTER_AND_GENERIC_FILE);
ObjectQuery query = toObjectQuery(GenericObjectType.class, queryType);
displayQuery(query);
// check parent filter
assertNotNull(query);
ObjectFilter filter = query.getFilter();
PrismAsserts.assertAndFilter(filter, 2);
// check first condition
ObjectFilter first = getFilterCondition(filter, 0);
PrismAsserts.assertEqualsFilter(first, GenericObjectType.F_NAME, PolyStringType.COMPLEX_TYPE, new ItemPath(GenericObjectType.F_NAME));
PrismAsserts.assertEqualsFilterValue((EqualFilter) first, createPolyString("generic object"));
// check second condition
ObjectFilter second = getFilterCondition(filter, 1);
PrismAsserts.assertEqualsFilter(second, intExtensionDefinition, DOMUtil.XSD_INT, new ItemPath(ObjectType.F_EXTENSION, new QName(NS_EXTENSION, "intType")));
PrismAsserts.assertEqualsFilterValue((EqualFilter) second, 123);
QueryType convertedQueryType = toQueryType(query);
assertNotNull("Re-serialized query is null ", convertedQueryType);
assertNotNull("Filter in re-serialized query must not be null.", convertedQueryType.getFilter());
displayQueryType(convertedQueryType);
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class PageRepositoryQuery method updateRequestWithMidpointQuery.
private void updateRequestWithMidpointQuery(RepositoryQueryDiagRequest request, QName objectType, String queryText, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
PrismContext prismContext = getPrismContext();
if (objectType == null) {
objectType = ObjectType.COMPLEX_TYPE;
}
@SuppressWarnings("unchecked") Class<? extends ObjectType> clazz = (Class<? extends ObjectType>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(objectType);
if (clazz == null) {
throw new SchemaException("Couldn't find compile-time class for object type of " + objectType);
}
QueryType queryType = prismContext.parserFor(queryText).xml().parseRealValue(QueryType.class);
request.setType(clazz);
ObjectQuery objectQuery = QueryJaxbConvertor.createObjectQuery(clazz, queryType, prismContext);
ObjectQuery queryWithExprEvaluated = ExpressionUtil.evaluateQueryExpressions(objectQuery, new ExpressionVariables(), getExpressionFactory(), getPrismContext(), "evaluate query expressions", task, result);
request.setQuery(queryWithExprEvaluated);
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class QueryBasedHandlerDto method getObjectQuery.
public String getObjectQuery() {
QueryType query = taskDto.getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.class);
if (query == null) {
return null;
}
PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
try {
return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serializeAnyData(query, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY));
} catch (SchemaException e) {
throw new SystemException("Couldn't serialize query: " + e.getMessage(), e);
}
}
Aggregations