You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2020/02/12 11:11:29 UTC

[syncope] branch 2_1_X updated: [SYNCOPE-1476] keep code aligned between 'membership' and 'own' plain attributes

This is an automated email from the ASF dual-hosted git repository.

fmartelli pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_1_X by this push:
     new abdb195  [SYNCOPE-1476] keep code aligned between 'membership' and 'own' plain attributes
abdb195 is described below

commit abdb19555d906d9b0a1aafd527e3ecd4756464db
Author: fmartelli <fa...@gmail.com>
AuthorDate: Wed Feb 12 12:10:53 2020 +0100

    [SYNCOPE-1476] keep code aligned between 'membership' and 'own' plain attributes
---
 .../client/console/wizards/any/PlainAttrs.java     | 38 ++++------------------
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
index 488e40e..03d7ee8 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
@@ -25,9 +25,6 @@ import java.util.Map;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.client.console.wicket.markup.html.bootstrap.tabs.Accordion;
-import org.apache.syncope.client.console.wicket.markup.html.form.AbstractFieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
-import org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.common.lib.EntityTOUtils;
 import org.apache.syncope.common.lib.to.AnyObjectTO;
@@ -170,11 +167,11 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
 
     @Override
     protected void setAttrs(final MembershipTO membershipTO) {
-        Map<String, AttrTO> attrMap =
-                GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent()
-                ? EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO).
-                        getMembership(membershipTO.getGroupKey()).get().getPlainAttrs())
-                : new HashMap<>();
+        Map<String, AttrTO> attrMap = GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).
+                isPresent()
+                        ? EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO).
+                                getMembership(membershipTO.getGroupKey()).get().getPlainAttrs())
+                        : new HashMap<>();
 
         List<AttrTO> attrs = membershipSchemas.get(membershipTO.getGroupKey()).values().stream().map(schema -> {
             AttrTO attrTO = new AttrTO();
@@ -233,30 +230,7 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> {
                 @Override
                 @SuppressWarnings({ "unchecked", "rawtypes" })
                 protected void populateItem(final ListItem<AttrTO> item) {
-                    AttrTO attrTO = item.getModelObject();
-
-                    AbstractFieldPanel<?> panel = getFieldPanel(schemas.get(attrTO.getSchema()));
-                    if (mode == AjaxWizard.Mode.TEMPLATE || !schemas.get(attrTO.getSchema()).isMultivalue()) {
-                        FieldPanel.class.cast(panel).setNewModel(attributableTO.getObject(), attrTO.getSchema());
-                    } else {
-                        // SYNCOPE-1476 set form as multipart to properly manage membership attributes
-                        panel = new MultiFieldPanel.Builder<>(new ListModel<String>() {
-
-                            private static final long serialVersionUID = -1765231556272935141L;
-
-                            @Override
-                            public List<String> getObject() {
-                                return attributableTO.getObject().getPlainAttr(attrTO.getSchema()).get().getValues();
-                            }
-                        }).build("panel",
-                                attrTO.getSchema(),
-                                FieldPanel.class.cast(panel)).setFormAsMultipart(true);
-                        // SYNCOPE-1215 the entire multifield panel must be readonly, not only its field
-                        ((MultiFieldPanel) panel).setReadOnly(schemas.get(attrTO.getSchema()).isReadonly());
-                    }
-                    item.add(panel);
-
-                    setExternalAction(attrTO, panel);
+                    setPanel(schemas, item, false);
                 }
             });
         }