Skip to content

Commit

Permalink
KNL-1451 - Add support for metadata (or LRS Statements) to events (sa…
Browse files Browse the repository at this point in the history
  • Loading branch information
jonespm authored Aug 11, 2016
1 parent 36daa21 commit 4123be9
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
}


Expand Down Expand Up @@ -143,4 +146,10 @@ public String toString() {
builder.append("]");
return builder.toString();
}

@Override
public LRS_Statement getLrsStatement() {
// TODO Auto-generated method stub
return lrsStatement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.Serializable;
import java.util.Date;

import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Statement;

/**
* <p>
* Event represents a single significant activity by the end-user.
Expand All @@ -45,6 +47,13 @@ public interface Event extends Serializable
*/
String getResource();

/**
* Access the LRSStatement.
*
* @return The LRSStatement.
*/
LRS_Statement getLrsStatement();

/**
* Access the event context
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand All @@ -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;

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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
*
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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
*
Expand All @@ -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;

Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
*/
Expand Down
Loading

0 comments on commit 4123be9

Please sign in to comment.