Author: bblfish
Date: Wed Jun 29 23:07:08 2011
New Revision: 1141311

URL: http://svn.apache.org/viewvc?rev=1141311&view=rev
Log:
CLEREZZA-510: renamed EasyGraphNode to the shorter EzGraphNode, and added an 
Object so that creating an EzGraphNode no longer requires "new". Fixed a couple 
of bugs introduced by previous changes in other packages.

Modified:
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
    
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
    
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/EasyGraph.scala
    
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala?rev=1141311&r1=1141310&r2=1141311&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/PingBack.scala
 Wed Jun 29 23:07:08 2011
@@ -25,7 +25,6 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.platform.Constants
 import java.security.{PrivilegedAction, AccessController}
 import javax.ws.rs.core.{Response, Context, UriInfo}
-import org.apache.clerezza.rdf.scala.utils.{EasyGraphNode, EasyGraph}
 import java.net._
 import org.slf4j.scala.Logger
 import javax.ws.rs._
@@ -35,6 +34,7 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.clerezza.rdf.core.{UriRef, MGraph}
 import org.apache.clerezza.rdf.utils.{UnionMGraph, GraphNode}
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph
+import org.apache.clerezza.rdf.scala.utils.{EzGraphNodeU, EzStyleChoice, 
EzGraphNode, EasyGraph}
 
 object PingBack {
        private val log: Logger = Logger(classOf[PingBack])
@@ -88,6 +88,7 @@ object PingBack {
 class PingBack {
 
        import PingBack._
+       import EzStyleChoice.unicode
 
        protected def activate(componentContext: ComponentContext): Unit = {
        }
@@ -98,7 +99,7 @@ class PingBack {
         * @param id: the user id
         * @param uriInfo jax-rs info
         */
-       def  pingCollection(id: String, uriInfo: UriInfo): EasyGraphNode = {
+       def  pingCollection(id: String, uriInfo: UriInfo): EzGraphNodeU = {
                val pingRef = new UriRef(pingCollUri(id, uriInfo))
                val pingCollG: EasyGraph = pingColl(pingRef)
                pingCollG(pingRef)
@@ -310,7 +311,7 @@ class PingBack {
        @Path("{item}")
        def viewPing(@Context uriInfo: UriInfo,
                                         @PathParam("id") id: String,
-                                        @PathParam("item") item: String): 
EasyGraphNode = {
+                                        @PathParam("item") item: String): 
EzGraphNode = {
 
                //ITS the wrong ping collection!!!
 

Modified: 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala?rev=1141311&r1=1141310&r2=1141311&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.accountcontrolpanel/platform.accountcontrolpanel.core/src/main/scala/org/apache/clerezza/platform/accountcontrolpanel/ProfilePanel.scala
 Wed Jun 29 23:07:08 2011
@@ -50,13 +50,12 @@ import java.security.PrivilegedAction
 import java.security.interfaces.RSAPublicKey
 import org.apache.clerezza.ssl.keygen.KeygenService
 import java.net.URI
-import org.apache.clerezza.rdf.scala.utils.{RichGraphNode, EasyGraphNode, 
EasyGraph}
 import org.apache.clerezza.rdf.core.access.security.TcPermission
 import org.apache.clerezza.rdf.ontologies._
 import org.slf4j.scala.Logging
 import javax.security.auth.Subject
 import org.apache.clerezza.platform.users.{WebIdInfo, WebIdGraphsService}
-
+import org.apache.clerezza.rdf.scala.utils._
 
 object ProfilePanel {
        val webIdTemplate = 
classOf[ProfilePanel].getAnnotation(classOf[Path]).value+"#me"
@@ -84,6 +83,7 @@ class ProfilePanel extends Logging {
 
        import collection.JavaConversions._
        import EasyGraph._
+       import EzStyleChoice.unicode
 
 
        @GET
@@ -96,11 +96,11 @@ class ProfilePanel extends Logging {
        }
 
        //todo: there is a bit of repetition in the graphs, and it is not clear 
why these relations should not go straight into the DB. What should, what 
should not?
-       private def getPersonalProfile(userName: String, info: UriInfo): 
EasyGraphNode = {
+       private def getPersonalProfile(userName: String, info: UriInfo): 
EzGraphNode = {
                val profileDocUri = getSuggestedPPDUri(userName)
 
-               val profile = AccessController.doPrivileged(new 
PrivilegedAction[EasyGraphNode] {
-                       def run: EasyGraphNode = {
+               val profile = AccessController.doPrivileged(new 
PrivilegedAction[EzGraphNodeU] {
+                       def run: EzGraphNodeU = {
                                val userInSysGraph = 
userManager.getUserInSystemGraph(userName)
                                val user = userInSysGraph.getNode
                                val profile = userInSysGraph.getNode match {
@@ -115,7 +115,7 @@ class ProfilePanel extends Logging {
                                        }
                                        case webid: UriRef => {
                                                var webIDInfo = 
webIdGraphsService.getWebIdInfo(webid)
-                                               var res = new 
EasyGraphNode(profileDocUri, new UnionMGraph(new SimpleMGraph, 
webIDInfo.localPublicUserData))
+                                               var res = 
EzGraphNode(profileDocUri, new UnionMGraph(new SimpleMGraph, 
webIDInfo.localPublicUserData))
                                                (res ⟝ 
CONTROLPANEL.isLocalProfile ⟶ webIDInfo.isLocal
                                                        ⟝ FOAF.primaryTopic 
⟶ webid)
                                                if (webIDInfo.isLocal) {

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=1141311&r1=1141310&r2=1141311&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
 Wed Jun 29 23:07:08 2011
@@ -601,7 +601,7 @@ class CertTester(subj: Subject, webIdGra
                        sout.serialize(out, graph, "text/rdf+n3")
                        val n3String = out.toString("UTF-8")
                        //todo: turtle mime type literal?
-                       val keylit: EasyGraphNode = g.bnode ⟝  OWL.sameAs ⟶ 
(n3String^^"http://example.com/turtle".uri)
+                       val keylit: EzGraphNode = g.bnode ⟝  OWL.sameAs ⟶ 
(n3String^^"http://example.com/turtle".uri)
 
 
                        //
@@ -708,7 +708,7 @@ class Assertor {
                        new TstResult
                }
 
-               def toRdf(): EasyGraphNode = (
+               def toRdf(): EzGraphNode = (
                        g.bnode ∈ EARL.Assertion
                                ⟝ EARL.test ⟶ testName
                                ⟝ EARL.result ⟶ result.toRdf()
@@ -740,7 +740,7 @@ class Assertor {
                }
 
 
-               def toRdf(): EasyGraphNode =  (
+               def toRdf(): EzGraphNode =  (
                                g.bnode ∈ EARL.TestResult
                                        ⟝ DC.description ⟶ description
                                        ⟝ EARL.outcome ⟶ outcome

Modified: 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala?rev=1141311&r1=1141310&r2=1141311&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
 Wed Jun 29 23:07:08 2011
@@ -99,7 +99,7 @@ class EzLiteral(lexicalForm: String) ext
        override def toString() = lexicalForm
 }
 
-abstract class EzStyle[T<:EasyGraphNode]() {
+abstract class EzStyle[T<:EzGraphNode]() {
        def preferred(ref: NonLiteral, tc: TripleCollection):T
 }
 
@@ -144,12 +144,12 @@ class EasyGraph(val graph: HashSet[Tripl
                if (graph ne other) graph.addAll(other)
        }
 
-       def bnode[T<: EasyGraphNode](implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode ): T = {
+       def bnode[T<: EzGraphNode](implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode ): T = {
                apply(new BNode)(writingStyle)
        }
 
        val namedBnodes = new HashMap[String,BNode]
-       def b_[T<: EasyGraphNode](name: String)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode): T = {
+       def b_[T<: EzGraphNode](name: String)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode): T = {
                namedBnodes.get(name) match {
                        case Some(bnode) => writingStyle.preferred(bnode,this)
                        case None => {
@@ -160,11 +160,11 @@ class EasyGraph(val graph: HashSet[Tripl
                }
        }
 
-       def u[T<: EasyGraphNode](url: String)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode): T = {
+       def u[T<: EzGraphNode](url: String)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode): T = {
                apply(new UriRef(url))(writingStyle)
        }
 
-       def apply[T<: EasyGraphNode](subj: NonLiteral)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode ): T = {
+       def apply[T<: EzGraphNode](subj: NonLiteral)(implicit writingStyle: 
EzStyle[T]=EzStyleChoice.unicode ): T = {
                writingStyle.preferred(subj,this)
        }
 
@@ -195,7 +195,7 @@ class EasyGraph(val graph: HashSet[Tripl
 }
 
 /**
- * Unicode arrow notation for EasyGraphNode. Very clean, short and efficient, 
but unicode values may not
+ * Unicode arrow notation for EzGraphNode. Very clean, short and efficient, 
but unicode values may not
  * be available everywhere yet.
  *
  * Because of operator binding rules all the mathematical operators  bind the 
strongest. This means that
@@ -203,10 +203,10 @@ class EasyGraph(val graph: HashSet[Tripl
  * bind more tightly.
  *
  *
- * @prefix graph: should this be an MGraph, since the EasyGraphNode is really 
designed for editing
+ * @prefix graph: should this be an MGraph, since the EzGraphNode is really 
designed for editing
  *
  */
-class EzGraphNodeU(ref: NonLiteral, graph: TripleCollection) extends 
EasyGraphNode(ref, graph) {
+class EzGraphNodeU(ref: NonLiteral, graph: TripleCollection) extends 
EzGraphNode(ref, graph) {
        //
        // symbolic notation
        //
@@ -258,7 +258,7 @@ class EzGraphNodeU(ref: NonLiteral, grap
                 */
                def ⟶*[T <: Resource](objs: Iterable[T]) = addMany(objs)
 
-               def ⟶(sub: EasyGraphNode) = addEG(sub)
+               def ⟶(sub: EzGraphNode) = addEG(sub)
 
        }
 
@@ -266,7 +266,7 @@ class EzGraphNodeU(ref: NonLiteral, grap
 }
 
 /**
- * Ascii Arrow notation for EasyGraphNode. This is easy to write using an 
ascii keyboard but because
+ * Ascii Arrow notation for EzGraphNode. This is easy to write using an ascii 
keyboard but because
  * of operator precedence rules, some operators will have higher and some 
lower precedence to these
  * meaning that one has to keep in mind these rules:
  *
@@ -294,7 +294,7 @@ class EzGraphNodeU(ref: NonLiteral, grap
     ending in a colon ‘:’ are right-associative. All other operators are 
leftassociative.
  </blockquote>
  */
-class EzGraphNodeA(ref: NonLiteral, graph: TripleCollection) extends 
EasyGraphNode(ref, graph) {
+class EzGraphNodeA(ref: NonLiteral, graph: TripleCollection) extends 
EzGraphNode(ref, graph) {
 
        type T_Pred = PredicateA
        type T_InvP = InversePredicateA
@@ -327,7 +327,7 @@ class EzGraphNodeA(ref: NonLiteral, grap
                 */
                def -->(list: List[Resource]) = addList(list)
 
-               def -->(sub: EasyGraphNode) = addEG(sub)
+               def -->(sub: EzGraphNode) = addEG(sub)
 
                /**
                 * Add one relation for each member of the iterable collection
@@ -340,19 +340,19 @@ class EzGraphNodeA(ref: NonLiteral, grap
        class InversePredicateA(ref: UriRef) extends InversePredicate(ref) {
                def --(subj: NonLiteral) = add(subj)
                def --(subj: String) = add(new UriRef(subj))
-               def --(subj: EasyGraphNode) = addGN(subj)
+               def --(subj: EzGraphNode) = addGN(subj)
                // since we can only have inverses from non literals (howto 
deal with bndoes?)
        }
 
 }
 
 /**
- * English language looking Notation for EasyGraphNode. This feels gives 
somewhat awkward
+ * English language looking Notation for EzGraphNode. This feels gives 
somewhat awkward
  * english, but the operator binding priorities for ascii named operators is 
the weakest, which
  * means that one needs very few parenthesis when writing out the code as all 
other operators bind
  * more tightly.
  */
-class EzGraphNodeEn(ref: NonLiteral, graph: TripleCollection) extends 
EasyGraphNode(ref, graph) {
+class EzGraphNodeEn(ref: NonLiteral, graph: TripleCollection) extends 
EzGraphNode(ref, graph) {
 
        type T_Pred = PredicateEn
        type T_InvP = InversePredicateEn
@@ -376,7 +376,7 @@ class EzGraphNodeEn(ref: NonLiteral, gra
 
                def of(subj: NonLiteral) = add(subj)
                def of(subj: String) = add(new UriRef(subj))
-               def of(subj: EasyGraphNode) = addGN(subj)
+               def of(subj: EzGraphNode) = addGN(subj)
        }
 
        class PredicateEn(rel: UriRef) extends Predicate(rel) {
@@ -397,30 +397,36 @@ class EzGraphNodeEn(ref: NonLiteral, gra
                 */
                def toEach[T <: Resource](objs: Iterable[T]) = addMany(objs)
 
-               def to(sub: EasyGraphNode) = addEG(sub)
+               def to(sub: EzGraphNode) = addEG(sub)
 
        }
 
 }
 
+object EzGraphNode {
+       def apply[T<:EzGraphNode](ref: NonLiteral, graph: 
TripleCollection)(implicit writingStyle: EzStyle[T]=EzStyleChoice.unicode ): T 
= {
+               writingStyle.preferred(ref,graph)
+       }
+}
+
 /**
- * EasyGraphNode. Create instances from an EasyGraph object. Differnt 
notations implementations can be used.
+ * EzGraphNode. Create instances from an EasyGraph object. Differnt notations 
implementations can be used.
  */
-abstract class EasyGraphNode(val ref: NonLiteral, val graph: TripleCollection) 
extends GraphNode(ref, graph) {
+abstract class EzGraphNode(val ref: NonLiteral, val graph: TripleCollection) 
extends GraphNode(ref, graph) {
 
 //     lazy val easyGraph = graph match {
 //             case eg: EasyGraph => eg
 //             case other: TripleCollection => new EasyGraph(graph)
 //     }
 
-       def +(sub: EasyGraphNode) = {
+       def +(sub: EzGraphNode) = {
                if (graph ne sub.graph) graph.addAll(sub.graph)
                this
        }
 
        type T_Pred <: Predicate
        type T_InvP <: InversePredicate
-       type T_EzGN <: EasyGraphNode
+       type T_EzGN <: EzGraphNode
 
        protected def predicate(rel: UriRef): T_Pred
        protected def inverse(rel: UriRef): T_InvP
@@ -433,7 +439,7 @@ abstract class EasyGraphNode(val ref: No
        def make(ref: NonLiteral, graph: TripleCollection): T_EzGN
 
        /*
-        * create an EasyGraphNode from this one where the backing graph is 
protected from writes by a new
+        * create an EzGraphNode from this one where the backing graph is 
protected from writes by a new
         * SimpleGraph.
         */
        def protect(): T_EzGN = make(ref, new UnionMGraph(new SimpleMGraph(), 
graph))
@@ -444,14 +450,14 @@ abstract class EasyGraphNode(val ref: No
 
        abstract class InversePredicate(rel: UriRef) {
 
-               protected def addGN(subj: EasyGraphNode) = {
-                       EasyGraphNode.this + subj
+               protected def addGN(subj: EzGraphNode) = {
+                       EzGraphNode.this + subj
                        add(subj.ref)
                }
 
                protected def add(subj: NonLiteral) = {
                        graph.add(new TripleImpl(subj, rel, ref))
-                       EasyGraphNode.this.asInstanceOf[T_EzGN]
+                       EzGraphNode.this.asInstanceOf[T_EzGN]
                }
        }
 
@@ -459,7 +465,7 @@ abstract class EasyGraphNode(val ref: No
 
                protected def add(obj: Resource): T_EzGN = {
                        addTriple(obj)
-                       EasyGraphNode.this.asInstanceOf[T_EzGN]
+                       EzGraphNode.this.asInstanceOf[T_EzGN]
                }
 
                protected def addTriple(obj: Resource) {
@@ -468,11 +474,11 @@ abstract class EasyGraphNode(val ref: No
 
                protected def addMany[T<:Resource](uris: Iterable[T]): T_EzGN = 
{
                        for (u <- uris) addTriple(u)
-                       EasyGraphNode.this.asInstanceOf[T_EzGN]
+                       EzGraphNode.this.asInstanceOf[T_EzGN]
                }
 
-               protected def addEG(sub: EasyGraphNode): T_EzGN = {
-                       EasyGraphNode.this + sub
+               protected def addEG(sub: EzGraphNode): T_EzGN = {
+                       EzGraphNode.this + sub
                        add(sub.ref)
                }
 
@@ -507,7 +513,7 @@ abstract class EasyGraphNode(val ref: No
                   val tripleLst = toTriples(headNode,list);
                        graph.add(new TripleImpl(headNode,RDF.`type`,RDF.List))
                        
graph.addAll(collection.JavaConversions.asJavaCollection(tripleLst))
-                       EasyGraphNode.this.asInstanceOf[T_EzGN]
+                       EzGraphNode.this.asInstanceOf[T_EzGN]
                }
 
        }

Modified: 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala?rev=1141311&r1=1141310&r2=1141311&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/test/scala/org/apache/clerezza/rdf/scala/utils/EasyGraphTest.scala
 Wed Jun 29 23:07:08 2011
@@ -196,7 +196,7 @@ class EasyGraphTest {
                import org.apache.clerezza.rdf.scala.utils.Lang._
                val ez = new EasyGraph()
 
-               val res : EasyGraphNode = (ez.bnode ⟝  OWL.sameAs ⟶  
(n3^^"http://example.com/turtle".uri))
+               val res : EzGraphNode = (ez.bnode ⟝  OWL.sameAs ⟶  
(n3^^"http://example.com/turtle".uri))
 
                Assert.assertEquals("the two graphs must be 
equal",gr.getGraph,ez.getGraph)
 


Reply via email to