You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2011/07/01 00:19:55 UTC
svn commit: r1141739 - in
/incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src:
main/scala/org/apache/clerezza/rdf/scala/utils/
test/scala/org/apache/clerezza/rdf/scala/utils/
Author: reto
Date: Thu Jun 30 22:19:54 2011
New Revision: 1141739
URL: http://svn.apache.org/viewvc?rev=1141739&view=rev
Log:
CLEREZZA-510: re-enabled usingAsciiArrows test using RichGraphNodes and simplified EzGraph
Modified:
incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala
Modified: incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala?rev=1141739&r1=1141738&r2=1141739&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala (original)
+++ incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala Thu Jun 30 22:19:54 2011
@@ -63,27 +63,27 @@ class EzGraph(val baseTc: MGraph) extend
}
/**
- * create a new bnode based EzGraphNode with the preferred writing style
+ * create a new bnode
*/
-// def bnode[T<: EzGraphNode](implicit writingStyle: EzStyle[T]=EzStyleChoice.arrow ): T = {
-// node(new BNode)(writingStyle)
-// }
+ def bnode: BNode = {
+ new BNode
+ }
//
-// val namedBnodes = new HashMap[String,BNode]
+ val namedBnodes = new HashMap[String,BNode]
//
-// /**
-// * create a new named bnode based EzGraphNode with the preferred writing style
-// */
-// def b_[T<: EzGraphNode](name: String)(implicit writingStyle: EzStyle[T]=EzStyleChoice.arrow): T = {
-// namedBnodes.get(name) match {
-// case Some(bnode) => writingStyle.preferred(bnode,baseTc)
-// case None => {
-// val bn = new BNode
-// namedBnodes.put(name, bn);
-// writingStyle.preferred(bn,baseTc)
-// }
-// }
-// }
+ /**
+ * create a new named bnode based EzGraphNode with the preferred writing style
+ */
+ def b_(name: String): BNode = {
+ namedBnodes.get(name) match {
+ case Some(bnode) => bnode
+ case None => {
+ val bn = new BNode
+ namedBnodes.put(name, bn);
+ bn
+ }
+ }
+ }
// /**
// * create a new url based EzGraphNode with the preferred writing style
@@ -100,28 +100,28 @@ class EzGraph(val baseTc: MGraph) extend
// writingStyle.preferred(subj,baseTc)
// }
- /**
- * Add a a relation
- * @param subj: subject of relation
- * @param relation: relation
- * @param: obj: the object of the statement
- * @return this, to making method chaining easier
- */
- def add(subj: NonLiteral, relation: UriRef, obj: Resource ) = {
- baseTc.add(new TripleImpl(subj,relation,obj))
- baseTc
- }
-
- /**
- * Add a type relation for the subject
- * @param subj: the subject of the relation
- * @param clazz: the rdfs:Class the subject is an instance of
- * @return this, to making method chaining easier
- */
- def addType(subj: NonLiteral, clazz: UriRef) = {
- baseTc.add(new TripleImpl(subj,RDF.`type`,clazz))
- baseTc
- }
+// /**
+// * Add a a relation
+// * @param subj: subject of relation
+// * @param relation: relation
+// * @param: obj: the object of the statement
+// * @return this, to making method chaining easier
+// */
+// def add(subj: NonLiteral, relation: UriRef, obj: Resource ) = {
+// baseTc.add(new TripleImpl(subj,relation,obj))
+// baseTc
+// }
+//
+// /**
+// * Add a type relation for the subject
+// * @param subj: the subject of the relation
+// * @param clazz: the rdfs:Class the subject is an instance of
+// * @return this, to making method chaining easier
+// */
+// def addType(subj: NonLiteral, clazz: UriRef) = {
+// baseTc.add(new TripleImpl(subj,RDF.`type`,clazz))
+// baseTc
+// }
}
@@ -231,7 +231,7 @@ class EzGraph(val baseTc: MGraph) extend
/**
* EzGraphNode. Create instances from an EzGraph object. Differnt notations implementations can be used.
*/
-abstract class EzGraphNode(val ref: NonLiteral, val graph: TripleCollection) extends RichGraphNode(ref, graph) {
+//abstract class EzGraphNode(val ref: NonLiteral, val graph: TripleCollection) extends RichGraphNode(ref, graph) {
// lazy val easyGraph = graph match {
// case eg: EzGraph => eg
@@ -249,7 +249,7 @@ abstract class EzGraphNode(val ref: NonL
-}
+//}
//object EzGraphNode {
// /**
Modified: incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala?rev=1141739&r1=1141738&r2=1141739&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala (original)
+++ incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/RichGraphNode.scala Thu Jun 30 22:19:54 2011
@@ -183,7 +183,7 @@ class RichGraphNode(resource: Resource,
//TODO add support for adding many for symmetry reasons
class InversePredicate(rel: UriRef) {
- protected def add(subj: RichGraphNode): RichGraphNode = {
+ protected def add(subj: GraphNode): RichGraphNode = {
//RichGraphNode.this + subj
add(subj.getNode.asInstanceOf[NonLiteral])
}
@@ -206,7 +206,7 @@ class RichGraphNode(resource: Resource,
* ...to the following EzGraphNode
* (useful for opening a new parenthesis and specifying other things in more detail
*/
- def --(subj: EzGraphNode) = add(subj)
+ def --(subj: GraphNode) = add(subj)
// since we can only have inverses from non literals (howto deal with bndoes?)
}
Modified: incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala
URL: http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala?rev=1141739&r1=1141738&r2=1141739&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala (original)
+++ incubator/clerezza/issues/CLEREZZA-510-reto/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala Thu Jun 30 22:19:54 2011
@@ -92,7 +92,7 @@ class EzGraphTest {
val ez = new EzGraph() {
henryUri.uri -- FOAF.knows --> retoUri.uri
}
- Assert.assertEquals("The wto graphs should be equals", expected, ez.getGraph)
+ Assert.assertEquals("The two graphs should be equals", expected, ez.getGraph)
}
// @Test
@@ -270,40 +270,37 @@ class EzGraphTest {
// Assert.assertFalse("Added one more triple, so graphs should no longer be equal", tinyGraph == ez.getGraph)
// }
//
-// @Test
-// def usingAsciiArrows {
-// import org.apache.clerezza.rdf.scala.utils.EzGraph._
-// import EzStyleChoice.arrow
-// val ez = EzGraph()
-// // example using arrows
-// (
-// ez.b_("reto").a(FOAF.Person)
-// -- FOAF.name --> "Reto Bachman-Gmür".lang('rm)
-// -- FOAF.title --> "Mr"
-// -- FOAF.currentProject --> "http://clerezza.org/".uri
-// -- FOAF.knows --> (
-// ez.u("http://bblfish.net/#hjs").a(FOAF.Person)
-// -- FOAF.name --> "Henry Story"
-// -- FOAF.currentProject --> "http://webid.info/".uri
-// -<- identity -- (
-// ez.bnode.a(RSAPublicKey) //. notation because of precedence of operators
-// -- modulus --> 65537
-// -- public_exponent --> (bblfishModulus^^hex) // brackets needed due to precedence
-// )
-// -- FOAF.knows -->> List(ez.b_("reto").ref,ez.b_("danny").ref)
-// )
-// -- FOAF.knows --> (ez.b_("danny").a(FOAF.Person)
-// -- FOAF.name --> "Danny Ayers".lang('en)
-// -- FOAF.knows --> "http://bblfish.net/#hjs".uri //knows
-// -- FOAF.knows --> ez.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)
-// ez.b_("danny") -- FOAF.name --> "George"
-// //Assert.assertNotSame("Added one more triple, so graphs should no longer be equal",tinyGraph,ez.graph)
-//
-// }
+ @Test
+ def usingAsciiArrows {
+ 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.knows --> (
+ "http://bblfish.net/#hjs".uri.a(FOAF.Person)
+ -- FOAF.name --> "Henry Story"
+ -- FOAF.currentProject --> "http://webid.info/".uri
+ -<- identity -- (
+ bnode.a(RSAPublicKey) //. notation because of precedence of operators
+ -- modulus --> 65537
+ -- public_exponent --> (bblfishModulus^^hex) // brackets needed due to precedence
+ )
+ -- FOAF.knows -->> List(b_("reto"), b_("danny"))
+ ) --
+ FOAF.knows --> (b_("danny").a(FOAF.Person) --
+ FOAF.name --> "Danny Ayers".lang('en)
+ -- FOAF.knows --> "http://bblfish.net/#hjs".uri //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)
+ import ez._
+ ez.b_("danny") -- FOAF.name --> "George"
+ //Assert.assertNotSame("Added one more triple, so graphs should no longer be equal",tinyGraph,ez.graph)
+
+ }
//
//
// @Test