use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class ResourceDependencyEditor method createResourceList.
private List<ObjectReferenceType> createResourceList() {
resourceMap.clear();
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_RESOURCES);
List<PrismObject<ResourceType>> resources = null;
List<ObjectReferenceType> references = new ArrayList<>();
try {
resources = getPageBase().getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (CommonException | RuntimeException e) {
result.recordFatalError("Couldn't get resource list.", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list.", e);
}
if (resources != null) {
ObjectReferenceType ref;
for (PrismObject<ResourceType> r : resources) {
resourceMap.put(r.getOid(), WebComponentUtil.getName(r));
ref = new ObjectReferenceType();
ref.setType(ResourceType.COMPLEX_TYPE);
ref.setOid(r.getOid());
references.add(ref);
}
}
return references;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class ExpressionVariableEditorDialog method createObjectReferenceListDeprecated.
private List<ObjectReferenceType> createObjectReferenceListDeprecated() {
objectMap.clear();
OperationResult result = new OperationResult(OPERATION_LOAD_REPOSITORY_OBJECTS);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_REPOSITORY_OBJECTS);
List<PrismObject<ObjectType>> objects = null;
List<ObjectReferenceType> references = new ArrayList<>();
try {
objects = getPageBase().getModelService().searchObjects(ObjectType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (CommonException | RuntimeException e) {
result.recordFatalError("Couldn't load objects from repository.", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load objects from repository", e);
}
if (objects != null) {
ObjectReferenceType ref;
for (PrismObject<ObjectType> obj : objects) {
objectMap.put(obj.getOid(), WebComponentUtil.getName(obj));
ref = new ObjectReferenceType();
ref.setOid(obj.getOid());
references.add(ref);
}
}
return references;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class TreeTablePanel method hasChildren.
private boolean hasChildren(SelectableBean<OrgType> orgToDelete) {
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isChildOf(// TODO what if orgToDelete.getValue()==null
orgToDelete.getValue().getOid()).build();
Task task = getPageBase().createSimpleTask(OPERATION_COUNT_CHILDREN);
OperationResult result = new OperationResult(OPERATION_COUNT_CHILDREN);
try {
int count = getPageBase().getModelService().countObjects(ObjectType.class, query, null, task, result);
return (count > 0);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | CommunicationException | ExpressionEvaluationException e) {
LoggingUtils.logUnexpectedException(LOGGER, e.getMessage(), e);
result.recordFatalError("Could not count members for org " + orgToDelete.getValue(), e);
return false;
}
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class OrgTreeProvider method getChildren.
@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
// getAvailableData().clear();
LOGGER.debug("Loading children for {}", new Object[] { node });
Iterator<SelectableBean<OrgType>> iterator = null;
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
node.getValue().getOid()).asc(ObjectType.F_NAME).build();
OperationResult result = new OperationResult(LOAD_ORG_UNITS);
try {
// Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
Collection<SelectorOptions<GetOperationOptions>> options = null;
Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
LOGGER.debug("Found {} units.", units.size());
List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
for (PrismObject<OrgType> unit : units) {
SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
list.add(selectable);
// if (getAvailableData().contains(selectable)){
// getAvailableData().remove(selectable);
// }
// getAvailableData().add(selectable);
}
getAvailableData().addAll(list);
// Collections.sort(list);
iterator = list.iterator();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
result.recordFatalError("Unable to load org unit", ex);
} finally {
result.computeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageOrgTree.class);
}
if (iterator == null) {
iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
}
LOGGER.debug("Finished loading children.");
return iterator;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class WorkItemDtoProvider method internalIterator.
@Override
public Iterator<? extends WorkItemDto> internalIterator(long first, long count) {
getAvailableData().clear();
Task task = getTaskManager().createTaskInstance();
OperationResult result = new OperationResult(OPERATION_LIST_ITEMS);
try {
ObjectQuery query = createQuery(first, count, result);
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(F_ASSIGNEE_REF), new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> items = getModel().searchContainers(WorkItemType.class, query, options, task, result);
for (WorkItemType item : items) {
try {
getAvailableData().add(new WorkItemDto(item));
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work item {}", e, item);
result.recordFatalError("Couldn't list work item.", e);
}
}
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work items", ex);
result.recordFatalError("Couldn't list work items.", ex);
}
if (result.isUnknown()) {
result.computeStatus();
}
return getAvailableData().iterator();
}
Aggregations