You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2009/01/11 22:58:24 UTC

svn commit: r733524 [5/6] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: components/jetspeed-page-manager/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/ components/jetspeed-page-manager/src/main/java/org/apache...

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationLocalizedFieldImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationLocalizedFieldImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationLocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationLocalizedFieldImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * 
+ * PortletApplicationLocalizedFieldImpl
+ * 
+ * PortletApplication specific class for LocalizedFields
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: PortletApplicationLocalizedFieldImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *  
+ */
+@Entity (name="PortletApplicationMetadataField")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="PA_METADATA_FIELDS")
+public class PortletApplicationLocalizedFieldImpl extends LocalizedFieldImpl implements PortletDefinitionCollectionMember
+{
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OBJECT_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplicationDefinitionImpl parent;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        parent = (PortletApplicationDefinitionImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationMetadataImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationMetadataImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationMetadataImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationMetadataImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.jetspeed.om.portlet.impl.GenericMetadataImpl;
+
+/**
+ * 
+ * PortletApplicationMetadataImpl
+ * 
+ * PortletApplication specific class for Metadata
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: PortletApplicationMetadataImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *  
+ */
+public class PortletApplicationMetadataImpl extends GenericMetadataImpl
+{
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.GenericMetadata#addField(java.util.Locale, java.lang.String, java.lang.String)
+     */
+    public void addField(Locale locale, String name, String value)
+    {
+        PortletApplicationLocalizedFieldImpl field = new PortletApplicationLocalizedFieldImpl();
+        field.setName(name);
+        field.setValue(value);
+        field.setLocale(locale);        
+        addField(field);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.GenericMetadata#createLocalizedField()
+     */
+    public LocalizedField createLocalizedField()
+    {
+        return new PortletApplicationLocalizedFieldImpl();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollection.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollection.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollection.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollection.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * PortletDefinitionCollection
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PortletDefinitionCollection<T> extends AbstractCollection<T>
+{
+    private Object owningObject;
+    private Collection<T> collection;
+
+    /**
+     * Construct collection to maintain JPA inverse relationship.
+     * 
+     * @param owningObject owning object.
+     * @param collection managed collection.
+     */
+    public PortletDefinitionCollection(Object owningObject, Collection<T> collection)
+    {
+        super();
+        this.owningObject = owningObject;
+        this.collection = collection;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#add(java.lang.Object)
+     */
+    public boolean add(T element)
+    {
+        ((PortletDefinitionCollectionMember)element).setInverseRelationship(owningObject);
+        return collection.add(element);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#iterator()
+     */
+    public Iterator<T> iterator()
+    {
+        return new Iterator<T>()
+        {
+            private Iterator<T> iter = collection.iterator();
+            private T lastNext = null;
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#hasNext()
+             */
+            public boolean hasNext()
+            {
+                return iter.hasNext();
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#next()
+             */
+            public T next()
+            {
+                return lastNext = iter.next();
+            }
+
+            /* (non-Javadoc)
+             * @see java.util.Iterator#remove()
+             */
+            public void remove()
+            {
+                iter.remove();
+                ((PortletDefinitionCollectionMember)lastNext).setInverseRelationship(null);
+            }            
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#remove(java.lang.Object)
+     */
+    public boolean remove(Object element)
+    {
+        if (collection.remove(element))
+        {
+            ((PortletDefinitionCollectionMember)element).setInverseRelationship(null);
+            return true;
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#size()
+     */
+    public int size()
+    {
+        return collection.size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollectionMember.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollectionMember.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollectionMember.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionCollectionMember.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,33 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+/**
+ * PortletDefinitionCollectionMember
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public interface PortletDefinitionCollectionMember
+{
+    /**
+     * Accessor used to maintain JPA bidirectional relationships.
+     * 
+     * @param inverse bidirectional relationship inverse.
+     */
+    public abstract void setInverseRelationship(Object inverse);
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * PortletDefinitionDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="PortletDefinitionDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl")
+public class PortletDefinitionDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 2937304565848638402L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public PortletDefinitionDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public PortletDefinitionDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (PortletDefinitionImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (PortletDefinitionImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDisplayNameImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDisplayNameImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDisplayNameImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionDisplayNameImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * PortletDefinitionDisplayNameImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="PortletDefinitionDisplayName")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DISPLAY_NAME")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl")
+public class PortletDefinitionDisplayNameImpl extends DisplayNameImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -5289374200402079223L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public PortletDefinitionDisplayNameImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public PortletDefinitionDisplayNameImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (PortletDefinitionImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (PortletDefinitionImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,517 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.GenericMetadata;
+import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.Language;
+import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.SecurityRoleRef;
+import org.apache.jetspeed.om.portlet.Supports;
+import org.apache.jetspeed.om.portlet.impl.AbstractPortletDefinitionImpl;
+import org.apache.jetspeed.om.portlet.impl.InlinePortletResourceBundle;
+import org.apache.jetspeed.util.HashCodeBuilder;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * 
+ * PortletDefinitionImpl
+ * 
+ * @version $Id: PortletDefinitionImpl.java 721461 2008-11-28 12:51:54Z vkumar $
+ *  
+ */
+@Entity (name="PortletDefinition")
+@Table (name="PORTLET_DEFINITION")
+@NamedQueries({@NamedQuery(name="PORTLET_DEFINITION", query="select pd from PortletDefinition pd where pd.app.name = :appName and pd.portletName = :portletName"),
+               @NamedQuery(name="PORTLET_DEFINITIONS", query="select pd from PortletDefinition pd")})
+public class PortletDefinitionImpl extends AbstractPortletDefinitionImpl implements PortletDefinition, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 4313127094480444419L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false, cascade=CascadeType.PERSIST)
+    @JoinColumn (name="APPLICATION_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplication app;    
+    @Basic
+    @Column (name="NAME")
+    protected String portletName;
+    @Basic
+    @Column (name="CLASS_NAME")
+    protected String portletClass;
+    @Basic
+    @Column (name="RESOURCE_BUNDLE")
+    protected String resourceBundle;
+    @Basic
+    @Column (name="PREFERENCE_VALIDATOR")
+    protected String preferenceValidatorClassname;
+    @Basic
+    @Column (name="EXPIRATION_CACHE")
+    private String expirationCacheField;
+    @Basic
+    @Column (name="SECURITY_REF")
+    private String jetspeedSecurityConstraint;
+    @OneToMany (targetEntity=PortletDefinitionLocalizedFieldImpl.class, mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private Collection<LocalizedField> metadataFields = null;
+    @OneToMany (targetEntity=PortletDefinitionDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+    @OneToMany (targetEntity=PortletDefinitionDisplayNameImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<DisplayName> displayNames;
+    @OneToMany (targetEntity=InitParamImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<InitParam> initParams;
+    @OneToMany (targetEntity=SecurityRoleRefImpl.class, mappedBy="def", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<SecurityRoleRef> securityRoleRefs;
+    @OneToMany (targetEntity=SupportsImpl.class, mappedBy="def", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Supports> supports;
+    @OneToMany (targetEntity=LanguageImpl.class, mappedBy="def", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Language> languages;
+
+    @PostLoad
+    private void postLoad()
+    {
+        expirationCache = ((expirationCacheField != null) ? Integer.parseInt(expirationCacheField) : null);
+        eagerFetchReferences();
+        eagerFetchCollections();
+    }    
+    private void eagerFetchReferences()
+    {
+        if (app != null)
+        {
+            app.getName();
+        }
+    }
+    private void eagerFetchCollections()
+    {
+        if (metadataFields != null)
+        {
+            metadataFields.size();
+        }
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+        if (displayNames != null)
+        {
+            displayNames.size();
+        }
+        if (initParams != null)
+        {
+            initParams.size();
+        }
+        if (securityRoleRefs != null)
+        {
+            securityRoleRefs.size();
+        }
+        if (supports != null)
+        {
+            supports.size();
+        }
+        if (languages != null)
+        {
+            languages.size();
+        }
+    }
+    @PrePersist
+    private void prePersist()
+    {
+        expirationCacheField = ((expirationCache != null) ? expirationCache.toString() : null);
+    }
+
+    @Transient
+    private Integer expirationCache;
+    @Transient
+    private transient Map<Locale,InlinePortletResourceBundle> resourceBundles = new HashMap<Locale, InlinePortletResourceBundle>();
+    @Transient
+    private transient PortletDefinitionCollection<LocalizedField> metadataFieldsCollection;     
+    @Transient
+    private transient PortletDefinitionList<Description> descriptionsList;     
+    @Transient
+    private transient PortletDefinitionList<DisplayName> displayNamesList;     
+    @Transient
+    private transient PortletDefinitionList<InitParam> initParamsList;
+    @Transient
+    private transient PortletDefinitionList<SecurityRoleRef> securityRoleRefsList;
+    @Transient
+    private transient PortletDefinitionList<Supports> supportsList;
+    @Transient
+    private transient PortletDefinitionList<Language> languagesList;
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        app = (PortletApplicationDefinitionImpl)inverse;
+    }
+        
+    // Implementation
+    
+    /**
+     * Default constructor.
+     */
+    public PortletDefinitionImpl()
+    {
+    }
+
+    public PortletApplication getApplication()
+    {
+        return app;
+    }
+    
+    public void setApplication(PortletApplication app)
+    {
+        this.app = app;
+    }
+
+    public String getPortletName()
+    {
+        return portletName;
+    }
+    
+    public void setPortletName( String name )
+    {
+        this.portletName = name;
+    }
+
+    public String getPortletClass()
+    {
+        return portletClass;
+    }
+
+    public void setPortletClass(String portletClass)
+    {
+        this.portletClass = portletClass;
+    }
+
+    public List<Language> getLanguages()
+    {
+        if ( languages == null )
+        {
+            languages = new ArrayList<Language>();
+        }
+        if ( languagesList == null )
+        {
+            languagesList = new PortletDefinitionList<Language>(this, languages);
+        }
+        return languagesList;
+    }
+    
+    public Language addLanguage(Locale locale)
+    {
+        // clear resourceBundle cache
+        resourceBundles.clear();
+        for (Language l : getLanguages())
+        {
+            if (l.getLocale().equals(locale))
+            {
+                // very special usage needed for Language as the default locale might have been created on the fly
+                // and will always be returned for getLanguage(defaultLocale)
+                return l;
+            }
+        }
+        LanguageImpl l = new LanguageImpl();
+        l.setLocale(locale);
+        languagesList.add(l);
+        return l;
+    }
+    
+    public String getPreferenceValidatorClassname()
+    {
+        return preferenceValidatorClassname;
+    }
+
+    public void setPreferenceValidatorClassname( String string )
+    {
+        preferenceValidatorClassname = string;
+    }
+
+    public GenericMetadata getMetadata()
+    {
+        if (metadataFields == null)
+        {
+            metadataFields = new ArrayList<LocalizedField>();
+        }
+        if (metadataFieldsCollection == null)
+        {
+            metadataFieldsCollection = new PortletDefinitionCollection<LocalizedField>(this, metadataFields);
+        }
+        GenericMetadata metadata = new PortletDefinitionMetadataImpl();
+        metadata.setFields(metadataFieldsCollection);
+        return metadata;
+    }
+
+    /**
+     * @return
+     */
+    public String getResourceBundle()
+    {
+        return resourceBundle;
+    }
+
+    /**
+     * @param string
+     */
+    public void setResourceBundle(String string)
+    {
+        resourceBundle = string;
+    }
+    
+    public String getJetspeedSecurityConstraint()
+    {
+        return this.jetspeedSecurityConstraint;
+    }
+
+    public void setJetspeedSecurityConstraint(String constraint)
+    {
+        this.jetspeedSecurityConstraint = constraint;
+    }
+    
+    public boolean isSameIdentity(PortletDefinition other)
+    {
+        long otherId = 0;
+        if (other != null && other instanceof PortletDefinitionImpl)
+        {
+            otherId = ((PortletDefinitionImpl)other).id;
+        }
+        return id != 0 && otherId != 0 && id == otherId;
+    }
+
+    public boolean equals( Object obj )
+    {
+        if (obj != null && obj.getClass().equals(getClass()))
+        {
+            PortletDefinitionImpl pd = (PortletDefinitionImpl) obj;
+            boolean sameId = id != 0 && pd.id != 0 && id == pd.id;
+            if (sameId)
+            {
+                return true;
+            }
+            String otherAppName = pd.getApplication() != null ? pd.getApplication().getName() : null;
+            boolean sameAppName = (app != null && app.getName() != null && otherAppName != null && app.getName().equals(otherAppName));
+            return sameAppName && (pd.getPortletName() != null && portletName != null && pd.getPortletName().equals(portletName));
+        }
+        return false;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(1, 3);
+        hasher.append(portletName);
+        hasher.append(id);
+        if (app != null)
+        {
+            hasher.append(app.getName());
+        }
+        return hasher.toHashCode();
+    }
+
+    public List<SecurityRoleRef> getSecurityRoleRefs()
+    {
+        if (securityRoleRefs == null)
+        {
+            securityRoleRefs = new ArrayList<SecurityRoleRef>();
+        }
+        if (securityRoleRefsList == null)
+        {
+            securityRoleRefsList = new PortletDefinitionList<SecurityRoleRef>(this, securityRoleRefs);
+        }
+        return securityRoleRefsList;
+    }
+    
+    public SecurityRoleRef addSecurityRoleRef(String roleName)
+    {
+        if (getSecurityRoleRef(roleName) != null)
+        {
+            throw new IllegalArgumentException("Security role reference for role: "+roleName+" already defined");
+        }
+        SecurityRoleRefImpl srr = new SecurityRoleRefImpl();
+        srr.setRoleName(roleName);
+        securityRoleRefsList.add(srr);
+        return srr;        
+    }
+    
+    public List<Supports> getSupports()
+    {
+        if (supports == null)
+        {
+            supports = new ArrayList<Supports>();
+        }
+        if (supportsList == null)
+        {
+            supportsList = new PortletDefinitionList<Supports>(this, supports);
+        }
+        return supportsList;
+    }
+    
+    public Supports addSupports(String mimeType)
+    {
+        if (getSupports(mimeType) != null)
+        {
+            throw new IllegalArgumentException("Supports for mime type: "+mimeType+" already defined");
+        }
+        SupportsImpl s = new SupportsImpl();
+        s.setMimeType(mimeType);
+        supportsList.add(s);
+        return s;        
+    }
+    
+    public int getExpirationCache()
+    {
+        return expirationCache != null ? expirationCache.intValue() : 0;
+    }
+
+    public void setExpirationCache(int value)
+    {
+        expirationCache = new Integer(value);
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        if (descriptions == null)
+        {
+            descriptions = new ArrayList<Description>();
+        }
+        if (descriptionsList == null)
+        {
+            descriptionsList = new PortletDefinitionList<Description>(this, descriptions);
+        }
+        return descriptionsList;
+    }
+    
+    public Description addDescription(String lang)
+    {
+        PortletDefinitionDescriptionImpl d = new PortletDefinitionDescriptionImpl(this, lang);
+        for (Description desc : getDescriptions())
+        {
+            if (desc.getLocale().equals(d.getLocale()))
+            {
+                throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
+            }
+        }
+        getDescriptions();
+        descriptionsList.add(d);
+        return d;
+    }
+
+    public List<DisplayName> getDisplayNames()
+    {
+        if (displayNames == null)
+        {
+            displayNames = new ArrayList<DisplayName>();
+        }
+        if (displayNamesList == null)
+        {
+            displayNamesList = new PortletDefinitionList<DisplayName>(this, displayNames);
+        }
+        return displayNamesList;
+    }
+    
+    public DisplayName addDisplayName(String lang)
+    {
+        PortletDefinitionDisplayNameImpl d = new PortletDefinitionDisplayNameImpl(this, lang);
+        for (DisplayName dn : getDisplayNames())
+        {
+            if (dn.getLocale().equals(d.getLocale()))
+            {
+                throw new IllegalArgumentException("DisplayName for language: "+d.getLocale()+" already defined");
+            }
+        }
+        displayNamesList.add(d);
+        return d;
+    }
+
+    public List<InitParam> getInitParams()
+    {
+        if (initParams == null)
+        {
+            initParams = new ArrayList<InitParam>();
+        }
+        if (initParamsList == null)
+        {
+            initParamsList = new PortletDefinitionList<InitParam>(this, initParams);
+        }
+        return initParamsList;
+    }
+    
+    public InitParam addInitParam(String paramName)
+    {
+        if (getInitParam(paramName) != null)
+        {
+            throw new IllegalArgumentException("Init parameter: "+paramName+" already defined");
+        }
+        InitParamImpl param = new InitParamImpl(this, paramName);
+        getInitParams();
+        initParamsList.add(param);
+        return param;
+    }
+
+    /**
+     * Get new persistent status.
+     * 
+     * @return whether object is new.
+     */
+    public boolean isNew()
+    {
+        return (id == 0);
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionList.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionList.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.util.AbstractList;
+import java.util.List;
+
+/**
+ * PortletDefinitionList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PortletDefinitionList<T> extends AbstractList<T>
+{
+    private Object owningObject;
+    private List<T> list;
+
+    /**
+     * Construct list to maintain JPA inverse relationship.
+     * 
+     * @param owningObject owning object.
+     * @param list managed list.
+     */
+    public PortletDefinitionList(Object owningObject, List<T> list)
+    {
+        super();
+        this.owningObject = owningObject;
+        this.list = list;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractList#add(int, java.lang.Object)
+     */
+    public void add(int index, T element)
+    {
+        ((PortletDefinitionCollectionMember)element).setInverseRelationship(owningObject);
+        list.add(index, element);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractList#get(int)
+     */
+    public T get(int index)
+    {
+        return list.get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractList#remove(int)
+     */
+    public T remove(int index)
+    {
+        T element = list.remove(index);
+        if (element != null)
+        {
+            ((PortletDefinitionCollectionMember)element).setInverseRelationship(null);
+        }
+        return element;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractList#set(int, java.lang.Object)
+     */
+    public T set(int index, T element)
+    {
+        ((PortletDefinitionCollectionMember)element).setInverseRelationship(owningObject);
+        T removedElement = list.set(index, element);
+        if (removedElement != null)
+        {
+            ((PortletDefinitionCollectionMember)removedElement).setInverseRelationship(null);
+        }
+        return removedElement;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.AbstractCollection#size()
+     */
+    public int size()
+    {
+        return list.size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionLocalizedFieldImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionLocalizedFieldImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionLocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionLocalizedFieldImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * 
+ * PortletDefinitionLocalizedFieldImpl
+ * 
+ * PortletDefinition specific class for LocalizedFields
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: PortletDefinitionLocalizedFieldImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *  
+ */
+@Entity (name="PortletDefinitionMetadataField")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="PD_METADATA_FIELDS")
+public class PortletDefinitionLocalizedFieldImpl extends LocalizedFieldImpl implements PortletDefinitionCollectionMember
+{
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OBJECT_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl parent;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        parent = (PortletDefinitionImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionMetadataImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionMetadataImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionMetadataImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionMetadataImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.util.Locale;
+
+import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.jetspeed.om.portlet.impl.GenericMetadataImpl;
+
+/**
+ * PortletDefinitionMetadataImpl
+ * <br/>
+ * PortletDefinition specific class for Metadata 
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: PortletDefinitionMetadataImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *
+ */
+public class PortletDefinitionMetadataImpl extends GenericMetadataImpl
+{
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.GenericMetadata#addField(java.util.Locale, java.lang.String, java.lang.String)
+     */
+    public void addField(Locale locale, String name, String value)
+    {
+        PortletDefinitionLocalizedFieldImpl field = new PortletDefinitionLocalizedFieldImpl();
+        field.setName(name);
+        field.setValue(value);
+        field.setLocale(locale);        
+        addField(field);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.GenericMetadata#createLocalizedField()
+     */
+    public LocalizedField createLocalizedField()
+    {
+        return new PortletDefinitionLocalizedFieldImpl();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleDescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleDescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * SecurityRoleDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="SecurityRoleDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.SecurityRoleImpl")
+public class SecurityRoleDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 7324817884867357365L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=SecurityRoleImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private SecurityRoleImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public SecurityRoleDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public SecurityRoleDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (SecurityRoleImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (SecurityRoleImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,142 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.SecurityRole;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * 
+ * @version: $Id: SecurityRoleImpl.java 720057 2008-11-23 22:31:00Z ate $
+ */
+@Entity (name="SecurityRole")
+@Table (name="SECURITY_ROLE")
+public class SecurityRoleImpl implements SecurityRole, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 283581119213077677L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="APPLICATION_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplicationDefinitionImpl app;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @OneToMany (targetEntity=SecurityRoleDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+    }
+
+    @Transient
+    private transient PortletDefinitionList<Description> descriptionsList;     
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        app = (PortletApplicationDefinitionImpl)inverse;
+    }
+    
+    // Implementation
+    
+    /**
+     * Default constructor.
+     */
+    public SecurityRoleImpl()
+    {
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        if (descriptions == null)
+        {
+            descriptions = new ArrayList<Description>();
+        }
+        if (descriptionsList == null)
+        {
+            descriptionsList = new PortletDefinitionList<Description>(this, descriptions);
+        }
+        return descriptionsList;
+    }
+    
+    public Description addDescription(String lang)
+    {
+        SecurityRoleDescriptionImpl d = new SecurityRoleDescriptionImpl(this, lang);
+        for (Description desc : getDescriptions())
+        {
+            if (desc.getLocale().equals(d.getLocale()))
+            {
+                throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
+            }
+        }
+        descriptionsList.add(d);
+        return d;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefDescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefDescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * SecurityRoleRefDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="SecurityRoleRefDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.SecurityRoleRefImpl")
+public class SecurityRoleRefDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -7650669761688679817L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=SecurityRoleRefImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private SecurityRoleRefImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public SecurityRoleRefDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public SecurityRoleRefDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (SecurityRoleRefImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (SecurityRoleRefImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.SecurityRoleRef;
+import org.apache.jetspeed.util.HashCodeBuilder;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * 
+ * SecurityRoleRefImpl
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: SecurityRoleRefImpl.java 720057 2008-11-23 22:31:00Z ate $
+ *
+ */
+@Entity (name="SecurityRoleRef")
+@Table (name="SECURITY_ROLE_REFERENCE")
+public class SecurityRoleRefImpl implements SecurityRoleRef, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -6245365009963199212L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="PORTLET_DEFINITION_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl def;
+    @Basic
+    @Column (name="ROLE_LINK")
+    private String link;
+    @Basic
+    @Column (name="ROLE_NAME")
+    private String name;
+    @OneToMany (targetEntity=SecurityRoleRefDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+    }
+
+    @Transient
+    private transient PortletDefinitionList<Description> descriptionsList;     
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        def = (PortletDefinitionImpl)inverse;
+    }
+    
+    // Implementation
+
+    public String getRoleLink()
+    {
+        return link;
+    }
+
+    public String getRoleName()
+    {
+        return name;
+    }
+
+    public void setRoleLink(String value)
+    {
+        this.link = value;
+    }
+
+    public void setRoleName(String name)
+    {
+        this.name = name;
+    }
+
+    public boolean equals(Object obj)
+    {
+        if (obj != null && obj instanceof SecurityRoleRef)
+        {
+            SecurityRoleRef aRef = (SecurityRoleRef) obj;
+            return getRoleName().equals(aRef.getRoleName());
+        }
+
+        return false;
+    }
+    
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(21, 81);
+        hasher.append(name);
+        return hasher.toHashCode();
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        if (descriptions == null)
+        {
+            descriptions = new ArrayList<Description>();
+        }
+        if (descriptionsList == null)
+        {
+            descriptionsList = new PortletDefinitionList<Description>(this, descriptions);
+        }
+        return descriptionsList;
+    }
+    
+    public Description addDescription(String lang)
+    {
+        SecurityRoleRefDescriptionImpl d = new SecurityRoleRefDescriptionImpl(this, lang);
+        for (Description desc : getDescriptions())
+        {
+            if (desc.getLocale().equals(d.getLocale()))
+            {
+                throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
+            }
+        }
+        descriptionsList.add(d);
+        return d;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SupportsImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SupportsImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SupportsImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SupportsImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.util.HashCodeBuilder;
+import org.apache.jetspeed.om.portlet.Supports;
+
+/**
+ * @version $Id: SupportsImpl.java 708230 2008-10-27 16:22:32Z ate $
+ */
+@Entity (name="Supports")
+@Table (name="PORTLET_SUPPORTS")
+public class SupportsImpl implements Supports, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 3053050293118297163L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="SUPPORTS_ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="PORTLET_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl def;
+    @Basic
+    @Column (name="MIME_TYPE")
+    private String mimeType;
+    @Basic
+    @Column (name="MODES")
+    private String modesField;
+    @Basic
+    @Column (name="STATES")
+    private String statesField;
+    
+    @PostLoad
+    private void postLoad()
+    {
+        portletModes = parseCSVList(modesField, portletModes);
+        windowStates = parseCSVList(statesField, windowStates);
+    }    
+    @PrePersist
+    private void prePersist()
+    {
+        modesField = formatCSVList(portletModes);
+        statesField = formatCSVList(windowStates);
+    }    
+
+    @Transient
+    private List<String> portletModes;
+    @Transient
+    private List<String> windowStates;
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        def = (PortletDefinitionImpl)inverse;
+    }
+    
+    // Implementation
+        
+    /**
+     * Default constructor.
+     */
+    public SupportsImpl()
+    {
+        portletModes = new ArrayList<String>();
+        windowStates = new ArrayList<String>();
+    }
+
+    public boolean equals(Object obj)
+    {
+        if (obj != null && obj instanceof Supports)
+        {
+            return mimeType.equals(((Supports)obj).getMimeType());
+        }
+        return false;
+    }
+
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(27, 87);
+        hasher.append(mimeType);
+        return hasher.toHashCode();
+    }
+
+    public String getMimeType()
+    {
+        return mimeType;
+    }
+
+    public List<String> getPortletModes()
+    {
+        return portletModes;
+    }
+
+    public List<String> getWindowStates()
+    {
+        return windowStates;
+    }
+
+    public void setMimeType(String mimeType)
+    {
+        this.mimeType = mimeType;
+    }
+
+    public void addPortletMode(String portletMode)
+    {
+        portletMode = portletMode.toLowerCase();
+        if (portletModes.contains(portletMode))
+        {
+            throw new IllegalArgumentException("PortletMode "+portletMode+" already defined");
+        }
+        portletModes.add(portletMode);
+    }
+
+    public void addWindowState(String windowState)
+    {
+        windowState = windowState.toLowerCase();
+        if (windowStates.contains(windowState))
+        {
+            throw new IllegalArgumentException("WindowState "+windowState+" already defined");
+        }
+        windowStates.add(windowState);
+    }
+
+    /**
+     * Utility to parse CSV string values into Lists.
+     *
+     * @param csv
+     * @param csvList
+     * @return parsed values list.
+     */
+    public static List<String> parseCSVList(String csv, List<String> csvList)
+    {
+        if (csvList == null)
+        {
+            csvList = new ArrayList<String>();
+        }
+        if (csv != null)
+        {
+            if (csv.indexOf(',') != -1)
+            {
+                StringTokenizer csvTokens = new StringTokenizer(csv, ",");
+                while (csvTokens.hasMoreTokens())
+                {
+                    csvList.add(csvTokens.nextToken().trim());
+                }
+            }
+            else
+            {
+                csvList.add(csv);
+            }
+        }
+        return csvList;
+    }
+
+    /**
+     * Utility to format CSV List values into strings.
+     *
+     * @param csvList
+     * @return formatted string value.
+     */
+    public static String formatCSVList(List<String> csvList)
+    {
+        if ((csvList != null) && !csvList.isEmpty())
+        {
+            StringBuffer csv = new StringBuffer();
+            Iterator<String> listIter = csvList.iterator();
+            while (listIter.hasNext())
+            {
+                if (csv.length() > 0)
+                {
+                    csv.append(",");
+                }
+                csv.append(listIter.next());
+            }
+            return csv.toString();
+        }
+        return null;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeDescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeDescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * UserAttributeDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="UserAttributeDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.UserAttributeImpl")
+public class UserAttributeDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 495731003320094423L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=UserAttributeImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private UserAttributeImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public UserAttributeDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public UserAttributeDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (UserAttributeImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (UserAttributeImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,142 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * <p>User attribute implementation.</p>
+ * 
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
+ */
+@Entity (name="UserAttribute")
+@Table (name="USER_ATTRIBUTE")
+public class UserAttributeImpl implements UserAttribute, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 1981287237356906294L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="APPLICATION_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplicationDefinitionImpl app;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @OneToMany (targetEntity=UserAttributeDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+    }
+
+    @Transient
+    private transient PortletDefinitionList<Description> descriptionsList;     
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        app = (PortletApplicationDefinitionImpl)inverse;
+    }
+    
+    // Implementation
+    
+    /**
+     * Default constructor
+     */
+    public UserAttributeImpl()
+    {
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        return (Description)JetspeedLocale.getBestLocalizedObject(getDescriptions(), locale);
+    }
+    
+    public List<Description> getDescriptions()
+    {
+        if (descriptions == null)
+        {
+            descriptions = new ArrayList<Description>();
+        }
+        if (descriptionsList == null)
+        {
+            descriptionsList = new PortletDefinitionList<Description>(this, descriptions);
+        }
+        return descriptionsList;
+    }
+    
+    public Description addDescription(String lang)
+    {
+        UserAttributeDescriptionImpl d = new UserAttributeDescriptionImpl(this, lang);
+        for (Description desc : getDescriptions())
+        {
+            if (desc.getLocale().equals(d.getLocale()))
+            {
+                throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
+            }
+        }
+        descriptionsList.add(d);
+        return d;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefDescriptionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefDescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.portlet.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * UserAttributeRefDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="UserAttributeRefDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.UserAttributeRefImpl")
+public class UserAttributeRefDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 1518109994219410606L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=UserAttributeRefImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private UserAttributeRefImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public UserAttributeRefDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public UserAttributeRefDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (UserAttributeRefImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (UserAttributeRefImpl)inverse;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org