Skip to content

Commit

Permalink
Merge branch 'feature/gui-wrapper' of https://github.com/Evolveum/mid…
Browse files Browse the repository at this point in the history
…point into feature/gui-wrapper
  • Loading branch information
KaterynaHonchar committed May 24, 2019
2 parents 8e4d669 + c8ebf46 commit f29e844
Show file tree
Hide file tree
Showing 68 changed files with 1,132 additions and 740 deletions.
Expand Up @@ -121,7 +121,7 @@ private boolean isObjectPolicyConfigurationType() {
return false;
}

private String createImageModel() {
protected String createImageModel() {
if (getModelObject() == null){
return "";
}
Expand Down
Expand Up @@ -15,19 +15,19 @@
*/
package com.evolveum.midpoint.gui.api.component.tabs;

import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;


/**
* Tab that contains a singleton panel.
*
* @author semancik
*/
public abstract class PanelTab<T extends ObjectType> extends AbstractTab {
public abstract class PanelTab extends AbstractTab {

private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -35,6 +35,8 @@ public interface PrismObjectWrapper<O extends ObjectType> extends PrismContainer

PrismObject<O> getObject();

PrismObject<O> getObjectOld();

String getOid();

PrismObjectValueWrapper<O> getValue();
Expand Down
Expand Up @@ -22,10 +22,13 @@
* @author skublik
*
*/
public interface ShadowWrapper<S extends ShadowType> extends PrismObjectWrapper<S> {
public interface ShadowWrapper extends PrismObjectWrapper<ShadowType> {

UserDtoStatus getProjectionStatus();
void setProjectionStatus(UserDtoStatus status);
boolean isLoadWithNoFetch();
void setLoadWithNoFetch(boolean noFetch);


boolean isProtected();
}

Large diffs are not rendered by default.

Expand Up @@ -755,6 +755,26 @@ public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator

}

public static boolean isEnableExperimentalFeature(ModelInteractionService modelInteractionService, Task task, OperationResult result) {
CompiledUserProfile adminGuiConfig = null;
try {
adminGuiConfig = modelInteractionService.getCompiledUserProfile(task, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());

}

if (adminGuiConfig == null) {
return false;
}

return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());

}

public static boolean isEnableExperimentalFeature(ModelServiceLocator pageBase) {
Task task = pageBase.createSimpleTask("Load admin gui config");
return isEnableExperimentalFeature(task, pageBase);
Expand Down
Expand Up @@ -492,13 +492,6 @@ public PrismContainerValueWrapper<C> createNewItemContainerValueWrapper(
//TODO error handling
}
model.getValues().add((PrismContainerValueWrapper) valueWrapper);
//
// ContainerWrapperFactory factory = new ContainerWrapperFactory(getPageBase());
// Task task = getPageBase().createSimpleTask("Creating new object policy");
// PrismContainerValueWrapper<C> valueWrapper = factory.createContainerValueWrapper(model.getObject(), newItem,
// model.getObject().getObjectStatus(), ValueStatus.ADDED, model.getObject().getPath(), task);
// valueWrapper.setShowEmpty(true, true);
// model.getObject().getValues().add(valueWrapper);
return (PrismContainerValueWrapper<C>) valueWrapper;
}

Expand Down
Expand Up @@ -136,6 +136,7 @@ public void onClick(AjaxRequestTarget ajaxRequestTarget) {
itemDetailsVisible = false;
cancelItemDetailsPerformed(ajaxRequestTarget);
ajaxRequestTarget.add(MultivalueContainerListPanelWithDetailsPanel.this);
ajaxRequestTarget.add(getPageBase().getFeedbackPanel());
}
};
details.add(cancelButton);
Expand All @@ -155,7 +156,7 @@ protected void cancelItemDetailsPerformed(AjaxRequestTarget target){
}

@Override
protected void itemPerformedForDefaultAction(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<C>> rowModel,
public void itemPerformedForDefaultAction(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<C>> rowModel,
List<PrismContainerValueWrapper<C>> listItems) {

if((listItems!= null && !listItems.isEmpty()) || rowModel != null) {
Expand Down
Expand Up @@ -23,6 +23,7 @@
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
Expand All @@ -39,7 +40,7 @@ public class AssignmentWrapperFactoryImpl extends PrismContainerWrapperFactoryIm

@Override
public boolean match(ItemDefinition<?> def) {
return AssignmentType.COMPLEX_TYPE.equals(def.getTypeName());
return def instanceof PrismContainerDefinition && def.isMultiValue();
}

@Override
Expand Down
Expand Up @@ -60,9 +60,9 @@
*
*/
@Component
public class PolicyConstraintPresentationTypeFactory<C extends Containerable> implements PrismContainerWrapperFactory<C> {
public class HeterogenousContainerWrapperFactory<C extends Containerable> implements PrismContainerWrapperFactory<C> {

private static final transient Trace LOGGER = TraceManager.getTrace(PolicyConstraintPresentationTypeFactory.class);
private static final transient Trace LOGGER = TraceManager.getTrace(HeterogenousContainerWrapperFactory.class);

@Autowired private GuiComponentRegistry registry;

Expand Down Expand Up @@ -93,8 +93,25 @@ public PrismContainerValueWrapper<C> createValueWrapper(PrismContainerWrapper<C>
PrismContainerValue<C> value, ValueStatus status, WrapperContext context)
throws SchemaException {
PrismContainerValueWrapper<C> containerValueWrapper = new PrismContainerValueWrapperImpl<C>(parent, value, status);
containerValueWrapper.setHeterogenous(true);

List<ItemWrapper<?,?,?,?>> wrappers = new ArrayList<>();

for (ItemDefinition<?> def : value.getDefinition().getDefinitions()) {

Item<?,?> childItem = value.findItem(def.getName());

if (childItem == null && def instanceof PrismContainerDefinition) {
LOGGER.trace("Skipping craeting wrapper for {}, only property and refernce wrappers are created for heterogenous containers.");
continue;
}

ItemWrapperFactory<?,?,?> factory = registry.findWrapperFactory(def);

ItemWrapper<?, ?, ?, ?> wrapper = factory.createWrapper(containerValueWrapper, def, context);
wrappers.add(wrapper);
}

containerValueWrapper.getItems().addAll((Collection) wrappers);
return containerValueWrapper;
}
Expand All @@ -104,6 +121,12 @@ protected List<PrismContainerValueWrapper<C>> createValuesWrapper(PrismContainer

// PrismContainerDefinition<C> definition = item.getDefinition();

if (item.getValues() == null || item.getValues().isEmpty()) {
PrismContainerValueWrapper<C> valueWrapper = createValueWrapper(itemWrapper, item.createNewValue(), ValueStatus.ADDED, context);
pvWrappers.add(valueWrapper);
return pvWrappers;
}

for (PrismContainerValue<C> pcv : item.getValues()) {
PrismContainerValueWrapper<C> valueWrapper = createValueWrapper(itemWrapper, pcv, ValueStatus.NOT_CHANGED, context);
pvWrappers.add(valueWrapper);
Expand All @@ -113,14 +136,44 @@ protected List<PrismContainerValueWrapper<C>> createValuesWrapper(PrismContainer

}

/**
*
* match single value containers which contains a looot of other conainers, e.g. policy rule, policy action, notification configuration, etc
*/
@Override
public boolean match(ItemDefinition<?> def) {
QName defName = def.getTypeName();
return PolicyConstraintPresentationType.COMPLEX_TYPE.equals(defName)
|| StatePolicyConstraintType.COMPLEX_TYPE.equals(defName)
|| HasAssignmentPolicyConstraintType.COMPLEX_TYPE.equals(defName)
|| ExclusionPolicyConstraintType.COMPLEX_TYPE.equals(defName)
|| PolicyConstraintsType.COMPLEX_TYPE.equals(defName);

if (!(def instanceof PrismContainerDefinition)) {
return false;
}

PrismContainerDefinition<?> containerDef = (PrismContainerDefinition<?>) def;

if (containerDef.isMultiValue()) {
return false;
}

List<? extends ItemDefinition> defs = containerDef.getDefinitions();
int containers = 0;
for (ItemDefinition<?> itemDef : defs) {
if (itemDef instanceof PrismContainerDefinition<?> && itemDef.isMultiValue()) {
containers++;
}
}

if (containers > 2) {
return true;
}

return false;

// if (def.isSingleValue() && )
// return PolicyConstraintPresentationType.COMPLEX_TYPE.equals(defName)
// || StatePolicyConstraintType.COMPLEX_TYPE.equals(defName)
// || HasAssignmentPolicyConstraintType.COMPLEX_TYPE.equals(defName)
// || ExclusionPolicyConstraintType.COMPLEX_TYPE.equals(defName)
// || PolicyConstraintsType.COMPLEX_TYPE.equals(defName);
}

@Override
Expand All @@ -131,7 +184,7 @@ public void register() {

@Override
public int getOrder() {
return 10;
return 110;
}

@Override
Expand All @@ -149,7 +202,7 @@ public PrismContainerWrapper<C> createWrapper(Item childContainer, ItemStatus st
}

@Override
public boolean skipCreateWrapper(ItemDefinition<?> def) {
public boolean skipCreateWrapper(ItemDefinition<?> def, WrapperContext wrapperContext) {
return false;
}

Expand Down
Expand Up @@ -36,6 +36,6 @@ public interface ItemWrapperFactory<IW extends ItemWrapper, VW extends PrismValu
IW createWrapper(Item childContainer, ItemStatus status, WrapperContext context) throws SchemaException;
VW createValueWrapper(IW parent, PV value, ValueStatus status, WrapperContext context) throws SchemaException;

boolean skipCreateWrapper(ItemDefinition<?> def);
boolean skipCreateWrapper(ItemDefinition<?> def, WrapperContext wrapperContext);

}
Expand Up @@ -23,9 +23,11 @@

import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.prism.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.PrismValueWrapper;
import com.evolveum.midpoint.gui.impl.registry.GuiComponentRegistryImpl;
import com.evolveum.midpoint.model.api.ModelInteractionService;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContext;
Expand All @@ -47,6 +49,7 @@ public abstract class ItemWrapperFactoryImpl<IW extends ItemWrapper, PV extends

@Autowired private GuiComponentRegistryImpl registry;
@Autowired private PrismContext prismContext;
@Autowired private ModelInteractionService modelInteractionService;

@Override
public IW createWrapper(PrismContainerValueWrapper<?> parent, ItemDefinition<?> def, WrapperContext context) throws SchemaException {
Expand Down Expand Up @@ -155,14 +158,18 @@ public PrismContext getPrismContext() {
}

@Override
public boolean skipCreateWrapper(ItemDefinition<?> def) {
public boolean skipCreateWrapper(ItemDefinition<?> def, WrapperContext wrapperContext) {
if (def.isOperational()) {
LOGGER.trace("Skipping creating wrapper for {}, because it is operational.", def.getName());
return true;
}

if (SearchFilterType.COMPLEX_TYPE.equals(def.getTypeName())) {
LOGGER.trace("Skipping creating wrapper for search filter.", def.getName());
LOGGER.trace("Skipping creating wrapper for search filter: {}", def.getName());
return true;
}

if (def.isExperimental() && !WebModelServiceUtils.isEnableExperimentalFeature(modelInteractionService, wrapperContext.getTask(), wrapperContext.getResult())) {
return true;
}

Expand Down
Expand Up @@ -82,6 +82,11 @@ private LookupTableType getPredefinedValues(PrismContainerValueWrapper<?> parent
LookupTableType lookupTable = new LookupTableType();
List<LookupTableRowType> list = lookupTable.createRowList();

if(parent == null || parent.getParent() == null || parent.getParent().getParent() == null) {
return lookupTable;
}


if(!(parent.getParent().getParent().getRealValue() instanceof LoggingConfigurationType)) {
throw new IllegalArgumentException("LoggingConfigurationType not found in parent for Appender");
}
Expand Down
Expand Up @@ -90,7 +90,7 @@ public void register() {
*/
@Override
public int getOrder() {
return Integer.MAX_VALUE;
return 10;
}


Expand Down
Expand Up @@ -67,7 +67,7 @@ protected void addItemWrapper(ItemDefinition<?> def, PrismContainerValueWrapper<
}

@Override
public boolean skipCreateWrapper(ItemDefinition<?> def) {
public boolean skipCreateWrapper(ItemDefinition<?> def, WrapperContext wrapperContext) {
return false;
}

Expand Down
Expand Up @@ -116,7 +116,7 @@ protected void addItemWrapper(ItemDefinition<?> def, PrismContainerValueWrapper<
}

LOGGER.trace("Found factory {} for {}", factory, def);
if (factory.skipCreateWrapper(def)) {
if (factory.skipCreateWrapper(def, context)) {
return;
}

Expand Down

0 comments on commit f29e844

Please sign in to comment.