Search in sources :

Example 16 with PrismContainerWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.

the class PageAdminObjectDetails method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getMainPopupBodyId(), null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            OperationResult result = new OperationResult(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
            if (newAssignmentsList.size() > 1) {
                result.recordWarning(getString("PageAdminObjectDetails.change.archetype.more.than.one.selected"));
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            AssignmentType oldArchetypAssignment = getOldArchetypeAssignment(result);
            if (oldArchetypAssignment == null) {
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            try {
                ObjectDelta<O> delta = getPrismContext().deltaFor(getCompileTimeClass()).item(AssignmentHolderType.F_ASSIGNMENT).delete(oldArchetypAssignment.clone()).asObjectDelta(getObjectWrapper().getOid());
                delta.addModificationAddContainer(AssignmentHolderType.F_ASSIGNMENT, newAssignmentsList.iterator().next());
                Task task = createSimpleTask(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
                getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
            } catch (Exception e) {
                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage(), e);
                result.recordFatalError(getString("PageAdminObjectDetails.change.archetype.failed", e.getMessage()), e);
            }
            result.computeStatusIfUnknown();
            showResult(result);
            target.add(PageAdminObjectDetails.this.getFeedbackPanel());
            refresh(target);
        }

        @Override
        protected List<ITab> createAssignmentTabs(AssignmentObjectRelation assignmentObjectRelation) {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(getPageBase().createStringResource("ObjectTypes.ARCHETYPE"), new VisibleBehaviour(() -> true)) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new FocusTypeAssignmentPopupTabPanel<ArchetypeType>(panelId, ObjectTypes.ARCHETYPE, null) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
                            PrismContainerWrapper<AssignmentType> assignmentsWrapper = null;
                            try {
                                assignmentsWrapper = getObjectWrapper().findContainer(FocusType.F_ASSIGNMENT);
                            } catch (SchemaException e) {
                                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
                            }
                            return assignmentsWrapper;
                        }

                        @Override
                        protected List<QName> getSupportedRelations() {
                            return Collections.singletonList(SchemaConstants.ORG_DEFAULT);
                        }

                        @Override
                        protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ArchetypeType>> rowModel) {
                            target.add(getObjectListPanel());
                            tabLabelPanelUpdate(target);
                        }

                        @Override
                        protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<ArchetypeType>> rowModel) {
                            if (rowModel == null) {
                                return Model.of(false);
                            }
                            List selectedObjects = getSelectedObjectsList();
                            return Model.of(selectedObjects == null || selectedObjects.size() == 0 || (rowModel.getObject() != null && rowModel.getObject().isSelected()));
                        }

                        @Override
                        protected ObjectTypes getObjectType() {
                            return ObjectTypes.ARCHETYPE;
                        }

                        @Override
                        protected ObjectQuery addFilterToContentQuery() {
                            ObjectQuery query = super.addFilterToContentQuery();
                            if (query == null) {
                                query = getPrismContext().queryFactory().createQuery();
                            }
                            List<String> archetypeOidsList = getArchetypeOidsListToAssign();
                            ObjectFilter filter = getPrismContext().queryFor(ArchetypeType.class).id(archetypeOidsList.toArray(new String[0])).buildFilter();
                            query.addFilter(filter);
                            return query;
                        }
                    };
                }
            });
            return tabs;
        }

        @Override
        protected IModel<String> getWarningMessageModel() {
            return createStringResource("PageAdminObjectDetails.button.changeArchetype.warningMessage");
        }
    };
    changeArchetypePopup.setOutputMarkupPlaceholderTag(true);
    showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Example 17 with PrismContainerWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.

the class TaskBasicPanel method initLayout.

protected void initLayout() {
    SingleContainerPanel mainPanel = new SingleContainerPanel(ID_MAIN_PANEL, getObjectWrapperModel(), getPanelConfiguration()) {

        @Override
        protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
            return getBasicTabVisibility(itemWrapper.getPath());
        }

        @Override
        protected ItemEditabilityHandler getEditabilityHandler() {
            return wrapper -> getBasicTabEditability(wrapper.getPath());
        }

        @Override
        protected IModel<PrismContainerWrapper> createVirtualContainerModel(VirtualContainersSpecificationType virtualContainer) {
            if (isDeprecatedVirtualContainer(virtualContainer)) {
                return null;
            }
            return super.createVirtualContainerModel(virtualContainer);
        }
    };
    add(mainPanel);
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) AbstractObjectMainPanel(com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel) PanelDisplay(com.evolveum.midpoint.web.application.PanelDisplay) Arrays(java.util.Arrays) ItemEditabilityHandler(com.evolveum.midpoint.gui.api.prism.wrapper.ItemEditabilityHandler) PanelType(com.evolveum.midpoint.web.application.PanelType) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) Collection(java.util.Collection) VirtualContainersSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualContainersSpecificationType) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) ItemVisibility(com.evolveum.midpoint.web.component.prism.ItemVisibility) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) TaskDetailsModel(com.evolveum.midpoint.gui.impl.page.admin.task.TaskDetailsModel) List(java.util.List) ContainerPanelConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType) RefreshableTabPanel(com.evolveum.midpoint.web.page.admin.server.RefreshableTabPanel) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) IModel(org.apache.wicket.model.IModel) Collections(java.util.Collections) PanelInstance(com.evolveum.midpoint.web.application.PanelInstance) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel) VirtualContainersSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualContainersSpecificationType)

Example 18 with PrismContainerWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.

the class ProvenanceMetadataPanel method createMetadataDetailsPanel.

private void createMetadataDetailsPanel(ListItem<PrismContainerValueWrapper<ProvenanceMetadataType>> provenanceListItem, ListItem<PrismContainerValueWrapper<ValueMetadataType>> valueMetadataListItem) {
    WebMarkupContainer panel = createAcquisitionPanel(PrismContainerWrapperModel.fromContainerValueWrapper(provenanceListItem.getModel(), ProvenanceMetadataType.F_ACQUISITION));
    provenanceListItem.add(panel);
    ToggleIconButton<Void> showMore = createShowMoreButton(provenanceListItem.getModel());
    provenanceListItem.add(showMore);
    IModel<PrismContainerWrapper<Containerable>> detailsModel = createDetailsModel(valueMetadataListItem.getModel());
    Label label = new Label(ID_YIELD_HEADER, createDetailsDescriptionModel(detailsModel));
    provenanceListItem.add(label);
    label.add(new VisibleBehaviour(() -> provenanceListItem.getModelObject().isShowEmpty()));
    MetadataContainerPanel<Containerable> defaultPanel = createDefaultPanel(detailsModel, provenanceListItem.getModel());
    defaultPanel.add(new VisibleBehaviour(() -> !getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
    provenanceListItem.add(defaultPanel);
    ItemPanelSettings settings = getSettings().copy();
    settings.setVisibilityHandler(w -> createItemVisibilityBehavior(w));
    ValueMetadataPanel<ValueMetadataType, PrismContainerValueWrapper<ValueMetadataType>> valueMetadataPanel = new ValueMetadataPanel<>(ID_VALUE_METADATA_DETAILS, valueMetadataListItem.getModel(), settings);
    valueMetadataPanel.add(new VisibleBehaviour(() -> getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
    provenanceListItem.add(valueMetadataPanel);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) Label(org.apache.wicket.markup.html.basic.Label) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Containerable(com.evolveum.midpoint.prism.Containerable) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 19 with PrismContainerWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.

the class ConstructionAssociationPanel method getAssociationsShadowRefs.

private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName, QName name) {
    List<ObjectReferenceType> shadowsList = new ArrayList<>();
    try {
        PrismContainerWrapper associationWrapper = getModelObject().findContainer(ConstructionType.F_ASSOCIATION);
        associationWrapper.getValues().forEach(associationValueWrapper -> {
            if (ValueStatus.DELETED.equals(((PrismContainerValueWrapper) associationValueWrapper).getStatus())) {
                return;
            }
            PrismContainerValue associationValue = ((PrismContainerValueWrapper) associationValueWrapper).getNewValue();
            ResourceObjectAssociationType assoc = (ResourceObjectAssociationType) associationValue.asContainerable();
            if (assoc == null || assoc.getOutbound() == null || assoc.getOutbound().getExpression() == null || ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()) == null) {
                return;
            }
            if (compareName) {
                QName assocRef = ItemPathTypeUtil.asSingleNameOrFailNullSafe(assoc.getRef());
                if (name != null && name.equals(assocRef)) {
                    shadowsList.addAll(ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()));
                }
            } else {
                shadowsList.addAll(ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()));
            }
        });
    } catch (SchemaException ex) {
    // nothing?
    }
    return shadowsList;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 20 with PrismContainerWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.

the class TaskTabsVisibility method computeOperationVisible.

public boolean computeOperationVisible(PageTask parentPage, PrismObjectWrapper<TaskType> taskWrapper) {
    PrismContainerWrapper lensContext = null;
    try {
        lensContext = taskWrapper.findContainer(TaskType.F_MODEL_OPERATION_CONTEXT);
    } catch (SchemaException ex) {
        LOGGER.warn("Unable to find modelOperationContext in task {}", taskWrapper.getObject().asObjectable());
    }
    operationVisible = parentPage.isEditingFocus() && isTaskItemReadable(taskWrapper, TaskType.F_MODEL_OPERATION_CONTEXT) && lensContext != null && !lensContext.isEmpty();
    return operationVisible;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)

Aggregations

PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)20 ArrayList (java.util.ArrayList)11 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)9 List (java.util.List)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)8 IModel (org.apache.wicket.model.IModel)8 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)5 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)5 DisplayNamePanel (com.evolveum.midpoint.gui.api.component.DisplayNamePanel)4 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)4 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)4 MultivalueContainerDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 MultivalueContainerListPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanel)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3