use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class PolicyRuleProcessor method getNumberOfAssigneesExceptMyself.
/**
* Returns numbers of assignees with the given relation name.
*/
private int getNumberOfAssigneesExceptMyself(AbstractRoleType target, String selfOid, QName relation, OperationResult result) throws SchemaException {
S_AtomicFilterExit q = QueryBuilder.queryFor(FocusType.class, prismContext).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(target.getOid());
if (selfOid != null) {
q = q.and().not().id(selfOid);
}
ObjectQuery query = q.build();
List<PrismObject<FocusType>> assignees = repositoryService.searchObjects(FocusType.class, query, null, result);
int count = 0;
assignee: for (PrismObject<FocusType> assignee : assignees) {
for (AssignmentType assignment : assignee.asObjectable().getAssignment()) {
if (assignment.getTargetRef() != null && ObjectTypeUtil.relationsEquivalent(relation, assignment.getTargetRef().getRelation())) {
count++;
continue assignee;
}
}
}
return count;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class FocusConstraintsChecker method checkPropertyUniqueness.
private <T> boolean checkPropertyUniqueness(PrismObject<F> objectNew, ItemPath propPath, LensContext<F> context, OperationResult result) throws SchemaException {
PrismProperty<T> property = objectNew.findProperty(propPath);
if (property == null || property.isEmpty()) {
throw new SchemaException("No property " + propPath + " in new object " + objectNew + ", cannot check uniqueness");
}
String oid = objectNew.getOid();
ObjectQuery query = QueryBuilder.queryFor(objectNew.getCompileTimeClass(), prismContext).itemAs(property).build();
List<PrismObject<F>> foundObjects = repositoryService.searchObjects(objectNew.getCompileTimeClass(), query, null, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Uniqueness check of {}, property {} resulted in {} results, using query:\n{}", new Object[] { objectNew, propPath, foundObjects.size(), query.debugDump() });
}
if (foundObjects.isEmpty()) {
return true;
}
if (foundObjects.size() > 1) {
LOGGER.trace("Found more than one object with property " + propPath + " = " + property);
message("Found more than one object with property " + propPath + " = " + property);
return false;
}
LOGGER.trace("Comparing {} and {}", foundObjects.get(0).getOid(), oid);
boolean match = foundObjects.get(0).getOid().equals(oid);
if (!match) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Found conflicting existing object with property " + propPath + " = " + property + ":\n" + foundObjects.get(0).debugDump());
}
message("Found conflicting existing object with property " + propPath + " = " + property + ": " + foundObjects.get(0));
conflictingObject = foundObjects.get(0);
}
return match;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchPanel method searchPerformed.
void searchPerformed(AjaxRequestTarget target) {
PageBase page = (PageBase) getPage();
PrismContext ctx = page.getPrismContext();
Search search = getModelObject();
ObjectQuery query = search.createObjectQuery(ctx);
LOG.debug("Created query: {}", query);
searchPerformed(query, target);
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class SearchFormPanel method initLayout.
protected void initLayout() {
final Form searchForm = new Form(ID_SEARCH_FORM);
add(searchForm);
searchForm.setOutputMarkupId(true);
SearchPanel search = new SearchPanel(ID_SEARCH, getModel()) {
@Override
public void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {
SearchFormPanel.this.searchPerformed(query, target);
}
};
searchForm.add(search);
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class PageTaskAdd method createResourceList.
private List<TaskAddResourcesDto> createResourceList() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
List<PrismObject<ResourceType>> resources = null;
List<TaskAddResourcesDto> resourceList = new ArrayList<TaskAddResourcesDto>();
try {
resources = getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't get resource list.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list", ex);
}
// }
if (resources != null) {
ResourceType item = null;
for (PrismObject<ResourceType> resource : resources) {
item = resource.asObjectable();
resourceList.add(new TaskAddResourcesDto(item.getOid(), WebComponentUtil.getOrigStringFromPoly(item.getName())));
}
}
return resourceList;
}
Aggregations