Two patches for Xesam adaptor



Hello

Two patches for the xesam adaptor:

title: Fixes title, as title is apparently dc:title in beagle and not title
snippet: implements snippet support

-- 
Anders Rune Jensen
http://people.iola.dk/anders/
--- /home/arj/source/beagle-xesam/src/Ontologies.cs	2007-12-18 15:30:05.000000000 +0100
+++ src/Ontologies.cs	2008-01-09 16:53:00.000000000 +0100
@@ -48,8 +48,8 @@
 			{
 				fields_mapping = new Dictionary<string, string> ();
 
-				fields_mapping.Add ("dc:title", "title");
-				fields_mapping.Add ("xesam:title", "title");
+				fields_mapping.Add ("dc:title", "dc:title");
+				fields_mapping.Add ("xesam:title", "dc:title");
 
 				fields_mapping.Add ("dc:author", "author");
 				fields_mapping.Add ("xesam:author", "author");
--- /home/arj/source/beagle-xesam/src/Ontologies.cs	2007-12-18 15:30:05.000000000 +0100
+++ src/Ontologies.cs	2008-01-09 16:53:00.000000000 +0100
@@ -73,6 +73,8 @@
 
 				fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension");
 				fields_mapping.Add ("fileExtension", "beagle:FilenameExtension");
+
+				fields_mapping.Add ("snippet", "snippet");
 			}
 
 			private static void InitializeSourcesMapping ()
--- /home/arj/source/beagle-xesam/src/Search.cs	2007-12-21 12:10:34.000000000 +0100
+++ src/Search.cs	2008-01-09 17:08:57.000000000 +0100
@@ -53,7 +53,7 @@
 				get { return bHit; }
 			}
 
-			public Hit (uint id, Beagle.Hit hit, string[] fields)
+		        public Hit (uint id, Beagle.Hit hit, string[] fields, Query query)
 			{
 				this.id = id;
 				bHit = hit;
@@ -77,7 +77,13 @@
 					case "date":
 						hitValue [i++] = hit.Timestamp.ToString ("s");
 						break;
-						
+
+					case "snippet":
+					        SnippetRequest sreq = new SnippetRequest (query, hit);
+						SnippetResponse sresp = (SnippetResponse) sreq.Send ();
+						hitValue [i++] = sresp.Snippet != null ? sresp.Snippet : String.Empty;
+						break;
+					    
 					default:
 						//FIXME: This *will* break since we don't know what the expected
 						//type here is
@@ -211,7 +217,7 @@
 				mutex.WaitOne ();
 
 				foreach (uint id in ids) {
-					Hit hit = new Hit (id, hits [id].BeagleHit, fields);
+				        Hit hit = new Hit (id, hits [id].BeagleHit, fields, query);
 					ret.Add (hit.Value);
 				}
 
@@ -227,8 +233,8 @@
 				// cache the hits and keep them nice and safe
 				Console.Error.WriteLine ("{0}: Got some hits: {1}", id, response.Hits.Count);
 				foreach (Beagle.Hit bHit in response.Hits) {
-				    //					Console.Error.WriteLine ("+Hit: {0}", bHit.Uri);
-					newHits.Add (hitCount++, new Xesam.Hit (hitCount, bHit, parentSession.HitFields));
+					Console.Error.WriteLine ("+Hit: {0}", bHit.Uri);
+					newHits.Add (hitCount++, new Xesam.Hit (hitCount, bHit, parentSession.HitFields, query));
 				}
 
 				if (newHits.Count > 0 && HitsAddedHandler != null) {


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