portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r733524 [4/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...
Date Sun, 11 Jan 2009 21:58:24 GMT
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/BaseLocalizedImpl.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/BaseLocalizedImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/BaseLocalizedImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/BaseLocalizedImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,226 @@
+/* 
+ * 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 java.util.StringTokenizer;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * BaseLocalizedImpl
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: LocalizedFieldImpl.java 708079 2008-10-27 03:15:51Z ate $
+ */
+@MappedSuperclass
+public abstract class BaseLocalizedImpl
+{
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="LOCALE_STRING")
+    private String localeField;
+
+    @PostLoad
+    private void postLoad()
+    {
+        locale = stringToLocale(localeField);
+    }    
+    @PrePersist
+    private void prePersist()
+    {
+        localeField = localeToString(locale);
+    }
+    
+    @Transient
+    protected Locale locale;
+    
+    // Implementation
+    
+    /**
+     * Default constructor
+     */
+    public BaseLocalizedImpl()
+    {
+    }
+    
+    /**
+     * Construct with locale.
+     * 
+     * @param locale
+     */
+    public BaseLocalizedImpl(Locale locale)
+    {
+        this.locale = locale;
+    }
+
+    /**
+     * @return locale.
+     */
+    public Locale getLocale()
+    {
+        return locale;
+    }
+
+    /**
+     * @param locale locale.
+     */
+    public void setLocale(Locale locale)
+    {
+        this.locale = locale;        
+    }
+
+    /**
+     * @param language locale language string.
+     */
+    public void setLanguage(String language)
+    {
+        if (language != null)
+        {
+            String[] localeArray = language.split("[-|_]");
+            String country = "";
+            String variant = "";
+            for (int i = 0; i < localeArray.length; i++)
+            {
+                if (i == 0)
+                {
+                    language = localeArray[i];
+                }
+                else if (i == 1)
+                {
+                    country = localeArray[i];
+                }
+                else if (i == 2)
+                {
+                    variant = localeArray[i];
+                }
+            }
+
+            locale = new Locale(language, country, variant);
+        }
+    }
+
+    /**
+     * @return locale language string.
+     */
+    public String getLanguage()
+    {
+        if (locale != null)
+        {
+            return locale.toString();
+        }
+        return null;
+    }
+
+    /**
+     * Convert locale into locale string field value.
+     * 
+     * @param locale locale to convert.
+     * @return locale string field value.
+     */
+    public static String localeToString(Locale locale)
+    {
+        if (locale == null)
+        {
+            return null;
+        }
+        String country = locale.getCountry();
+        String language = locale.getLanguage();
+        String variant = locale.getVariant();
+        StringBuffer buffer = new StringBuffer(40);
+        if (language != null)
+        {
+            buffer.append(language);
+        }
+        buffer.append(',');
+        if (country != null)
+        {
+            buffer.append(country);
+        }
+        buffer.append(',');
+        if (variant != null)
+        {
+            buffer.append(variant);
+        }
+        return buffer.toString().trim();
+    }
+
+    /**
+     * Convert locale string field value into locale.
+     * 
+     * @param locale locale string field value to convert.
+     * @return locale.
+     */
+    public static Locale stringToLocale(String locale)
+    {
+        if (locale == null)
+        {
+            return null;
+        }
+        StringTokenizer tokenizer = new StringTokenizer(locale, ",");
+        if (!tokenizer.hasMoreElements())
+        {
+            return JetspeedLocale.getDefaultLocale();
+        }
+        String language = tokenizer.nextToken().trim();
+        String country = null;
+        String variant = null;
+        if (tokenizer.hasMoreTokens())
+        {
+            country = tokenizer.nextToken().trim();
+        }           
+        if (tokenizer.hasMoreTokens())
+        {
+            variant = tokenizer.nextToken().trim();
+        }
+        if (country != null && language != null && variant != null)
+        {
+            return new Locale (language, country, variant);
+        }
+        else if (country != null && language != null)
+        {
+            return new Locale(language, country);
+        }
+        else if (language != null)
+        {
+            return new Locale(language, ""); // JDK 1.3 compatibility
+        }
+        else
+        {
+            return JetspeedLocale.getDefaultLocale();                
+        }
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeDescriptionImpl.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/CustomPortletModeDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeDescriptionImpl.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;
+
+/**
+ * CustomPortletModeDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="CustomPortletModeDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.CustomPortletModeImpl")
+public class CustomPortletModeDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -985422424104349058L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=CustomPortletModeImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private CustomPortletModeImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public CustomPortletModeDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public CustomPortletModeDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (CustomPortletModeImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (CustomPortletModeImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeImpl.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/CustomPortletModeImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomPortletModeImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,206 @@
+/*
+* 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 javax.portlet.PortletMode;
+
+import org.apache.jetspeed.om.portlet.CustomPortletMode;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+@Entity (name="CustomPortletMode")
+@Table (name="CUSTOM_PORTLET_MODE")
+public class CustomPortletModeImpl implements CustomPortletMode, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 4267094423318207227L;
+
+    // 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="CUSTOM_NAME")
+    private String customName;
+    @Basic
+    @Column (name="MAPPED_NAME")
+    private String mappedName;
+    @OneToMany (targetEntity=CustomPortletModeDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+    }
+
+    @Transient
+    private Boolean portalManaged;
+    @Transient
+    private transient PortletMode customMode;
+    @Transient
+    private transient PortletMode mappedMode;
+    @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 CustomPortletModeImpl()
+    {
+    }
+    
+    public void setPortletMode(String customName)
+    {
+        this.customName = customName.toLowerCase();
+    }
+
+    public void setMappedName(String mappedName)
+    {
+        if (this.mappedName != null || this.mappedMode != null)
+        {
+            throw new IllegalArgumentException("MappedName already set");
+        } else if (mappedName != null)
+        {
+            this.mappedName = mappedName.toLowerCase();
+        }
+    }
+
+    public PortletMode getCustomMode()
+    {
+        if (customMode == null)
+        {
+            customMode = new PortletMode(customName);
+        }
+        return customMode;
+    }
+
+    public PortletMode getMappedMode()
+    {
+        if (mappedMode == null)
+        {
+            if (mappedName != null)
+            {
+                mappedMode = new PortletMode(mappedName);
+            } else
+            {
+                mappedMode = getCustomMode();
+            }
+        }
+        return mappedMode;
+    }
+
+    public int hashCode()
+    {
+        return customName != null ? customName.hashCode() : super.hashCode();
+    }
+
+    public boolean equals(Object object)
+    {
+        if (object instanceof CustomPortletModeImpl)
+            return customName.equals(((CustomPortletModeImpl) object).customName);
+        else
+            return false;
+    }
+
+    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)
+    {
+        CustomPortletModeDescriptionImpl d = new CustomPortletModeDescriptionImpl(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;
+    }
+
+    public String getPortletMode()
+    {
+        return customName;
+    }
+
+    public boolean isPortalManaged()
+    {
+        return portalManaged == null ? true : portalManaged.booleanValue();
+    }
+
+    public void setPortalManaged(boolean value)
+    {
+        portalManaged = value ? Boolean.TRUE : Boolean.FALSE;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateDescriptionImpl.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/CustomWindowStateDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateDescriptionImpl.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;
+
+/**
+ * CustomWindowStateDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="CustomWindowStateDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.CustomWindowStateImpl")
+public class CustomWindowStateDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -7392663198180514181L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=CustomWindowStateImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private CustomWindowStateImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public CustomWindowStateDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public CustomWindowStateDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (CustomWindowStateImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (CustomWindowStateImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.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/CustomWindowStateImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,195 @@
+/*
+* 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 javax.portlet.WindowState;
+
+import org.apache.jetspeed.om.portlet.CustomWindowState;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+@Entity (name="CustomWindowState")
+@Table (name="CUSTOM_WINDOW_STATE")
+public class CustomWindowStateImpl implements CustomWindowState, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -5904345359095765092L;
+
+    // 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="CUSTOM_NAME")
+    private String customName;
+    @Basic
+    @Column (name="MAPPED_NAME")
+    private String mappedName;
+    @OneToMany (targetEntity=CustomWindowStateDescriptionImpl.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 WindowState customState;
+    @Transient
+    private transient WindowState mappedState;
+    @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 CustomWindowStateImpl()
+    {
+    }
+
+    public void setWindowState(String customName)
+    {
+        this.customName = customName.toLowerCase();
+    }
+
+    public void setMappedName(String mappedName)
+    {
+        if ( this.mappedName != null || this.mappedState != null )
+        {
+            throw new IllegalArgumentException("MappedName already set");
+        }
+        else if ( mappedName != null )
+        {
+            this.mappedName = mappedName.toLowerCase();
+        }
+    }
+
+    public WindowState getCustomState()
+    {
+        if (customState == null)
+        {
+            customState = new WindowState(customName);
+        }
+        return customState;
+    }
+
+    public WindowState getMappedState()
+    {
+        if (mappedState == null)
+        {
+            if (mappedName != null)
+            {
+                mappedState = new WindowState(mappedName);
+            } else
+            {
+                mappedState = getCustomState();
+            }
+        }
+        return mappedState;
+    }
+
+    public int hashCode()
+    {
+        return customName != null ? customName.hashCode() : super.hashCode();
+    }
+
+    public boolean equals(Object object)
+    {
+        if (object instanceof CustomWindowStateImpl)
+            return customName.equals(((CustomWindowStateImpl) object).customName);
+        else
+            return false;
+    }
+
+    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)
+    {
+        CustomWindowStateDescriptionImpl d = new CustomWindowStateDescriptionImpl(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;
+    }
+
+    public String getWindowState()
+    {
+        return customName;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DescriptionImpl.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/DescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DescriptionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,102 @@
+/*
+ * 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 javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.util.JetspeedLocale;
+import org.apache.jetspeed.om.portlet.Description;
+
+/**
+ * DescriptionImpl
+ * <br>
+ * Implementation of the <code>Description</code>
+ * interface.
+ * 
+ * @see org.apache.jetspeed.om.portlet.Description
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: DescriptionImpl.java 709620 2008-11-01 01:49:31Z ate $
+ *
+ */
+@Entity
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+public abstract class DescriptionImpl extends BaseLocalizedImpl implements Description 
+{
+    private static final long serialVersionUID = -5362030217090227948L;
+
+    // Members
+    
+    @Basic
+    @Column (name="DESCRIPTION")
+    private String description;
+
+    @Transient
+    private String lang;
+
+    // Implementation
+    
+    /**
+     * Default constructor
+     */
+    public DescriptionImpl()
+    {
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public DescriptionImpl(Object owner, String lang)
+    {
+        this.lang = lang;
+        this.locale = JetspeedLocale.convertStringToLocale(lang);
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription(String value)
+    {
+        this.description = value;
+    }
+
+    public String getLang()
+    {
+        return lang == null ? JetspeedLocale.getDefaultLocale().toString() : lang;
+    }
+
+    public Locale getLocale()
+    {
+        return locale == null ? locale = JetspeedLocale.convertStringToLocale(lang) : locale;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DisplayNameImpl.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/DisplayNameImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DisplayNameImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/DisplayNameImpl.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.Locale;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.util.JetspeedLocale;
+import org.apache.jetspeed.om.portlet.DisplayName;
+
+/**
+ * DisplayNameImpl
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: DisplayNameImpl.java 709620 2008-11-01 01:49:31Z ate $
+ *
+ */
+@Entity
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DISPLAY_NAME")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+public abstract class DisplayNameImpl extends BaseLocalizedImpl implements DisplayName
+{
+    private static final long serialVersionUID = -3427008244571982919L;
+
+    // Members
+    
+    @Basic
+    @Column (name="DISPLAY_NAME")
+    protected String displayName;
+    
+    @Transient
+    protected String lang;
+
+    // Implementation
+    
+    /**
+     * Default constructor
+     */
+    public DisplayNameImpl()
+    {
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public DisplayNameImpl(Object owner, String lang)
+    {
+        this.lang = lang;
+        this.locale = JetspeedLocale.convertStringToLocale(lang);
+    }
+    
+    public String getDisplayName()
+    {
+        return displayName;
+    }
+
+    public void setDisplayName(String value)
+    {
+        this.displayName = value;
+    }
+
+    public String getLang()
+    {
+        return lang == null ? JetspeedLocale.getDefaultLocale().toString() : lang;
+    }
+
+    public Locale getLocale()
+    {
+        return locale == null ? locale = JetspeedLocale.convertStringToLocale(lang) : locale;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamDescriptionImpl.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/InitParamDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamDescriptionImpl.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;
+
+/**
+ * InitParamDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="InitParamDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.InitParamImpl")
+public class InitParamDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 4012696646296392593L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=InitParamImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="PARAMETER_ID")
+    private InitParamImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public InitParamDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public InitParamDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (InitParamImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (InitParamImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.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/InitParamImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,191 @@
+/*
+ * 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.InitParam;
+import org.apache.jetspeed.util.HashCodeBuilder;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+/**
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ */
+@Entity (name="InitParam")
+@Table (name="PARAMETER")
+public class InitParamImpl implements InitParam, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -9005569664806490067L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="PARAMETER_ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl owner;
+    @Basic
+    @Column (name="OWNER_CLASS_NAME")
+    private String ownerClassName;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="PARAMETER_VALUE")
+    private String value;
+    @OneToMany (targetEntity=InitParamDescriptionImpl.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)
+    {
+        owner = (PortletDefinitionImpl)inverse;
+    }    
+
+    // Implementation
+    
+    /**
+     * Default constructor.
+     */
+    public InitParamImpl()
+    {
+        ownerClassName = PortletDefinitionImpl.class.getName();
+    }
+    
+    /**
+     * Construct with owner and name.
+     * 
+     * @param owner
+     * @param name
+     */
+    public InitParamImpl(Object owner, String name)
+    {
+        this.owner = (PortletDefinitionImpl) owner;
+        this.ownerClassName = owner.getClass().getName();
+        this.name = name;
+    }
+    
+    public String getParamName()
+    {
+        return name;
+    }
+
+    public String getParamValue()
+    {
+        return value;
+    }
+
+    public void setParamName(String name)
+    {
+        this.name = name;
+    }
+
+    public void setParamValue(String value)
+    {
+        this.value = value;
+    }
+
+    public boolean equals(Object obj)
+    {
+        if (obj != null && obj.getClass().equals(getClass()))
+        {
+            InitParamImpl p = (InitParamImpl) obj;            
+            return (name != null && p.getParamName() != null && name.equals(p.getParamName()) && ownerClassName != null && p.ownerClassName != null && ownerClassName.equals(p.ownerClassName));
+        }
+
+        return false;
+
+    }
+
+    public int hashCode()
+    {
+        HashCodeBuilder hash = new HashCodeBuilder(17, 77);
+        return hash.append(name).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)
+    {
+        InitParamDescriptionImpl d = new InitParamDescriptionImpl(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/JetspeedServiceReferenceImpl.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/JetspeedServiceReferenceImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/JetspeedServiceReferenceImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/JetspeedServiceReferenceImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,96 @@
+/* 
+ * 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.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.Table;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.JetspeedServiceReference;
+
+/**
+ * Defines Jetspeed services supported by a portlet application.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ */
+@Entity (name="JetspeedService")
+@Table (name="JETSPEED_SERVICE")
+public class JetspeedServiceReferenceImpl implements JetspeedServiceReference, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = -3380975345535443239L;
+
+    // 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;
+
+    /* (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 JetspeedServiceReferenceImpl()
+    {        
+    }
+    
+    /**
+     * Construct with name of service.
+     * 
+     * @param name name of service.
+     */
+    public JetspeedServiceReferenceImpl(String name)
+    {
+        this.name = name;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LanguageImpl.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/LanguageImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LanguageImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LanguageImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,170 @@
+/*
+ * 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.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+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;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.om.portlet.Language;
+import org.apache.jetspeed.util.HashCodeBuilder;
+
+/**
+ * 
+ * LanguageImpl <br>
+ * Okay, base Language really has nothing to really do at all with language per
+ * se. It actually represents the localized <code>title</code> and
+ * <code>short-title</code> attributes of a portlet's definition.
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id: LanguageImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *  
+ */
+@Entity (name="Language")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="LANGUAGE")
+public class LanguageImpl extends BaseLocalizedImpl implements Language, Serializable, PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 3817645806723304558L;
+    
+    // Members
+
+    @ManyToOne (targetEntity=PortletDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="PORTLET_ID", referencedColumnName="ID")
+    private PortletDefinitionImpl def;
+    @Basic
+    @Column (name="TITLE")
+    private String title;
+    @Basic
+    @Column (name="SHORT_TITLE")
+    private String shortTitle;
+    @Basic
+    @Column (name="KEYWORDS")
+    private String keywords;
+
+    @Transient
+    private transient List<String> keywordList;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        def = (PortletDefinitionImpl)inverse;
+    }
+        
+    /**
+     * Default constructor.
+     */
+    public LanguageImpl()
+    {
+    }
+
+    public String getTitle()
+    {
+        return title;
+    }
+
+    public String getShortTitle()
+    {
+        return shortTitle;
+    }
+
+    @SuppressWarnings("unchecked")
+    public List<String> getKeywordList()
+    {
+        if ( keywordList == null )
+        {
+            if (keywords != null)
+            {
+                keywordList = new ArrayList<String>();
+                StringTokenizer tok = new StringTokenizer(keywords, ", \t");
+                while (tok.hasMoreTokens())
+                {
+                    keywordList.add(tok.nextToken());
+                }
+                keywordList = Collections.unmodifiableList(keywordList);
+                
+            }
+            else
+            {
+                keywordList = Collections.emptyList();
+            }
+        }
+        return keywordList;
+    }
+
+    public void setTitle( String title )
+    {
+        this.title = title;
+    }
+
+    public void setShortTitle( String shortTitle )
+    {
+        this.shortTitle = shortTitle;
+    }
+
+    public void setKeywords( String keywords )
+    {
+        this.keywords = keywords;
+        this.keywordList = null;
+    }
+    
+    public String getKeywords()
+    {
+        return keywords;
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if (obj != null && obj instanceof Language)
+        {
+            return obj.hashCode() == this.hashCode();
+        }
+
+        return false;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(19, 79);
+        Locale locale = getLocale();
+        hasher.append(locale.getCountry()).append(locale.getLanguage()).append(locale.getVariant());
+        return hasher.toHashCode();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LocalizedFieldImpl.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/LocalizedFieldImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/LocalizedFieldImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,137 @@
+/* 
+ * 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 javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.MappedSuperclass;
+
+import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.jetspeed.util.HashCodeBuilder;
+
+/**
+ * LocalizedFieldImpl
+ * 
+ * Implementation that represents a string value and the locale of that string
+ * 
+ * @author <a href="mailto:jford@apache.org">Jeremy Ford</a>
+ * @version $Id: LocalizedFieldImpl.java 708079 2008-10-27 03:15:51Z ate $
+ *
+ */
+@MappedSuperclass
+public abstract class LocalizedFieldImpl extends BaseLocalizedImpl implements LocalizedField
+{
+    // Members
+    
+    @Basic
+    @Column (name="COLUMN_VALUE")
+    private String value;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+
+    // Implementation
+    
+    /**
+     * Default constructor
+     */
+    public LocalizedFieldImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct field with locale and value.
+     * 
+     * @param locale
+     * @param value
+     */
+    public LocalizedFieldImpl(Locale locale, String value)
+    {
+        super(locale);
+        this.value = value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.LocalizedField#getValue()
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.LocalizedField#setValue(java.lang.String)
+     */
+    public void setValue(String value)
+    {
+        this.value = value;        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.LocalizedField#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.LocalizedField#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;        
+    }
+    
+    public String toString()
+    {
+        return "Name: " + name + " Value: " + value + " Locale: " + locale;
+    }
+    
+    public boolean equals(Object o)
+    {
+        boolean result = false;
+        
+        if(o instanceof LocalizedFieldImpl && o != null)
+        {
+            LocalizedFieldImpl localField = (LocalizedFieldImpl)o;
+            
+            result = (this.name == null) ? (localField.name == null) : (this.name.equals(localField.name));
+            result = result && ((this.value == null) ? (localField.value == null) : (this.value.equals(localField.value)));
+            result = result && ((this.locale == null) ? (localField.locale == null) : (this.locale.equals(localField.locale)));
+        }
+        
+        return result;
+    }
+    
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(27, 101);
+        hasher.append(name).append(value);
+        if(locale != null)
+        {    
+            hasher.append(locale.getCountry()).append(locale.getLanguage()).append(locale.getVariant());
+        }
+        return hasher.toHashCode();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.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/PortletApplicationDefinitionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java Sun Jan 11 13:58:21 2009
@@ -0,0 +1,576 @@
+/*
+ * 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.List;
+
+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.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.CustomPortletMode;
+import org.apache.jetspeed.om.portlet.CustomWindowState;
+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.JetspeedServiceReference;
+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.SecurityRole;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.om.portlet.UserAttributeRef;
+import org.apache.jetspeed.om.portlet.impl.AbstractPortletApplicationDefinitionImpl;
+
+/**
+ * PortletApplicationDefinitionImpl
+ * 
+ * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: PortletApplicationDefinitionImpl.java 720057 2008-11-23 22:31:00Z ate $
+ * @since 1.0
+ */
+@Entity (name="PortletApplication")
+@Table (name="PORTLET_APPLICATION")
+@NamedQueries({@NamedQuery(name="PORTLET_APPLICATION", query="select pa from PortletApplication pa where pa.name = :name"),
+               @NamedQuery(name="PORTLET_APPLICATIONS", query="select pa from PortletApplication pa")})
+public class PortletApplicationDefinitionImpl extends AbstractPortletApplicationDefinitionImpl implements PortletApplication, Serializable
+{
+    private static final long serialVersionUID = 3762187785710438592L;
+
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="APPLICATION_ID")
+    private long id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="APP_TYPE")
+    private int applicationType;
+    @Basic
+    @Column (name="CHECKSUM")
+    private String checksum;
+    @Basic
+    @Column (name="REVISION")
+    private long revision;
+    @Basic
+    @Column (name="VERSION")
+    private String version;
+    @Basic
+    @Column (name="APP_NAME")
+    private String name;
+    @Basic
+    @Column (name="CONTEXT_ROOT")
+    private String contextRoot;
+    @Basic
+    @Column (name="SECURITY_REF")
+    private String jetspeedSecurityConstraint;
+    @OneToMany (targetEntity=PortletApplicationLocalizedFieldImpl.class, mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private Collection<LocalizedField> metadataFields;
+    @OneToMany (targetEntity=PortletApplicationDescriptionImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<Description> descriptions;
+    @OneToMany (targetEntity=PortletApplicationDisplayNameImpl.class, mappedBy="owner", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<DisplayName> displayNames;    
+    @OneToMany (targetEntity=SecurityRoleImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<SecurityRole> roles;
+    @OneToMany (targetEntity=PortletDefinitionImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<PortletDefinition> portlets;
+    @OneToMany (targetEntity=CustomPortletModeImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<CustomPortletMode> customPortletModes;
+    @OneToMany (targetEntity=CustomWindowStateImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<CustomWindowState> customWindowStates;
+    @OneToMany (targetEntity=UserAttributeImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<UserAttribute> userAttributes;
+    @OneToMany (targetEntity=UserAttributeRefImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<UserAttributeRef> userAttributeRefs;
+    @OneToMany (targetEntity=JetspeedServiceReferenceImpl.class, mappedBy="app", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private List<JetspeedServiceReference> services;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (metadataFields != null)
+        {
+            metadataFields.size();
+        }
+        if (descriptions != null)
+        {
+            descriptions.size();
+        }
+        if (displayNames != null)
+        {
+            displayNames.size();
+        }
+        if (roles != null)
+        {
+            roles.size();
+        }
+        if (portlets != null)
+        {
+            portlets.size();
+        }
+        if (customPortletModes != null)
+        {
+            customPortletModes.size();
+        }
+        if (customWindowStates != null)
+        {
+            customWindowStates.size();
+        }
+        if (userAttributes != null)
+        {
+            userAttributes.size();
+        }
+        if (userAttributeRefs != null)
+        {
+            userAttributeRefs.size();
+        }
+        if (services != null)
+        {
+            services.size();
+        }
+    }
+    @PrePersist
+    private void prePersist()
+    {
+        revision++;
+    }
+
+    @Transient
+    private long checksumLong;   
+    @Transient
+    private transient PortletDefinitionCollection<LocalizedField> metadataFieldsCollection;     
+    @Transient
+    private transient PortletDefinitionList<Description> descriptionsList;     
+    @Transient
+    private transient PortletDefinitionList<DisplayName> displayNamesList;     
+    @Transient
+    private transient PortletDefinitionList<SecurityRole> rolesList;     
+    @Transient
+    private transient PortletDefinitionList<PortletDefinition> portletsList;
+    @Transient
+    private transient PortletDefinitionList<CustomPortletMode> customPortletModesList;
+    @Transient
+    private transient PortletDefinitionList<CustomWindowState> customWindowStatesList;
+    @Transient
+    private transient PortletDefinitionList<UserAttribute> userAttributesList;
+    @Transient
+    private transient PortletDefinitionList<UserAttributeRef> userAttributeRefsList;
+    @Transient
+    private transient PortletDefinitionList<JetspeedServiceReference> servicesList;
+
+    // Implementation
+    
+    /**
+     * Default constructor.
+     */
+    public PortletApplicationDefinitionImpl()
+    {
+        applicationType = PortletApplication.WEBAPP;
+        checksum = "0";
+        checksumLong = -1;
+        services = new ArrayList<JetspeedServiceReference>();
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.common.Application#getPortletName()
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.common.Application#setPortletName(String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.common.Application#getVersion()
+     */
+    public String getVersion()
+    {
+        return this.version;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.common.Application#setVersion(String)
+     */
+    public void setVersion(String version)
+    {
+        this.version = version;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.portlet.PortletApplication#setApplicationType(int)
+     */
+    public void setApplicationType(int type)
+    {
+        this.applicationType = type;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.portlet.PortletApplication#getApplicationType()
+     */
+    public int getApplicationType()
+    {
+        return applicationType;
+    }
+
+    public long getChecksum()
+    {
+        if(checksumLong == -1)
+        {
+            checksumLong = Long.parseLong(checksum);
+        }
+        return checksumLong;
+    }
+    
+    public void setChecksum(long checksum)
+    {
+        this.checksumLong = checksum;
+        this.checksum = Long.toString(checksum);
+    }
+
+    public long getRevision()
+    {
+        return revision;
+    }
+
+    public void setRevision(long revision)
+    {
+        this.revision = revision;
+    }
+    
+    public void setContextRoot(String contextRoot)
+    {
+        this.contextRoot = contextRoot;
+    }
+    
+    public String getContextRoot()
+    {
+        return contextRoot;
+    }
+    
+    public String getJetspeedSecurityConstraint()
+    {
+        return this.jetspeedSecurityConstraint;
+    }
+
+    public void setJetspeedSecurityConstraint(String constraint)
+    {
+        this.jetspeedSecurityConstraint = constraint;
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.portlet.PortletApplication#getMetadata()
+     */
+    public GenericMetadata getMetadata()
+    {
+        if (metadataFields == null)
+        {
+            metadataFields = new ArrayList<LocalizedField>();
+        }
+        if (metadataFieldsCollection == null)
+        {
+            metadataFieldsCollection = new PortletDefinitionCollection<LocalizedField>(this, metadataFields);
+        }
+        GenericMetadata metadata = new PortletApplicationMetadataImpl();
+        metadata.setFields(metadataFieldsCollection);
+        return metadata;
+    }
+    
+    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)
+    {
+        PortletApplicationDescriptionImpl d = new PortletApplicationDescriptionImpl(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;
+    }
+
+    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)
+    {
+        PortletApplicationDisplayNameImpl d = new PortletApplicationDisplayNameImpl(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<SecurityRole> getSecurityRoles()
+    {
+        if (roles == null)
+        {
+            roles = new ArrayList<SecurityRole>();
+        }
+        if (rolesList == null)
+        {
+            rolesList = new PortletDefinitionList<SecurityRole>(this, rolesList);
+        }
+        return rolesList;
+    }
+    
+    public SecurityRole addSecurityRole(String name)
+    {
+        for (SecurityRole role : getSecurityRoles())
+        {
+            if (role.getName().equals(name))
+            {
+                throw new IllegalArgumentException("Security Role "+name+" already defined");
+            }
+        }
+        SecurityRoleImpl role = new SecurityRoleImpl();
+        role.setName(name);
+        rolesList.add(role);
+        return role;
+    }
+    
+    public List<PortletDefinition> getPortlets()
+    {
+        if (portlets == null)
+        {
+            portlets = new ArrayList<PortletDefinition>();
+        }
+        if (portletsList == null)
+        {
+            portletsList = new PortletDefinitionList<PortletDefinition>(this, portlets);
+        }
+        return portletsList;
+    }
+
+    public PortletDefinition addPortlet(String name)
+    {
+        if (getPortlet(name) != null)
+        {
+            throw new IllegalArgumentException("Portlet with name: "+name+" already defined");
+        }
+        PortletDefinitionImpl portlet = new PortletDefinitionImpl();
+        portlet.setPortletName(name);
+        portlet.setApplication(this);
+        getPortlets().add(portlet);
+        return portlet;
+    }
+
+    public List<CustomPortletMode> getCustomPortletModes()
+    {
+        if (customPortletModes == null)
+        {
+            customPortletModes = new ArrayList<CustomPortletMode>();
+        }
+        if (customPortletModesList == null)
+        {
+            customPortletModesList = new PortletDefinitionList<CustomPortletMode>(this, customPortletModes);
+        }
+        return customPortletModesList;
+    }
+    
+    public CustomPortletMode addCustomPortletMode(String name)
+    {
+        if (getCustomPortletMode(name) != null)
+        {
+            throw new IllegalArgumentException("Custom PortletMode with mode name: "+name+" already defined");
+        }
+        
+        // clear transient cache
+        supportedPortletModes = null;
+        supportedCustomModes = null;
+        mappedCustomModes = null;
+        
+        CustomPortletModeImpl cpm = new CustomPortletModeImpl();
+        cpm.setPortletMode(name);
+        getCustomPortletModes().add(cpm);
+        return cpm;        
+    }
+
+    public List<CustomWindowState> getCustomWindowStates()
+    {
+        if (customWindowStates == null)
+        {
+            customWindowStates = new ArrayList<CustomWindowState>();
+        }
+        if (customWindowStatesList == null)
+        {
+            customWindowStatesList = new PortletDefinitionList<CustomWindowState>(this, customWindowStates);
+        }
+        return customWindowStatesList;
+    }
+    
+    public CustomWindowState addCustomWindowState(String name)
+    {
+        if (getCustomWindowState(name) != null)
+        {
+            throw new IllegalArgumentException("Custom WindowState with state name: "+name+" already defined");
+        }
+
+        // clear transient cache
+        supportedWindowStates = null;
+        supportedCustomStates = null;
+        mappedCustomStates = null;
+        
+        CustomWindowStateImpl cws = new CustomWindowStateImpl();
+        cws.setWindowState(name);
+        getCustomWindowStates().add(cws);
+        return cws;        
+    }
+
+    public List<UserAttribute> getUserAttributes()
+    {
+        if (userAttributes == null)
+        {
+            userAttributes = new ArrayList<UserAttribute>();
+        }
+        if (userAttributesList == null)
+        {
+            userAttributesList = new PortletDefinitionList<UserAttribute>(this, userAttributes);
+        }
+        return userAttributesList;
+    }
+
+    public UserAttribute addUserAttribute(String name)
+    {
+        if (getUserAttribute(name) != null)
+        {
+            throw new IllegalArgumentException("User attribute with name: "+name+" already defined");
+        }
+        UserAttributeImpl ua = new UserAttributeImpl();
+        ua.setName(name);
+        getUserAttributes().add(ua);
+        return ua;        
+    }
+
+    public List<UserAttributeRef> getUserAttributeRefs()
+    {
+        if (userAttributeRefs == null)
+        {
+            userAttributeRefs = new ArrayList<UserAttributeRef>();
+        }
+        if (userAttributeRefsList == null)
+        {
+            userAttributeRefsList = new PortletDefinitionList<UserAttributeRef>(this, userAttributeRefs);
+        }
+        return userAttributeRefsList;
+    }
+
+    public UserAttributeRef addUserAttributeRef(String name)
+    {
+        if (getUserAttributeRef(name) != null)
+        {
+            throw new IllegalArgumentException("User attribute reference with name: "+name+" already defined");
+        }
+        UserAttributeRefImpl uar = new UserAttributeRefImpl();
+        uar.setName(name);
+        getUserAttributeRefs().add(uar);
+        return uar;        
+    }
+
+    public List<JetspeedServiceReference> getJetspeedServices()
+    {
+        if (services == null)
+        {
+            this.services = new ArrayList<JetspeedServiceReference>();
+        }
+        if (servicesList == null)
+        {
+            this.servicesList = new PortletDefinitionList<JetspeedServiceReference>(this, services);
+        }
+        return servicesList;
+    }
+    
+    public void addJetspeedServiceReference(String name)
+    {
+        for (JetspeedServiceReference ref : getJetspeedServices())
+        {
+            if (ref.getName().equals(name))
+            {
+                throw new IllegalArgumentException("Jetspeed service: "+name+" already defined");
+            }
+        }
+        JetspeedServiceReferenceImpl ref = new JetspeedServiceReferenceImpl();
+        ref.setName(name);
+        getJetspeedServices().add(ref);
+    }
+
+    /**
+     * 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/PortletApplicationDescriptionImpl.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/PortletApplicationDescriptionImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDescriptionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDescriptionImpl.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;
+
+/**
+ * PortletApplicationDescriptionImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="PortletApplicationDescription")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DESCRIPTION")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl")
+public class PortletApplicationDescriptionImpl extends DescriptionImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 1127833149923678744L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplicationDefinitionImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public PortletApplicationDescriptionImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public PortletApplicationDescriptionImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (PortletApplicationDefinitionImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (PortletApplicationDefinitionImpl)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDisplayNameImpl.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/PortletApplicationDisplayNameImpl.java?rev=733524&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDisplayNameImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDisplayNameImpl.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;
+
+/**
+ * PortletApplicationDisplayNameImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="PortletApplicationDisplayName")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="LOCALIZED_DISPLAY_NAME")
+@DiscriminatorColumn (name="OWNER_CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl")
+public class PortletApplicationDisplayNameImpl extends DisplayNameImpl implements PortletDefinitionCollectionMember
+{
+    private static final long serialVersionUID = 1331361864671181999L;
+
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=PortletApplicationDefinitionImpl.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="OWNER_ID", referencedColumnName="APPLICATION_ID")
+    private PortletApplicationDefinitionImpl owner;
+
+    /**
+     * Default constructor
+     */
+    public PortletApplicationDisplayNameImpl()
+    {
+        super();
+    }
+    
+    /**
+     * Construct with owner and language.
+     * 
+     * @param owner description owner.
+     * @param lang description language.
+     */
+    public PortletApplicationDisplayNameImpl(Object owner, String lang)
+    {
+        super(owner, lang);
+        this.owner = (PortletApplicationDefinitionImpl)owner;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.jpa.PortletDefinitionCollectionMember#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        owner = (PortletApplicationDefinitionImpl)inverse;
+    }
+}



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


Mime
View raw message