diff --git a/content/content-impl-providers/impl/src/java/org/sakaiproject/content/providers/BaseEventDelayHandler.java b/content/content-impl-providers/impl/src/java/org/sakaiproject/content/providers/BaseEventDelayHandler.java index c35d239c3965..4c6d611241c7 100644 --- a/content/content-impl-providers/impl/src/java/org/sakaiproject/content/providers/BaseEventDelayHandler.java +++ b/content/content-impl-providers/impl/src/java/org/sakaiproject/content/providers/BaseEventDelayHandler.java @@ -19,6 +19,7 @@ import org.sakaiproject.event.api.Event; import org.sakaiproject.event.api.EventDelayHandler; import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.time.api.Time; import org.sakaiproject.user.api.User; import org.sakaiproject.user.api.UserDirectoryService; @@ -391,5 +392,11 @@ public String getContext() public Date getEventTime() { return null; } + + @Override + public LRS_Statement getLrsStatement() { + //Don't do anything right now on a rerun + return null; + } } } diff --git a/dashboard/impl/src/java/org/sakaiproject/dash/jobs/DashAggregateJob.java b/dashboard/impl/src/java/org/sakaiproject/dash/jobs/DashAggregateJob.java index e6ad3511e7f8..5e08fb81b431 100644 --- a/dashboard/impl/src/java/org/sakaiproject/dash/jobs/DashAggregateJob.java +++ b/dashboard/impl/src/java/org/sakaiproject/dash/jobs/DashAggregateJob.java @@ -357,7 +357,7 @@ private String startJob() throws SQLException { sessionId = rs.getString("SESSION_ID"); if(isEventContextSupported) context = rs.getString("CONTEXT"); - EventCopy eventcopy = new EventCopy(date,event,ref,context,sessionUser,sessionId, ' ',0); + EventCopy eventcopy = new EventCopy(date,event,ref,context,sessionUser,sessionId, ' ',0, null); eventsQueue.add(eventcopy); counter++; @@ -530,7 +530,7 @@ public long collectPastSiteEvents(String siteId, Date initialDate, Date finalDat sessionUser = rs.getString("SESSION_USER"); sessionId = rs.getString("SESSION_ID"); context = rs.getString("CONTEXT"); - EventCopy eventcopy = new EventCopy(date,event,ref,context,sessionUser,sessionId, ' ',0); + EventCopy eventcopy = new EventCopy(date,event,ref,context,sessionUser,sessionId, ' ',0, null); eventsQueue.add( eventcopy ); counter++; }catch(Exception e){ diff --git a/dashboard/impl/src/java/org/sakaiproject/dash/logic/EventCopy.java b/dashboard/impl/src/java/org/sakaiproject/dash/logic/EventCopy.java index e4a50acb294d..b1830c4d284a 100644 --- a/dashboard/impl/src/java/org/sakaiproject/dash/logic/EventCopy.java +++ b/dashboard/impl/src/java/org/sakaiproject/dash/logic/EventCopy.java @@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory; import org.sakaiproject.dash.app.SakaiProxy; import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; /************************************************************************ * Making copies of events @@ -31,12 +32,13 @@ public void setSakaiProxy(SakaiProxy proxy) { protected String entityReference; protected String sessionId; protected String userId; + protected LRS_Statement lrsStatement; public EventCopy() { super(); } - public EventCopy(Date eventTime, String eventIdentifier, String entityReference, String context, String userId, String sessionId, char eventCode, int priority) { + public EventCopy(Date eventTime, String eventIdentifier, String entityReference, String context, String userId, String sessionId, char eventCode, int priority, LRS_Statement lrsStatement) { super(); this.eventTime= eventTime; this.eventIdentifier = eventIdentifier; @@ -45,6 +47,7 @@ public EventCopy(Date eventTime, String eventIdentifier, String entityReference, this.userId = userId; this.sessionId = sessionId; this.modify = ('m' == eventCode); + this.lrsStatement = lrsStatement; } @@ -143,4 +146,10 @@ public String toString() { builder.append("]"); return builder.toString(); } + + @Override + public LRS_Statement getLrsStatement() { + // TODO Auto-generated method stub + return lrsStatement; + } } diff --git a/kernel/api/src/main/java/org/sakaiproject/event/api/Event.java b/kernel/api/src/main/java/org/sakaiproject/event/api/Event.java index e2e5b6a2e8b1..bf8c5d38aa63 100644 --- a/kernel/api/src/main/java/org/sakaiproject/event/api/Event.java +++ b/kernel/api/src/main/java/org/sakaiproject/event/api/Event.java @@ -24,6 +24,8 @@ import java.io.Serializable; import java.util.Date; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; + /** *
* Event represents a single significant activity by the end-user. @@ -45,6 +47,13 @@ public interface Event extends Serializable */ String getResource(); + /** + * Access the LRSStatement. + * + * @return The LRSStatement. + */ + LRS_Statement getLrsStatement(); + /** * Access the event context * diff --git a/kernel/api/src/main/java/org/sakaiproject/event/api/EventTrackingService.java b/kernel/api/src/main/java/org/sakaiproject/event/api/EventTrackingService.java index 3de114f11eab..ce015a4af9ad 100644 --- a/kernel/api/src/main/java/org/sakaiproject/event/api/EventTrackingService.java +++ b/kernel/api/src/main/java/org/sakaiproject/event/api/EventTrackingService.java @@ -23,6 +23,7 @@ import java.util.Observer; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.time.api.Time; import org.sakaiproject.user.api.User; @@ -84,6 +85,25 @@ public interface EventTrackingService */ Event newEvent(String event, String resource, String context, boolean modify, int priority); +/** + * Construct a Event object. + * + * @param event + * The Event id. + * @param resource + * The resource reference. + * @param context + * The Event's context (may be null). + * @param modify + * Set to true if this event caused a resource modification, false if it was just an access. + * @param priority + * The Event's notification priority. Use NotificationService.NOTI_OPTIONAL as default. + * @param lrsStatement + * Additional, optional (currently unpersisted) lrsStatement passed to LRS service (null is the default) + * @return A new Event object that can be used with this service. + */ + Event newEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement); + /** * Post an event * diff --git a/kernel/api/src/main/java/org/sakaiproject/event/api/SimpleEvent.java b/kernel/api/src/main/java/org/sakaiproject/event/api/SimpleEvent.java index 4699f147a1e9..532718a65e4a 100644 --- a/kernel/api/src/main/java/org/sakaiproject/event/api/SimpleEvent.java +++ b/kernel/api/src/main/java/org/sakaiproject/event/api/SimpleEvent.java @@ -23,6 +23,8 @@ import java.util.Date; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; + /** * Allows Event object to be serializable for distribution * KNL-1184 @@ -57,6 +59,7 @@ public SimpleEvent(Event event, String serverId) { setPriority(event.getPriority()); setEventTime(event.getEventTime()); setServerId(serverId); + setLRSStatement(event.getLrsStatement()); } /** The Event's sequence number. */ @@ -68,6 +71,9 @@ public SimpleEvent(Event event, String serverId) { /** The Event's resource reference string. */ protected String resource = ""; + /** The Event's lrs statement */ + protected LRS_Statement lrsStatement = null; + /** The Event's context. May be null. */ protected String context = null; @@ -126,6 +132,25 @@ public String getResource() { public void setResource(String id) { resource = (id != null) ? id : ""; } + + /** + * Access the resource metadata. + * + * @return The resource metadata string. + */ + public LRS_Statement getLrsStatement() { + return lrsStatement; + } + + /** + * Set the resource lrsStatement. + * + * @param id + * The resource LRS Statement. + */ + public void setLRSStatement(LRS_Statement lrsStatement) { + this.lrsStatement = lrsStatement; + } /** * Access the resource reference. diff --git a/kernel/kernel-impl/src/main/java/org/sakaiproject/event/impl/BaseEventTrackingService.java b/kernel/kernel-impl/src/main/java/org/sakaiproject/event/impl/BaseEventTrackingService.java index 050b1941373c..39246160105a 100644 --- a/kernel/kernel-impl/src/main/java/org/sakaiproject/event/impl/BaseEventTrackingService.java +++ b/kernel/kernel-impl/src/main/java/org/sakaiproject/event/impl/BaseEventTrackingService.java @@ -27,7 +27,13 @@ import org.sakaiproject.authz.api.SecurityService; import org.sakaiproject.entity.api.EntityManager; import org.sakaiproject.entity.api.Reference; -import org.sakaiproject.event.api.*; +import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.EventDelayHandler; +import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; +import org.sakaiproject.event.api.NotificationService; +import org.sakaiproject.event.api.UsageSession; +import org.sakaiproject.event.api.UsageSessionService; import org.sakaiproject.time.api.Time; import org.sakaiproject.time.api.TimeService; import org.sakaiproject.tool.api.Placement; @@ -187,7 +193,7 @@ public void setEventDelayHandler(EventDelayHandler handler) */ public Event newEvent(String event, String resource, boolean modify) { - return new BaseEvent(event, resource, modify, NotificationService.NOTI_OPTIONAL); + return new BaseEvent(event, resource, modify, NotificationService.NOTI_OPTIONAL, null); } /** @@ -205,7 +211,7 @@ public Event newEvent(String event, String resource, boolean modify) */ public Event newEvent(String event, String resource, boolean modify, int priority) { - return new BaseEvent(event, resource, modify, priority); + return new BaseEvent(event, resource, modify, priority, null); } /** @@ -225,9 +231,30 @@ public Event newEvent(String event, String resource, boolean modify, int priorit */ public Event newEvent(String event, String resource, String context, boolean modify, int priority) { - return new BaseEvent(event, resource, context, modify, priority); + return new BaseEvent(event, resource, context, modify, priority, null); } + /** + * Construct a Event object. + * + * @param event + * The Event id. + * @param resource + * The resource reference. + * @param context + * The Event's context. + * @param modify + * Set to true if this event caused a resource modification, false if it was just an access. + * @param priority + * The Event's notification priority. + * @return A new Event object that can be used with this service. + */ + public Event newEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement) + { + return new BaseEvent(event, resource, context, modify, priority, lrsStatement); + } + + /** * Post an event * @@ -377,7 +404,7 @@ protected BaseEvent ensureBaseEvent(Event e) } else { - event = new BaseEvent(e.getEvent(), e.getResource(), e.getModify(), e.getPriority()); + event = new BaseEvent(e.getEvent(), e.getResource(), e.getModify(), e.getPriority(),null); event.setSessionId(e.getSessionId()); event.setUserId(e.getUserId()); } @@ -522,6 +549,9 @@ protected class BaseEvent implements Event /** Event creation time. */ protected Date m_time = null; + /** Event LRS Statement */ + protected LRS_Statement m_lrsStatement = null; + /** * Construct * @@ -534,10 +564,11 @@ protected class BaseEvent implements Event * @param priority * The Event's notification priority. */ - public BaseEvent(String event, String resource, boolean modify, int priority) + public BaseEvent(String event, String resource, boolean modify, int priority, LRS_Statement lrsStatement) { setEvent(event); setResource(resource); + m_lrsStatement = lrsStatement; m_modify = modify; m_priority = priority; @@ -582,23 +613,32 @@ public BaseEvent(String event, String resource, boolean modify, int priority) * @param priority * The Event's notification priority. */ - public BaseEvent(String event, String resource, String context, boolean modify, int priority) + public BaseEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement) { - setEvent(event); - setResource(resource); - m_modify = modify; - m_priority = priority; + this(event, resource, modify, priority, lrsStatement); m_context = context; - - // KNL-997 - String uId = sessionManager().getCurrentSessionUserId(); - if (uId == null) - { - uId = "?"; - } - setUserId(uId); + } + + /** + * Construct + * + * @param seq + * The event sequence number. + * @param event + * The Event id. + * @param resource + * The resource id. + * @param modify + * If the event caused a modify, true, if it was just an access, false. + * @param priority + * The Event's notification priority. + */ + public BaseEvent(String event, String resource, String context, boolean modify, int priority) + { + this(event, resource, context, modify, priority, null); } + /** * Construct * @@ -692,7 +732,17 @@ public String getContext() { return m_context; } - + + /** + * Access the resource metadata. + * + * @return The resource metadata string. + */ + public LRS_Statement getLrsStatement() + { + return m_lrsStatement; + } + /** * Access the UsageSession id. If null, check for a User id. * diff --git a/kernel/kernel-impl/src/test/java/org/sakai/memory/impl/test/MockEventTrackingService.java b/kernel/kernel-impl/src/test/java/org/sakai/memory/impl/test/MockEventTrackingService.java index e1f278fc426f..45010edab74e 100644 --- a/kernel/kernel-impl/src/test/java/org/sakai/memory/impl/test/MockEventTrackingService.java +++ b/kernel/kernel-impl/src/test/java/org/sakai/memory/impl/test/MockEventTrackingService.java @@ -26,6 +26,7 @@ import org.sakaiproject.event.api.Event; import org.sakaiproject.event.api.EventDelayHandler; import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.event.api.UsageSession; import org.sakaiproject.time.api.Time; import org.sakaiproject.user.api.User; @@ -100,6 +101,16 @@ public Event newEvent(String event, String resource, String context, boolean mod return null; } + /* (non-Javadoc) + * @see org.sakaiproject.event.api.EventTrackingService#newEvent(java.lang.String, java.lang.String, java.lang.String, boolean, int, LRS_Statement) + */ + public Event newEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement) + { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) * @see org.sakaiproject.event.api.EventTrackingService#post(org.sakaiproject.event.api.Event) */ diff --git a/kernel/kernel-impl/src/test/java/org/sakaiproject/conditions/impl/TestConditionService.java b/kernel/kernel-impl/src/test/java/org/sakaiproject/conditions/impl/TestConditionService.java index 1d4d7f8460f1..f543e3f9fd59 100644 --- a/kernel/kernel-impl/src/test/java/org/sakaiproject/conditions/impl/TestConditionService.java +++ b/kernel/kernel-impl/src/test/java/org/sakaiproject/conditions/impl/TestConditionService.java @@ -12,6 +12,7 @@ import org.sakaiproject.conditions.api.ConditionService; import org.sakaiproject.conditions.api.Rule; import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; public class TestConditionService { @@ -69,6 +70,10 @@ public int getPriority() { public String getResource() { return "69"; } + + public LRS_Statement getLrsStatement() { + return null; + } public String getSessionId() { // TODO Auto-generated method stub @@ -113,6 +118,10 @@ public int getPriority() { public String getResource() { return "zt10"; } + + public LRS_Statement getLrsStatement() { + return null; + } public String getSessionId() { // TODO Auto-generated method stub diff --git a/sitestats/sitestats-impl/src/java/org/sakaiproject/sitestats/impl/CustomEventImpl.java b/sitestats/sitestats-impl/src/java/org/sakaiproject/sitestats/impl/CustomEventImpl.java index 8f2c2124775e..bf66f6765fe6 100644 --- a/sitestats/sitestats-impl/src/java/org/sakaiproject/sitestats/impl/CustomEventImpl.java +++ b/sitestats/sitestats-impl/src/java/org/sakaiproject/sitestats/impl/CustomEventImpl.java @@ -22,6 +22,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; public class CustomEventImpl implements Event { @@ -32,6 +33,7 @@ public class CustomEventImpl implements Event { private String sessionUser; private String sessionId; private boolean modify; + private LRS_Statement lrsStatement; public CustomEventImpl(Date date, String event, String ref, String sessionUser, String sessionId) { this(date, event, ref, null, sessionUser, sessionId, 'm'); @@ -42,6 +44,9 @@ public CustomEventImpl(Date date, String event, String ref, String context, Stri } public CustomEventImpl(Date date, String event, String ref, String context, String sessionUser, String sessionId, char eventCode) { + this(date, event, ref, context, sessionUser, sessionId, 'm',null); + } + public CustomEventImpl(Date date, String event, String ref, String context, String sessionUser, String sessionId, char eventCode, LRS_Statement lrsStatement) { this.date = date; this.event = event; this.ref = ref; @@ -49,6 +54,7 @@ public CustomEventImpl(Date date, String event, String ref, String context, Stri this.sessionUser = sessionUser; this.sessionId = sessionId; this.modify = ('m' == eventCode); + this.lrsStatement = lrsStatement; } public Date getDate() { @@ -98,4 +104,10 @@ public String toString(){ append("modify", modify). toString(); } + + @Override + public LRS_Statement getLrsStatement() { + // TODO Auto-generated method stub + return null; + } } diff --git a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEvent.java b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEvent.java index 4c5b71104df6..a45b47997c58 100644 --- a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEvent.java +++ b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEvent.java @@ -25,6 +25,7 @@ import java.util.Date; import org.sakaiproject.event.api.Event; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.sitestats.test.data.FakeData; /** @@ -43,25 +44,30 @@ public class FakeEvent implements Event { private String context = null; private boolean modify = true; private int priority = 3; + private LRS_Statement lrsStatement = null; public FakeEvent() { } public FakeEvent(String event, String resource, boolean modify) { - this(event, resource, FakeData.SITE_A_ID, modify, 3); + this(event, resource, FakeData.SITE_A_ID, modify, 3, null); } public FakeEvent(String event, String resource, boolean modify, int priority) { - this(event, resource, FakeData.SITE_A_ID, modify, priority); + this(event, resource, FakeData.SITE_A_ID, modify, priority, null); } public FakeEvent(String event, String resource, String context, boolean modify, int priority) { + this(event, resource, context, modify, priority, null); + } + public FakeEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement) { super(); this.event = event; this.modify = modify; this.priority = priority; this.resource = resource; this.context = context; + this.lrsStatement = lrsStatement; } /* @@ -132,4 +138,10 @@ public Date getEventTime() { return null; } +@Override +public LRS_Statement getLrsStatement() { + // TODO Auto-generated method stub + return null; +} + } diff --git a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEventTrackingService.java b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEventTrackingService.java index 37955cea9dd8..7f3e5a476066 100644 --- a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEventTrackingService.java +++ b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/mocks/FakeEventTrackingService.java @@ -26,6 +26,7 @@ import org.sakaiproject.event.api.Event; import org.sakaiproject.event.api.EventDelayHandler; import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.event.api.UsageSession; import org.sakaiproject.time.api.Time; import org.sakaiproject.user.api.User; @@ -67,6 +68,11 @@ public Event newEvent(String event, String resource, String context, boolean mod return new FakeEvent(event, resource, context, modify, priority); } + public Event newEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement) { + return new FakeEvent(event, resource, context, modify, priority, lrsStatement); + } + + public void post(Event e) { for(Observer o : observers) { o.update(this, e); @@ -82,5 +88,4 @@ public void post(Event e, User arg1) { } public void setEventDelayHandler(EventDelayHandler arg0) {} - } diff --git a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/perf/mock/MockEventTrackingService.java b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/perf/mock/MockEventTrackingService.java index edd94e20f161..83f7a783d361 100644 --- a/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/perf/mock/MockEventTrackingService.java +++ b/sitestats/sitestats-impl/src/test/org/sakaiproject/sitestats/test/perf/mock/MockEventTrackingService.java @@ -5,6 +5,7 @@ import org.sakaiproject.event.api.Event; import org.sakaiproject.event.api.EventDelayHandler; import org.sakaiproject.event.api.EventTrackingService; +import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement; import org.sakaiproject.event.api.UsageSession; import org.sakaiproject.time.api.Time; import org.sakaiproject.user.api.User; @@ -97,4 +98,11 @@ public void cancelDelays(String resource, String event) { } + @Override + public Event newEvent(String event, String resource, String context, boolean modify, int priority, + LRS_Statement lrsStatement) { + // TODO Auto-generated method stub + return null; + } + }