Search in sources :

Example 1 with ValueMetadataWrapperImpl

use of com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl 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 2 with ValueMetadataWrapperImpl

use of com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl in project midpoint by Evolveum.

the class ItemWrapperFactoryImpl method setupMetadata.

protected <VW extends PrismValueWrapper> void setupMetadata(IW itemWrapper, VW valueWrapper, WrapperContext ctx) throws SchemaException {
    if (itemWrapper.isMetadata()) {
        return;
    }
    PrismValue oldValue = valueWrapper.getNewValue();
    PrismContainer<ValueMetadataType> metadataContainer = oldValue.getValueMetadataAsContainer();
    if (canContainLegacyMetadata(oldValue)) {
        PrismContainer<MetadataType> oldMetadata = ((PrismContainerValue) oldValue).findContainer(ObjectType.F_METADATA);
        if (oldMetadata != null && oldMetadata.getValue() != null) {
            PrismContainerValue<ValueMetadataType> newMetadataValue = metadataContainer.createNewValue();
            transformStorageMetadata(newMetadataValue, oldMetadata);
            transformProcessMetadata(newMetadataValue, oldMetadata);
        }
    }
    ValueMetadataWrapperFactoryImpl valueMetadataWrapperFactory = new ValueMetadataWrapperFactoryImpl(getRegistry());
    PrismContainerWrapper<ValueMetadataType> valueMetadataWrapper = valueMetadataWrapperFactory.createWrapper(null, metadataContainer, ItemStatus.NOT_CHANGED, ctx);
    if (valueMetadataWrapper != null) {
        valueWrapper.setValueMetadata(new ValueMetadataWrapperImpl(valueMetadataWrapper));
    }
}
Also used : ValueMetadataWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl)

Aggregations

ValueMetadataWrapperImpl (com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)1 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)1 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)1 ContainersPopupDto (com.evolveum.midpoint.gui.impl.prism.panel.component.ContainersPopupDto)1 Containerable (com.evolveum.midpoint.prism.Containerable)1 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)1 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)1 QNameUtil (com.evolveum.midpoint.util.QNameUtil)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 LoggingUtils (com.evolveum.midpoint.util.logging.LoggingUtils)1 Trace (com.evolveum.midpoint.util.logging.Trace)1 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 ItemVisibility (com.evolveum.midpoint.web.component.prism.ItemVisibility)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 ProvenanceMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceMetadataType)1 ValueMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValueMetadataType)1