rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfrank...@apache.org
Subject svn commit: r1208834 - in /incubator/rave/trunk: rave-components/rave-core/ rave-components/rave-core/src/main/java/org/apache/rave/portal/model/ rave-components/rave-web/ rave-demo-gadgets/ rave-portal-dependencies/ rave-portal-resources/ rave-portal/...
Date Wed, 30 Nov 2011 22:15:03 GMT
Author: mfranklin
Date: Wed Nov 30 22:15:01 2011
New Revision: 1208834

URL: http://svn.apache.org/viewvc?rev=1208834&view=rev
Log:
Completed mapping of new o.a.r.p.model.Person to Shindig SPI (Supports RAVE-347)

Added:
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Organization.java
      - copied, changed from r1208404, incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Organization.java
Removed:
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Account.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Address.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Organization.java
Modified:
    incubator/rave/trunk/rave-components/rave-core/   (props changed)
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Person.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonAssociation.java
    incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonProperty.java
    incubator/rave/trunk/rave-components/rave-web/   (props changed)
    incubator/rave/trunk/rave-demo-gadgets/   (props changed)
    incubator/rave/trunk/rave-portal/   (props changed)
    incubator/rave/trunk/rave-portal-dependencies/   (props changed)
    incubator/rave/trunk/rave-portal-resources/   (props changed)
    incubator/rave/trunk/rave-portal/pom.xml
    incubator/rave/trunk/rave-providers/rave-opensocial-provider/   (props changed)
    incubator/rave/trunk/rave-providers/rave-w3c-provider/   (props changed)
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
    incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml
    incubator/rave/trunk/rave-shindig/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java

Propchange: incubator/rave/trunk/rave-components/rave-core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -3,3 +3,5 @@
 target
 catalog.xml
 .settings
+
+*.iml

Copied: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Organization.java
(from r1208404, incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Organization.java)
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Organization.java?p2=incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Organization.java&p1=incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Organization.java&r1=1208404&r2=1208834&rev=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Organization.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Organization.java
Wed Nov 30 22:15:01 2011
@@ -16,29 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.rave.opensocial.model;
+package org.apache.rave.portal.model;
 
 import org.apache.rave.persistence.BasicEntity;
-import org.apache.shindig.social.opensocial.model.Address;
 
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import javax.persistence.*;
 import java.util.Date;
 
 /**
  */
 @Entity
 @Table(name = "organization")
-public class Organization implements org.apache.shindig.social.opensocial.model.Organization,
BasicEntity {
+public class Organization implements BasicEntity {
 
     /**
      * The internal object ID used for references to this object. Should be generated by
the
@@ -47,352 +36,168 @@ public class Organization implements org
     @Id
     @Column(name = "entity_id")
     @GeneratedValue(strategy = GenerationType.TABLE, generator = "organizationIdGenerator")
-    @TableGenerator(name = "organizationIdGenerator", table = "RAVE_SHINDIG_SEQUENCES", pkColumnName
= "SEQ_NAME",
+    @TableGenerator(name = "organizationIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName
= "SEQ_NAME",
             valueColumnName = "SEQ_COUNT", pkColumnValue = "organization", allocationSize
= 1, initialValue = 1)
     private Long entityId;
 
     @OneToOne
     private Address address;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "description", length = 255)
     private String description;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "endDate")
     @Temporal(TemporalType.DATE)
     private Date endDate;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "field", length = 255)
     private String field;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "name", length = 255)
     private String name;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
-    @Basic
-    @Column(name = "salary", length = 255)
-    private String salary;
-
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "start_date")
     @Temporal(TemporalType.DATE)
     private Date startDate;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "sub_field", length = 255)
     private String subField;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "title", length = 255)
     private String title;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "webpage", length = 255)
     private String webpage;
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "type", length = 255)
-    private String type;
+    private String qualifier;
+
 
-    /**
-     * Part of the Organization Model
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization
-     */
     @Basic
     @Column(name = "primary_organization")
     private Boolean primary;
 
     /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getAddress()
      */
+    public Long getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(Long entityId) {
+        this.entityId = entityId;
+    }
+
     public Address getAddress() {
         return address;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setAddress(org.apache.shindig.social.opensocial.model.Address)
-     */
     public void setAddress(Address address) {
         this.address = address;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getDescription()
-     */
     public String getDescription() {
         return description;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setDescription(String)
-     */
     public void setDescription(String description) {
         this.description = description;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getEndDate()
-     */
     public Date getEndDate() {
-        if (endDate == null) {
-            return null;
-        }
-        return new Date(endDate.getTime());
+        return endDate;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setEndDate(java.util.Date)
-     */
     public void setEndDate(Date endDate) {
-        if (endDate == null) {
-            this.endDate = null;
-        } else {
-            this.endDate = new Date(endDate.getTime());
-        }
+        this.endDate = endDate;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getField()
-     */
     public String getField() {
         return field;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setField(String)
-     */
     public void setField(String field) {
         this.field = field;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getName()
-     */
     public String getName() {
         return name;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setName(String)
-     */
     public void setName(String name) {
         this.name = name;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getSalary()
-     */
-    public String getSalary() {
-        return salary;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setSalary(String)
-     */
-    public void setSalary(String salary) {
-        this.salary = salary;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getStartDate()
-     */
     public Date getStartDate() {
-        if (startDate == null) {
-            return null;
-        }
-        return new Date(startDate.getTime());
+        return startDate;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setStartDate(java.util.Date)
-     */
     public void setStartDate(Date startDate) {
-        if (startDate == null) {
-            this.startDate = null;
-        } else {
-            this.startDate = new Date(startDate.getTime());
-        }
+        this.startDate = startDate;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getSubField()
-     */
     public String getSubField() {
         return subField;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setSubField(String)
-     */
     public void setSubField(String subField) {
         this.subField = subField;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getTitle()
-     */
     public String getTitle() {
         return title;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setTitle(String)
-     */
     public void setTitle(String title) {
         this.title = title;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getWebpage()
-     */
     public String getWebpage() {
         return webpage;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setWebpage(String)
-     */
     public void setWebpage(String webpage) {
         this.webpage = webpage;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getType()
-     */
-    public String getType() {
-        return type;
+    public String getQualifier() {
+        return qualifier;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setType(String)
-     */
-    public void setType(String type) {
-        this.type = type;
+    public void setQualifier(String qualifier) {
+        this.qualifier = qualifier;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#getPrimary()
-     */
     public Boolean getPrimary() {
         return primary;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see org.apache.shindig.social.opensocial.model.Organization#setPrimary(Boolean)
-     */
     public void setPrimary(Boolean primary) {
         this.primary = primary;
     }
 
-    /**
-     */
-    public Long getEntityId() {
-        return entityId;
-    }
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
 
-    public void setEntityId(Long entityId) {
-        this.entityId = entityId;
+        Organization that = (Organization) o;
+
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return
false;
+
+        return true;
     }
 
+    @Override
+    public int hashCode() {
+        return entityId != null ? entityId.hashCode() : 0;
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Person.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Person.java?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Person.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/Person.java
Wed Nov 30 22:15:01 2011
@@ -112,17 +112,21 @@ public class Person implements BasicEnti
     protected String status;
 
     @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
-    @JoinTable(name = "person_address_join",
+    @JoinTable(name = "person_address_jn",
             joinColumns = @JoinColumn(name = "address_id", referencedColumnName = "entity_id"),
             inverseJoinColumns = @JoinColumn(name="person_id", referencedColumnName = "entity_id"))
     protected List<Address> addresses;
 
+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+    @JoinColumn(name="person_id", referencedColumnName = "entity_id")
+    protected List<Organization> organizations;
+
     @OneToMany(targetEntity = PersonProperty.class)
     @JoinColumn(name = "person_id", referencedColumnName = "entity_id")
     protected List<PersonProperty> properties;
 
     @ManyToMany(fetch = FetchType.LAZY)
-    @JoinTable(name = "person_friends_jn",
+    @JoinTable(name = "person_association",
             joinColumns = @JoinColumn(name = "follower_id", referencedColumnName = "entity_id"),
             inverseJoinColumns = @JoinColumn(name = "followed_id", referencedColumnName =
"entity_id"))
     protected List<Person> friends;
@@ -247,5 +251,29 @@ public class Person implements BasicEnti
         this.friends = friends;
     }
 
+    public List<Organization> getOrganizations() {
+        return organizations;
+    }
+
+    public void setOrganizations(List<Organization> organizations) {
+        this.organizations = organizations;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        Person person = (Person) o;
+
+        if (entityId != null ? !entityId.equals(person.entityId) : person.entityId != null)
return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return entityId != null ? entityId.hashCode() : 0;
+    }
 }
 

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonAssociation.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonAssociation.java?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonAssociation.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonAssociation.java
Wed Nov 30 22:15:01 2011
@@ -72,4 +72,21 @@ public class PersonAssociation implement
     public void setFollowed(Person followed) {
         this.followed = followed;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        PersonAssociation that = (PersonAssociation) o;
+
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return
false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return entityId != null ? entityId.hashCode() : 0;
+    }
 }

Modified: incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonProperty.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonProperty.java?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonProperty.java
(original)
+++ incubator/rave/trunk/rave-components/rave-core/src/main/java/org/apache/rave/portal/model/PersonProperty.java
Wed Nov 30 22:15:01 2011
@@ -113,4 +113,21 @@ public class PersonProperty implements B
     public void setExtendedValue(String extendedValue) {
         this.extendedValue = extendedValue;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        PersonProperty that = (PersonProperty) o;
+
+        if (entityId != null ? !entityId.equals(that.entityId) : that.entityId != null) return
false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return entityId != null ? entityId.hashCode() : 0;
+    }
 }
\ No newline at end of file

Propchange: incubator/rave/trunk/rave-components/rave-web/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -5,3 +5,5 @@ target
 .classpath
 
 .project
+
+*.iml

Propchange: incubator/rave/trunk/rave-demo-gadgets/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -2,3 +2,5 @@
 target
 .classpath
 .project
+
+*.iml

Propchange: incubator/rave/trunk/rave-portal/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -3,3 +3,5 @@
 target
 nbactions.xml
 .settings
+
+*.iml

Propchange: incubator/rave/trunk/rave-portal-dependencies/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -5,3 +5,5 @@ target
 .project
 
 .classpath
+
+*.iml

Propchange: incubator/rave/trunk/rave-portal-resources/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -3,3 +3,5 @@
 target
 catalog.xml
 .settings
+
+*.iml

Modified: incubator/rave/trunk/rave-portal/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/pom.xml?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/pom.xml (original)
+++ incubator/rave/trunk/rave-portal/pom.xml Wed Nov 30 22:15:01 2011
@@ -43,7 +43,7 @@
         <!-- if you want to start remote debugging session suspended
   override on command line with -Dcargo.debug.suspend=y -->
         <cargo.debug.suspend>n</cargo.debug.suspend>
-
+        <cargo.args></cargo.args>
     </properties>
 
     <dependencies>
@@ -123,7 +123,7 @@
                     <configuration>
                         <properties>
                             <cargo.jvmargs>
-                                <![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend}
-noverify ${javaagent}]]>
+                                <![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=${cargo.debug.address},server=y,suspend=${cargo.debug.suspend}
-noverify ${javaagent} ${cargo.args}]]>
                             </cargo.jvmargs>
                             <cargo.tomcat.context.reloadable>true</cargo.tomcat.context.reloadable>
                         </properties>

Propchange: incubator/rave/trunk/rave-providers/rave-opensocial-provider/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -5,3 +5,5 @@ target
 .settings
 
 .classpath
+
+*.iml

Propchange: incubator/rave/trunk/rave-providers/rave-w3c-provider/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Nov 30 22:15:01 2011
@@ -5,3 +5,5 @@ target
 .classpath
 
 .settings
+
+*.iml

Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
(original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
Wed Nov 30 22:15:01 2011
@@ -20,16 +20,15 @@
 package org.apache.rave.opensocial.service.impl;
 
 import org.apache.rave.exception.NotSupportedException;
-import org.apache.rave.portal.model.PersonProperty;
+import org.apache.rave.portal.model.*;
 import org.apache.rave.portal.model.util.ModelUtils;
 import org.apache.rave.util.CollectionUtils;
 import org.apache.shindig.protocol.model.Enum;
 import org.apache.shindig.protocol.model.EnumImpl;
-import org.apache.shindig.social.core.model.BodyTypeImpl;
-import org.apache.shindig.social.core.model.ListFieldImpl;
-import org.apache.shindig.social.core.model.UrlImpl;  
-import org.apache.shindig.social.core.model.NameImpl;
+import org.apache.shindig.social.core.model.*;
 import org.apache.shindig.social.opensocial.model.*;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.Organization;
 
 import java.io.Serializable;
 import java.text.ParseException;
@@ -87,7 +86,10 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<Account> getAccounts() {
-        //return displayField(Field.ACCOUNTS) ? CollectionUtils.<Account>toBaseTypedList(internal.getAccounts())
: null;
+        if(displayField(Field.ACCOUNTS)) {
+            List<PersonProperty> properties = getFromProperties(Field.ACCOUNTS);
+            return convertAccounts(properties);
+        }
         return null;
     }
 
@@ -108,8 +110,7 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<Address> getAddresses() {
-        //return displayField(Field.ADDRESSES) ? CollectionUtils.<Address>toBaseTypedList(internal.getAddresses())
: null;
-        return null;
+        return displayField(Field.ADDRESSES) ? convertAddresses(internal.getAddresses())
: null;        
     }
 
     @Override
@@ -199,9 +200,23 @@ public class FieldRestrictingPerson impl
         throw new NotSupportedException();
     }
 
+    /**
+     * Since addresses are stored as a first class relation to the Rave person, the simplest
way to set current location
+     * is to store a pointer in the properties to the qualifier for the address in the list.
+     *
+     * NOTE: This requires that the qualifier be set on all addresses
+     * @return a valid address if the qualifier is found; null otherwise
+     */
     @Override
     public Address getCurrentLocation() {
-        //return displayField(Field.CURRENT_LOCATION) ? internal.getCurrentLocation() : null;
+        String qualifier = getSingleValueFromProperties(Field.CURRENT_LOCATION);
+        if(qualifier != null) {
+            for(org.apache.rave.portal.model.Address address : internal.getAddresses()) {
+                if(qualifier.equals(address.getQualifier())) {
+                    return convertAddress(address);
+                }
+            }
+        }
         return null;
     }
 
@@ -294,7 +309,7 @@ public class FieldRestrictingPerson impl
 
     @Override
     public Boolean getHasApp() {
-        return displayField(Field.HAS_APP) ? false : null;
+        return null;
     }
 
     @Override
@@ -466,8 +481,7 @@ public class FieldRestrictingPerson impl
 
     @Override
     public List<Organization> getOrganizations() {
-        //return displayField(Field.ORGANIZATIONS) ? CollectionUtils.<Organization>toBaseTypedList(internal.getOrganizations())
: null;
-        return null;
+        return displayField(Field.ORGANIZATIONS) ? convertOrganizations(internal.getOrganizations())
: null;
     }
 
     @Override
@@ -812,8 +826,33 @@ public class FieldRestrictingPerson impl
     private static Url convertToUrl(PersonProperty property) {
         return new UrlImpl(property.getValue(), property.getExtendedValue(), property.getQualifier());
     }
+    
+    private List<Address> convertAddresses(List<org.apache.rave.portal.model.Address>
addresses) {
+        List<Address> converted = new ArrayList<Address>();
+        if(addresses != null) {
+            for(org.apache.rave.portal.model.Address address : addresses) {
+                converted.add(convertAddress(address));
+            }
+        }
+        return converted;
+    }
+
+    private Address convertAddress(org.apache.rave.portal.model.Address address) {
+        Address converted = new AddressImpl(address.getFormatted());
+        converted.setCountry(address.getCountry());
+        converted.setLatitude(address.getLatitude());
+        converted.setLocality(address.getLocality());
+        converted.setLongitude(address.getLongitude());
+        converted.setPostalCode(address.getPostalCode());
+        converted.setRegion(address.getRegion());
+        converted.setStreetAddress(address.getStreetAddress());
+        converted.setType(address.getQualifier());
+        converted.setPrimary(address.getPrimary());
+        return converted;
+    }
 
-    protected static Map<String, List<PersonProperty>> createPropertyMap(List<PersonProperty>
properties) {
+
+    private static Map<String, List<PersonProperty>> createPropertyMap(List<PersonProperty>
properties) {
         Map<String, List<PersonProperty>> map = new HashMap<String, List<PersonProperty>>();
         for(PersonProperty property : properties) {
             List<PersonProperty> propertyList;
@@ -828,4 +867,46 @@ public class FieldRestrictingPerson impl
         }
         return map;
     }
+
+    private static List<Account> convertAccounts(List<PersonProperty> properties)
{
+        List<Account> accounts = new ArrayList<Account>();
+        for(PersonProperty property : properties) {
+            Account account = convertToAccount(property);
+            accounts.add(account);
+        }
+        return accounts;
+    }
+
+    private static Account convertToAccount(PersonProperty property) {
+        Account account = new AccountImpl();
+        account.setUsername(property.getValue());
+        account.setUserId(property.getExtendedValue());
+        account.setDomain(property.getQualifier());
+        return account;
+    }
+
+    private List<Organization> convertOrganizations(List<org.apache.rave.portal.model.Organization>
organizations) {
+        List<Organization> converted = new ArrayList<Organization>();
+        if(organizations != null) {
+            for(org.apache.rave.portal.model.Organization org : organizations) {
+                converted.add(convertOrganization(org));
+            }
+        }
+        return converted;
+    }
+
+    private Organization convertOrganization(org.apache.rave.portal.model.Organization org)
{
+        Organization converted = new OrganizationImpl();
+        converted.setAddress(convertAddress(org.getAddress()));
+        converted.setDescription(org.getDescription());
+        converted.setStartDate(org.getStartDate());
+        converted.setEndDate(org.getEndDate());
+        converted.setField(org.getField());
+        converted.setName(org.getName());
+        converted.setSubField(org.getSubField());
+        converted.setType(org.getQualifier());
+        converted.setTitle(org.getTitle());
+        converted.setWebpage(org.getWebpage());
+        return converted;
+    }
 }

Modified: incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml Wed Nov
30 22:15:01 2011
@@ -28,9 +28,7 @@
       <class>org.apache.rave.portal.model.PersonAssociation</class>
       <class>org.apache.rave.portal.model.PersonProperty</class>
       <class>org.apache.rave.portal.model.Address</class>
-      <class>org.apache.rave.opensocial.model.Account</class>
-      <class>org.apache.rave.opensocial.model.Address</class>
-      <class>org.apache.rave.opensocial.model.Organization</class>
+      <class>org.apache.rave.portal.model.Organization</class>
       <class>org.apache.rave.opensocial.model.ApplicationData</class>
       <class>org.apache.rave.opensocial.repository.impl.JpaApplicationDataRepository$JpaSerializableApplicationData</class>
       <class>org.apache.rave.gadgets.oauth.model.OAuthTokenInfo</class>

Modified: incubator/rave/trunk/rave-shindig/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java?rev=1208834&r1=1208833&r2=1208834&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
(original)
+++ incubator/rave/trunk/rave-shindig/src/test/java/org/apache/rave/opensocial/service/FieldRestrictingPersonTest.java
Wed Nov 30 22:15:01 2011
@@ -73,12 +73,21 @@ public class FieldRestrictingPersonTest 
     private static final String IM_2 = "skypename";
     private static final String LINK_VALUE = "linkValue";
     private static final String LINK_TEXT = "linkText";
+    private static final String STREET = "1 Long Road";
+    private static final String CITY = "Big City";
+    private static final String STATE = "TX";
+    private static final String COUNTRY = "USA";
+    private static final float LATITUDE = 10234.12F;
+    private static final float LONGITUDE = 0.0F;
+    private static final String POSTAL_CODE = "00000";
+    private static final String QUALIFIER = "Home";
+    private static final String ID = "1";
 
 
     @Test
     public void getId() {
         Person p = new FieldRestrictingPerson(getTestPerson(), null);
-        assertThat(p.getId(), is(equalTo("1")));
+        assertThat(p.getId(), is(equalTo(ID)));
     }
     @Test
     public void getDisplayName() {
@@ -386,6 +395,32 @@ public class FieldRestrictingPersonTest 
         assertThat(p.getStatus(), is(equalTo(STATUS)));
     }
 
+    @Test
+    public void getAddresses_set() {
+        Person p = new FieldRestrictingPerson(getTestPerson(), getFieldSet(Person.Field.ADDRESSES));
+        assertThat(p.getAddresses().size(), is(equalTo(2)));
+        assertThat(p.getAddresses().get(1).getStreetAddress(), is(equalTo(STREET)));
+        assertThat(p.getAddresses().get(1).getLocality(), is(equalTo(CITY)));
+        assertThat(p.getAddresses().get(1).getRegion(), is(equalTo(STATE)));
+        assertThat(p.getAddresses().get(1).getCountry(), is(equalTo(COUNTRY)));
+        assertThat(p.getAddresses().get(1).getLatitude(), is(equalTo(LATITUDE)));
+        assertThat(p.getAddresses().get(1).getLongitude(), is(equalTo(LONGITUDE)));
+        assertThat(p.getAddresses().get(1).getPostalCode(), is(equalTo(POSTAL_CODE)));
+        assertThat(p.getAddresses().get(1).getType(), is(equalTo(QUALIFIER)));
+    }
+
+    @Test
+    public void getCurrentLocation_set() {
+        Person p = new FieldRestrictingPerson(getTestPerson(), getFieldSet(Person.Field.CURRENT_LOCATION));
+        assertThat(p.getCurrentLocation().getStreetAddress(), is(equalTo(STREET)));
+    }
+
+    @Test
+    public void getCurrentLocation_notset() {
+        Person p = new FieldRestrictingPerson(getTestPerson(), getFieldSet(Person.Field.ADDRESSES));
+        assertThat(p.getCurrentLocation(), is(nullValue()));
+    }
+
     @Test(expected = NotSupportedException.class)
     public void setStatus() {
         new FieldRestrictingPerson(null, null).setStatus(SUFFIX);
@@ -600,7 +635,6 @@ public class FieldRestrictingPersonTest 
         person.setHonorificSuffix(SUFFIX);
         person.setPreferredName(PREFERRED_NAME);
         person.setStatus(STATUS);
-        person.setAddresses(null);
         List<PersonProperty> properties = new ArrayList<PersonProperty>();
         properties.add(new PersonProperty(1L, "gender", Person.Gender.female.toString(),
null, "", false));
         properties.add(new PersonProperty(1L, "drinker", Drinker.HEAVILY.toString(), null,
"", false));
@@ -617,7 +651,23 @@ public class FieldRestrictingPersonTest 
         properties.add(new PersonProperty(1L, "activities", ACTIVITY_2, null, "", false));
         properties.add(new PersonProperty(1L, "profileSong", LINK_VALUE, LINK_TEXT, null,
false));
         properties.add(new PersonProperty(1L, "lookingFor", LookingFor.FRIENDS.toString(),
null, null, false));
+        properties.add(new PersonProperty(1L, "currentLocation", QUALIFIER, null, null, null));
+        properties.add(new PersonProperty(1L, "account", IM_1, "1", IM_PROVIDER_1, false));
         person.setProperties(properties);
+        org.apache.rave.portal.model.Address address = new org.apache.rave.portal.model.Address();
+        address.setCountry(COUNTRY);
+        address.setLatitude(LATITUDE);
+        address.setLongitude(LONGITUDE);
+        address.setLocality(CITY);
+        address.setRegion(STATE);
+        address.setPostalCode(POSTAL_CODE);
+        address.setStreetAddress(STREET);
+        address.setQualifier(QUALIFIER);
+        List<org.apache.rave.portal.model.Address> addresses = new ArrayList<org.apache.rave.portal.model.Address>();
+        addresses.add(new org.apache.rave.portal.model.Address());
+        addresses.add(address);
+        person.setAddresses(addresses);
+
         return person;
     }
 



Mime
View raw message