beagle r4495 - in branches/beagle-rdf: BeagleClient RDFAdapter tools



Author: dbera
Date: Sun Feb 17 00:50:04 2008
New Revision: 4495
URL: http://svn.gnome.org/viewvc/beagle?rev=4495&view=rev

Log:
Patch from Enrico. Instead of asking the user for the property type, derive it internally. Ideally, BeagleSource would know the mapping, property name etc so it is a better place to handle the property type. Also RDFQueryTool is just a testing tool.


Modified:
   branches/beagle-rdf/BeagleClient/Query.cs
   branches/beagle-rdf/RDFAdapter/BeagleSource.cs
   branches/beagle-rdf/tools/RdfQueryTool.cs

Modified: branches/beagle-rdf/BeagleClient/Query.cs
==============================================================================
--- branches/beagle-rdf/BeagleClient/Query.cs	(original)
+++ branches/beagle-rdf/BeagleClient/Query.cs	Sun Feb 17 00:50:04 2008
@@ -283,13 +283,29 @@
 			Keepalive = false;
 		}
 
-		public RDFQuery (Uri subject, string predicate, PropertyType predicate_type, string _object) : this ()
+		public RDFQuery (Uri subject, string predicate, string _object) : this ()
 		{
+			// extract the property type from the property, and remove the prop:?: prefix
+			// e.g. from prop:k:beagle:MimeType
+			PropertyType ptype = PropertyType.Internal;
+			
+			if (predicate != null) {
+				if ((predicate.Length > 7) && predicate.StartsWith ("prop:")) {
+					switch (predicate [5]) {
+						case 't': ptype = PropertyType.Text; break;
+						case 'k': ptype = PropertyType.Keyword; break;
+						case 'd': ptype = PropertyType.Date; break;
+					}
+					// remove the prop:?:, which will be added by beagle later
+					predicate = predicate.Substring (7);
+				}
+			}
+
 			this.Subject = subject;
 			this.Predicate = (predicate == null ? String.Empty : predicate);
-			this.PredicateType = predicate_type;
+			this.PredicateType = ptype;
 			this.Object = (_object == null ? String.Empty : _object);
-
+						
 			// FIXME: the query contains a dummy part that will make the query
 			// pass even if it is empty. Empty queries are not handled by default.
 			//

Modified: branches/beagle-rdf/RDFAdapter/BeagleSource.cs
==============================================================================
--- branches/beagle-rdf/RDFAdapter/BeagleSource.cs	(original)
+++ branches/beagle-rdf/RDFAdapter/BeagleSource.cs	Sun Feb 17 00:50:04 2008
@@ -76,23 +76,7 @@
 			}
 		}
 
-		// extract the property type from the property
-		// e.g. from prop:k:beagle:MimeType
-		PropertyType ptype = PropertyType.Internal;
-
-		if (p != null) {
-			if ((p.Length > 7) && p.StartsWith ("prop:")) {
-				switch (p [5]) {
-					case 't': ptype = PropertyType.Text; break;
-					case 'k': ptype = PropertyType.Keyword; break;
-					case 'd': ptype = PropertyType.Date; break;
-				}
-				// remove the prop:?:, which will be added by beagle later
-				p = p.Substring (7);
-			}
-		}
-
-		RDFQuery query = new RDFQuery (s, p, ptype, o);
+		RDFQuery query = new RDFQuery (s, p, o);
 		RDFQueryResult result = (RDFQueryResult) query.Send ();
 		
 		foreach (Hit hit in result.Hits) {

Modified: branches/beagle-rdf/tools/RdfQueryTool.cs
==============================================================================
--- branches/beagle-rdf/tools/RdfQueryTool.cs	(original)
+++ branches/beagle-rdf/tools/RdfQueryTool.cs	Sun Feb 17 00:50:04 2008
@@ -8,11 +8,10 @@
 	public static void Main (string[] args)
 	{
 
-		if (args.Length != 4) {
+		if (args.Length != 3) {
 			Console.WriteLine ("Usage: program-name <subject> <predicate> <predicate-type> <object>");
 			Console.WriteLine ("      <subject>         : URI or path");
 			Console.WriteLine ("      <predicate>       : property name (string)");
-			Console.WriteLine ("      <predicate-type>  : property type (Internal,Text,Keyword,Date)");
 			Console.WriteLine ("      <object>          : object (string)");
 			Console.WriteLine ("      Use \"\" (empty string) for unspecified subject, predicate, type or object");
 			return;
@@ -20,17 +19,13 @@
 
 		RDFQueryResult result;
 
-		Console.WriteLine ("subject:'{0}' predicate:'{1}'({3}) object:'{2}'", args [0], args [1], args [3], args [2]);
+		Console.WriteLine ("subject:'{0}' predicate:'{1}' object:'{2}'", args [0], args [1], args [2]);
 
 		Uri subject = null;
 		if (args [0] != String.Empty)
 			subject = new Uri (args [0]);
 
-		PropertyType type = PropertyType.Text;
-		if (args [2] != String.Empty)
-			type = (PropertyType) Enum.Parse (typeof (PropertyType), args [2], true);
-
-		RDFQuery query = new RDFQuery (subject, args [1], type, args [3]);
+		RDFQuery query = new RDFQuery (subject, args [1], args [2]);
 		result = (RDFQueryResult) query.Send ();
 
 		if (result == null) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]