Search in sources :

Example 26 with ObjectFilter

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);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 27 with ObjectFilter

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Example 28 with ObjectFilter

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;
}
Also used : ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 29 with ObjectFilter

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);
    }
}
Also used : ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 30 with ObjectFilter

use of com.evolveum.midpoint.prism.query.ObjectFilter in project midpoint by Evolveum.

the class TestSecurityBasic method test290AutzJackRoleOwnerAssign.

@Test
public void test290AutzJackRoleOwnerAssign() throws Exception {
    final String TEST_NAME = "test290AutzJackRoleOwnerAssign";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    cleanupAutzTest(USER_JACK_OID);
    assignRole(USER_JACK_OID, ROLE_ROLE_OWNER_ASSIGN_OID);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    login(USER_JACK_USERNAME);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    assertReadAllow(NUMBER_OF_ALL_USERS + 1);
    assertAddDeny();
    assertModifyDeny();
    assertDeleteDeny();
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    assertAssignments(user, 2);
    assertAssignedRole(user, ROLE_ROLE_OWNER_ASSIGN_OID);
    assertAllow("assign application role 1 to jack", (task, result) -> assignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result));
    user = getUser(USER_JACK_OID);
    assertAssignments(user, 3);
    assertAssignedRole(user, ROLE_APPLICATION_1_OID);
    assertDeny("assign application role 2 to jack", new Attempt() {

        @Override
        public void run(Task task, OperationResult result) throws Exception {
            assignRole(USER_JACK_OID, ROLE_APPLICATION_2_OID, task, result);
        }
    });
    assertAllow("unassign application role 1 from jack", (task, result) -> unassignRole(USER_JACK_OID, ROLE_APPLICATION_1_OID, task, result));
    user = getUser(USER_JACK_OID);
    assertAssignments(user, 2);
    RoleSelectionSpecification spec = getAssignableRoleSpecification(getUser(USER_JACK_OID));
    assertRoleTypes(spec);
    assertFilter(spec.getFilter(), TypeFilter.class);
    assertEquals("Wrong type filter type", RoleType.COMPLEX_TYPE, ((TypeFilter) spec.getFilter()).getType());
    ObjectFilter subfilter = ((TypeFilter) spec.getFilter()).getFilter();
    assertFilter(subfilter, RefFilter.class);
    assertEquals(1, ((RefFilter) subfilter).getValues().size());
    assertEquals("Wrong OID in ref filter", USER_JACK_OID, ((RefFilter) subfilter).getValues().get(0).getOid());
    assertGlobalStateUntouched();
}
Also used : RefFilter(com.evolveum.midpoint.prism.query.RefFilter) Task(com.evolveum.midpoint.task.api.Task) RoleSelectionSpecification(com.evolveum.midpoint.model.api.RoleSelectionSpecification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TypeFilter(com.evolveum.midpoint.prism.query.TypeFilter) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) Test(org.testng.annotations.Test)

Aggregations

ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)64 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)30 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)25 Task (com.evolveum.midpoint.task.api.Task)21 ArrayList (java.util.ArrayList)14 Test (org.testng.annotations.Test)13 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)12 QName (javax.xml.namespace.QName)12 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)9 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)8 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)8 NoneFilter (com.evolveum.midpoint.prism.query.NoneFilter)7 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)7 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 PrismContext (com.evolveum.midpoint.prism.PrismContext)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5