~robtaylor/zeitgeist/tracker

« back to all changes in this revision

Viewing changes to _zeitgeist/engine/extensions/tracker.py

  • Committer: Rob Taylor
  • Date: 2010-05-13 12:23:25 UTC
  • Revision ID: robtaylor@luitsiana-20100513122325-5zwafuj8kxhsda53
tracker extention is now sucessfully pushing events into tracker

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
                bus = dbus.SessionBus ()
40
40
                self.tracker = bus.get_object(TRACKER_NAME, TRACKER_OBJ)
41
41
                self.resources = dbus.Interface(self.tracker, TRACKER_IFACE)
42
 
                # Set up zeitgeists' Event Interpretation and Manifestation objects
43
 
                # these are basically used as enums...
44
 
                self.resources.SparqlUpdate("""
45
 
                        insert {
46
 
                                <uri:zg:eventinterpretation:createevent> a zg:CreateEvent .
47
 
                                <uri:zg:eventinterpretation:accessevent> a zg:AccessEvent .
48
 
                                <uri:zg:eventinterpretation:leaveevent> a zg:LeaveEvent .
49
 
                                <uri:zg:eventinterpretation:modifyevent> a zg:ModifyEvent .
50
 
                                <uri:zg:eventinterpretation:deleteevent> a zg:DeleteEvent .
51
 
                                <uri:zg:eventinterpretation:receiveevent> a zg:ReceiveEvent .
52
 
                                <uri:zg:eventinterpretation:sendevent> a zg:SendEvent .
53
 
                                <uri:zg:eventmanifestation:useractivity> a zg:UserActivity .
54
 
                                <uri:zg:eventmanifestation:heuristicactivity> a zg:HeuristicActivity .
55
 
                                <uri:zg:eventmanifestation:scheduledactivity> a zg:ScheduledActivity .
56
 
                                <uri:zg:eventmanifestation:worldactivity> a zg:WorldActivity .
57
 
                        }
58
 
                        """)
59
 
                
60
42
                
61
43
        def dummy_tracker_method(self, event):
62
44
                print event
78
60
                # mimetype
79
61
                # interpretation
80
62
                # manifestation
81
 
                uuid = uuid.uuid4()
 
63
                eventuuid = uuid.uuid4()
82
64
                zgevent = {
83
 
                        'uuid': uuid.hex,
84
 
                        'timestamp': event.timestamp,
85
 
                        'application' : event.actor.strip('application://'),
86
 
                        'interpretation' : event.interpretation,
87
 
                        'manifestation' : event.manifestation,
88
 
                        'id' : event.id }
89
 
 
90
 
                print zgevent
 
65
                        'uuid': eventuuid.hex,
 
66
                        'timestamp': event.get_timestamp(),
 
67
                        'application' : event.get_actor().replace('application://',''),
 
68
                        'interpretation' : event.get_interpretation(),
 
69
                        'manifestation' : event.get_manifestation(),
 
70
                        'id' : event.get_id() }
 
71
        
 
72
                zgevent['subjects'] = ""
 
73
                for subject in event.get_subjects():
 
74
                        zgevent['subjects'] += 'zg:hasSubject <%s>;' % subject.get_uri()
 
75
 
 
76
#               print zgevent
 
77
                                
 
78
                query = """
 
79
                        insert {
 
80
                                <uri:uuid:%(uuid)s> a zg:Event ;
 
81
                                                    zg:timestamp %(timestamp)s ;
 
82
                                                    zg:hasActor ?a ;
 
83
                                                    zg:hasEventInterpretation <%(interpretation)s>;
 
84
                                                    zg:hasEventManifestation <%(manifestation)s>;
 
85
                                                    zg:eventId %(id)s;
 
86
                                                    %(subjects)s
 
87
                        } WHERE {
 
88
                                ?a a nfo:SoftwareApplication;
 
89
                                     nfo:fileName 'rhythmbox.desktop'
 
90
                        }
 
91
                        """ % zgevent
 
92
 
 
93
                print query
 
94
                self.resources.SparqlUpdate(query)
91
95
                return event
92
 
                                
93
 
#               self.resources.SparqlUpdate("""
94
 
#                       insert {
95
 
#                               <uri:uuid:%s> a zg:Event ;
96
 
#                               zg:timestamp 1234 ; zg:hasActor ?a ; zg:hasEventInterpretation <urn:zg:eventinterpretation:leaveevent>; zg:hasEventManifestation <urn:zg:eventmanifestation:useractivity>; zg:hasSubject <urn:album:Thriller%20%28SpecialEdition%29> ; zg:eventId 1234 } WHERE { ?a a nfo:SoftwareApplication; nfo:fileName 'rhythmbox.desktop' }"
97
 
        
98