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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations