Skip to content

Commit

Permalink
SAK-45601: Modify "ifs" processing for XAPI events and pool usage ins…
Browse files Browse the repository at this point in the history
…tead of threads (sakaiproject#9353)

* SAK-45601: Modify "ifs" processing for XAPI events and pool usage
instead of threads

* SAK-45601: Included Test JUnit
  • Loading branch information
victorGomollon authored Jul 15, 2021
1 parent 0d606e9 commit 6b643f7
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,9 @@
# Default: No filters (all statements processed)
# lrs.origins.filter=tool1,tool2,tool3

# Number max of thread
# Default: 10
# lrs.max.threadPool=10

# ########################################################################
# TOOLS (tool specific settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.Map;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.context.event.ContextStartedEvent;
import lombok.Getter;

/**
* Provides support for Sakai to work with Learning Record Stores (LRS)
Expand Down Expand Up @@ -100,6 +102,10 @@ public interface LearningResourceStoreService {
*/
public LRS_Actor getEventActor(Event event);

public void onApplicationEvent(ContextStartedEvent event);

public void getXAPIEvent();

// Service CLASSes

public static class LRS_Statement {
Expand Down Expand Up @@ -1234,4 +1240,18 @@ public String toString() {
}
}

public class EventWrapper {
@Getter private String verb;
@Getter private String object;
@Getter private String origin;
@Getter private String type;

public EventWrapper(String verb, String object, String origin, String type) {
this.verb = verb;
this.object = object;
this.origin = origin;
this.type = type;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.sakaiproject.event.api;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import lombok.Data;

@Entity
@Table( name = "TINCANAPI_EVENT")
@NamedQuery( name = "getAllTincanapiEvent",
query = "from TincanapiEvent")

@Data
public class TincanapiEvent {

@Id
@Column(name = "EVENT")
private String event;

@Column(name = "VERB", length = 255, nullable = false)
private String verb;

@Column(name = "ORIGIN", length = 255, nullable = false)
private String origin;

@Column(name = "OBJECT", length = 255, nullable = false)
private String object;

@Column(name = "EVENT_SUPPLIER", length = 255)
private String eventSupplier;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.sakaiproject.event.api;

import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.event.api.LearningResourceStoreService.EventWrapper;
import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Object;
import org.sakaiproject.event.api.LearningResourceStoreService.LRS_Verb;

public class XAPIFactory{
public LRS_Verb getEventVerb(Event event, Map<String, EventWrapper> xAPIEvent) {
LRS_Verb verb = null;
if (event != null) {
String e = StringUtils.lowerCase(event.getEvent());
if (xAPIEvent.containsKey(e)) {
verb = new LRS_Verb(xAPIEvent.get(e).getVerb());
}
}
return verb;
}

public LRS_Object getEventObject(Event event, Map<String, EventWrapper> xAPIEvent, String url) {
LRS_Object object = null;
if (event != null) {
String e = StringUtils.lowerCase(event.getEvent());
/*
* NOTE: use the following terms "view", "add", "edit", "delete"
*/

if (xAPIEvent.containsKey(e)) {
object = new LRS_Object (/*serverConfigurationService.getPortalUrl()*/url + event.getResource(), xAPIEvent.get(e).getObject());
}
}
return object;
}

public String getEventOrigin(Event event, Map<String, EventWrapper> xAPIEvent) {
String origin = null;
if (event != null) {
String e = StringUtils.lowerCase(event.getEvent());

if (xAPIEvent.containsKey(e)) {
origin = xAPIEvent.get(e).getOrigin();
} else {
origin = e;
}
}
return origin;
}
}
8 changes: 8 additions & 0 deletions kernel/kernel-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
</executions>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>${basedir}/src/main/webapp</directory>
</testResource>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
Expand Down
Loading

0 comments on commit 6b643f7

Please sign in to comment.