commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject incubator-commonsrdf git commit: jsonld-java integration draft
Date Mon, 04 Apr 2016 00:08:00 GMT
Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/jsonld-java [created] 84cf08e24


jsonld-java integration draft


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/84cf08e2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/84cf08e2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/84cf08e2

Branch: refs/heads/jsonld-java
Commit: 84cf08e245d0ec7fd074ba402779a9c1a5b77afd
Parents: 13a6b07
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Mon Apr 4 01:07:44 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Mon Apr 4 01:07:44 2016 +0100

----------------------------------------------------------------------
 jsonld-java/.gitignore                          |   1 +
 jsonld-java/pom.xml                             |  67 +++++++++++
 .../commons/rdf/jsonldjava/JsonLDGraph.java     | 118 +++++++++++++++++++
 .../commons/rdf/jsonldjava/package-info.java    |  22 ++++
 .../org.apache.commons.rdf.api.RDFTermFactory   |   1 +
 pom.xml                                         |  14 +++
 6 files changed, 223 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/jsonld-java/.gitignore
----------------------------------------------------------------------
diff --git a/jsonld-java/.gitignore b/jsonld-java/.gitignore
new file mode 100644
index 0000000..b83d222
--- /dev/null
+++ b/jsonld-java/.gitignore
@@ -0,0 +1 @@
+/target/

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/jsonld-java/pom.xml
----------------------------------------------------------------------
diff --git a/jsonld-java/pom.xml b/jsonld-java/pom.xml
new file mode 100644
index 0000000..1c7ff41
--- /dev/null
+++ b/jsonld-java/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-rdf-parent</artifactId>
+        <version>0.2.0-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>commons-rdf-jsonld-java</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Commons RDF: Integration: JSON-LD Java</name>
+    <description>Parser integration of JSON-LD Java</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>commons-rdf-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>commons-rdf-api</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.parent.groupId}</groupId>
+            <artifactId>commons-rdf-simple</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
+        <dependency>
+		    <groupId>com.github.jsonld-java</groupId>
+		    <artifactId>jsonld-java</artifactId>
+		    <version>0.8.2</version>
+		</dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLDGraph.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLDGraph.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLDGraph.java
new file mode 100644
index 0000000..a5302d0
--- /dev/null
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLDGraph.java
@@ -0,0 +1,118 @@
+package org.apache.commons.rdf.jsonldjava;
+
+import java.util.stream.Stream;
+
+import org.apache.commons.rdf.api.BlankNode;
+import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Graph;
+import org.apache.commons.rdf.api.IRI;
+import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.RDFTerm;
+import org.apache.commons.rdf.api.Triple;
+
+import com.github.jsonldjava.core.RDFDataset;
+import com.github.jsonldjava.core.RDFDataset.Node;
+import com.github.jsonldjava.core.RDFDataset.Quad;
+
+public class JsonLDGraph implements Graph {
+	private RDFDataset rdfDataSet;
+
+	/**
+	 * If true, include all Quad statements as Triples. If false, 
+	 * only Quads in the default graph (<code>null</code>) are
+	 * included.
+	 */
+	private boolean unionGraph = false;
+
+	@Override
+	public void close() throws Exception {
+		rdfDataSet = null;		
+	}
+
+	@Override
+	public void add(Triple triple) {
+		Quad q = asJsonLdQuad(triple);
+	}
+
+	private Quad asJsonLdQuad(Triple triple) {
+		Node subject = asJsonLdNode(triple.getSubject());
+		Node predicate = asJsonLdNode(triple.getPredicate());
+		Node object = asJsonLdNode(triple.getObject());
+		String graph = null;
+		// TODO: Add Quad to commons-rdf
+//		if (triple instanceof Quad) {
+//			String graph = triple.getGraph().getIRIString();
+//		}
+		return new Quad(subject, predicate, object, graph);
+		
+	}
+
+	private Node asJsonLdNode(RDFTerm object) {
+		if (object instanceof IRI) {
+			return new RDFDataset.IRI( ((IRI)object).getIRIString() );
+		}
+		if (object instanceof BlankNode) {
+			return new RDFDataset.BlankNode( ((BlankNode)object).uniqueReference() );
+		}
+		if (object instanceof Literal) {
+			Literal literal = (Literal) object;
+			return new RDFDataset.Literal(literal.getLexicalForm(), literal.getDatatype().getIRIString(),

+					literal.getLanguageTag().get());
+		}
+		throw new IllegalArgumentException("RDFTerm not instanceof IRI, BlankNode or Literal: "
+ object);
+	}
+
+	@Override
+	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		new RDFDataset.Quad(asJsonLdNode(subject), asJsonLdNode(predicate), asJsonLdNode(object),
null); 
+		
+	}
+
+	@Override
+	public boolean contains(Triple triple) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void remove(Triple triple) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void clear() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public long size() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public Stream<? extends Triple> getTriples() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Stream<? extends Triple> getTriples(BlankNodeOrIRI subject, IRI predicate,
RDFTerm object) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
new file mode 100644
index 0000000..39b7525
--- /dev/null
+++ b/jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Integration with jsonld-java
+ * 
+ */
+package org.apache.commons.rdf.jsonldjava;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
----------------------------------------------------------------------
diff --git a/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
b/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
new file mode 100644
index 0000000..4287ca8
--- /dev/null
+++ b/jsonld-java/src/main/resources/META-INF/services/org.apache.commons.rdf.api.RDFTermFactory
@@ -0,0 +1 @@
+#
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/84cf08e2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d3da45e..16de28c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,6 +217,7 @@
     <modules>
         <module>api</module>
         <module>simple</module>
+        <module>jsonld-java</module>
     </modules>
 
     <dependencyManagement>
@@ -406,6 +407,19 @@
                                         <ignore />
                                     </action>
                                 </pluginExecution>
+                                <pluginExecution>
+                                	<pluginExecutionFilter>
+                                		<groupId>org.apache.felix</groupId>
+                                		<artifactId>maven-bundle-plugin</artifactId>
+                                		<versionRange>[2.5.3,)</versionRange>
+                                		<goals>
+                                			<goal>manifest</goal>
+                                		</goals>
+                                	</pluginExecutionFilter>
+                                	<action>
+                                		<ignore />
+                                	</action>
+                                </pluginExecution>
                             </pluginExecutions>
                         </lifecycleMappingMetadata>
                     </configuration>


Mime
View raw message