Skip to content

Commit

Permalink
LSNBLDR-784 Moved all event literals into single class (sakaiproject#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Feb 28, 2017
1 parent 83f4066 commit 5e81f59
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.sakaiproject.lessonbuildertool.api;

public class LessonBuilderEvents {

public static final String CREATE = "lessonbuilder.create";
public static final String UPDATE = "lessonbuilder.update";
public static final String DELETE = "lessonbuilder.delete";
public static final String REMOVE = "lessonbuilder.remove";
public static final String READ = "lessonbuilder.read";
}

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.sakaiproject.db.api.SqlReader;
import org.sakaiproject.db.api.SqlService;
import org.sakaiproject.event.cover.EventTrackingService;
import org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents;
import org.sakaiproject.lessonbuildertool.ChecklistItemStatus;
import org.sakaiproject.lessonbuildertool.SimpleChecklistItem;
import org.sakaiproject.lessonbuildertool.SimpleChecklistItemImpl;
Expand Down Expand Up @@ -649,13 +650,13 @@ public boolean saveItem(Object o, List<String>elist, String nowriteerr, boolean

if (o instanceof SimplePageItem) {
SimplePageItem item = (SimplePageItem)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.create", "/lessonbuilder/item/" + item.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.CREATE, "/lessonbuilder/item/" + item.getId(), true));
} else if (o instanceof SimplePage) {
SimplePage page = (SimplePage)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.create", "/lessonbuilder/page/" + page.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.CREATE, "/lessonbuilder/page/" + page.getPageId(), true));
} else if (o instanceof SimplePageComment) {
SimplePageComment comment = (SimplePageComment)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.create", "/lessonbuilder/comment/" + comment.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.CREATE, "/lessonbuilder/comment/" + comment.getId(), true));
}

if(o instanceof SimplePageItem || o instanceof SimplePage) {
Expand Down Expand Up @@ -698,11 +699,11 @@ public boolean saveOrUpdate(Object o, List<String>elist, String nowriteerr, bool

if (o instanceof SimplePageItem) {
SimplePageItem i = (SimplePageItem)o;
String eventType = (i.getId() == 0 ? "lessonbuilder.create" : "lessonbuilder.update");
String eventType = (i.getId() == 0 ? LessonBuilderEvents.CREATE : LessonBuilderEvents.UPDATE);
EventTrackingService.post(EventTrackingService.newEvent(eventType, "/lessonbuilder/item/" + i.getId(), true));
} else if (o instanceof SimplePage) {
SimplePage i = (SimplePage)o;
String eventType = (i.getPageId() == 0 ? "lessonbuilder.create" : "lessonbuilder.update");
String eventType = (i.getPageId() == 0 ? LessonBuilderEvents.CREATE : LessonBuilderEvents.UPDATE);
EventTrackingService.post(EventTrackingService.newEvent(eventType, "/lessonbuilder/page/" + i.getPageId(), true));
}

Expand Down Expand Up @@ -751,13 +752,13 @@ public boolean deleteItem(Object o) {

if (o instanceof SimplePageItem) {
SimplePageItem i = (SimplePageItem)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/item/" + i.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.DELETE, "/lessonbuilder/item/" + i.getId(), true));
} else if (o instanceof SimplePage) {
SimplePage i = (SimplePage)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/page/" + i.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.DELETE, "/lessonbuilder/page/" + i.getPageId(), true));
} else if(o instanceof SimplePageComment) {
SimplePageComment i = (SimplePageComment) o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/comment/" + i.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.DELETE, "/lessonbuilder/comment/" + i.getId(), true));
}

try {
Expand Down Expand Up @@ -821,13 +822,13 @@ public boolean update(Object o, List<String>elist, String nowriteerr, boolean re

if (o instanceof SimplePageItem) {
SimplePageItem item = (SimplePageItem)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.update", "/lessonbuilder/item/" + item.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.UPDATE, "/lessonbuilder/item/" + item.getId(), true));
} else if (o instanceof SimplePage) {
SimplePage page = (SimplePage)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.update", "/lessonbuilder/page/" + page.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.UPDATE, "/lessonbuilder/page/" + page.getPageId(), true));
} else if (o instanceof SimplePageComment) {
SimplePageComment comment = (SimplePageComment)o;
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.update", "/lessonbuilder/comment/" + comment.getId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.UPDATE, "/lessonbuilder/comment/" + comment.getId(), true));
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.exception.ServerOverloadException;
import org.sakaiproject.exception.TypeException;
import org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents;
import org.sakaiproject.lessonbuildertool.LessonBuilderAccessAPI;
import org.sakaiproject.lessonbuildertool.SimplePageItem;
import org.sakaiproject.lessonbuildertool.SimplePageLogEntry;
Expand Down Expand Up @@ -590,7 +591,7 @@ public void handleAccess(HttpServletRequest req, HttpServletResponse res, Refere
// https://heidelberg.rutgers.edu/access/citation/content/group/24da8519-08c2-4c8c-baeb-8abdfd6c69d7/New%20Citation%20List

if (item.getAttribute("multimediaUrl") != null) {
eventTrackingService.post(eventTrackingService.newEvent("lessonbuilder.read", "/lessonbuilder/item/" + item.getId(), false));
eventTrackingService.post(eventTrackingService.newEvent(LessonBuilderEvents.READ, "/lessonbuilder/item/" + item.getId(), false));
res.sendRedirect(item.getAttribute("multimediaUrl"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import org.sakaiproject.entitybroker.entityprovider.capabilities.Createable;

import org.sakaiproject.entitybroker.util.AbstractEntityProvider;
import org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents;
import org.sakaiproject.lessonbuildertool.LessonBuilderAccessAPI;
import org.sakaiproject.lessonbuildertool.ToolApi;
import org.sakaiproject.lessonbuildertool.SimplePage;
Expand Down Expand Up @@ -1706,7 +1707,7 @@ public String getAssociatedToolId() {
}

public final static String[] EVENT_KEYS=
new String[] {"lessonbuilder.create", "lessonbuilder.delete", "lessonbuilder.update", "lessonbuilder.read"};
new String[] {LessonBuilderEvents.CREATE, LessonBuilderEvents.DELETE, LessonBuilderEvents.UPDATE, LessonBuilderEvents.READ};

/**
* Return an array of all the event keys which should be tracked for statistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
//import uk.ac.cam.caret.sakai.rwiki.service.api.model.RWikiObject;
//import uk.ac.cam.caret.sakai.rwiki.utils.NameHelper;

import org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents;
import org.sakaiproject.lessonbuildertool.SimplePage;
import org.sakaiproject.lessonbuildertool.LessonBuilderAccessAPI;
import org.sakaiproject.lessonbuildertool.SimplePageItem;
Expand Down Expand Up @@ -134,9 +135,9 @@ public void init()
"search.enable", "false")))
{

searchService.registerFunction("lessonbuilder.create");
searchService.registerFunction("lessonbuilder.update");
searchService.registerFunction("lessonbuilder.delete");
searchService.registerFunction(LessonBuilderEvents.CREATE);
searchService.registerFunction(LessonBuilderEvents.UPDATE);
searchService.registerFunction(LessonBuilderEvents.DELETE);
searchIndexBuilder.registerEntityContentProducer(this);
}
}
Expand Down Expand Up @@ -220,12 +221,12 @@ public boolean matches(String reference)
public Integer getAction(Event event)
{
String eventName = event.getEvent();
if ("lessonbuilder.create".equals(eventName)
|| "lessonbuilder.update".equals(eventName))
if (LessonBuilderEvents.CREATE.equals(eventName)
|| LessonBuilderEvents.UPDATE.equals(eventName))
{
return SearchBuilderItem.ACTION_ADD;
}
if ("lessonbuilder.delete".equals(eventName))
if (LessonBuilderEvents.DELETE.equals(eventName))
{
return SearchBuilderItem.ACTION_DELETE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.exception.TypeException;
import org.sakaiproject.id.cover.IdManager;
import org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents;
import org.sakaiproject.lessonbuildertool.*;
import org.sakaiproject.lessonbuildertool.cc.CartridgeLoader;
import org.sakaiproject.lessonbuildertool.cc.Parser;
Expand Down Expand Up @@ -4778,15 +4779,15 @@ public void track(long itemId, String path, Long studentPageId) {
entry.setPath(path);
entry.setToolId(toolId);
SimplePageItem item = findItem(itemId);
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.read", "/lessonbuilder/item/" + item.getId(), complete));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.READ, "/lessonbuilder/item/" + item.getId(), complete));
trackComplete(item, complete);
studentPageId = -1L;
}else if(path != null) {
entry.setPath(path);
entry.setComplete(true);
entry.setToolId(toolId);
SimplePage page = getPage(studentPageId);
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.read", "/lessonbuilder/page/" + page.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.READ, "/lessonbuilder/page/" + page.getPageId(), true));
}

saveItem(entry);
Expand All @@ -4800,7 +4801,7 @@ public void track(long itemId, String path, Long studentPageId) {
entry.setToolId(toolId);
entry.setDummy(false);
SimplePageItem item = findItem(itemId);
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.read", "/lessonbuilder/item/" + item.getId(), complete));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.READ, "/lessonbuilder/item/" + item.getId(), complete));
if (complete != wasComplete)
trackComplete(item, complete);
studentPageId = -1L;
Expand All @@ -4810,7 +4811,7 @@ public void track(long itemId, String path, Long studentPageId) {
entry.setToolId(toolId);
entry.setDummy(false);
SimplePage page = getPage(studentPageId);
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.read", "/lessonbuilder/page/" + page.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.READ, "/lessonbuilder/page/" + page.getPageId(), true));
}

update(entry);
Expand Down
3 changes: 2 additions & 1 deletion lessonbuilder/tool/src/webapp/removePage.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
%><%@ page import="org.sakaiproject.component.cover.ComponentManager" %><%
%><%@ page import="org.sakaiproject.lessonbuildertool.model.SimplePageToolDao" %><%
%><%@ page import="org.sakaiproject.event.cover.EventTrackingService" %><%
%><%@ page import="org.sakaiproject.lessonbuildertool.api.LessonBuilderEvents" %><%
%><%@ page import="org.sakaiproject.lessonbuildertool.SimplePage" %><%
%><%@ page import="org.apache.commons.lang.StringEscapeUtils" %>

Expand Down Expand Up @@ -97,7 +98,7 @@
out.println(StringEscapeUtils.escapeHtml("removePage unable to save site " + e));
}
EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.remove", "/lessonbuilder/page/" + simplePage.getPageId(), true));
EventTrackingService.post(EventTrackingService.newEvent(LessonBuilderEvents.REMOVE, "/lessonbuilder/page/" + simplePage.getPageId(), true));
out.println("<script>parent.location.replace(\"/portal/site/" + URLEncoder.encode(site.getId(), "UTF-8") + "\")</script>");
Expand Down

0 comments on commit 5e81f59

Please sign in to comment.