[gatein-commits] gatein SVN: r7868 - in portal/trunk/component/portal/src: test/java/org/exoplatform/portal/config and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 25 06:40:10 EDT 2011


Author: haint
Date: 2011-10-25 06:40:10 -0400 (Tue, 25 Oct 2011)
New Revision: 7868

Modified:
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
   portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
Log:
GTNPORTAL-2193 Cannot store Dashboard portlet attributes at the first time

Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	2011-10-25 10:36:54 UTC (rev 7867)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	2011-10-25 10:40:10 UTC (rev 7868)
@@ -311,6 +311,13 @@
                boolean showMode = attrs.getValue(MappedAttributes.SHOW_MODE, false);
                boolean showWindowState = attrs.getValue(MappedAttributes.SHOW_WINDOW_STATE, false);
                String theme = attrs.getValue(MappedAttributes.THEME, null);
+               
+               Described described = srcContainer.adapt(Described.class);
+               
+               String id = attrs.getValue(MappedAttributes.ID, null);
+               String icon = attrs.getValue(MappedAttributes.ICON, null);
+               String width = attrs.getValue(MappedAttributes.WIDTH, null);
+               String height = attrs.getValue(MappedAttributes.HEIGHT, null);
 
                //
                List<String> a = Collections.singletonList(UserACL.EVERYONE);
@@ -325,16 +332,16 @@
                   component.getName(),
                   ApplicationType.PORTLET,
                   state,
-                  null,
-                  null,
-                  null,
-                  null,
+                  id,
+                  described.getName(),
+                  icon,
+                  described.getDescription(),
                   showInfoBar,
                   showWindowState,
                   showMode,
                   theme,
-                  null,
-                  null,
+                  width,
+                  height,
                   Collections.<String, String>emptyMap(),
                   a);
             }
@@ -533,6 +540,8 @@
       for (ModelData srcChild : src.getChildren())
       {
          String srcChildId = srcChild.getStorageId();
+         //Flag variable, become non null if and only if we are saving a transient dashboard
+         ApplicationData<?> transientDashboardData  = null;
 
          // Replace dashboard application by container if needed
          // this should be removed once we make the dashboard as first class
@@ -564,20 +573,36 @@
                   else
                   {
                      data = DashboardData.INITIAL_DASHBOARD;
+                     transientDashboardData = (ApplicationData<?>)srcChild;
                   }
 
                   //
+                  String icon = data.getIcon();
+                  if(icon == null) icon = app.getIcon();
+                  
+                  String title = data.getTitle();
+                  if(title == null) title = app.getTitle();
+                  
+                  String description = data.getDescription();
+                  if(description == null) description = app.getDescription();
+                  
+                  String width = data.getWidth();
+                  if(width == null) width = app.getWidth();
+                  
+                  String height = data.getHeight();
+                  if(height == null) height = app.getHeight();
+                  
                   data = new DashboardData(
                      data.getStorageId(),
                      data.getId(),
                      data.getName(),
-                     data.getIcon(),
+                     icon,
                      data.getTemplate(),
                      data.getFactoryId(),
-                     data.getTitle(),
-                     data.getDescription(),
-                     data.getWidth(),
-                     data.getHeight(),
+                     title,
+                     description,
+                     width,
+                     height,
                      app.getAccessPermissions(),
                      data.getChildren()
                   );
@@ -667,6 +692,14 @@
          }
 
          //
+         if(transientDashboardData != null)
+         {
+            Attributes attrs = dstChild.getAttributes();
+            attrs.setValue(MappedAttributes.SHOW_INFO_BAR, transientDashboardData.isShowInfoBar());
+            attrs.setValue(MappedAttributes.SHOW_MODE, transientDashboardData.isShowApplicationMode());
+            attrs.setValue(MappedAttributes.SHOW_WINDOW_STATE, transientDashboardData.isShowApplicationState());
+            attrs.setValue(MappedAttributes.THEME, transientDashboardData.getTheme());
+         }
          save(srcChild, dstChild, changes, hierarchyRelationships);
 
          //

Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2011-10-25 10:36:54 UTC (rev 7867)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java	2011-10-25 10:40:10 UTC (rev 7868)
@@ -692,6 +692,76 @@
       assertEquals("foo/bar", storage_.getId(app.getState()));
    }
 
+   @SuppressWarnings("unchecked")
+   public void testInitialDashboard() throws Exception
+   {
+      // Add dashboard portlet to a page first time
+      String dashboardTheme = "dashboardTheme";
+      String dashboardIcon = "dashboardIcon";
+      String dashboardTitle = "dashboardTitle";
+      String dashboardDesc = "dashboardDesc";
+      String dashboardWidth = "dashboardWidth";
+      String dashboardHeight = "dashboardHeight";
+      
+      String normalTheme = "normalTheme";
+      
+      
+      Page page = new Page();
+      String pageId = "portal::test::bit";
+      page.setPageId(pageId );
+      Application<Portlet> dashboardPortlet = Application.createPortletApplication();
+      Application<Portlet> normalPortlet = Application.createPortletApplication();
+
+      dashboardPortlet.setState(new TransientApplicationState<Portlet>("dashboard/DashboardPortlet"));
+      dashboardPortlet.setTheme(dashboardTheme);
+      dashboardPortlet.setIcon(dashboardIcon);
+      dashboardPortlet.setTitle(dashboardTitle);
+      dashboardPortlet.setDescription(dashboardDesc);
+      dashboardPortlet.setWidth(dashboardWidth);
+      dashboardPortlet.setHeight(dashboardHeight);
+
+      normalPortlet.setState(new TransientApplicationState<Portlet>("normalPortlet"));
+      normalPortlet.setTheme(normalTheme);
+
+      page.getChildren().add(dashboardPortlet);
+      page.getChildren().add(normalPortlet);
+      storage_.save(page);
+
+      //
+      page = storage_.getPage("portal::test::bit");
+      assertEquals(2, page.getChildren().size());
+      dashboardPortlet = (Application<Portlet>) page.getChildren().get(0);
+      normalPortlet = (Application<Portlet>) page.getChildren().get(1);
+      assertNotNull(dashboardPortlet);
+      assertNotNull(normalPortlet);
+      
+      assertEquals(normalTheme, normalPortlet.getTheme());
+      assertEquals(dashboardTheme, dashboardPortlet.getTheme());
+      assertEquals(dashboardIcon, dashboardPortlet.getIcon());
+      assertEquals(dashboardTitle, dashboardPortlet.getTitle());
+      assertEquals(dashboardDesc, dashboardPortlet.getDescription());
+      assertEquals(dashboardWidth, dashboardPortlet.getWidth());
+      assertEquals(dashboardHeight, dashboardPortlet.getHeight());
+
+      // Update the dashboard portlet and save
+      dashboardPortlet.setTheme(dashboardTheme);
+      page.getChildren().clear();
+      page.getChildren().add(dashboardPortlet);
+      storage_.save(page);
+
+      //
+      page = storage_.getPage("portal::test::bit");
+      assertEquals(1, page.getChildren().size());
+      dashboardPortlet = (Application<Portlet>) page.getChildren().get(0);
+      assertNotNull(dashboardPortlet);
+      assertEquals(dashboardTheme, dashboardPortlet.getTheme());
+      assertEquals(dashboardIcon, dashboardPortlet.getIcon());
+      assertEquals(dashboardTitle, dashboardPortlet.getTitle());
+      assertEquals(dashboardDesc, dashboardPortlet.getDescription());
+      assertEquals(dashboardWidth, dashboardPortlet.getWidth());
+      assertEquals(dashboardHeight, dashboardPortlet.getHeight());
+   }
+
    public void testDashboardLayout() throws Exception
    {
       Application<Portlet> dashboardPortlet = Application.createPortletApplication();



More information about the gatein-commits mailing list