abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1202016 - in /abdera/abdera2: ./ activities/src/main/java/org/apache/abdera2/activities/io/gson/ activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/model/objects/
Date Tue, 15 Nov 2011 02:59:30 GMT
Author: jmsnell
Date: Tue Nov 15 02:59:29 2011
New Revision: 1202016

URL: http://svn.apache.org/viewvc?rev=1202016&view=rev
Log:
Add experimental "reactions" support in the Activity Stream impl and fix a cpl bugs

Added:
    abdera/abdera2/.classpath   (with props)
    abdera/abdera2/.project   (with props)
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
  (with props)
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java

Added: abdera/abdera2/.classpath
URL: http://svn.apache.org/viewvc/abdera/abdera2/.classpath?rev=1202016&view=auto
==============================================================================
--- abdera/abdera2/.classpath (added)
+++ abdera/abdera2/.classpath Tue Nov 15 02:59:29 2011
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="src" output="common/target/classes" path="common/src/main/resources"/>
+	<classpathentry kind="src" output="examples/target/classes" path="examples/src/main/resources"/>
+	<classpathentry kind="src" output="examples/target/classes" path="examples/src/main/java"/>
+	<classpathentry kind="src" output="test/target/test-classes" path="test/src/test/java"/>
+	<classpathentry kind="src" output="test/target/classes" path="test/src/main/java"/>
+	<classpathentry kind="src" output="test/target/classes" path="test/src/main/resources"/>
+	<classpathentry kind="src" output="server/target/classes" path="server/src/main/resources"/>
+	<classpathentry kind="src" output="server/target/classes" path="server/src/main/java"/>
+	<classpathentry kind="src" output="security/target/classes" path="security/src/main/resources"/>
+	<classpathentry kind="src" output="security/target/classes" path="security/src/main/java"/>
+	<classpathentry kind="src" output="ext/target/classes" path="ext/src/main/resources"/>
+	<classpathentry kind="src" output="ext/target/classes" path="ext/src/main/java"/>
+	<classpathentry kind="src" output="core/target/classes" path="core/src/main/resources"/>
+	<classpathentry kind="src" output="core/target/classes" path="core/src/main/java"/>
+	<classpathentry kind="src" output="common/target/classes" path="common/src/main/java"/>
+	<classpathentry kind="src" output="client/target/classes" path="client/src/main/java"/>
+	<classpathentry kind="src" output="client/target/classes" path="client/src/main/resources"/>
+	<classpathentry kind="src" output="activities/target/classes" path="activities/src/main/resources"/>
+	<classpathentry kind="src" output="activities/target/classes" path="activities/src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM
1.5.0 (MacOS X Default)">
+		<attributes>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Propchange: abdera/abdera2/.classpath
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/.project
URL: http://svn.apache.org/viewvc/abdera/abdera2/.project?rev=1202016&view=auto
==============================================================================
--- abdera/abdera2/.project (added)
+++ abdera/abdera2/.project Tue Nov 15 02:59:29 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>abdera2</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Propchange: abdera/abdera2/.project
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/io/gson/BaseAdapter.java
Tue Nov 15 02:59:29 2011
@@ -58,6 +58,7 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.objects.QuestionObject;
 import org.apache.abdera2.activities.model.objects.ReviewObject;
 import org.apache.abdera2.activities.model.objects.ServiceObject;
+import org.apache.abdera2.activities.model.objects.TaskObject;
 import org.apache.abdera2.activities.model.objects.TvEpisodeObject;
 import org.apache.abdera2.activities.model.objects.TvSeasonObject;
 import org.apache.abdera2.activities.model.objects.TvSeriesObject;
@@ -106,6 +107,7 @@ final class BaseAdapter 
     map.put("duration", Integer.class);
     map.put("height", Integer.class);
     map.put("location", PlaceObject.class);
+    map.put("reactions", TaskObject.class);
     map.put("mood", Mood.class);
     map.put("address", Address.class);
     map.put("stream", MediaLink.class);
@@ -166,7 +168,8 @@ final class BaseAdapter 
       TvSeasonObject.TvSeasonBuilder.class,
       TvSeriesObject.TvSeriesBuilder.class,
       VersionObject.VersionBuilder.class,
-      BinaryObject.BinaryBuilder.class
+      BinaryObject.BinaryBuilder.class,
+      TaskObject.TaskBuilder.class
     );
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASObject.java
Tue Nov 15 02:59:29 2011
@@ -29,6 +29,7 @@ import org.apache.abdera2.activities.ext
 import org.apache.abdera2.activities.model.objects.EmbeddedExperience;
 import org.apache.abdera2.activities.model.objects.Mood;
 import org.apache.abdera2.activities.model.objects.PlaceObject;
+import org.apache.abdera2.activities.model.objects.TaskObject;
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.selector.Selector;
@@ -55,6 +56,7 @@ public class ASObject extends ASBase {
   public static final String UPDATED = "updated";
   public static final String UPSTREAMDUPLICATES = "upstreamDuplicates";
   public static final String URL = "url";
+  public static final String REACTIONS = "reactions";
   
   public static final String INREPLYTO = "inReplyTo";
   public static final String LOCATION = "location";
@@ -93,7 +95,8 @@ public class ASObject extends ASBase {
     private ImmutableSet.Builder<ASObject> replies = ImmutableSet.builder();
     private ImmutableSet.Builder<String> downdups = ImmutableSet.builder();
     private ImmutableSet.Builder<String> updups = ImmutableSet.builder();
-    private boolean a,t,r,d,u;
+    private ImmutableSet.Builder<TaskObject> tasks = ImmutableSet.builder();
+    private boolean a,t,r,d,u,z;
     
     public Builder(String objectType, Class<X> _class, Class<M> _builder) {
       super(_class,_builder);
@@ -105,37 +108,116 @@ public class ASObject extends ASBase {
     public Builder(Map<String,Object> map,Class<X> _class, Class<M> _builder)
{
       super(map,_class,_builder);
     }
+    
+    public M reaction(TaskObject object) {
+      if (object == null) return (M)this;
+      z = true;
+      tasks.add(object);
+      return (M)this;
+    }
+    
+    public M reaction(TaskObject... objects) {
+      if (objects == null) return (M)this;
+      for (TaskObject obj : objects)
+        reaction(obj);
+      return (M)this;
+    }
+    
+    public M reaction(Iterable<TaskObject> objects) {
+      if (objects == null) return (M)this;
+      for (TaskObject obj : objects)
+        reaction(obj);
+      return (M)this;
+    }
+    
+    
+    public M attachment(ASObject... objects) {
+      if (objects == null) return (M)this;
+      for (ASObject obj : objects)
+        attachment(obj);
+      return (M)this;
+    }
+    
+    public M attachment(Iterable<ASObject> objects) {
+      if (objects == null) return (M)this;
+      for (ASObject obj : objects)
+        attachment(obj);
+      return (M)this;
+    }
+    
     public M attachment(ASObject object) {
       if (object == null) return (M)this;
-      if (!a)a=true;
+      a = true;
       attachments.add(object);
       return (M)this;
     }
     
+    public M downstreamDuplicate(String... objects) {
+      if (objects == null) return (M)this;
+      for (String obj : objects)
+        downstreamDuplicate(obj);
+      return (M)this;
+    }
+    
+    public M downstreamDuplicate(Iterable<String> objects) {
+      if (objects == null) return (M)this;
+      for (String obj : objects)
+        downstreamDuplicate(obj);
+      return (M)this;
+    }
+    
     public M downstreamDuplicate(String id) {
       if (id == null) return (M)this;
-      if (!d)d=true;
+      d = true;
       downdups.add(id);
       return (M)this;
     }
     
     public M inReplyTo(ASObject object) {
       if (object == null) return (M)this;
-      if (!r)r=true;
+      r = true;
       replies.add(object);
       return (M)this;
     }
     
+    public M tag(ASObject... objects) {
+      if (objects == null) return (M)this;
+      for (ASObject obj : objects)
+        tag(obj);
+      return (M)this;
+    }
+    
+    public M tag(Iterable<ASObject> objects) {
+      if (objects == null) return (M)this;
+      for (ASObject obj : objects)
+        tag(obj);
+      return (M)this;
+    }
+    
     public M tag(ASObject object) {
       if (object == null) return (M)this;
-      if (!t)t=true;
+      t = true;
       tags.add(object);
       return (M)this;
     }
     
+    public M upstreamDuplicate(String... objects) {
+      if (objects == null) return (M)this;
+      for (String obj : objects)
+        upstreamDuplicate(obj);
+      return (M)this;
+    }
+    
+    public M upstreamDuplicate(Iterable<String> objects) {
+      if (objects == null) return (M)this;
+      for (String obj : objects)
+        upstreamDuplicate(obj);
+      return (M)this;
+    }
+    
     public M upstreamDuplicate(String id) {
       if (id == null) return (M)this;
-      if (!u)u=true;
+      u = true;
       updups.add(id);
       return (M)this;
     }
@@ -239,11 +321,13 @@ public class ASObject extends ASBase {
     }
     
     public void preGet() {
+      super.preGet();
       if (a) set(ATTACHMENTS, attachments.build());
       if (t) set(TAGS, tags.build());
       if (r) set(INREPLYTO, replies.build());
       if (d) set(DOWNSTREAMDUPLICATES, downdups.build());
       if (u) set(UPSTREAMDUPLICATES, updups.build());
+      if (z) set(REACTIONS, tasks.build());
     }
     
   }
@@ -294,7 +378,11 @@ public class ASObject extends ASBase {
    * duplication detection easier
    */
   public Iterable<String> getDownstreamDuplicates() {
-    return checkEmpty((Iterable<String>)getProperty(DOWNSTREAMDUPLICATES));
+    return checkEmpty(this.<Iterable<String>>getProperty(DOWNSTREAMDUPLICATES));
+  }
+  
+  public Iterable<TaskObject> getReactions() {
+    return checkEmpty(this.<Iterable<TaskObject>>getProperty(REACTIONS));
   }
   
   /**

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Activity.java
Tue Nov 15 02:59:29 2011
@@ -181,6 +181,7 @@ public class Activity extends ASObject {
       return (M)this;
     }
     public void preGet() {
+      super.preGet();
       if (a) set(Audience.TO.label(),to.build());
       if (b) set(Audience.CC.label(),cc.build());
       if (c) set(Audience.BCC.label(),bcc.build());

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
Tue Nov 15 02:59:29 2011
@@ -136,6 +136,7 @@ public class Collection<T extends ASObje
       return (M)this;
     }
     public void preGet() {
+      super.preGet();
       Set<T> i = items.build();
       if(b) set(OBJECT_TYPES, types.build());
       if(a) {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
Tue Nov 15 02:59:29 2011
@@ -249,6 +249,7 @@ public class BinaryObject extends FileOb
     }
     
     public void preGet() {
+      super.preGet();
       if (!a)  mimeType("application/octet-stream");
     }
   }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java
Tue Nov 15 02:59:29 2011
@@ -28,7 +28,7 @@ public final class Mood extends ASBase {
   public static final String IMAGE = "image";
   public static final String DISPLAYNAME = "displayName";
   
-  protected Mood(Map<String,Object> map) {
+  public Mood(Map<String,Object> map) {
     super(map,Builder.class,Mood.class);
   }
   

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
Tue Nov 15 02:59:29 2011
@@ -374,6 +374,7 @@ public class PersonObject 
       return (M)this;
     }
     public void preGet() {
+      super.preGet();
       if (a) set("accounts",accounts.build());
       if (b) set("addresses",addresses.build());
       if (c) set("alternateNames",altnames.build());

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java?rev=1202016&r1=1202015&r2=1202016&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java
Tue Nov 15 02:59:29 2011
@@ -123,6 +123,7 @@ public class QuestionObject 
       return (M)this;
     }
     public void preGet() {
+      super.preGet();
       if (a) set(OPTIONS, options.build());
     }
   }

Added: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java?rev=1202016&view=auto
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
(added)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
Tue Nov 15 02:59:29 2011
@@ -0,0 +1,148 @@
+package org.apache.abdera2.activities.model.objects;
+
+import java.util.Map;
+
+import org.apache.abdera2.activities.io.gson.Properties;
+import org.apache.abdera2.activities.io.gson.Property;
+import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.Verb;
+import org.apache.abdera2.common.anno.Name;
+import org.apache.abdera2.common.date.DateTimes;
+import org.apache.abdera2.common.iri.IRI;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Special object type intended to describe the actions that can be 
+ * taken in response to another object.
+ * 
+ * this is purely experimental at this point and is something 
+ * that I'm kicking around with the AS community. It's included 
+ * here as a basic proof of the concept and to get some implementation
+ * experience playing around with it
+ */
+public class TaskObject extends ASObject {
+
+  public TaskObject(Map<String,Object> map) {
+    super(map,TaskBuilder.class,TaskObject.class);
+  }
+  
+  public <X extends TaskObject, M extends Builder<X,M>>TaskObject(Map<String,Object>
map, Class<M> _class, Class<X> _obj) {
+    super(map,_class,_obj);
+  }
+  
+  public <X extends ASObject>X getObject() {
+    return getProperty("for");
+  }
+  
+  public <X extends ASObject>X getActor() {
+    return getProperty("actor");
+  }
+  
+  public Iterable<String> getSupersedes() {
+    return checkEmpty(this.<Iterable<String>>getProperty("supersedes"));
+  }
+  
+  public boolean isRequired() {
+    return (Boolean)getProperty("required");
+  }
+  
+  public DateTime getBy() {
+    return getProperty("by");
+  }
+
+  public Verb getVerb() {
+    return getProperty("verb");
+  }
+  
+  public IRI getResourceLink() {
+    return getProperty("resourceLink");
+  }
+  
+  public static TaskBuilder makeTask() {
+    return new TaskBuilder("task");
+  }
+ 
+  @Name("task")
+  @Properties({
+    @Property(name="by",to=DateTime.class),
+    @Property(name="supersedes",to=String.class),
+    @Property(name="resourceLink",to=IRI.class),
+    @Property(name="for",to=ASObject.class)
+  })
+  public static final class TaskBuilder extends Builder<TaskObject,TaskBuilder> {
+    public TaskBuilder() {
+      super(TaskObject.class,TaskBuilder.class);
+    }
+    public TaskBuilder(Map<String, Object> map) {
+      super(map, TaskObject.class,TaskBuilder.class);
+    }
+    public TaskBuilder(String objectType) {
+      super(objectType, TaskObject.class,TaskBuilder.class);
+    }
+  }
+  
+  @SuppressWarnings("unchecked")
+  public static abstract class Builder<X extends TaskObject,M extends Builder<X,M>>

+    extends ASObject.Builder<X,M> {
+    
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder)
{
+      super(map,_class,_builder);
+    }
+    public M object(ASObject object) {
+      set("for",object);
+      return (M)this;
+    }
+    public M actor(ASObject object) {
+      set("actor",object);
+      return (M)this;
+    }
+    public M supersedes(String... ids) {
+      if (ids == null) return (M)this;
+      set("supersedes",ImmutableSet.copyOf(ids));
+      return (M)this;
+    }
+    public M required() {
+      set("required",true);
+      return (M)this;
+    }
+    public M by(DateTime dateTime) {
+      set("by",dateTime);
+      return (M)this;
+    }
+    public M byNow() {
+      set("by",DateTimes.now());
+      return (M)this;
+    }
+    public M by(Duration duration) {
+      return by(DateTimes.now().plus(duration));
+    }
+    public M selfLink(IRI iri) {
+      set("selfLink", iri);
+      return (M)this;
+    }
+    public M selfLink(String iri) {
+      return selfLink(new IRI(iri));
+    }
+    public M verb(Verb verb) {
+      set("verb",verb);
+      return (M)this;
+    }
+    public M resourceLink(IRI iri) {
+      set("resourceLink",iri);
+      return (M)this;
+    }
+    public M resourceLink(String iri) {
+      return resourceLink(new IRI(iri));
+    }
+  }
+  
+}

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TaskObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message