diff --git a/.gitignore b/.gitignore index c02e826..3d8f870 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target .classpath .project .settings/org.scala-ide.sdt.core.prefs +logs diff --git a/app/controllers/TestRdfSerialization.java b/app/controllers/TestRdfSerialization.java new file mode 100644 index 0000000..12d0666 --- /dev/null +++ b/app/controllers/TestRdfSerialization.java @@ -0,0 +1,27 @@ +package controllers; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.github.jsonldjava.core.JsonLdError; +import com.github.jsonldjava.core.JsonLdOptions; +import com.github.jsonldjava.core.JsonLdProcessor; +import com.github.jsonldjava.jena.JenaRDFParser; +import com.github.jsonldjava.utils.JsonUtils; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ModelFactory; + +public class TestRdfSerialization { + + public static void main(String[] args) throws JsonLdError, JsonGenerationException, IOException { + Model model = ModelFactory.createDefaultModel(); + model.read("http://d-nb.info/gnd/2047974-8/about/lds"); + Object jsonLd = JsonLdProcessor.fromRDF(model, new JenaRDFParser()); + String context = "http://hub.culturegraph.org/entityfacts/context/v1/entityfacts.jsonld"; + JsonLdOptions options = new JsonLdOptions(); + options.setCompactArrays(false); + jsonLd = JsonLdProcessor.compact(jsonLd, context, options); + System.out.println(JsonUtils.toPrettyString(jsonLd)); + } + +} diff --git a/build.sbt b/build.sbt index e57ccf0..d8f5bf1 100644 --- a/build.sbt +++ b/build.sbt @@ -8,3 +8,7 @@ lazy val root = (project in file(".")).enablePlugins(PlayJava) scalaVersion := "2.12.2" libraryDependencies += guice + +libraryDependencies += "com.github.jsonld-java" % "jsonld-java" % "0.10.0" + +libraryDependencies += "com.github.jsonld-java" % "jsonld-java-jena" % "0.4.1"