rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zh...@apache.org
Subject svn commit: r1104678 [1/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
Author: zhguo
Date: Wed May 18 03:42:09 2011
New Revision: 1104678

URL: http://svn.apache.org/viewvc?rev=1104678&view=rev
Log:
RAVE-13: OpenSocial persistence and SPI (Service Provider Interface) implementation
https://issues.apache.org/jira/browse/RAVE-13
RAVE-15: Implement Person related SPIs
https://issues.apache.org/jira/browse/RAVE-35
RAVE-34: Implement AppData
https://issues.apache.org/jira/browse/RAVE-34

- Added JPA-compliant classes for OpenSocial data objects (e.g. Person, Activity)
- Implement Person service, Activity service and Appdata service using OpenJPA + H2. 
- Added dummy code for implementation of other services (e.g. AlbumService, MessageService)
- Much code is borrowed from sample SPI implementation in Shindig and modified.
- Sample use: after tomcat is started, go to 
  http://localhost:8080/social/rest/people/canonical?fields=nickname,age,gender
  If everything works well, you should see JSON response about person "canonical".
- Test code is not included yet.


Added:
    incubator/rave/trunk/rave-shindig/src/main/java/
    incubator/rave/trunk/rave-shindig/src/main/java/org/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/jdbc/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/DatabasePopulateContextListener.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialService.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/ShindigUtil.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/RaveNameImpl.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AccountDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityTemplateParamsDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AddressDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapValueDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationPropertyDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/BodyTypeDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/EmailDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/EnumDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/FriendDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/FriendPropertyDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/GroupPropertyDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ImDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ListFieldDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/MediaItemDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/MessageDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/NameDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationAddressDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/OrganizationDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAccountDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonAddressDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertyDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/DbObject.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterCapability.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/api/FilterSpecification.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/OpenJPAEntityManagerProvider.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/ActivityServiceDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/AppDataServiceDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/JPASocialModule.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/JPQLUtils.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/PersonServiceDb.java
    incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/SPIUtils.java
    incubator/rave/trunk/rave-shindig/src/main/resources/
    incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/
    incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/orm.xml
    incubator/rave/trunk/rave-shindig/src/main/resources/META-INF/persistence.xml
    incubator/rave/trunk/rave-shindig/src/main/webapp/WEB-INF/web.xml
Modified:
    incubator/rave/trunk/pom.xml
    incubator/rave/trunk/rave-portal/pom.xml
    incubator/rave/trunk/rave-shindig/pom.xml

Modified: incubator/rave/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/pom.xml?rev=1104678&r1=1104677&r2=1104678&view=diff
==============================================================================
--- incubator/rave/trunk/pom.xml (original)
+++ incubator/rave/trunk/pom.xml Wed May 18 03:42:09 2011
@@ -58,6 +58,8 @@
         <easymock.version>3.0</easymock.version>
         <openjpa-all.version>2.1.0</openjpa-all.version>
         <org.openid4java.version>0.9.6</org.openid4java.version>
+        <jersey-server.version>1.6</jersey-server.version>
+        <jersey-spring.version>1.0</jersey-spring.version>
     </properties>
 
     <repositories>
@@ -77,6 +79,31 @@
                 <type>war</type>
             </dependency>
             <dependency>
+                <groupId>org.apache.shindig</groupId>
+                <artifactId>shindig-social-api</artifactId>
+                <version>${apache.shindig.version}</version>
+            </dependency>
+            <dependency>
+              <groupId>org.apache.shindig</groupId>
+              <artifactId>shindig-social-api</artifactId>
+              <type>test-jar</type>
+              <scope>test</scope>
+              <version>${apache.shindig.version}</version>
+            </dependency>
+            <dependency>
+              <groupId>org.apache.shindig</groupId>
+              <artifactId>shindig-common</artifactId>
+              <type>test-jar</type>
+              <scope>test</scope>
+              <version>${apache.shindig.version}</version>
+            </dependency>
+            <dependency>
+              <groupId>org.apache.shindig</groupId>
+              <artifactId>shindig-gadgets</artifactId>
+              <scope>test</scope>
+              <version>${apache.shindig.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-webmvc</artifactId>
                 <version>${org.springframework.version}</version>
@@ -112,6 +139,40 @@
                 <version>${openjpa-all.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.sun.jersey</groupId>
+                <artifactId>jersey-spring</artifactId>
+                <version>${jersey-spring.version}</version>
+                <exclusions>
+                  <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring</artifactId>
+                  </exclusion>
+                  <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-core</artifactId>
+                  </exclusion>
+                  <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-web</artifactId>
+                  </exclusion>
+                  <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-beans</artifactId>
+                  </exclusion>
+                  <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-context</artifactId>
+                  </exclusion>
+                </exclusions>
+            </dependency>
+
+            <dependency>
+                <groupId>com.sun.jersey</groupId>
+                <artifactId>jersey-server</artifactId>
+                <version>${jersey-server.version}</version>
+            </dependency>
+  
             <!-- Logging -->
             <dependency>
                 <groupId>org.slf4j</groupId>
@@ -176,6 +237,19 @@
             <scope>provided</scope>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>el-api</artifactId>
+            <version>[1,)</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>jasper-el</artifactId>
+            <version>[1,)</version>
+            <scope>provided</scope>
+        </dependency>
+                
         <!-- Exclude commons-logging by adding it as a provided dependency -->
         <dependency>
             <groupId>commons-logging</groupId>

Modified: incubator/rave/trunk/rave-portal/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/pom.xml?rev=1104678&r1=1104677&r2=1104678&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/pom.xml (original)
+++ incubator/rave/trunk/rave-portal/pom.xml Wed May 18 03:42:09 2011
@@ -66,7 +66,6 @@ if needed you can specify it on the comm
     </pluginRepositories>
 
     <dependencies>
-
         <dependency>
             <groupId>org.apache.rave</groupId>
             <artifactId>rave-shindig</artifactId>
@@ -100,17 +99,17 @@ if needed you can specify it on the comm
             <artifactId>spring-security-config</artifactId>
         </dependency>
         <dependency>
-  			<groupId>org.springframework.security</groupId>
-  			<artifactId>spring-security-openid</artifactId>
-  			<version>${org.springframework.version}</version>
-		</dependency>
-		<dependency>
-       		 <groupId>org.openid4java</groupId>
-        	 <artifactId>openid4java-consumer</artifactId>
-        	<version>${org.openid4java.version}</version>
-        	<type>pom</type>
-		</dependency>
- 		
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-openid</artifactId>
+            <version>${org.springframework.version}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.openid4java</groupId>
+          <artifactId>openid4java-consumer</artifactId>
+          <version>${org.openid4java.version}</version>
+          <type>pom</type>
+        </dependency>
+
         <!--Persistence-->
         <dependency>
             <groupId>org.apache.openjpa</groupId>
@@ -122,7 +121,7 @@ if needed you can specify it on the comm
             <artifactId>h2</artifactId>
             <version>${com.h2database.version}</version>
         </dependency>
-
+        
         <!-- JSTL -->
         <dependency>
             <groupId>javax.servlet</groupId>
@@ -158,8 +157,8 @@ if needed you can specify it on the comm
     </dependencies>
 
     <build>
-        <defaultGoal>install</defaultGoal>
-        <plugins>
+       <defaultGoal>install</defaultGoal>
+       <plugins>
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>openjpa-maven-plugin</artifactId>
@@ -243,4 +242,4 @@ if needed you can specify it on the comm
         </plugins>
     </build>
 
-</project>
\ No newline at end of file
+</project>

Modified: incubator/rave/trunk/rave-shindig/pom.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/pom.xml?rev=1104678&r1=1104677&r2=1104678&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/pom.xml (original)
+++ incubator/rave/trunk/rave-shindig/pom.xml Wed May 18 03:42:09 2011
@@ -38,13 +38,56 @@
   <packaging>war</packaging>
   <version>0.1-incubating-SNAPSHOT</version>
   
+ 	<properties>
+ 		<com.h2database.version>1.3.154</com.h2database.version>
+ 	</properties>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.shindig</groupId>
       <artifactId>shindig-server</artifactId>
       <type>war</type>
     </dependency>
-  </dependencies>
+ 		
+ 		<dependency>
+ 			<groupId>com.h2database</groupId>
+ 			<artifactId>h2</artifactId>
+ 			<version>${com.h2database.version}</version>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>org.apache.openjpa</groupId>
+ 			<artifactId>openjpa-all</artifactId>
+ 		</dependency>
+ 
+ 		<dependency>
+ 			<groupId>org.apache.shindig</groupId>
+ 			<artifactId>shindig-social-api</artifactId>
+ 		</dependency>
+ 		
+ 		<dependency>
+      <groupId>org.apache.shindig</groupId>
+      <artifactId>shindig-social-api</artifactId>
+      <type>test-jar</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.shindig</groupId>
+      <artifactId>shindig-common</artifactId>
+      <type>test-jar</type>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.shindig</groupId>
+      <artifactId>shindig-gadgets</artifactId>
+    </dependency>
+    
+    <dependency>
+       <groupId>xmlunit</groupId>
+       <artifactId>xmlunit</artifactId>
+       <version>1.3</version>
+       <scope>test</scope>
+    </dependency>
+   </dependencies>
   
   <build>
     <defaultGoal>install</defaultGoal>
@@ -66,4 +109,4 @@
 
   </build>
   
-</project>
\ No newline at end of file
+</project>

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/DatabasePopulateContextListener.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/DatabasePopulateContextListener.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/DatabasePopulateContextListener.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/DatabasePopulateContextListener.java Wed May 18 03:42:09 2011
@@ -0,0 +1,100 @@
+/*
+ * 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.rave.os;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.rave.os.model.RaveNameImpl;
+import org.apache.shindig.social.opensocial.jpa.EnumDb;
+import org.apache.shindig.social.opensocial.jpa.PersonDb;
+import org.apache.shindig.social.opensocial.model.Drinker;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.NetworkPresence;
+import org.apache.shindig.social.opensocial.model.Person.Gender;
+import org.apache.shindig.social.opensocial.model.Smoker;
+
+/**
+ *
+ */
+public class DatabasePopulateContextListener implements ServletContextListener {
+
+    private final static String PersistenceUnitName = "raveShindigPersistenceUnit";
+    private static EntityManager em;
+    private static EntityManagerFactory emf;
+
+    public static EntityManager getEntityManager() {
+        if (em == null) {
+            if (emf == null)
+                emf = Persistence.createEntityManagerFactory(PersistenceUnitName);
+            em = emf.createEntityManager();
+        }
+        return em;
+    }
+
+
+    @Override
+    public void contextInitialized(ServletContextEvent sce) {
+        String executeScriptQuery = "SELECT * FROM person";
+        String sqlScripts[] = { "initial_data.sql" };
+
+        List<File> scriptLocations = new ArrayList<File>();
+        for (String sqlScript : sqlScripts) {
+            scriptLocations.add(new File(sqlScript));
+        }
+
+        populateDatabase();
+    }
+
+    private void populateDatabase() {
+        PersonDb person = new PersonDb();
+        person.setId("canonical");
+        Name name = new RaveNameImpl();
+        name.setFamilyName("canonical");
+        name.setGivenName("canonical");
+        person.setName(name);
+        person.setDrinker(new EnumDb<Drinker>(Drinker.NO));
+        person.setGender(Gender.male);
+        person.setNetworkPresence(new EnumDb<NetworkPresence>(NetworkPresence.ONLINE));
+        person.setAboutMe("About me");
+        person.setAge(25);
+        person.setBirthday(new Date());
+        person.setNickname("hoosier");
+        person.setSmoker(new EnumDb<Smoker>(Smoker.NO));
+
+        // EntityManager em = emf.createEntityManager();
+        EntityManager em = getEntityManager();
+        em.getTransaction().begin();
+        em.persist(person);
+        em.flush();
+        em.getTransaction().commit();
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent sce) {
+
+    }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java Wed May 18 03:42:09 2011
@@ -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.rave.os;
+
+import org.apache.shindig.social.opensocial.jpa.spi.ActivityServiceDb;
+import org.apache.shindig.social.opensocial.jpa.spi.AppDataServiceDb;
+import org.apache.shindig.social.opensocial.jpa.spi.PersonServiceDb;
+import org.apache.shindig.social.opensocial.oauth.OAuthDataStore;
+import org.apache.shindig.social.opensocial.spi.ActivityService;
+import org.apache.shindig.social.opensocial.spi.ActivityStreamService;
+import org.apache.shindig.social.opensocial.spi.AlbumService;
+import org.apache.shindig.social.opensocial.spi.AppDataService;
+import org.apache.shindig.social.opensocial.spi.MediaItemService;
+import org.apache.shindig.social.opensocial.spi.MessageService;
+import org.apache.shindig.social.opensocial.spi.PersonService;
+import org.apache.shindig.social.sample.oauth.SampleOAuthDataStore;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
+
+/**
+ * Provides bindings for implementations of social API classes using JPA.
+ */
+public class JPAOpenSocialModule extends AbstractModule {
+  
+    @Override
+    protected void configure() {
+        // FIXME
+        // This line is copied from Shindig SampleModule.java.
+        // If this line is not included here, tomcat gives error when it's started.
+        // It seems that other modules depend on this the binding.
+        bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
+            .toInstance("sampledata/canonicaldb.json");
+
+        bind(PersonService.class).to(PersonServiceDb.class);
+        bind(ActivityService.class).to(ActivityServiceDb.class);
+        bind(ActivityStreamService.class).to(JPAOpenSocialService.class);
+        bind(AlbumService.class).to(JPAOpenSocialService.class);
+        bind(MediaItemService.class).to(JPAOpenSocialService.class);
+        bind(AppDataService.class).to(AppDataServiceDb.class);
+        bind(MessageService.class).to(JPAOpenSocialService.class);
+        bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
+    }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialService.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialService.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialService.java Wed May 18 03:42:09 2011
@@ -0,0 +1,252 @@
+/*
+ * 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.rave.os;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Future;
+
+import org.apache.shindig.auth.SecurityToken;
+import org.apache.shindig.protocol.ProtocolException;
+import org.apache.shindig.protocol.RestfulCollection;
+import org.apache.shindig.protocol.conversion.BeanConverter;
+import org.apache.shindig.social.opensocial.model.ActivityEntry;
+import org.apache.shindig.social.opensocial.model.Album;
+import org.apache.shindig.social.opensocial.model.MediaItem;
+import org.apache.shindig.social.opensocial.model.Message;
+import org.apache.shindig.social.opensocial.model.MessageCollection;
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.spi.ActivityStreamService;
+import org.apache.shindig.social.opensocial.spi.AlbumService;
+import org.apache.shindig.social.opensocial.spi.CollectionOptions;
+import org.apache.shindig.social.opensocial.spi.GroupId;
+import org.apache.shindig.social.opensocial.spi.MediaItemService;
+import org.apache.shindig.social.opensocial.spi.MessageService;
+import org.apache.shindig.social.opensocial.spi.UserId;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Dummy implementation of Shindig OpenSocial SPIs.
+ * 
+ * This class just implements services in a dummy way, which makes Shindig not complain. If a certain service is
+ * implemented meaningfully, a new class should be created for it. Read class <code>PersonServiceDb</code> for an
+ * example.
+ * 
+ */
+public class JPAOpenSocialService implements MediaItemService, MessageService, AlbumService, ActivityStreamService {
+    
+    // @Override
+    public Future<RestfulCollection<Person>> getPeople(Set<UserId> userIds, GroupId groupId,
+            CollectionOptions collectionOptions, Set<String> fields, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<ActivityEntry>> getActivityEntries(Set<UserId> userIds, GroupId groupId,
+            String appId, Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<ActivityEntry>> getActivityEntries(UserId userId, GroupId groupId, String appId,
+            Set<String> fields, CollectionOptions options, Set<String> activityIds, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<ActivityEntry> getActivityEntry(UserId userId, GroupId groupId, String appId, Set<String> fields,
+            String activityId, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> deleteActivityEntries(UserId userId, GroupId groupId, String appId, Set<String> activityIds,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<ActivityEntry> updateActivityEntry(UserId userId, GroupId groupId, String appId, Set<String> fields,
+            ActivityEntry activity, String activityId, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<ActivityEntry> createActivityEntry(UserId userId, GroupId groupId, String appId, Set<String> fields,
+            ActivityEntry activity, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Album> getAlbum(UserId userId, String appId, Set<String> fields, String albumId, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<Album>> getAlbums(UserId userId, String appId, Set<String> fields,
+            CollectionOptions options, Set<String> albumIds, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<Album>> getAlbums(Set<UserId> userIds, GroupId groupId, String appId,
+            Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> deleteAlbum(UserId userId, String appId, String albumId, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> createAlbum(UserId userId, String appId, Album album, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> updateAlbum(UserId userId, String appId, Album album, String albumId, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<MessageCollection>> getMessageCollections(UserId userId, Set<String> fields,
+            CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<MessageCollection> createMessageCollection(UserId userId, MessageCollection msgCollection,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> modifyMessageCollection(UserId userId, MessageCollection msgCollection, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> deleteMessageCollection(UserId userId, String msgCollId, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<Message>> getMessages(UserId userId, String msgCollId, Set<String> fields,
+            List<String> msgIds, CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> createMessage(UserId userId, String appId, String msgCollId, Message message,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> deleteMessages(UserId userId, String msgCollId, List<String> ids, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> modifyMessage(UserId userId, String msgCollId, String messageId, Message message,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<MediaItem> getMediaItem(UserId userId, String appId, String albumId, String mediaItemId,
+            Set<String> fields, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<MediaItem>> getMediaItems(UserId userId, String appId, String albumId,
+            Set<String> mediaItemIds, Set<String> fields, CollectionOptions options, SecurityToken token)
+            throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<MediaItem>> getMediaItems(UserId userId, String appId, String albumId,
+            Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<RestfulCollection<MediaItem>> getMediaItems(Set<UserId> userIds, GroupId groupId, String appId,
+            Set<String> fields, CollectionOptions options, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> deleteMediaItem(UserId userId, String appId, String albumId, String mediaItemId,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> createMediaItem(UserId userId, String appId, String albumId, MediaItem mediaItem,
+            SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<Void> updateMediaItem(UserId userId, String appId, String albumId, String mediaItemId,
+            MediaItem mediaItem, SecurityToken token) throws ProtocolException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/ShindigUtil.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/ShindigUtil.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/ShindigUtil.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/ShindigUtil.java Wed May 18 03:42:09 2011
@@ -0,0 +1,45 @@
+/**
+ * 
+ */
+package org.apache.rave.os;
+
+import org.apache.shindig.protocol.conversion.BeanConverter;
+import org.apache.shindig.protocol.conversion.BeanJsonConverter;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.name.Named;
+import com.google.inject.name.Names;
+
+/**
+ * 
+ */
+public class ShindigUtil {
+
+    class SocialApiGuiceModule extends AbstractModule {
+        @Override
+        protected void configure() {
+            bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to(
+                    BeanJsonConverter.class);
+        }
+    }
+
+    public ShindigUtil() {
+        Injector injector = Guice.createInjector(new SocialApiGuiceModule());
+        injector.injectMembers(this);
+    }
+
+    @Inject
+    @Named("shindig.bean.converter.json")
+    private BeanConverter beanConverter;
+
+    public BeanConverter getBeanConverter() {
+        return beanConverter;
+    }
+
+    public void setBeanConverter(BeanConverter beanConverter) {
+        this.beanConverter = beanConverter;
+    }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.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.rave.os;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.shindig.auth.AnonymousAuthenticationHandler;
+import org.apache.shindig.auth.AuthenticationHandler;
+import org.apache.shindig.common.servlet.ParameterFetcher;
+import org.apache.shindig.protocol.DataServiceServletFetcher;
+import org.apache.shindig.protocol.conversion.BeanConverter;
+import org.apache.shindig.protocol.conversion.BeanJsonConverter;
+import org.apache.shindig.protocol.conversion.BeanXStreamConverter;
+import org.apache.shindig.protocol.conversion.xstream.XStreamConfiguration;
+import org.apache.shindig.social.core.oauth.AuthenticationHandlerProvider;
+import org.apache.shindig.social.core.util.BeanXStreamAtomConverter;
+import org.apache.shindig.social.core.util.xstream.XStream081Configuration;
+import org.apache.shindig.social.opensocial.service.ActivityHandler;
+import org.apache.shindig.social.opensocial.service.ActivityStreamHandler;
+import org.apache.shindig.social.opensocial.service.AlbumHandler;
+import org.apache.shindig.social.opensocial.service.AppDataHandler;
+import org.apache.shindig.social.opensocial.service.MediaItemHandler;
+import org.apache.shindig.social.opensocial.service.MessageHandler;
+import org.apache.shindig.social.opensocial.service.PersonHandler;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
+
+/**
+ * Provides social api component injection. Implementor may want to replace this module if they need
+ * to replace some of the internals of the Social API, like for instance the JSON to Bean to JSON
+ * converter Beans, however in general this should not be required, as most default implementations
+ * have been specified with the Guice @ImplementedBy annotation.
+ */
+public class SocialApiGuiceModule extends AbstractModule {
+
+  /** {@inheritDoc} */
+  @Override
+  protected void configure() {
+    bind(ParameterFetcher.class).annotatedWith(Names.named("DataServiceServlet"))
+        .to(DataServiceServletFetcher.class);
+
+    bind(Boolean.class)
+        .annotatedWith(Names.named(AnonymousAuthenticationHandler.ALLOW_UNAUTHENTICATED))
+        .toInstance(Boolean.TRUE);
+    bind(XStreamConfiguration.class).to(XStream081Configuration.class);
+    bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.xml")).to(
+        BeanXStreamConverter.class);
+    bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to(
+        BeanJsonConverter.class);
+    bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.atom")).to(
+        BeanXStreamAtomConverter.class);
+
+    bind(new TypeLiteral<List<AuthenticationHandler>>(){}).toProvider(
+        AuthenticationHandlerProvider.class);
+
+    Multibinder<Object> handlerBinder = Multibinder.newSetBinder(binder(), Object.class,
+        Names.named("org.apache.shindig.handlers"));
+    for (Class handler : getHandlers()) {
+      handlerBinder.addBinding().toInstance(handler);
+    }
+  }
+
+  /**
+   * Hook to provide a Set of request handlers.  Subclasses may override
+   * to add or replace additional handlers.
+   */
+  protected Set<Class<?>> getHandlers() {
+//    return ImmutableSet.of(ActivityHandler.class, AppDataHandler.class,
+//            PersonHandler.class, MessageHandler.class, AlbumHandler.class,
+//            MediaItemHandler.class, ActivityStreamHandler.class);
+      return ImmutableSet.of(PersonHandler.class, ActivityHandler.class);
+  }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/RaveNameImpl.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/RaveNameImpl.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/RaveNameImpl.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/model/RaveNameImpl.java Wed May 18 03:42:09 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.rave.os.model;
+
+import static javax.persistence.GenerationType.AUTO;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.apache.shindig.social.core.model.NameImpl;
+
+/**
+ * Glue for JPA.
+ *  
+ */
+@Entity
+public class RaveNameImpl extends NameImpl {
+    
+    @Id
+    @GeneratedValue(strategy = AUTO)
+    @Column(name = "oid")
+    private long objectId;
+    
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AccountDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AccountDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AccountDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AccountDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,163 @@
+/*
+ * 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.jpa.api.DbObject;
+import org.apache.shindig.social.opensocial.model.Account;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Version;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+/**
+ * Storage object for the Person. Stored in a table "account" which is also used by
+ * joined extension classes, the account usage column defines the class where the extension
+ * is used, but in most cases addresses are shared and this column has the value "sharedaccount"
+ * For more information on the API see {@link Account}
+ */
+@Entity
+@Table(name = "account")
+@Inheritance(strategy = InheritanceType.JOINED)
+@DiscriminatorColumn(name = "account_usage")
+@DiscriminatorValue(value = "sharedaccount")
+public class AccountDb implements Account, 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;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Account
+   */
+  @Basic
+  @Column(name = "domain", length = 255)
+  protected String domain;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Account
+   */
+  @Basic
+  @Column(name = "user_id", length = 255)
+  protected String userId;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Account
+   */
+  @Basic
+  @Column(name = "username", length = 255)
+  protected String username;
+
+  /**
+   * create an empty account object.
+   */
+  public AccountDb() {
+  }
+
+  /**
+   * Create an account object based on domain, userId and username
+   * @param domain the domain of the account
+   * @param userId the user id of the account
+   * @param username the username of the account
+   */
+  public AccountDb(String domain, String userId, String username) {
+    this.domain = domain;
+    this.userId = userId;
+    this.username = username;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#getDomain()
+   */
+  public String getDomain() {
+    return domain;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#setDomain(java.lang.String)
+   */
+  public void setDomain(String domain) {
+    this.domain = domain;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#getUserId()
+   */
+  public String getUserId() {
+    return userId;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#setUserId(java.lang.String)
+   */
+  public void setUserId(String userId) {
+    this.userId = userId;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#getUsername()
+   */
+  public String getUsername() {
+    return username;
+  }
+
+  /**
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Account#setUsername(java.lang.String)
+   */
+  public void setUsername(String username) {
+    this.username = username;
+  }
+
+  /**
+   * {@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/ActivityDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,665 @@
+/*
+ * 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.GenerationType.IDENTITY;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.MapMaker;
+
+import org.apache.shindig.social.opensocial.jpa.api.DbObject;
+import org.apache.shindig.social.opensocial.model.Activity;
+import org.apache.shindig.social.opensocial.model.MediaItem;
+
+import java.util.Date;
+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.MapKey;
+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;
+
+/**
+ * Activity model object stored in the "activity" table.
+ */
+@Entity
+@Table(name = "activity")
+@NamedQueries(value = {
+    @NamedQuery(name = ActivityDb.FINDBY_ACTIVITY_ID, 
+        query = "select activity from ActivityDb activity where activity.userId = :userId and activity.id = :activityId")
+    })
+public class ActivityDb implements Activity, DbObject {
+
+  public static final String FINDBY_ACTIVITY_ID = "q.activity.findbyactivityid";
+
+  public static final String PARAM_USERID = "userId";
+  
+  public static final String PARAM_ACTIVITYID = "activityId";
+   
+  public static final String JPQL_FINDBY_ACTIVITIES = null;
+  
+  public static final String JPQL_FINDACTIVITY = "select a from ActivityDb a where ";
+  
+  public static final String JPQL_FINDACTIVITY_BY_FRIENDS = "select a from ActivityDb a where a.userId in (select p.id from PersonDb p where p.objectId in (select f.friend.objectId from PersonDb p, FriendDb f where p.objectId = f.person.objectId and ";
+
+  /**
+   * 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;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "app_id", length = 255)
+  protected String appId;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "body", length = 255)
+  protected String body;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "body_id", length = 255)
+  protected String bodyId;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "external_id", length = 255)
+  protected String externalId;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "activity_id", length = 255)
+  protected String id;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "updated")
+  @Temporal(TemporalType.TIMESTAMP)
+  protected Date updated;
+
+  /**
+   * A list of shared media items associated with this activity, joined by the
+   * table "activity_media" such that activity_media.activity_id = activity.oid
+   * and activity_media.media_id = media.oid. Media items may be shared amongst
+   * many activities or other entities.
+   */
+  @ManyToMany(targetEntity = MediaItemDb.class, cascade = ALL)
+  @JoinTable(name = "activity_media",
+      joinColumns = @JoinColumn(name = "activity_id", referencedColumnName = "oid"),
+      inverseJoinColumns = @JoinColumn(name = "media_id", referencedColumnName = "oid"))
+  protected List<MediaItem> mediaItems;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "posted_time")
+  protected Long postedTime;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "priority")
+  protected Float priority;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "stream_favicon_url", length = 255)
+  protected String streamFaviconUrl;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "stream_source_url", length = 255)
+  protected String streamSourceUrl;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "stream_title", length = 255)
+  protected String streamTitle;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "stream_url", length = 255)
+  protected String streamUrl;
+
+  /**
+   * Create map using ActivityTemplateParamsDb such that ActivityTemplateParams
+   * are joined on oid -> activity_id and then the name value becomes the key,
+   * and the value becomes the value unfortunately JPA wont do
+   * Map<String,String> so this is handled in the prePersist and postLoad hook.
+   */
+  @OneToMany(targetEntity = ActivityTemplateParamsDb.class, mappedBy = "activity", cascade = ALL)
+  @MapKey(name = "name")
+  protected Map<String, ActivityTemplateParamsDb> templateParamsDb = new MapMaker().makeMap();
+
+  /**
+   * The transient store for templateParamers loaded by the postLoad hook and
+   * persisted by the prePersist hook.
+   */
+  @Transient
+  protected Map<String, String> templateParams;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "title", length = 255)
+  protected String title;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "title_id", length = 255)
+  protected String titleId;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "url", length = 255)
+  protected String url;
+
+  /**
+   * model field.
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity
+   */
+  @Basic
+  @Column(name = "user_id", length = 255)
+  protected String userId;
+
+  public ActivityDb() {
+  }
+
+  public ActivityDb(String id, String userId) {
+    this.id = id;
+    this.userId = userId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getAppId()
+   */
+  public String getAppId() {
+    return appId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setAppId(java.lang.String)
+   */
+  public void setAppId(String appId) {
+    this.appId = appId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getBody()
+   */
+  public String getBody() {
+    return body;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setBody(java.lang.String)
+   */
+  public void setBody(String body) {
+    this.body = body;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getBodyId()
+   */
+  public String getBodyId() {
+    return bodyId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setBodyId(java.lang.String)
+   */
+  public void setBodyId(String bodyId) {
+    this.bodyId = bodyId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getExternalId()
+   */
+  public String getExternalId() {
+    return externalId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setExternalId(java.lang.String)
+   */
+  public void setExternalId(String externalId) {
+    this.externalId = externalId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getId()
+   */
+  public String getId() {
+    return id;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setId(java.lang.String)
+   */
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getUpdated()
+   */
+  public Date getUpdated() {
+    if (updated == null) {
+      return null;
+    }
+    return new Date(updated.getTime());
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setUpdated(java.util.Date)
+   */
+  public void setUpdated(Date updated) {
+    if (updated == null) {
+      this.updated = null;
+    } else {
+      this.updated = new Date(updated.getTime());
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getMediaItems()
+   */
+  public List<MediaItem> getMediaItems() {
+    return mediaItems;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setMediaItems(java.util.List)
+   */
+  public void setMediaItems(List<MediaItem> mediaItems) {
+    this.mediaItems = mediaItems;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getPostedTime()
+   */
+  public Long getPostedTime() {
+    return postedTime;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setPostedTime(java.lang.Long)
+   */
+  public void setPostedTime(Long postedTime) {
+    this.postedTime = postedTime;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getPriority()
+   */
+  public Float getPriority() {
+    return priority;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setPriority(java.lang.Float)
+   */
+  public void setPriority(Float priority) {
+    this.priority = priority;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getStreamFaviconUrl()
+   */
+  public String getStreamFaviconUrl() {
+    return streamFaviconUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setStreamFaviconUrl(java.lang.String)
+   */
+  public void setStreamFaviconUrl(String streamFaviconUrl) {
+    this.streamFaviconUrl = streamFaviconUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getStreamSourceUrl()
+   */
+  public String getStreamSourceUrl() {
+    return streamSourceUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setStreamSourceUrl(java.lang.String)
+   */
+  public void setStreamSourceUrl(String streamSourceUrl) {
+    this.streamSourceUrl = streamSourceUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getStreamTitle()
+   */
+  public String getStreamTitle() {
+    return streamTitle;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setStreamTitle(java.lang.String)
+   */
+  public void setStreamTitle(String streamTitle) {
+    this.streamTitle = streamTitle;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getStreamUrl()
+   */
+  public String getStreamUrl() {
+    return streamUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setStreamUrl(java.lang.String)
+   */
+  public void setStreamUrl(String streamUrl) {
+    this.streamUrl = streamUrl;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getTemplateParams()
+   */
+  public Map<String, String> getTemplateParams() {
+    return templateParams;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setTemplateParams(java.util.Map)
+   */
+  public void setTemplateParams(Map<String, String> templateParams) {
+    this.templateParams = templateParams;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getTitle()
+   */
+  public String getTitle() {
+    return title;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setTitle(java.lang.String)
+   */
+  public void setTitle(String title) {
+    this.title = title;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getTitleId()
+   */
+  public String getTitleId() {
+    return titleId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setTitleId(java.lang.String)
+   */
+  public void setTitleId(String titleId) {
+    this.titleId = titleId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getUrl()
+   */
+  public String getUrl() {
+    return url;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setUrl(java.lang.String)
+   */
+  public void setUrl(String url) {
+    this.url = url;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#getUserId()
+   */
+  public String getUserId() {
+    return userId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.model.Activity#setUserId(java.lang.String)
+   */
+  public void setUserId(String userId) {
+    this.userId = userId;
+  }
+
+  /**
+   * {@inheritDoc}
+   *
+   * @see org.apache.shindig.social.opensocial.jpa.api.DbObject#getObjectId()
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+  /**
+   * Hook into the pre persist JPA event to take the transient fields and
+   * populate the DB fields prior to persisting the data.
+   */
+  @PrePersist
+  public void populateDbFields() {
+    if (templateParams != null) {
+      // add new entries
+      for (Entry<String, String> e : templateParams.entrySet()) {
+        ActivityTemplateParamsDb a = templateParamsDb.get(e.getKey());
+        if (a == null) {
+          a = new ActivityTemplateParamsDb();
+          a.name = e.getKey();
+          a.value = e.getValue();
+          a.activity = this;
+          // a.activities = Lists.newArrayList();
+          // a.activities.add(this);
+          templateParamsDb.put(e.getKey(), a);
+        } else {
+          a.value = e.getValue();
+        }
+      }
+      // remove old entries
+      List<String> toRemove = Lists.newArrayList();
+      for (Entry<String, ActivityTemplateParamsDb> e : templateParamsDb
+          .entrySet()) {
+        if (!templateParams.containsKey(e.getKey())) {
+          toRemove.add(e.getKey());
+        }
+      }
+      for (String r : toRemove) {
+        templateParamsDb.remove(r);
+      }
+    }
+  }
+
+  /**
+   * Hook into the post load event in JPA to take the database fields and load
+   * the transient fields prior to making the object available to java.
+   */
+  @PostLoad
+  public void loadTransientFields() {
+    templateParams = new MapMaker().makeMap();
+    for (Entry<String, ActivityTemplateParamsDb> e : templateParamsDb
+        .entrySet()) {
+      templateParams.put(e.getKey(), e.getValue().value);
+    }
+  }
+
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityTemplateParamsDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityTemplateParamsDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityTemplateParamsDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ActivityTemplateParamsDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import static javax.persistence.CascadeType.ALL;
+import static javax.persistence.GenerationType.IDENTITY;
+
+import org.apache.shindig.social.opensocial.jpa.api.DbObject;
+import org.apache.shindig.social.opensocial.model.Activity;
+
+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.Table;
+import javax.persistence.Version;
+
+/**
+ *
+ */
+@Entity
+@Table(name = "template_params")
+public class ActivityTemplateParamsDb 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;
+
+  /**
+   * Create a link to the activities joining activity_id here to oid in
+   * activities.
+   */
+
+  @ManyToOne(targetEntity = ActivityDb.class, cascade = ALL)
+  @JoinColumn(name = "activity_id", referencedColumnName = "oid")
+  protected Activity activity;
+  // TODO: <openjpa-1.2.0-r422266:683325 fatal user error>
+  // org.apache.openjpa.persistence.ArgumentException: The type of field
+  // "org.apache.shindig.social.opensocial.jpa.ActivityTemplateParamsDb.activities"
+  // isn't supported
+  // by declared persistence strategy "ManyToOne". Please choose a different
+  // strategy.
+
+  /**
+   * The name of the value in the template parameters.
+   */
+  @Basic
+  @Column(name = "template_name")
+  protected String name;
+
+  /**
+   * The value of the parameter.
+   */
+  @Basic
+  @Column(name = "template_value")
+  protected String value;
+
+  /**
+   * {@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/AddressDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AddressDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AddressDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/AddressDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,361 @@
+/*
+ * 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.Person;
+
+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.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import java.util.List;
+
+/**
+ * Address storage, stored in "address", may be joined with other subclasses and if so
+ * "address_usage" will contain the subclass discriminatory value. 
+ * This might also be "sharedaddress" if this address is shared.
+ */
+@Entity
+@Table(name = "address")
+@Inheritance(strategy = InheritanceType.JOINED)
+@DiscriminatorColumn(name = "address_usage")
+@DiscriminatorValue(value = "sharedaddress")
+@NamedQuery(name = AddressDb.FINDBY_POSTCODE, 
+    query = "select a from AddressDb a where a.postalCode = :postalcode ")
+public class AddressDb implements Address, DbObject {
+  /**
+   * Name of the JPA query to find addresses by postcode
+   */
+  public static final String FINDBY_POSTCODE = "q.address.findbypostcode";
+
+  /**
+   * name of the postcode parameter used in named queries (JPA)
+   */
+  public static final String PARAM_POSTCODE = "postalcode";
+
+  /**
+   * 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;
+
+  /**
+   * People may be at this address, this is a list of people who are currently at this address.
+   */
+  @OneToMany(targetEntity = PersonDb.class, mappedBy = "currentLocation")
+  private List<Person> atLocation;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "country", length = 255)
+  private String country;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "latitude")
+  private Float latitude;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "longitude")
+  private Float longitude;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "locality", length = 255)
+  private String locality;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "postal_code", length = 255)
+  private String postalCode;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "region", length = 255)
+  private String region;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "street_address", length = 255)
+  private String streetAddress;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "type", length = 255)
+  private String type;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "formatted", length = 255)
+  private String formatted;
+
+  /**
+   * model field.
+   * @see org.apache.shindig.social.opensocial.model.Address
+   */
+  @Basic
+  @Column(name = "primary_address")
+  private Boolean primary;
+
+  /**
+   *  default constructor
+   */
+  public AddressDb() {
+  }
+
+  /**
+   * Create an address from the formatted address, no parsing of the address will be performed.
+   * @param formatted the formatted address.
+   */
+  public AddressDb(String formatted) {
+    this.formatted = formatted;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getCountry()
+   */
+  public String getCountry() {
+    return country;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setCountry(java.lang.String)
+   */
+  public void setCountry(String country) {
+    this.country = country;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getLatitude()
+   */
+  public Float getLatitude() {
+    return latitude;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setLatitude(java.lang.Float)
+   */
+  public void setLatitude(Float latitude) {
+    this.latitude = latitude;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getLocality()
+   */
+  public String getLocality() {
+    return locality;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setLocality(java.lang.String)
+   */
+  public void setLocality(String locality) {
+    this.locality = locality;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getLongitude()
+   */
+  public Float getLongitude() {
+    return longitude;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setLongitude(java.lang.Float)
+   */
+  public void setLongitude(Float longitude) {
+    this.longitude = longitude;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getPostalCode()
+   */
+  public String getPostalCode() {
+    return postalCode;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setPostalCode(java.lang.String)
+   */
+  public void setPostalCode(String postalCode) {
+    this.postalCode = postalCode;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getRegion()
+   */
+  public String getRegion() {
+    return region;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setRegion(java.lang.String)
+   */
+  public void setRegion(String region) {
+    this.region = region;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getStreetAddress()
+   */
+  public String getStreetAddress() {
+    return streetAddress;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setStreetAddress(java.lang.String)
+   */
+  public void setStreetAddress(String streetAddress) {
+    this.streetAddress = streetAddress;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getType()
+   */
+  public String getType() {
+    return type;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setType(java.lang.String)
+   */
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getFormatted()
+   */
+  public String getFormatted() {
+    return formatted;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setFormatted(java.lang.String)
+   */
+  public void setFormatted(String formatted) {
+    this.formatted = formatted;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#getPrimary()
+   */
+  public Boolean getPrimary() {
+    return primary;
+  }
+
+  /** 
+   * {@inheritDoc}
+   * @see org.apache.shindig.social.opensocial.model.Address#setPrimary(java.lang.Boolean)
+   */
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+  /**
+   * @return the objectId
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+  /**
+   * @return the atLocation
+   */
+  public List<Person> getAtLocation() {
+    return atLocation;
+  }
+
+  /**
+   * @param atLocation the atLocation to set
+   */
+  public void setAtLocation(List<Person> atLocation) {
+    this.atLocation = atLocation;
+  }
+}

Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapDb.java?rev=1104678&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapDb.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/ApplicationDataMapDb.java Wed May 18 03:42:09 2011
@@ -0,0 +1,210 @@
+/*
+ * 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.GenerationType.IDENTITY;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.MapMaker;
+
+import org.apache.shindig.social.opensocial.jpa.api.DbObject;
+
+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.ManyToOne;
+import javax.persistence.MapKey;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+
+/**
+ * An application data map is the map of data for a single key within an application.
+ */
+@Entity
+@Table(name="application_datamap")
+public class ApplicationDataMapDb implements DbObject {
+  /**
+   * The object needs to be seializable (map).
+   */
+  private static final long serialVersionUID = 8017568825925047318L;
+
+  public static final String FINDBY_ALL_GROUP = null;
+
+  public static final String FINDBY_FRIENDS_GROUP = "select am from ApplicationDataMapDb am where am.personId in (select f.friend.id from PersonDb p, FriendDb f where p.objectId = f.person.objectId and ";
+
+  public static final String FINDBY_GROUP_GROUP = null;
+
+  public static final String FINDBY_SELF_GROUP = "select am from ApplicationDataMapDb am 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")
+  protected long objectId;
+
+  /**
+   * An optimistic locking field.
+   */
+  @Version
+  @Column(name = "version")
+  protected long version;
+
+  /**
+   * A Application Data Map belongs to a set of maps associated with an application.
+   * The link from Application to DataMap is not navigable since it may contain 1000's of entries.
+   */
+  @ManyToOne(targetEntity=ApplicationDb.class)
+  @JoinColumn(name="application_id", referencedColumnName="oid")
+  protected ApplicationDb application;
+
+  /**
+   * Create map using ApplicationDataMapValueDb such that ApplicationDataMapDb are joined on oid ->
+   * application_datamap_id and then the name value becomes the key, and the value becomes the value
+   * unfortunately JPA wont do Map<String,String> so this is handled in the prePersist and postLoad
+   * hook.
+   */
+  @OneToMany(targetEntity=ApplicationDataMapValueDb.class, mappedBy="applicationDataMap", cascade = ALL)
+  @MapKey(name="name")
+  protected Map<String, ApplicationDataMapValueDb> valuesDb = new MapMaker().makeMap();
+
+  /**
+   * The transient store for values loaded by the postLoad hook and persisted by the
+   * prePersist hook.
+   */
+  @Transient
+  protected Map<String, String> values;
+
+  @Basic
+  @Column(name="person_id", length=255)
+  protected String personId;
+
+  /**
+   * persist the state of object before sending to the db.
+   */
+  @PrePersist
+  public void prePersist() {
+    // add new entries
+    for (Entry<String, String> e : values.entrySet()) {
+      ApplicationDataMapValueDb a = valuesDb.get(e.getKey());
+      if (a == null) {
+        a = new ApplicationDataMapValueDb();
+        a.name = e.getKey();
+        a.value = e.getValue();
+        a.applicationDataMap = this;
+        valuesDb.put(e.getKey(), a);
+      } else {
+        a.value = e.getValue();
+      }
+    }
+    // remove old entries
+    List<String> toRemove = Lists.newArrayList();
+    for (Entry<String, ApplicationDataMapValueDb> e : valuesDb.entrySet()) {
+      if (!values.containsKey(e.getKey())) {
+        toRemove.add(e.getKey());
+      }
+    }
+    for (String r : toRemove) {
+      valuesDb.remove(r);
+    }
+  }
+
+  /**
+   * set the state of the object after load
+   */
+  @PostLoad
+  public void postLoad() {
+    values = new MapMaker().makeMap();
+    for (Entry<String, ApplicationDataMapValueDb> e : valuesDb.entrySet()) {
+      values.put(e.getKey(), e.getValue().value);
+    }
+  }
+
+  /**
+   * @return the application
+   */
+  public ApplicationDb getApplication() {
+    return application;
+  }
+
+  /**
+   * @param applicationData the applicationData to set
+   */
+  public void setApplication(ApplicationDb application) {
+    this.application = application;
+  }
+
+  /**
+   * @return the values
+   */
+  public Map<String, String> getValues() {
+    return values;
+  }
+
+  /**
+   * @param values the values to set
+   */
+  public void setValues(Map<String, String> values) {
+    this.values = values;
+  }
+
+  /**
+   * @return the objectId
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+  /**
+   * @return the version
+   */
+  public long getVersion() {
+    return version;
+  }
+
+  /**
+   * @return the personId
+   */
+  public String getPersonId() {
+    return personId;
+  }
+
+  /**
+   * @param personId the personId to set
+   */
+  public void setPersonId(String personId) {
+    this.personId = personId;
+  }
+
+
+}



Mime
View raw message