use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertors method testFilterUserNameJaxb.
@Test
public void testFilterUserNameJaxb() throws Exception {
displayTestTitle("testFilterUserNameJaxb");
SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_NAME_FILE);
ObjectQuery query = toObjectQuery(UserType.class, filterType);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
PrismAsserts.assertEqualsFilter(filter, UserType.F_NAME, PolyStringType.COMPLEX_TYPE, new ItemPath(new QName(null, UserType.F_NAME.getLocalPart())));
PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, createPolyString("jack"));
QueryType convertedQueryType = toQueryType(query);
System.out.println("Re-converted query type");
System.out.println(convertedQueryType.debugDump());
Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
System.out.println("Serialized filter (JAXB->DOM)");
System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
DomAsserts.assertElementQName(filterClauseElement, EqualFilter.ELEMENT_NAME);
DomAsserts.assertSubElements(filterClauseElement, 2);
DomAsserts.assertSubElement(filterClauseElement, PrismConstants.Q_VALUE);
Element valueElement = DOMUtil.getChildElement(filterClauseElement, PrismConstants.Q_VALUE);
DomAsserts.assertTextContent(valueElement, "jack");
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertors method testFilterNotInOid.
@Test
public void testFilterNotInOid() throws Exception {
displayTestTitle("testFilterNotInOid");
SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_IN_OID);
ObjectQuery query = toObjectQuery(UserType.class, filterType);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
assertTrue("Filter is not of NOT type", filter instanceof NotFilter);
ObjectFilter subFilter = ((NotFilter) filter).getFilter();
assertTrue("Subfilter is not of IN_OID type", subFilter instanceof InOidFilter);
QueryType convertedQueryType = toQueryType(query);
System.out.println("Re-converted query type");
System.out.println(convertedQueryType.debugDump());
Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump());
System.out.println("Serialized filter (JAXB->DOM)");
String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement);
System.out.println(filterAsString);
LOGGER.info(filterAsString);
DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not"));
assertEquals("wrong # of inOid subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "inOid").getLength());
assertEquals("wrong # of value subfilters", 4, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength());
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertors method testFilterUserAndJaxb.
@Test
public void testFilterUserAndJaxb() throws Exception {
displayTestTitle("testFilterUserAndJaxb");
SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_USER_AND_FILE);
ObjectQuery query = toObjectQuery(UserType.class, filterType);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
PrismAsserts.assertAndFilter(filter, 2);
ObjectFilter first = getFilterCondition(filter, 0);
PrismAsserts.assertEqualsFilter(first, UserType.F_GIVEN_NAME, DOMUtil.XSD_STRING, new ItemPath(new QName(null, UserType.F_GIVEN_NAME.getLocalPart())));
PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "Jack");
ObjectFilter second = getFilterCondition(filter, 1);
PrismAsserts.assertEqualsFilter(second, UserType.F_LOCALITY, DOMUtil.XSD_STRING, new ItemPath(new QName(null, UserType.F_LOCALITY.getLocalPart())));
PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "Caribbean");
QueryType convertedQueryType = toQueryType(query);
System.out.println("Re-converted query type");
System.out.println(convertedQueryType.debugDump());
SearchFilterType convertedFilterType = convertedQueryType.getFilter();
MapXNode xFilter = convertedFilterType.serializeToXNode();
PrismAsserts.assertSize(xFilter, 1);
PrismAsserts.assertSubnode(xFilter, AndFilter.ELEMENT_NAME, MapXNode.class);
MapXNode xandmap = (MapXNode) xFilter.get(AndFilter.ELEMENT_NAME);
PrismAsserts.assertSize(xandmap, 1);
PrismAsserts.assertSubnode(xandmap, EqualFilter.ELEMENT_NAME, ListXNode.class);
ListXNode xequalsList = (ListXNode) xandmap.get(EqualFilter.ELEMENT_NAME);
PrismAsserts.assertSize(xequalsList, 2);
Element filterClauseElement = convertedFilterType.getFilterClauseAsElement(getPrismContext());
System.out.println("Serialized filter (JAXB->DOM)");
System.out.println(DOMUtil.serializeDOMToString(filterClauseElement));
DomAsserts.assertElementQName(filterClauseElement, AndFilter.ELEMENT_NAME);
DomAsserts.assertSubElements(filterClauseElement, 2);
Element firstSubelement = DOMUtil.getChildElement(filterClauseElement, 0);
DomAsserts.assertElementQName(firstSubelement, EqualFilter.ELEMENT_NAME);
Element firstValueElement = DOMUtil.getChildElement(firstSubelement, PrismConstants.Q_VALUE);
DomAsserts.assertTextContent(firstValueElement, "Jack");
Element secondSubelement = DOMUtil.getChildElement(filterClauseElement, 1);
DomAsserts.assertElementQName(secondSubelement, EqualFilter.ELEMENT_NAME);
Element secondValueElement = DOMUtil.getChildElement(secondSubelement, PrismConstants.Q_VALUE);
DomAsserts.assertTextContent(secondValueElement, "Caribbean");
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertors method testFilterNotFullText.
@Test
public void testFilterNotFullText() throws Exception {
displayTestTitle("testFilterNotFullText");
SearchFilterType filterType = PrismTestUtil.parseAnyValue(FILTER_NOT_FULL_TEXT);
ObjectQuery query = toObjectQuery(UserType.class, filterType);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
assertTrue("Filter is not of NOT type", filter instanceof NotFilter);
ObjectFilter subFilter = ((NotFilter) filter).getFilter();
assertTrue("Subfilter is not of FULL_TEXT type", subFilter instanceof FullTextFilter);
QueryType convertedQueryType = toQueryType(query);
System.out.println("Re-converted query type");
System.out.println(convertedQueryType.debugDump());
Element filterClauseElement = convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext());
LOGGER.info(convertedQueryType.getFilter().getFilterClauseXNode().debugDump());
System.out.println("Serialized filter (JAXB->DOM)");
String filterAsString = DOMUtil.serializeDOMToString(filterClauseElement);
System.out.println(filterAsString);
LOGGER.info(filterAsString);
DomAsserts.assertElementQName(filterClauseElement, new QName(PrismConstants.NS_QUERY, "not"));
assertEquals("wrong # of fullText subfilters", 1, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "fullText").getLength());
assertEquals("wrong # of value subfilters", 2, filterClauseElement.getElementsByTagNameNS(PrismConstants.NS_QUERY, "value").getLength());
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class PageDebugList method deleteObjectsAsync.
private String deleteObjectsAsync(QName type, ObjectQuery objectQuery, boolean raw, String taskName, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
Task task = createSimpleTask(result.getOperation());
task.setHandlerUri(ModelPublicConstants.DELETE_TASK_HANDLER_URI);
if (objectQuery == null) {
objectQuery = new ObjectQuery();
}
QueryType query = QueryJaxbConvertor.createQueryType(objectQuery, getPrismContext());
PrismPropertyDefinition queryDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE, getPrismContext());
PrismProperty<QueryType> queryProp = queryDef.instantiate();
queryProp.setRealValue(query);
task.setExtensionProperty(queryProp);
PrismPropertyDefinition typeDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE, DOMUtil.XSD_QNAME, getPrismContext());
PrismProperty<QName> typeProp = typeDef.instantiate();
typeProp.setRealValue(type);
task.setExtensionProperty(typeProp);
PrismPropertyDefinition rawDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OPTION_RAW, DOMUtil.XSD_BOOLEAN, getPrismContext());
PrismProperty<QName> rawProp = rawDef.instantiate();
rawProp.setRealValue(raw);
task.setExtensionProperty(rawProp);
task.setName(taskName);
task.savePendingModifications(result);
TaskManager taskManager = getTaskManager();
taskManager.switchToBackground(task, result);
result.setBackgroundTaskOid(task.getOid());
return task.getOid();
}
Aggregations