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);
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class TestFilterExpression method test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal.
@Test
public void test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal() throws Exception {
final String TEST_NAME = "test212EvaluateExpressionLinkRefObjectReferenceTypeDefaultsVal";
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-object-reference-type-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