Repository: syncope
Updated Branches:
  refs/heads/master bc1a14275 -> 1ffc62e57


[SYNCOPE-156] providing aux classes selection


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/1ffc62e5
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/1ffc62e5
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/1ffc62e5

Branch: refs/heads/master
Commit: 1ffc62e5757276d108ba7ac568f585f9c1fa298f
Parents: bc1a142
Author: fmartelli <[email protected]>
Authored: Wed Nov 18 19:07:52 2015 +0100
Committer: fmartelli <[email protected]>
Committed: Wed Nov 18 19:07:52 2015 +0100

----------------------------------------------------------------------
 .../console/wizards/any/AbstractAttrs.java      |  39 +++++
 .../console/wizards/any/AnyWizardBuilder.java   |   1 +
 .../client/console/wizards/any/AuxClasses.java  |  60 ++++++++
 .../client/console/wizards/any/DerAttrs.java    | 144 +++++++++---------
 .../client/console/wizards/any/PlainAttrs.java  |  48 +++---
 .../client/console/wizards/any/VirAttrs.java    | 146 +++++++++----------
 .../client/console/wizards/any/AuxClasses.html  |  26 ++++
 .../client/console/wizards/any/DerAttrs.html    |  25 +---
 .../client/console/wizards/any/PlainAttrs.html  |  39 ++---
 .../client/console/wizards/any/VirAttrs.html    |  25 +---
 10 files changed, 329 insertions(+), 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
new file mode 100644
index 0000000..4413763
--- /dev/null
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrs.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wizards.any;
+
+import org.apache.syncope.client.console.rest.AnyTypeRestClient;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.wicket.extensions.wizard.WizardStep;
+
+public abstract class AbstractAttrs extends WizardStep {
+
+    private static final long serialVersionUID = -5387344116983102292L;
+
+    protected final SchemaRestClient schemaRestClient = new SchemaRestClient();
+
+    protected final AnyTypeRestClient anyTypeRestClient = new 
AnyTypeRestClient();
+
+    protected final AnyTO entityTO;
+
+    public AbstractAttrs(final AnyTO entityTO) {
+        this.entityTO = entityTO;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
index 8af18e5..a722223 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
@@ -56,6 +56,7 @@ public class AnyWizardBuilder<T extends AnyTO> extends 
AjaxWizardBuilder<T> impl
     @Override
     protected WizardModel buildModelSteps(final T modelObject, final 
WizardModel wizardModel) {
         addOptionalDetailsPanel(modelObject, wizardModel);
+        wizardModel.add(new AuxClasses(modelObject, anyTypeClasses.toArray(new 
String[] {})));
         wizardModel.add(new PlainAttrs(modelObject, null, Mode.ADMIN, 
anyTypeClasses.toArray(new String[] {})));
         wizardModel.add(new DerAttrs(modelObject, anyTypeClasses.toArray(new 
String[] {})));
         wizardModel.add(new VirAttrs(modelObject, anyTypeClasses.toArray(new 
String[] {})));

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
new file mode 100644
index 0000000..a33df7c
--- /dev/null
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AuxClasses.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.wizards.any;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.syncope.client.console.SyncopeConsoleSession;
+import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.rest.api.service.AnyTypeClassService;
+import org.apache.wicket.extensions.wizard.WizardStep;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.util.ListModel;
+
+public class AuxClasses extends WizardStep {
+
+    private static final long serialVersionUID = 552437609667518888L;
+
+    private final AnyTO entityTO;
+
+    public <T extends AnyTO> AuxClasses(final T entityTO, final String... 
anyTypeClass) {
+        this.setOutputMarkupId(true);
+        this.entityTO = entityTO;
+
+        final AnyTypeClassService service = 
SyncopeConsoleSession.get().getService(AnyTypeClassService.class);
+
+        final List<String> current = Arrays.asList(anyTypeClass);
+
+        final List<String> choices = new ArrayList<String>();
+        for (AnyTypeClassTO aux : service.list()) {
+            if (!current.contains(aux.getKey())) {
+                choices.add(aux.getKey());
+            }
+        }
+
+        add(new AjaxPalettePanel<>(
+                "auxClasses",
+                new PropertyModel<List<String>>(this.entityTO, "auxClasses"),
+                new ListModel<>(choices),
+                true).setOutputMarkupId(true));
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java
index fa1e21b..1b08760 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java
@@ -19,120 +19,120 @@
 package org.apache.syncope.client.console.wizards.any;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.DerSchemaTO;
 import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.wicket.extensions.wizard.WizardStep;
+import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.MarkupStream;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.list.ListItem;
 import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.LoadableDetachableModel;
 import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.model.ResourceModel;
 
-public class DerAttrs extends WizardStep {
+public class DerAttrs extends AbstractAttrs {
 
     private static final long serialVersionUID = -5387344116983102292L;
 
-    private final SchemaRestClient schemaRestClient = new SchemaRestClient();
-
     public <T extends AnyTO> DerAttrs(final T entityTO, final String... 
anyTypeClass) {
-
+        super(entityTO);
         setOutputMarkupId(true);
 
-        final IModel<List<String>> derSchemas = new 
LoadableDetachableModel<List<String>>() {
+        final LoadableDetachableModel<List<AttrTO>> derAttrTOs = new 
LoadableDetachableModel<List<AttrTO>>() {
 
-            private static final long serialVersionUID = 5275935387613157437L;
+            private static final long serialVersionUID = 1L;
 
             @Override
-            protected List<String> load() {
-                List<DerSchemaTO> derSchemaNames = 
schemaRestClient.getSchemas(SchemaType.DERIVED, anyTypeClass);
+            protected List<AttrTO> load() {
+                final List<String> classes = CollectionUtils.collect(
+                        
anyTypeRestClient.getAnyTypeClass(entityTO.getAuxClasses().toArray(new String[] 
{})),
+                        new Transformer<AnyTypeClassTO, String>() {
+
+                            @Override
+                            public String transform(final AnyTypeClassTO 
input) {
+                                return input.getKey();
+                            }
+                        }, new ArrayList<String>(Arrays.asList(anyTypeClass)));
+
+                final List<DerSchemaTO> derSchemas
+                        = schemaRestClient.getSchemas(SchemaType.DERIVED, 
classes.toArray(new String[] {}));
 
-                return new ArrayList<>(CollectionUtils.collect(derSchemaNames, 
new Transformer<DerSchemaTO, String>() {
+                final Map<String, AttrTO> currents = entityTO.getDerAttrMap();
+                entityTO.getDerAttrs().clear();
+
+                return CollectionUtils.collect(derSchemas, new 
Transformer<DerSchemaTO, AttrTO>() {
 
                     @Override
-                    public String transform(final DerSchemaTO input) {
-                        return input.getKey();
+                    public AttrTO transform(final DerSchemaTO input) {
+                        AttrTO attrTO = currents.get(input.getKey());
+                        if (attrTO == null) {
+                            attrTO = new AttrTO();
+                            attrTO.setSchema(input.getKey());
+                        }
+                        return attrTO;
                     }
-                }));
+                }, new ArrayList<>(entityTO.getDerAttrs()));
             }
         };
 
-        final Map<String, AttrTO> derAttrMap = entityTO.getDerAttrMap();
-        CollectionUtils.collect(derSchemas.getObject(), new 
Transformer<String, AttrTO>() {
+        final WebMarkupContainer attributesContainer = new 
WebMarkupContainer("derAttrContainer");
+        attributesContainer.setOutputMarkupId(true);
+        add(attributesContainer);
+
+        ListView<AttrTO> attributes = new ListView<AttrTO>("attrs", 
derAttrTOs) {
+
+            private static final long serialVersionUID = 9101744072914090143L;
 
             @Override
-            public AttrTO transform(final String input) {
-                AttrTO attrTO = derAttrMap.get(input);
-                if (attrTO == null) {
-                    attrTO = new AttrTO();
-                    attrTO.setSchema(input);
+            public void renderHead(final IHeaderResponse response) {
+                super.renderHead(response);
+                if (derAttrTOs.getObject().isEmpty()) {
+                    response.render(OnDomReadyHeaderItem.forScript(
+                            
String.format("$('#emptyPlaceholder').append(\"%s\")", 
getString("attribute.empty.list"))));
                 }
-                return attrTO;
             }
-        }, entityTO.getDerAttrs());
-
-        final Fragment fragment;
-        if (entityTO.getDerAttrs().isEmpty()) {
-            // show empty list message
-            fragment = new Fragment("content", "empty", this);
-        } else {
-            fragment = new Fragment("content", "attributes", this);
-
-            final WebMarkupContainer attributesContainer = new 
WebMarkupContainer("derAttrContainer");
-            attributesContainer.setOutputMarkupId(true);
-            fragment.add(attributesContainer);
 
-            ListView<AttrTO> attributes = new ListView<AttrTO>("attrs",
-                    new PropertyModel<List<AttrTO>>(entityTO, "derAttrs") {
-
-                        private static final long serialVersionUID = 1L;
-
-                        @Override
-                        public List<AttrTO> getObject() {
-                            return new ArrayList<>(entityTO.getDerAttrs());
-                        }
-
-                    }) {
-
-                        private static final long serialVersionUID = 
9101744072914090143L;
-
-                        @Override
-                        protected void populateItem(final ListItem<AttrTO> 
item) {
-                            final AttrTO attrTO = item.getModelObject();
-
-                            final IModel<String> model;
-                            final List<String> values = attrTO.getValues();
-                            if (values == null || values.isEmpty()) {
-                                model = new 
ResourceModel("derived.emptyvalue.message", StringUtils.EMPTY);
-                            } else {
-                                model = new Model<String>(values.get(0));
-                            }
+            @Override
+            public void onComponentTagBody(final MarkupStream markupStream, 
final ComponentTag openTag) {
+                super.onComponentTagBody(markupStream, openTag);
+                openTag.put("class", "empty");
+            }
 
-                            final AjaxTextFieldPanel panel = new 
AjaxTextFieldPanel(
-                                    "panel", attrTO.getSchema(), model, false);
+            @Override
+            protected void populateItem(final ListItem<AttrTO> item) {
+                final AttrTO attrTO = item.getModelObject();
+
+                final IModel<String> model;
+                final List<String> values = attrTO.getValues();
+                if (values == null || values.isEmpty()) {
+                    model = new ResourceModel("derived.emptyvalue.message", 
StringUtils.EMPTY);
+                } else {
+                    model = new Model<String>(values.get(0));
+                }
 
-                            panel.setEnabled(false);
-                            panel.setRequired(true);
-                            panel.setOutputMarkupId(true);
-                            item.add(panel);
+                final AjaxTextFieldPanel panel = new AjaxTextFieldPanel(
+                        "panel", attrTO.getSchema(), model, false);
 
-                        }
-                    };
-            attributesContainer.add(attributes);
-        }
+                panel.setEnabled(false);
+                panel.setRequired(true);
+                panel.setOutputMarkupId(true);
+                item.add(panel);
 
-        add(fragment);
+            }
+        };
+        attributesContainer.add(attributes);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java
----------------------------------------------------------------------
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 2ab5c6f..3aecf61 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
@@ -19,6 +19,7 @@
 package org.apache.syncope.client.console.wizards.any;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
@@ -26,10 +27,11 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.syncope.client.console.commons.JexlHelpUtils;
 import org.apache.syncope.client.console.commons.Mode;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
@@ -40,56 +42,58 @@ import 
org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel
 import 
org.apache.syncope.client.console.wicket.markup.html.form.SpinnerFieldPanel;
 import org.apache.syncope.common.lib.SyncopeConstants;
 import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.PlainSchemaTO;
 import org.apache.syncope.common.lib.types.AttrSchemaType;
 import org.apache.syncope.common.lib.types.SchemaType;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
-import org.apache.wicket.extensions.wizard.WizardStep;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.IChoiceRenderer;
 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.LoadableDetachableModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.model.PropertyModel;
 
-public class PlainAttrs extends WizardStep {
+public class PlainAttrs extends AbstractAttrs {
 
     private static final long serialVersionUID = 552437609667518888L;
 
-    private final SchemaRestClient schemaRestClient = new SchemaRestClient();
-
-    private final AnyTO entityTO;
-
     private final Mode mode;
 
     private Map<String, PlainSchemaTO> schemas = new LinkedHashMap<>();
 
-    private final String[] anyTypeClass;
-
     public <T extends AnyTO> PlainAttrs(
             final T entityTO, final Form<?> form, final Mode mode, final 
String... anyTypeClass) {
+        super(entityTO);
         this.setOutputMarkupId(true);
 
-        this.entityTO = entityTO;
         this.mode = mode;
-        this.anyTypeClass = anyTypeClass;
 
-        setSchemas();
-        setAttrs();
-
-        add(new ListView<AttrTO>("schemas", new 
PropertyModel<List<AttrTO>>(entityTO, "plainAttrs") {
+        final LoadableDetachableModel<List<AttrTO>> plainAttrTOs = new 
LoadableDetachableModel<List<AttrTO>>() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public List<AttrTO> getObject() {
-                return new ArrayList<>(super.getObject());
+            protected List<AttrTO> load() {
+                setSchemas(CollectionUtils.collect(
+                        
anyTypeRestClient.getAnyTypeClass(entityTO.getAuxClasses().toArray(new String[] 
{})),
+                        new Transformer<AnyTypeClassTO, String>() {
+
+                            @Override
+                            public String transform(final AnyTypeClassTO 
input) {
+                                return input.getKey();
+                            }
+                        }, new 
ArrayList<String>(Arrays.asList(anyTypeClass))));
+                setAttrs();
+                return new ArrayList<>(entityTO.getPlainAttrs());
             }
+        };
 
-        }) {
+        add(new ListView<AttrTO>("schemas", plainAttrTOs) {
 
             private static final long serialVersionUID = 9101744072914090143L;
 
@@ -121,14 +125,14 @@ public class PlainAttrs extends WizardStep {
                                     panel));
                 }
             }
-        }
-        );
+        });
     }
 
-    private void setSchemas() {
+    private void setSchemas(final List<String> anyTypeClasses) {
 
         AttrTO attrLayout = null;
-        final List<PlainSchemaTO> schemaTOs = 
schemaRestClient.getSchemas(SchemaType.PLAIN, anyTypeClass);
+        final List<PlainSchemaTO> schemaTOs
+                = schemaRestClient.getSchemas(SchemaType.PLAIN, 
anyTypeClasses.toArray(new String[] {}));
 
         schemas.clear();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
index 048cb9a..7f45501 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java
@@ -19,123 +19,113 @@
 package org.apache.syncope.client.console.wizards.any;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeMap;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Transformer;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.rest.SchemaRestClient;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
 import 
org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel;
 import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
 import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.VirSchemaTO;
 import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.wicket.extensions.wizard.WizardStep;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.list.ListItem;
 import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.LoadableDetachableModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.model.PropertyModel;
 
-public class VirAttrs extends WizardStep {
+public class VirAttrs extends AbstractAttrs {
 
     private static final long serialVersionUID = -7982691107029848579L;
 
-    private SchemaRestClient schemaRestClient = new SchemaRestClient();
-
-    private final Map<String, VirSchemaTO> schemas = new TreeMap<String, 
VirSchemaTO>();
-
     public <T extends AnyTO> VirAttrs(final T entityTO, final String... 
anyTypeClass) {
+        super(entityTO);
         this.setOutputMarkupId(true);
 
-        final IModel<List<String>> virSchemas = new 
LoadableDetachableModel<List<String>>() {
+        final LoadableDetachableModel<List<AttrTO>> virAttrTOs = new 
LoadableDetachableModel<List<AttrTO>>() {
 
-            private static final long serialVersionUID = 5275935387613157437L;
+            private static final long serialVersionUID = 1L;
 
             @Override
-            protected List<String> load() {
-                List<VirSchemaTO> schemaTOs = 
schemaRestClient.getSchemas(SchemaType.VIRTUAL, anyTypeClass);
-
-                schemas.clear();
-
-                for (VirSchemaTO schemaTO : schemaTOs) {
-                    schemas.put(schemaTO.getKey(), schemaTO);
-                }
+            protected List<AttrTO> load() {
+                final List<String> classes = CollectionUtils.collect(
+                        
anyTypeRestClient.getAnyTypeClass(entityTO.getAuxClasses().toArray(new String[] 
{})),
+                        new Transformer<AnyTypeClassTO, String>() {
+
+                            @Override
+                            public String transform(final AnyTypeClassTO 
input) {
+                                return input.getKey();
+                            }
+                        }, new ArrayList<String>(Arrays.asList(anyTypeClass)));
+
+                final List<VirSchemaTO> virSchemas
+                        = schemaRestClient.getSchemas(SchemaType.VIRTUAL, 
classes.toArray(new String[] {}));
+
+                final Map<String, AttrTO> currents = entityTO.getVirAttrMap();
+                entityTO.getVirAttrs().clear();
+
+                return CollectionUtils.collect(virSchemas, new 
Transformer<VirSchemaTO, AttrTO>() {
+
+                    @Override
+                    public AttrTO transform(final VirSchemaTO input) {
+                        AttrTO attrTO = currents.get(input.getKey());
+                        if (attrTO == null) {
+                            attrTO = new AttrTO();
+                            attrTO.setSchema(input.getKey());
+                            attrTO.getValues().add(StringUtils.EMPTY);
+                        } else if (attrTO.getValues().isEmpty()) {
+                            attrTO.getValues().add("");
+                        }
 
-                return new ArrayList<>(schemas.keySet());
+                        attrTO.setReadonly(input.isReadonly());
+                        return attrTO;
+                    }
+                }, new ArrayList<>(entityTO.getVirAttrs()));
             }
         };
 
-        final Map<String, AttrTO> virAttrMap = entityTO.getVirAttrMap();
-        CollectionUtils.collect(virSchemas.getObject(), new 
Transformer<String, AttrTO>() {
+        final WebMarkupContainer attributesContainer = new 
WebMarkupContainer("virAttrContainer");
+        attributesContainer.setOutputMarkupId(true);
+        add(attributesContainer);
+
+        ListView<AttrTO> attributes = new ListView<AttrTO>("attrs", 
virAttrTOs) {
+
+            private static final long serialVersionUID = 9101744072914090143L;
 
             @Override
-            public AttrTO transform(final String input) {
-                AttrTO attrTO = virAttrMap.get(input);
-                if (attrTO == null) {
-                    attrTO = new AttrTO();
-                    attrTO.setSchema(input);
-                    attrTO.getValues().add(StringUtils.EMPTY);
-                } else if (attrTO.getValues().isEmpty()) {
-                    attrTO.getValues().add("");
+            public void renderHead(final IHeaderResponse response) {
+                super.renderHead(response);
+                if (virAttrTOs.getObject().isEmpty()) {
+                    response.render(OnDomReadyHeaderItem.forScript(
+                            
String.format("$('#emptyPlaceholder').append(\"%s\")", 
getString("attribute.empty.list"))));
                 }
-
-                return attrTO;
             }
-        }, entityTO.getVirAttrs());
-
-        final Fragment fragment;
-        if (entityTO.getVirAttrs().isEmpty()) {
-            // show empty list message
-            fragment = new Fragment("content", "empty", this);
-        } else {
-            fragment = new Fragment("content", "attributes", this);
-
-            final WebMarkupContainer attributesContainer = new 
WebMarkupContainer("virAttrContainer");
-            attributesContainer.setOutputMarkupId(true);
-            fragment.add(attributesContainer);
 
-            ListView<AttrTO> attributes = new ListView<AttrTO>("attrs",
-                    new PropertyModel<List<AttrTO>>(entityTO, "virAttrs") {
-
-                        private static final long serialVersionUID = 1L;
-
-                        @Override
-                        public List<AttrTO> getObject() {
-                            return new ArrayList<>(entityTO.getVirAttrs());
-                        }
-
-                    }) {
-
-                        private static final long serialVersionUID = 
9101744072914090143L;
-
-                        @Override
-                        @SuppressWarnings("unchecked")
-                        protected void populateItem(final ListItem<AttrTO> 
item) {
-                            AttrTO attrTO = item.getModelObject();
-                            final VirSchemaTO schema = 
schemas.get(attrTO.getSchema());
-
-                            attrTO.setReadonly(schema.isReadonly());
+            @Override
+            @SuppressWarnings("unchecked")
+            protected void populateItem(final ListItem<AttrTO> item) {
+                AttrTO attrTO = item.getModelObject();
 
-                            final AjaxTextFieldPanel panel = new 
AjaxTextFieldPanel(
-                                    "panel", attrTO.getSchema(), new 
Model<String>(), false);
+                attrTO.setReadonly(attrTO.isReadonly());
 
-                            item.add(new MultiFieldPanel.Builder<String>(
-                                            new 
PropertyModel<List<String>>(attrTO, "values")).build(
-                                            "panel",
-                                            schema.getKey(),
-                                            
panel).setEnabled(!schema.isReadonly()));
-                        }
-                    };
+                final AjaxTextFieldPanel panel = new AjaxTextFieldPanel(
+                        "panel", attrTO.getSchema(), new Model<String>(), 
false);
 
-            attributesContainer.add(attributes);
-        }
+                item.add(new MultiFieldPanel.Builder<String>(
+                        new PropertyModel<List<String>>(attrTO, 
"values")).build(
+                                "panel",
+                                attrTO.getSchema(),
+                                panel).setEnabled(!attrTO.isReadonly()));
+            }
+        };
 
-        add(fragment);
+        attributesContainer.add(attributes);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AuxClasses.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AuxClasses.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AuxClasses.html
new file mode 100644
index 0000000..b38ead8
--- /dev/null
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/AuxClasses.html
@@ -0,0 +1,26 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org";>
+  <head><title></title></head>
+  <body>
+    <wicket:panel>
+      <span wicket:id="auxClasses">[AUX]</span>
+    </wicket:panel>
+  </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/DerAttrs.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/DerAttrs.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/DerAttrs.html
index 6b17a06..defa627 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/DerAttrs.html
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/DerAttrs.html
@@ -16,27 +16,18 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org"; 
xmlns:message="http://xmlns.jcp.org/jsf/composite";>
+<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org"; >
   <head><title></title></head>
   <body>
     <wicket:panel>
-      <span wicket:id="content">[CONTENT]</span>
-      
-      <wicket:fragment wicket:id="empty">
-        <div class="attribute.empty.list">
-          <wicket:message key="attribute.empty.list"/>
+      <div id="emptyPlaceholder"/>
+      <div wicket:id="derAttrContainer">
+        <div class="form-group" wicket:id="attrs">
+          <span wicket:id="panel">
+            [panel for dynamic input type markup]
+          </span>
         </div>
-      </wicket:fragment>
-      
-      <wicket:fragment wicket:id="attributes">
-        <div wicket:id="derAttrContainer">
-          <div class="form-group" wicket:id="attrs">
-            <span wicket:id="panel">
-              [panel for dynamic input type markup]
-            </span>
-          </div>
-        </div>
-      </wicket:fragment>
+      </div>
     </wicket:panel>
   </body>
 </html>

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PlainAttrs.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PlainAttrs.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PlainAttrs.html
index 52f6321..cfad334 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PlainAttrs.html
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/PlainAttrs.html
@@ -17,24 +17,27 @@ specific language governing permissions and limitations
 under the License.
 -->
 <html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org";>
-  <wicket:panel>
-    <div wicket:id="schemas">
-      <div class="form-group">
-        <span wicket:id="panel">
-          [panel for dynamic input type markup]
-        </span>
-        <a class="tooltips" wicket:id="questionMarkJexlHelp" href="#" 
alt="Click to help" title="Click to help">
-          <img src="img/help.png"/>
-          <span wicket:id="jexlHelp" class="tooltips">
-            <wicket:message key="jexl_info"/>
-            <ul>
-              <li><wicket:message key="jexl_ex1"/></li>
-              <li><wicket:message key="jexl_ex2"/></li>
-            </ul>
-            <a href="#" wicket:id="jexlLink" target="_blank"><wicket:message 
key="jexl_syntax_url"/></a>
+  <head><title></title></head>
+  <body>
+    <wicket:panel>
+      <div wicket:id="schemas">
+        <div class="form-group">
+          <span wicket:id="panel">
+            [panel for dynamic input type markup]
           </span>
-        </a>
+          <a class="tooltips" wicket:id="questionMarkJexlHelp" href="#" 
alt="Click to help" title="Click to help">
+            <img src="img/help.png"/>
+            <span wicket:id="jexlHelp" class="tooltips">
+              <wicket:message key="jexl_info"/>
+              <ul>
+                <li><wicket:message key="jexl_ex1"/></li>
+                <li><wicket:message key="jexl_ex2"/></li>
+              </ul>
+              <a href="#" wicket:id="jexlLink" target="_blank"><wicket:message 
key="jexl_syntax_url"/></a>
+            </span>
+          </a>
+        </div>
       </div>
-    </div>
-  </wicket:panel>
+    </wicket:panel>
+  </body>
 </html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/syncope/blob/1ffc62e5/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/VirAttrs.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/VirAttrs.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/VirAttrs.html
index c73710d..a0d9eb3 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/VirAttrs.html
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/wizards/any/VirAttrs.html
@@ -16,27 +16,18 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org"; 
xmlns:message="http://xmlns.jcp.org/jsf/composite";>
+<html xmlns="http://www.w3.org/1999/xhtml"; 
xmlns:wicket="http://wicket.apache.org"; >
   <head><title></title></head>
   <body>
     <wicket:panel>
-      <span wicket:id="content">[CONTENT]</span>
-
-      <wicket:fragment wicket:id="empty">
-        <div class="attribute.empty.list">
-          <wicket:message key="attribute.empty.list"/>
-        </div>
-      </wicket:fragment>
-
-      <wicket:fragment wicket:id="attributes">
-        <div wicket:id="virAttrContainer">
-          <div class="form-group" wicket:id="attrs">
-            <span wicket:id="panel">
-              [panel for dynamic input type markup]
-            </span>
-          </div>
+      <div id="emptyPlaceholder"/>
+      <div wicket:id="virAttrContainer">
+        <div class="form-group" wicket:id="attrs">
+          <span wicket:id="panel">
+            [panel for dynamic input type markup]
+          </span>
         </div>
-      </wicket:fragment>
+      </div>
     </wicket:panel>
   </body>
 </html>

Reply via email to