Skip to content

Commit

Permalink
more packaging, docs, gpg, source
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffcaseyyet committed Nov 27, 2024
1 parent ced03ae commit 85241a2
Show file tree
Hide file tree
Showing 35 changed files with 286 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ jobs:
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy Documentation
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: target/apidocs

66 changes: 63 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,46 @@
<packaging>jar</packaging>
<version>0.0.1</version>
<name>xAPI Tools</name>
<description>xAPI Serialization Model and Tools for Java</description>
<description>Java Serialization Model and Tools for xAPI Standard (IEEE 9274.1.1)</description>
<url>https://github.com/yetanalytics/java-xapi-tools</url>
<scm>
<url>https://github.com/yetanalytics/java-xapi-tools</url>
<connection>scm:git:https://github.com/yetanalytics/java-xapi-tools.git</connection>
<developerConnection>scm:git:https://github.com/yetanalytics/java-xapi-tools.git</developerConnection>
</scm>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<organization>Yet Analytics Inc.</organization>
<organizationUrl>https://www.yetanalytics.com</organizationUrl>
<name>Cliff Casey</name>
<email>[email protected]</email>
<url>https://github.com/cliffcaseyyet</url>
</developer>
</developers>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jackson.version>2.18.1</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.18.1</version>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.18.1</version>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
Expand Down Expand Up @@ -68,6 +83,51 @@
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.7</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>install</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/AbstractActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yetanalytics.xapi.model.deserializers.AbstractActorDeserializer;

/**
* Abstract Class for serialization and deserialization of xAPI Actors
*/
@JsonDeserialize(using = AbstractActorDeserializer.class)
public abstract class AbstractActor extends AbstractObject {

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/AbstractObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yetanalytics.xapi.model.deserializers.AbstractObjectDeserializer;

/**
* Abstract Class for serialization and deserialization of xAPI Objects
*/
@JsonDeserialize(using = AbstractObjectDeserializer.class)
public class AbstractObject {

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Account Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2424-account-object">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class Account {

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Activity Object Type of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2441-when-the-objecttype-is-activity">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
@JsonDeserialize
public class Activity extends AbstractObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Activity Definition Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#activity-definition">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class ActivityDefinition {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* A concrete class representation of the Agent Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2421-when-the-actor-objecttype-is-agent">9274.1.1 xAPI Specification</a>.
* This class has no fields because it only contains what it inherits from AbstractActor.
*/
@JsonInclude(Include.NON_NULL)
@JsonDeserialize
public class Agent extends AbstractActor {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Attachment Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2411-attachments">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class Attachment {

Expand All @@ -14,6 +18,7 @@ public class Attachment {
private String sha2;
private String fileUrl;


public String getUsageType() {
return usageType;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Context Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#246-context">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class Context {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Context Activities Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2462-contextactivities-property">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class ContextActivities {

Expand Down
35 changes: 34 additions & 1 deletion src/main/java/com/yetanalytics/xapi/model/Extensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
import com.yetanalytics.xapi.model.serializers.ExtensionSerializer;
import com.yetanalytics.xapi.util.Mapper;

/**
* A wrapper object for using <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#41-extensions">xAPI Extensions</a>.
*
* The extension JSON data is stored in a combination of LinkedHashMap and
* ArrayList depending on the JSON elements. It can be accessed directly
* or through a JSONPath API.
*/
@JsonDeserialize(using = ExtensionDeserializer.class)
@JsonSerialize(using = ExtensionSerializer.class)
public class Extensions {
Expand All @@ -23,14 +30,31 @@ public Extensions(Map<String, Object> input) {
extMap = input;
}

/**
* Sets an entry in the Extensions Map
* @param key the IRI key of the extension
* @param value The Collections API representation of the JSON Data
*/
public void put(String key, Object value) {
extMap.put(key, value);
}

/**
* Retrieve extension data
* @param key The IRI of the extension
* @return The Collections API representation of the JSON Data
*/
public Object get(String key) {
return extMap.get(key);
}

/**
* Attempt a JSONPath query of the Extension data.
* @param key The IRI key of the extension in which to perform the query
* @param jsonPathExpression A JSONPath query to perform in the Extension data
* @param typeKey The type that the query is expecting to retrieve
* @return
*/
@SuppressWarnings("unchecked")
public <T> T read(String key, String jsonPathExpression, Class<T> typeKey) {
try {
Expand All @@ -47,14 +71,23 @@ public <T> T read(String key, String jsonPathExpression, Class<T> typeKey) {
return null;
}

/**
* Remove an extension by IRI key
* @param key the IRI of the extension to remove
*/
public void remove(String key) {
extMap.remove(key);
}

/**
* @return A Set of all IRI Extension keys
*/
public Set<String> getKeys() {
return extMap.keySet();
}

/**
* @return The raw Extensions Map
*/
public Map<String, Object> getMap() {
return extMap;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Group Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#2422-when-the-actor-objecttype-is-group">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
@JsonDeserialize
public class Group extends AbstractActor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Class representation of the Interaction Component of the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#interaction-components">9274.1.1 xAPI Specification</a>.
*/
@JsonInclude(Include.NON_NULL)
public class InteractionComponent {

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/yetanalytics/xapi/model/InteractionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.yetanalytics.xapi.model.deserializers.InteractionTypeDeserializer;

/**
* Enumeration representing all Interaction Types in the
* <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#interaction-types">9274.1.1 xAPI Specification</a>.
*/
@JsonDeserialize(using = InteractionTypeDeserializer.class)
public enum InteractionType {
TRUE_FALSE("true-false"),
Expand All @@ -23,10 +27,17 @@ public enum InteractionType {
this.displayName = displayName;
}

/**
* @return Display name of the InteractionType (used in JSON/Serialization)
*/
@Override
@JsonValue
public String toString() { return displayName; }

/**
* @param name displayName to look up correct InteractionType
* @return Appropriate InteractionType for the displayName
*/
public static InteractionType getByDisplayName(String name) {
for(InteractionType t : values()){
if(t.toString().equals(name)){
Expand All @@ -36,6 +47,11 @@ public static InteractionType getByDisplayName(String name) {
throw new IllegalArgumentException("Bad InteractionType Value");
}

/**
* Helper method for testing string equivalence to an InteractionType
* @param match string to test for InteractionType equivalence
* @return boolean representing equivalence
*/
public boolean matches(String match) {
return this.toString().equals(match);
}
Expand Down
Loading

0 comments on commit 85241a2

Please sign in to comment.