use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class FocusValidityScannerTaskHandler method createQuery.
@Override
protected ObjectQuery createQuery(AbstractScannerResultHandler<UserType> handler, TaskRunResult runResult, Task coordinatorTask, OperationResult opResult) throws SchemaException {
initProcessedOids(coordinatorTask);
ObjectQuery query = new ObjectQuery();
ObjectFilter filter;
PrismObjectDefinition<UserType> focusObjectDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
XMLGregorianCalendar lastScanTimestamp = handler.getLastScanTimestamp();
XMLGregorianCalendar thisScanTimestamp = handler.getThisScanTimestamp();
if (lastScanTimestamp == null) {
filter = QueryBuilder.queryFor(FocusType.class, prismContext).item(F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).or().exists(F_ASSIGNMENT).block().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(AssignmentType.F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).endBlock().buildFilter();
} else {
filter = QueryBuilder.queryFor(FocusType.class, prismContext).item(F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp).and().item(F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp).and().item(F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).or().exists(F_ASSIGNMENT).block().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).gt(lastScanTimestamp).and().item(AssignmentType.F_ACTIVATION, F_VALID_FROM).le(thisScanTimestamp).or().item(AssignmentType.F_ACTIVATION, F_VALID_TO).gt(lastScanTimestamp).and().item(AssignmentType.F_ACTIVATION, F_VALID_TO).le(thisScanTimestamp).endBlock().buildFilter();
}
query.setFilter(filter);
return query;
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class DeleteAllPanel method countShadows.
private void countShadows(boolean isAccountShadow) {
DeleteAllDto dto = model.getObject();
Task task = getPagebase().createSimpleTask(OPERATION_SEARCH_ITERATIVE_TASK);
OperationResult result = new OperationResult(OPERATION_SEARCH_ITERATIVE_TASK);
Collection<SelectorOptions<GetOperationOptions>> options = new ArrayList<>();
GetOperationOptions opt = GetOperationOptions.createRaw();
options.add(SelectorOptions.create(ItemPath.EMPTY_PATH, opt));
try {
ObjectFilter filter = QueryBuilder.queryFor(ShadowType.class, getPagebase().getPrismContext()).item(ShadowType.F_KIND).eq(ShadowKindType.ACCOUNT).buildFilter();
if (isAccountShadow) {
ObjectQuery query = ObjectQuery.createObjectQuery(filter);
dto.setAccountShadowCount(getPagebase().getModelService().countObjects(ShadowType.class, query, options, task, result));
dto.setObjectsToDelete(dto.getObjectsToDelete() + dto.getAccountShadowCount());
} else {
ObjectQuery query = ObjectQuery.createObjectQuery(NotFilter.createNot(filter));
dto.setNonAccountShadowCount(getPagebase().getModelService().countObjects(ShadowType.class, query, options, task, result));
dto.setObjectsToDelete(dto.getObjectsToDelete() + dto.getNonAccountShadowCount());
}
} catch (Exception ex) {
result.computeStatus(getString("deleteAllDialog.message.countSearchProblem"));
LoggingUtils.logUnexpectedException(LOGGER, getString("deleteAllDialog.message.countSearchProblem"), ex);
}
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class RefinedObjectClassDefinitionImpl method convertToPattern.
private static ResourceObjectPattern convertToPattern(ResourceObjectPatternType patternType, RefinedObjectClassDefinition rAccountDef) throws SchemaException {
ResourceObjectPattern resourceObjectPattern = new ResourceObjectPattern(rAccountDef);
SearchFilterType filterType = patternType.getFilter();
if (filterType != null) {
ObjectFilter filter = QueryConvertor.parseFilter(filterType, rAccountDef.getObjectDefinition());
resourceObjectPattern.addFilter(filter);
return resourceObjectPattern;
}
// Deprecated
if (patternType.getName() != null) {
RefinedAttributeDefinition attributeDefinition = rAccountDef.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "name"));
if (attributeDefinition == null) {
throw new SchemaException("No ICF NAME attribute in schema as specified in the definition of protected objects (this is deprecated syntax anyway, convert it to filter)");
}
ResourceAttribute<String> attr = attributeDefinition.instantiate();
attr.setRealValue(patternType.getName());
resourceObjectPattern.addIdentifier(attr);
} else if (patternType.getUid() != null) {
RefinedAttributeDefinition attributeDefinition = rAccountDef.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "uid"));
if (attributeDefinition == null) {
throw new SchemaException("No ICF UID attribute in schema as specified in the definition of protected objects (this is deprecated syntax anyway, convert it to filter)");
}
ResourceAttribute<String> attr = attributeDefinition.instantiate();
attr.setRealValue(patternType.getUid());
resourceObjectPattern.addIdentifier(attr);
} else {
throw new SchemaException("No filter and no deprecated name/uid in resource object pattern");
}
return resourceObjectPattern;
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class TestFilterExpression method test150EvaluateExpressionEmployeeTypeDefaultsNull.
@Test
public void test150EvaluateExpressionEmployeeTypeDefaultsNull() throws Exception {
final String TEST_NAME = "test150EvaluateExpressionEmployeeTypeDefaultsNull";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-filter-defaults.xml", null, EqualFilter.class, task, result);
EqualFilter equalFilter = (EqualFilter) filter;
AssertJUnit.assertNull("Expected NO values in filter, but found " + equalFilter.getValues(), equalFilter.getValues());
executeFilter(filter, 4, task, result);
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class TestFilterExpression method test210EvaluateExpressionLinkRefDefaultsVal.
@Test
public void test210EvaluateExpressionLinkRefDefaultsVal() throws Exception {
final String TEST_NAME = "test210EvaluateExpressionLinkRefDefaultsVal";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
ObjectFilter filter = evaluateExpressionAssertFilter("expression-linkref-filter-defaults.xml", ACCOUNT_SHADOW_GUYBRUSH_OID, RefFilter.class, task, result);
RefFilter refFilter = (RefFilter) filter;
assertEquals("Wrong number of values in filter: " + refFilter.getValues(), 1, refFilter.getValues().size());
executeFilter(filter, 1, task, result);
}
Aggregations