Exemple #1
0
 def reifyProperty(self, parameters):
     property_num = parameters['processor'][6:]
     subject = parameters['uri']
     property = parameters['prop%s_name' % property_num]
     value = parameters['prop%s_value' % property_num]
     if self.rednode.getRange(property)==LITERAL:
         value = literal(value)
     self.rednode.reify(self.rednode.local.URI+self.generateURI(), subject, property, value)
Exemple #2
0
    def _remove(self, subject, predicate, object):
        self.store.remove(subject, predicate, object)

        statement_uri = self.generateURI()
        self.journal.add(statement_uri, TYPE, STATEMENT)
        self.journal.add(statement_uri, SUBJECT, subject)
        self.journal.add(statement_uri, PREDICATE, predicate)
        self.journal.add(statement_uri, OBJECT, object)
        self.journal.add(statement_uri, OPERATION, DELETE)
        self.journal.add(statement_uri, SOURCE, self.URI)
        self.journal.add(statement_uri, TIMESTAMP, literal(self.sn.date_time_path()))
Exemple #3
0
 def __init__(self, parser, adder, parent, name, atts):    
     HandlerBase.__init__(self, parser, adder, parent)
     self.predicate = name
     if atts.has_key(u"resource"):
         self.object = atts[u"resource"]
         if self.object[0]==u"#":
             self.object = self.parser.GetBase() + self.object
         for att in atts.keys():
             if att == u"resource":
                 pass
             else:
                 self.adder(self.object, att, literal(atts[att]))
     elif atts.has_key(RESOURCE):
         self.object = atts[RESOURCE]
         if self.object[0]==u"#":
             self.object = self.parser.GetBase() + self.object
         for att in atts.keys():
             if att == RESOURCE:
                 pass
             else:
                 self.adder(self.object, att, literal(atts[att]))
     else:
         self.object = literal(u"")
Exemple #4
0
    def update(self, parameters, subject=None, copy=0):
	if subject==None:
	    subject = parameters['uri']
        count = parameters['prop_count']
        i = 0
        while i < int(count):
            i = i + 1
            property = parameters['prop%s_name' % i]
            value = parameters['prop%s_value' % i]
            orig = parameters['prop%s_orig' % i]            
            isLiteral = parameters['prop%s_isLiteral' % i]
            if isLiteral == "yes":
                value = literal(value)
            if copy:
                self.rednode.local.add(subject, property, value)
            elif value!=orig:
                self.rednode.local.remove(subject, property, orig)
                self.rednode.local.add(subject, property, value)
        newProperty = parameters['newProperty']
        newPropertyValue = ""
        if self.rednode.getRange(newProperty)==LITERAL:
            newPropertyValue = literal(newPropertyValue)
        if newProperty!="":
            self.rednode.local.add(subject, newProperty, newPropertyValue)
Exemple #5
0
 def __init__(self, parser, adder, parent, atts):
     HandlerBase.__init__(self, parser, adder, parent)
     self.subject = None
     if atts.has_key(u"about"):
         self.subject = atts[u"about"]
     elif atts.has_key(u"ID"):
         self.subject = self.parser.GetBase() + u"#" + atts[u"ID"]
     elif atts.has_key(ABOUT):
         self.subject = atts[ABOUT]
     elif atts.has_key(ID):
         self.subject = self.parser.GetBase() + u"#" + atts[ID]
     else:
         import sys
         print atts
         sys.stderr.write(u"Descriptions must have either an about or an ID\n")
         
     for att in atts.keys():
         if att==u"about" or att==u"ID" or att==ABOUT or att==ID:
             pass
         else:
             self.adder(self.subject, att, literal(atts[att]))
Exemple #6
0
        """
        Experimental -- may change, depend on it at your own risk

        This method differs from visit(aSubject, None, None) in that it will only
        call the callback once per subject.
        """
        for s in self.spo.keys():
            callback(s)
                    


from rdf.const import *

from rdf.literal import literal, un_literal, is_literal

ADD = literal("add")
DELETE = literal("delete")
OPERATION = "http://redfoot.sourceforge.net/2001/01/30/#operation"
TIMESTAMP = "http://redfoot.sourceforge.net/2001/01/30/#timestamp"
SOURCE = "http://redfoot.sourceforge.net/2001/01/30/#source"

#from rdf.query import QueryStore
#class JournalingStore(TripleStore, QueryStore):
class JournalingStore:

    def __init__(self):
        self.store = TripleStore()
        self.sn = SN()


    def chron(self, a, b):