Skip to content

Commit

Permalink
SAK-42082 Remove duplicate grading alerts in bullhorns (#7515)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish committed Nov 4, 2019
1 parent 06cfa87 commit c17058a
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 252 deletions.
Expand Up @@ -1224,14 +1224,18 @@ public void updateSubmission(AssignmentSubmission submission) throws PermissionE
}
} else if (dateReturned != null && submission.getGraded() && (dateSubmitted == null || dateReturned.isAfter(dateSubmitted) || dateSubmitted.isAfter(dateReturned) && submission.getDateModified().isAfter(dateSubmitted))) {
if (submission.getGraded()) {
// Send a non LRS event for other listeners to handle, bullhorns for instance.
Event event = eventTrackingService.newEvent(AssignmentConstants.EVENT_GRADE_ASSIGNMENT_SUBMISSION, reference, null, true, NotificationService.NOTI_NONE, true);
eventTrackingService.post(event);

//TODO: This should use an LRS_Group when that exists rather than firing off individual events for each LRS_Actor KNL-1560
for (AssignmentSubmissionSubmitter submitter : submission.getSubmitters()) {
try {
User user = userDirectoryService.getUser(submitter.getSubmitter());
LRS_Statement statement = getStatementForAssignmentGraded(reference, submission.getAssignment(), submission, user);
// releasing a submitted assignment or releasing grade to an unsubmitted assignment
Event event = eventTrackingService.newEvent(AssignmentConstants.EVENT_GRADE_ASSIGNMENT_SUBMISSION, reference, null, true, NotificationService.NOTI_OPTIONAL, statement);
eventTrackingService.post(event);
LRS_Statement statement = getStatementForAssignmentGraded(reference, submission.getAssignment(), submission, user);
// releasing a submitted assignment or releasing grade to an unsubmitted assignment
Event lrsEvent = eventTrackingService.newEvent(AssignmentConstants.EVENT_GRADE_ASSIGNMENT_SUBMISSION, reference, null, true, NotificationService.NOTI_OPTIONAL, statement);
eventTrackingService.post(lrsEvent);
} catch (UserNotDefinedException e) {
log.warn("Assignments could not find user ({}) while registering Event for LRSS", submitter.getSubmitter());
}
Expand Down
Expand Up @@ -404,5 +404,9 @@ public LRS_Statement getLrsStatement() {
//Don't do anything right now on a rerun
return null;
}

public boolean isTransient() {
return false;
}
}
}
10 changes: 8 additions & 2 deletions kernel/api/src/main/java/org/sakaiproject/event/api/Event.java
Expand Up @@ -60,7 +60,7 @@ public interface Event extends Serializable
* @return The event context
*/
String getContext();

/**
* Access the UsageSession id. If null, check for a User id.
*
Expand Down Expand Up @@ -88,10 +88,16 @@ public interface Event extends Serializable
* @return The event's notification priority.
*/
int getPriority();

/**
* Retrieve the events time
* @return the events time
*/
Date getEventTime();

/**
* If an event is marked as transient, it will not be written to any storage - it will only
* ever exist in memory
*/
boolean isTransient();
}
Expand Up @@ -86,7 +86,7 @@ public interface EventTrackingService
*/
Event newEvent(String event, String resource, String context, boolean modify, int priority);

/**
/**
* Construct a Event object.
*
* @param event
Expand All @@ -105,6 +105,26 @@ public interface EventTrackingService
*/
Event newEvent(String event, String resource, String context, boolean modify, int priority, LRS_Statement lrsStatement);

/**
* Construct a Event object.
*
* @param event
* The Event id.
* @param resource
* The resource reference.
* @param context
* The Event's context (may be null, if null will try to detect 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. Use NotificationService.NOTI_OPTIONAL as default.
* @param isTransient
* Setting this to true means that the event will never be persisted into storage. It will only ever
* exist in memory.
* @return A new Event object that can be used with this service.
*/
Event newEvent(String event, String resource, String context, boolean modify, int priority, boolean isTransient);

/**
* Post an event
*
Expand Down
145 changes: 15 additions & 130 deletions kernel/api/src/main/java/org/sakaiproject/event/api/SimpleEvent.java
Expand Up @@ -23,12 +23,16 @@

import java.util.Date;

import lombok.Getter;
import lombok.Setter;

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

/**
* Allows Event object to be serializable for distribution
* KNL-1184
*/
@Getter @Setter
public class SimpleEvent implements Event {

static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -78,10 +82,10 @@ public SimpleEvent(Event event, String serverId) {
protected String context = null;

/** The Event's session id string. May be null. */
protected String session = null;
protected String sessionId = null;

/** The Event's user id string. May be null. */
protected String user = null;
protected String userId = null;

/** The Event's modify flag (true if the event caused a resource modification). */
protected boolean modify = false;
Expand All @@ -90,11 +94,14 @@ public SimpleEvent(Event event, String serverId) {
protected int priority = NotificationService.NOTI_OPTIONAL;

/** Event creation time. */
protected Date time = null;
protected Date eventTime = null;

/** Event server ID */
protected String serverId = null;

/** Do we store this event? */
protected boolean isTransient = false;

/**
* Access the event id string
*
Expand All @@ -114,15 +121,6 @@ public void setEvent(String id) {
this.id = (id != null) ? id : "";
}

/**
* Access the resource reference.
*
* @return The resource reference string.
*/
public String getResource() {
return resource;
}

/**
* Set the resource id.
*
Expand All @@ -132,14 +130,9 @@ 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;

public boolean getModify() {
return this.modify;
}

/**
Expand All @@ -152,50 +145,14 @@ public void setLRSStatement(LRS_Statement lrsStatement) {
this.lrsStatement = lrsStatement;
}

/**
* Access the resource reference.
*
* @return The resource reference string.
*/
public String getContext() {
return context;
}

/**
* Set the resource reference
*
* @param context resource reference
*/
public void setContext(String context) {
this.context = context;
}

/**
* Access the UsageSession id. If null, check for a User id.
*
* @return The UsageSession id string.
*/
public String getSessionId() {
return session;
}

/**
* Set the session id.
*
* @param id
* The session id string.
*/
public void setSessionId(String id) {
session = ((id != null) && (id.length() > 0)) ? id : null;
}

/**
* Access the User id. If null, check for a session id.
*
* @return The User id string.
*/
public String getUserId() {
return user;
sessionId = ((id != null) && (id.length() > 0)) ? id : null;
}

/**
Expand All @@ -205,79 +162,7 @@ public String getUserId() {
* The user id string.
*/
public void setUserId(String id) {
user = ((id != null) && (id.length() > 0)) ? id : null;
}

/**
* Is this event one that caused a modify to the resource, or just an access.
*
* @return true if the event caused a modify to the resource, false if it was just an access.
*/
public boolean getModify() {
return modify;
}

/**
* Set resource modify or access
*
* @param modify modified event
*/
public void setModify(boolean modify) {
this.modify = modify;
}

/**
* Access the event's notification priority.
*
* @return The event's notification priority.
*/
public int getPriority() {
return priority;
}

/**
* Set the event's notification priority
*
* @param priority level
*/
public void setPriority(int priority) {
this.priority = priority;
}

/**
* Get the server's ID
*
* @return the server ID string
*/
public String getServerId() {
return serverId;
}

/**
* Set the server ID string
*
* @param serverId id string
*/
public void setServerId(String serverId) {
this.serverId = serverId;
}

/**
* Get the event's time
*
* @return the event date
*/
public Date getEventTime() {
return time;
}

/**
* Set the event's date
*
* @param time date event occurred
*/
public void setEventTime(Date time) {
this.time = time;
userId = ((id != null) && (id.length() > 0)) ? id : null;
}

/**
Expand Down

0 comments on commit c17058a

Please sign in to comment.