Search in sources :

Example 1 with ObjectOrdering

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;
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ObjectOrdering

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;
}
Also used : ArrayList(java.util.ArrayList) ItemName(com.evolveum.midpoint.prism.path.ItemName) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ObjectOrdering

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);
}
Also used : WebComponentUtil.safeLongToInteger(com.evolveum.midpoint.gui.api.util.WebComponentUtil.safeLongToInteger) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering)

Example 4 with ObjectOrdering

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);
}
Also used : QName(javax.xml.namespace.QName) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) TaskErrorSelectableBeanImpl(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl) OperationExecutionType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationExecutionType) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 5 with ObjectOrdering

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);
}
Also used : QName(javax.xml.namespace.QName) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) TaskErrorSelectableBeanImpl(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 QName (javax.xml.namespace.QName)7 OrderDirection (com.evolveum.midpoint.prism.query.OrderDirection)6 SortParam (org.apache.wicket.extensions.markup.html.repeater.util.SortParam)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)4 SelectableBeanContainerDataProvider (com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 SelectableBeanObjectDataProvider (com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider)2 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)2 TaskErrorSelectableBeanImpl (com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl)2 TaskErrorSelectableBeanImplOld (com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImplOld)2 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 CsvDownloadButtonPanel (com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel)1 WebComponentUtil.safeLongToInteger (com.evolveum.midpoint.gui.api.util.WebComponentUtil.safeLongToInteger)1