Beispiel #1
0
 def all(self, schema_name, depth=3):
     schema_uri = self.parent.get_uri(schema_name)
     uri = URIRef(schema_uri)
     var = v['uri']
     q = Select([var]).where((var, RDF.type, uri))
     q = q.order_by(desc(var))
     for data in q.execute(self.graph):
         yield self.get(data['uri'], depth=depth, schema=schema_uri)
Beispiel #2
0
 def all(self, schema_name, depth=3):
     schema_uri = self.parent.get_uri(schema_name)
     uri = URIRef(schema_uri)
     var = v['uri']
     q = Select([var]).where((var, RDF.type, uri))
     q = q.order_by(desc(var))
     for data in q.execute(self.graph):
         yield self.get(data['uri'], depth=depth, schema=schema_uri)
Beispiel #3
0
    def query(self, parents=None):
        """ Compose the query and generate SPARQL. """
        # TODO: benchmark single-query strategy
        q = Select([])
        q = self.project(q, parent=True)
        q = self.filter(q, parents=parents)

        if self.parent is None:
            subq = Select([self.var])
            subq = self.filter(subq, parents=parents)
            subq = subq.offset(self.node.offset)
            subq = subq.limit(self.node.limit)
            subq = subq.distinct()
            # TODO: sorting.
            subq = subq.order_by(desc(self.var))
            q = q.where(subq)

        # if hasattr(self.context, 'identifier'):
        #     q._where = graph(self.context.identifier, q._where)
        log.debug("Compiled query: %r", q.compile())
        return q
Beispiel #4
0
    def query(self, parents=None):
        """ Compose the query and generate SPARQL. """
        # TODO: benchmark single-query strategy
        q = Select([])
        q = self.project(q, parent=True)
        q = self.filter(q, parents=parents)

        if self.parent is None:
            subq = Select([self.var])
            subq = self.filter(subq, parents=parents)
            subq = subq.offset(self.node.offset)
            subq = subq.limit(self.node.limit)
            subq = subq.distinct()
            # TODO: sorting.
            subq = subq.order_by(desc(self.var))
            q = q.where(subq)

        # if hasattr(self.context, 'identifier'):
        #     q._where = graph(self.context.identifier, q._where)
        log.debug("Compiled query: %r", q.compile())
        return q