use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.
the class ReportObjectsListPanel method createProvider.
@Override
protected ISelectableDataProvider<C, SelectableBean<C>> createProvider() {
SelectableBeanContainerDataProvider<C> provider = new SelectableBeanContainerDataProvider<>(this, getSearchModel(), null, false) {
@Override
public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
VariablesMap variables = new VariablesMap();
if (getSearchModel().getObject() != null) {
variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
processReferenceVariables(variables);
}
List<C> list = (List<C>) getModelInteractionService().searchObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, query.getPaging(), variables, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
}
List<SelectableBean<C>> data = new ArrayList<SelectableBean<C>>();
for (C object : list) {
data.add(createDataObjectWrapper(object));
}
return data;
}
@Override
protected Integer countObjects(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
VariablesMap variables = new VariablesMap();
if (getSearchModel().getObject() != null) {
variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
processReferenceVariables(variables);
}
return getModelInteractionService().countObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, null, variables, task, result);
}
@Override
protected boolean isUseObjectCounting() {
return !isDisableCounting();
}
@Override
public boolean isOrderingDisabled() {
return isDisableSorting();
}
@Override
public ObjectQuery getQuery() {
// fake query because of we need paging in method createDataObjectWrappers
return getPrismContext().queryFor(ObjectType.class).build();
}
@Override
@NotNull
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
if (AuditEventRecordType.class.equals(getDefaultType()) && sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
}
return super.createObjectOrderings(sortParam);
}
};
if (provider.getSort() == null && hasView()) {
if (ObjectType.class.isAssignableFrom(getDefaultType())) {
provider.setSort("name", SortOrder.ASCENDING);
} else if (AuditEventRecordType.class.isAssignableFrom(getDefaultType())) {
provider.setSort("timestamp", SortOrder.ASCENDING);
}
}
return provider;
}
use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.
the class TaskErrorsPanel method initLayoutOld.
private void initLayoutOld() {
SelectableBeanObjectDataProvider<? extends ObjectType> provider = new SelectableBeanObjectDataProvider<>(this, null) {
@Override
protected String getDefaultSortParam() {
return TaskErrorSelectableBeanImplOld.F_ERROR_TIMESTAMP;
}
@Override
protected SortOrder getDefaultSortOrder() {
return SortOrder.DESCENDING;
}
@Override
public SelectableBean<ObjectType> createDataObjectWrapper(ObjectType obj) {
return new TaskErrorSelectableBeanImplOld<>(obj, getObjectWrapper().getOid());
}
@Override
public ObjectQuery getQuery() {
return createContentQuery(getObjectWrapper().getOid(), getPageBase());
}
@NotNull
@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
if (sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
ItemPath ordering;
if (sortParam.getProperty().equals(TaskErrorSelectableBeanImplOld.F_ERROR_TIMESTAMP)) {
ordering = ItemPath.create("operationExecution", "timestamp");
} else {
ordering = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
}
return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ordering, order));
} else {
return Collections.emptyList();
}
}
@Override
public Class<ObjectType> getType() {
return ObjectType.class;
}
};
BoxedTablePanel<TaskErrorSelectableBeanImplOld<ObjectType>> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsOld());
table.setOutputMarkupId(true);
add(table);
}
use of org.apache.wicket.extensions.markup.html.repeater.util.SortParam in project midpoint by Evolveum.
the class TaskErrorsTabPanel method initLayoutOld.
private void initLayoutOld() {
SelectableBeanObjectDataProvider<? extends ObjectType> provider = new SelectableBeanObjectDataProvider<>(this, null) {
@Override
public SelectableBean<ObjectType> createDataObjectWrapper(ObjectType obj) {
return new TaskErrorSelectableBeanImplOld<>(obj, getModelObject().getOid());
}
@Override
public ObjectQuery getQuery() {
return createContentQuery(getModelObject().getOid(), getPageBase());
}
@NotNull
@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
if (sortParam != null && sortParam.getProperty() != null) {
OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
ItemPath ordering;
if (sortParam.getProperty().equals(TaskErrorSelectableBeanImplOld.F_ERROR_TIMESTAMP)) {
ordering = ItemPath.create("operationExecution", "timestamp");
} else {
ordering = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
}
return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ordering, order));
} else {
return Collections.emptyList();
}
}
@Override
public Class<ObjectType> getType() {
return ObjectType.class;
}
};
BoxedTablePanel<TaskErrorSelectableBeanImplOld<ObjectType>> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsOld());
table.setOutputMarkupId(true);
add(table);
}
Aggregations