Skip to content

Commit

Permalink
schema handling and attributes panel improvements, new enabled proper…
Browse files Browse the repository at this point in the history
…ty for mapping
  • Loading branch information
katkav committed May 20, 2021
1 parent c72e856 commit cadaf29
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 45 deletions.
Expand Up @@ -8,7 +8,7 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div wicket:id="mappings" class="row">
<div class="col-md-4" wicket:id="mappingEnabled"></div>
<div class="col-md-8" wicket:id="mapping"></div>
</div>
Expand Down
Expand Up @@ -9,23 +9,29 @@
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper;
import com.evolveum.midpoint.gui.impl.factory.panel.ItemRealValueModel;
import com.evolveum.midpoint.web.component.input.TriStateComboPanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.VariableBindingDefinitionType;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;

import java.util.List;

public class MappingColumnPanel extends BasePanel<PrismContainerValueWrapper<MappingType>> {
public class MappingColumnPanel extends BasePanel<PrismContainerWrapper<MappingType>> {

private static final String ID_MAPPING_ENABLED = "mappingEnabled";
private static final String ID_MAPPING = "mapping";
private static final String ID_MAPPINGS = "mappings";

public MappingColumnPanel(String id, IModel<PrismContainerValueWrapper<MappingType>> model) {
public MappingColumnPanel(String id, IModel<PrismContainerWrapper<MappingType>> model) {
super(id, model);
}

Expand All @@ -37,13 +43,28 @@ protected void onInitialize() {

private void initLayout() {

ReadOnlyModel<String> mappingDescription = new ReadOnlyModel<>(() -> {
ListView<PrismContainerValueWrapper<MappingType>> mappings = new ListView<>(ID_MAPPINGS, new PropertyModel<>(getModel(), "values")) {

@Override
protected void populateItem(ListItem<PrismContainerValueWrapper<MappingType>> item) {
TriStateComboPanel dropDownChoicePanel = new TriStateComboPanel(ID_MAPPING_ENABLED, new PropertyModel<>(new ItemRealValueModel<>(item.getModel()), MappingType.F_ENABLED.getLocalPart()));
item.add(dropDownChoicePanel);
Label label = new Label(ID_MAPPING, createMappingDescription(item.getModel()));
item.add(label);
}
};
add(mappings);

}

private IModel<String> createMappingDescription(IModel<PrismContainerValueWrapper<MappingType>> model) {
return new ReadOnlyModel<>(() -> {

if (getModelObject() == null) {
return null;
}

MappingType mappingType = getModelObject().getRealValue();
MappingType mappingType = model.getObject().getRealValue();
if (mappingType == null) {
return null;
}
Expand Down Expand Up @@ -76,12 +97,5 @@ private void initLayout() {

return target + "(" + strength + ")";
});

TriStateComboPanel dropDownChoicePanel = new TriStateComboPanel(ID_MAPPING_ENABLED, Model.of(true));
add(dropDownChoicePanel);

Label label = new Label(ID_MAPPING, mappingDescription);
add(label);

}
}
Expand Up @@ -66,7 +66,7 @@ private void initLayout() {

List<ITab> tabs = createTabs();
if (isAddDefaultPanel) {
tabs.add(addBasicContainerValuePanel());
tabs.add(0, addBasicContainerValuePanel());
}
TabbedPanel tabbedPanel = WebComponentUtil.createTabPanel(ID_DETAILS, getPageBase(), tabs, null);
tabbedPanel.setOutputMarkupId(true);
Expand Down
Expand Up @@ -8,6 +8,8 @@

import javax.annotation.PostConstruct;

import com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -35,7 +37,7 @@ public Integer getOrder() {

@Override
public <IW extends ItemWrapper<?, ?>> boolean match(IW wrapper) {
return ActivationType.F_LOCKOUT_STATUS.equals(wrapper.getItemName());
return wrapper instanceof PrismPropertyWrapper && ActivationType.F_LOCKOUT_STATUS.equals(wrapper.getItemName());
}

@Override
Expand Down
Expand Up @@ -92,18 +92,18 @@ protected List<IColumn<PrismContainerValueWrapper<ResourceAttributeDefinitionTyp
@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ResourceAttributeDefinitionType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ResourceAttributeDefinitionType>> rowModel) {
IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ResourceAttributeDefinitionType.F_OUTBOUND);
cellItem.add(new MappingColumnPanel(componentId, new PropertyModel<>(mappingModel, "value")));
cellItem.add(new MappingColumnPanel(componentId, mappingModel));
}
});

// columns.add(new AbstractColumn<>(createStringResource("Inbound")) {
//
// @Override
// public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ResourceAttributeDefinitionType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ResourceAttributeDefinitionType>> rowModel) {
// IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ResourceAttributeDefinitionType.F_INBOUND);
// cellItem.add(new MappingColumnPanel(componentId, new PropertyModel<>(mappingModel, "values")));
// }
// });
columns.add(new AbstractColumn<>(createStringResource("Inbound")) {

@Override
public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ResourceAttributeDefinitionType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ResourceAttributeDefinitionType>> rowModel) {
IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ResourceAttributeDefinitionType.F_INBOUND);
cellItem.add(new MappingColumnPanel(componentId, mappingModel));
}
});
return columns;
}
};
Expand Down
Expand Up @@ -9,6 +9,7 @@
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.DisplayNamePanel;
import com.evolveum.midpoint.gui.api.component.tabs.PanelTab;
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.impl.component.MultivalueContainerDetailsPanel;
Expand All @@ -20,9 +21,9 @@
import com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn;
import com.evolveum.midpoint.web.component.form.MidpointForm;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.prism.ItemVisibility;
import com.evolveum.midpoint.web.model.PrismContainerWrapperModel;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GlobalPolicyRuleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType;

Expand All @@ -31,7 +32,6 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -60,26 +60,7 @@ private void initLayout() {

@Override
protected MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> item) {
return new MultivalueContainerDetailsPanel<>(ID_ITEM_DETAILS, item.getModel(), true) {

@Override
protected @NotNull List<ITab> createTabs() {
List<ITab> tabs = new ArrayList<>();
tabs.add(new PanelTab(createStringResource("Attributes")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAttributePanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ResourceObjectTypeDefinitionType.F_ATTRIBUTE));
}
});
return tabs;
}

@Override
protected DisplayNamePanel<ResourceObjectTypeDefinitionType> createDisplayNamePanel(String displayNamePanelId) {
return new DisplayNamePanel<>(displayNamePanelId, new ItemRealValueModel<>(getModel()));
}
};
return createMultivalueContainerDetailsPanel(ID_ITEM_DETAILS, item.getModel());
}

@Override
Expand Down Expand Up @@ -125,4 +106,35 @@ public String getCssClass() {
private MultivalueContainerListPanelWithDetailsPanel<ResourceObjectTypeDefinitionType> getMultivalueContainerListPanel(){
return ((MultivalueContainerListPanelWithDetailsPanel<ResourceObjectTypeDefinitionType>)get(createComponentPath(ID_FORM, ID_TABLE)));
}

private MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> createMultivalueContainerDetailsPanel(String panelId, IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> model) {
return new MultivalueContainerDetailsPanel<>(panelId, model, true) {

@Override
protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
if (itemWrapper instanceof PrismContainerWrapper) {
return ItemVisibility.HIDDEN;
}
return ItemVisibility.AUTO;
}

@Override
protected @NotNull List<ITab> createTabs() {
List<ITab> tabs = new ArrayList<>();
tabs.add(new PanelTab(createStringResource("Attributes")) {

@Override
public WebMarkupContainer createPanel(String panelId) {
return new ResourceAttributePanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ResourceObjectTypeDefinitionType.F_ATTRIBUTE));
}
});
return tabs;
}

@Override
protected DisplayNamePanel<ResourceObjectTypeDefinitionType> createDisplayNamePanel(String displayNamePanelId) {
return new DisplayNamePanel<>(displayNamePanelId, new ItemRealValueModel<>(getModel()));
}
};
}
}
Expand Up @@ -10538,6 +10538,20 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="enabled" minOccurs="0" type="xsd:boolean" default="true">
<xsd:annotation>
<xsd:documentation>
<p>
Specifies if the mapping is enabled and is being evaluated. Default
value is true. It means, that each defined mapping is by default enabled.
To skip mapping evaluation, it has to be set to false.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:displayName>MappingType.enabled</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
Expand Down

0 comments on commit cadaf29

Please sign in to comment.