Skip to content

Commit

Permalink
fix for MID-7954 - added new tabs for "construction" inducements, now…
Browse files Browse the repository at this point in the history
… there is:

* construction tab - with basic attributes,
* construction attributes tab - where the attribute mappings are shown and can be managed
* construction association tab - where association mappings are shown and can be managed

(cherry picked from commit 90e9035)
  • Loading branch information
katkav committed Aug 30, 2022
1 parent 6d3c923 commit 5c3e91d
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div wicket:id="basic" />
<div wicket:id="attributes" />
</wicket:panel>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
}
};
add(baseConstructionPanel);

ResourceAttributePanel attrsPanel = new ResourceAttributePanel(ID_ATTRIBUTES, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ConstructionType.F_ATTRIBUTE), null);
add(attrsPanel);

}

public ContainerPanelConfigurationType getConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
*/
package com.evolveum.midpoint.gui.impl.component;

import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.impl.prism.panel.ResourceAssociationPanel;
import com.evolveum.midpoint.gui.impl.prism.panel.ResourceAttributePanel;

import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -65,7 +69,7 @@ protected List<ITab> createTabs() {
AssignmentsUtil.AssignmentTypeType assignmentTypeType = AssignmentsUtil.getAssignmentType(getModelObject());
switch (assignmentTypeType) {
case CONSTRUCTION:
tabs.add(createConstructionTabs());
tabs.addAll(createConstructionTabs());
break;
case POLICY_RULE:
tabs.add(createTabs("AssignmentType.policyRule", AssignmentType.F_POLICY_RULE, PolicyRuleType.COMPLEX_TYPE));
Expand Down Expand Up @@ -224,17 +228,42 @@ public WebMarkupContainer createPanel(String panelId) {
};

}
private PanelTab createConstructionTabs() {
return new PanelTab(createStringResource("AssignmentType.construction")) {
private List<PanelTab> createConstructionTabs() {
List<PanelTab> constructionTabs = new ArrayList<>();

constructionTabs.add(new PanelTab(createStringResource("AssignmentType.construction")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new AssignmentConstructionPanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), AssignmentType.F_CONSTRUCTION), getConfig());
}
};
});

if (isInducement()) {
constructionTabs.add(new PanelTab(createStringResource("AssignmentDetailsPanel.construction.attribute")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAttributePanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE)), null);
}
});

constructionTabs.add(new PanelTab(createStringResource("AssignmentDetailsPanel.construction.association")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAssociationPanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ItemPath.create(AssignmentType.F_CONSTRUCTION, ConstructionType.F_ASSOCIATION)), null);
}
});
}
return constructionTabs;
// return createTabs("AssignmentType.construction", AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE);
}

private boolean isInducement() {
return AbstractRoleType.F_INDUCEMENT.equivalent(getModelObject().getPath().lastName());
}

private PanelTab createActivationTab() {
return new PanelTab(createStringResource("AssignmentType.activation")) {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2022 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.prism.panel;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.impl.component.MappingColumnPanel;
import com.evolveum.midpoint.gui.impl.page.admin.AbstractPageObjectDetails;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

import java.util.ArrayList;
import java.util.List;

public class ResourceAssociationPanel extends ItemRefinedPanel<ResourceObjectAssociationType> {

public ResourceAssociationPanel(String id, IModel<PrismContainerWrapper<ResourceObjectAssociationType>> model, ContainerPanelConfigurationType config) {
super(id, model, config);
}

@Override
protected List<IColumn<PrismContainerValueWrapper<ResourceObjectAssociationType>, String>> createAdditionalColumns() {
List<IColumn<PrismContainerValueWrapper<ResourceObjectAssociationType>, String>> columns = new ArrayList<>();

columns.add(new AbstractColumn<>(createStringResource("Outbound")) {

@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ResourceObjectAssociationType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> rowModel) {
IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ResourceObjectAssociationType.F_OUTBOUND);
cellItem.add(new MappingColumnPanel(componentId, mappingModel));
}
});

columns.add(new AbstractColumn<>(createStringResource("Inbound")) {

@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ResourceObjectAssociationType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> rowModel) {
IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ResourceObjectAssociationType.F_INBOUND);
cellItem.add(new MappingColumnPanel(componentId, mappingModel));
}
});
return columns;
}

@Override
protected boolean customEditItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ResourceObjectAssociationType>> rowModel, List<PrismContainerValueWrapper<ResourceObjectAssociationType>> listItems) {
if (getConfig() == null) {
return false;
}

AbstractPageObjectDetails parent = findParent(AbstractPageObjectDetails.class);
if (parent == null) {
return false;
}

ContainerPanelConfigurationType detailsPanel = new ContainerPanelConfigurationType();
detailsPanel.setPanelType("attributeDefinitionDetails");

PrismContainerValueWrapper<ResourceObjectAssociationType> attrDef;
if (rowModel != null) {
attrDef = rowModel.getObject();
} else {
attrDef = listItems.iterator().next();
}
// VirtualContainersSpecificationType virtualContainer = new VirtualContainersSpecificationType(getPrismContext());
detailsPanel.setPath(new ItemPathType(attrDef.getPath()));

// detailsPanel.getContainer().add(virtualContainer);

detailsPanel.setIdentifier("attributeDefinitionDetails");
DisplayType displayType = new DisplayType();
displayType.setLabel(new PolyStringType(attrDef.getDisplayName()));
IconType icon = new IconType();
icon.setCssClass("fa fa-navicon");
displayType.setIcon(icon);
detailsPanel.setDisplay(displayType);

getPageBase().getSessionStorage().setObjectDetailsStorage("details" + parent.getType().getSimpleName(), detailsPanel);

ResourceAssociationPanel.this.getConfig().getPanel().add(detailsPanel);
target.add(parent);
parent.replacePanel(detailsPanel, target);
return true;
}
}

0 comments on commit 5c3e91d

Please sign in to comment.