Author: bblfish
Date: Fri Jul  1 18:36:37 2011
New Revision: 1142019

URL: http://svn.apache.org/viewvc?rev=1142019&view=rev
Log:
CLEREZZA-510 EzGraph extends AbstractMGraph - reto showed the way, so that's ok 
for me here.

Modified:
    
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
    
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
    
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala

Modified: 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala?rev=1142019&r1=1142018&r2=1142019&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
 Fri Jul  1 18:36:37 2011
@@ -198,7 +198,7 @@ class CertTester(subj: Subject, webIdGra
                                                     -- EARL.outcome --> {if 
(eC) EARL.passed else EARL.failed})
                        )
                if (eC) ass -- EARL.subject -->> x509claimRefs.map(p => p._1)
-               else return g.graph
+               else return g
 
 
                //
@@ -692,7 +692,7 @@ class Assertor {
                for (test <- assertions) {
                        test.toRdf()
                }
-               g.graph
+               g
        }
 
        class Assertion(testName: UriRef,

Modified: 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala?rev=1142019&r1=1142018&r2=1142019&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EzGraph.scala
 Fri Jul  1 18:36:37 2011
@@ -122,15 +122,22 @@ object EzStyleChoice {
  * @created: 20/04/2011
  */
 //todo: should this take a TripleCollection or a Set[Triple]
-class EzGraph(val graph: TripleCollection) {
+class EzGraph(val baseTc: TripleCollection) extends AbstractMGraph {
 
        def this() = this (new SimpleMGraph())
 
+       def performFilter(subject: NonLiteral, predicate: UriRef,
+                       obj: Resource): java.util.Iterator[Triple] = 
baseTc.filter(subject, predicate, obj)
+
+       override def size = baseTc.size
+
+       override def add(t: Triple) = baseTc.add(t)
+
        /**
         * Add all triples into the other graph to this one
         */
        def +=(other: Graph) = {
-               if (graph ne other) graph.addAll(other)
+               if (baseTc ne other) baseTc.addAll(other)
        }
 
        /**
@@ -140,18 +147,18 @@ class EzGraph(val graph: TripleCollectio
                node(new BNode)(writingStyle)
        }
 
-       val namedBnodes = new HashMap[String,BNode]
+       protected 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,graph)
+                       case Some(bnode) => writingStyle.preferred(bnode,baseTc)
                        case None => {
                                val bn = new BNode
                                namedBnodes.put(name, bn);
-                               writingStyle.preferred(bn,graph)
+                               writingStyle.preferred(bn,baseTc)
                        }
                }
        }
@@ -168,7 +175,7 @@ class EzGraph(val graph: TripleCollectio
         * The EzGraphNode will contain the graph that this EzGraph is built on 
and point to the given subj
         */
        def node[T<: EzGraphNode](subj: NonLiteral)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.arrow ): T = {
-               writingStyle.preferred(subj,graph)
+               writingStyle.preferred(subj,baseTc)
        }
 
        /**
@@ -179,8 +186,8 @@ class EzGraph(val graph: TripleCollectio
         * @return this, to making method chaining easier
         */
        def add(subj: NonLiteral, relation: UriRef, obj: Resource ) = {
-               graph.add(new TripleImpl(subj,relation,obj))
-               graph
+               baseTc.add(new TripleImpl(subj,relation,obj))
+               baseTc
        }
 
        /**
@@ -190,8 +197,8 @@ class EzGraph(val graph: TripleCollectio
         * @return this, to making method chaining easier
         */
        def addType(subj: NonLiteral, clazz: UriRef) = {
-               graph.add(new TripleImpl(subj,RDF.`type`,clazz))
-               graph
+               baseTc.add(new TripleImpl(subj,RDF.`type`,clazz))
+               baseTc
        }
 
 

Modified: 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala?rev=1142019&r1=1142018&r2=1142019&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EzGraphTest.scala
 Fri Jul  1 18:36:37 2011
@@ -91,8 +91,8 @@ class EzGraphTest {
                val ez = EzGraph()
                ez.bnode ∈ FOAF.Person
 
-               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.graph.size())
-               Assert.assertEquals("the two graphs should be 
equals",gr.getGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.size())
+               Assert.assertEquals("the two graphs should be 
equals",gr.getGraph,ez.getGraph) //mutable graphs cannot be compared for 
equality
 
        }
 
@@ -124,8 +124,8 @@ class EzGraphTest {
                ( ez.u(retoUri) ∈ FOAF.Person
                            ⟝ todoRef ⟶ List[Resource]("SPARQL update 
support".lang(en),"XSPARQL support".lang(en),holiday.uri))
 
-               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.size())
+               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,ez.getGraph) //mutable graphs cannot be compared for 
equality
 
        }
 
@@ -141,14 +141,14 @@ class EzGraphTest {
                //default style is now arrow
                (ez.u(retoUri) -- FOAF.knows -->> 
List(henryUri.uri,danbriUri.uri))
 
-               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez.size())
+               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,ez.getGraph) //mutable graphs cannot be compared for 
equality
 
                val ez2 = EzGraph()
                (ez2.u(retoUri)(EzStyleChoice.unicode) ⟝  FOAF.knows ⟶*  
Set(danbriUri.uri,henryUri.uri))
 
-               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez2.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,new SimpleGraph(ez2.graph)) //mutable graphs cannot 
be compared for equality
+               Assert.assertEquals("the two graphs should be of same 
size",gr.size(),ez2.size())
+               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,ez2.getGraph) //mutable graphs cannot be compared for 
equality
 
        }
 
@@ -200,7 +200,7 @@ class EzGraphTest {
 
                (ez.bnode ⟝  OWL.sameAs ⟶  
(n3^^"http://example.com/turtle".uri))
 
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               Assert.assertEquals("Both graphs should contain exactly the 
same triples",gr.getGraph,ez.getGraph) //mutable graphs cannot be compared for 
equality
 
        }
 
@@ -252,10 +252,10 @@ class EzGraphTest {
                                            ⟝ FOAF.knows ⟶ ez.b_("reto")
                         )
                 )
-               Assert.assertEquals("the two graphs should be of same 
size",tinyGraph.size(),ez.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",tinyGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               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) //mutable graphs cannot be compared for 
equality
                ez.b_("danny") ⟝  FOAF.name ⟶  "George"
-               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal", tinyGraph,ez.graph)
+               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal", tinyGraph,ez.getGraph)
        }
 
        @Test
@@ -287,10 +287,10 @@ class EzGraphTest {
                                            -- FOAF.knows --> ez.b_("reto")
                         )
                 )
-               Assert.assertEquals("the two graphs should be of same 
size",tinyGraph.size(),ez.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",tinyGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               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) //mutable graphs cannot be compared for 
equality
                ez.b_("danny") -- FOAF.name --> "George"
-               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal",tinyGraph,new SimpleGraph(ez.graph))
+               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal",tinyGraph,ez.getGraph)
 
        }
 
@@ -325,10 +325,10 @@ class EzGraphTest {
                                            has FOAF.knows to ez.b_("reto")
                         )
                 )
-               Assert.assertEquals("the two graphs should be of same 
size",tinyGraph.size(),ez.graph.size())
-               Assert.assertEquals("Both graphs should contain exactly the 
same triples",tinyGraph,new SimpleGraph(ez.graph)) //mutable graphs cannot be 
compared for equality
+               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) //mutable graphs cannot be compared for 
equality
                ez.b_("danny") has FOAF.name to "George"
-               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal",tinyGraph,new SimpleGraph(ez.graph))
+               Assert.assertNotSame("Added one more triple, so graphs should 
no longer be equal",tinyGraph,ez.getGraph)
 
        }
 


Reply via email to