clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [2/5] clerezza git commit: CLEREZZA-978: using rdf-commons from clerezza-rdf-core repository
Date Mon, 23 Mar 2015 16:43:02 GMT
CLEREZZA-978: using 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/68a05975
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/68a05975
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/68a05975

Branch: refs/heads/rdf-commons
Commit: 68a05975738f5119a50f42782fbaa2c7ea1df897
Parents: f3f3b33
Author: Reto Gmuer <reto@apache.org>
Authored: Mon Mar 23 16:20:51 2015 +0000
Committer: Reto Gmuer <reto@apache.org>
Committed: Mon Mar 23 16:20:51 2015 +0000

----------------------------------------------------------------------
 rdf.scala.utils/pom.xml                         | 14 ++--
 .../clerezza/rdf/scala/utils/EzLiteral.scala    | 25 +++++--
 .../clerezza/rdf/scala/utils/EzMGraph.scala     | 32 +++++---
 .../clerezza/rdf/scala/utils/NameSpace.scala    | 10 +--
 .../clerezza/rdf/scala/utils/Preamble.scala     | 28 ++++---
 .../rdf/scala/utils/RichGraphNode.scala         | 60 ++++++++-------
 .../clerezza/rdf/scala/utils/EzMGraphTest.scala | 78 +++++++++++---------
 .../rdf/scala/utils/RichGraphNodeTest.scala     | 45 ++++++-----
 .../rdf/scala/utils/TypeConversionTest.scala    | 21 +++---
 9 files changed, 182 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/pom.xml b/rdf.scala.utils/pom.xml
index 1026034..7d8f99e 100644
--- a/rdf.scala.utils/pom.xml
+++ b/rdf.scala.utils/pom.xml
@@ -24,16 +24,16 @@
     <parent>
         <artifactId>clerezza</artifactId>
         <groupId>org.apache.clerezza</groupId>
-        <version>0.5</version>
+        <version>7-SNAPSHOT</version>
         <relativePath>../parent</relativePath>
     </parent>
     <groupId>org.apache.clerezza</groupId>
     <artifactId>rdf.scala.utils</artifactId>
     <version>1.0.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
-    <name>Clerezza - SCB Scala Utilities</name>
-    <description>OSGi bundle providing utilities for accessing SCB
-    TripleCollections with Scala. Adding import
+    <name>Clerezza - RDF Scala Utilities</name>
+    <description>OSGi bundle providing utilities for accessing Clerezza RDF Commons
+    Graphs with Scala. Adding import
     "org.apache.clerezza.rdf.scala.utils.Preamble._" will allow to use
     "node/-FOAF.knows/FOAF.name!" with a GraphNode node as shortcut for
     node.getSubject(FOAF.knows).getObject(FOAF.name).getNode(). To access
@@ -62,12 +62,12 @@
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.core</artifactId>
-            <version>0.14</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.clerezza</groupId>
             <artifactId>rdf.utils</artifactId>
-            <version>0.14</version>
+            <version>1.0.0-SNAPSHOT</version>
         </dependency>
     </dependencies>
     <build>
@@ -98,7 +98,7 @@
                 <configuration>
                     <scalaVersion>${scala.version}</scalaVersion>
                     <args>
-                        <arg>-target:jvm-1.5</arg>
+                        <arg>-target:jvm-1.7</arg>
                         <arg>-deprecation</arg>
                     </args>
                     <charset>UTF-8</charset>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzLiteral.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzLiteral.scala
b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzLiteral.scala
index b7e7313..c9fcc11 100644
--- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzLiteral.scala
+++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzLiteral.scala
@@ -19,9 +19,14 @@
 
 package org.apache.clerezza.rdf.scala.utils
 
-import org.apache.clerezza.rdf.core.impl.{TypedLiteralImpl, PlainLiteralImpl}
+//import org.apache.clerezza.rdf.core.impl.{TypedLiteralImpl, PlainLiteralImpl}
 import org.apache.clerezza.rdf.ontologies.XSD
-import org.apache.clerezza.rdf.core.{TypedLiteral, Language, PlainLiteral, UriRef}
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Language
+import org.apache.commons.rdf.Literal
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl
+import org.apache.commons.rdf.impl.utils.TypedLiteralImpl
+//import org.apache.commons.rdf.core.{TypedLiteral, Language, PlainLiteral, Iri}
 
 object EzLiteral extends EzLiteralImplicits
 
@@ -50,21 +55,27 @@ class EzLiteral(string: String) extends TypedLiteralImpl(string,XSD.string)
{
   /**
    * @return a plain literal with language specified by lang
    */
-  def lang(lng: String): PlainLiteral = lang(new Language(lng))
+  def lang(lng: String): Literal = lang(new Language(lng))
 
   /**
    * @return a plain literal with language specified by lang
    */
-  def lang(lng: Language): PlainLiteral = new PlainLiteralImpl(string, lng)
+  def lang(lng: Language): Literal = new PlainLiteralImpl(string, lng)
 
   /**
    * Map to a Typed Literal of given type
    */
-  def ^^(typ: UriRef): TypedLiteral = new TypedLiteralImpl(string, typ)
+  def ^^(typ: Iri): Literal = new TypedLiteralImpl(string, typ)
 
   /**
-   * Map to a URI of given lexical form
+   * alias for iri
    */
-  def uri = new UriRef(string)
+  @deprecated(message ="use  `iri`", since="1.0.0")
+  def uri = iri
+  
+  /**
+   * Map to an IRI of given lexical form
+   */
+  def iri = new Iri(string)
 
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzMGraph.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzMGraph.scala
b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzMGraph.scala
index 485f939..6ddb92b 100644
--- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzMGraph.scala
+++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzMGraph.scala
@@ -21,25 +21,33 @@ package org.apache.clerezza.rdf.scala.utils
 
 import org.apache.clerezza.rdf.core._
 import org.apache.clerezza.rdf.core.impl._
+import org.apache.commons.rdf.BlankNode
+import org.apache.commons.rdf.BlankNodeOrIri
+import org.apache.commons.rdf.Graph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.RdfTerm
+import org.apache.commons.rdf.Triple
+import org.apache.commons.rdf.impl.utils.AbstractGraph
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph
 import scala.collection.mutable.HashMap
 
 
 /**
- * EzMGraph enhances graph writing, it can make writing rdf graphs in code a lot more
+ * EzGraph enhances graph writing, it can make writing rdf graphs in code a lot more
  * readable, as it avoids a lot of repetition.
  *
  * @param graph: a Triple collection
  * @author hjs, reto
  */
-class EzMGraph(val baseTc: MGraph) extends AbstractMGraph with TcDependentConversions {
+class EzGraph(val baseTc: Graph) extends AbstractGraph with TcDependentConversions {
 
 
-  def this() = this (new SimpleMGraph())
+  def this() = this (new SimpleGraph())
 
-  def performFilter(subject: NonLiteral, predicate: UriRef,
-      obj: Resource): java.util.Iterator[Triple] = baseTc.filter(subject, predicate, obj)
+  def performFilter(subject: BlankNodeOrIri, predicate: Iri,
+      obj: RdfTerm): java.util.Iterator[Triple] = baseTc.filter(subject, predicate, obj)
 
-  override def size = baseTc.size
+  override def performSize = baseTc.size
 
   override def add(t: Triple) = baseTc.add(t)
 
@@ -53,20 +61,22 @@ class EzMGraph(val baseTc: MGraph) extends AbstractMGraph with TcDependentConver
   /**
    * create a new bnode
    */
-  def bnode: BNode = {
-    new BNode
+  def bnode = blankNode
+ 
+   def blankNode: BlankNode = {
+    new BlankNode
   }
 
-  private val namedBnodes = new HashMap[String,BNode]
+  private val namedBnodes = new HashMap[String,BlankNode]
 
   /**
    * create a new named bnode based EzGraphNode with the preferred writing style
    */
-  def b_(name: String): BNode = {
+  def b_(name: String): BlankNode = {
     namedBnodes.get(name) match {
       case Some(bnode) => bnode
       case None => {
-        val bn = new BNode
+        val bn = new BlankNode
         namedBnodes.put(name, bn);
         bn
       }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/NameSpace.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/NameSpace.scala
b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/NameSpace.scala
index ff67919..19be8aa 100644
--- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/NameSpace.scala
+++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/NameSpace.scala
@@ -18,7 +18,7 @@
  */
 package org.apache.clerezza.rdf.scala.utils
 
-import org.apache.clerezza.rdf.core.UriRef
+import org.apache.commons.rdf.Iri
 
 /**
  * A IRI-namespace prefix
@@ -26,12 +26,12 @@ import org.apache.clerezza.rdf.core.UriRef
 class NameSpace(prefix: String) {
 
   /**
-   * returns a UriRef applying this namespace prefix to the given symbol
+   * returns a Iri applying this namespace prefix to the given symbol
    */
-  def +(s: Symbol) = new UriRef(prefix + s.name)
+  def +(s: Symbol) = new Iri(prefix + s.name)
 
   /**
-   * returns a UriRef applying this prefix to the given string
+   * returns a Iri applying this prefix to the given string
    */
-  def +(s: String) = new UriRef(prefix + s)
+  def +(s: String) = new Iri(prefix + s)
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/Preamble.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/Preamble.scala
b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/Preamble.scala
index d5ff494..8af2452 100644
--- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/Preamble.scala
+++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/Preamble.scala
@@ -18,8 +18,7 @@
  */
 package org.apache.clerezza.rdf.scala.utils
 
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl
-import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl
+
 import org.apache.clerezza.rdf.ontologies.XSD
 import org.apache.clerezza.rdf.utils.GraphNode
 import java.math.BigInteger
@@ -27,6 +26,13 @@ import java.net.URI
 import java.net.URL
 import java.util.Date
 import org.apache.clerezza.rdf.core._
+import org.apache.commons.rdf.Graph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Literal
+import org.apache.commons.rdf.RdfTerm
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph
+import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph
 
 /**
 * This object provides the implicit conversions. Typically this is used by
@@ -50,7 +56,7 @@ object Preamble extends TcIndependentConversions {
 * Typically this is used by
 * adding
 * {{{
-* val preamble = new org.apache.clerezza.rdf.scala.utils.Preamble(myMGraph)
+* val preamble = new org.apache.clerezza.rdf.scala.utils.Preamble(myGraph)
 * import preamble._
 * }}}
 * before the
@@ -58,14 +64,14 @@ object Preamble extends TcIndependentConversions {
 *
 * @author bblfish, reto
 */
-class Preamble(val baseTc: TripleCollection) extends TcDependentConversions {
+class Preamble(val baseTc: Graph) extends TcDependentConversions {
   
 }
 protected trait TcDependentConversions extends TcIndependentConversions {
   
-  def baseTc: TripleCollection
+  def baseTc: Graph
   
-  implicit def toRichGraphNode(resource: Resource) = {
+  implicit def toRichGraphNode(resource: RdfTerm) = {
     new RichGraphNode(new GraphNode(resource, baseTc))
   }
 }
@@ -102,16 +108,16 @@ protected trait TcIndependentConversions extends EzLiteralImplicits
{
 
   implicit def double2lit(double: Double) = litFactory.createTypedLiteral(double)
 
-  implicit def uriRef2Prefix(uriRef: UriRef) = new NameSpace(uriRef.getUnicodeString)
+  implicit def uriRef2Prefix(uriRef: Iri) = new NameSpace(uriRef.getUnicodeString)
 
-  implicit def URItoUriRef(uri: URI) = new UriRef(uri.toString)
+  implicit def URItoIri(uri: URI) = new Iri(uri.toString)
 
-  implicit def URLtoUriRef(url: URL) = new UriRef(url.toExternalForm)
+  implicit def URLtoIri(url: URL) = new Iri(url.toExternalForm)
   
 }
 protected object TcIndependentConversions {
-  val emptyGraph = new impl.SimpleGraph(new impl.SimpleMGraph)
-  val emptyLiteral = new RichGraphNode(new GraphNode(new impl.PlainLiteralImpl(""), emptyGraph))
+  val emptyGraph = new SimpleImmutableGraph(new SimpleGraph)
+  val emptyLiteral = new RichGraphNode(new GraphNode(new PlainLiteralImpl(""), emptyGraph))
 
 }
 

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
index 95f6aab..4f2addc 100644
--- a/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
+++ b/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
@@ -18,14 +18,18 @@
  */
 package org.apache.clerezza.rdf.scala.utils
 
+import org.apache.clerezza.rdf.core.LiteralFactory
 import org.apache.clerezza.rdf.ontologies.RDF
 import org.apache.clerezza.rdf.utils.GraphNode
 import java.util.Iterator
 import _root_.scala.collection.JavaConversions._
 import _root_.scala.reflect.Manifest
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph
-import org.apache.clerezza.rdf.core.{TripleCollection, UriRef, Resource, Literal, TypedLiteral,
LiteralFactory, NonLiteral, BNode}
-import org.apache.clerezza.rdf.utils.UnionMGraph
+import org.apache.commons.rdf.Graph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Literal
+import org.apache.commons.rdf.RdfTerm
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph
+import org.apache.clerezza.rdf.utils.UnionGraph
 
 
 /**
@@ -35,9 +39,9 @@ import org.apache.clerezza.rdf.utils.UnionMGraph
  * Triple-collection
  *
  * @param resource the node represented by this RichGraphNode
- * @param graph the TripleCollection that describes the resource
+ * @param graph the Graph that describes the resource
  */
-class RichGraphNode(resource: Resource, graph: TripleCollection ) extends GraphNode(resource,
graph) {
+class RichGraphNode(resource: RdfTerm, graph: Graph ) extends GraphNode(resource, graph)
{
 
   /**
    * Construct a RichGraphNode given an existing [[GraphNde]]
@@ -51,7 +55,7 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
    *
    * @return all objects of the specified property of the node wrapped by this object
    */
-  def /(property: UriRef): CollectedIter[RichGraphNode] = {
+  def /(property: Iri): CollectedIter[RichGraphNode] = {
     new CollectedIter[RichGraphNode](() => new GraphNodeIter(getObjects(property)), readLock)
   }
 
@@ -61,7 +65,7 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
    * @param property the property for which the subjects pointing to this node by that property
are requested
    * @return the matching resources
    */
-  def /-(property: UriRef): CollectedIter[RichGraphNode] = {
+  def /-(property: Iri): CollectedIter[RichGraphNode] = {
     new CollectedIter[RichGraphNode](() => new GraphNodeIter(getSubjects(property)), readLock)
   }
 
@@ -83,20 +87,20 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
 
   /**
    * produces a default String representation for the node, this is the lexical form of literals,
-   * the unicode-string for UriRef and for BNodes the value returned by toString
+   * the unicode-string for Iri and for BlankNodes the value returned by toString
    *
    * @return the default string representation of the node
    */
   def * : String = {
     getNode() match {
       case lit: Literal => lit.getLexicalForm
-      case uri: UriRef => uri.getUnicodeString
+      case uri: Iri => uri.getUnicodeString
       case wrappedNode => wrappedNode.toString
     }
   }
 
   private def asClass[T](clazz : Class[T]) : T= {
-    val typedLiteral = getNode().asInstanceOf[TypedLiteral]
+    val typedLiteral = getNode().asInstanceOf[Literal]
     clazz match {
       case c if(c == classOf[Boolean])  => LiteralFactory.getInstance().createObject(
           classOf[java.lang.Boolean], typedLiteral).booleanValue.asInstanceOf[T]
@@ -111,20 +115,20 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
    * @return the literal represented by this node as instance of the specified type
    */
   def as[T](implicit m: Manifest[T]): T = {
-    asClass(m.erasure.asInstanceOf[Class[T]])
+    asClass(m.runtimeClass.asInstanceOf[Class[T]])
   }
 
   /**
-   * Operator syntax shortcut to get the <code>Resource</code> wrapped by this
+   * Operator syntax shortcut to get the <code>RdfTerm</code> wrapped by this
    * <code>GraphNode</code>
    *
-   * @return the node represented by this GraphNode as Resource, same as <code>getNode</code>
+   * @return the node represented by this GraphNode as RdfTerm, same as <code>getNode</code>
    */
   def ! = {
     getNode()
   }
 
-  private class GraphNodeIter[T <: Resource](base: Iterator[T]) extends Iterator[RichGraphNode]
{
+  private class GraphNodeIter[T <: RdfTerm](base: Iterator[T]) extends Iterator[RichGraphNode]
{
     override def hasNext() = {
         base.hasNext();
     }
@@ -140,7 +144,7 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
 
   /**
    *Sets the RDF:type of the subject */
-  def a(rdfclass: UriRef): RichGraphNode = {
+  def a(rdfclass: Iri): RichGraphNode = {
     addProperty(RDF.`type`, rdfclass)
     return this
   }
@@ -149,13 +153,13 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
    * create an RichGraphNode from this one where the backing graph is protected from writes
by a new
    * SimpleGraph.
    */
-  def protect(): RichGraphNode = new RichGraphNode(getNode, new UnionMGraph(new SimpleMGraph(),
graph))
+  def protect(): RichGraphNode = new RichGraphNode(getNode, new UnionGraph(new SimpleGraph(),
graph))
 
 
   /**
    * relate the subject via the given relation to....
    */
-  def --(rel: Resource): DashTuple = new DashTuple(rel)
+  def --(rel: RdfTerm): DashTuple = new DashTuple(rel)
 
   def --(rel: RichGraphNode): DashTuple = new DashTuple(rel.getNode)
 
@@ -165,9 +169,9 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
    */
   def <--(tuple: RichGraphNode#DashTuple): RichGraphNode = {
     val inversePropertyRes = tuple.first.getNode
-    val inverseProperty: UriRef =  inversePropertyRes match {
-      case p: UriRef => p
-      case _ => throw new RuntimeException("DashTuple must be a UriRef")
+    val inverseProperty: Iri =  inversePropertyRes match {
+      case p: Iri => p
+      case _ => throw new RuntimeException("DashTuple must be a Iri")
     }
     RichGraphNode.this.addInverseProperty(inverseProperty, tuple.second)
     RichGraphNode.this
@@ -181,7 +185,7 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
 //    /**
 //     * ...to the following non literal
 //     */
-//    def --(subj: NonLiteral): RichGraphNode = {
+//    def --(subj: BlankNodeOrIri): RichGraphNode = {
 //      RichGraphNode.this.addInverseProperty(rel, subj)
 //      RichGraphNode.this
 //    }
@@ -189,14 +193,14 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
 //    /**
 //     * ...to the following resource (given as a string)
 //     */
-//    def --(subj: String): RichGraphNode = --(new UriRef(subj))
+//    def --(subj: String): RichGraphNode = --(new Iri(subj))
 //
 //    /**
 //     * ...to the following EzGraphNode
 //     * (useful for opening a new parenthesis and specifying other things in more detail
 //     */
 //    def --(subj: GraphNode): RichGraphNode = {
-//      --(subj.getNode.asInstanceOf[NonLiteral])
+//      --(subj.getNode.asInstanceOf[BlankNodeOrIri])
 //    }
 //    // since we can only have inverses from non literals (howto deal with bndoes?)
 //  }
@@ -204,16 +208,16 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
   /**
    *  class for relations with the current RichGraphNode.ref as subject
    */
-  class DashTuple(val second: Resource) {
+  class DashTuple(val second: RdfTerm) {
 
     val first = RichGraphNode.this
     /**
      * ...to the following non resource
      */
-    def -->(obj: Resource): RichGraphNode = {
+    def -->(obj: RdfTerm): RichGraphNode = {
       val property = second match {
-        case u: UriRef => u;
-        case _ => throw new RuntimeException("Property must be a UriRef")
+        case u: Iri => u;
+        case _ => throw new RuntimeException("Property must be a Iri")
       }
       RichGraphNode.this.addProperty(property, obj)
       RichGraphNode.this
@@ -230,7 +234,7 @@ class RichGraphNode(resource: Resource, graph: TripleCollection ) extends
GraphN
     /**
      * Add one relation for each member of the iterable collection
      */
-    def -->>[T <: Resource](uris: Iterable[T]): RichGraphNode = {
+    def -->>[T <: RdfTerm](uris: Iterable[T]): RichGraphNode = {
       for (u <- uris) -->(u)
       RichGraphNode.this
     }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala
b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala
index 946d77e..3e72d87 100644
--- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala
+++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzMGraphTest.scala
@@ -18,6 +18,14 @@
  */
 package org.apache.clerezza.rdf.scala.utils
 
+import org.apache.commons.rdf.BlankNode
+import org.apache.commons.rdf.ImmutableGraph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Language
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl
+import org.apache.commons.rdf.impl.utils.TripleImpl
+import org.apache.commons.rdf.impl.utils.TypedLiteralImpl
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph
 import org.junit._
 import org.apache.clerezza.rdf.core._
 import impl._
@@ -27,7 +35,7 @@ import org.apache.clerezza.rdf.ontologies._
 /**
  * @author bblfish, reto
  */ 
-class EzMGraphTest {
+class EzGraphTest {
 
   val bblfishModulus = """
     9D ☮ 79 ☮ BF ☮ E2 ☮ F4 ☮ 98 ☮ BC ☮ 79 ☮ 6D ☮ AB ☮ 73 ☮ E2 ☮ 8B
☮ 39 ☮ 4D ☮ B5 26 ✜ 68 ✜ 49 ✜ EE ✜ 71 ✜ 87 ✜
@@ -40,28 +48,28 @@ class EzMGraphTest {
 
   /**import some references in order to reduce dependencies */
 
-  final val hex: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#hex")
-  final val identity: UriRef = new UriRef("http://www.w3.org/ns/auth/cert#identity")
-  final val RSAPublicKey: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#RSAPublicKey")
-  final val modulus: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#modulus")
-  final val public_exponent: UriRef = new UriRef("http://www.w3.org/ns/auth/rsa#public_exponent")
+  final val hex: Iri = new Iri("http://www.w3.org/ns/auth/cert#hex")
+  final val identity: Iri = new Iri("http://www.w3.org/ns/auth/cert#identity")
+  final val RSAPublicKey: Iri = new Iri("http://www.w3.org/ns/auth/rsa#RSAPublicKey")
+  final val modulus: Iri = new Iri("http://www.w3.org/ns/auth/rsa#modulus")
+  final val public_exponent: Iri = new Iri("http://www.w3.org/ns/auth/rsa#public_exponent")
 
   val henryUri: String = "http://bblfish.net/#hjs"
   val retoUri: String = "http://farewellutopia.com/reto/#me"
   val danbriUri: String = "http://danbri.org/foaf.rdf#danbri"
 
 
-  private val tinyGraph: Graph = {
-    val gr = new SimpleMGraph
-    val reto = new BNode()
-    val danny = new BNode()
-    val henry = new UriRef(henryUri)
+  private val tinyGraph: ImmutableGraph = {
+    val gr = new SimpleGraph
+    val reto = new BlankNode()
+    val danny = new BlankNode()
+    val henry = new Iri(henryUri)
 
     gr.add(new TripleImpl(reto, RDF.`type`, FOAF.Person))
     gr.add(new TripleImpl(reto, FOAF.name, new PlainLiteralImpl("Reto Bachman-Gmür", new
Language("rm"))))
     //it is difficult to remember that one needs to put a string literal if one does not
want to specify a language
     gr.add(new TripleImpl(reto, FOAF.title, new TypedLiteralImpl("Mr", XSD.string)))
-    gr.add(new TripleImpl(reto, FOAF.currentProject, new UriRef("http://clerezza.org/")))
+    gr.add(new TripleImpl(reto, FOAF.currentProject, new Iri("http://clerezza.org/")))
     gr.add(new TripleImpl(reto, FOAF.knows, henry))
     gr.add(new TripleImpl(reto, FOAF.knows, danny))
 
@@ -71,56 +79,56 @@ class EzMGraphTest {
     gr.add(new TripleImpl(danny, FOAF.knows, reto))
 
     gr.add(new TripleImpl(henry, FOAF.name, new TypedLiteralImpl("Henry Story", XSD.string)))
//It is tricky to remember that one needs this for pure strings
-    gr.add(new TripleImpl(henry, FOAF.currentProject, new UriRef("http://webid.info/")))
+    gr.add(new TripleImpl(henry, FOAF.currentProject, new Iri("http://webid.info/")))
     gr.add(new TripleImpl(henry, RDF.`type`, FOAF.Person))
     gr.add(new TripleImpl(henry, FOAF.knows, danny))
     gr.add(new TripleImpl(henry, FOAF.knows, reto))
 
-    val pk = new BNode()
+    val pk = new BlankNode()
     gr.add(new TripleImpl(pk, RDF.`type`, RSAPublicKey))
     gr.add(new TripleImpl(pk, identity, henry))
     gr.add(new TripleImpl(pk, modulus, LiteralFactory.getInstance().createTypedLiteral(65537)))
     gr.add(new TripleImpl(pk, public_exponent, new TypedLiteralImpl(bblfishModulus, hex)))
-    gr.getGraph
+    gr.getImmutableGraph
   }
 
 
   @Test
   def singleTriple {
     val expected = {
-      val s = new SimpleMGraph
-      s.add(new TripleImpl(henryUri.uri, FOAF.knows, retoUri.uri))
-      s.getGraph
+      val s = new SimpleGraph
+      s.add(new TripleImpl(henryUri.iri, FOAF.knows, retoUri.iri))
+      s.getImmutableGraph
     }
-    val ez = new EzMGraph() {
-      henryUri.uri -- FOAF.knows --> retoUri.uri
+    val ez = new EzGraph() {
+      henryUri.iri -- FOAF.knows --> retoUri.iri
     }
-    Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph)
+    Assert.assertEquals("The two graphs should be equals", expected, ez.getImmutableGraph)
   }
 
   @Test
   def inverseTriple {
     val expected = {
-      val s = new SimpleMGraph
-      s.add(new TripleImpl(retoUri.uri, FOAF.knows, henryUri.uri))
-      s.getGraph
+      val s = new SimpleGraph
+      s.add(new TripleImpl(retoUri.iri, FOAF.knows, henryUri.iri))
+      s.getImmutableGraph
     }
-    val ez = new EzMGraph() {
-      henryUri.uri <--  FOAF.knows -- retoUri.uri
+    val ez = new EzGraph() {
+      henryUri.iri <--  FOAF.knows -- retoUri.iri
     }
-    Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph)
+    Assert.assertEquals("The two graphs should be equals", expected, ez.getImmutableGraph)
   }
 
   @Test
   def usingAsciiArrows {
-    val ez = new EzMGraph() {(
+    val ez = new EzGraph() {(
       b_("reto").a(FOAF.Person) -- FOAF.name --> "Reto Bachman-Gmür".lang("rm")
         -- FOAF.title --> "Mr"
-        -- FOAF.currentProject --> "http://clerezza.org/".uri
+        -- FOAF.currentProject --> "http://clerezza.org/".iri
         -- FOAF.knows --> (
-          "http://bblfish.net/#hjs".uri.a(FOAF.Person)
+          "http://bblfish.net/#hjs".iri.a(FOAF.Person)
             -- FOAF.name --> "Henry Story"
-              -- FOAF.currentProject --> "http://webid.info/".uri
+              -- FOAF.currentProject --> "http://webid.info/".iri
               -- FOAF.knows -->> List(b_("reto"), b_("danny"))
           //one need to list properties before inverse properties, or use brackets
           <-- identity -- (
@@ -132,15 +140,15 @@ class EzMGraphTest {
         -- FOAF.knows --> (
           b_("danny").a(FOAF.Person)
             -- FOAF.name --> "Danny Ayers".lang("en")
-              -- FOAF.knows --> "http://bblfish.net/#hjs".uri //knows
+              -- FOAF.knows --> "http://bblfish.net/#hjs".iri //knows
             -- FOAF.knows --> b_("reto")
         )
     )}
     Assert.assertEquals("the two graphs should be of same size",tinyGraph.size,ez.size)
-    Assert.assertEquals("Both graphs should contain exactly the same triples",tinyGraph,ez.getGraph)
+    Assert.assertEquals("Both graphs should contain exactly the same triples",tinyGraph,ez.getImmutableGraph)
     //We can add triples by creating a new anonymous instance
-    new EzMGraph(ez) {(
-      "http://bblfish.net/#hjs".uri -- FOAF.name --> "William"
+    new EzGraph(ez) {(
+      "http://bblfish.net/#hjs".iri -- FOAF.name --> "William"
       -- FOAF.name --> "Bill"
     )}
     Assert.assertEquals("the triple colletion has grown by one",tinyGraph.size()+2,ez.size)

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala
b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala
index ec6cb1c..2029c03 100644
--- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala
+++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNodeTest.scala
@@ -22,29 +22,38 @@ import org.apache.clerezza.rdf.utils._
 import org.apache.clerezza.rdf.core._
 import org.apache.clerezza.rdf.core.impl._
 import org.apache.clerezza.rdf.ontologies._
+import org.apache.commons.rdf.BlankNode
+import org.apache.commons.rdf.Graph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Language
+import org.apache.commons.rdf.Literal
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl
+import org.apache.commons.rdf.impl.utils.TripleImpl
+import org.apache.commons.rdf.impl.utils.TypedLiteralImpl
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph
 import org.junit._
 import Preamble._
 
 class RichGraphNodeTest {
 
-  private val johnUri = new UriRef("http://example.org/john")
-  private val susanneUri = new UriRef("http://example.org/susanne")
-  private val listUri = new UriRef("http://example.org/list")
-  private val greetingsUri = new UriRef("http://example.org/greetings")
-  private val billBNode = new BNode()
+  private val johnUri = new Iri("http://example.org/john")
+  private val susanneUri = new Iri("http://example.org/susanne")
+  private val listUri = new Iri("http://example.org/list")
+  private val greetingsUri = new Iri("http://example.org/greetings")
+  private val billBlankNode = new BlankNode()
   private var node : RichGraphNode = null;
-  private var mGraph = new SimpleMGraph()
+  private var mGraph = new SimpleGraph()
 
   @Before
   def prepare() = {
     mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("John")));
     mGraph.add(new TripleImpl(johnUri, FOAF.nick, new PlainLiteralImpl("johny")));
     mGraph.add(new TripleImpl(johnUri, FOAF.name, new PlainLiteralImpl("Johnathan Guller")));
-    mGraph.add(new TripleImpl(johnUri, FOAF.knows, billBNode))
+    mGraph.add(new TripleImpl(johnUri, FOAF.knows, billBlankNode))
     mGraph.add(new TripleImpl(johnUri, RDF.`type`, FOAF.Person));
-    mGraph.add(new TripleImpl(billBNode, FOAF.nick, new PlainLiteralImpl("Bill")));
-    mGraph.add(new TripleImpl(billBNode, FOAF.name, new PlainLiteralImpl("William")));
-    mGraph.add(new TripleImpl(billBNode, RDF.`type`, FOAF.Person));
+    mGraph.add(new TripleImpl(billBlankNode, FOAF.nick, new PlainLiteralImpl("Bill")));
+    mGraph.add(new TripleImpl(billBlankNode, FOAF.name, new PlainLiteralImpl("William")));
+    mGraph.add(new TripleImpl(billBlankNode, RDF.`type`, FOAF.Person));
     mGraph.add(new TripleImpl(susanneUri, FOAF.knows, johnUri));
     mGraph.add(new TripleImpl(susanneUri, FOAF.name, new PlainLiteralImpl("Susanne")));
     mGraph.add(new TripleImpl(susanneUri, RDF.`type`, FOAF.Person));
@@ -85,11 +94,11 @@ class RichGraphNodeTest {
 
   @Test
   def testIterate = {
-    val simple: MGraph = new SimpleMGraph();
-    val node = new GraphNode(new BNode(), simple);
-    node.addProperty(DCTERMS.provenance, new UriRef("http://example.org/foo"));
-    node.addProperty(DCTERMS.language, new UriRef("http://www.bluewin.ch/"));
-    simple.add(new TripleImpl(new UriRef("http://www.bluewin.ch/"),RDF.`type`, RDFS.Container));
+    val simple: Graph = new SimpleGraph();
+    val node = new GraphNode(new BlankNode(), simple);
+    node.addProperty(DCTERMS.provenance, new Iri("http://example.org/foo"));
+    node.addProperty(DCTERMS.language, new Iri("http://www.bluewin.ch/"));
+    simple.add(new TripleImpl(new Iri("http://www.bluewin.ch/"),RDF.`type`, RDFS.Container));
     node.addProperty(RDF.`type`, PLATFORM.HeadedPage);
     node.addProperty(RDF.`type`, RDFS.Class);
     val test: CollectedIter[RichGraphNode] = node/DCTERMS.language/RDF.`type`;
@@ -149,8 +158,8 @@ class RichGraphNodeTest {
   @Test
   def literalAsObject = {
     val dateLiteral = new TypedLiteralImpl("2009-01-01T01:33:58Z",
-          new UriRef("http://www.w3.org/2001/XMLSchema#dateTime"))
-    val node = new GraphNode(dateLiteral, new SimpleMGraph())
+          new Iri("http://www.w3.org/2001/XMLSchema#dateTime"))
+    val node = new GraphNode(dateLiteral, new SimpleGraph())
     Assert.assertNotNull(node.as[java.util.Date])
   }
 
@@ -158,7 +167,7 @@ class RichGraphNodeTest {
   def literalLanguage = {
     node = new GraphNode(greetingsUri, mGraph)
     val lang = new Language("en")
-    val enValue = (node/RDF.value).find(l=>(l!).asInstanceOf[PlainLiteral].getLanguage
== lang).get
+    val enValue = (node/RDF.value).find(l=>(l!).asInstanceOf[Literal].getLanguage == lang).get
     Assert.assertEquals("hello", enValue*)
   }
 

http://git-wip-us.apache.org/repos/asf/clerezza/blob/68a05975/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala
----------------------------------------------------------------------
diff --git a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala
b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala
index 6190d4e..5798e86 100644
--- a/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala
+++ b/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/TypeConversionTest.scala
@@ -18,10 +18,13 @@ package org.apache.clerezza.rdf.scala.utils
  * specific language governing permissions and limitations
  * under the License.
  */
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf.Language
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl
+import org.apache.commons.rdf.impl.utils.TripleImpl
+import org.apache.commons.rdf.impl.utils.TypedLiteralImpl
 import org.junit._
 import org.apache.clerezza.rdf.core._
-import impl.{TripleImpl, PlainLiteralImpl, TypedLiteralImpl}
-import com.sun.xml.internal.ws.developer.MemberSubmissionAddressing.Validation
 
 class TypeConversionTest {
 
@@ -31,27 +34,27 @@ class TypeConversionTest {
 
   @Test
   def useStringAsObject {
-    val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")),
"a value")
+    val t = new TripleImpl(new Iri(("http://example.org/subject")), new Iri(("http://example.org/predicate")),
"a value")
     Assert.assertEquals(literalFactory.createTypedLiteral("a value"), t.getObject)
   }
 
   /*@Test
   def useStringWithLanguageTag {
-    val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")),
"a value"("en"))
+    val t = new TripleImpl(new Iri(("http://example.org/subject")), new Iri(("http://example.org/predicate")),
"a value"("en"))
     Assert.assertEquals(new PlainLiteralImpl("a value", new Language("en")), t.getObject)
   }*/
 
   @Test
   def useStringWithLanguageTag {
      val lit = new PlainLiteralImpl("a value", new Language("en"))
-    val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")),
"a value" lang "en")
+    val t = new TripleImpl(new Iri(("http://example.org/subject")), new Iri(("http://example.org/predicate")),
"a value" lang "en")
     Assert.assertEquals(lit, t.getObject)
   }
 
   @Test
   def useStringWithType {
-    val typeUri = new UriRef("http://example.org/dt")
-    val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")),
"a value"^^typeUri)
+    val typeUri = new Iri("http://example.org/dt")
+    val t = new TripleImpl(new Iri(("http://example.org/subject")), new Iri(("http://example.org/predicate")),
"a value"^^typeUri)
     Assert.assertEquals(new TypedLiteralImpl("a value", typeUri), t.getObject)
   }
 
@@ -64,8 +67,8 @@ class TypeConversionTest {
 
   @Test
   def dotUri {
-    val t = new TripleImpl(new UriRef(("http://example.org/subject")), new UriRef(("http://example.org/predicate")),
"http://example.org".uri)
-    Assert.assertEquals(new UriRef("http://example.org"), t.getObject)
+    val t = new TripleImpl(new Iri(("http://example.org/subject")), new Iri(("http://example.org/predicate")),
"http://example.org".iri)
+    Assert.assertEquals(new Iri("http://example.org"), t.getObject)
   }
 
 }


Mime
View raw message