Search in sources :

Example 86 with QueryType

use of org.apache.openejb.jee.oejb2.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");
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 87 with QueryType

use of org.apache.openejb.jee.oejb2.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());
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) PrismTestUtil.createPolyString(com.evolveum.midpoint.prism.util.PrismTestUtil.createPolyString) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 88 with QueryType

use of org.apache.openejb.jee.oejb2.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");
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) ListXNode(com.evolveum.midpoint.prism.xnode.ListXNode) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 89 with QueryType

use of org.apache.openejb.jee.oejb2.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());
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) PrismTestUtil.createPolyString(com.evolveum.midpoint.prism.util.PrismTestUtil.createPolyString) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 90 with QueryType

use of org.apache.openejb.jee.oejb2.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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)57 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)41 Test (org.junit.Test)40 QueryImpl (ddf.catalog.operation.impl.QueryImpl)37 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)36 QName (javax.xml.namespace.QName)34 Test (org.testng.annotations.Test)32 JAXBElement (javax.xml.bind.JAXBElement)27 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)24 ArrayList (java.util.ArrayList)24 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)20 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)17 Matchers.anyString (org.mockito.Matchers.anyString)14 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 Task (com.evolveum.midpoint.task.api.Task)12 Holder (javax.xml.ws.Holder)12 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)12 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)12