Search in sources :

Example 51 with QueryType

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

the class PipelineData method getDataAsReferences.

/**
 * Returns the pipeline content as a list of references. Objects, PRVs, OIDs are converted directly
 * to references. Search filters and queries are evaluated first.
 *
 * This is a legacy method and its use should be avoided.
 */
@NotNull
public List<ObjectReferenceType> getDataAsReferences(QName defaultTargetType, Class<? extends ObjectType> typeForQuery, ExecutionContext context, OperationResult result) throws ScriptExecutionException, CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
    List<ObjectReferenceType> retval = new ArrayList<>(data.size());
    for (PipelineItem item : data) {
        PrismValue value = item.getValue();
        if (value instanceof PrismObjectValue) {
            PrismObjectValue<?> objectValue = (PrismObjectValue<?>) value;
            ObjectReferenceType ref = new ObjectReferenceType();
            ref.setType(objectValue.asPrismObject().getDefinition().getTypeName());
            ref.setOid(objectValue.getOid());
            retval.add(ref);
        } else if (value instanceof PrismPropertyValue) {
            Object realValue = value.getRealValue();
            if (realValue instanceof SearchFilterType) {
                retval.addAll(resolveQuery(typeForQuery, new QueryType().filter((SearchFilterType) realValue), context, result));
            } else if (realValue instanceof QueryType) {
                retval.addAll(resolveQuery(typeForQuery, (QueryType) realValue, context, result));
            } else if (realValue instanceof String) {
                ObjectReferenceType ref = new ObjectReferenceType();
                ref.setType(defaultTargetType);
                ref.setOid((String) realValue);
                retval.add(ref);
            } else if (realValue instanceof ObjectReferenceType) {
                retval.add((ObjectReferenceType) realValue);
            } else {
                throw new ScriptExecutionException("Unsupported reference type: " + value.getClass());
            }
        } else if (value instanceof PrismReferenceValue) {
            PrismReferenceValue referenceValue = (PrismReferenceValue) value;
            ObjectReferenceType ref = new ObjectReferenceType();
            ref.setupReferenceValue(referenceValue);
            retval.add(ref);
        }
    }
    return retval;
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) ScriptExecutionException(com.evolveum.midpoint.util.exception.ScriptExecutionException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) NotNull(org.jetbrains.annotations.NotNull)

Example 52 with QueryType

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

the class AuditSearchTest method searchObjects.

@NotNull
private SearchResultList<AuditEventRecordType> searchObjects(ObjectQuery query, OperationResult operationResult, SelectorOptions<GetOperationOptions>... selectorOptions) throws SchemaException {
    QueryType queryType = prismContext.getQueryConverter().createQueryType(query);
    String serializedQuery = prismContext.xmlSerializer().serializeAnyData(queryType, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
    display("QUERY: " + serializedQuery);
    // sanity check if it's re-parsable
    assertThat(prismContext.parserFor(serializedQuery).parseRealValue(QueryType.class)).isNotNull();
    return auditService.searchObjects(query, Arrays.asList(selectorOptions), operationResult);
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) NotNull(org.jetbrains.annotations.NotNull)

Example 53 with QueryType

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

the class AuditSearchTest method countObjects.

private int countObjects(ObjectQuery query, OperationResult operationResult, SelectorOptions<GetOperationOptions>... selectorOptions) throws SchemaException {
    QueryType queryType = prismContext.getQueryConverter().createQueryType(query);
    String serializedQuery = prismContext.xmlSerializer().serializeAnyData(queryType, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
    System.out.println("queryType = " + serializedQuery);
    // sanity check if it's re-parsable
    assertThat(prismContext.parserFor(serializedQuery).parseRealValue(QueryType.class)).isNotNull();
    return auditService.countObjects(query, Arrays.asList(selectorOptions), operationResult);
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 54 with QueryType

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

the class TestOpenDj method test201SearchObjects.

@Test
public void test201SearchObjects() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ShadowType object = parseObjectType(ACCOUNT_SEARCH_FILE, ShadowType.class);
    display("New object", object);
    String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
    assertEquals(ACCOUNT_SEARCH_OID, addedObjectOid);
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType);
    rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT);
    rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT);
    // WHEN
    SearchResultList<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    assertSuccess(result);
    display("Search results", searchResults);
    assertEquals("Unexpected number of search results", 14, searchResults.size());
    assertConnectorOperationIncrement(1, 29);
    assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0);
    // SPR search. No estimate.
    assertApproxNumberOfAllResults(searchResults.getMetadata(), null);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 55 with QueryType

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

the class TestOpenDj method test234SearchObjectsPagedOffsetSortSn.

@Test
public void test234SearchObjectsPagedOffsetSortSn() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = getQueryConverter().createObjectQuery(ShadowType.class, queryType);
    ObjectPaging paging = prismContext.queryFactory().createPaging(2, 4);
    paging.setOrdering(prismContext.queryFactory().createOrdering(PATH_SN, OrderDirection.ASCENDING));
    query.setPaging(paging);
    rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT);
    rememberCounter(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT);
    // WHEN
    when();
    List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    then();
    result.computeStatus();
    assertSuccess(result);
    display("Search results", searchResults);
    assertSearchResults(searchResults, "jbeckett", "jbond", "cook", "drake");
    assertConnectorOperationIncrement(1, 9);
    assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

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