Search in sources :

Example 66 with QueryType

use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.

the class ObjectSetUtil method getQueryFromTaskObjectRef.

private static QueryType getQueryFromTaskObjectRef(ObjectReferenceType objectRef) {
    if (objectRef == null) {
        return null;
    }
    SearchFilterType filterType = objectRef.getFilter();
    if (filterType == null || FilterUtil.isFilterEmpty(filterType)) {
        return null;
    }
    QueryType queryType = new QueryType();
    queryType.setFilter(filterType);
    return queryType;
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 67 with QueryType

use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.

the class TestQueryConverter method test930EqualsWithTypedValue.

/**
 * MID-6658
 */
@Test
public void test930EqualsWithTypedValue() throws Exception {
    SearchFilterType filterBean = PrismTestUtil.parseAtomicValue(FILTER_EQUALS_WITH_TYPED_VALUE, SearchFilterType.COMPLEX_TYPE);
    ObjectQuery query;
    try {
        query = getQueryConverter().createObjectQuery(UserType.class, filterBean);
        displayQuery(query);
        assertNotNull(query);
        ObjectFilter filter = query.getFilter();
        PrismAsserts.assertEqualsFilter(query.getFilter(), EXT_LONG_TYPE, DOMUtil.XSD_LONG, EXT_LONG_TYPE_PATH);
        PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, 4L);
        QueryType convertedQueryBean = toQueryType(query);
        displayQueryType(convertedQueryBean);
    } catch (Exception ex) {
        logger.error("Error while converting query: {}", ex.getMessage(), ex);
        throw ex;
    }
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Example 68 with QueryType

use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.

the class TestQueryConverter method testTypeFilterQuery.

@Test
public void testTypeFilterQuery() throws Exception {
    SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
    ObjectQuery query;
    try {
        query = getQueryConverter().createObjectQuery(ConnectorType.class, filterType);
        displayQuery(query);
        assertNotNull(query);
        ObjectFilter filter = query.getFilter();
        assertTrue("filter is not an instance of type filter", filter instanceof TypeFilter);
        TypeFilter typeFilter = (TypeFilter) filter;
        assertEquals(typeFilter.getType(), UserType.COMPLEX_TYPE);
        assertNotNull("filter in type filter must not be null", typeFilter.getFilter());
        ItemPath namePath = UserType.F_NAME;
        PrismPropertyDefinition ppd = getUserDefinition().findPropertyDefinition(namePath);
        PrismAsserts.assertEqualsFilter(typeFilter.getFilter(), ppd.getItemName(), ppd.getTypeName(), namePath);
        PrismAsserts.assertEqualsFilterValue((EqualFilter) typeFilter.getFilter(), PrismTestUtil.createPolyString("some name identificator"));
        QueryType convertedQueryType = toQueryType(query);
        displayQueryType(convertedQueryType);
    } catch (Exception ex) {
        logger.error("Error while converting query: {}", ex.getMessage(), ex);
        throw ex;
    }
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Example 69 with QueryType

use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.

the class TestQueryConverter method testAccountQueryAttributesAndResource.

@Test
public void testAccountQueryAttributesAndResource() throws Exception {
    SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_FILE);
    ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
    displayQuery(query);
    assertNotNull(query);
    ObjectFilter filter = query.getFilter();
    PrismAsserts.assertAndFilter(filter, 2);
    ObjectFilter first = getFilterCondition(filter, 0);
    PrismAsserts.assertRefFilter(first, ShadowType.F_RESOURCE_REF, ObjectReferenceType.COMPLEX_TYPE, ShadowType.F_RESOURCE_REF);
    assertRefFilterValue((RefFilter) first, "aae7be60-df56-11df-8608-0002a5d5c51b");
    ObjectFilter second = getFilterCondition(filter, 1);
    PrismAsserts.assertEqualsFilter(second, ICF_NAME, DOMUtil.XSD_STRING, ItemPath.create(ShadowType.F_ATTRIBUTES, ICF_NAME));
    PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "uid=jbond,ou=People,dc=example,dc=com");
    QueryType convertedQueryType = toQueryType(query);
// logger.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext())));
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Example 70 with QueryType

use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.

the class TestQueryConverter method test920QueryTypeEquals.

// Q{AND(IN OID: 8657eccf-c60d-4b5c-bbd4-4c73ecfd6436; ,REF: resourceRef,PRV(oid=aeff994e-381a-4fb3-af3b-f0f5dcdc9653, targetType=null),EQUAL: kind,PPV(ShadowKindType:ENTITLEMENT),EQUAL: intent,PPV(String:group)),null
@Test
public void test920QueryTypeEquals() throws Exception {
    ObjectQuery query1 = getPrismContext().queryFor(ShadowType.class).id("8657eccf-c60d-4b5c-bbd4-4c73ecfd6436").and().item(ShadowType.F_RESOURCE_REF).ref("aeff994e-381a-4fb3-af3b-f0f5dcdc9653").and().item(ShadowType.F_KIND).eq(ShadowKindType.ENTITLEMENT).and().item(ShadowType.F_INTENT).eq("group").build();
    ObjectQuery query2 = getPrismContext().queryFor(ShadowType.class).id("8657eccf-c60d-4b5c-bbd4-4c73ecfd6436").and().item(ShadowType.F_RESOURCE_REF).ref("aeff994e-381a-4fb3-af3b-f0f5dcdc9653").and().item(ShadowType.F_KIND).eq(ShadowKindType.ENTITLEMENT).and().item(ShadowType.F_INTENT).eq("group").build();
    System.out.println(query1.equals(query2));
    QueryType bean1 = getPrismContext().getQueryConverter().createQueryType(query1);
    QueryType bean2 = getPrismContext().getQueryConverter().createQueryType(query2);
    System.out.println(bean1.equals(bean2));
    System.out.println(bean1.hashCode() == bean2.hashCode());
}
Also used : QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)91 Test (org.junit.Test)89 QueryImpl (ddf.catalog.operation.impl.QueryImpl)71 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)67 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)58 Test (org.testng.annotations.Test)52 QName (javax.xml.namespace.QName)50 JAXBElement (javax.xml.bind.JAXBElement)44 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)38 ArrayList (java.util.ArrayList)37 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)34 Filter (org.opengis.filter.Filter)32 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 SortBy (org.opengis.filter.sort.SortBy)22 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)21 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)21 SortByImpl (ddf.catalog.filter.impl.SortByImpl)20 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)19 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)19 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)18