use of com.evolveum.midpoint.prism.query.ObjectOrdering in project midpoint by Evolveum.
the class SearchingUtils method createObjectOrderings.
@NotNull
public static List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam, boolean isWorkItem) {
if (sortParam == null || sortParam.getProperty() == null) {
return Collections.emptyList();
}
String propertyName = sortParam.getProperty();
ItemPath casePath = isWorkItem ? new ItemPath(T_PARENT) : ItemPath.EMPTY_PATH;
ItemPath campaignPath = casePath.subPath(T_PARENT);
ItemPath primaryItemPath;
if (TARGET_NAME.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_TARGET_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (OBJECT_NAME.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_OBJECT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (TENANT_NAME.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_TENANT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (ORG_NAME.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_ORG_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (CURRENT_REVIEW_DEADLINE.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_CURRENT_STAGE_DEADLINE);
} else if (CURRENT_REVIEW_REQUESTED_TIMESTAMP.equals(propertyName)) {
primaryItemPath = casePath.subPath(AccessCertificationCaseType.F_CURRENT_STAGE_CREATE_TIMESTAMP);
} else if (CAMPAIGN_NAME.equals(propertyName)) {
primaryItemPath = campaignPath.subPath(ObjectType.F_NAME);
} else {
primaryItemPath = new ItemPath(new QName(SchemaConstantsGenerated.NS_COMMON, propertyName));
}
List<ObjectOrdering> rv = new ArrayList<>();
rv.add(ObjectOrdering.createOrdering(primaryItemPath, sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING));
// additional criteria are used to avoid random shuffling if first criteria is too vague)
// campaign OID
rv.add(ObjectOrdering.createOrdering(campaignPath.subPath(PrismConstants.T_ID), OrderDirection.ASCENDING));
// case ID
rv.add(ObjectOrdering.createOrdering(casePath.subPath(PrismConstants.T_ID), OrderDirection.ASCENDING));
if (isWorkItem) {
// work item ID
rv.add(ObjectOrdering.createOrdering(new ItemPath(PrismConstants.T_ID), OrderDirection.ASCENDING));
}
return rv;
}
use of com.evolveum.midpoint.prism.query.ObjectOrdering in project midpoint by Evolveum.
the class SearchingUtils method createObjectOrderings.
@NotNull
public static List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam, boolean isWorkItem, PrismContext prismContext) {
if (sortParam == null || sortParam.getProperty() == null) {
return Collections.emptyList();
}
String propertyName = sortParam.getProperty();
ItemPath casePath = isWorkItem ? ItemName.fromQName(T_PARENT) : ItemPath.EMPTY_PATH;
ItemPath campaignPath = casePath.append(T_PARENT);
ItemPath primaryItemPath;
if (TARGET_NAME.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_TARGET_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (OBJECT_NAME.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_OBJECT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (TENANT_NAME.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_TENANT_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (ORG_NAME.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_ORG_REF, PrismConstants.T_OBJECT_REFERENCE, ObjectType.F_NAME);
} else if (CURRENT_REVIEW_DEADLINE.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_CURRENT_STAGE_DEADLINE);
} else if (CURRENT_REVIEW_REQUESTED_TIMESTAMP.equals(propertyName)) {
primaryItemPath = casePath.append(AccessCertificationCaseType.F_CURRENT_STAGE_CREATE_TIMESTAMP);
} else if (CAMPAIGN_NAME.equals(propertyName)) {
primaryItemPath = campaignPath.append(ObjectType.F_NAME);
} else {
primaryItemPath = new ItemName(SchemaConstantsGenerated.NS_COMMON, propertyName);
}
List<ObjectOrdering> rv = new ArrayList<>();
rv.add(prismContext.queryFactory().createOrdering(primaryItemPath, sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING));
// additional criteria are used to avoid random shuffling if first criteria is too vague)
// campaign OID
rv.add(prismContext.queryFactory().createOrdering(campaignPath.append(PrismConstants.T_ID), OrderDirection.ASCENDING));
// case ID
rv.add(prismContext.queryFactory().createOrdering(casePath.append(PrismConstants.T_ID), OrderDirection.ASCENDING));
if (isWorkItem) {
// work item ID
rv.add(prismContext.queryFactory().createOrdering(ItemName.fromQName(PrismConstants.T_ID), OrderDirection.ASCENDING));
}
return rv;
}
use of com.evolveum.midpoint.prism.query.ObjectOrdering in project midpoint by Evolveum.
the class BaseSortableDataProvider method createPaging.
protected ObjectPaging createPaging(long offset, long pageSize) {
Integer o = safeLongToInteger(offset);
Integer size = safeLongToInteger(pageSize);
List<ObjectOrdering> orderings = null;
if (!isOrderingDisabled()) {
orderings = createObjectOrderings(getSort());
}
return getPrismContext().queryFactory().createPaging(o, size, orderings);
}
use of com.evolveum.midpoint.prism.query.ObjectOrdering in project midpoint by Evolveum.
the class TaskErrorsTabPanel method initLayoutNew.
private void initLayoutNew() {
var provider = new SelectableBeanContainerDataProvider<OperationExecutionType>(this, Model.of(), null, true) {
@Override
protected String getDefaultSortParam() {
return TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP;
}
@Override
protected SortOrder getDefaultSortOrder() {
return SortOrder.DESCENDING;
}
@Override
public SelectableBean<OperationExecutionType> createDataObjectWrapper(OperationExecutionType obj) {
return new TaskErrorSelectableBeanImpl(obj);
}
@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(TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP)) {
ordering = ItemPath.create(OperationExecutionType.F_TIMESTAMP);
} else if (sortParam.getProperty().equals("name")) {
// TODO why is this "name" and not TaskErrorSelectableBeanImpl.F_OBJECT_REF_NAME?
ordering = ItemPath.create(PrismConstants.T_PARENT, ObjectType.F_NAME);
} else {
// TODO this is actually not used
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<OperationExecutionType> getType() {
return OperationExecutionType.class;
}
};
BoxedTablePanel<?> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumns());
table.setOutputMarkupId(true);
add(table);
}
use of com.evolveum.midpoint.prism.query.ObjectOrdering in project midpoint by Evolveum.
the class TaskErrorsPanel method initLayoutNew.
private void initLayoutNew() {
var provider = new SelectableBeanContainerDataProvider<OperationExecutionType>(this, Model.of(), null, true) {
@Override
protected String getDefaultSortParam() {
return TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP;
}
@Override
protected SortOrder getDefaultSortOrder() {
return SortOrder.DESCENDING;
}
@Override
public SelectableBean<OperationExecutionType> createDataObjectWrapper(OperationExecutionType obj) {
return new TaskErrorSelectableBeanImpl(obj);
}
@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(TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP)) {
ordering = ItemPath.create(OperationExecutionType.F_TIMESTAMP);
} else if (sortParam.getProperty().equals("name")) {
// TODO why is this "name" and not TaskErrorSelectableBeanImplNew.F_OBJECT_REF_NAME?
ordering = ItemPath.create(PrismConstants.T_PARENT, ObjectType.F_NAME);
} else {
// TODO this is actually not used
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<OperationExecutionType> getType() {
return OperationExecutionType.class;
}
};
BoxedTablePanel<?> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsNew());
table.setOutputMarkupId(true);
add(table);
}
Aggregations