Beispiel #1
0
    def _build_triple_sql_command(self, subject, predicate, obj, context, quoted):
        """
        Build an insert command for regular triple table.

        """
        stmt_table = quoted and self.tables["quoted_statements"] or self.tables["asserted_statements"]

        triple_pattern = statement_to_term_combination(subject, predicate, obj, context)
        command = stmt_table.insert()

        if quoted:
            params = {
                "subject": subject,
                "predicate": predicate,
                "object": obj,
                "context": context.identifier,
                "termComb": triple_pattern,
                "objLanguage": isinstance(obj, Literal) and obj.language or None,
                "objDatatype": isinstance(obj, Literal) and obj.datatype or None,
            }
        else:
            params = {
                "subject": subject,
                "predicate": predicate,
                "object": obj,
                "context": context.identifier,
                "termComb": triple_pattern,
            }
        return command, params
Beispiel #2
0
 def save(self, *args, **kwargs):
     #assumption is all three are URIRef. This might not be true.
     self.termcomb = int(
         statement_to_term_combination(
             URIRef(self.subject.subject), URIRef(self.predicate.value),
             URIRef(self.object.subject),
             graph.get_context(self.context.value)))
     super(AssertedStatement, self).save(*args, **kwargs)
Beispiel #3
0
    def _build_literal_triple_sql_command(self, subject, predicate, obj, context):
        """
        Build an insert command for literal triples.

        These triples correspond to RDF statements where the object is a Literal,
        e.g. `rdflib.Literal`.

        """
        triple_pattern = int(statement_to_term_combination(subject, predicate, obj, context))
        command = self.tables["literal_statements"].insert()
        values = {
            "subject": subject,
            "predicate": predicate,
            "object": obj,
            "context": context.identifier,
            "termComb": triple_pattern,
            "objLanguage": isinstance(obj, Literal) and obj.language or None,
            "objDatatype": isinstance(obj, Literal) and obj.datatype or None,
        }
        return command, values
    def _build_literal_triple_sql_command(self, subject, predicate, obj,
                                          context):
        """
        Build an insert command for literal triples.

        These triples correspond to RDF statements where the object is a Literal,
        e.g. `rdflib.Literal`.

        """
        triple_pattern = int(
            statement_to_term_combination(subject, predicate, obj, context))
        command = self.tables["literal_statements"].insert()
        values = {
            "subject": subject,
            "predicate": predicate,
            "object": obj,
            "context": context.identifier,
            "termComb": triple_pattern,
            "objLanguage": isinstance(obj, Literal) and obj.language or None,
            "objDatatype": isinstance(obj, Literal) and obj.datatype or None,
        }
        return command, values
    def _build_triple_sql_command(self, subject, predicate, obj, context,
                                  quoted):
        """
        Build an insert command for regular triple table.

        """
        stmt_table = (quoted and self.tables["quoted_statements"]
                      or self.tables["asserted_statements"])

        triple_pattern = statement_to_term_combination(
            subject,
            predicate,
            obj,
            context,
        )
        command = stmt_table.insert()

        if quoted:
            params = {
                "subject": subject,
                "predicate": predicate,
                "object": obj,
                "context": context.identifier,
                "termComb": triple_pattern,
                "objLanguage": isinstance(obj, Literal) and obj.language
                or None,
                "objDatatype": isinstance(obj, Literal) and obj.datatype
                or None
            }
        else:
            params = {
                "subject": subject,
                "predicate": predicate,
                "object": obj,
                "context": context.identifier,
                "termComb": triple_pattern,
            }
        return command, params
Beispiel #6
0
 def save(self, *args, **kwargs):
     self.termcomb = int(
         statement_to_term_combination(
             URIRef(self.subject.subject), URIRef(self.predicate.value),
             Literal(self.object), graph.get_context(self.context.value)))
     super(QuotedStatement, self).save(*args, **kwargs)
Beispiel #7
0
 def save(self, *args, **kwargs):
   self.termcomb = int(statement_to_term_combination(URIRef(self.subject.subject), URIRef(self.predicate.value), Literal(self.object), graph.get_context(self.context.value)))
   super(LiteralStatement, self).save(*args, **kwargs)
Beispiel #8
0
 def save(self, *args, **kwargs):
   #assumption is all three are URIRef. This might not be true.
   self.termcomb = int(statement_to_term_combination(URIRef(self.subject.subject), URIRef(self.predicate.value), URIRef(self.object.subject), graph.get_context(self.context.value)))
   super(AssertedStatement, self).save(*args, **kwargs)