use of com.evolveum.prism.xml.ns._public.query_3.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();
}
use of com.evolveum.prism.xml.ns._public.query_3.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsValidate.
@Test
public void testPostGetRecordsValidate() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
GetRecordsType grr = createDefaultPostRecordsRequest();
grr.setResultType(ResultType.VALIDATE);
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
when(catalogFramework.query(argument.capture())).thenReturn(getQueryResponse());
CswRecordCollection collection = csw.getRecords(grr);
assertThat(collection.getCswRecords(), is(empty()));
assertThat(collection.getNumberOfRecordsMatched(), is(0L));
assertThat(collection.getNumberOfRecordsReturned(), is(0L));
}
use of com.evolveum.prism.xml.ns._public.query_3.QueryType in project ddf by codice.
the class CswQueryFactoryTest method ogcSpatialQuery.
/**
* Runs a binary Spatial OGC Query, verifying that the right filter class is generated based on OGC Filter
*
* @param spatialOps BinarySpatialOps query
* @throws UnsupportedQueryException
* @throws SourceUnavailableException
* @throws FederationException
* @throws CswException
*/
private <N extends BinarySpatialOperator> void ogcSpatialQuery(Class<N> clz, JAXBElement<BinarySpatialOpType> spatialOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
GetRecordsType grr = createDefaultPostRecordsRequest();
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
FilterType filter = new FilterType();
filter.setSpatialOps(spatialOps);
constraint.setFilter(filter);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
assertThat(frameworkQuery.getFilter(), instanceOf(clz));
@SuppressWarnings("unchecked") N spatial = (N) frameworkQuery.getFilter();
assertThat(((LiteralExpressionImpl) spatial.getExpression2()).getValue(), is(polygon));
assertThat(((AttributeExpressionImpl) spatial.getExpression1()).getPropertyName(), is(SPATIAL_TEST_ATTRIBUTE));
}
use of com.evolveum.prism.xml.ns._public.query_3.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsResults.
@Test
public void testPostGetRecordsResults() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
GetRecordsType grr = createDefaultPostRecordsRequest();
grr.setResultType(ResultType.RESULTS);
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
query.setConstraint(constraint);
ElementSetNameType esnt = new ElementSetNameType();
esnt.setValue(ElementSetType.SUMMARY);
query.setElementSetName(esnt);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
final String exampleSchema = CswConstants.CSW_OUTPUT_SCHEMA;
grr.setOutputSchema(exampleSchema);
final String exampleMime = "application/xml";
grr.setOutputFormat(exampleMime);
CswRecordCollection collection = csw.getRecords(grr);
assertThat(collection.getMimeType(), is(exampleMime));
assertThat(collection.getOutputSchema(), is(exampleSchema));
assertThat(collection.getSourceResponse(), notNullValue());
assertThat(collection.getResultType(), is(ResultType.RESULTS));
assertThat(collection.getElementSetType(), is(ElementSetType.SUMMARY));
}
use of com.evolveum.prism.xml.ns._public.query_3.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsValidElementNames.
/**
* Test Valid GetRecords request, no exceptions should be thrown
*/
@Test
public void testPostGetRecordsValidElementNames() throws CswException {
GetRecordsType grr = createDefaultPostRecordsRequest();
QueryType query = new QueryType();
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
List<QName> elementNameList = Arrays.asList(new QName("brief"), new QName("summary"), new QName("full"));
query.setElementName(elementNameList);
grr.setAbstractQuery(jaxbQuery);
csw.getRecords(grr);
}
Aggregations