use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.
the class TestQueryConverter method test935NotEqualsNull.
/**
* MID-6657
*/
@Test
public void test935NotEqualsNull() throws Exception {
SearchFilterType filterBean = PrismTestUtil.parseAtomicValue(FILTER_NOT_EQUALS_NULL, SearchFilterType.COMPLEX_TYPE);
ObjectQuery query;
try {
query = getQueryConverter().createObjectQuery(UserType.class, filterBean);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
assertTrue(filter instanceof NotFilter);
ObjectFilter innerFilter = ((NotFilter) filter).getFilter();
assertTrue(innerFilter instanceof EqualFilter);
List<? extends PrismPropertyValue<?>> values = ((EqualFilter<?>) innerFilter).getValues();
assertTrue(values == null || values.isEmpty());
QueryType convertedQueryBean = toQueryType(query);
displayQueryType(convertedQueryBean);
} catch (Exception ex) {
logger.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
}
}
use of net.opengis.wfs.v_1_1_0.QueryType in project midpoint by Evolveum.
the class WebComponentUtil method createMenuItemsFromActions.
@NotNull
public static List<InlineMenuItem> createMenuItemsFromActions(@NotNull List<GuiActionType> actions, String operation, PageBase pageBase, @NotNull Supplier<Collection<? extends ObjectType>> selectedObjectsSupplier) {
List<InlineMenuItem> menuItems = new ArrayList<>();
actions.forEach(action -> {
if (action.getTaskTemplateRef() == null) {
return;
}
String templateOid = action.getTaskTemplateRef().getOid();
if (StringUtils.isEmpty(templateOid)) {
return;
}
String label = action.getDisplay() != null && PolyStringUtils.isNotEmpty(action.getDisplay().getLabel()) ? action.getDisplay().getLabel().getOrig() : action.getName();
menuItems.add(new InlineMenuItem(Model.of(label)) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new ColumnMenuAction<SelectableBean<ObjectType>>() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
OperationResult result = new OperationResult(operation);
try {
Collection<String> oids;
if (getRowModel() != null) {
oids = Collections.singletonList(getRowModel().getObject().getValue().getOid());
} else {
oids = CollectionUtils.emptyIfNull(selectedObjectsSupplier.get()).stream().filter(o -> o.getOid() != null).map(o -> o.getOid()).collect(Collectors.toSet());
}
if (!oids.isEmpty()) {
@NotNull Item<PrismValue, ItemDefinition> extensionQuery = prepareExtensionValues(oids);
MidPointPrincipal principal = pageBase.getPrincipal();
if (principal == null) {
throw new SecurityViolationException("No current user");
}
TaskType newTask = pageBase.getModelService().getObject(TaskType.class, templateOid, createCollection(createExecutionPhase()), pageBase.createSimpleTask(operation), result).asObjectable();
newTask.setName(PolyStringType.fromOrig(newTask.getName().getOrig() + " " + (int) (Math.random() * 10000)));
newTask.setOid(null);
newTask.setTaskIdentifier(null);
newTask.setOwnerRef(createObjectRef(principal.getFocus()));
newTask.setExecutionState(RUNNABLE);
newTask.setSchedulingState(READY);
newTask.asPrismObject().getOrCreateExtension().add(extensionQuery);
ObjectSetBasedWorkDefinitionType workDef = ObjectSetUtil.getObjectSetDefinitionFromTask(newTask);
QueryType query = (QueryType) extensionQuery.getRealValue();
ObjectSetType objectSet = workDef.getObjects();
if (objectSet == null) {
objectSet = new ObjectSetType();
objectSet.setType(ObjectType.COMPLEX_TYPE);
}
objectSet.setQuery(query);
workDef.setObjects(objectSet);
ObjectDelta<TaskType> delta = DeltaFactory.Object.createAddDelta(newTask.asPrismObject());
Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = saveTask(delta, result, pageBase);
String newTaskOid = ObjectDeltaOperation.findAddDeltaOid(executedChanges, newTask.asPrismObject());
newTask.setOid(newTaskOid);
newTask.setTaskIdentifier(newTaskOid);
result.setInProgress();
result.setBackgroundTaskOid(newTask.getOid());
} else {
result.recordWarning(pageBase.createStringResource("WebComponentUtil.message.createMenuItemsFromActions.warning").getString());
}
} catch (Exception ex) {
result.recordFatalError(result.getOperation(), ex);
target.add(pageBase.getFeedbackPanel());
} finally {
pageBase.showResult(result);
target.add(pageBase.getFeedbackPanel());
}
}
};
}
/**
* Extension values are task-dependent. Therefore, in the future we will probably make
* this behaviour configurable. For the time being we assume that the task template will be
* of "iterative task handler" type and so it will expect mext:objectQuery extension property.
*
* FIXME
*/
@NotNull
private Item<PrismValue, ItemDefinition> prepareExtensionValues(Collection<String> oids) throws SchemaException {
PrismContext prismContext = pageBase.getPrismContext();
ObjectQuery objectQuery = prismContext.queryFor(ObjectType.class).id(oids.toArray(new String[0])).build();
QueryType queryBean = pageBase.getQueryConverter().createQueryType(objectQuery);
PrismContainerDefinition<?> extDef = PrismContext.get().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class).findContainerDefinition(TaskType.F_EXTENSION);
ItemDefinition<Item<PrismValue, ItemDefinition>> def = extDef != null ? extDef.findItemDefinition(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY) : null;
if (def == null) {
throw new SchemaException("No definition of " + SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY + " in the extension");
}
Item<PrismValue, ItemDefinition> extensionItem = def.instantiate();
extensionItem.add(prismContext.itemFactory().createValue(queryBean));
return extensionItem;
}
});
});
return menuItems;
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class CswSubscriptionEndpoint method createOrUpdateSubscription.
public Response createOrUpdateSubscription(GetRecordsType request, String requestId, boolean persist) throws CswException {
validator.validateOutputFormat(request.getOutputFormat(), mimeTypeTransformerManager);
validator.validateOutputSchema(request.getOutputSchema(), schemaTransformerManager);
if (request.getAbstractQuery() != null) {
if (!request.getAbstractQuery().getValue().getClass().equals(QueryType.class)) {
throw new CswException("Unknown QueryType: " + request.getAbstractQuery().getValue().getClass());
}
QueryType query = (QueryType) request.getAbstractQuery().getValue();
validator.validateTypes(query.getTypeNames(), CswConstants.VERSION_2_0_2);
validator.validateElementNames(query);
if (query.getConstraint() != null && query.getConstraint().isSetFilter() && query.getConstraint().isSetCqlText()) {
throw new CswException("A Csw Query can only have a Filter or CQL constraint");
}
}
if (requestId != null) {
request.setRequestId(requestId);
}
addOrUpdateSubscription(request, persist);
LOGGER.trace("Exiting getRecordsSubscription.");
return createAcknowledgment(request);
}
use of net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class CswEndpointTest method testPostGetRecordsGmdCswOutputSchema.
@Test
public void testPostGetRecordsGmdCswOutputSchema() 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(GmdConstants.GMD_NAMESPACE, GmdConstants.GMD_LOCAL_NAME, GmdConstants.GMD_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
constraint.setCqlText(GMD_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 net.opengis.wfs.v_1_1_0.QueryType in project ddf by codice.
the class CswEndpointTest 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