Search in sources :

Example 31 with CompiledObjectCollectionView

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

the class DefaultGuiConfigurationCompiler method mergeCollectionViewsWithDefault.

private void mergeCollectionViewsWithDefault(CompiledGuiProfile compiledGuiProfile) {
    Collection<Class<?>> classes = collectCollectionClasses();
    List<CompiledObjectCollectionView> defaultCollectionViews = compileDefaultCollectionViews(classes);
    for (CompiledObjectCollectionView defaultCollectionView : defaultCollectionViews) {
        CompiledObjectCollectionView compiledObjectCollectionView = compiledGuiProfile.findObjectCollectionView(defaultCollectionView.getContainerType(), defaultCollectionView.getViewIdentifier());
        if (compiledObjectCollectionView == null) {
            compiledGuiProfile.getObjectCollectionViews().add(defaultCollectionView);
            continue;
        }
        mergeCollectionViews(compiledObjectCollectionView, defaultCollectionView);
    }
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)

Example 32 with CompiledObjectCollectionView

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

the class SearchFactory method getSearchBoxConfiguration.

private static SearchBoxConfigurationType getSearchBoxConfiguration(ModelServiceLocator modelServiceLocator, QName type, String collectionViewName, Search.PanelType panelType) {
    OperationResult result = new OperationResult(LOAD_ADMIN_GUI_CONFIGURATION);
    try {
        CompiledGuiProfile guiConfig = modelServiceLocator.getModelInteractionService().getCompiledGuiProfile(null, result);
        CompiledObjectCollectionView view = guiConfig.findObjectCollectionView(type, collectionViewName);
        if (view != null) {
            if (Search.PanelType.MEMBER_PANEL.equals(panelType) && view.getAdditionalPanels() != null && view.getAdditionalPanels().getMemberPanel() != null) {
                return view.getAdditionalPanels().getMemberPanel().getSearchBoxConfiguration();
            }
            return view.getSearchBoxConfiguration();
        }
        return null;
    } catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException ex) {
        throw new SystemException(ex);
    }
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Example 33 with CompiledObjectCollectionView

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

the class ContainerableListPanel method compileWidgetCollectionView.

private CompiledObjectCollectionView compileWidgetCollectionView(DashboardWidgetType widget, Task task) {
    CollectionRefSpecificationType collectionSpec = widget.getData().getCollection();
    try {
        @NotNull CompiledObjectCollectionView compiledView = getPageBase().getModelInteractionService().compileObjectCollectionView(collectionSpec, null, task, task.getResult());
        if (widget.getPresentation() != null && widget.getPresentation().getView() != null) {
            getPageBase().getModelInteractionService().applyView(compiledView, widget.getPresentation().getView());
        }
        compiledView.setCollection(collectionSpec);
        return compiledView;
    } catch (SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | ObjectNotFoundException e) {
        LOGGER.error("Couldn't compile collection " + collectionSpec, e);
        return null;
    }
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull)

Example 34 with CompiledObjectCollectionView

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

the class PageAssignmentHolderDetails method createTemplatePanel.

private CreateTemplatePanel<AH> createTemplatePanel() {
    return new CreateTemplatePanel<>(ID_TEMPLATE) {

        @Override
        protected Collection<CompiledObjectCollectionView> findAllApplicableArchetypeViews() {
            return PageAssignmentHolderDetails.this.findAllApplicableArchetypeViews();
        }

        @Override
        protected QName getType() {
            return ObjectTypes.getObjectType(PageAssignmentHolderDetails.this.getType()).getTypeQName();
        }

        @Override
        protected void onTemplateChosePerformed(CompiledObjectCollectionView collectionViews, AjaxRequestTarget target) {
            PrismObject<AH> assignmentHolder;
            try {
                assignmentHolder = getPrismContext().createObject(PageAssignmentHolderDetails.this.getType());
            } catch (Throwable e) {
                LOGGER.error("Cannot create prism object for {}. Using object from page model.", PageAssignmentHolderDetails.this.getType());
                assignmentHolder = getObjectDetailsModels().getObjectWrapperModel().getObject().getObjectOld().clone();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionViews);
            if (archetypeRef != null) {
                AssignmentHolderType holder = assignmentHolder.asObjectable();
                archetypeRef.forEach(a -> holder.getAssignment().add(ObjectTypeUtil.createAssignmentTo(a, getPrismContext())));
            }
            reloadObjectDetailsModel(assignmentHolder);
            Fragment fragment = createDetailsFragment();
            fragment.setOutputMarkupId(true);
            PageAssignmentHolderDetails.this.replace(fragment);
            target.add(fragment);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CreateTemplatePanel(com.evolveum.midpoint.gui.impl.page.admin.CreateTemplatePanel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Example 35 with CompiledObjectCollectionView

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

the class ResourceTasksPanel method initLayout.

protected void initLayout() {
    final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<>(ID_TASKS_TABLE, TaskType.class, null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_RESOURCE_TASKS_PANEL;
        }

        @Override
        protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> createResourceTasksQuery(), null);
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return null;
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) {
            if (collectionView == null) {
                collectionView = getObjectCollectionView();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionView);
            try {
                PrismContext prismContext = getPrismContext();
                PrismObjectDefinition<TaskType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(TaskType.COMPLEX_TYPE);
                PrismObject<TaskType> obj = def.instantiate();
                TaskType newTask = obj.asObjectable();
                ObjectReferenceType resourceRef = new ObjectReferenceType();
                resourceRef.setOid(ResourceTasksPanel.this.getObjectWrapper().getOid());
                resourceRef.setType(ResourceType.COMPLEX_TYPE);
                newTask.setObjectRef(resourceRef);
                WebComponentUtil.initNewObjectWithReference(getPageBase(), newTask, archetypeRef);
            } catch (SchemaException ex) {
                getPageBase().getFeedbackMessages().error(ResourceTasksPanel.this, ex.getUserFriendlyMessage());
                target.add(getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
            return ColumnUtils.getDefaultTaskColumns();
        }

        @Override
        protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
            List<CompiledObjectCollectionView> newObjectInfluencesList = super.getNewObjectInfluencesList();
            List<CompiledObjectCollectionView> filteredInfluencesList = new ArrayList<>();
            if (newObjectInfluencesList != null) {
                newObjectInfluencesList.forEach(influence -> {
                    if (influence.getCollection() != null && influence.getCollection().getCollectionRef() != null && ArrayUtils.contains(resourceTaskArchetypeOids, influence.getCollection().getCollectionRef().getOid())) {
                        filteredInfluencesList.add(influence);
                    }
                });
            }
            return filteredInfluencesList;
        }
    };
    tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
    add(tasksPanel);
    AjaxButton runNow = new AjaxButton(ID_RUN_NOW, getPageBase().createStringResource("pageTaskEdit.button.runNow")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedRealObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.runNowPerformed(oids, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(runNow);
    AjaxButton resume = new AjaxButton(ID_RESUME, getPageBase().createStringResource("pageTaskEdit.button.resume")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.resumeTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(resume);
    AjaxButton suspend = new AjaxButton(ID_SUSPEND, getPageBase().createStringResource("pageTaskEdit.button.suspend")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.suspendTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(suspend);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) PrismContext(com.evolveum.midpoint.prism.PrismContext) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) 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)

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