Skip to content

Commit

Permalink
Merge branch 'feature/axiom' into feature/metadata-mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 12, 2020
2 parents 52d4614 + f296694 commit 3fd7ab8
Show file tree
Hide file tree
Showing 183 changed files with 8,088 additions and 2,635 deletions.
Expand Up @@ -2697,6 +2697,10 @@ public <O extends ObjectType> PrismObjectWrapperFactory<O> findObjectWrapperFact
return registry.findWrapperFactory(def);
}

public <C extends Containerable> PrismContainerWrapperFactory<C> findContainerWrapperFactory(PrismContainerDefinition<C> def) {
return registry.findContainerWrapperFactory(def);
}

public <IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException {

ItemWrapperFactory<IW, VW, PV> factory = registry.findWrapperFactory(parentWrapper);
Expand Down
Expand Up @@ -8,10 +8,7 @@

import java.util.List;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.exception.SchemaException;
Expand All @@ -22,7 +19,7 @@
* @author katka
*
*/
public interface PrismContainerValueWrapper<C extends Containerable> extends PrismValueWrapper<C, PrismContainerValue<C>>{
public interface PrismContainerValueWrapper<C extends Containerable> extends PrismValueWrapper<C> {

String getDisplayName();
String getHelpText();
Expand All @@ -31,11 +28,6 @@ public interface PrismContainerValueWrapper<C extends Containerable> extends Pri

void setExpanded(boolean expanded);

boolean hasMetadata();
boolean isShowMetadata();

void setShowMetadata(boolean showMetadata);

boolean isSorted();
void setSorted(boolean sorted);

Expand All @@ -46,9 +38,9 @@ public interface PrismContainerValueWrapper<C extends Containerable> extends Pri

<T extends Containerable> List<PrismContainerWrapper<T>> getContainers();

List<? extends ItemWrapper<?,?>> getNonContainers();
List<? extends ItemWrapper<?, ?>> getNonContainers();

List<? extends ItemWrapper<?,?>> getItems();
List<? extends ItemWrapper<?, ?>> getItems();

<T extends Containerable> PrismContainerWrapper<T> findContainer(ItemPath path) throws SchemaException;
<X> PrismPropertyWrapper<X> findProperty(ItemPath propertyPath) throws SchemaException;
Expand All @@ -60,7 +52,6 @@ public interface PrismContainerValueWrapper<C extends Containerable> extends Pri
boolean isSelected();
boolean setSelected(boolean selected); //TODO why return boolean?


boolean isReadOnly();
void setReadOnly(boolean readOnly, boolean recursive);

Expand All @@ -83,4 +74,7 @@ public interface PrismContainerValueWrapper<C extends Containerable> extends Pri

PrismContainerDefinition<C> getDefinition();

@Override
PrismContainerValue<C> getNewValue();
}

Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.gui.api.prism.wrapper;

import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObjectValue;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

/**
Expand All @@ -14,6 +16,6 @@
*/
public interface PrismObjectValueWrapper<O extends ObjectType> extends PrismContainerValueWrapper<O> {



@Override
PrismContainerValue<O> getNewValue();
}
Expand Up @@ -8,6 +8,7 @@

import java.io.Serializable;

import com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
Expand All @@ -19,20 +20,28 @@
* @author katka
*
*/
public interface PrismValueWrapper<T, V extends PrismValue> extends Serializable, DebugDumpable {
public interface PrismValueWrapper<T> extends Serializable, DebugDumpable {

T getRealValue();
void setRealValue(T realValue);

ValueStatus getStatus();
void setStatus(ValueStatus status);

V getNewValue();
V getOldValue();
<V extends PrismValue> V getNewValue();
<V extends PrismValue> V getOldValue();
<IW extends ItemWrapper> IW getParent();

<D extends ItemDelta<V,? extends ItemDefinition>> void addToDelta(D delta) throws SchemaException;
<D extends ItemDelta<PrismValue,? extends ItemDefinition>> void addToDelta(D delta) throws SchemaException;

boolean isVisible();

PrismContainerValueWrapper getValueMetadata();
void setValueMetadata(ValueMetadataWrapperImpl valueMetadata);

boolean isShowMetadata();
void setShowMetadata(boolean showMetadata);

String toShortString();

}
Expand Up @@ -29,7 +29,7 @@
/**
* @author skublik
*/
public class PrismReferenceWrapperColumn<C extends Containerable, R extends Referencable> extends AbstractItemWrapperColumn<C, PrismValueWrapper<R, PrismReferenceValue>> {
public class PrismReferenceWrapperColumn<C extends Containerable, R extends Referencable> extends AbstractItemWrapperColumn<C, PrismValueWrapper<R>> {

private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -27,7 +27,7 @@
* @author katka
*
*/
public class PrismReferenceWrapperColumnPanel<R extends Referencable> extends AbstractItemWrapperColumnPanel<PrismReferenceWrapper<R>, PrismValueWrapper<R, PrismReferenceValue>> {
public class PrismReferenceWrapperColumnPanel<R extends Referencable> extends AbstractItemWrapperColumnPanel<PrismReferenceWrapper<R>, PrismValueWrapper<R>> {

private static final long serialVersionUID = 1L;
private static final Trace LOGGER = TraceManager.getTrace(PrismReferenceWrapperColumnPanel.class);
Expand All @@ -37,12 +37,12 @@ public class PrismReferenceWrapperColumnPanel<R extends Referencable> extends Ab
}

@Override
protected String createLabel(PrismValueWrapper<R, PrismReferenceValue> object) {
protected String createLabel(PrismValueWrapper<R> object) {
return WebComponentUtil.getReferencedObjectDisplayNamesAndNames(object.getRealValue(), false, true);
}

@Override
protected Panel createValuePanel(String id, IModel<PrismReferenceWrapper<R>> model, PrismValueWrapper<R, PrismReferenceValue> object) {
protected Panel createValuePanel(String id, IModel<PrismReferenceWrapper<R>> model, PrismValueWrapper<R> object) {

Panel panel;
try {
Expand All @@ -57,7 +57,7 @@ protected Panel createValuePanel(String id, IModel<PrismReferenceWrapper<R>> mod
}

@Override
protected Panel createLink(String id, IModel<PrismValueWrapper<R, PrismReferenceValue>> object) {
protected Panel createLink(String id, IModel<PrismValueWrapper<R>> object) {
LinkPanel linkPanel = new LinkPanel(id, new IModel<String>() {

@Override
Expand Down
Expand Up @@ -87,7 +87,7 @@ public ItemRealValueModel<T> getRealValueModel() {
return realValueModel;
}

public <VW extends PrismValueWrapper<T,?>> void setRealValueModel(IModel<VW> valueWrapper) {
public <VW extends PrismValueWrapper<T>> void setRealValueModel(IModel<VW> valueWrapper) {
this.realValueModel = new ItemRealValueModel<>(valueWrapper);
}

Expand Down
Expand Up @@ -17,7 +17,7 @@ public class ItemRealValueModel<T> extends PropertyModel<T>{
private static final long serialVersionUID = 1L;


public ItemRealValueModel(IModel<? extends PrismValueWrapper<T,?>> modelObject) {
public ItemRealValueModel(IModel<? extends PrismValueWrapper<T>> modelObject) {
super(modelObject, "realValue");
}

Expand Down
Expand Up @@ -27,7 +27,7 @@ public PrismContainerPanelContext(IModel<PrismContainerWrapper<C>> itemWrapper)
}

@Override
public <VW extends PrismValueWrapper<C,?>> void setRealValueModel(IModel<VW> valueWrapper) {
public <VW extends PrismValueWrapper<C>> void setRealValueModel(IModel<VW> valueWrapper) {
super.setRealValueModel(valueWrapper);
this.valueWrapperModel = (IModel<PrismContainerValueWrapper<C>>) valueWrapper;
}
Expand Down
Expand Up @@ -9,9 +9,12 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

import com.evolveum.midpoint.gui.api.factory.wrapper.ItemWrapperFactory;
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.gui.impl.prism.wrapper.ValueMetadataWrapperImpl;
import com.evolveum.midpoint.model.api.ModelService;

import com.evolveum.midpoint.prism.path.ItemName;
Expand Down Expand Up @@ -154,7 +157,7 @@ private boolean skipCreateWrapper(ItemDefinition<?> def, ItemStatus status, Wrap
}

protected boolean canCreateWrapper(ItemDefinition<?> def, ItemStatus status, WrapperContext context, boolean isEmptyValue) {
if (def.isOperational()) {
if (def.isOperational() && !context.isCreateOperational()) {
LOGGER.trace("Skipping creating wrapper for {}, because it is operational.", def.getItemName());
return false;
}
Expand All @@ -173,6 +176,7 @@ protected List<VW> createValuesWrapper(IW itemWrapper, I item, WrapperContext co
if (shouldCreateEmptyValue(item, context)) {
PV prismValue = createNewValue(item);
VW valueWrapper = createValueWrapper(itemWrapper, prismValue, ValueStatus.ADDED, context);
// setupMetadata(valueWrapper, context);
pvWrappers.add(valueWrapper);
}
return pvWrappers;
Expand All @@ -181,6 +185,7 @@ protected List<VW> createValuesWrapper(IW itemWrapper, I item, WrapperContext co
for (PV pcv : values) {
if(canCreateValueWrapper(pcv)){
VW valueWrapper = createValueWrapper(itemWrapper, pcv, ValueStatus.NOT_CHANGED, context);
setupMetadata(valueWrapper, context);
pvWrappers.add(valueWrapper);
}
}
Expand All @@ -189,6 +194,21 @@ protected List<VW> createValuesWrapper(IW itemWrapper, I item, WrapperContext co

}

protected <VW extends PrismValueWrapper> void setupMetadata(VW valueWrapper, WrapperContext ctx) throws SchemaException {
PrismValue oldValue = valueWrapper.getNewValue();
Optional<ValueMetadata> metadata = oldValue.valueMetadata();
if (!metadata.isPresent()) {
LOGGER.trace("Skipping creating metadata");
return;
}

ValueMetadata valueMetadata = metadata.get();

ValueMetadataWrapperFactoryImpl valueMetadataWrapperFactory = new ValueMetadataWrapperFactoryImpl(getRegistry());
PrismContainerValueWrapper<Containerable> valueMetadataWrapper = valueMetadataWrapperFactory.createValueWrapper(null, valueMetadata, ValueStatus.NOT_CHANGED, ctx);
valueWrapper.setValueMetadata(new ValueMetadataWrapperImpl(valueMetadataWrapper));
}

protected List<PV> getValues(I item) {
return item.getValues();
}
Expand Down Expand Up @@ -261,7 +281,7 @@ protected boolean shouldCreateEmptyValue(I item, WrapperContext context) {
/**
* @return the registry
*/
public GuiComponentRegistryImpl getRegistry() {
public GuiComponentRegistry getRegistry() {
return registry;
}

Expand Down
Expand Up @@ -27,7 +27,7 @@ public class OperationalContainerWrapperFactory extends PrismContainerWrapperFac

@Override
public boolean match(ItemDefinition<?> def) {
return QNameUtil.match(MetadataType.COMPLEX_TYPE, def.getTypeName()) || QNameUtil.match(TriggerType.COMPLEX_TYPE, def.getTypeName());
return QNameUtil.match(TriggerType.COMPLEX_TYPE, def.getTypeName()); //QNameUtil.match(MetadataType.COMPLEX_TYPE, def.getTypeName()) ||
}

@PostConstruct
Expand Down
Expand Up @@ -66,7 +66,9 @@ public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C>

containerValueWrapper.getItems().addAll((Collection) children);
containerValueWrapper.setVirtualContainerItems(context.getVirtualItemSpecification());
parent.setVirtual(context.getVirtualItemSpecification() != null);
if (parent != null) {
parent.setVirtual(context.getVirtualItemSpecification() != null);
}
return containerValueWrapper;
}

Expand Down
Expand Up @@ -70,6 +70,7 @@ public PrismObjectWrapper<O> createObjectWrapper(PrismObject<O> object, ItemStat
context.setShowEmpty(ItemStatus.ADDED == status);
objectWrapper.setExpanded(true);
PrismContainerValueWrapper<O> valueWrapper = createValueWrapper(objectWrapper, object.getValue(), ItemStatus.ADDED == status ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);
setupMetadata(valueWrapper, context);
objectWrapper.getValues().add(valueWrapper);
registerWrapperPanel(objectWrapper);

Expand Down Expand Up @@ -97,6 +98,7 @@ public void updateWrapper(PrismObjectWrapper<O> wrapper, WrapperContext context)
wrapper.getValue().getItems().clear();

PrismContainerValueWrapper<O> valueWrapper = createValueWrapper(wrapper, wrapper.getObject().getValue(), ItemStatus.ADDED == wrapper.getStatus() ? ValueStatus.ADDED : ValueStatus.NOT_CHANGED, context);
setupMetadata(valueWrapper, context);
wrapper.getValues().clear();
wrapper.getValues().add(valueWrapper);

Expand Down
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.gui.impl.factory.wrapper;

import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.api.registry.GuiComponentRegistry;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.ValueStatus;

import java.util.List;

public class ValueMetadataWrapperFactoryImpl extends PrismContainerWrapperFactoryImpl<Containerable> {

private GuiComponentRegistry registry;

ValueMetadataWrapperFactoryImpl(GuiComponentRegistry registry) {
this.registry = registry;
}

@Override
public PrismContainerValueWrapper<Containerable> createValueWrapper(PrismContainerWrapper<Containerable> parent, PrismContainerValue<Containerable> value, ValueStatus status, WrapperContext context) throws SchemaException {
context.setCreateOperational(true);
PrismContainerValueWrapper<Containerable> v = super.createValueWrapper(parent, value, status, context);
context.setCreateOperational(false);
return v;
}

@Override
protected boolean shouldBeExpanded(PrismContainerWrapper<Containerable> parent, PrismContainerValue<Containerable> value, WrapperContext context) {
return true;
}

@Override
protected boolean shouldCreateEmptyValue(PrismContainer<Containerable> item, WrapperContext context) {
return false;
}

@Override
protected List<? extends ItemDefinition> getItemDefinitions(PrismContainerWrapper<Containerable> parent, PrismContainerValue<Containerable> value) {
return value.getComplexTypeDefinition().getDefinitions();
}

@Override
public GuiComponentRegistry getRegistry() {
return registry;
}

@Override
protected ItemWrapper<?, ?> createChildWrapper(ItemDefinition<?> def, PrismContainerValueWrapper<?> containerValueWrapper, WrapperContext context) throws SchemaException {
ItemWrapper<?, ?> child = super.createChildWrapper(def, containerValueWrapper, context);
//TODO ugly hack. find out something smarter
if (ItemStatus.ADDED == child.getStatus()) {
return null;
}

return child;
}
}
Expand Up @@ -19,7 +19,6 @@
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
Expand Down Expand Up @@ -53,7 +52,7 @@ public ExpressionPropertyPanel(String id, IModel<PrismPropertyWrapper<Expression
}

@Override
protected Panel createHeaderPanel() {
protected Component createHeaderPanel() {
ExpressionWrapper expressionWrapper = (ExpressionWrapper) getModelObject();
if (expressionWrapper != null && (expressionWrapper.isAssociationExpression() || expressionWrapper.isAttributeExpression())){
return new ExpressionPropertyHeaderPanel(ID_HEADER, getModel()) {
Expand Down

0 comments on commit 3fd7ab8

Please sign in to comment.