Author: julien_viet
Date: 2009-11-23 12:17:11 -0500 (Mon, 23 Nov 2009)
New Revision: 767
Added:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/NavigationTestCase.java
Modified:
components/mop/trunk/core/pom.xml
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java
components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml
Log:
GTNMOP-12 : Supporting ordered children in the navigation
Modified: components/mop/trunk/core/pom.xml
===================================================================
--- components/mop/trunk/core/pom.xml 2009-11-23 16:44:55 UTC (rev 766)
+++ components/mop/trunk/core/pom.xml 2009-11-23 17:17:11 UTC (rev 767)
@@ -70,6 +70,16 @@
</dependency>
<dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.gatein.common</groupId>
+ <artifactId>common-logging</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.chromattic</groupId>
<artifactId>chromattic.exo</artifactId>
<scope>test</scope>
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java 2009-11-23
16:44:55 UTC (rev 766)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java 2009-11-23
17:17:11 UTC (rev 767)
@@ -24,6 +24,7 @@
import org.chromattic.api.annotations.Create;
import org.chromattic.api.annotations.RelatedMappedBy;
+import java.util.List;
import java.util.Map;
/**
@@ -38,14 +39,18 @@
public abstract NavigationImpl getOwner();
@OneToMany
- public abstract Map<String, NavigationImpl> getNavigations();
+ public abstract Map<String, NavigationImpl> getNavigationMap();
+ @OneToMany
+ public abstract List<NavigationImpl> getNavigationList();
+
@Create
public abstract NavigationImpl createNavigation();
public NavigationImpl addNavigation(String name) {
NavigationImpl page = createNavigation();
- getNavigations().put(name, page);
+ page.setName(name);
+ getNavigationList().add(page);
return page;
}
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java 2009-11-23
16:44:55 UTC (rev 766)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java 2009-11-23
17:17:11 UTC (rev 767)
@@ -33,7 +33,7 @@
import org.gatein.mop.api.workspace.Site;
import org.gatein.mop.api.workspace.link.PageLink;
-import java.util.Collection;
+import java.util.List;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -98,9 +98,9 @@
}
}
- public Collection<? extends Navigation> getChildren() {
+ public List<? extends Navigation> getChildren() {
NavigationContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getNavigations().values();
+ return childrenContainer.getNavigationList();
}
public Navigation getChild(String name) {
@@ -108,7 +108,7 @@
throw new NullPointerException();
}
NavigationContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getNavigations().get(name);
+ return childrenContainer.getNavigationMap().get(name);
}
public NavigationImpl addChild(String name) {
Modified: components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml
===================================================================
--- components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2009-11-23
16:44:55 UTC (rev 766)
+++ components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2009-11-23
17:17:11 UTC (rev 767)
@@ -230,7 +230,7 @@
</childNodeDefinitions>
</nodeType>
- <nodeType name="mop:navigationcontainer" isMixin="false"
hasOrderableChildNodes="false" primaryItemName="">
+ <nodeType name="mop:navigationcontainer" isMixin="false"
hasOrderableChildNodes="true" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
<supertype>mix:referenceable</supertype>
Added:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/NavigationTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/NavigationTestCase.java
(rev 0)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/NavigationTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
@@ -0,0 +1,49 @@
+/**
+ * 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.gatein.mop.core.api.workspace;
+
+import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.core.api.AbstractPOMTestCase;
+import org.gatein.mop.core.api.ModelImpl;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class NavigationTestCase extends AbstractPOMTestCase
+{
+ public void testNavigationOrder()
+ {
+ ModelImpl model = pomService.getModel();
+ Site portal = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"portal_for_navigation");
+ Navigation root = portal.getRootNavigation();
+ Navigation n1 = root.addChild("1");
+ Navigation n2 = root.addChild("2");
+ Navigation n3 = root.addChild("3");
+ List<? extends Navigation> ns = root.getChildren();
+ assertEquals(3, ns.size());
+ assertSame(n1, ns.get(0));
+ assertSame(n2, ns.get(1));
+ assertSame(n3, ns.get(2));
+ }
+}