Search in sources :

Example 16 with PrismContainerValueWrapper

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

the class CaseWorkItemsPanel method initLayout.

private void initLayout() {
    ContainerableListPanel workItemsPanel = new ContainerableListPanel<CaseWorkItemType, PrismContainerValueWrapper<CaseWorkItemType>>(ID_WORKITEMS_TABLE, CaseWorkItemType.class) {

        @Override
        protected List<IColumn<PrismContainerValueWrapper<CaseWorkItemType>, String>> createDefaultColumns() {
            return CaseWorkItemsPanel.this.createDefaultColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            if (View.FULL_LIST.equals(view)) {
                return createRowActions();
            }
            return null;
        }

        @Override
        protected ISelectableDataProvider<CaseWorkItemType, PrismContainerValueWrapper<CaseWorkItemType>> createProvider() {
            return CaseWorkItemsPanel.this.createProvider(getSearchModel());
        }

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

        @Override
        protected boolean hideFooterIfSinglePage() {
            return View.DASHBOARD.equals(view);
        }

        @Override
        protected boolean isHeaderVisible() {
            return !View.DASHBOARD.equals(view);
        }

        @Override
        protected IColumn createCheckboxColumn() {
            return CaseWorkItemsPanel.this.createCheckboxColumn();
        }

        @Override
        protected IColumn createIconColumn() {
            return CaseWorkItemsPanel.this.createIconColumn();
        }

        @Override
        protected IColumn createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
            return CaseWorkItemsPanel.this.createNameColumn();
        }

        @Override
        protected String getStorageKey() {
            return SessionStorage.KEY_WORK_ITEMS;
        }

        @Override
        protected CaseWorkItemType getRowRealValue(PrismContainerValueWrapper<CaseWorkItemType> rowModelObject) {
            if (rowModelObject == null) {
                return null;
            }
            return rowModelObject.getRealValue();
        }
    };
    workItemsPanel.setOutputMarkupId(true);
    add(workItemsPanel);
}
Also used : UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IModel(org.apache.wicket.model.IModel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 17 with PrismContainerValueWrapper

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

the class PageWorkItemsClaimable method createRowActions.

@Override
protected List<InlineMenuItem> createRowActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("pageWorkItem.button.claim")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    claimWorkItemPerformed(getRowModel(), target);
                }
            };
        }

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(CaseWorkItemUtil.isCaseWorkItemNotClosed(workItem));
            } else {
                return super.getEnabled();
            }
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return createStringResource("CaseWorkItemsPanel.confirmWorkItemsClaimAction");
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_ICON_CLAIM);
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 18 with PrismContainerValueWrapper

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

the class ObjectTemplateItemPanel method createAdditionalColumns.

@Override
protected List<IColumn<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>, String>> createAdditionalColumns() {
    List<IColumn<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>, String>> columns = new ArrayList<>();
    columns.add(new AbstractColumn<>(createStringResource("ObjectTemplateItemDefinitionType.mapping")) {

        @Override
        public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>> rowModel) {
            IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ObjectTemplateItemDefinitionType.F_MAPPING);
            cellItem.add(new MappingColumnPanel(componentId, mappingModel));
        }
    });
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    getMultivalueContainerListPanel().deleteItemPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
                }
            };
        }
    };
    items.add(item);
    item = 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 new ColumnMenuAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    getMultivalueContainerListPanel().editItemPerformed(target, getRowModel(), getMultivalueContainerListPanel().getSelectedItems());
                    target.add(getMultivalueContainerListPanel().getFeedbackPanel());
                }
            };
        }
    };
    items.add(item);
    columns.add(new InlineMenuButtonColumn(items, getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    return columns;
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) ObjectTemplateMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateMappingType) IModel(org.apache.wicket.model.IModel) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) ArrayList(java.util.ArrayList) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MappingColumnPanel(com.evolveum.midpoint.gui.impl.component.MappingColumnPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) 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 19 with PrismContainerValueWrapper

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

the class MultivalueContainerListDataProvider method searchThroughList.

protected List<PrismContainerValueWrapper<C>> searchThroughList() {
    List<PrismContainerValueWrapper<C>> list = model.getObject();
    if (list == null || list.isEmpty()) {
        return null;
    }
    ObjectQuery query = getQuery();
    if (query == null || query.getFilter() == null) {
        return list;
    }
    List<PrismContainerValueWrapper<C>> filtered = list.stream().filter(valueWrapper -> {
        try {
            return ObjectQuery.match(valueWrapper.getRealValue(), query.getFilter(), getPageBase().getMatchingRuleRegistry());
        } catch (SchemaException e) {
            throw new TunnelException(e.getMessage());
        }
    }).collect(Collectors.toList());
    return filtered;
}
Also used : BaseSearchDataProvider(com.evolveum.midpoint.web.component.data.BaseSearchDataProvider) PropertyUtils(org.apache.commons.beanutils.PropertyUtils) Iterator(java.util.Iterator) Component(org.apache.wicket.Component) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) BaseSortableDataProvider(com.evolveum.midpoint.web.component.data.BaseSortableDataProvider) Collectors(java.util.stream.Collectors) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISelectableDataProvider(com.evolveum.midpoint.web.component.data.ISelectableDataProvider) List(java.util.List) Validate(org.apache.commons.lang3.Validate) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ObjectUtils(org.apache.commons.lang3.ObjectUtils) SystemException(com.evolveum.midpoint.util.exception.SystemException) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) IModel(org.apache.wicket.model.IModel) Containerable(com.evolveum.midpoint.prism.Containerable) NotNull(org.jetbrains.annotations.NotNull) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Search(com.evolveum.midpoint.web.component.search.Search) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TunnelException(com.evolveum.midpoint.util.exception.TunnelException) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 20 with PrismContainerValueWrapper

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

the class ResourceAttributeRefPanelFactory method getChoicesList.

private List<ItemName> getChoicesList(PrismPropertyPanelContext<ItemPathType> ctx) {
    PrismPropertyWrapper<?> wrapper = ctx.unwrapWrapperModel();
    // attribute/ref
    if (wrapper == null) {
        return Collections.emptyList();
    }
    // attribute value
    if (wrapper.getParent() == null) {
        return Collections.emptyList();
    }
    // attribute
    ItemWrapper<?, ?> attributeWrapper = wrapper.getParent().getParent();
    if (attributeWrapper == null) {
        return Collections.emptyList();
    }
    PrismContainerValueWrapper<?> itemWrapper = attributeWrapper.getParent();
    if (itemWrapper == null) {
        return Collections.emptyList();
    }
    if (!(itemWrapper instanceof ConstructionValueWrapper)) {
        return Collections.emptyList();
    }
    ConstructionValueWrapper constructionWrapper = (ConstructionValueWrapper) itemWrapper;
    try {
        ResourceSchema schema = constructionWrapper.getRefinedSchema();
        if (schema == null) {
            return new ArrayList<>();
        }
        ResourceObjectDefinition rOcd = schema.findObjectDefinition(constructionWrapper.getKind(), constructionWrapper.getIntent());
        if (rOcd == null) {
            return Collections.emptyList();
        }
        if (ConstructionType.F_ASSOCIATION.equivalent(attributeWrapper.getItemName())) {
            Collection<ResourceAssociationDefinition> associationDefs = rOcd.getAssociationDefinitions();
            return associationDefs.stream().map(ResourceAssociationDefinition::getName).collect(Collectors.toList());
        }
        Collection<? extends ResourceAttributeDefinition<?>> attrDefs = rOcd.getAttributeDefinitions();
        return attrDefs.stream().map(a -> a.getItemName()).collect(Collectors.toList());
    } catch (SchemaException e) {
        LOGGER.warn("Cannot get resource attribute definitions");
    }
    return Collections.emptyList();
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) ArrayList(java.util.ArrayList) PrismPropertyWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper) ConstructionValueWrapper(com.evolveum.midpoint.gui.impl.prism.wrapper.ConstructionValueWrapper) IModel(org.apache.wicket.model.IModel) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Serializable(java.io.Serializable) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition) List(java.util.List) Component(org.springframework.stereotype.Component) ItemName(com.evolveum.midpoint.prism.path.ItemName) PostConstruct(javax.annotation.PostConstruct) AutoCompleteQNamePanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ConstructionValueWrapper(com.evolveum.midpoint.gui.impl.prism.wrapper.ConstructionValueWrapper) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ArrayList(java.util.ArrayList) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)

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