You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ie...@apache.org on 2008/09/17 15:57:21 UTC

svn commit: r696304 - in /incubator/shindig/trunk/java/samples/src/main: java/org/apache/shindig/social/opensocial/jpa/ resources/META-INF/

Author: ieb
Date: Wed Sep 17 06:57:20 2008
New Revision: 696304

URL: http://svn.apache.org/viewvc?rev=696304&view=rev
Log:
Create Application Entities in the model and wired them into person.
Applications also have properties.
NB, all properties are stored in a list_field table, that will need to be partitioned
on the discriminator (or perhapse made independant). This can be done later.

Added:
    incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java
    incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java
Modified:
    incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java
    incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java?rev=696304&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java Wed Sep 17 06:57:20 2008
@@ -0,0 +1,127 @@
+/*
+ * 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.ListField;
+import org.apache.shindig.social.opensocial.model.Person;
+
+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.ManyToOne;
+import javax.persistence.MapKey;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import java.util.Map;
+
+/**
+ * Stores information about applications
+ */
+@Entity
+@Table(name = "group")
+public class ApplicationDb implements DbObject {
+  /**
+   * 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")
+  protected long objectId;
+
+  /**
+   * An optimistic locking field.
+   */
+  @Version
+  @Column(name = "version")
+  protected long version;
+
+
+  /**
+   * The application has properties.
+   */
+  @OneToMany(targetEntity = ApplicationPropertyDb.class, mappedBy = "application")
+  @MapKey(name = "type")
+  protected Map<String, ListField> properties;
+
+
+  /**
+   * Each Application has an Id
+   */
+  @Basic
+  @Column(name = "id", length = 255)
+  protected String id;
+
+
+  /**
+   * @return the properties
+   */
+  public Map<String, ListField> getProperties() {
+    return properties;
+  }
+
+
+  /**
+   * @param properties the properties to set
+   */
+  public void setProperties(Map<String, ListField> properties) {
+    this.properties = properties;
+  }
+
+
+  /**
+   * @return the id
+   */
+  public String getId() {
+    return id;
+  }
+
+
+  /**
+   * @param id the id to set
+   */
+  public void setId(String id) {
+    this.id = id;
+  }
+
+
+  /**
+   * @return the version
+   */
+  public long getVersion() {
+    return version;
+  }
+
+
+  /**
+   * @return the objectId
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java?rev=696304&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java Wed Sep 17 06:57:20 2008
@@ -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 javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * This is a property of an application, extending the listfield type, and using the type property
+ * to perform the mapping. Main storage is in the listfield table, but application property stores
+ * the details of the properties of the application.
+ */
+@Entity
+@Table(name = "application_property")
+@PrimaryKeyJoinColumn(name = "oid")
+public class ApplicationPropertyDb extends ListFieldDb {
+  /**
+   * The group relationship connected with this property.
+   */
+  @ManyToOne(targetEntity = ApplicationDb.class)
+  @JoinColumn(name = "application_id", referencedColumnName = "oid")
+  protected ApplicationDb application;
+
+  /**
+   * @return the application
+   */
+  public ApplicationDb getApplication() {
+    return application;
+  }
+
+  /**
+   * @param application the application to set
+   */
+  public void setApplication(ApplicationDb application) {
+    this.application = application;
+  }
+
+}

Modified: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java?rev=696304&r1=696303&r2=696304&view=diff
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java (original)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java Wed Sep 17 06:57:20 2008
@@ -45,6 +45,8 @@
 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;
@@ -119,53 +121,52 @@
   private static final String TVSHOWS_PROPERTY = "tvshow";
 
   private static final Map<String, FilterSpecification> FILTER_COLUMNS = 
-      new HashMap<String, FilterSpecification>();
+    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 };
-  private static final FilterOperation[] EQUALS_FILTEROPTIONS = new FilterOperation[] { 
-    FilterOperation.equals };
+  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));
-    
+    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());
+    FILTER_COLUMNS.put("topFriends", new FilterSpecification());
+    FILTER_COLUMNS.put("hasApp", new FilterSpecification());
   }
 
   private static final FilterCapability FILTER_CAPABILITY = new FilterCapability() {
@@ -571,6 +572,17 @@
   @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() {
   }
@@ -1266,4 +1278,18 @@
     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;
+  }
 }

Modified: incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml?rev=696304&r1=696303&r2=696304&view=diff
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml (original)
+++ incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml Wed Sep 17 06:57:20 2008
@@ -54,4 +54,10 @@
   </entity>
   <entity class="org.apache.shindig.social.opensocial.jpa.GroupDb">
   </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.GroupPropertyDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.ApplicationDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.ApplicationPropertyDb">
+  </entity>
 </entity-mappings>