Permalink
Browse files

preliminary support for the Business Event Subscriptions stuff works now

  • Loading branch information...
1 parent 1599171 commit 766725819722cc34649deeea646f577e60b2f866 @mindcrime mindcrime committed Apr 22, 2012
Showing with 375 additions and 83 deletions.
  1. +14 −0 .classpath
  2. +1 −0 .settings/org.eclipse.wst.common.component
  3. +12 −11 grails-app/controllers/org/fogbeam/quoddy/ActivityStreamController.groovy
  4. +9 −8 grails-app/controllers/org/fogbeam/quoddy/StatusController.groovy
  5. +1 −2 grails-app/domain/org/fogbeam/quoddy/Activity.groovy
  6. +1 −3 grails-app/domain/org/fogbeam/quoddy/CalendarEvent.groovy
  7. +1 −2 grails-app/domain/org/fogbeam/quoddy/EventBase.groovy
  8. +4 −3 grails-app/domain/org/fogbeam/quoddy/SubscriptionEvent.groovy
  9. +1 −1 grails-app/jobs/org/fogbeam/quoddy/DummyJob.groovy
  10. +21 −21 grails-app/services/org/fogbeam/quoddy/EventQueueService.groovy
  11. +28 −23 grails-app/services/org/fogbeam/quoddy/EventStreamService.groovy
  12. +8 −8 grails-app/services/org/fogbeam/quoddy/EventSubscriptionService.groovy
  13. +67 −0 grails-app/services/org/fogbeam/quoddy/ExistDBService.groovy
  14. +113 −0 grails-app/taglib/org/fogbeam/quoddy/taglib/XmlTagLib.groovy
  15. +20 −0 grails-app/views/_renderSubscriptionEvent.gsp
  16. +1 −1 grails-app/views/layouts/main.gsp
  17. BIN lib/excalibur-cli-1.0.jar
  18. BIN lib/exist-fluent.jar
  19. BIN lib/exist-optional.jar
  20. BIN lib/exist.jar
  21. BIN lib/jgroups-all-2.2.6.jar
  22. BIN lib/jline-0.9.94.jar
  23. BIN lib/serializer.jar
  24. BIN lib/ws-commons-util-1.0.2.jar
  25. BIN lib/xalan.jar
  26. BIN lib/xmldb.jar
  27. BIN lib/xmlrpc-client-3.1.2.jar
  28. BIN lib/xmlrpc-common-3.1.2.jar
  29. BIN lib/xmlrpc-server-3.1.2.jar
  30. +27 −0 web-app/css/oagis.css
  31. +46 −0 web-app/stylesheets/oagis3.xsl
View
@@ -12,6 +12,7 @@
<classpathentry kind="src" path="grails-app/jobs"/>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="grails-app/resources"/>
+ <classpathentry kind="src" path="grails-app/taglib"/>
<classpathentry kind="lib" path="lib/activation.jar"/>
<classpathentry kind="lib" path="lib/commons-math-2.1.jar"/>
<classpathentry kind="lib" path="lib/lucene-core-3.0.1.jar"/>
@@ -246,5 +247,18 @@
<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
</attributes>
</classpathentry>
+ <classpathentry kind="lib" path="lib/exist-fluent.jar"/>
+ <classpathentry kind="lib" path="lib/exist-optional.jar"/>
+ <classpathentry kind="lib" path="lib/exist.jar"/>
+ <classpathentry kind="lib" path="lib/excalibur-cli-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/jgroups-all-2.2.6.jar"/>
+ <classpathentry kind="lib" path="lib/jline-0.9.94.jar"/>
+ <classpathentry kind="lib" path="lib/xmldb.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-client-3.1.2.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-common-3.1.2.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-server-3.1.2.jar"/>
+ <classpathentry kind="lib" path="lib/serializer.jar"/>
+ <classpathentry kind="lib" path="lib/xalan.jar"/>
+ <classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -22,5 +22,6 @@
<wb-resource deploy-path="/" source-path="/.link_to_grails_plugins/jaxrs-0.5-m1/grails-app/conf"/>
<wb-resource deploy-path="/" source-path="/.link_to_grails_plugins/jaxrs-0.5-m1/src/java"/>
<wb-resource deploy-path="/" source-path="/.link_to_grails_plugins/jaxrs-0.5-m1/src/groovy"/>
+ <wb-resource deploy-path="/" source-path="/grails-app/taglib"/>
</wb-module>
</project-modules>
@@ -19,7 +19,6 @@ class ActivityStreamController
// XXX more recent updates waiting
// or something along those lines...
long queueSize = 0;
- // List messages = jmsService.browse(queue: "uitestActivityQueue", "standard", null );
if( session.user != null )
{
// println "checking queueSize for user: ${session.user.userId}";
@@ -47,19 +46,19 @@ class ActivityStreamController
page = "1";
}
println "getContentHtml requested page: ${page}";
- def activities = new ArrayList<Activity>();
+ def events = new ArrayList<EventBase>();
if( user != null )
{
user = userService.findUserByUserId( session.user.userId );
// activities = eventStreamService.getRecentFriendActivitiesForUser( user );
- activities = eventStreamService.getRecentActivitiesForUser( user, 25 * Integer.parseInt( page ) );
+ events = eventStreamService.getRecentActivitiesForUser( user, 25 * Integer.parseInt( page ) );
}
else
{
// don't do anything if we don't have a user
}
- render(template:"/activityStream",model:[activities:activities]);
+ render(template:"/activityStream",model:[activities:events]);
}
@@ -84,17 +83,19 @@ class ActivityStreamController
eventStreamService.saveActivity( activity );
// send notification message
- Map msg = new HashMap();
- msg.creator = activity.owner.userId;
- msg.text = activity.content;
- msg.targetUuid = activity.targetUuid;
+ // Map msg = new HashMap();
+ // msg.creator = activity.owner.userId;
+ // msg.text = activity.content;
+ // msg.targetUuid = activity.targetUuid;
// msg.published = activity.published;
- msg.originTime = activity.dateCreated.time;
+ // msg.originTime = activity.dateCreated.time;
// TODO: figure out what to do with "effectiveDate" here
- msg.effectiveDate = msg.originTime;
+ // msg.effectiveDate = msg.originTime;
+
+ // msg.actualEvent = activity;
println "sending message to JMS";
- jmsService.send( queue: 'uitestActivityQueue', msg, 'standard', null );
+ jmsService.send( queue: 'uitestActivityQueue', /* msg */ activity, 'standard', null );
// println streamEntry.toString();
@@ -74,18 +74,19 @@ class StatusController {
eventStreamService.saveActivity( activity );
- Map msg = new HashMap();
- msg.creator = activity.owner.userId;
- msg.text = newStatus.text;
- msg.targetUuid = activity.targetUuid;
- msg.originTime = activity.dateCreated.time; // NOTE: this will be ever so slightly different from "effectiveDate"
+ // Map msg = new HashMap();
+ // msg.creator = activity.owner.userId;
+ // msg.text = newStatus.text;
+ // msg.targetUuid = activity.targetUuid;
+ // msg.originTime = activity.dateCreated.time; // NOTE: this will be ever so slightly different from "effectiveDate"
// due to the latency in writing to the database. So we need to explicitly
// include the effectiveDate as a field in this message as well
- msg.effectiveDate = activity.effectiveDate.time;
-
+ // msg.effectiveDate = activity.effectiveDate.time;
+ // msg.actualEvent = activity;
+
println "sending message to JMS";
- jmsService.send( queue: 'uitestActivityQueue', msg, 'standard', null );
+ jmsService.send( queue: 'uitestActivityQueue', /* msg */ activity, 'standard', null );
}
@@ -1,6 +1,5 @@
package org.fogbeam.quoddy
-import org.fogbeam.quoddy.EventBase;
/* TODO: map the fields of this class to the activitystrea.ms protocol */
/* SPEC: http://activitystrea.ms/specs/json/1.0/ */
@@ -149,7 +148,7 @@ Following is a simple, minimal example of a JSON serialized activity:
url JSON [RFC4627] String An IRI [RFC3987] identifying a resource providing an HTML representation of the object. An object MAY contain a url property
*/
-class Activity extends EventBase
+class Activity extends EventBase implements Serializable
{
public Activity()
@@ -1,10 +1,8 @@
package org.fogbeam.quoddy
-import org.fogbeam.quoddy.EventBase;
-class CalendarEvent extends EventBase
+class CalendarEvent extends EventBase implements Serializable
{
-
public CalendarEvent()
{
@@ -1,8 +1,7 @@
package org.fogbeam.quoddy
-class EventBase
+public class EventBase implements Serializable
{
-
static mapping =
{
tablePerHierarchy false
@@ -1,11 +1,13 @@
package org.fogbeam.quoddy
-class SubscriptionEvent extends EventBase
+class SubscriptionEvent extends EventBase implements Serializable
{
static constraints = {
}
- static transients = ['templateName'];
+ static transients = ['templateName', 'xmlDoc'];
+
+ transient org.w3c.dom.Node xmlDoc;
// we'll read this from the XML database, using the UUID stored in our DB
// and populate this just-in-time for rendering in the stream.
@@ -15,5 +17,4 @@ class SubscriptionEvent extends EventBase
{
return "/renderSubscriptionEvent";
}
-
}
@@ -19,7 +19,7 @@ class DummyJob
Date now = new Date();
SimpleDateFormat sdf = SimpleDateFormat.getDateTimeInstance();
- println( "TRIGGER: sending rebuild cache message: ${sdf.format( now )}" );
+ // println( "TRIGGER: sending rebuild cache message: ${sdf.format( now )}" );
}
}
@@ -2,7 +2,7 @@ package org.fogbeam.quoddy
import java.util.Set
-import javax.jms.MapMessage
+import javax.jms.Message
class EventQueueService
{
@@ -15,7 +15,7 @@ class EventQueueService
def onMessage(msg)
{
- // println "Message class: ${msg.class}";
+ println "Message class: ${msg.class}";
println "Received message from JMS: ${msg}";
@@ -38,8 +38,8 @@ class EventQueueService
// messages that were to the public stream. We'll come back to deal with
// common group membership and other scenarios later.
def streamPublic = ShareTarget.findByName( ShareTarget.STREAM_PUBLIC);
-
- if( ! msg.getString( 'targetUuid').equals( streamPublic.uuid ))
+ EventBase event = (EventBase)msg.getObject();
+ if( ! event.targetUuid.equals( streamPublic.uuid ))
{
return;
}
@@ -48,14 +48,14 @@ class EventQueueService
// TODO: don't offer message unless the owner of this queue
// and the event creator, are friends (or the owner *is* the creator)
// println "msg creator: ${msg.getString( 'creator')}";
- User msgCreator = userService.findUserByUserId( msg.getString( 'creator') );
+ User msgCreator = userService.findUserByUserId( event.owner.userId );
if( msgCreator )
{
println "found User object for ${msgCreator.userId}";
}
else
{
- println( "No User for ${msg.getString('creator')}");
+ println( "No User for ${event.owner.userId}");
}
FriendCollection friendCollection = FriendCollection.findByOwnerUuid( msgCreator.uuid );
@@ -78,21 +78,21 @@ class EventQueueService
{
println "match found, offering message";
Deque<Map> userQueue = entry.getValue();
- if( msg instanceof MapMessage )
+ if( msg instanceof Message )
{
- println "MapMessage being offered";
+ println "Message being offered";
- Map internalMsg = new HashMap();
+ // Map internalMsg = new HashMap();
// TODO: turn this into a plain old Map
- Enumeration mapNames = msg.getMapNames();
- while( mapNames.hasMoreElements())
- {
- String name = mapNames.nextElement();
- internalMsg.put( name, msg.getObject(name));
- }
+ // Enumeration mapNames = msg.getMapNames();
+ // while( mapNames.hasMoreElements())
+ // {
+ // String name = mapNames.nextElement();
+ // internalMsg.put( name, msg.getObject(name));
+ // }
println "putting message on user queue for user ${key}";
- userQueue.offerFirst( internalMsg );
+ userQueue.offerFirst( event );
}
else
{
@@ -106,7 +106,7 @@ class EventQueueService
public long getQueueSizeForUser( final String userId )
{
- println "getting queue size for user: ${userId}";
+ // println "getting queue size for user: ${userId}";
long queueSize = 0;
Deque<Map> userQueue = eventQueues.get( userId );
@@ -115,23 +115,23 @@ class EventQueueService
queueSize = userQueue.size();
}
- println "Queue size for user: ${userId} = ${queueSize}";
+ // println "Queue size for user: ${userId} = ${queueSize}";
return queueSize;
}
- public List<Map> getMessagesForUser( final String userId, final int msgCount )
+ public List<EventBase> getMessagesForUser( final String userId, final int msgCount )
{
println "getting messages for user: ${userId}, msgCount: ${msgCount}";
- List<Map> messages = new ArrayList<Map>();
+ List<EventBase> messages = new ArrayList<Map>();
Deque<Map> userQueue = eventQueues.get( userId );
if( userQueue != null )
{
println "got userQueue for user ${userId}";
for( int i = 0; i < msgCount; i++ )
{
// get message from queue, put it in return set
- Map msg = userQueue.pollFirst();
+ EventBase msg = userQueue.pollFirst();
messages.add( msg );
}
}
Oops, something went wrong.

0 comments on commit 7667258

Please sign in to comment.