-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convenient methods for voiding statements and getting multiple st…
- Loading branch information
Showing
11 changed files
with
594 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>dev.learning.xapi.samples</groupId> | ||
<artifactId>xapi-samples-build</artifactId> | ||
<version>1.1.5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>get-statement-iterator</artifactId> | ||
<name>Get xAPI StatementIterator Sample</name> | ||
<description>Get xAPI StatementIterator</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>dev.learning.xapi</groupId> | ||
<artifactId>xapi-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.learning.xapi.samples</groupId> | ||
<artifactId>core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
51 changes: 51 additions & 0 deletions
51
...rc/main/java/dev/learning/xapi/samples/getstatements/GetStatementIteratorApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2016-2023 Berry Cloud Ltd. All rights reserved. | ||
*/ | ||
|
||
package dev.learning.xapi.samples.getstatements; | ||
|
||
import dev.learning.xapi.client.XapiClient; | ||
import dev.learning.xapi.model.Verb; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* Sample using xAPI client to get multiple statements as StatementIterator. | ||
* | ||
* @author Thomas Turrell-Croft | ||
* @author István Rátkai (Selindek) | ||
*/ | ||
@SpringBootApplication | ||
public class GetStatementIteratorApplication implements CommandLineRunner { | ||
|
||
/** | ||
* Default xAPI client. Properties are picked automatically from application.properties. | ||
*/ | ||
@Autowired | ||
private XapiClient client; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(GetStatementIteratorApplication.class, args).close(); | ||
} | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
|
||
// Get Statements as StatementIterator | ||
var statements = client.getStatementIterator().block(); | ||
|
||
// Print the returned statements to the console | ||
statements.toStream().forEach(s -> System.out.println(s)); | ||
|
||
// Get Statements with Verb filter as StatementIterator | ||
var filteredStatements = | ||
client.getStatementIterator(r -> r.verb(Verb.ATTEMPTED)).block(); | ||
|
||
// Print the returned statements to the console | ||
filteredStatements.toStream().forEach(s -> System.out.println(s)); | ||
|
||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
samples/get-statement-iterator/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
xapi.client.username = admin | ||
xapi.client.password = password | ||
xapi.client.baseUrl = https://example.com/xapi/ | ||
|
||
spring.codec.max-in-memory-size=1MB |
2 changes: 2 additions & 0 deletions
2
samples/get-statement-with-attachment/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
xapi.client.username = admin | ||
xapi.client.password = password | ||
xapi.client.baseUrl = https://example.com/xapi/ | ||
|
||
spring.codec.max-in-memory-size=1MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
samples/get-statements/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
xapi.client.username = admin | ||
xapi.client.password = password | ||
xapi.client.baseUrl = https://example.com/xapi/ | ||
|
||
spring.codec.max-in-memory-size=1MB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.