Search in sources :

Example 16 with PrismContainerDefinition

use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.

the class ListContainersPopup method initLayout.

private void initLayout() {
    IModel<List<ContainersPopupDto>> popupModel = new LoadableModel<>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ContainersPopupDto> load() {
            List<PrismContainerDefinition<C>> defs;
            try {
                defs = getModelObject().getChildContainers();
            } catch (SchemaException e) {
                LoggingUtils.logUnexpectedException(LOGGER, "Cannot get children containers for {}, reason {}", e, getModelObject(), e.getMessage());
                getSession().error("ListContainersPopup.children.list.failed");
                defs = new ArrayList<>();
            }
            List<ContainersPopupDto> modelObject = defs.stream().filter(def -> def.isExperimental() ? WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) : true).map(def -> createContainersPopupDto(def)).collect(Collectors.toList());
            return modelObject;
        }
    };
    ListView<ContainersPopupDto> listView = new ListView<ContainersPopupDto>(ID_CONTAINERS, popupModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ContainersPopupDto> item) {
            CheckFormGroup checkFormGroup = new CheckFormGroup(ID_SELECTED, new PropertyModel<>(item.getModel(), "selected"), new StringResourceModel("ListContainersPopup.selected"), "col-md-2", "col-md-10") {

                protected boolean getLabelVisible() {
                    return false;
                }
            };
            checkFormGroup.getCheck().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
            checkFormGroup.add(AttributeAppender.append("class", " checkbox-without-margin-bottom "));
            checkFormGroup.setOutputMarkupId(true);
            item.add(checkFormGroup);
            String displayNameKey = item.getModelObject() != null ? item.getModelObject().getDisplayName() : "";
            Label definition = new Label(ID_DEFINITION, new StringResourceModel(displayNameKey));
            definition.setOutputMarkupId(true);
            item.add(definition);
        }
    };
    listView.setOutputMarkupId(true);
    listView.setReuseItems(true);
    add(listView);
    AjaxButton select = new AjaxButton(ID_SELECT, new StringResourceModel("ListContainerPopup.select")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().hideMainPopup(target);
            ListView<ContainersPopupDto> listView = (ListView<ContainersPopupDto>) ListContainersPopup.this.get(ID_CONTAINERS);
            List<PrismContainerDefinition<?>> selected = new ArrayList<>();
            listView.getModelObject().forEach(child -> {
                if (child.isSelected()) {
                    selected.add(child.getDef());
                }
            });
            processSelectedChildren(target, selected);
        }
    };
    select.setOutputMarkupId(true);
    add(select);
    AjaxButton cancel = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("PageBase.button.cancel")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().hideMainPopup(target);
        }
    };
    add(cancel);
}
Also used : CheckFormGroup(com.evolveum.midpoint.web.component.form.CheckFormGroup) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) StringResourceModel(org.apache.wicket.model.StringResourceModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) ArrayList(java.util.ArrayList) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) IModel(org.apache.wicket.model.IModel) Containerable(com.evolveum.midpoint.prism.Containerable) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ListView(org.apache.wicket.markup.html.list.ListView) Popupable(com.evolveum.midpoint.web.component.dialog.Popupable) Label(org.apache.wicket.markup.html.basic.Label) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Collectors(java.util.stream.Collectors) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) PropertyModel(org.apache.wicket.model.PropertyModel) QName(javax.xml.namespace.QName) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) CheckFormGroup(com.evolveum.midpoint.web.component.form.CheckFormGroup) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 17 with PrismContainerDefinition

use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.

the class PrismValueMetadataPanel method createMetadataListModel.

private ReadOnlyModel<List<ContainersPopupDto>> createMetadataListModel() {
    return new ReadOnlyModel<>(() -> {
        ValueMetadataWrapperImpl metadataWrapper = getValueMetadata();
        List<PrismContainerDefinition<? extends Containerable>> childContainers;
        try {
            childContainers = metadataWrapper != null ? metadataWrapper.getChildContainers() : Collections.emptyList();
        } catch (SchemaException e) {
            LOGGER.error("Cannot get child containers: {}", e.getMessage(), e);
            childContainers = Collections.emptyList();
        }
        List<ContainersPopupDto> navigation = childContainers.stream().map(c -> new ContainersPopupDto(false, c)).collect(Collectors.toList());
        List<? extends ItemDefinition> childNonContainers = metadataWrapper != null ? metadataWrapper.getChildNonContainers() : Collections.emptyList();
        if (!childNonContainers.isEmpty()) {
            navigation.add(new ContainersPopupDto(false, metadataWrapper));
        }
        return navigation;
    });
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ContainersPopupDto(com.evolveum.midpoint.gui.impl.prism.panel.component.ContainersPopupDto) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) ItemVisibility(com.evolveum.midpoint.web.component.prism.ItemVisibility) QNameUtil(com.evolveum.midpoint.util.QNameUtil) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) IModel(org.apache.wicket.model.IModel) Containerable(com.evolveum.midpoint.prism.Containerable) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ListView(org.apache.wicket.markup.html.list.ListView) ValueMetadataWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListItem(org.apache.wicket.markup.html.list.ListItem) ValueMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType) Collectors(java.util.stream.Collectors) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) ProvenanceMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ValueMetadataWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ContainersPopupDto(com.evolveum.midpoint.gui.impl.prism.panel.component.ContainersPopupDto) Containerable(com.evolveum.midpoint.prism.Containerable)

Example 18 with PrismContainerDefinition

use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.

the class ItemPathPanel method initLayout.

private void initLayout() {
    ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, new AbstractReadOnlyModel<ItemPathDto>() {

        private static final long serialVersionUID = 1L;

        public ItemPathDto getObject() {
            return ItemPathPanel.this.getModelObject();
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
            return initNamspaceDefinitionMap();
        }
    };
    itemDefPanel.setOutputMarkupId(true);
    add(itemDefPanel);
    AjaxButton plusButton = new AjaxButton(ID_PLUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
        }
    };
    plusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
                return true;
            }
            return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
        }
    });
    plusButton.setOutputMarkupId(true);
    add(plusButton);
    AjaxButton minusButton = new AjaxButton(ID_MINUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ItemPathDto path = ItemPathPanel.this.getModelObject();
            //				ItemPathDto parent = null;
            //				if (path.getItemDef() == null){
            //					parent = path.getParentPath();
            //				} else {
            //					parent = path;
            //				}
            refreshItemPathPanel(path, false, target);
        }
    };
    minusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
        }
    });
    minusButton.setOutputMarkupId(true);
    add(minusButton);
    DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<QName>(ID_NAMESPACE, new PropertyModel<QName>(getModel(), "objectType"), new ListModel<QName>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
    namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshItemPath(ItemPathPanel.this.getModelObject(), target);
        }
    });
    namespacePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
        }
    });
    namespacePanel.setOutputMarkupId(true);
    add(namespacePanel);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Collection(java.util.Collection) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 19 with PrismContainerDefinition

use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.

the class TaskQuartzImpl method setExtensionContainerValue.

// use this method to avoid cloning the value
@Override
public <T extends Containerable> void setExtensionContainerValue(QName containerName, T value) throws SchemaException {
    PrismContainerDefinition containerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(containerName);
    if (containerDef == null) {
        throw new SchemaException("Unknown container item " + containerName);
    }
    ArrayList<PrismContainerValue<T>> values = new ArrayList(1);
    values.add(value.asPrismContainerValue());
    processModificationBatched(setExtensionContainerAndPrepareDelta(containerName, containerDef, values));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ArrayList(java.util.ArrayList) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition)

Example 20 with PrismContainerDefinition

use of com.evolveum.midpoint.prism.PrismContainerDefinition in project midpoint by Evolveum.

the class Construction method evaluateAssociation.

private Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluateAssociation(ResourceObjectAssociationType associationDefinitionType, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef());
    if (assocName == null) {
        throw new SchemaException("Missing 'ref' in association in construction in " + getSource());
    }
    MappingType outboundMappingType = associationDefinitionType.getOutbound();
    if (outboundMappingType == null) {
        throw new SchemaException("No outbound section in definition of association " + assocName + " in construction in " + getSource());
    }
    PrismContainerDefinition<ShadowAssociationType> outputDefinition = getAssociationContainerDefinition();
    Mapping.Builder<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> mappingBuilder = mappingFactory.<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>>createMappingBuilder().mappingType(outboundMappingType).contextDescription("for association " + PrettyPrinter.prettyPrint(assocName) + " in " + getSource()).originType(OriginType.ASSIGNMENTS).originObject(getSource());
    RefinedAssociationDefinition rAssocDef = refinedObjectClassDefinition.findAssociationDefinition(assocName);
    if (rAssocDef == null) {
        throw new SchemaException("No association " + assocName + " in object class " + refinedObjectClassDefinition.getHumanReadableName() + " in construction in " + getSource());
    }
    Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> evaluatedMapping = evaluateMapping(mappingBuilder, assocName, outputDefinition, rAssocDef.getAssociationTarget(), task, result);
    LOGGER.trace("Evaluated mapping for association " + assocName + ": " + evaluatedMapping);
    return evaluatedMapping;
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) Mapping(com.evolveum.midpoint.model.common.mapping.Mapping) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType) RefinedAssociationDefinition(com.evolveum.midpoint.common.refinery.RefinedAssociationDefinition)

Aggregations

PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)41 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)18 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)17 Task (com.evolveum.midpoint.task.api.Task)16 Test (org.testng.annotations.Test)16 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)14 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)13 QName (javax.xml.namespace.QName)10 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 ArrayList (java.util.ArrayList)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5 List (java.util.List)5 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)4 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)4 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)4