use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class ObjectBrowserPanel method createObjectListPanel.
private ObjectListPanel<O> createObjectListPanel(Class<? extends O> type, final boolean multiselect) {
PopupObjectListPanel<O> listPanel = new PopupObjectListPanel<O>(ID_TABLE, type, multiselect, parentPage, selectedObjectsList) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, O object) {
ObjectBrowserPanel.this.onSelectPerformed(target, object);
}
@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
if (queryFilter != null) {
if (query == null) {
query = new ObjectQuery();
}
query.addFilter(queryFilter);
}
return query;
}
};
listPanel.setOutputMarkupId(true);
return listPanel;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class TypedAssignablePanel method createObjectListPanel.
private PopupObjectListPanel<T> createObjectListPanel(String id, final String countId, final QName type) {
PopupObjectListPanel<T> listPanel = new PopupObjectListPanel<T>(id, qnameToCompileTimeClass(type), true, getPageBase()) {
@Override
protected void onUpdateCheckbox(AjaxRequestTarget target) {
refreshCounts(target);
}
@Override
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
if (type.equals(RoleType.COMPLEX_TYPE)) {
LOGGER.debug("Loading roles which the current user has right to assign");
OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNABLE_ROLES);
ObjectFilter filter = null;
try {
ModelInteractionService mis = parentPage.getModelInteractionService();
RoleSelectionSpecification roleSpec = mis.getAssignableRoleSpecification(SecurityUtils.getPrincipalUser().getUser().asPrismObject(), result);
filter = roleSpec.getFilter();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load available roles", ex);
result.recordFatalError("Couldn't load available roles", ex);
} finally {
result.recomputeStatus();
}
if (!result.isSuccess() && !result.isHandledError()) {
parentPage.showResult(result);
}
if (query == null) {
query = new ObjectQuery();
}
query.addFilter(filter);
}
return query;
}
};
listPanel.setOutputMarkupId(true);
listPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return type.equals(typeModel.getObject());
}
});
return listPanel;
}
use of com.evolveum.midpoint.prism.query.ObjectQuery in project midpoint by Evolveum.
the class ResourceCredentialsEditor method createPasswordPolicyList.
private List<ObjectReferenceType> createPasswordPolicyList() {
passPolicyMap.clear();
OperationResult result = new OperationResult(OPERATION_LOAD_PASSWORD_POLICIES);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_PASSWORD_POLICIES);
List<PrismObject<ValuePolicyType>> policies = null;
List<ObjectReferenceType> references = new ArrayList<>();
try {
policies = getPageBase().getModelService().searchObjects(ValuePolicyType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (CommonException | RuntimeException e) {
result.recordFatalError("Couldn't load password policies.", e);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load password policies", e);
}
if (policies != null) {
ObjectReferenceType ref;
for (PrismObject<ValuePolicyType> policy : policies) {
passPolicyMap.put(policy.getOid(), WebComponentUtil.getName(policy));
ref = new ObjectReferenceType();
ref.setType(ValuePolicyType.COMPLEX_TYPE);
ref.setOid(policy.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;
}
Aggregations