use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.
the class PageAuthenticationBase method createDynamicFormQuery.
protected ObjectQuery createDynamicFormQuery() {
DynamicFormPanel<UserType> userDynamicPanel = getDynamicForm();
List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
PrismObject<UserType> user;
try {
user = userDynamicPanel.getObject();
} catch (SchemaException e1) {
getSession().error(getString("pageForgetPassword.message.usernotfound"));
throw new RestartResponseException(PageForgotPassword.class);
}
List<EqualFilter> filters = new ArrayList<>();
QueryFactory queryFactory = getPrismContext().queryFactory();
for (ItemPath path : filledItems) {
PrismProperty<?> property = user.findProperty(path);
EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
filter.setValue(property.getAnyValue().clone());
filters.add(filter);
}
return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.
the class PageForgotPassword method createDynamicFormQuery.
private ObjectQuery createDynamicFormQuery(Form form) {
DynamicFormPanel<UserType> userDynamicPanel = (DynamicFormPanel<UserType>) form.get(createComponentPath(ID_DYNAMIC_LAYOUT, ID_DYNAMIC_FORM));
List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
PrismObject<UserType> user;
try {
user = userDynamicPanel.getObject();
} catch (SchemaException e1) {
getSession().error(getString("pageForgetPassword.message.usernotfound"));
throw new RestartResponseException(PageForgotPassword.class);
}
List<EqualFilter> filters = new ArrayList<>();
QueryFactory queryFactory = getPrismContext().queryFactory();
for (ItemPath path : filledItems) {
PrismProperty<?> property = user.findProperty(path);
EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
filter.setValue(property.getAnyValue().clone());
filters.add(filter);
}
return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.
the class FocusPersonasTabPanel method loadModel.
private LoadableModel<List<PrismObject<FocusType>>> loadModel() {
return new LoadableModel<List<PrismObject<FocusType>>>(false) {
@Override
protected List<PrismObject<FocusType>> load() {
List<String> personaOidsList = getPersonasOidsList();
List<PrismObject<FocusType>> personasList = new ArrayList<>();
if (personaOidsList.size() > 0) {
QueryFactory factory = getPrismContext().queryFactory();
ObjectQuery query = factory.createQuery(factory.createInOid(personaOidsList));
OperationResult result = new OperationResult(OPERATION_SEARCH_PERSONAS_OBJECTS);
personasList = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
}
return personasList;
}
};
}
use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.
the class CompleteQuery method or.
/**
* Composes complete queries into single "OR" query. Requires compatible paging and options.
* (Currently no paging nor options is allowed.)
*/
@NotNull
public static CompleteQuery<?> or(List<CompleteQuery<?>> completeQueries, PrismContext prismContext) {
QueryFactory queryFactory = prismContext.queryFactory();
Class<? extends ObjectType> commonType = getCommonAncestor(completeQueries);
List<ObjectFilter> disjuncts = new ArrayList<>();
for (CompleteQuery<?> completeQuery : completeQueries) {
if (CollectionUtils.isNotEmpty(completeQuery.options)) {
throw new UnsupportedOperationException("Query options are not supported here: " + completeQuery.options);
}
ObjectQuery query = completeQuery.query;
if (query != null && query.getPaging() != null) {
throw new UnsupportedOperationException("Query paging is not supported here: " + query.getPaging());
}
ObjectFilter filter = query != null ? query.getFilter() : null;
Class<?> type = completeQuery.type;
if (type.equals(commonType)) {
if (filter != null) {
disjuncts.add(filter);
}
} else {
QName typeName = prismContext.getSchemaRegistry().determineTypeForClassRequired(type);
disjuncts.add(queryFactory.createType(typeName, filter));
}
}
ObjectQuery orQuery = queryFactory.createQuery(queryFactory.createOrOptimized(disjuncts));
return new CompleteQuery<>(commonType, orQuery, null);
}
use of com.evolveum.midpoint.prism.query.QueryFactory in project midpoint by Evolveum.
the class DeleteRepositoryAction method deleteByOid.
private void deleteByOid() throws SchemaException {
QueryFactory queryFactory = context.getPrismContext().queryFactory();
InOidFilter filter = queryFactory.createInOid(options.getOid());
ObjectQuery query = queryFactory.createQuery(filter);
deleteByFilter(query);
}
Aggregations