Author: julien_viet
Date: 2010-03-10 12:37:13 -0500 (Wed, 10 Mar 2010)
New Revision: 2117
Added:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/Scope.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/TemplatizedImpl.java
Removed:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/composer/
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/TemplatizedObject.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/composer/
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Navigation.java
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Page.java
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Templatized.java
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/PageImpl.java
components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/TestMOPService.java
components/mop/trunk/core/src/test/resources/conf/configuration.xml
Log:
had to rework a bit templatization
Added: components/mop/trunk/api/src/main/java/org/gatein/mop/api/Scope.java
===================================================================
--- components/mop/trunk/api/src/main/java/org/gatein/mop/api/Scope.java
(rev 0)
+++ components/mop/trunk/api/src/main/java/org/gatein/mop/api/Scope.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 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.api;
+
+/**
+ * A generic notion of scope.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public enum Scope
+{
+
+ INHERITED, LOCAL
+
+}
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Navigation.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Navigation.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Navigation.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -31,7 +31,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface Navigation extends TemplatizedObject
+public interface Navigation extends WorkspaceObject
{
/**
@@ -108,4 +108,11 @@
* @return the link object
*/
<L extends Link> L linkTo(ObjectType<L> linkType);
+
+ /**
+ * Returns the templatized aspect of this navigation when it exists.
+ *
+ * @return the templatized
+ */
+ Templatized getTemplatized();
}
Modified: components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Page.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Page.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Page.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -32,7 +32,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface Page extends TemplatizedObject
+public interface Page extends WorkspaceObject
{
/**
@@ -118,13 +118,22 @@
/**
* Returns the templatized objects for this page.
*
- * @param templatizedType the type of templatized
+ * @param type the type of templatized
* @param <T> the templatized workspace object type parameter
* @return the collection of templatized objects
*/
- <T extends TemplatizedObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> templatizedType);
+ <T extends WorkspaceObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> type);
/**
+ * Templatize the provided object.
+ *
+ * @param object the object to templatize
+ * @return the templatized aspect of the object
+ * @throws IllegalArgumentException if the object cannot be templatized for a
particular reason
+ */
+ Templatized templatize(WorkspaceObject object) throws IllegalArgumentException;
+
+ /**
* Returns the customization context of this object;
*
* @return the customization context
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Templatized.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Templatized.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Templatized.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -18,6 +18,8 @@
*/
package org.gatein.mop.api.workspace;
+import org.gatein.mop.api.Scope;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -39,4 +41,8 @@
*/
void setTemplate(Page template);
+ Scope getScope();
+
+ void setScope(Scope scope);
+
}
Deleted:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/TemplatizedObject.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/TemplatizedObject.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/TemplatizedObject.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -1,29 +0,0 @@
-/**
- * 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.api.workspace;
-
-/**
- * A workspace object that can use a template.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public interface TemplatizedObject extends WorkspaceObject, Templatized
-{
-}
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 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -27,7 +27,6 @@
import org.chromattic.api.annotations.RelatedMappedBy;
import org.chromattic.api.RelationshipType;
import org.gatein.mop.api.workspace.Navigation;
-import org.gatein.mop.api.workspace.Page;
import org.gatein.mop.api.workspace.link.Link;
import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.Site;
@@ -69,30 +68,19 @@
@Create
public abstract PageLinkImpl createPageLink();
- @ManyToOne(type = RelationshipType.PATH)
- @MappedBy("mop:template")
- public abstract PageImpl getPageTemplate();
-
- public abstract void setPageTemplate(PageImpl template);
-
@Destroy
public abstract void destroy();
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ public abstract TemplatizedImpl getTemplatized();
+
+ public abstract void setTemplatized(TemplatizedImpl templatized);
+
public ObjectType<? extends Navigation> getObjectType()
{
return ObjectType.NAVIGATION;
}
- public Page getTemplate()
- {
- return getPageTemplate();
- }
-
- public void setTemplate(Page template)
- {
- setPageTemplate((PageImpl)template);
- }
-
public Navigation getParent()
{
NavigationContainer parent = getParentContainer();
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -29,8 +29,8 @@
import org.gatein.mop.api.workspace.Page;
import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.Templatized;
import org.gatein.mop.api.workspace.WorkspaceObject;
-import org.gatein.mop.api.workspace.TemplatizedObject;
import org.gatein.mop.api.workspace.link.PageLink;
import org.gatein.mop.api.Attributes;
import org.gatein.mop.core.util.AbstractAttributes;
@@ -107,9 +107,35 @@
//
*******************************************************************************************************************
- public <T extends TemplatizedObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> templatizedType)
+ public Templatized templatize(WorkspaceObject object)
+ { TemplatizedImpl templatized;
+ if (object instanceof NavigationImpl)
+ {
+ NavigationImpl nav = (NavigationImpl)object;
+ templatized = nav.getTemplatized();
+ if (templatized != null)
+ {
+ throw new IllegalArgumentException("The object is already
templatized");
+ }
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ //
+ templatized = object.adapt(TemplatizedImpl.class);
+
+ //
+ templatized.setTemplate(this);
+
+ //
+ return templatized;
+ }
+
+ public <T extends WorkspaceObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> type)
{
- if (Page.class.equals(templatizedType.getJavaType()))
+ if (Page.class.equals(type.getJavaType()))
{
ArrayList bilto = new ArrayList();
for (Page page : getTemplatizedPages())
@@ -118,7 +144,7 @@
}
return bilto;
}
- else if (Navigation.class.isAssignableFrom(templatizedType.getJavaType()))
+ else if (Navigation.class.isAssignableFrom(type.getJavaType()))
{
ArrayList bilto = new ArrayList();
for (Navigation page : getTemplatizedNavigations())
Added:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/TemplatizedImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/TemplatizedImpl.java
(rev 0)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/TemplatizedImpl.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 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.chromattic.api.RelationshipType;
+import org.chromattic.api.annotations.ManyToOne;
+import org.chromattic.api.annotations.MappedBy;
+import org.chromattic.api.annotations.MixinType;
+import org.chromattic.api.annotations.Property;
+import org.gatein.mop.api.Scope;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Templatized;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+@MixinType(name = "mop:templatized")
+public abstract class TemplatizedImpl implements Templatized
+{
+
+ @ManyToOne(type = RelationshipType.PATH)
+ @MappedBy("mop:template")
+ public abstract PageImpl getPageTemplate();
+
+ public abstract void setPageTemplate(PageImpl template);
+
+ public void setTemplate(Page template)
+ {
+ setPageTemplate((PageImpl)template);
+ }
+
+ public Page getTemplate()
+ {
+ return getPageTemplate();
+ }
+
+ @Property(name = "scope:template")
+ public abstract Scope getScope();
+
+ public abstract void setScope(Scope scope);
+}
Modified: components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml
===================================================================
--- components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2010-03-10
16:57:26 UTC (rev 2116)
+++ components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2010-03-10
17:37:13 UTC (rev 2117)
@@ -207,13 +207,15 @@
<propertyDefinition name="mop:template" requiredType="Path"
autoCreated="false" mandatory="false" onParentVersion="COPY"
protected="false" multiple="false">
<valueConstraints/>
</propertyDefinition>
+ <propertyDefinition name="scope:template"
requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false"
multiple="false">
+ <valueConstraints/>
+ </propertyDefinition>
</propertyDefinitions>
</nodeType>
<nodeType name="mop:navigation" isMixin="false"
hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>mop:workspaceobject</supertype>
- <supertype>mop:templatized</supertype>
</supertypes>
<childNodeDefinitions>
<childNodeDefinition name="mop:children"
defaultPrimaryType="mop:navigationcontainer" autoCreated="true"
mandatory="false"
@@ -277,7 +279,6 @@
<nodeType name="mop:page" isMixin="false"
hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>mop:workspaceobject</supertype>
- <supertype>mop:templatized</supertype>
<supertype>mop:customizationcontext</supertype>
</supertypes>
<childNodeDefinitions>
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -82,7 +82,6 @@
//
Page page = root.addChild("page");
assertNotNull(page);
- page.setTemplate(template);
//
NavigationImpl nav = (NavigationImpl)site.getRootNavigation();
@@ -90,7 +89,7 @@
// assertNull(nav.getLink());
//
- nav.setTemplate(template);
+ template.templatize(nav);
//
PageLinkImpl pageTarget = nav.createPageLink();
@@ -105,10 +104,6 @@
// Try something with template relationships
- Collection<? extends Page> templatizedPages =
template.getTemplatizedObjects(ObjectType.PAGE);
- assertNotNull(templatizedPages);
- assertEquals(1, templatizedPages.size());
-
Collection<? extends Navigation> templatizedNavigations =
template.getTemplatizedObjects(ObjectType.NAVIGATION);
assertNotNull(templatizedNavigations);
assertEquals(1, templatizedNavigations.size());
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -18,6 +18,8 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.gatein.mop.api.Scope;
+import org.gatein.mop.api.workspace.Templatized;
import org.gatein.mop.api.workspace.ui.UIComponent;
import org.gatein.mop.core.util.Tools;
import org.gatein.mop.api.workspace.ObjectType;
@@ -100,20 +102,16 @@
Workspace workspace = pomService.getModel().getWorkspace();
Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
Page template = portal.getRootPage().addChild("template");
- portal.getRootNavigation().setTemplate(template);
- assertEquals(template, portal.getRootNavigation().getTemplate());
+ Navigation rootNav = portal.getRootNavigation();
+ assertNull(rootNav.getTemplatized());
+ Templatized templatized = template.templatize(rootNav);
+ assertSame(templatized, rootNav.getTemplatized());
+ assertNull(templatized.getScope());
+ templatized.setScope(Scope.INHERITED);
+ assertEquals(Scope.INHERITED, templatized.getScope());
+ assertEquals(template, templatized.getTemplate());
}
- public void testPageTemplate()
- {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page template = portal.getRootPage().addChild("template");
- Page foo = portal.getRootPage().addChild("foo");
- foo.setTemplate(template);
- assertEquals(template, foo.getTemplate());
- }
-
public void testLoading()
{
Workspace workspace = pomService.getModel().getWorkspace();
@@ -202,7 +200,7 @@
Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
Page root = portal.getRootPage();
Page template = root.addChild("template");
- portal.getRootNavigation().setTemplate(template);
+ template.templatize(portal.getRootNavigation());
pom.save();
pom = pomService.getModel();
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/TestMOPService.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/TestMOPService.java 2010-03-10
16:57:26 UTC (rev 2116)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/TestMOPService.java 2010-03-10
17:37:13 UTC (rev 2117)
@@ -32,6 +32,7 @@
import org.gatein.mop.core.api.workspace.PortalSite;
import org.gatein.mop.core.api.workspace.PortalSiteContainer;
import org.gatein.mop.core.api.workspace.SecuredImpl;
+import org.gatein.mop.core.api.workspace.TemplatizedImpl;
import org.gatein.mop.core.api.workspace.UIBodyImpl;
import org.gatein.mop.core.api.workspace.UIContainerImpl;
import org.gatein.mop.core.api.workspace.UIWindowImpl;
@@ -93,6 +94,7 @@
builder.add(GroupSite.class);
builder.add(UserSiteContainer.class);
builder.add(UserSite.class);
+ builder.add(TemplatizedImpl.class);
//
builder.add(CustomizationContainer.class);
Modified: components/mop/trunk/core/src/test/resources/conf/configuration.xml
===================================================================
--- components/mop/trunk/core/src/test/resources/conf/configuration.xml 2010-03-10
16:57:26 UTC (rev 2116)
+++ components/mop/trunk/core/src/test/resources/conf/configuration.xml 2010-03-10
17:37:13 UTC (rev 2117)
@@ -34,6 +34,7 @@
<properties-param>
<name>namespaces</name>
<property name="mop"
value="http://www.gatein.org/jcr/mop/1.0/"/>
+ <property name="scope"
value="http://www.gatein.org/jcr/scope/1.0/"/>
</properties-param>
</init-params>
</component-plugin>