use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method initMemberTable.
private void initMemberTable(TableId tableId, Form form) {
WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
memberContainer.setOutputMarkupId(true);
memberContainer.setOutputMarkupPlaceholderTag(true);
form.add(memberContainer);
MainObjectListPanel<ObjectType> childrenListPanel = new MainObjectListPanel<ObjectType>(ID_MEMBER_TABLE, ObjectType.class, tableId, getSearchOptions(), getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
detailsPerformed(target, object);
}
@Override
protected boolean isClickable(IModel<SelectableBean<ObjectType>> rowModel) {
if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
return false;
}
Class<?> objectClass = rowModel.getObject().getValue().getClass();
return WebComponentUtil.hasDetailsPage(objectClass);
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target) {
AbstractRoleMemberPanel.this.createFocusMemberPerformed(null, target);
}
@Override
protected List<IColumn<SelectableBean<ObjectType>, String>> createColumns() {
return createMembersColumns();
}
@Override
protected IColumn<SelectableBean<ObjectType>, String> createActionsColumn() {
return new InlineMenuHeaderColumn(createMembersHeaderInlineMenu());
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return new ArrayList<>();
}
@Override
protected ObjectQuery createContentQuery() {
ObjectQuery q = super.createContentQuery();
ObjectQuery members = AbstractRoleMemberPanel.this.createContentQuery();
List<ObjectFilter> filters = new ArrayList<>();
if (q != null && q.getFilter() != null) {
filters.add(q.getFilter());
}
if (members != null && members.getFilter() != null) {
filters.add(members.getFilter());
}
if (filters.size() == 1) {
return ObjectQuery.createObjectQuery(filters.iterator().next());
}
return ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class PageUsers method mergePerformed.
private void mergePerformed(AjaxRequestTarget target, final UserType selectedUser) {
List<QName> supportedTypes = new ArrayList<>();
supportedTypes.add(UserType.COMPLEX_TYPE);
ObjectFilter filter = InOidFilter.createInOid(selectedUser.getOid());
ObjectFilter notFilter = NotFilter.createNot(filter);
ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(getMainPopupBodyId(), UserType.class, supportedTypes, false, PageUsers.this, notFilter) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
hideMainPopup(target);
mergeConfirmedPerformed(selectedUser, user, target);
}
};
panel.setOutputMarkupId(true);
showMainPopup(panel, target);
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class AccCertQueryHelper method searchOpenWorkItems.
// public because of testing
// principal == null => take all work items
public List<AccessCertificationWorkItemType> searchOpenWorkItems(ObjectQuery baseWorkItemsQuery, MidPointPrincipal principal, boolean notDecidedOnly, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException {
// enhance filter with reviewerRef + enabled
ObjectQuery newQuery;
ObjectFilter reviewerAndEnabledFilter = getReviewerAndEnabledFilterForWI(principal);
ObjectFilter filterToAdd;
if (notDecidedOnly) {
ObjectFilter noResponseFilter = QueryBuilder.queryFor(AccessCertificationWorkItemType.class, prismContext).item(F_OUTPUT, F_OUTCOME).isNull().buildFilter();
filterToAdd = AndFilter.createAnd(reviewerAndEnabledFilter, noResponseFilter);
} else {
filterToAdd = reviewerAndEnabledFilter;
}
newQuery = replaceFilter(baseWorkItemsQuery, filterToAdd);
// retrieve cases, filtered
List<AccessCertificationWorkItemType> workItems = repositoryService.searchContainers(AccessCertificationWorkItemType.class, newQuery, options, result);
return workItems;
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class AccCertQueryHelper method getCase.
public AccessCertificationCaseType getCase(String campaignOid, long caseId, Task task, OperationResult result) throws SchemaException, SecurityViolationException {
ObjectFilter filter = AndFilter.createAnd(InOidFilter.createOwnerHasOidIn(campaignOid), InOidFilter.createInOid(String.valueOf(caseId)));
ObjectQuery query = ObjectQuery.createObjectQuery(filter);
List<AccessCertificationCaseType> caseList = repositoryService.searchContainers(AccessCertificationCaseType.class, query, null, result);
if (caseList.isEmpty()) {
return null;
} else if (caseList.size() == 1) {
return caseList.get(0);
} else {
throw new IllegalStateException("More than one certification case with ID " + caseId + " in campaign " + campaignOid);
}
}
use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.
the class SearchEvaluator method evaluate.
public <T extends ObjectType> PipelineData evaluate(SearchExpressionType searchExpression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
Validate.notNull(searchExpression.getType());
boolean noFetch = expressionHelper.getArgumentAsBoolean(searchExpression.getParameter(), PARAM_NO_FETCH, input, context, false, "search", globalResult);
@SuppressWarnings({ "unchecked", "raw" }) Class<T> objectClass = (Class<T>) ObjectTypes.getObjectTypeFromTypeQName(searchExpression.getType()).getClassDefinition();
ObjectQuery objectQuery = null;
if (searchExpression.getQuery() != null) {
try {
objectQuery = QueryJaxbConvertor.createObjectQuery(objectClass, searchExpression.getQuery(), prismContext);
} catch (SchemaException e) {
throw new ScriptExecutionException("Couldn't parse object query due to schema exception", e);
}
} else if (searchExpression.getSearchFilter() != null) {
// todo resolve variable references in the filter
objectQuery = new ObjectQuery();
try {
ObjectFilter filter = QueryConvertor.parseFilter(searchExpression.getSearchFilter(), objectClass, prismContext);
objectQuery.setFilter(filter);
} catch (SchemaException e) {
throw new ScriptExecutionException("Couldn't parse object filter due to schema exception", e);
}
}
final String variableName = searchExpression.getVariable();
final PipelineData oldVariableValue = variableName != null ? context.getVariable(variableName) : null;
final PipelineData outputData = PipelineData.createEmpty();
final MutableBoolean atLeastOne = new MutableBoolean(false);
ResultHandler<T> handler = (object, parentResult) -> {
context.checkTaskStop();
atLeastOne.setValue(true);
if (searchExpression.getScriptingExpression() != null) {
if (variableName != null) {
context.setVariable(variableName, PipelineData.create(object.getValue()));
}
JAXBElement<?> childExpression = searchExpression.getScriptingExpression();
try {
outputData.addAllFrom(scriptingExpressionEvaluator.evaluateExpression((ScriptingExpressionType) childExpression.getValue(), PipelineData.create(object.getValue()), context, globalResult));
globalResult.setSummarizeSuccesses(true);
globalResult.summarize();
} catch (ScriptExecutionException e) {
// todo think about this
if (context.isContinueOnAnyError()) {
LoggingUtils.logUnexpectedException(LOGGER, "Exception when evaluating item from search result list.", e);
} else {
throw new SystemException(e);
}
}
} else {
outputData.addValue(object.getValue());
}
return true;
};
try {
Collection<SelectorOptions<GetOperationOptions>> options = operationsHelper.createGetOptions(searchExpression.getOptions(), noFetch);
modelService.searchObjectsIterative(objectClass, objectQuery, handler, options, context.getTask(), globalResult);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
// TODO continue on any error?
throw new ScriptExecutionException("Couldn't execute searchObjects operation: " + e.getMessage(), e);
}
if (atLeastOne.isFalse()) {
String matching = objectQuery != null ? "matching " : "";
// temporary hack, this will be configurable
context.println("Warning: no " + matching + searchExpression.getType().getLocalPart() + " object found");
}
if (variableName != null) {
context.setVariable(variableName, oldVariableValue);
}
return outputData;
}
Aggregations