Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/upgrade-pro…
Browse files Browse the repository at this point in the history
…cess
  • Loading branch information
1azyman committed Jun 26, 2023
2 parents ac06bb5 + 7a60f96 commit cd14e94
Show file tree
Hide file tree
Showing 71 changed files with 3,610 additions and 858 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.evolveum.midpoint.gui.api.factory.wrapper;

import com.evolveum.midpoint.gui.api.util.MappingDirection;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.schema.ResourceShadowCoordinates;
import com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
Expand Down Expand Up @@ -63,13 +65,7 @@ public class WrapperContext {
private List<? extends ContainerPanelConfigurationType> detailsPageTypeConfiguration;
private Collection<VirtualContainersSpecificationType> virtualContainers = new ArrayList<>();

//Attribute mapping related attributes
public enum AttributeMappingType {
INBOUND,
OUTBOUND,
OVERRIDE
}
private AttributeMappingType attributeMappingType;
private MappingDirection attributeMappingType;
private boolean configureMappingType;

private boolean isShowedByWizard;
Expand Down Expand Up @@ -260,11 +256,11 @@ public void setDetailsPageTypeConfiguration(List<? extends ContainerPanelConfigu
this.detailsPageTypeConfiguration = detailsPageTypeConfiguration;
}

public void setAttributeMappingType(AttributeMappingType attributeMappingType) {
public void setAttributeMappingType(MappingDirection attributeMappingType) {
this.attributeMappingType = attributeMappingType;
}

public AttributeMappingType getAttributeMappingType() {
public MappingDirection getAttributeMappingType() {
return attributeMappingType;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2010-2023 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.api.util;

import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;

/**
* Attribute mapping related attributes
*/
public enum MappingDirection {
INBOUND(ResourceAttributeDefinitionType.F_INBOUND),
OUTBOUND(ResourceAttributeDefinitionType.F_OUTBOUND),
OVERRIDE(null);

private ItemName containerName;

MappingDirection(ItemName containerName) {
this.containerName = containerName;
}

public ItemName getContainerName() {
return containerName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5790,4 +5790,57 @@ public static boolean isDarkModeEnabled() {
MidPointAuthWebSession session = MidPointAuthWebSession.get();
return session.getSessionStorage().getMode() == SessionStorage.Mode.DARK;
}

public static String createMappingIcon(PrismContainerValueWrapper<? extends Containerable> object) {
if (object == null) {
return "fa fa-circle";
}

PrismContainerDefinition<? extends Containerable> def = object.getDefinition();
if (def == null) {
return "fa fa-circle";
}

if (object.getParentContainerValue(ResourceActivationDefinitionType.class) != null) {
if (QNameUtil.match(def.getTypeName(), MappingType.COMPLEX_TYPE)){
PrismContainerValueWrapper<ResourceBidirectionalMappingType> parent =
object.getParentContainerValue(ResourceBidirectionalMappingType.class);
if (parent == null) {
return "fa fa-circle";
}

PrismContainerDefinition<ResourceBidirectionalMappingType> parentDef = parent.getDefinition();
return createMappingIcon(parentDef);

} else {
return createMappingIcon(def);
}
}
return "fa fa-circle";
}

public static String createMappingIcon(PrismContainerDefinition<? extends Containerable> def) {
if (def == null) {
return "fa fa-circle";
}

if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_ADMINISTRATIVE_STATUS)) {
return "fa fa-id-card-clip";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_EXISTENCE)) {
return "fa fa-universal-access";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_VALID_FROM)) {
return "fa fa-arrow-right-from-bracket";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_VALID_TO)) {
return "fa fa-arrow-right-to-bracket";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_LOCKOUT_STATUS)) {
return "fa fa-user-lock";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DISABLE_INSTEAD_DELETE)) {
return "fa fa-user-slash";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_DELAYED_DELETE)) {
return "fa fa-clock";
} else if (QNameUtil.match(def.getItemName(), ResourceActivationDefinitionType.F_PRE_PROVISION)) {
return "fa fa-user-plus";
}
return "fa fa-circle";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@

import com.evolveum.midpoint.gui.impl.prism.panel.ItemPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettings;
import com.evolveum.midpoint.gui.impl.prism.panel.ItemWrapperComparator;
import com.evolveum.midpoint.gui.impl.prism.panel.vertical.form.VerticalFormPasswordPropertyPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.vertical.form.VerticalFormPrismPropertyPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.vertical.form.VerticalFormPrismReferencePanel;
import com.evolveum.midpoint.gui.impl.prism.wrapper.ProtectedStringTypeWrapperImpl;
import com.evolveum.midpoint.schema.processor.*;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.data.column.ColumnUtils;
import com.evolveum.midpoint.web.util.ExpressionUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand All @@ -45,7 +47,6 @@
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.security.MidPointApplication;

import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.model.IModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -438,4 +439,69 @@ public static ItemPanel createVerticalPropertyPanel(String id, IModel<? extends
propertyPanel.setOutputMarkupId(true);
return propertyPanel;
}

public static void sortContainers(List<PrismContainerWrapper<? extends Containerable>> containers) {
ItemWrapperComparator<?> comparator = new ItemWrapperComparator<>(WebComponentUtil.getCollator(), false);
if (CollectionUtils.isNotEmpty(containers)) {
containers.sort((Comparator) comparator);
}
}

public static String getLocalizedDisplayName(Item item) {
Validate.notNull(item, "Item must not be null.");

String displayName = item.getDisplayName();
if (!StringUtils.isEmpty(displayName)) {
return localizeName(displayName, displayName);
}

QName name = item.getElementName();
if (name != null) {
displayName = name.getLocalPart();

PrismContainerValue<?> val = item.getParent();
if (val != null && val.getDefinition() != null
&& val.getDefinition().isRuntimeSchema()) {
return localizeName(displayName, displayName);
}

if (val != null) {
if (val.getRealClass() != null) {
displayName = val.getRealClass().getSimpleName() + "." + displayName;
String localizedName = localizeName(displayName, displayName);
//try to find by super class name + item name
if (localizedName.equals(displayName) && val.getRealClass().getSuperclass() != null) {
return getItemDisplayNameFromSuperClassName(val.getRealClass().getSuperclass(), name.getLocalPart());
}
} else if (val.getTypeName() != null) {
displayName = val.getTypeName().getLocalPart() + "." + displayName;
}
}
} else {
displayName = item.getDefinition().getTypeName().getLocalPart();
}

return localizeName(displayName, name.getLocalPart());
}

private static String getItemDisplayNameFromSuperClassName(Class superClass, String itemName) {
if (superClass == null) {
return "";
}
String displayNameParentClass = superClass.getSimpleName() + "." + itemName;
String localizedName = localizeName(displayNameParentClass, displayNameParentClass);
if (localizedName.equals(displayNameParentClass) && superClass.getSuperclass() != null) {
return getItemDisplayNameFromSuperClassName(superClass.getSuperclass(), itemName);
}
if (!localizedName.equals(displayNameParentClass)) {
return localizedName;
} else {
return itemName;
}
}

private static String localizeName(String nameKey, String defaultString) {
Validate.notNull(nameKey, "Null localization key");
return ColumnUtils.createStringResource(nameKey, defaultString).getString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

package com.evolveum.midpoint.gui.impl.component.tile;

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

import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
Expand All @@ -26,7 +24,7 @@
/**
* Created by Viliam Repan (lazyman).
*/
public class TilePanel<T extends Serializable> extends BasePanel<Tile<T>> {
public class TilePanel<T extends Tile<O>, O extends Serializable> extends BasePanel<T> {

private static final long serialVersionUID = 1L;

Expand All @@ -35,7 +33,7 @@ public class TilePanel<T extends Serializable> extends BasePanel<Tile<T>> {

private static final String ID_DESCRIPTION = "description";

public TilePanel(String id, IModel<Tile<T>> model) {
public TilePanel(String id, IModel<T> model) {
super(id, model);

initLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
</wicket:fragment>
<wicket:fragment wicket:id="tilesFragment">
<div wicket:id="tiles" style="min-height: 250px;">
<div wicket:id="tiles">
<div wicket:id="tile"/>
</div>
</wicket:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class TileTablePanel<T extends Tile, O extends Serializable> ext
private static final long serialVersionUID = 1L;

static final String ID_TILES_CONTAINER = "tilesContainer";
static final String ID_TILES_FRAGMENT = "tilesFragment";
protected static final String ID_TILES_FRAGMENT = "tilesFragment";
protected static final String ID_TILES = "tiles";

private static final String ID_HEADER_FRAGMENT = "headerFragment";
Expand Down Expand Up @@ -106,6 +106,7 @@ private void initLayout() {
add(tilesContainer);

WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
footerContainer.add(new VisibleBehaviour(this::showFooter));
footerContainer.setOutputMarkupId(true);
footerContainer.add(AttributeAppender.append("class", getTilesFooterCssClasses()));
add(footerContainer);
Expand All @@ -127,6 +128,10 @@ protected String getPaginationCssClass() {
add(table);
}

protected boolean showFooter() {
return true;
}

protected WebMarkupContainer createTilesContainer(String idTilesContainer, ISortableDataProvider<O, String> provider, UserProfileStorage.TableId tableId) {
Fragment tilesFragment = new Fragment(idTilesContainer, ID_TILES_FRAGMENT, TileTablePanel.this);

Expand All @@ -143,6 +148,7 @@ protected PageableListView createTilesPanel(
@Override
protected void populateItem(ListItem<T> item) {
item.add(AttributeAppender.append("class", () -> getTileCssClasses()));
item.add(AttributeAppender.append("style", () -> getTileCssStyle()));

Component tile = createTile(ID_TILE, item.getModel());
item.add(tile);
Expand All @@ -155,6 +161,10 @@ protected List<T> createItem(O object) {
};
}

protected String getTileCssStyle() {
return "min-height: 250px;";
}

protected UserProfileStorage.TableId getTableId() {
return tableId;
}
Expand Down Expand Up @@ -266,7 +276,7 @@ public void refresh(AjaxRequestTarget target) {
if (viewToggleModel.getObject() == ViewToggle.TABLE) {
target.add(get(ID_TABLE));
} else {
target.add(get(ID_TILES_CONTAINER), getTilesNavigation());
target.add(get(ID_TILES_CONTAINER), getTilesNavigation(), get(ID_FOOTER_CONTAINER));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.evolveum.midpoint.gui.impl.factory.wrapper;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractPredefinedActivationMappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CollectionRefSpecificationType;

import org.springframework.stereotype.Component;
Expand All @@ -27,7 +28,9 @@ public class NoEmptyValueContainerWrapperFactoryImpl<C extends Containerable> ex
public boolean match(ItemDefinition<?> def) {
return def instanceof PrismContainerDefinition && def.isMultiValue()
|| AbstractWorkItemOutputType.COMPLEX_TYPE.equals(def.getTypeName())
|| ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName());
|| ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName())
|| (def.getTypeClass() != null
&& AbstractPredefinedActivationMappingType.class.isAssignableFrom(def.getTypeClass()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,14 @@
package com.evolveum.midpoint.gui.impl.factory.wrapper;

import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext;
import com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext.AttributeMappingType;
import com.evolveum.midpoint.gui.api.prism.ItemStatus;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.impl.prism.wrapper.ResourceAttributeMappingValueWrapper;
import com.evolveum.midpoint.gui.impl.prism.wrapper.ResourceAttributeMappingWrapper;
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.prism.path.ItemPath;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Component;

/**
Expand Down

0 comments on commit cd14e94

Please sign in to comment.