[gatein-commits] gatein SVN: r2058 - in portal/trunk: component/portal/src/main/java/org/exoplatform/portal/mop and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Mar 9 09:52:31 EST 2010


Author: julien_viet
Date: 2010-03-09 09:52:30 -0500 (Tue, 09 Mar 2010)
New Revision: 2058

Added:
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/Visible.java
Modified:
   portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
   portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java
   portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration1.xml
   portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
extract the visible aspect of a navigation in a mixin instead of generic properties


Modified: portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml
===================================================================
--- portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/component/portal/src/main/java/conf/gatein-nodetypes.xml	2010-03-09 14:52:30 UTC (rev 2058)
@@ -57,4 +57,26 @@
     </propertyDefinitions>
   </nodeType>
 
+  <nodeType name="gtn:visible" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
+    <propertyDefinitions>
+      <propertyDefinition name="gtn:startpublicationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="gtn:endpublicationdate" requiredType="Date" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints/>
+      </propertyDefinition>
+      <propertyDefinition name="gtn:visibility" requiredType="String" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" multiple="false">
+        <valueConstraints>
+          <valueConstraint>DISPLAYED</valueConstraint>
+          <valueConstraint>HIDDEN</valueConstraint>
+          <valueConstraint>TEMPORAL</valueConstraint>
+          <valueConstraint>SYSTEM</valueConstraint>
+        </valueConstraints>
+        <defaultValues>
+          <defaultValue>DISPLAYED</defaultValue>
+        </defaultValues>
+      </propertyDefinition>
+    </propertyDefinitions>
+  </nodeType>
+
 </nodeTypes>

Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/Visible.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/Visible.java	                        (rev 0)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/mop/Visible.java	2010-03-09 14:52:30 UTC (rev 2058)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.mop;
+
+import org.chromattic.api.annotations.MixinType;
+import org.chromattic.api.annotations.Property;
+
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+ at MixinType(name = "gtn:visible")
+public abstract class Visible
+{
+
+   @Property(name = "gtn:startpublicationdate")
+   public abstract Date getStartPublicationDate();
+
+   public abstract void setStartPublicationDate(Date date);
+
+   @Property(name = "gtn:endpublicationdate")
+   public abstract Date getEndPublicationDate();
+
+   public abstract void setEndPublicationDate(Date date);
+
+   @Property(name = "gtn:visibility")
+   public abstract Visibility getVisibility();
+
+   public abstract void setVisibility(Visibility visibility);
+
+}

Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/MappedAttributes.java	2010-03-09 14:52:30 UTC (rev 2058)
@@ -59,18 +59,9 @@
    public static final Key<String> URI = Key.create("uri", ValueType.STRING);
 
    /** . */
-   public static final Key<Date> START_PUBLICATION_DATE = Key.create("start-publication-date", ValueType.DATE);
-
-   /** . */
-   public static final Key<Date> END_PUBLICATION_DATE = Key.create("end-publication-date", ValueType.DATE);
-
-   /** . */
    public static final Key<String> TEMPLATE = Key.create("template", ValueType.STRING);
 
    /** . */
-   public static final Key<String> VISIBILITY = Key.create("visibility", ValueType.STRING);
-
-   /** . */
    public static final Key<String> LOCALE = Key.create("locale", ValueType.STRING);
 
    /** . */

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	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/data/Mapper.java	2010-03-09 14:52:30 UTC (rev 2058)
@@ -24,13 +24,10 @@
 import org.exoplatform.portal.config.model.ApplicationState;
 import org.exoplatform.portal.config.model.ApplicationType;
 import org.exoplatform.portal.config.model.CloneApplicationState;
-import org.exoplatform.portal.mop.Decorated;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.ProtectedResource;
+import org.exoplatform.portal.mop.*;
 import org.exoplatform.portal.config.model.PersistentApplicationState;
 import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.config.model.TransientApplicationState;
-import org.exoplatform.portal.mop.Visibility;
 import org.exoplatform.portal.pom.config.POMSession;
 import org.exoplatform.portal.pom.config.Utils;
 import org.exoplatform.portal.pom.spi.portlet.Portlet;
@@ -152,15 +149,18 @@
          Described described = src.adapt(Described.class);
 
          //
+         Visible visible = src.adapt(Visible.class);
+
+         //
          NavigationNodeData dstNode = new NavigationNodeData(
             src.getObjectId(),
             attrs.getValue(MappedAttributes.URI),
             described.getName(),
             attrs.getValue(MappedAttributes.ICON),
             src.getName(),
-            attrs.getValue(MappedAttributes.START_PUBLICATION_DATE),
-            attrs.getValue(MappedAttributes.END_PUBLICATION_DATE),
-            Visibility.valueOf(attrs.getValue(MappedAttributes.VISIBILITY, Visibility.DISPLAYED.toString())),
+            visible.getStartPublicationDate(),
+            visible.getEndPublicationDate(),
+            visible.getVisibility() != null ? visible.getVisibility() : Visibility.DISPLAYED,
             pageReference,
             children
          );
@@ -203,12 +203,15 @@
          described.setName(node.getLabel());
 
          //
+         Visible visible = dst.adapt(Visible.class);
+         visible.setVisibility(node.getVisibility());
+         visible.setStartPublicationDate(node.getStartPublicationDate());
+         visible.setEndPublicationDate(node.getEndPublicationDate());
+
+         //
          Attributes attrs = dst.getAttributes();
          attrs.setValue(MappedAttributes.URI, node.getURI());
          attrs.setValue(MappedAttributes.ICON, node.getIcon());
-         attrs.setValue(MappedAttributes.START_PUBLICATION_DATE, node.getStartPublicationDate());
-         attrs.setValue(MappedAttributes.END_PUBLICATION_DATE, node.getEndPublicationDate());
-         attrs.setValue(MappedAttributes.VISIBILITY, node.getVisibility().name());
       }
       else if (src instanceof NavigationData)
       {

Modified: portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration1.xml
===================================================================
--- portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration1.xml	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration1.xml	2010-03-09 14:52:30 UTC (rev 2058)
@@ -181,6 +181,7 @@
           <value>org.exoplatform.portal.mop.ProtectedResource</value>
           <value>org.exoplatform.portal.mop.Described</value>
           <value>org.exoplatform.portal.mop.Decorated</value>
+          <value>org.exoplatform.portal.mop.Visible</value>
         </values-param>
       </init-params>
     </component-plugin>

Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestSavedPOM.java	2010-03-09 14:52:30 UTC (rev 2058)
@@ -20,9 +20,7 @@
 package org.exoplatform.portal.config;
 
 import org.exoplatform.container.PortalContainer;
-import org.exoplatform.portal.mop.Decorated;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.mop.ProtectedResource;
+import org.exoplatform.portal.mop.*;
 import org.exoplatform.portal.pom.config.POMSession;
 import org.exoplatform.portal.pom.config.POMSessionManager;
 import org.gatein.mop.api.Attributes;
@@ -113,13 +111,17 @@
       Attributes nodeAttrs = nodeNavigation.getAttributes();
       assertEquals("node_uri", nodeAttrs.getString("uri"));
       assertEquals("node_icon", nodeAttrs.getString("icon"));
+
+      //
+      assertTrue(nodeNavigation.isAdapted(Visible.class));
+      Visible visible = nodeNavigation.adapt(Visible.class);
       GregorianCalendar start = new GregorianCalendar(2000, 2, 21, 1, 33, 0);
       start.setTimeZone(TimeZone.getTimeZone("UTC"));
-      assertEquals(start.getTime(), nodeAttrs.getDate("start-publication-date"));
+      assertEquals(start.getTime(), visible.getStartPublicationDate());
       GregorianCalendar end = new GregorianCalendar(2009, 2, 21, 1, 33, 0);
       end.setTimeZone(TimeZone.getTimeZone("UTC"));
-      assertEquals(end.getTime(), nodeAttrs.getDate("end-publication-date"));
-      assertEquals("TEMPORAL", nodeAttrs.getString("visibility"));
+      assertEquals(end.getTime(), visible.getEndPublicationDate());
+      assertEquals(Visibility.TEMPORAL, visible.getVisibility());
 
       //
       Link link = nodeNavigation.getLink();

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2010-03-09 14:21:42 UTC (rev 2057)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml	2010-03-09 14:52:30 UTC (rev 2058)
@@ -254,6 +254,7 @@
           <value>org.exoplatform.portal.mop.ProtectedResource</value>
           <value>org.exoplatform.portal.mop.Described</value>
           <value>org.exoplatform.portal.mop.Decorated</value>
+          <value>org.exoplatform.portal.mop.Visible</value>
         </values-param>
         <properties-param>
           <name>options</name>



More information about the gatein-commits mailing list