Search in sources :

Example 36 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class PageSystemConfiguration method initLayout.

private void initLayout() {
    IModel<List<CompositedIconButtonDto>> model = Model.ofList(Arrays.asList(createCompositedButton("fa fa-wrench", PageSystemBasic.class), createCompositedButton("fa fa-camera", PageSystemPolicies.class), createCompositedButton("fa fa-envelope", PageSystemNotification.class), createCompositedButton("fa fa-file-text", PageSystemLogging.class), createCompositedButton("fa fa-camera", PageProfiling.class), createCompositedButton("fa fa-camera", PageSystemAdminGui.class), createCompositedButton("fa fa-camera", PageSystemWorkflow.class), createCompositedButton("fa fa-camera", PageRoleManagement.class), createCompositedButton("fa fa-camera", PageSystemInternals.class), createCompositedButton("fa fa-camera", PageAccessCertification.class)));
    MultiCompositedButtonPanel panel = new MultiCompositedButtonPanel(ID_CONTAINER, model) {

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            navigateToNext(page);
        }
    };
    panel.add(AttributeModifier.append("class", " row"));
    add(panel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebPage(org.apache.wicket.markup.html.WebPage) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) List(java.util.List) MultiCompositedButtonPanel(com.evolveum.midpoint.web.component.MultiCompositedButtonPanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Example 37 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class CollectionProcessor method evaluateCollectionPolicyRules.

Collection<EvaluatedPolicyRule> evaluateCollectionPolicyRules(PrismObject<ObjectCollectionType> collection, CompiledObjectCollectionView collectionView, Class<? extends ObjectType> targetTypeClass, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    if (collectionView == null) {
        collectionView = new CompiledObjectCollectionView();
        compileObjectCollectionView(collectionView, null, collection.asObjectable(), targetTypeClass, task, result);
    }
    Collection<EvaluatedPolicyRule> evaluatedPolicyRules = new ArrayList<>();
    for (AssignmentType assignmentType : collection.asObjectable().getAssignment()) {
        PolicyRuleType policyRuleType = assignmentType.getPolicyRule();
        if (policyRuleType == null) {
            continue;
        }
        evaluatedPolicyRules.add(evaluatePolicyRule(collection, collectionView, assignmentType, policyRuleType, task, result));
    }
    return evaluatedPolicyRules;
}
Also used : EvaluatedPolicyRule(com.evolveum.midpoint.model.api.context.EvaluatedPolicyRule) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ArrayList(java.util.ArrayList)

Example 38 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class CollectionProcessor method compileObjectCollectionView.

private void compileObjectCollectionView(CompiledObjectCollectionView existingView, CollectionRefSpecificationType baseCollectionSpec, @NotNull ObjectCollectionType objectCollectionType, Class<? extends Containerable> targetTypeClass, Task task, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, ObjectNotFoundException {
    if (targetTypeClass == null) {
        if (existingView.getContainerType() == null) {
            QName targetTypeQName = objectCollectionType.getType();
            if (targetTypeQName == null) {
                throw new SchemaException("Target container type not specified in " + objectCollectionType);
            }
            targetTypeClass = ObjectTypes.getObjectTypeClassIfKnown(targetTypeQName);
            if (targetTypeClass == null) {
                PrismContainerDefinition<Containerable> def = prismContext.getSchemaRegistry().findContainerDefinitionByType(targetTypeQName);
                if (def == null) {
                    throw new IllegalArgumentException("Unsupported container type " + targetTypeQName);
                }
                targetTypeClass = def.getTypeClass();
            }
            existingView.setContainerType(targetTypeQName);
        } else {
            QName targetTypeQName = existingView.getContainerType();
            targetTypeClass = ObjectTypes.getObjectTypeClass(targetTypeQName);
        }
    }
    // Used for help text in search panel
    if (objectCollectionType.getDescription() != null) {
        existingView.setObjectCollectionDescription(objectCollectionType.getDescription());
    }
    // hierarchy. It makes no sense to compile all domain specs from the entire hierarchy just to throw that out.
    if (!existingView.hasDomain()) {
        CollectionRefSpecificationType domainSpec = objectCollectionType.getDomain();
        if (domainSpec != null) {
            CompiledObjectCollectionView domainView = new CompiledObjectCollectionView();
            compileObjectCollectionView(domainView, domainSpec, targetTypeClass, task, result);
            if (domainView.getFilter() == null) {
                // We have domain specification, but compilation produced no filter. Which means that the domain is "all"
                // Explicitly set "all" filter here. We want to avoid confusion between no domain spec and "all" domain spec.
                existingView.setDomainFilter(prismContext.queryFactory().createAll());
            } else {
                existingView.setDomainFilter(domainView.getFilter());
            }
            existingView.setDomainOptions(domainView.getOptions());
        }
    }
    SearchFilterType collectionFilterType = objectCollectionType.getFilter();
    ObjectFilter collectionFilter;
    if (collectionFilterType != null) {
        collectionFilter = prismContext.getQueryConverter().parseFilter(collectionFilterType, targetTypeClass);
    } else {
        collectionFilter = null;
    }
    List<SelectorOptions<GetOperationOptions>> collectionOptions = GetOperationOptionsUtil.optionsBeanToOptions(objectCollectionType.getGetOptions());
    CollectionRefSpecificationType baseCollectionSpecFromCollection = objectCollectionType.getBaseCollection();
    if (baseCollectionSpecFromCollection == null && baseCollectionSpec == null) {
        existingView.setFilter(collectionFilter);
        existingView.setOptions(collectionOptions);
    } else {
        if (baseCollectionSpecFromCollection == null || baseCollectionSpec == null) {
            compileBaseCollectionSpec(collectionFilter, existingView, collectionOptions, baseCollectionSpec == null ? baseCollectionSpecFromCollection : baseCollectionSpec, targetTypeClass, task, result);
        } else {
            compileObjectCollectionView(existingView, baseCollectionSpecFromCollection, targetTypeClass, task, result);
            ObjectFilter baseFilterFromCollection = existingView.getFilter();
            Collection<SelectorOptions<GetOperationOptions>> baseOptionFromCollection = existingView.getOptions();
            compileObjectCollectionView(existingView, baseCollectionSpec, targetTypeClass, task, result);
            ObjectFilter baseFilter = existingView.getFilter();
            ObjectFilter combinedFilter = ObjectQueryUtil.filterAnd(baseFilterFromCollection, baseFilter, prismContext);
            combinedFilter = ObjectQueryUtil.filterAnd(combinedFilter, collectionFilter, prismContext);
            existingView.setFilter(combinedFilter);
            GetOperationOptionsBuilder optionsBuilder = schemaService.getOperationOptionsBuilder().setFrom(baseOptionFromCollection);
            optionsBuilder.mergeFrom(existingView.getOptions());
            optionsBuilder.mergeFrom(collectionOptions);
            existingView.setOptions(optionsBuilder.build());
        }
    }
    compileView(existingView, objectCollectionType.getDefaultView(), false);
}
Also used : SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 39 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class WebComponentUtil method getCollectionViewByObject.

public static CompiledObjectCollectionView getCollectionViewByObject(AssignmentHolderType assignmentHolder, PageBase pageBase) {
    String archetypeOid = getArchetypeOid(assignmentHolder);
    if (!StringUtils.isEmpty(archetypeOid)) {
        List<CompiledObjectCollectionView> collectionViews = pageBase.getCompiledGuiProfile().getObjectCollectionViews();
        for (CompiledObjectCollectionView view : collectionViews) {
            if (view.getCollection() != null && view.getCollection().getCollectionRef() != null && archetypeOid.equals(view.getCollection().getCollectionRef().getOid())) {
                return view;
            }
        }
    }
    QName type = classToQName(pageBase.getPrismContext(), assignmentHolder.getClass());
    return pageBase.getCompiledGuiProfile().findObjectCollectionView(type, null);
}
Also used : QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 40 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ChooseMemberPopup method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    Form form = new Form(ID_FORM);
    form.setOutputMarkupId(true);
    add(form);
    IModel<List<CompositedIconButtonDto>> assignButtonDescriptionModel = createAssignButtonDescriptionModel();
    MultiCompositedButtonPanel assignDescriptionButtonsPanel = new MultiCompositedButtonPanel(ID_COMPOSITED_BUTTONS, assignButtonDescriptionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            Form form = (Form) ChooseMemberPopup.this.get(ID_FORM);
            isCompositedButtonsPanelVisible = false;
            addOrReplaceTabPanels(form, relationSpec);
            target.add(form);
        }
    };
    form.add(assignDescriptionButtonsPanel);
    assignDescriptionButtonsPanel.add(new VisibleBehaviour(() -> isCompositedButtonsPanelVisible));
    addOrReplaceTabPanels(form, null);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, createStringResource("userBrowserDialog.button.cancelButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
        }
    };
    cancelButton.setOutputMarkupId(true);
    form.add(cancelButton);
    AjaxButton addButton = new AjaxButton(ID_ADD_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            boolean orgPanelProcessed = false;
            for (ITab panelTab : tabs) {
                WebMarkupContainer tabPanel = ((CountablePanelTab) panelTab).getPanel();
                if (tabPanel == null) {
                    continue;
                }
                MemberPopupTabPanel memberPanel = (MemberPopupTabPanel) tabPanel;
                if (memberPanel.getObjectType().equals(ObjectTypes.ORG) && orgPanelProcessed) {
                    continue;
                }
                List<ObjectType> selectedObjects = memberPanel.getObjectType().equals(ObjectTypes.ORG) ? memberPanel.getPreselectedObjects() : memberPanel.getSelectedObjectsList();
                if (selectedObjects == null || selectedObjects.size() == 0) {
                    continue;
                }
                executeMemberOperation(memberPanel.getAbstractRoleTypeObject(), createInOidQuery(selectedObjects), memberPanel.getRelationValue(), memberPanel.getObjectType().getTypeQName(), target, getPageBase());
                if (memberPanel.getObjectType().equals(ObjectTypes.ORG)) {
                    orgPanelProcessed = true;
                }
            }
            ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
        }
    };
    addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
    addButton.add(new EnableBehaviour(() -> isAddButtonEnabled()));
    addButton.setOutputMarkupId(true);
    form.add(addButton);
}
Also used : WebPage(org.apache.wicket.markup.html.WebPage) Form(org.apache.wicket.markup.html.form.Form) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Aggregations

CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)41 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)13 WebPage (org.apache.wicket.markup.html.WebPage)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)6 ArrayList (java.util.ArrayList)6 MultiCompositedButtonPanel (com.evolveum.midpoint.web.component.MultiCompositedButtonPanel)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 MultiFunctinalButtonDto (com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Form (org.apache.wicket.markup.html.form.Form)3