clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/6] clerezza git commit: CLEREZZA-963: using and rdf-commons from clerezza-rdf-core repository
Date Thu, 19 Mar 2015 21:34:35 GMT
Repository: clerezza
Updated Branches:
  refs/heads/rdf-commons 4cb0b5240 -> de5881d42


CLEREZZA-963: using and rdf-commons from clerezza-rdf-core repository

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/340cdcaf
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/340cdcaf
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/340cdcaf

Branch: refs/heads/rdf-commons
Commit: 340cdcafd3026a5d5a7dfc6a31d925ae813967b4
Parents: 4cb0b52
Author: Reto Gmuer <reto@apache.org>
Authored: Thu Mar 19 17:41:59 2015 +0000
Committer: Reto Gmuer <reto@apache.org>
Committed: Thu Mar 19 17:41:59 2015 +0000

----------------------------------------------------------------------
 maven-ontologies-plugin/pom.xml                 |   4 +-
 rdf.ontologies/pom.xml                          |   8 +-
 rdf.schemagen/pom.xml                           |  15 ++-
 .../clerezza/rdf/schemagen/SchemaGen.java       | 118 ++++++++++---------
 4 files changed, 76 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/340cdcaf/maven-ontologies-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/maven-ontologies-plugin/pom.xml b/maven-ontologies-plugin/pom.xml
index c04cf20..f4884a1 100644
--- a/maven-ontologies-plugin/pom.xml
+++ b/maven-ontologies-plugin/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <artifactId>clerezza</artifactId>
         <groupId>org.apache.clerezza</groupId>
-        <version>0.5</version>
+        <version>1.0.0-SNAPSHOT</version>
         <relativePath>../parent</relativePath>
     </parent>
     <groupId>org.apache.clerezza</groupId>
@@ -49,7 +49,7 @@
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.schemagen</artifactId>
-            <version>0.11</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
              <groupId>org.apache.maven</groupId>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/340cdcaf/rdf.ontologies/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.ontologies/pom.xml b/rdf.ontologies/pom.xml
index 7dbf888..d9a7a7e 100644
--- a/rdf.ontologies/pom.xml
+++ b/rdf.ontologies/pom.xml
@@ -37,9 +37,9 @@
     <description>Some java classes with constants for common ontologies.</description>
     <dependencies>
         <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.core</artifactId>
-            <version>0.14</version>
+            <groupId>org.apache.clerezza.commons-rdf</groupId>
+            <artifactId>commons-rdf-api</artifactId>
+            <version>0.1-SNAPSHOT</version>
         </dependency>
     </dependencies>
     <build>
@@ -47,6 +47,7 @@
             <plugin>
                 <groupId>org.apache.clerezza</groupId>
                 <artifactId>maven-ontologies-plugin</artifactId>
+                <version>1.0.0-SNAPSHOT</version>
                 <executions>
                     <execution>
                         <phase>generate-sources</phase>
@@ -71,7 +72,6 @@
                         </goals>
                     </execution>
                 </executions>
-                <version>0.4</version>
         </plugin>
         </plugins>
     </build>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/340cdcaf/rdf.schemagen/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.schemagen/pom.xml b/rdf.schemagen/pom.xml
index 70a208a..af8820c 100644
--- a/rdf.schemagen/pom.xml
+++ b/rdf.schemagen/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <artifactId>clerezza</artifactId>
         <groupId>org.apache.clerezza</groupId>
-        <version>0.5</version>
+        <version>1.0.0-SNAPSHOT</version>
         <relativePath>../parent</relativePath>
     </parent>
     <groupId>org.apache.clerezza</groupId>
@@ -43,14 +43,19 @@
             <artifactId>wymiwyg-commons-core</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.clerezza</groupId>
-            <artifactId>rdf.core</artifactId>
-            <version>0.14</version>
+            <groupId>org.apache.clerezza.commons-rdf</groupId>
+            <artifactId>commons-rdf-api</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza.commons-rdf</groupId>
+            <artifactId>commons-rdf-impl-utils</artifactId>
+            <version>0.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.jena.parser</artifactId>
-            <version>0.12</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/340cdcaf/rdf.schemagen/src/main/java/org/apache/clerezza/rdf/schemagen/SchemaGen.java
----------------------------------------------------------------------
diff --git a/rdf.schemagen/src/main/java/org/apache/clerezza/rdf/schemagen/SchemaGen.java
b/rdf.schemagen/src/main/java/org/apache/clerezza/rdf/schemagen/SchemaGen.java
index ce4f720..adbfbeb 100644
--- a/rdf.schemagen/src/main/java/org/apache/clerezza/rdf/schemagen/SchemaGen.java
+++ b/rdf.schemagen/src/main/java/org/apache/clerezza/rdf/schemagen/SchemaGen.java
@@ -31,16 +31,18 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+
+
 import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
 import org.wymiwyg.commons.util.arguments.AnnotatedInterfaceArguments;
 import org.wymiwyg.commons.util.arguments.ArgumentHandler;
 import org.wymiwyg.commons.util.arguments.InvalidArgumentsException;
@@ -102,7 +104,7 @@ public class SchemaGen {
         Iterator<Triple> ontologyTriples = schemaGraph.filter(null, RDF.type, OWL.Ontology);
         String result;
         if(ontologyTriples.hasNext()) {
-            result = ((UriRef) ontologyTriples.next().getSubject()).getUnicodeString();
+            result = ((Iri) ontologyTriples.next().getSubject()).getUnicodeString();
         } else {
             throw new RuntimeException("No OWL Ontology found!");
         }
@@ -131,7 +133,7 @@ public class SchemaGen {
             out.println(';');
         }
         out.println();
-        out.println("import org.apache.clerezza.rdf.core.UriRef;");
+        out.println("import org.apache.commons.rdf.Iri;");
         out.println();
         out.print("public class ");
         out.print(getSimpleName());
@@ -186,16 +188,16 @@ public class SchemaGen {
                 out.println(description);
                 out.println("\t */");
             }
-            out.print("\tpublic static final UriRef ");
+            out.print("\tpublic static final Iri ");
             out.print(ontologyResource.getLocalName());
-            out.print(" = new UriRef(\"");
+            out.print(" = new Iri(\"");
             out.print(ontologyResource.getUriString());
             out.println("\");");
         }
 
     }
 
-    private Collection<OntologyResource> getResourcesOfType(UriRef type) {
+    private Collection<OntologyResource> getResourcesOfType(Iri type) {
          return getResourcesOfType(type, null);
     }
 
@@ -205,14 +207,14 @@ public class SchemaGen {
      * @param ignore a set things to ignore
      * @return
      */
-    private Collection<OntologyResource> getResourcesOfType(UriRef type, Collection<OntologyResource>
ignore) {
+    private Collection<OntologyResource> getResourcesOfType(Iri type, Collection<OntologyResource>
ignore) {
         Set<OntologyResource> result = new HashSet<OntologyResource>();
         Iterator<Triple> classStatemente = schemaGraph.filter(null, RDF.type,
                 type);
         while (classStatemente.hasNext()) {
             Triple triple = classStatemente.next();
-            NonLiteral classResource = triple.getSubject();
-            if (classResource instanceof BNode) {
+            BlankNodeOrIri classResource = triple.getSubject();
+            if (classResource instanceof BlankNode) {
                 if (type !=null) System.err.println("Ignoring anonymous resource of type
" + type.getUnicodeString());
                 else System.err.println("Ignoring anonymous resource");
                 for (Triple contextTriple : getNodeContext(classResource, schemaGraph)) {
@@ -222,7 +224,7 @@ public class SchemaGen {
             }
 
             // Test if the given resource belongs to the ontology
-            final UriRef classUri = (UriRef) classResource;
+            final Iri classUri = (Iri) classResource;
             final String strClassUri = classUri.getUnicodeString();
             if (strClassUri.startsWith(namespace)) {
                 // The remaining part of the class URI must not contain
@@ -246,25 +248,25 @@ public class SchemaGen {
         return result;
     }
 
-    private Graph getNodeContext(NonLiteral resource, Graph graph) {
-        final HashSet<BNode> dontExpand = new HashSet<BNode>();
-        if (resource instanceof BNode) {
-            dontExpand.add((BNode) resource);
+    private ImmutableGraph getNodeContext(BlankNodeOrIri resource, Graph graph) {
+        final HashSet<BlankNode> dontExpand = new HashSet<BlankNode>();
+        if (resource instanceof BlankNode) {
+            dontExpand.add((BlankNode) resource);
         }
-        return getContextOf(resource, dontExpand, graph).getGraph();
+        return getContextOf(resource, dontExpand, graph).getImmutableGraph();
 
     }
 
-    private MGraph getContextOf(NonLiteral node, Set<BNode> dontExpand,
+    private Graph getContextOf(BlankNodeOrIri node, Set<BlankNode> dontExpand,
             Graph graph) {
-        MGraph result = new SimpleMGraph();
+        Graph result = new SimpleGraph();
         Iterator<Triple> forwardProperties = graph.filter(node, null, null);
         while (forwardProperties.hasNext()) {
             Triple triple = forwardProperties.next();
             result.add(triple);
-            Resource object = triple.getObject();
-            if (object instanceof BNode) {
-                BNode bNodeObject = (BNode) object;
+            RdfTerm object = triple.getObject();
+            if (object instanceof BlankNode) {
+                BlankNode bNodeObject = (BlankNode) object;
                 if (!dontExpand.contains(bNodeObject)) {
                     dontExpand.add(bNodeObject);
                     result.addAll(getContextOf(bNodeObject, dontExpand, graph));
@@ -275,9 +277,9 @@ public class SchemaGen {
         while (backwardProperties.hasNext()) {
             Triple triple = backwardProperties.next();
             result.add(triple);
-            NonLiteral subject = triple.getSubject();
-            if (subject instanceof BNode) {
-                BNode bNodeSubject = (BNode) subject;
+            BlankNodeOrIri subject = triple.getSubject();
+            if (subject instanceof BlankNode) {
+                BlankNode bNodeSubject = (BlankNode) subject;
                 if (!dontExpand.contains(bNodeSubject)) {
                     dontExpand.add(bNodeSubject);
                     result.addAll(getContextOf(bNodeSubject, dontExpand, graph));
@@ -307,7 +309,7 @@ public class SchemaGen {
             Comparable<OntologyResource> {
 
         final Graph graph;
-        final UriRef uri;
+        final Iri uri;
 
         static final List<String> reservedWords = Arrays.asList(
                 "abstract", "assert", "boolean", "break", "byte", "case",
@@ -320,7 +322,7 @@ public class SchemaGen {
                 "synchronized", "this", "throw", "throws", "transient",
                 "true", "try", "void", "volatile", "while");
 
-        OntologyResource(UriRef uri, Graph graph) {
+        OntologyResource(Iri uri, Graph graph) {
             this.uri = uri;
             this.graph = graph;
         }
@@ -346,7 +348,7 @@ public class SchemaGen {
             Iterator<Triple> titleStatements = graph.filter(
                     uri, DCTERMS.title, null);
             while (titleStatements.hasNext()) {
-                Resource object = titleStatements.next().getObject();
+                RdfTerm object = titleStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("title: ");
                     result.append (((Literal) object).getLexicalForm());
@@ -356,7 +358,7 @@ public class SchemaGen {
             Iterator<Triple> descriptionStatements = graph.filter(
                     uri, DCTERMS.description, null);
             while (descriptionStatements.hasNext()) {
-                Resource object = descriptionStatements.next().getObject();
+                RdfTerm object = descriptionStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("description: ");
                     result.append (((Literal) object).getLexicalForm());
@@ -366,7 +368,7 @@ public class SchemaGen {
             Iterator<Triple> skosDefStatements = graph.filter(
                     uri, SKOS.definition, null);
             while (skosDefStatements.hasNext()) {
-                Resource object = skosDefStatements.next().getObject();
+                RdfTerm object = skosDefStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("definition: ");
                     result.append (((Literal) object).getLexicalForm());
@@ -376,7 +378,7 @@ public class SchemaGen {
             Iterator<Triple> rdfsCommentStatements = graph.filter(
                     uri, RDFS.comment, null);
             while (rdfsCommentStatements.hasNext()) {
-                Resource object = rdfsCommentStatements.next().getObject();
+                RdfTerm object = rdfsCommentStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("comment: ");
                     result.append(((Literal) object).getLexicalForm());
@@ -386,7 +388,7 @@ public class SchemaGen {
             Iterator<Triple> skosNoteStatements = graph.filter(
                     uri, SKOS.note, null);
             while (skosNoteStatements.hasNext()) {
-                Resource object = skosNoteStatements.next().getObject();
+                RdfTerm object = skosNoteStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("note: ");
                     result.append (((Literal) object).getLexicalForm());
@@ -396,13 +398,13 @@ public class SchemaGen {
             Iterator<Triple> skosExampleStatements = graph.filter(
                     uri, SKOS.example, null);
             while (skosExampleStatements.hasNext()) {
-                Resource object = skosExampleStatements.next().getObject();
+                RdfTerm object = skosExampleStatements.next().getObject();
                 if (object instanceof Literal) {
                     result.append("example: ");
                     result.append (((Literal) object).getLexicalForm());
                     result.append("\n");
-                } else if (object instanceof UriRef) {
-                    result.append("see <a href="+((UriRef)object).getUnicodeString()+">example</a>");
+                } else if (object instanceof Iri) {
+                    result.append("see <a href="+((Iri)object).getUnicodeString()+">example</a>");
                     result.append("\n");
                 }
             }
@@ -442,13 +444,13 @@ public class SchemaGen {
 
 
         private static final String NS = "http://www.w3.org/2002/07/owl#";
-        private static final UriRef Class =
-                new UriRef(NS + "Class");
-        public static final Resource Ontology = new UriRef(NS + "Ontology");
-        private static final UriRef DatatypeProperty =
-                new UriRef(NS + "DatatypeProperty");
-        private static final UriRef ObjectProperty =
-                new UriRef(NS + "ObjectProperty");
+        private static final Iri Class =
+                new Iri(NS + "Class");
+        public static final RdfTerm Ontology = new Iri(NS + "Ontology");
+        private static final Iri DatatypeProperty =
+                new Iri(NS + "DatatypeProperty");
+        private static final Iri ObjectProperty =
+                new Iri(NS + "ObjectProperty");
     }
 
     /** RDFS Ontology. */
@@ -456,9 +458,9 @@ public class SchemaGen {
 
         private static final String NS =
                 "http://www.w3.org/2000/01/rdf-schema#";
-        private static final UriRef Class = new UriRef(NS + "Class");
-        private static final UriRef Datatype = new UriRef(NS + "Datatype");
-        private static final UriRef comment = new UriRef(NS + "comment");
+        private static final Iri Class = new Iri(NS + "Class");
+        private static final Iri Datatype = new Iri(NS + "Datatype");
+        private static final Iri comment = new Iri(NS + "comment");
     }
 
     /** RDF Ontology. */
@@ -466,19 +468,19 @@ public class SchemaGen {
 
         private static final String NS =
                 "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-        private static final UriRef Property = new UriRef(NS + "Property");
-        private static final UriRef type = new UriRef(NS + "type");
+        private static final Iri Property = new Iri(NS + "Property");
+        private static final Iri type = new Iri(NS + "type");
     }
 
     private static class SKOS {
-        static final UriRef definition = new UriRef("http://www.w3.org/2008/05/skos#definition");
-        static final UriRef note = new UriRef("http://www.w3.org/2004/02/skos/core#note");
-        static final UriRef example = new UriRef("http://www.w3.org/2004/02/skos/core#example");
+        static final Iri definition = new Iri("http://www.w3.org/2008/05/skos#definition");
+        static final Iri note = new Iri("http://www.w3.org/2004/02/skos/core#note");
+        static final Iri example = new Iri("http://www.w3.org/2004/02/skos/core#example");
     }
 
     private static class DCTERMS {
-        public static final UriRef title = new UriRef("http://purl.org/dc/terms/title");
-        public static final UriRef description = new UriRef("http://purl.org/dc/terms/description");
+        public static final Iri title = new Iri("http://purl.org/dc/terms/title");
+        public static final Iri description = new Iri("http://purl.org/dc/terms/description");
 
     }
 }


Mime
View raw message