Author: julien_viet
Date: 2010-02-20 12:47:58 -0500 (Sat, 20 Feb 2010)
New Revision: 1788
Added:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceCustomizationContextImpl.java
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/composer/ComponentIterator.java
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Workspace.java
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/ui/UIContainer.java
components/mop/trunk/core/pom.xml
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java
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/PageContainer.java
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/PortalSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.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/WorkspaceTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java
Log:
update to chromattic trunk snapshot
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/composer/ComponentIterator.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/composer/ComponentIterator.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/composer/ComponentIterator.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -70,7 +70,7 @@
if (current instanceof UIContainer)
{
UIContainer container = (UIContainer)current;
- Iterator<? extends UIComponent> iterator = container.iterator();
+ Iterator<UIComponent> iterator =
container.getComponents().iterator();
if (iterator.hasNext())
{
stack.add(new ContainerVisit(container, iterator));
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Workspace.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Workspace.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/Workspace.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface Workspace extends WorkspaceObject, WorkspaceCustomizationContext
+public interface Workspace extends WorkspaceObject
{
/**
@@ -62,4 +62,11 @@
*/
<S extends Site> S addSite(ObjectType<S> siteType, String name);
+ /**
+ * Returns the customization context of this object;
+ *
+ * @return the customization context
+ */
+ WorkspaceCustomizationContext getCustomizationContext();
+
}
Modified:
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/ui/UIContainer.java
===================================================================
---
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/ui/UIContainer.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/api/src/main/java/org/gatein/mop/api/workspace/ui/UIContainer.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface UIContainer extends UIComponent, List<UIComponent>
+public interface UIContainer extends UIComponent
{
<T extends UIComponent> T add(ObjectType<T> componentType, String
componentName);
@@ -35,4 +35,7 @@
UIComponent get(String componentName);
+ List<UIComponent> getComponents();
+
+
}
Modified: components/mop/trunk/core/pom.xml
===================================================================
--- components/mop/trunk/core/pom.xml 2010-02-19 21:37:44 UTC (rev 1787)
+++ components/mop/trunk/core/pom.xml 2010-02-20 17:47:58 UTC (rev 1788)
@@ -38,7 +38,7 @@
<description>Model Object for Portal Core</description>
<properties>
- <org.chromattic.version>1.0.0-cr1</org.chromattic.version>
+ <org.chromattic.version>1.0.0-cr2-SNAPSHOT</org.chromattic.version>
</properties>
<dependencies>
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -27,7 +27,7 @@
* @version $Revision$
*/
@PrimaryType(name = "mop:groupsite")
-public abstract class GroupSite extends SiteImpl
+public abstract class GroupSite extends SiteImpl<GroupSiteContainer>
{
// Site implementation
***********************************************************************************************
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,6 +18,7 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.chromattic.api.annotations.PrimaryType;
import org.gatein.mop.api.workspace.link.Link;
import org.gatein.mop.api.workspace.ObjectType;
@@ -25,6 +26,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
+@PrimaryType(name = "mop:link")
public abstract class LinkImpl extends WorkspaceObjectImpl implements Link
{
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 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -39,7 +39,7 @@
{
@OneToOne
- @RelatedMappedBy("navigations")
+ @RelatedMappedBy("children")
public abstract NavigationImpl getOwner();
@OneToMany
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -38,7 +38,7 @@
{
@OneToOne
- @RelatedMappedBy("pages")
+ @RelatedMappedBy("children")
public abstract PageImpl getOwner();
@OneToMany
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-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -38,7 +38,6 @@
import org.gatein.mop.api.content.ContentType;
import org.gatein.mop.api.Attributes;
import org.gatein.mop.core.util.AbstractAttributes;
-import org.gatein.mop.core.api.workspace.content.CustomizationContainer;
import java.util.Collection;
import java.util.ArrayList;
@@ -93,8 +92,7 @@
@MappedBy("children")
public abstract PageContainer getChildrenContainer();
- @OneToOne
- @RelatedMappedBy("children")
+ @ManyToOne
public abstract PageContainer getParentContainer();
@OneToOne
@@ -108,45 +106,44 @@
@Destroy
public abstract void destroy();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ public abstract WorkspaceCustomizationContextImpl getCustomizationContext();
// WorkspaceCustomizationContext implementation
**********************************************************************
public String getContextType()
{
- return WorkspaceCustomizationContext.TYPE;
+ return getCustomizationContext().getContextType();
}
public String getContextId()
{
- return getObjectId();
+ return getCustomizationContext().getContextId();
}
public boolean contains(CustomizationContext that)
{
- return contains(this, that);
+ return getCustomizationContext().contains(that);
}
public Customization<?> getCustomization(String name)
{
- return getCustomizations().getCustomization(name);
+ return getCustomizationContext().getCustomization(name);
}
public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
{
- return getCustomizations().customize(name, contentType, contentId, state);
+ return getCustomizationContext().customize(name, contentType, contentId, state);
}
public <S> Customization<S> customize(String name, Customization<S>
customization)
{
- return getCustomizations().customize(name, customization);
+ return getCustomizationContext().customize(name, customization);
}
public String nameOf(Customization customization)
{
- return getCustomizations().nameOf(customization);
+ return getCustomizationContext().nameOf(customization);
}
//
*******************************************************************************************************************
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -27,7 +27,7 @@
* @version $Revision$
*/
@PrimaryType(name = "mop:portalsite")
-public abstract class PortalSite extends SiteImpl
+public abstract class PortalSite extends SiteImpl<PortalSiteContainer>
{
// Site implementation
***********************************************************************************************
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,11 +18,13 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.chromattic.api.RelationshipType;
import org.chromattic.api.annotations.FormattedBy;
import org.chromattic.api.annotations.ManyToOne;
import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.MappedBy;
import org.chromattic.api.annotations.Destroy;
+import org.chromattic.api.annotations.PrimaryType;
import org.gatein.mop.api.workspace.Site;
import org.gatein.mop.api.workspace.Page;
import org.gatein.mop.api.workspace.ObjectType;
@@ -31,14 +33,14 @@
import org.gatein.mop.api.content.Customization;
import org.gatein.mop.api.content.ContentType;
import org.gatein.mop.core.api.MOPFormatter;
-import org.gatein.mop.core.api.workspace.content.CustomizationContainer;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
@FormattedBy(MOPFormatter.class)
-public abstract class SiteImpl extends WorkspaceObjectImpl implements Site,
WorkspaceCustomizationContext
+@PrimaryType(name = "mop:site")
+public abstract class SiteImpl<C extends SiteContainer> extends WorkspaceObjectImpl
implements Site, WorkspaceCustomizationContext
{
@OneToOne
@@ -50,14 +52,13 @@
public abstract NavigationImpl getRootNavigation();
@ManyToOne
- public abstract SiteContainer getSites();
+ public abstract C getSites();
@Destroy
public abstract void destroy();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ public abstract WorkspaceCustomizationContextImpl getCustomizationContext();
public abstract ObjectType<? extends Site> getObjectType();
@@ -78,36 +79,36 @@
public String getContextType()
{
- return WorkspaceCustomizationContext.TYPE;
+ return getCustomizationContext().getContextType();
}
public String getContextId()
{
- return getObjectId();
+ return getCustomizationContext().getContextId();
}
public boolean contains(CustomizationContext that)
{
- return contains(this, that);
+ return getCustomizationContext().contains(that);
}
public Customization<?> getCustomization(String name)
{
- return getCustomizations().getCustomization(name);
+ return getCustomizationContext().getCustomization(name);
}
public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
{
- return getCustomizations().customize(name, contentType, contentId, state);
+ return getCustomizationContext().customize(name, contentType, contentId, state);
}
public <S> Customization<S> customize(String name, Customization<S>
customization)
{
- return getCustomizations().customize(name, customization);
+ return getCustomizationContext().customize(name, customization);
}
public String nameOf(Customization customization)
{
- return getCustomizations().nameOf(customization);
+ return getCustomizationContext().nameOf(customization);
}
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,6 +18,7 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.chromattic.api.annotations.PrimaryType;
import org.gatein.mop.api.workspace.ui.UIComponent;
import org.gatein.mop.api.workspace.ObjectType;
import org.chromattic.api.annotations.ManyToOne;
@@ -27,6 +28,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
+@PrimaryType(name = "mop:uicomponent")
public abstract class UIComponentImpl extends WorkspaceObjectImpl implements UIComponent
{
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -20,7 +20,6 @@
import org.chromattic.api.annotations.OneToMany;
import org.chromattic.api.annotations.Create;
-import org.chromattic.api.annotations.Name;
import org.chromattic.api.annotations.PrimaryType;
import org.gatein.mop.api.workspace.ui.UIContainer;
import org.gatein.mop.api.workspace.ui.UIComponent;
@@ -53,7 +52,7 @@
public abstract Map<String, UIComponentImpl> getComponentMap();
@OneToMany
- public abstract List<UIComponent> getComponentList();
+ public abstract List<UIComponentImpl> getComponentList();
public ObjectType<? extends UIContainer> getObjectType()
{
@@ -110,125 +109,133 @@
throw new UnsupportedOperationException();
}
child.setName(name);
- List<UIComponent> children = getComponentList();
+ List<UIComponentImpl> children = getComponentList();
children.add(index, child);
return componentType.cast(child);
}
+ public List<UIComponent> getComponents() {
+ // We have to do that
+ return (List)components;
+ }
+
// List<UIComponent> implementation
**********************************************************************************
- public int size()
- {
- return getComponentList().size();
- }
+ private final List<UIComponentImpl> components = new
List<UIComponentImpl>() {
- public boolean isEmpty()
- {
- return getComponentList().isEmpty();
- }
+ public int size()
+ {
+ return getComponentList().size();
+ }
- public boolean contains(Object o)
- {
- return getComponentList().contains(o);
- }
+ public boolean isEmpty()
+ {
+ return getComponentList().isEmpty();
+ }
- public Iterator<UIComponent> iterator()
- {
- return getComponentList().iterator();
- }
+ public boolean contains(Object o)
+ {
+ return getComponentList().contains(o);
+ }
- public Object[] toArray()
- {
- return new Object[0];
- }
+ public Iterator<UIComponentImpl> iterator()
+ {
+ return getComponentList().iterator();
+ }
- public <T> T[] toArray(T[] a)
- {
- return getComponentList().toArray(a);
- }
+ public Object[] toArray()
+ {
+ return new Object[0];
+ }
- public boolean add(UIComponent uiComponent)
- {
- return getComponentList().add(uiComponent);
- }
+ public <T> T[] toArray(T[] a)
+ {
+ return getComponentList().toArray(a);
+ }
- public boolean remove(Object o)
- {
- return getComponentList().remove(o);
- }
+ public boolean add(UIComponentImpl uiComponent)
+ {
+ return getComponentList().add(uiComponent);
+ }
- public boolean containsAll(Collection<?> c)
- {
- return getComponentList().containsAll(c);
- }
+ public boolean remove(Object o)
+ {
+ return getComponentList().remove(o);
+ }
- public boolean addAll(Collection<? extends UIComponent> c)
- {
- return getComponentList().addAll(c);
- }
+ public boolean containsAll(Collection<?> c)
+ {
+ return getComponentList().containsAll(c);
+ }
- public boolean addAll(int index, Collection<? extends UIComponent> c)
- {
- return getComponentList().addAll(index, c);
- }
+ public boolean addAll(Collection<? extends UIComponentImpl> c)
+ {
+ return getComponentList().addAll(c);
+ }
- public boolean removeAll(Collection<?> c)
- {
- return getComponentList().removeAll(c);
- }
+ public boolean addAll(int index, Collection<? extends UIComponentImpl> c)
+ {
+ return getComponentList().addAll(index, c);
+ }
- public boolean retainAll(Collection<?> c)
- {
- return getComponentList().retainAll(c);
- }
+ public boolean removeAll(Collection<?> c)
+ {
+ return getComponentList().removeAll(c);
+ }
- public void clear()
- {
- getComponentList().clear();
- }
+ public boolean retainAll(Collection<?> c)
+ {
+ return getComponentList().retainAll(c);
+ }
- public UIComponent get(int index)
- {
- return getComponentList().get(index);
- }
+ public void clear()
+ {
+ getComponentList().clear();
+ }
- public UIComponent set(int index, UIComponent element)
- {
- return getComponentList().set(index, element);
- }
+ public UIComponentImpl get(int index)
+ {
+ return getComponentList().get(index);
+ }
- public void add(int index, UIComponent element)
- {
- getComponentList().add(index, element);
- }
+ public UIComponentImpl set(int index, UIComponentImpl element)
+ {
+ return getComponentList().set(index, element);
+ }
- public UIComponent remove(int index)
- {
- return getComponentList().remove(index);
- }
+ public void add(int index, UIComponentImpl element)
+ {
+ getComponentList().add(index, element);
+ }
- public int indexOf(Object o)
- {
- return getComponentList().indexOf(o);
- }
+ public UIComponentImpl remove(int index)
+ {
+ return getComponentList().remove(index);
+ }
- public int lastIndexOf(Object o)
- {
- return getComponentList().lastIndexOf(o);
- }
+ public int indexOf(Object o)
+ {
+ return getComponentList().indexOf(o);
+ }
- public ListIterator<UIComponent> listIterator()
- {
- return getComponentList().listIterator();
- }
+ public int lastIndexOf(Object o)
+ {
+ return getComponentList().lastIndexOf(o);
+ }
- public ListIterator<UIComponent> listIterator(int index)
- {
- return getComponentList().listIterator(index);
- }
+ public ListIterator<UIComponentImpl> listIterator()
+ {
+ return getComponentList().listIterator();
+ }
- public List<UIComponent> subList(int fromIndex, int toIndex)
- {
- return getComponentList().subList(fromIndex, toIndex);
- }
+ public ListIterator<UIComponentImpl> listIterator(int index)
+ {
+ return getComponentList().listIterator(index);
+ }
+
+ public List<UIComponentImpl> subList(int fromIndex, int toIndex)
+ {
+ return getComponentList().subList(fromIndex, toIndex);
+ }
+ };
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -28,7 +28,7 @@
* @version $Revision$
*/
@PrimaryType(name = "mop:usersite")
-public abstract class UserSite extends SiteImpl
+public abstract class UserSite extends SiteImpl<UserSiteContainer>
{
// Site implementation
***********************************************************************************************
Added:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceCustomizationContextImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceCustomizationContextImpl.java
(rev 0)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceCustomizationContextImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -0,0 +1,81 @@
+/*
+ * 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.MappedBy;
+import org.chromattic.api.annotations.OneToOne;
+import org.chromattic.api.annotations.PrimaryType;
+import org.chromattic.api.annotations.RelatedMappedBy;
+import org.gatein.mop.api.content.ContentType;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.content.CustomizationContext;
+import org.gatein.mop.api.workspace.WorkspaceCustomizationContext;
+import org.gatein.mop.core.api.workspace.content.CustomizationContainer;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+@PrimaryType(name = "mop:customizationcontext")
+public abstract class WorkspaceCustomizationContextImpl implements
WorkspaceCustomizationContext {
+
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ public abstract WorkspaceObjectImpl getOwner();
+
+ @OneToOne
+ @MappedBy("customizations")
+ public abstract CustomizationContainer getCustomizations();
+
+ public String getContextType()
+ {
+ return WorkspaceCustomizationContext.TYPE;
+ }
+
+ public String getContextId()
+ {
+ return getOwner().getObjectId();
+ }
+
+ public boolean contains(CustomizationContext that)
+ {
+ return WorkspaceObjectImpl.contains(this, that);
+ }
+
+ public Customization<?> getCustomization(String name)
+ {
+ return getCustomizations().getCustomization(name);
+ }
+
+ public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
+ {
+ return getCustomizations().customize(name, contentType, contentId, state);
+ }
+
+ public <S> Customization<S> customize(String name, Customization<S>
customization)
+ {
+ return getCustomizations().customize(name, customization);
+ }
+
+ public String nameOf(Customization customization)
+ {
+ return getCustomizations().nameOf(customization);
+ }
+}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,6 +18,7 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.chromattic.api.RelationshipType;
import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.MappedBy;
import org.chromattic.api.annotations.FindById;
@@ -29,7 +30,6 @@
import org.gatein.mop.api.content.CustomizationContext;
import org.gatein.mop.api.content.Customization;
import org.gatein.mop.api.content.ContentType;
-import org.gatein.mop.core.api.workspace.content.CustomizationContainer;
import java.util.Collection;
@@ -38,7 +38,7 @@
* @version $Revision$
*/
@PrimaryType(name = "mop:workspace")
-public abstract class WorkspaceImpl extends WorkspaceObjectImpl implements Workspace,
WorkspaceCustomizationContext
+public abstract class WorkspaceImpl extends WorkspaceObjectImpl implements Workspace
{
public ObjectType<? extends Workspace> getObjectType()
@@ -60,52 +60,14 @@
@MappedBy("usersites")
public abstract UserSiteContainer getUserSites();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne(type = RelationshipType.EMBEDDED)
+ public abstract WorkspaceCustomizationContextImpl getCustomizationContext();
// CustomizationContextResolver implementation
***********************************************************************
@FindById
public abstract CustomizationContext resolveContext(String contextId);
- // WorkspaceCustomizationContext implementation
**********************************************************************
-
- public String getContextType()
- {
- return WorkspaceCustomizationContext.TYPE;
- }
-
- public String getContextId()
- {
- return getObjectId();
- }
-
- public boolean contains(CustomizationContext that)
- {
- return contains(this, that);
- }
-
- public Customization<?> getCustomization(String name)
- {
- return getCustomizations().getCustomization(name);
- }
-
- public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
- {
- return getCustomizations().customize(name, contentType, contentId, state);
- }
-
- public <S> Customization<S> customize(String name, Customization<S>
customization)
- {
- return getCustomizations().customize(name, customization);
- }
-
- public String nameOf(Customization customization)
- {
- return getCustomizations().nameOf(customization);
- }
-
// Workspace implementation
******************************************************************************************
@SuppressWarnings("unchecked")
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,7 +18,7 @@
*/
package org.gatein.mop.core.api.workspace;
-import org.chromattic.api.annotations.FormattedBy;
+import org.chromattic.api.annotations.*;
import org.chromattic.common.collection.AbstractFilterIterator;
import org.gatein.mop.api.workspace.WorkspaceObject;
import org.gatein.mop.api.workspace.ObjectType;
@@ -27,9 +27,6 @@
import org.gatein.mop.core.api.MOPFormatter;
import org.gatein.mop.core.api.ModelImpl;
import org.gatein.mop.core.util.AbstractAttributes;
-import org.chromattic.api.annotations.Id;
-import org.chromattic.api.annotations.Name;
-import org.chromattic.api.annotations.Properties;
import java.util.Map;
import java.util.Set;
@@ -41,6 +38,7 @@
* @version $Revision$
*/
@FormattedBy(MOPFormatter.class)
+@PrimaryType(name = "mop:workspaceobject")
public abstract class WorkspaceObjectImpl implements WorkspaceObject
{
@@ -147,6 +145,11 @@
static boolean contains(CustomizationContext container, CustomizationContext
contained)
{
+ return contains(((WorkspaceCustomizationContextImpl)container).getOwner(),
contained);
+ }
+
+ private static boolean contains(WorkspaceObjectImpl container, CustomizationContext
contained)
+ {
if (container == null)
{
throw new NullPointerException("No null container accepted");
@@ -156,6 +159,8 @@
throw new NullPointerException("No null contained accepted");
}
+
+
//
if (container == contained)
{
@@ -166,7 +171,7 @@
if (contained instanceof SiteImpl)
{
SiteImpl site = (SiteImpl)contained;
- return contains(container, site.getWorkspace());
+ return contains(container, site.getWorkspace().getCustomizationContext());
}
else if (contained instanceof PageImpl)
{
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -19,6 +19,7 @@
package org.gatein.mop.core.api.workspace.content;
import org.chromattic.api.annotations.FormattedBy;
+import org.chromattic.api.annotations.PrimaryType;
import org.gatein.mop.api.content.Customization;
import org.gatein.mop.api.content.CustomizationContext;
import org.gatein.mop.api.content.ContentType;
@@ -47,6 +48,7 @@
* @version $Revision$
*/
@FormattedBy(MOPFormatter.class)
+@PrimaryType(name = "mop:customization")
public abstract class AbstractCustomization implements Customization<Object>,
StateContainer
{
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -28,6 +28,7 @@
import org.chromattic.api.annotations.OneToMany;
import org.chromattic.api.annotations.RelatedMappedBy;
import org.gatein.mop.core.api.MOPFormatter;
+import org.gatein.mop.core.api.workspace.WorkspaceCustomizationContextImpl;
import java.util.Map;
@@ -42,7 +43,7 @@
@OneToOne
@RelatedMappedBy("mop:customizations")
- public abstract WorkspaceCustomizationContext getOwner();
+ public abstract WorkspaceCustomizationContextImpl getOwner();
@OneToMany
public abstract Map<String, WorkspaceCustomization> getCustomizations();
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -20,6 +20,7 @@
import org.chromattic.api.annotations.ManyToOne;
import org.chromattic.api.annotations.Destroy;
+import org.chromattic.api.annotations.PrimaryType;
import org.chromattic.api.annotations.Property;
import org.gatein.mop.api.content.CustomizationContext;
import org.gatein.mop.api.content.ContentType;
@@ -30,6 +31,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
+@PrimaryType(name = "mop:workspacecustomization")
public abstract class WorkspaceCustomization extends AbstractCustomization
{
Modified: components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml
===================================================================
--- components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2010-02-19
21:37:44 UTC (rev 1787)
+++ components/mop/trunk/core/src/main/resources/conf/mop-nodetypes.xml 2010-02-20
17:47:58 UTC (rev 1788)
@@ -132,9 +132,10 @@
</childNodeDefinitions>
</nodeType>
- <nodeType name="mop:customizationcontext" isMixin="true"
hasOrderableChildNodes="false" primaryItemName="">
+ <nodeType name="mop:customizationcontext" isMixin="false"
hasOrderableChildNodes="false" primaryItemName="">
<supertypes>
<supertype>nt:base</supertype>
+ <supertype>mix:referenceable</supertype>
</supertypes>
<childNodeDefinitions>
<childNodeDefinition name="mop:customizations"
defaultPrimaryType="mop:customizationcontainer" autoCreated="true"
mandatory="false"
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-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -18,6 +18,7 @@
*/
package org.gatein.mop.core.api.workspace;
+import org.gatein.mop.api.workspace.ui.UIComponent;
import org.gatein.mop.core.util.Tools;
import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.Site;
@@ -32,6 +33,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.Collections;
+import java.util.List;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -231,22 +233,24 @@
container.add(ObjectType.WINDOW, "2");
container.add(0, ObjectType.WINDOW, "0");
- assertEquals("0", container.get(0).getName());
- assertEquals("2", container.get(1).getName());
- assertEquals(2, container.size());
+ List<UIComponent> components = container.getComponents();
+ assertEquals("0", components.get(0).getName());
+ assertEquals("2", components.get(1).getName());
+ assertEquals(2, components.size());
+
container.add(1, ObjectType.WINDOW, "1");
- assertEquals("0", container.get(0).getName());
- assertEquals("1", container.get(1).getName());
- assertEquals("2", container.get(2).getName());
- assertEquals(3, container.size());
+ assertEquals("0", components.get(0).getName());
+ assertEquals("1", components.get(1).getName());
+ assertEquals("2", components.get(2).getName());
+ assertEquals(3, components.size());
- container.add(0, container.get(2));
+ components.add(0, components.get(2));
- assertEquals("2", container.get(0).getName());
- assertEquals("0", container.get(1).getName());
- assertEquals("1", container.get(2).getName());
- assertEquals(3, container.size());
+ assertEquals("2", components.get(0).getName());
+ assertEquals("0", components.get(1).getName());
+ assertEquals("1", components.get(2).getName());
+ assertEquals(3, components.size());
}
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java 2010-02-19
21:37:44 UTC (rev 1787)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java 2010-02-20
17:47:58 UTC (rev 1788)
@@ -54,8 +54,8 @@
public void testVirtualCustomization()
{
Workspace workspace = pomService.getModel().getWorkspace();
- Customization<Preferences> customization1 =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- Customization<Preferences> customization2 =
workspace.customize("paris", customization1);
+ Customization<Preferences> customization1 =
workspace.getCustomizationContext().customize("marseille",
Preferences.CONTENT_TYPE, "WeatherPortlet", marseille);
+ Customization<Preferences> customization2 =
workspace.getCustomizationContext().customize("paris", customization1);
//
customization2.setState(paris);
@@ -76,15 +76,15 @@
public void testCustomizeWorkspace()
{
Workspace workspace = pomService.getModel().getWorkspace();
- assertNull(workspace.getCustomization("marseille"));
- Customization<Preferences> customization =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+
assertNull(workspace.getCustomizationContext().getCustomization("marseille"));
+ Customization<Preferences> customization =
workspace.getCustomizationContext().customize("marseille",
Preferences.CONTENT_TYPE, "WeatherPortlet", marseille);
assertNotNull(customization);
Preferences b = customization.getState();
assertEquals(marseille, b);
assertEquals(0, customization.getContexts().size());
assertEquals("WeatherPortlet", customization.getContentId());
assertEquals(Preferences.CONTENT_TYPE, customization.getType());
- assertEquals("marseille", workspace.nameOf(customization));
+ assertEquals("marseille",
workspace.getCustomizationContext().nameOf(customization));
}
public void testCustomizeWindow()