Skip to content
Snippets Groups Projects
Commit 738ea6ee authored by Andreas Schärtl's avatar Andreas Schärtl
Browse files

uloapi: fetch number of triplets and return in /statistics

parent b49e4c9f
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ public class GraphDB {
* Functional interface that defines a function for running operations on
* a GraphDB database.
*/
private interface Operation<T> {
public interface Operation<T> {
/**
* Run some operation connected to a database.
*
......
package info.mathhub.uloapi.query;
import info.mathhub.uloapi.config.Config;
public class Query {
private final String serverUrl;
private final String repository;
private static Query singleton;
public Query(String serverUrl, String repository) {
this.serverUrl = serverUrl;
this.repository = repository;
}
public static synchronized Query getSingleton() {
if (Query.singleton == null) {
Query.singleton = new Query(Config.serverUrl(), Config.repository());
}
return Query.singleton;
}
public Statistics getStatistics() {
return new Statistics(10);
final GraphDB.Operation<Long> operation = (manager, repository, connection) -> {
return connection.size();
};
final long numTriplets = GraphDB.execute(this.serverUrl, this.repository, operation);
return new Statistics(numTriplets);
}
}
......@@ -9,7 +9,7 @@ public class Statistics {
*/
public long numTriplets;
Statistics(int numTriplets) {
Statistics(long numTriplets) {
this.numTriplets = numTriplets;
}
}
......@@ -18,7 +18,7 @@ public class Routes {
};
public static final Route statistics = (Request request, Response response) -> {
return new Query().getStatistics();
return Query.getSingleton().getStatistics();
};
public static final Route name = (Request request, Response response) -> {
......
info.mathhub.uloapi.config.serverurl="http://graphdb:7200"
info.mathhub.uloapi.config.repository="myulo"
\ No newline at end of file
info.mathhub.uloapi.config.serverurl=http://rdf:7200
info.mathhub.uloapi.config.repository=myulo
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment