Siegfried Gevatter has proposed merging lp:~zeitgeist/zeitgeist/auto-mimetype 
into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  Bug #899602 in Zeitgeist Framework: "Automatically determine interpretation 
from mime-type when it's empty"
  https://bugs.launchpad.net/zeitgeist/+bug/899602

For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/auto-mimetype/+merge/87080
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/auto-mimetype/+merge/87080
Your team Zeitgeist Framework Team is requested to review the proposed merge of 
lp:~zeitgeist/zeitgeist/auto-mimetype into lp:zeitgeist.
=== modified file 'src/engine.vala'
--- src/engine.vala	2011-12-04 22:58:25 +0000
+++ src/engine.vala	2011-12-29 13:38:24 +0000
@@ -662,6 +662,23 @@
 
             unowned Subject subject = event.subjects[i];
 
+            // If subject manifestation and interpretation are not set,
+            // we try to automatically determine them from the other data.
+
+            if (subject.manifestation == "")
+            {
+                var manifestation = manifestation_for_uri (subject.uri);
+                if (manifestation != null)
+                    subject.manifestation = manifestation;
+            }
+
+            if (subject.interpretation == "")
+            {
+                var interp = interpretation_for_mimetype (subject.mimetype);
+                if (interp != null)
+                    subject.interpretation = interp;
+            }
+
             insert_stmt.bind_text (8, subject.uri);
             insert_stmt.bind_text (9, subject.current_uri);
             insert_stmt.bind_int64 (10,

=== added file 'test/data/incomplete_events.js'
--- test/data/incomplete_events.js	1970-01-01 00:00:00 +0000
+++ test/data/incomplete_events.js	2011-12-29 13:38:24 +0000
@@ -0,0 +1,56 @@
+[
+	{
+		"timestamp" : 400,
+		"interpretation" : "#AccessEvent",
+		"manifestation" : "#UserActivity",
+		"actor" : "Mistery",
+		"subjects" : [
+			{
+				"uri" : "foo://bar",
+				"interpretation" : "",
+				"manifestation" : "Hi"
+			},{
+				"uri" : "http://meh";,
+                "mimetype" : "bs",
+				"interpretation" : "",
+				"manifestation" : "Something"
+			}
+		]
+	},{
+		"timestamp" : 500,
+		"interpretation" : "#AccessEvent",
+		"manifestation" : "#UserActivity",
+		"actor" : "Void",
+		"subjects" : [
+			{
+				"uri" : "file://baz0",
+                "mimetype" : "text/x-python",
+				"interpretation" : "",
+				"manifestation" : ""
+			},{
+				"uri" : "file://baz1",
+                "mimetype" : "text/x-python",
+				"interpretation" : "a",
+				"manifestation" : ""
+			},{
+				"uri" : "file://baz2",
+                "mimetype" : "text/x-python",
+				"interpretation" : "",
+				"manifestation" : "b"
+			}
+		]
+	},{
+		"timestamp" : 600,
+		"interpretation" : "#SendEvent",
+		"manifestation" : "#UserActivity",
+		"actor" : "Empty",
+		"subjects" : [
+			{
+				"uri" : "sftp://quiz";,
+                "mimetype" : "text/x-sql",
+				"interpretation" : "#Audio",
+				"manifestation" : "something else"
+			}
+		]
+	}
+]

=== modified file 'test/dbus/remote-test.py'
--- test/dbus/remote-test.py	2011-12-29 13:22:53 +0000
+++ test/dbus/remote-test.py	2011-12-29 13:38:24 +0000
@@ -224,6 +224,29 @@
 		results = self.findEventsForTemplatesAndWait([], num_events=3)
 		self.assertEquals(3, len(results))
 
+	def testInsertWithEmptySubjectInterpretationManifestation(self):
+		events = parse_events("test/data/incomplete_events.js")
+		ids = self.insertEventsAndWait(events)
+		self.assertEquals(3, len(ids))
+		
+		event = self.getEventsAndWait([ids[0]])[0]
+		self.assertEquals("Hi", event.subjects[0].manifestation)
+		self.assertEquals("", event.subjects[0].interpretation)
+		self.assertEquals("Something", event.subjects[1].manifestation)
+		self.assertEquals("", event.subjects[1].interpretation)
+
+		event = self.getEventsAndWait([ids[1]])[0]
+		self.assertEquals(Manifestation.FILE_DATA_OBJECT, event.subjects[0].manifestation)
+		self.assertEquals(Interpretation.SOURCE_CODE, event.subjects[0].interpretation)
+		self.assertEquals(Manifestation.FILE_DATA_OBJECT, event.subjects[1].manifestation)
+		self.assertEquals("a", event.subjects[1].interpretation)
+		self.assertEquals("b", event.subjects[2].manifestation)
+		self.assertEquals(Interpretation.SOURCE_CODE, event.subjects[2].interpretation)
+		
+		event = self.getEventsAndWait([ids[2]])[0]
+		self.assertEquals("something else", event.subjects[0].manifestation)
+		self.assertEquals("#Audio", event.subjects[0].interpretation)
+
 	def testInsertWithDuplicateSubject(self):
 		events = parse_events("test/data/three_events.js")
 		events[0].subjects.append(list(events[0].subjects[0]))

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to