use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class Clockwork method triggerReconcileAffected.
private <F extends ObjectType> HookOperationMode triggerReconcileAffected(LensContext<F> context, Task task, OperationResult result) throws SchemaException {
// check applicability
if (!ModelExecuteOptions.isReconcileAffected(context.getOptions())) {
return HookOperationMode.FOREGROUND;
}
if (context.getFocusClass() == null || !RoleType.class.isAssignableFrom(context.getFocusClass())) {
LOGGER.warn("ReconcileAffected requested but not available for {}. Doing nothing.", context.getFocusClass());
return HookOperationMode.FOREGROUND;
}
// check preconditions
if (context.getFocusContext() == null) {
throw new IllegalStateException("No focus context when expected it");
}
PrismObject<RoleType> role = (PrismObject) context.getFocusContext().getObjectAny();
if (role == null) {
throw new IllegalStateException("No role when expected it");
}
// preparing the recompute/reconciliation task
Task reconTask;
if (task.isPersistent()) {
reconTask = task.createSubtask();
} else {
reconTask = task;
}
assert !reconTask.isPersistent();
// creating object query
PrismPropertyDefinition propertyDef = prismContext.getSchemaRegistry().findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
PrismReferenceValue referenceValue = new PrismReferenceValue(context.getFocusContext().getOid(), RoleType.COMPLEX_TYPE);
ObjectFilter refFilter = QueryBuilder.queryFor(FocusType.class, prismContext).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(referenceValue).buildFilter();
SearchFilterType filterType = QueryConvertor.createSearchFilterType(refFilter, prismContext);
QueryType queryType = new QueryType();
queryType.setFilter(filterType);
PrismProperty<QueryType> property = propertyDef.instantiate();
property.setRealValue(queryType);
reconTask.addExtensionProperty(property);
// other parameters
reconTask.setName("Recomputing users after changing role " + role.asObjectable().getName());
reconTask.setBinding(TaskBinding.LOOSE);
reconTask.setInitialExecutionStatus(TaskExecutionStatus.RUNNABLE);
reconTask.setHandlerUri(RecomputeTaskHandler.HANDLER_URI);
reconTask.setCategory(TaskCategory.RECOMPUTATION);
taskManager.switchToBackground(reconTask, result);
result.setBackgroundTaskOid(reconTask.getOid());
result.recordStatus(OperationResultStatus.IN_PROGRESS, "Reconciliation task switched to background");
return HookOperationMode.BACKGROUND;
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testAccountQueryAttributesAndResourceNoNs.
@Test
public void testAccountQueryAttributesAndResourceNoNs() throws Exception {
displayTestTitle("testAccountQueryAttributesAndResourceNoNs");
SearchFilterType filterType = unmarshalFilter(FILTER_ACCOUNT_ATTRIBUTES_RESOURCE_REF_NO_NS_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, new ItemPath(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, new ItemPath("attributes", "name"));
//PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "uid=jbond,ou=People,dc=example,dc=com");
QueryType convertedQueryType = toQueryType(query);
System.out.println(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext())));
// TODO: add some asserts
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testConnectorQuery.
@Test
public void testConnectorQuery() throws Exception {
displayTestTitle("testConnectorQuery");
SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_CONNECTOR_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE);
ObjectQuery query;
try {
query = QueryJaxbConvertor.createObjectQuery(ConnectorType.class, filterType, getPrismContext());
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
PrismAsserts.assertEqualsFilter(query.getFilter(), ConnectorType.F_CONNECTOR_TYPE, DOMUtil.XSD_STRING, new ItemPath(ConnectorType.F_CONNECTOR_TYPE));
PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, "org.identityconnectors.ldap.LdapConnector");
QueryType convertedQueryType = toQueryType(query);
displayQueryType(convertedQueryType);
} catch (Exception ex) {
LOGGER.error("Error while converting query: {}", ex.getMessage(), ex);
throw ex;
}
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method checkQuery.
private void checkQuery(Class<? extends Containerable> objectClass, ObjectQuery q1object, String q2xml) throws Exception {
// step 1 (serialization of Q1 + comparison)
displayText("Query 1:");
displayQuery(q1object);
QueryType q1jaxb = toQueryType(q1object);
displayQueryType(q1jaxb);
String q1xml = toXml(q1jaxb);
displayQueryXml(q1xml);
// XMLAssert.assertXMLEqual("Serialized query is not correct: Expected:\n" + q2xml + "\n\nReal:\n" + q1xml, q2xml, q1xml);
// step 2 (parsing of Q2 + comparison)
displayText("Query 2:");
displayQueryXml(q2xml);
QueryType q2jaxb = toQueryType(q2xml);
displayQueryType(q2jaxb);
ObjectQuery q2object = toObjectQuery(objectClass, q2jaxb);
// primitive way of comparing parsed queries
assertEquals("Reparsed query is not as original one (via toString)", q1object.toString(), q2object.toString());
assertTrue("Reparsed query is not as original one (via equivalent):\nq1=" + q1object + "\nq2=" + q2object, q1object.equivalent(q2object));
}
use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.
the class TestQueryConvertor method testAccountQueryCompositeOr.
@Test
public void testAccountQueryCompositeOr() throws Exception {
displayTestTitle("testAccountQueryCompositeOr");
SearchFilterType filterType = unmarshalFilter(FILTER_OR_COMPOSITE);
ObjectQuery query = toObjectQuery(ShadowType.class, filterType);
displayQuery(query);
assertNotNull(query);
ObjectFilter filter = query.getFilter();
PrismAsserts.assertOrFilter(filter, 4);
ObjectFilter first = getFilterCondition(filter, 0);
PrismAsserts.assertEqualsFilter(first, ShadowType.F_INTENT, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_INTENT));
PrismAsserts.assertEqualsFilterValue((EqualFilter) first, "some account type");
ObjectFilter second = getFilterCondition(filter, 1);
PrismAsserts.assertEqualsFilter(second, fooBlaDefinition, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_ATTRIBUTES, fooBlaDefinition));
PrismAsserts.assertEqualsFilterValue((EqualFilter) second, "foo value");
ObjectFilter third = getFilterCondition(filter, 2);
PrismAsserts.assertEqualsFilter(third, stringExtensionDefinition, DOMUtil.XSD_STRING, new ItemPath(ShadowType.F_EXTENSION, stringExtensionDefinition));
PrismAsserts.assertEqualsFilterValue((EqualFilter) third, "uid=test,dc=example,dc=com");
ObjectFilter forth = getFilterCondition(filter, 3);
PrismAsserts.assertRefFilter(forth, ShadowType.F_RESOURCE_REF, ObjectReferenceType.COMPLEX_TYPE, new ItemPath(ShadowType.F_RESOURCE_REF));
assertRefFilterValue((RefFilter) forth, "d0db5be9-cb93-401f-b6c1-86ffffe4cd5e");
QueryType convertedQueryType = toQueryType(query);
LOGGER.info(DOMUtil.serializeDOMToString(convertedQueryType.getFilter().getFilterClauseAsElement(getPrismContext())));
// TODO: add some asserts
}
Aggregations