rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zh...@apache.org
Subject svn commit: r1104678 [3/4] - in /incubator/rave/trunk: ./ rave-portal/ rave-shindig/ rave-shindig/src/main/java/ rave-shindig/src/main/java/org/ rave-shindig/src/main/java/org/apache/ rave-shindig/src/main/java/org/apache/rave/ rave-shindig/src/main/ja...
Date Wed, 18 May 2011 03:42:11 GMT
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,398 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+import org.apache.shindig.social.opensocial.jpa.api.DbObject;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.Organization;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Version;
+
+import java.util.Date;
+import static javax.persistence.CascadeType.PERSIST;
+import static javax.persistence.CascadeType.MERGE;
+import static javax.persistence.CascadeType.REFRESH;
+
+/**
+ * An organization is stored in the organization table. There may be types of organization where
+ * this class is extended. The storage contains a org_usage column which is used to discriminate the
+ * usage of each organization record. Where the record is shared the value will be shared. Classes
+ * that extend this class may have other values.
+ */
+@Entity
+@Table(name = "organization")
+@Inheritance(strategy = InheritanceType.JOINED)
+@DiscriminatorColumn(name = "org_usage")
+@DiscriminatorValue("shared")
+@NamedQuery(name = OrganizationDb.FINDBY_NAME, 
+    query = "select o from OrganizationDb o where o.name = :name ")
+public class OrganizationDb implements Organization, DbObject {
+  /**
+   * The name of the JPA named query to find the organization by name.
+   */
+  public static final String FINDBY_NAME = "q.organization.findbyname";
+  /**
+   * The name of the parameter used for the name column in JPA queries.
+   */
+  public static final String PARAM_NAME = "name";
+
+  /**
+   * The internal object ID used for references to this object. Should be generated by the
+   * underlying storage mechanism
+   */
+  @Id
+  @GeneratedValue(strategy = IDENTITY)
+  @Column(name = "oid")
+  private long objectId;
+
+  /**
+   * An optimistic locking field
+   */
+  @Version
+  @Column(name = "version")
+  protected long version;
+
+  /**
+   * The address associated with this Organization.
+   */
+  // TODO: does an organization have only one address, or many with one primary
+  @OneToOne(targetEntity = OrganizationAddressDb.class, mappedBy = "organization", cascade = {
+      PERSIST, MERGE, REFRESH })
+  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;
+
+  /**
+   * 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 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(java.lang.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());
+  }
+
+  /**
+   * {@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());
+    }
+  }
+
+  /**
+   * {@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(java.lang.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(java.lang.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(java.lang.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());
+  }
+
+  /**
+   * {@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());
+    }
+  }
+
+  /**
+   * {@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(java.lang.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(java.lang.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(java.lang.String)
+   */
+  public void setWebpage(String webpage) {
+    this.webpage = webpage;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Organization#getType()
+   */
+  public String getType() {
+    return type;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Organization#setType(java.lang.String)
+   */
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  /**
+   * {@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(java.lang.Boolean)
+   */
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.jpa.api.DbObject#getObjectId()
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAccountDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAccountDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAccountDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAccountDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,94 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * This object connects to a single account to a person, defining the relationship
+ * between the person and the account. It extends the account object, which stored its instances in
+ * the 'account' table by storing instances of this class in the 'person_account table. Records 
+ * are joined using oid, and use the same shared account discriminator.
+ */
+@Entity
+@Table(name="person_account")
+@DiscriminatorValue("sharedaccount")
+public class PersonAccountDb extends AccountDb {
+  @Basic
+  @Column(name="primary_account")
+  private Boolean primary;
+  
+  /**
+   * The person connected the account
+   */
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  private Person person;
+  
+  @Basic
+  @Column(name="type", length=255)
+  private String type;
+
+
+  public PersonAccountDb() {
+  }
+
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+
+  public Boolean getPrimary() {
+    return primary;
+  }
+
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+
+  /**
+   * @return the person
+   */
+  public Person getPerson() {
+    return person;
+  }
+
+
+  /**
+   * @param person the person to set
+   */
+  public void setPerson(Person person) {
+    this.person = person;
+  }
+
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAddressDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAddressDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAddressDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAddressDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,93 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ *
+ */
+/*
+ * This object connects to a single Address, and to a single organization, 
+ * defining the organizations relationship with the address
+ */
+@Entity
+@Table(name="person_address")
+@DiscriminatorValue(value="sharedaddress")
+public class PersonAddressDb extends AddressDb {
+  @Basic
+  @Column(name="primary_address")
+  private Boolean primary;
+  
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  private Person person;
+  
+  @Basic
+  @Column(name="type", length=255)
+  private String type;
+
+
+  public PersonAddressDb() {
+    // TODO Auto-generated constructor stub
+  }
+
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+
+  public Boolean getPrimary() {
+    return primary;
+  }
+
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+
+  /**
+   * @return the person
+   */
+  public Person getPerson() {
+    return person;
+  }
+
+
+  /**
+   * @param person the person to set
+   */
+  public void setPerson(Person person) {
+    this.person = person;
+  }
+
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,1307 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import static javax.persistence.CascadeType.ALL;
+import static javax.persistence.CascadeType.MERGE;
+import static javax.persistence.CascadeType.PERSIST;
+import static javax.persistence.CascadeType.REFRESH;
+import static javax.persistence.GenerationType.IDENTITY;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.shindig.protocol.model.Enum;
+import org.apache.shindig.protocol.model.FilterOperation;
+import org.apache.shindig.social.opensocial.jpa.api.DbObject;
+import org.apache.shindig.social.opensocial.jpa.api.FilterCapability;
+import org.apache.shindig.social.opensocial.jpa.api.FilterSpecification;
+import org.apache.shindig.social.opensocial.model.Account;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.BodyType;
+import org.apache.shindig.social.opensocial.model.Drinker;
+import org.apache.shindig.social.opensocial.model.ListField;
+import org.apache.shindig.social.opensocial.model.LookingFor;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.NetworkPresence;
+import org.apache.shindig.social.opensocial.model.Organization;
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Smoker;
+import org.apache.shindig.social.opensocial.model.Url;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * Default Implementation of the Person object in the org.apache.shindig.social.opensocial.jpa.
+ */
+@Entity
+@Table(name = "person")
+@NamedQueries(value = {
+        @NamedQuery(name = PersonDb.FINDBY_PERSONID, query = "select p from PersonDb p where p.id = :id "),
+        @NamedQuery(name = PersonDb.FINDBY_LIKE_PERSONID, query = "select p from PersonDb p where p.id like :id") })
+public class PersonDb implements Person, DbObject {
+
+    public static final String FINDBY_PERSONID = "q.person.findbypersonid";
+
+    public static final String PARAM_PERSONID = "id";
+
+    public static final String FINDBY_LIKE_PERSONID = "q.person.findbylikepersonid";
+
+    private static final String LOOKING_FOR_PROPERTY = "looking-for";
+
+    private static final String ACTIVITIES_PROPERTY = "activity";
+
+    private static final String BOOKS_PROPERTY = "book";
+
+    private static final String CARS_PROPERTY = "car";
+
+    private static final String HEROES_PROPERTY = "hero";
+
+    private static final String INTERESTS_PROPERTY = "interest";
+
+    private static final String LANGUAGES_PROPERTY = "language";
+
+    private static final String MOVIES_PROPERTY = "movie";
+
+    private static final String MUSIC_PROPERTY = "music";
+
+    private static final String FOOD_PROPERTY = "food";
+
+    private static final String QUOTES_PROPERTY = "quotes";
+
+    private static final String SPORTS_PROPERTY = "sport";
+
+    private static final String TAGS_PROPERTY = "tag";
+
+    private static final String TURNOFFS_PROPERTY = "turnoff";
+
+    private static final String TURNONS_PROPERTY = "turnon";
+
+    private static final String TVSHOWS_PROPERTY = "tvshow";
+
+    private static final Map<String, FilterSpecification> FILTER_COLUMNS = new HashMap<String, FilterSpecification>();
+
+    private static final FilterOperation[] ALL_FILTEROPTIONS = new FilterOperation[] { FilterOperation.equals,
+            FilterOperation.contains, FilterOperation.present, FilterOperation.startsWith };
+    private static final FilterOperation[] NUMERIC_FILTEROPTIONS = new FilterOperation[] { FilterOperation.equals,
+            FilterOperation.present };
+    @SuppressWarnings("unused")
+    private static final FilterOperation[] EQUALS_FILTEROPTIONS = new FilterOperation[] { FilterOperation.equals };
+
+    static {
+        FILTER_COLUMNS.put("aboutMe", new FilterSpecification("aboutMe", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("age", new FilterSpecification("age", NUMERIC_FILTEROPTIONS));
+        FILTER_COLUMNS.put("birthday", new FilterSpecification("birthday", NUMERIC_FILTEROPTIONS));
+        FILTER_COLUMNS.put("children", new FilterSpecification("children", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("displayName", new FilterSpecification("displayName", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("drinker", new FilterSpecification("drinkerDb", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("ethnicity", new FilterSpecification("ethnicity", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("fashion", new FilterSpecification("fashion", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("gender", new FilterSpecification("gender", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("happiestWhen", new FilterSpecification("happiestWhen", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("humor", new FilterSpecification("humor", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("jobInterests", new FilterSpecification("jobInterests", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("livingArrangement", new FilterSpecification("livingArrangement", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("movies", new FilterSpecification("movies", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("networkPresenceDb", new FilterSpecification("networkPresenceDb", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("nickname", new FilterSpecification("nickname", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("pets", new FilterSpecification("pets", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("politicalViews", new FilterSpecification("politicalViews", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("relationshipStatus", new FilterSpecification("relationshipStatus", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("religion", new FilterSpecification("religion", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("romance", new FilterSpecification("romance", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("scaredOf", new FilterSpecification("scaredOf", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("sexualOrientation", new FilterSpecification("sexualOrientation", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("smokerDb", new FilterSpecification("smokerDb", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("status", new FilterSpecification("status", ALL_FILTEROPTIONS));
+        FILTER_COLUMNS.put("utcOffset", new FilterSpecification("utcOffset", NUMERIC_FILTEROPTIONS));
+
+        // the following are special operations which are accepted, but work differently
+        FILTER_COLUMNS.put("topFriends", new FilterSpecification());
+        FILTER_COLUMNS.put("hasApp", new FilterSpecification());
+    }
+
+    private static final FilterCapability FILTER_CAPABILITY = new FilterCapability() {
+        /**
+         * {@inheritDoc}
+         */
+        public String findFilterableProperty(String fieldName, FilterOperation filterOperation) {
+            FilterSpecification spec = FILTER_COLUMNS.get(fieldName);
+            if (spec != null) {
+                return spec.translateProperty(filterOperation);
+            }
+            return null;
+        }
+
+    };
+
+    public static final String JPQL_FINDALLPERSON = null;
+
+    // TODO The commented out query supports sorting by friend.score but needs a join with FriendDb which returns
+    // duplicates.
+    // Using 'group by' to avoid duplicates doesn't work in HSQLDB or Derby - causes a
+    // "Not in aggregate function or group by clause" jdbc exception.
+    // public static final String JPQL_FINDPERSON_BY_FRIENDS =
+    // "select p from PersonDb p join FriendDb f on p.objectId = f.friend.objectId where p.objectId in (select f.friend.objectId from PersonDb p, FriendDb f where p.objectId = f.person.objectId and ";
+    public static final String JPQL_FINDPERSON_BY_FRIENDS = "select p from PersonDb p where p.objectId in (select f.friend.objectId from PersonDb p, FriendDb f where p.objectId = f.person.objectId and ";
+
+    public static final Object JPQL_FINDPERSON_BY_GROUP = null;
+
+    public static final Object JPQL_FINDPERSON = "select p from PersonDb p where ";
+
+    /**
+     * The internal object ID used for references to this object. Should be generated by the underlying storage
+     * mechanism
+     */
+    @Id
+    @GeneratedValue(strategy = IDENTITY)
+    @Column(name = "oid")
+    private long objectId;
+
+    /**
+     * An optimistic locking field.
+     */
+    @Version
+    @Column(name = "version")
+    protected long version;
+
+    @Basic
+    @Column(name = "about_me", length = 255)
+    protected String aboutMe = "";
+
+    @OneToMany(targetEntity = PersonPropertyDb.class, mappedBy = "person", cascade = ALL)
+    protected List<PersonPropertyDb> properties = Lists.newArrayList();
+
+    @OneToMany(targetEntity = PersonAccountDb.class, mappedBy = "person", cascade = ALL)
+    protected List<Account> accounts = Lists.newArrayList();
+
+    @Transient
+    protected List<String> activities = Lists.newArrayList();
+
+    @OneToMany(targetEntity = PersonAddressDb.class, mappedBy = "person", cascade = ALL)
+    protected List<Address> addresses = Lists.newArrayList();
+
+    @Basic
+    @Column(name = "age")
+    protected Integer age;
+
+    @ManyToOne(targetEntity = BodyTypeDb.class, cascade = ALL)
+    @JoinColumn(name = "body_type_id", referencedColumnName = "oid")
+    protected BodyType bodyType;
+
+    @Transient
+    protected List<String> books = Lists.newArrayList();
+
+    @Transient
+    protected List<String> cars = Lists.newArrayList();
+
+    @Basic
+    @Column(name = "children", length = 255)
+    protected String children = "";
+
+    /**
+   *
+   */
+    @ManyToOne(targetEntity = AddressDb.class, cascade = { PERSIST, MERGE, REFRESH })
+    @JoinColumn(name = "address_id", referencedColumnName = "oid")
+    protected Address currentLocation;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "birthday")
+    @Temporal(TemporalType.DATE)
+    protected Date birthday;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "drinker", length = 255)
+    protected String drinkerDb;
+
+    @Transient
+    protected Enum<Drinker> drinker;
+
+    @Basic
+    @Column(name = "display_name", length = 255)
+    private String displayName = "";
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = EmailDb.class, mappedBy = "person", cascade = ALL)
+    protected List<ListField> emails = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "ethnicity", length = 255)
+    protected String ethnicity = "";
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "fashion", length = 255)
+    protected String fashion = "";
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> food = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "gender", length = 255)
+    protected String genderDb;
+
+    @Transient
+    protected Gender gender;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "happiest_when", length = 255)
+    protected String happiestWhen;
+
+    /**
+   *
+   */
+    @Transient
+    protected Boolean hasApp;
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> heroes = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "humor", length = 255)
+    protected String humor;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "person_id", length = 255)
+    protected String id;
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = ImDb.class, mappedBy = "person", cascade = ALL)
+    protected List<ListField> ims = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> interests = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "job_interests", length = 255)
+    protected String jobInterests = "";
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> languagesSpoken = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "updated")
+    @Temporal(TemporalType.TIMESTAMP)
+    protected Date updated;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "living_arrangement", length = 255)
+    protected String livingArrangement;
+
+    /**
+   *
+   */
+    @Transient
+    // stored as a property, processed on get,set
+    protected List<Enum<LookingFor>> lookingFor = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> movies = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> music = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @ManyToOne(targetEntity = NameDb.class, cascade = ALL)
+    @JoinColumn(name = "name_id", referencedColumnName = "oid")
+    protected Name name;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "network_presence", length = 255)
+    protected String networkPresenceDb;
+
+    @Transient
+    protected Enum<NetworkPresence> networkPresence = new EnumDb<NetworkPresence>(NetworkPresence.XA);
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "nickname", length = 255)
+    protected String nickname;
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = PersonOrganizationDb.class, mappedBy = "person", cascade = { PERSIST, MERGE, REFRESH })
+    protected List<Organization> organizations;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "pets", length = 255)
+    protected String pets;
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = PhoneDb.class, mappedBy = "person", cascade = ALL)
+    protected List<ListField> phoneNumbers;
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = PhotoDb.class, mappedBy = "person", cascade = ALL)
+    protected List<ListField> photos;
+    @Basic
+    @Column(name = "political_views", length = 255)
+    protected String politicalViews;
+
+    @Basic
+    @Column(name = "preferredUsername", length = 255)
+    protected String preferredUsername;
+
+    /**
+   *
+   */
+    @Transient
+    protected Url profileSong;
+
+    /**
+   *
+   */
+    @Transient
+    protected Url profileVideo;
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> quotes = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "relationship_status", length = 255)
+    protected String relationshipStatus;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "religion", length = 255)
+    protected String religion;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "romance", length = 255)
+    protected String romance;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "scared_of", length = 255)
+    protected String scaredOf;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "sexual_orientation", length = 255)
+    protected String sexualOrientation;
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "smoker", length = 255)
+    protected String smokerDb;
+
+    @Transient
+    protected Enum<Smoker> smoker;
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> sports = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "status", length = 255)
+    protected String status;
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> tags = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Basic
+    @Column(name = "utc_offset")
+    protected Long utcOffset;
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> turnOffs = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> turnOns = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @Transient
+    protected List<String> tvShows = Lists.newArrayList();
+
+    /**
+   *
+   */
+    @OneToMany(targetEntity = UrlDb.class, mappedBy = "person", cascade = ALL)
+    protected List<Url> urls;
+
+    // Note: Not in the opensocial js person object directly
+    @Transient
+    private boolean isOwner = false;
+
+    @Transient
+    private boolean isViewer = false;
+
+    /**
+     * People have applications that they use, many people may use the same application, hence this is a many to many
+     * property, the link table is person_application where person_application.person_id points to person.oid and
+     * person_application.application_id points to application.oid.
+     */
+    @ManyToMany(targetEntity = ApplicationDb.class)
+    @JoinTable(name = "person_application", joinColumns = @JoinColumn(name = "person_id", referencedColumnName = "oid"), inverseJoinColumns = @JoinColumn(name = "application_id", referencedColumnName = "oid"))
+    protected List<ApplicationDb> applictions;
+
+    public PersonDb() {
+    }
+
+    public PersonDb(String id, String displayName, Name name) {
+        this.id = id;
+        this.name = name;
+        this.displayName = displayName;
+    }
+
+    public String getAboutMe() {
+        return aboutMe;
+    }
+
+    public void setAboutMe(String aboutMe) {
+        this.aboutMe = aboutMe;
+    }
+
+    public List<Account> getAccounts() {
+        return accounts;
+    }
+
+    public void setAccounts(List<Account> accounts) {
+        this.accounts = accounts;
+    }
+
+    public List<String> getActivities() {
+        return activities;
+    }
+
+    public void setActivities(List<String> activities) {
+        this.activities = activities;
+    }
+
+    public List<Address> getAddresses() {
+        return addresses;
+    }
+
+    public void setAddresses(List<Address> addresses) {
+        this.addresses = addresses;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+
+    public BodyType getBodyType() {
+        return bodyType;
+    }
+
+    public void setBodyType(BodyType bodyType) {
+        this.bodyType = bodyType;
+    }
+
+    public List<String> getBooks() {
+        return books;
+    }
+
+    public void setBooks(List<String> books) {
+        this.books = books;
+    }
+
+    public List<String> getCars() {
+        return cars;
+    }
+
+    public void setCars(List<String> cars) {
+        this.cars = cars;
+    }
+
+    public String getChildren() {
+        return children;
+    }
+
+    public void setChildren(String children) {
+        this.children = children;
+    }
+
+    public Address getCurrentLocation() {
+        return currentLocation;
+    }
+
+    public void setCurrentLocation(Address currentLocation) {
+        this.currentLocation = currentLocation;
+    }
+
+    public Date getBirthday() {
+        if (birthday == null) {
+            return null;
+        }
+        return new Date(birthday.getTime());
+    }
+
+    public void setBirthday(Date birthday) {
+        if (birthday == null) {
+            this.birthday = null;
+        } else {
+            this.birthday = new Date(birthday.getTime());
+        }
+    }
+
+    public Enum<Drinker> getDrinker() {
+        return this.drinker;
+    }
+
+    public void setDrinker(Enum<Drinker> newDrinker) {
+        this.drinker = newDrinker;
+    }
+
+    public List<ListField> getEmails() {
+        return emails;
+    }
+
+    public void setEmails(List<ListField> emails) {
+        this.emails = emails;
+    }
+
+    public String getEthnicity() {
+        return ethnicity;
+    }
+
+    public void setEthnicity(String ethnicity) {
+        this.ethnicity = ethnicity;
+    }
+
+    public String getFashion() {
+        return fashion;
+    }
+
+    public void setFashion(String fashion) {
+        this.fashion = fashion;
+    }
+
+    public List<String> getFood() {
+        return food;
+    }
+
+    public void setFood(List<String> food) {
+        this.food = food;
+    }
+
+    public Gender getGender() {
+        return gender;
+    }
+
+    public void setGender(Gender newGender) {
+        this.gender = newGender;
+    }
+
+    public String getHappiestWhen() {
+        return happiestWhen;
+    }
+
+    public void setHappiestWhen(String happiestWhen) {
+        this.happiestWhen = happiestWhen;
+    }
+
+    public Boolean getHasApp() {
+        return hasApp;
+    }
+
+    public void setHasApp(Boolean hasApp) {
+        this.hasApp = hasApp;
+    }
+
+    public List<String> getHeroes() {
+        return heroes;
+    }
+
+    public void setHeroes(List<String> heroes) {
+        this.heroes = heroes;
+    }
+
+    public String getHumor() {
+        return humor;
+    }
+
+    public void setHumor(String humor) {
+        this.humor = humor;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public List<ListField> getIms() {
+        return ims;
+    }
+
+    public void setIms(List<ListField> ims) {
+        this.ims = ims;
+    }
+
+    public List<String> getInterests() {
+        return interests;
+    }
+
+    public void setInterests(List<String> interests) {
+        this.interests = interests;
+    }
+
+    public String getJobInterests() {
+        return jobInterests;
+    }
+
+    public void setJobInterests(String jobInterests) {
+        this.jobInterests = jobInterests;
+    }
+
+    public List<String> getLanguagesSpoken() {
+        return languagesSpoken;
+    }
+
+    public void setLanguagesSpoken(List<String> languagesSpoken) {
+        this.languagesSpoken = languagesSpoken;
+    }
+
+    public Date getUpdated() {
+        if (updated == null) {
+            return null;
+        }
+        return new Date(updated.getTime());
+    }
+
+    public void setUpdated(Date updated) {
+        if (updated == null) {
+            this.updated = null;
+        } else {
+            this.updated = new Date(updated.getTime());
+        }
+    }
+
+    public String getLivingArrangement() {
+        return livingArrangement;
+    }
+
+    public void setLivingArrangement(String livingArrangement) {
+        this.livingArrangement = livingArrangement;
+    }
+
+    public List<Enum<LookingFor>> getLookingFor() {
+        return lookingFor;
+    }
+
+    public void setLookingFor(List<Enum<LookingFor>> lookingFor) {
+        this.lookingFor = lookingFor;
+    }
+
+    public List<String> getMovies() {
+        return movies;
+    }
+
+    public void setMovies(List<String> movies) {
+        this.movies = movies;
+    }
+
+    public List<String> getMusic() {
+        return music;
+    }
+
+    public void setMusic(List<String> music) {
+        this.music = music;
+    }
+
+    public Name getName() {
+        return name;
+    }
+
+    public void setName(Name name) {
+        this.name = name;
+    }
+
+    public Enum<NetworkPresence> getNetworkPresence() {
+        return networkPresence;
+    }
+
+    public void setNetworkPresence(Enum<NetworkPresence> networkPresence) {
+        this.networkPresence = networkPresence;
+    }
+
+    public String getNickname() {
+        return nickname;
+    }
+
+    public void setNickname(String nickname) {
+        this.nickname = nickname;
+    }
+
+    public List<Organization> getOrganizations() {
+        return organizations;
+    }
+
+    public void setOrganizations(List<Organization> organizations) {
+        this.organizations = organizations;
+    }
+
+    public String getPets() {
+        return pets;
+    }
+
+    public void setPets(String pets) {
+        this.pets = pets;
+    }
+
+    public List<ListField> getPhoneNumbers() {
+        return phoneNumbers;
+    }
+
+    public void setPhoneNumbers(List<ListField> phoneNumbers) {
+        this.phoneNumbers = phoneNumbers;
+    }
+
+    public List<ListField> getPhotos() {
+        return photos;
+    }
+
+    public void setPhotos(List<ListField> photos) {
+        this.photos = photos;
+    }
+
+    public String getPoliticalViews() {
+        return politicalViews;
+    }
+
+    public void setPoliticalViews(String politicalViews) {
+        this.politicalViews = politicalViews;
+    }
+
+    public String getPreferredUsername() {
+        return preferredUsername;
+    }
+
+    public void setPreferredUsername(String preferredUsername) {
+        this.preferredUsername = preferredUsername;
+    }
+
+    public Url getProfileSong() {
+        return profileSong;
+    }
+
+    public void setProfileSong(Url profileSong) {
+        this.profileSong = profileSong;
+    }
+
+    public Url getProfileVideo() {
+        return profileVideo;
+    }
+
+    public void setProfileVideo(Url profileVideo) {
+        this.profileVideo = profileVideo;
+    }
+
+    public List<String> getQuotes() {
+        return quotes;
+    }
+
+    public void setQuotes(List<String> quotes) {
+        this.quotes = quotes;
+    }
+
+    public String getRelationshipStatus() {
+        return relationshipStatus;
+    }
+
+    public void setRelationshipStatus(String relationshipStatus) {
+        this.relationshipStatus = relationshipStatus;
+    }
+
+    public String getReligion() {
+        return religion;
+    }
+
+    public void setReligion(String religion) {
+        this.religion = religion;
+    }
+
+    public String getRomance() {
+        return romance;
+    }
+
+    public void setRomance(String romance) {
+        this.romance = romance;
+    }
+
+    public String getScaredOf() {
+        return scaredOf;
+    }
+
+    public void setScaredOf(String scaredOf) {
+        this.scaredOf = scaredOf;
+    }
+
+    public String getSexualOrientation() {
+        return sexualOrientation;
+    }
+
+    public void setSexualOrientation(String sexualOrientation) {
+        this.sexualOrientation = sexualOrientation;
+    }
+
+    public Enum<Smoker> getSmoker() {
+        return this.smoker;
+    }
+
+    public void setSmoker(Enum<Smoker> newSmoker) {
+        this.smoker = newSmoker;
+    }
+
+    public List<String> getSports() {
+        return sports;
+    }
+
+    public void setSports(List<String> sports) {
+        this.sports = sports;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public List<String> getTags() {
+        return tags;
+    }
+
+    public void setTags(List<String> tags) {
+        this.tags = tags;
+    }
+
+    public Long getUtcOffset() {
+        return utcOffset;
+    }
+
+    public void setUtcOffset(Long utcOffset) {
+        this.utcOffset = utcOffset;
+    }
+
+    public List<String> getTurnOffs() {
+        return turnOffs;
+    }
+
+    public void setTurnOffs(List<String> turnOffs) {
+        this.turnOffs = turnOffs;
+    }
+
+    public List<String> getTurnOns() {
+        return turnOns;
+    }
+
+    public void setTurnOns(List<String> turnOns) {
+        this.turnOns = turnOns;
+    }
+
+    public List<String> getTvShows() {
+        return tvShows;
+    }
+
+    public void setTvShows(List<String> tvShows) {
+        this.tvShows = tvShows;
+    }
+
+    public List<Url> getUrls() {
+        return urls;
+    }
+
+    public void setUrls(List<Url> urls) {
+        this.urls = urls;
+    }
+
+    public boolean getIsOwner() {
+        return isOwner;
+    }
+
+    public void setIsOwner(boolean isOwner) {
+        this.isOwner = isOwner;
+    }
+
+    public boolean getIsViewer() {
+        return isViewer;
+    }
+
+    public void setIsViewer(boolean isViewer) {
+        this.isViewer = isViewer;
+    }
+
+    // Proxied fields
+
+    public String getProfileUrl() {
+        Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
+        return url == null ? null : url.getValue();
+    }
+
+    public void setProfileUrl(String profileUrl) {
+        Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
+        if (url != null) {
+            url.setValue(profileUrl);
+        } else {
+            setUrls(addListField(new UrlDb(profileUrl, null, PROFILE_URL_TYPE), getUrls()));
+        }
+    }
+
+    public String getThumbnailUrl() {
+        ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
+        return photo == null ? null : photo.getValue();
+    }
+
+    public void setThumbnailUrl(String thumbnailUrl) {
+        ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
+        if (photo != null) {
+            photo.setValue(thumbnailUrl);
+        } else {
+            setPhotos(addListField(new ListFieldDb(THUMBNAIL_PHOTO_TYPE, thumbnailUrl), getPhotos()));
+        }
+    }
+
+    private <T extends ListField> T getListFieldWithType(String type, List<T> list) {
+        if (list != null) {
+            for (T url : list) {
+                if (type.equalsIgnoreCase(url.getType())) {
+                    return url;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    private <T extends ListField> List<T> addListField(T field, List<T> list) {
+        if (list == null) {
+            list = Lists.newArrayList();
+        }
+        list.add(field);
+        return list;
+    }
+
+    /**
+     * @return the objectId
+     */
+    public long getObjectId() {
+        return objectId;
+    }
+
+    @PrePersist
+    public void populateDbFields() {
+        if (drinker != null)
+            drinkerDb = drinker.toString();
+        if (gender != null)
+            genderDb = gender.toString();
+        if (networkPresence != null)
+            networkPresenceDb = networkPresence.toString();
+        if (smoker != null)
+            smokerDb = smoker.toString();
+
+        List<String> lookingFor = Lists.newArrayList();
+        for (Enum<LookingFor> np : this.lookingFor) {
+            lookingFor.add(np.toString());
+        }
+        Map<String, List<String>> toSave = new HashMap<String, List<String>>();
+        toSave.put(LOOKING_FOR_PROPERTY, lookingFor);
+        toSave.put(ACTIVITIES_PROPERTY, this.activities);
+        toSave.put(BOOKS_PROPERTY, this.books);
+        toSave.put(CARS_PROPERTY, this.cars);
+        toSave.put(FOOD_PROPERTY, this.food);
+        toSave.put(HEROES_PROPERTY, this.heroes);
+        toSave.put(INTERESTS_PROPERTY, this.interests);
+        toSave.put(LANGUAGES_PROPERTY, this.languagesSpoken);
+        toSave.put(MOVIES_PROPERTY, this.movies);
+        toSave.put(MUSIC_PROPERTY, this.music);
+        toSave.put(QUOTES_PROPERTY, this.quotes);
+        toSave.put(SPORTS_PROPERTY, this.sports);
+        toSave.put(TAGS_PROPERTY, this.tags);
+        toSave.put(TURNOFFS_PROPERTY, this.turnOffs);
+        toSave.put(TURNONS_PROPERTY, this.turnOns);
+        toSave.put(TVSHOWS_PROPERTY, this.tvShows);
+
+        for (Entry<String, List<String>> e : toSave.entrySet()) {
+            // add new entries
+            for (String v : e.getValue()) {
+                boolean present = false;
+                for (PersonPropertyDb pp : properties) {
+                    if (e.getKey().equals(pp.getType()) && v.equals(pp.getValue())) {
+                        present = true;
+                        break;
+                    }
+                }
+                if (!present) {
+                    PersonPropertyDb pp = new PersonPropertyDb();
+                    pp.setType(e.getKey());
+                    pp.setValue(v);
+                }
+            }
+            // remove missing entries
+            List<PersonPropertyDb> toRemove = Lists.newArrayList();
+            for (PersonPropertyDb pp : properties) {
+                if (e.getKey().equals(pp.getType())) {
+                    boolean present = false;
+                    for (String v : e.getValue()) {
+                        if (pp.getValue().equals(v)) {
+                            present = true;
+                            break;
+                        }
+                    }
+                    if (!present) {
+                        toRemove.add(pp);
+                    }
+                }
+            }
+            properties.removeAll(toRemove);
+        }
+    }
+
+    @PostLoad
+    public void loadTransientFields() {
+        drinker = new EnumDb<Drinker>(Drinker.valueOf(drinkerDb));
+        gender = Gender.valueOf(genderDb);
+        networkPresence = new EnumDb<NetworkPresence>(NetworkPresence.valueOf(networkPresenceDb));
+        smoker = new EnumDb<Smoker>(Smoker.valueOf(smokerDb));
+
+        List<String> lookingFor = Lists.newArrayList();
+        this.activities = Lists.newArrayList();
+        this.books = Lists.newArrayList();
+        this.cars = Lists.newArrayList();
+        this.food = Lists.newArrayList();
+        this.heroes = Lists.newArrayList();
+        this.interests = Lists.newArrayList();
+        this.languagesSpoken = Lists.newArrayList();
+        this.movies = Lists.newArrayList();
+        this.music = Lists.newArrayList();
+        this.quotes = Lists.newArrayList();
+        this.sports = Lists.newArrayList();
+        this.tags = Lists.newArrayList();
+        this.turnOffs = Lists.newArrayList();
+        this.turnOns = Lists.newArrayList();
+        this.tvShows = Lists.newArrayList();
+
+        Map<String, List<String>> toSave = Maps.newHashMap();
+
+        toSave.put(LOOKING_FOR_PROPERTY, lookingFor);
+        toSave.put(ACTIVITIES_PROPERTY, this.activities);
+        toSave.put(BOOKS_PROPERTY, this.books);
+        toSave.put(CARS_PROPERTY, this.cars);
+        toSave.put(FOOD_PROPERTY, this.food);
+        toSave.put(HEROES_PROPERTY, this.heroes);
+        toSave.put(INTERESTS_PROPERTY, this.interests);
+        toSave.put(LANGUAGES_PROPERTY, this.languagesSpoken);
+        toSave.put(MOVIES_PROPERTY, this.movies);
+        toSave.put(MUSIC_PROPERTY, this.music);
+        toSave.put(QUOTES_PROPERTY, this.quotes);
+        toSave.put(SPORTS_PROPERTY, this.sports);
+        toSave.put(TAGS_PROPERTY, this.tags);
+        toSave.put(TURNOFFS_PROPERTY, this.turnOffs);
+        toSave.put(TURNONS_PROPERTY, this.turnOns);
+        toSave.put(TVSHOWS_PROPERTY, this.tvShows);
+
+        for (PersonPropertyDb pp : properties) {
+            List<String> l = toSave.get(pp.type);
+            if (l != null) {
+                l.add(pp.getValue());
+            }
+        }
+
+        this.lookingFor = Lists.newArrayList();
+        for (String lf : lookingFor) {
+            this.lookingFor.add(new EnumDb<LookingFor>(LookingFor.valueOf(lf)));
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.shindig.social.opensocial.model.Person#getDisplayName()
+     */
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.shindig.social.opensocial.model.Person#setDisplayName(java.lang.String)
+     */
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public static FilterCapability getFilterCapability() {
+        return FILTER_CAPABILITY;
+
+    }
+
+    /**
+     * @return the applictions
+     */
+    public List<ApplicationDb> getApplictions() {
+        return applictions;
+    }
+
+    /**
+     * @param applictions
+     *            the applictions to set
+     */
+    public void setApplictions(List<ApplicationDb> applictions) {
+        this.applictions = applictions;
+    }
+
+    /** {@inheritDoc} */
+    public Map<String, ? extends Object> getAppData() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    public void setAppData(Map<String, ? extends Object> appData) {
+    }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * 
+ */
+/*
+ * This object connects to a single Address, and to a single organization, defining the
+ * organizations relationship with the address
+ */
+@Entity
+@Table(name = "person_organization")
+@DiscriminatorValue("shared")
+@NamedQuery(name = PersonOrganizationDb.PERSON_ORG_FINDBY_NAME, 
+    query = "select p from PersonOrganizationDb p where p.name = :name ")
+public class PersonOrganizationDb extends OrganizationDb {
+  public static final String PERSON_ORG_FINDBY_NAME = "q.personorganizationdb.findbyname";
+
+  @Basic
+  @Column(name = "primary_organization")
+  private Boolean primary;
+
+  @ManyToOne(targetEntity = PersonDb.class)
+  @JoinColumn(name = "person_id", referencedColumnName = "oid")
+  protected Person person;
+
+  @Basic
+  @Column(name = "type", length = 255)
+  private String type;
+
+  public PersonOrganizationDb() {
+    // TODO Auto-generated constructor stub
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  public Boolean getPrimary() {
+    return primary;
+  }
+
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertyDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertyDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertyDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertyDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * A property, associated with a person, extends the "list_field" table, 
+ * and sets the "list_field_type" to PersonPropertiesDb.
+ */
+@Entity
+@Table(name="person_properties")
+@PrimaryKeyJoinColumn(name="oid")
+public class PersonPropertyDb extends ListFieldDb {
+
+  /**
+   * The person who this property is associated with.
+   */
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * Phone Entity, extends the ListField object (and list_field table), joining on the object ID.
+ * Objects of this type will have "list_field_type" set to PhoneDb in list_field
+ */
+@Entity
+@Table(name = "phone")
+@PrimaryKeyJoinColumn(name = "oid")
+@NamedQuery(name = PhoneDb.FINDBY_PHONE_NUMBER, 
+    query = "select p from PhoneDb p where p.value = :phonenumber ")
+public class PhoneDb extends ListFieldDb {
+
+  /**
+   * The name of the JPA query to find phone numbers by phone number (bit odd)
+   */
+  public static final String FINDBY_PHONE_NUMBER = "q.pphone.findbynumber";
+  /**
+   * The name of the phone number parameter in JPA queries
+   */
+  public static final String PARAM_PHONE_NUMBER = "phonenumber";
+  
+  /**
+   * The person who is associated with this phone number.
+   */
+  @ManyToOne(targetEntity = PersonDb.class)
+  @JoinColumn(name = "person_id", referencedColumnName = "oid")
+  protected Person person;
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * Photo Entity, extends the ListField object (and list_field table), joining on the object ID.
+ * Objects of this type will have "list_field_type" set to PhotoDb in list_field
+ */
+@Entity
+@Table(name="photo")
+@PrimaryKeyJoinColumn(name="oid")
+@NamedQuery(name = PhotoDb.FINDBY_PHOTO, 
+    query = "select p from PhotoDb p where p.value = :photo ")
+public class PhotoDb extends ListFieldDb {
+  
+  /**
+   * The name of the JPA query to find phone numbers by phone number (bit odd)
+   */
+  public static final String FINDBY_PHOTO = "q.pphoto.findbyphoto";
+  /**
+   * The name of the phone number parameter in JPA queries
+   */
+  public static final String PARAM_PHOTO = "photo";
+
+  /**
+   * The person who is using this photo.
+   */
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Url;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * Url Entity, extends the ListField object (and list_field table), joining on the object ID.
+ * Objects of this type will have "list_field_type" set to UrlDb in list_field
+ */
+@Entity
+@Table(name = "url")
+@PrimaryKeyJoinColumn(name = "oid")
+@NamedQuery(name = UrlDb.FINDBY_URL, query = "select u from UrlDb u where u.value = :url ")
+public class UrlDb extends ListFieldDb implements Url {
+  public static final String FINDBY_URL = "q.url.findbyurl";
+
+  public static final String PARAM_URL = "url";
+
+  @Basic
+  @Column(name = "link_text")
+  private String linkText;
+
+  /**
+   * The person who is using this url.
+   */
+  @ManyToOne(targetEntity = PersonDb.class)
+  @JoinColumn(name = "person_id", referencedColumnName = "oid")
+  protected Person person;
+
+  public UrlDb() {
+  }
+
+  public UrlDb(String value, String linkText, String type) {
+    super(type, value);
+    this.linkText = linkText;
+  }
+
+  public String getLinkText() {
+    return linkText;
+  }
+
+  public void setLinkText(String linkText) {
+    this.linkText = linkText;
+  }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/DbObject.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/DbObject.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/DbObject.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/DbObject.java Wed May 18 03:42:09 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.shindig.social.opensocial.jpa.api;
+
+
+/**
+ * All Database objects should implement this, mainly to ensure that each has an
+ * object ID. The object ID can't be set, its generated.
+ */
+public interface DbObject {
+  /**
+   * Get the internal object ID used for references to this object. Should be generated
+   * by the underlying storage mechanism.
+   * @return the ID of the object
+   */
+  long getObjectId();
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterCapability.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterCapability.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterCapability.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterCapability.java Wed May 18 03:42:09 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.shindig.social.opensocial.jpa.api;
+
+import org.apache.shindig.protocol.model.FilterOperation;
+
+/**
+ * Specifies the ability to filter an object
+ */
+public interface FilterCapability {
+  /**
+   * Check to see if the property is filterable on an operation. The final property that is returned
+   * must not be directly based on the fieldName passed in and must be suitable for direct use
+   * within a JPQL statement. (ie don't trust the passed in parameter)
+   * 
+   * @param fieldName the field name that is being filtered, value is not to be trusted.
+   * @param filterOperation the operation being applied to the field.
+   * @return the final property that is being filtered or null is the filter operation specified is
+   *         not applicable
+   */
+  String findFilterableProperty(String fieldName, FilterOperation filterOperation);
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterSpecification.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterSpecification.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterSpecification.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterSpecification.java Wed May 18 03:42:09 2011
@@ -0,0 +1,93 @@
+/*
+ * 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.shindig.social.opensocial.jpa.api;
+
+import org.apache.shindig.protocol.model.FilterOperation;
+
+/**
+ * A FilterSpecifiation encapsulates the Filter operation for a specific field. Name of the target
+ * property based on the operation.
+ */
+public class FilterSpecification {
+
+  public static final String SPECIAL_OPERATION = "special operation";
+  private String finalProperty;
+  private FilterOperation[] filterOptions;
+  private boolean special;
+
+  /**
+   * Create a FilterSpecification with a target final property name and a set of acceptable
+   * operations.
+   *
+   * @param finalProperty the name of the final property on the class as used by JPQL
+   * @param filterOptions an array of operations that may be applied to this property
+   */
+  public FilterSpecification(String finalProperty, FilterOperation[] filterOptions) {
+    this.finalProperty = finalProperty;
+    this.filterOptions = new FilterOperation[filterOptions.length];
+    System.arraycopy(filterOptions, 0, this.filterOptions, 0, filterOptions.length);
+    this.special = false;
+  }
+
+  /**
+   * Create a default filter operation that operates on special terms, ie that is has no filter
+   * mapping and is handled as a special case in the processing. Im this case the finalProperty is
+   * set to a reserved value.
+   */
+  public FilterSpecification() {
+    this.special = true;
+  }
+
+  /**
+   * Convert the property into the final property.
+   *
+   * @param operation the operation that is being used.
+   * @return returns the final property name, or null if the operation is not applicable
+   */
+  public String translateProperty(FilterOperation operation) {
+    if (special) {
+      return SPECIAL_OPERATION;
+    } else {
+      for (FilterOperation fo : filterOptions) {
+        if (fo.equals(operation)) {
+          return finalProperty;
+        }
+      }
+      return null;
+    }
+  }
+
+  /**
+   * If the final property is special, then return true.
+   * @param finalProp the final property
+   * @return true if special
+   */
+  public static boolean isSpecial(String finalProp) {
+    return SPECIAL_OPERATION.equals(finalProp);
+  }
+
+  /**
+   * If the final property is valid, return true.
+   * @param finalProp the final property
+   * @return true if valid.
+   */
+  public static boolean isValid(String finalProp) {
+    return (finalProp != null);
+  }
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java Wed May 18 03:42:09 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.shindig.social.opensocial.jpa.openjpa;
+
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+/**
+ * 
+ */
+public class Bootstrap {
+
+  private static final String DB_DRIVER = "db.driver";
+  private static final String DB_URL = "db.url";
+  private static final String DB_USER = "db.user";
+  private static final String DB_PASSWORD = "db.password";
+  private static final String DB_MIN_WRITE = "db.write.min";
+  private static final String DB_MIN_NUM_READ = "db.read.min";
+  private EntityManager entityManager;
+
+//  @Inject
+  public Bootstrap(@Named(DB_DRIVER)
+  String dbDriver, @Named(DB_URL)
+  String dbUrl, @Named(DB_USER)
+  String dbUser, @Named(DB_PASSWORD)
+  String dbPassword, @Named(DB_MIN_NUM_READ)
+  String minRead, @Named(DB_MIN_WRITE)
+  String minWrite) {
+
+  }
+
+  public Bootstrap() {
+
+  }
+
+  public void init(String unitName) {
+
+    EntityManagerFactory emFactory = Persistence.createEntityManagerFactory(unitName);
+    entityManager = emFactory.createEntityManager();
+  }
+
+  /**
+   * @param unitName
+   * @return
+   */
+  public EntityManager getEntityManager(String unitName) {
+    if (entityManager == null) {
+      init(unitName);
+    }
+    return entityManager;
+  }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/OpenJPAEntityManagerProvider.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/OpenJPAEntityManagerProvider.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/OpenJPAEntityManagerProvider.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/OpenJPAEntityManagerProvider.java Wed May 18 03:42:09 2011
@@ -0,0 +1,50 @@
+/*
+ * 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.shindig.social.opensocial.jpa.openjpa;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.name.Named;
+
+import javax.persistence.EntityManager;
+
+/**
+ * Creates an Eclipse Entity Manager.
+ */
+public class OpenJPAEntityManagerProvider implements Provider<EntityManager> {
+
+  private Bootstrap bootstrap;
+  private String unitName = "raveShindigOpenJPATest";
+
+  /**
+   * 
+   */
+  @Inject
+  public OpenJPAEntityManagerProvider(Bootstrap bootstrap) {
+    this.bootstrap = bootstrap;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see com.google.inject.Provider#get()
+   */
+  public EntityManager get() {
+    return bootstrap.getEntityManager(unitName);
+  }
+}



Mime
View raw message