Search in sources :

Example 21 with PrismContainerValueWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper 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 22 with PrismContainerValueWrapper

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

the class AssignmentPanel method getAssignmentMenuActions.

private <AH extends FocusType> List<InlineMenuItem> getAssignmentMenuActions() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    PrismObject<AH> obj = getMultivalueContainerListPanel().getFocusObject();
    try {
        boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI, AuthorizationPhaseType.REQUEST, obj, null, null, null);
        if (isUnassignAuthorized) {
            menuItems.add(new ButtonInlineMenuItem(getAssignmentsLimitReachedUnassignTitleModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    } catch (Exception ex) {
        LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
        if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)) {
            menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.unassign")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    }
    menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return getMultivalueContainerListPanel().createEditColumnAction();
        }
    });
    ButtonInlineMenuItem menu = new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<PrismContainerValueWrapper<AssignmentType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    PrismContainerValueWrapper<AssignmentType> assignmentContainer = getRowModel().getObject();
                    PrismReferenceWrapper<ObjectReferenceType> targetRef;
                    try {
                        targetRef = assignmentContainer.findReference(ItemPath.create(AssignmentType.F_TARGET_REF));
                    } catch (SchemaException e) {
                        getSession().error("Couldn't show details page. More information provided in log.");
                        LOGGER.error("Couldn't show details page, no targetRef reference wrapper found: {}", e.getMessage(), e);
                        target.add(getPageBase().getFeedbackPanel());
                        return;
                    }
                    if (targetRef != null && targetRef.getValues() != null && targetRef.getValues().size() > 0) {
                        PrismReferenceValueWrapperImpl<ObjectReferenceType> refWrapper = targetRef.getValues().get(0);
                        if (!StringUtils.isEmpty(refWrapper.getNewValue().getOid())) {
                            Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(refWrapper.getRealValue().getType()).getClassDefinition();
                            WebComponentUtil.dispatchToObjectDetailsPage(targetClass, refWrapper.getNewValue().getOid(), AssignmentPanel.this, false);
                        }
                    }
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    menu.setVisibilityChecker((InlineMenuItem.VisibilityChecker) (rowModel, isHeader) -> {
        PrismContainerValueWrapper<AssignmentType> assignment = (PrismContainerValueWrapper<AssignmentType>) rowModel.getObject();
        if (assignment == null) {
            return false;
        }
        PrismReferenceWrapper<Referencable> target = null;
        try {
            target = assignment.findReference(AssignmentType.F_TARGET_REF);
        } catch (Exception e) {
            LOGGER.error("Couldn't find targetRef in assignment");
        }
        return target != null && !target.isEmpty();
    });
    menuItems.add(menu);
    return menuItems;
}
Also used : PrismContainerWrapperModel(com.evolveum.midpoint.web.model.PrismContainerWrapperModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismContainerWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismContainerWrapperColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AssignmentCandidatesSpecification(com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification) StringUtils(org.apache.commons.lang3.StringUtils) AjaxLinkColumn(com.evolveum.midpoint.web.component.data.column.AjaxLinkColumn) QNameUtil(com.evolveum.midpoint.util.QNameUtil) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Search(com.evolveum.midpoint.web.component.search.Search) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) Label(org.apache.wicket.markup.html.basic.Label) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) SearchFactory(com.evolveum.midpoint.web.component.search.SearchFactory) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Task(com.evolveum.midpoint.task.api.Task) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AssignmentListProvider(com.evolveum.midpoint.web.component.util.AssignmentListProvider) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PropertyModel(org.apache.wicket.model.PropertyModel) Item(org.apache.wicket.markup.repeater.Item) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PrismReferenceValueWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl) AssignmentPopupDto(com.evolveum.midpoint.gui.api.component.AssignmentPopupDto) GuiDisplayTypeUtil(com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil) RefFilter(com.evolveum.midpoint.prism.query.RefFilter) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) Trace(com.evolveum.midpoint.util.logging.Trace) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) PageStorage(com.evolveum.midpoint.web.session.PageStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) AssignmentsDetailsPanel(com.evolveum.midpoint.gui.impl.component.AssignmentsDetailsPanel) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) CompositedIconColumn(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ArrayList(java.util.ArrayList) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 23 with PrismContainerValueWrapper

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

the class AssignmentPanel method createAssignmentMoreDataColumn.

private IColumn<PrismContainerValueWrapper<AssignmentType>, String> createAssignmentMoreDataColumn() {
    return new AbstractColumn<>(createStringResource("AssignmentPanel.moreData")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<AssignmentType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<AssignmentType>> rowModel) {
            AssignmentType assignmentType = rowModel != null && rowModel.getObject() != null ? rowModel.getObject().getRealValue() : null;
            cellItem.add(new Label(componentId, AssignmentsUtil.getAssignmentSpecificInfoLabel(assignmentType, AssignmentPanel.this.getPageBase())));
        }
    };
}
Also used : ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 24 with PrismContainerValueWrapper

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

the class ConstructionAssociationPanel method getShadowReferencesModel.

private IModel<List<ObjectReferenceType>> getShadowReferencesModel(ResourceAssociationDefinition def) {
    return new LoadableModel<List<ObjectReferenceType>>() {

        private static final long serialVersionUID = 1L;

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

Example 25 with PrismContainerValueWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper 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)

Aggregations

PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)25 ArrayList (java.util.ArrayList)16 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 IModel (org.apache.wicket.model.IModel)10 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)9 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)8 InlineMenuButtonColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn)7 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 Label (org.apache.wicket.markup.html.basic.Label)6 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)5 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)5 List (java.util.List)5 PrismPropertyWrapperColumn (com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn)4 Task (com.evolveum.midpoint.task.api.Task)4 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)4 QName (javax.xml.namespace.QName)4