clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bblf...@apache.org
Subject svn commit: r1124410 - /incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
Date Wed, 18 May 2011 20:36:36 GMT
Author: bblfish
Date: Wed May 18 20:36:36 2011
New Revision: 1124410

URL: http://svn.apache.org/viewvc?rev=1124410&view=rev
Log:
CLEREZZA-510: deprecate the class so that people are warned of potential changes. This is
the inverse of deprecation really. It should perhaps be called "unstable" like in rdf ontologies.
But the point is to make sure people who try it out give feedback, and don't complain if some
of the feedback is then acted on later.

Modified:
    incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala

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=1124410&r1=1124409&r2=1124410&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 May 18 20:36:36 2011
@@ -23,9 +23,12 @@ import org.apache.clerezza.rdf.core._
 import impl._
 import org.apache.clerezza.rdf.ontologies.RDF
 import java.math.BigInteger
-import org.apache.clerezza.rdf.utils.{UnionMGraph, GraphNode}
 import java.util.Date
 import java.lang.Boolean
+import java.net.{URL, URI}
+import org.apache.clerezza.rdf.core._
+import reflect.Apply
+import org.apache.clerezza.rdf.utils.{UnionMGraph, GraphNode}
 
 object EasyGraph {
 
@@ -51,6 +54,10 @@ object EasyGraph {
 
 	implicit def uriRef2Prefix(uriRef: UriRef) = new NameSpace(uriRef.getUnicodeString)
 
+	implicit def URItoUriRef(uri: URI) = new UriRef(uri.toString)
+
+	implicit def URLtoUriRef(url: URL) = new UriRef(url.toExternalForm)
+
 
 	//	val g = new EasyGraph(new SimpleMGraph)
 	//	val sub = g.bnode
@@ -124,6 +131,8 @@ class PlainLiteralScala(string: String) 
  * @created: 20/04/2011
  */
 
+@deprecated("Don't use yet other than for trying out this class as it may be merged with
another class or changed dramatically." +
+	" Send feedback to CLEREZZA-510. ")
 class EasyGraph(val graph: TripleCollection) extends SimpleMGraph(graph) {
 
 	/*
@@ -144,6 +153,29 @@ class EasyGraph(val graph: TripleCollect
 
 	def apply(subj: NonLiteral) = new EasyGraphNode(subj, this)
 
+	/**
+	 * 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 ) = {
+		graph.add(new TripleImpl(subj,relation,obj))
+		graph
+	}
+
+	/**
+	 * 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) = {
+		graph.add(new TripleImpl(subj,RDF.`type`,clazz))
+		graph
+	}
+
 	//note one could have an apply for a Literal that would return a InversePredicate
 	//but that would require restructuring EasyGraphNode so that one can have an EasyGraphNode
 	//with a missing ref, or perhaps a sublcass of EasyGraphnode that only has the <- operator
available



Mime
View raw message