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:56:56 UTC
svn commit: r696303 - in
/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa:
GroupDb.java GroupPropertyDb.java
Author: ieb
Date: Wed Sep 17 06:56:56 2008
New Revision: 696303
URL: http://svn.apache.org/viewvc?rev=696303&view=rev
Log:
Fixed the many to many link table in Groups (wrong way round).
Added Group Properties to the model, as groups probably will have properties.
Added:
incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java
Modified:
incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java
Modified: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java?rev=696303&r1=696302&r2=696303&view=diff
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java (original)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java Wed Sep 17 06:56:56 2008
@@ -20,6 +20,7 @@
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;
@@ -31,10 +32,13 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
+import javax.persistence.MapKey;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import java.util.List;
+import java.util.Map;
/**
* Represents a group in the social database. The assumption in this object is that groups are
@@ -72,9 +76,9 @@
@ManyToMany(targetEntity = PersonDb.class)
@JoinTable(name = "membership",
joinColumns =
- @JoinColumn(name = "person_id", referencedColumnName = "oid"),
+ @JoinColumn(name = "group_id", referencedColumnName = "oid"),
inverseJoinColumns =
- @JoinColumn(name = "group_id", referencedColumnName = "oid"))
+ @JoinColumn(name = "person_id", referencedColumnName = "oid"))
protected List<Person> members;
/**
@@ -85,6 +89,13 @@
protected String id;
/**
+ * The group has properties.
+ */
+ @OneToMany(targetEntity = GroupPropertyDb.class, mappedBy = "group")
+ @MapKey(name = "type")
+ protected Map<String, ListField> properties;
+
+ /**
* @return the owner
*/
public Person getOwner() {
@@ -140,4 +151,18 @@
return version;
}
+ /**
+ * @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;
+ }
+
}
Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java?rev=696303&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java Wed Sep 17 06:56:56 2008
@@ -0,0 +1,59 @@
+/*
+ * 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 a group, extending the listfield type, and using the type property to
+ * perform the mapping. Main storage is in the listfield table, but group property stores the
+ * details of the properties of the group.
+ */
+@Entity
+@Table(name = "group_property")
+@PrimaryKeyJoinColumn(name = "oid")
+public class GroupPropertyDb extends ListFieldDb {
+ /**
+ * The group relationship connected with this property.
+ */
+ @ManyToOne(targetEntity = GroupDb.class)
+ @JoinColumn(name = "group_id", referencedColumnName = "oid")
+ protected GroupDb group;
+
+ /**
+ * @return the group
+ */
+ public GroupDb getGroup() {
+ return group;
+ }
+
+ /**
+ * @param group the group to set
+ */
+ public void setGroup(GroupDb group) {
+ this.group = group;
+ }
+
+
+
+
+}