syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1459736 - in /syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console: pages/DisplayAttributesModalPage.java pages/panels/ResultSetPanel.java rest/SchemaRestClient.java
Date Fri, 22 Mar 2013 11:55:27 GMT
Author: ilgrosso
Date: Fri Mar 22 11:55:27 2013
New Revision: 1459736

URL: http://svn.apache.org/r1459736
Log:
[SYNCOPE-341] Refreshing schemas, dschemas and vschemas at Users page load

Modified:
    syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/DisplayAttributesModalPage.java
    syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java
    syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java

Modified: syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/DisplayAttributesModalPage.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/DisplayAttributesModalPage.java?rev=1459736&r1=1459735&r2=1459736&view=diff
==============================================================================
--- syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/DisplayAttributesModalPage.java
(original)
+++ syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/DisplayAttributesModalPage.java
Fri Mar 22 11:55:27 2013
@@ -29,8 +29,6 @@ import org.apache.commons.lang.ArrayUtil
 import org.apache.syncope.client.to.UserTO;
 import org.apache.syncope.console.commons.Constants;
 import org.apache.syncope.console.commons.PreferenceManager;
-import org.apache.syncope.console.rest.SchemaRestClient;
-import org.apache.syncope.types.AttributableType;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.form.AjaxButton;
@@ -66,105 +64,79 @@ public class DisplayAttributesModalPage 
         "attributes", "derivedAttributes", "virtualAttributes", "memberships", "resources",
         "serialVersionUID", "password", "propagationTOs"};
 
-    public static final List<String> DEFAULT_SELECTION = Arrays.asList(new String[]{"id",
"username", "status"});
+    public static final List<String> DEFAULT_SELECTION = Arrays.asList(new String[]
{"id", "username", "status"});
 
     @SpringBean
     private PreferenceManager prefMan;
 
-    /**
-     * Schema rest client.
-     */
-    @SpringBean
-    private SchemaRestClient schemaRestClient;
+    private final List<String> selectedDetails;
 
-    final private IModel<List<String>> dnames = new LoadableDetachableModel<List<String>>()
{
+    private final List<String> selectedSchemas;
 
-        private static final long serialVersionUID = 5275935387613157437L;
+    private final List<String> selectedVirSchemas;
 
-        @Override
-        protected List<String> load() {
+    private final List<String> selectedDerSchemas;
 
-            final List<String> details = new ArrayList<String>();
+    public DisplayAttributesModalPage(final PageReference pageRef, final ModalWindow window,
+            final List<String> schemaNames, final List<String> dSchemaNames,
final List<String> vSchemaNames) {
 
-            Class<?> clazz = UserTO.class;
+        super();
 
-            // loop on class and all superclasses searching for field
-            while (clazz != null && clazz != Object.class) {
-                for (Field field : clazz.getDeclaredFields()) {
-                    if (!ArrayUtils.contains(ATTRIBUTES_TO_HIDE, field.getName())) {
-                        details.add(field.getName());
-                    }
-                }
-                clazz = clazz.getSuperclass();
-            }
+        final IModel<List<String>> fnames = new LoadableDetachableModel<List<String>>()
{
 
-            Collections.reverse(details);
-            return details;
-        }
-    };
+            private static final long serialVersionUID = 5275935387613157437L;
 
-    final private IModel<List<String>> names = new LoadableDetachableModel<List<String>>()
{
+            @Override
+            protected List<String> load() {
 
-        private static final long serialVersionUID = 5275935387613157437L;
+                final List<String> details = new ArrayList<String>();
 
-        @Override
-        protected List<String> load() {
+                Class<?> clazz = UserTO.class;
 
-            List<String> schemas = schemaRestClient.getSchemaNames(AttributableType.USER);
+                // loop on class and all superclasses searching for field
+                while (clazz != null && clazz != Object.class) {
+                    for (Field field : clazz.getDeclaredFields()) {
+                        if (!ArrayUtils.contains(ATTRIBUTES_TO_HIDE, field.getName())) {
+                            details.add(field.getName());
+                        }
+                    }
+                    clazz = clazz.getSuperclass();
+                }
 
-            if (schemas == null) {
-                schemas = new ArrayList<String>();
+                Collections.reverse(details);
+                return details;
             }
+        };
 
-            return schemas;
-        }
-    };
-
-    final private IModel<List<String>> dsnames = new LoadableDetachableModel<List<String>>()
{
-
-        private static final long serialVersionUID = 5275935387613157437L;
-
-        @Override
-        protected List<String> load() {
+        final IModel<List<String>> names = new LoadableDetachableModel<List<String>>()
{
 
-            List<String> schemas = schemaRestClient.getDerivedSchemaNames(AttributableType.USER);
+            private static final long serialVersionUID = 5275935387613157437L;
 
-            if (schemas == null) {
-                schemas = new ArrayList<String>();
+            @Override
+            protected List<String> load() {
+                return schemaNames;
             }
+        };
 
-            return schemas;
-        }
-    };
-
-    final private IModel<List<String>> vsnames = new LoadableDetachableModel<List<String>>()
{
-
-        private static final long serialVersionUID = 5275935387613157437L;
-
-        @Override
-        protected List<String> load() {
+        final IModel<List<String>> dsnames = new LoadableDetachableModel<List<String>>()
{
 
-            List<String> schemas = schemaRestClient.getVirtualSchemaNames(AttributableType.USER);
+            private static final long serialVersionUID = 5275935387613157437L;
 
-            if (schemas == null) {
-                schemas = new ArrayList<String>();
+            @Override
+            protected List<String> load() {
+                return dSchemaNames;
             }
+        };
 
-            return schemas;
-        }
-    };
-
-    private final List<String> selectedDetails;
-
-    private final List<String> selectedSchemas;
-
-    private final List<String> selectedVirSchemas;
-
-    private final List<String> selectedDerSchemas;
+        final IModel<List<String>> vsnames = new LoadableDetachableModel<List<String>>()
{
 
-    public DisplayAttributesModalPage(final PageReference pageRef, final ModalWindow window)
{
+            private static final long serialVersionUID = 5275935387613157437L;
 
-        super();
+            @Override
+            protected List<String> load() {
+                return vSchemaNames;
+            }
+        };
 
         final Form form = new Form("form");
         form.setModel(new CompoundPropertyModel(this));
@@ -180,7 +152,7 @@ public class DisplayAttributesModalPage 
         final CheckGroup dgroup = new CheckGroup("dCheckGroup", new PropertyModel(this, "selectedDetails"));
         form.add(dgroup);
 
-        final ListView<String> details = new ListView<String>("details", dnames)
{
+        final ListView<String> details = new ListView<String>("details", fnames)
{
 
             private static final long serialVersionUID = 9101744072914090143L;
 
@@ -298,7 +270,7 @@ public class DisplayAttributesModalPage 
             }
 
             @Override
-            protected void onError(AjaxRequestTarget target, Form<?> form) {
+            protected void onError(final AjaxRequestTarget target, final Form<?> form)
{
                 target.add(feedbackPanel);
             }
         };

Modified: syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java?rev=1459736&r1=1459735&r2=1459736&view=diff
==============================================================================
--- syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java
(original)
+++ syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/pages/panels/ResultSetPanel.java
Fri Mar 22 11:55:27 2013
@@ -34,6 +34,7 @@ import org.apache.syncope.console.pages.
 import org.apache.syncope.console.pages.DisplayAttributesModalPage;
 import org.apache.syncope.console.pages.EditUserModalPage;
 import org.apache.syncope.console.pages.StatusModalPage;
+import org.apache.syncope.console.rest.SchemaRestClient;
 import org.apache.syncope.console.rest.UserRestClient;
 import org.apache.syncope.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink;
 import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn;
@@ -41,6 +42,7 @@ import org.apache.syncope.console.wicket
 import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.UserAttrColumn;
 import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
 import org.apache.syncope.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.types.AttributableType;
 import org.apache.wicket.Component;
 import org.apache.wicket.Page;
 import org.apache.wicket.PageReference;
@@ -119,6 +121,12 @@ public class ResultSetPanel extends Pane
     private UserRestClient restClient;
 
     /**
+     * Schema rest client.
+     */
+    @SpringBean
+    private SchemaRestClient schemaRestClient;
+
+    /**
      * Application preferences.
      */
     @SpringBean
@@ -186,14 +194,24 @@ public class ResultSetPanel extends Pane
      */
     private final BasePage page;
 
+    private final List<String> schemaNames;
+
+    private final List<String> dSchemaNames;
+
+    private final List<String> vSchemaNames;
+
     public <T extends AbstractAttributableTO> ResultSetPanel(final String id, final
boolean filtered,
             final NodeCond searchCond, final PageReference pageRef) {
-        super(id);
 
+        super(id);
         setOutputMarkupId(true);
 
         page = (BasePage) pageRef.getPage();
 
+        schemaNames = schemaRestClient.getSchemaNames(AttributableType.USER);
+        dSchemaNames = schemaRestClient.getDerivedSchemaNames(AttributableType.USER);
+        vSchemaNames = schemaRestClient.getVirtualSchemaNames(AttributableType.USER);
+
         this.filtered = filtered;
         this.filter = searchCond;
         this.feedbackPanel = page.getFeedbackPanel();
@@ -244,7 +262,8 @@ public class ResultSetPanel extends Pane
 
                     @Override
                     public Page createPage() {
-                        return new DisplayAttributesModalPage(page.getPageReference(), displaymodal);
+                        return new DisplayAttributesModalPage(page.getPageReference(), displaymodal,
+                                schemaNames, dSchemaNames, vSchemaNames);
                     }
                 });
 
@@ -355,15 +374,21 @@ public class ResultSetPanel extends Pane
         }
 
         for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_ATTRIBUTES_VIEW))
{
-            columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.schema));
+            if (schemaNames.contains(name)) {
+                columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.schema));
+            }
         }
 
         for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_DERIVED_ATTRIBUTES_VIEW))
{
-            columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.derivedSchema));
+            if (dSchemaNames.contains(name)) {
+                columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.derivedSchema));
+            }
         }
 
         for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW))
{
-            columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.virtualSchema));
+            if (vSchemaNames.contains(name)) {
+                columns.add(new UserAttrColumn(name, UserAttrColumn.SchemaType.virtualSchema));
+            }
         }
 
         // Add defaults in case of no selection

Modified: syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java?rev=1459736&r1=1459735&r2=1459736&view=diff
==============================================================================
--- syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
(original)
+++ syncope/branches/1_0_X/console/src/main/java/org/apache/syncope/console/rest/SchemaRestClient.java
Fri Mar 22 11:55:27 2013
@@ -100,7 +100,6 @@ public class SchemaRestClient extends Ab
      * @return List of derived schema names.
      */
     public List<String> getDerivedSchemaNames(final AttributableType type) {
-
         final List<String> userDerivedSchemasNames = new ArrayList<String>();
 
         try {
@@ -124,7 +123,6 @@ public class SchemaRestClient extends Ab
      * @return List of derived schemas.
      */
     public List<VirtualSchemaTO> getVirtualSchemas(final AttributableType type) {
-
         List<VirtualSchemaTO> userVirtualSchemas = null;
 
         try {



Mime
View raw message