def write(self): prop_id = Uri(self.raw_entity['id']) last_updated = self.raw_entity['last_updated'] state = self.raw_entity['state'] print('[WPARSER] Updated {} to state {}'.format(str(prop_id), state)) Graph.updateStatement(prop_id, DOME.last_updated, last_updated) Graph.updateStatement(prop_id, DOME.value, str(state)) self.outqueue.put(str(prop_id))
def toString(self, f): if f == 'html': return '''<!DOCTYPE html><html><head> <link type="text/css" rel="stylesheet" href="https://w3.scripts.mit.edu/tabulator/tabbedtab.css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="https://w3.scripts.mit.edu/tabulator/js/mashup/mashlib.js"></script> <script type="text/javascript"> jQuery.ajaxPrefilter(function(options) { if (options.crossDomain) { options.url = "https://w3.scripts.mit.edu/proxy?uri=" + encodeURIComponent(options.url); } }); jQuery(document).ready(function() { tabulator.outline.GotoSubject(tabulator.kb.sym(window.location.href), true, undefined, true, undefined); }); </script></head><body> <div class="TabulatorOutline" id="DummyUUID"><table id="outline"></table></div></body></html>''' s = Serializer(name=f) s.set_feature(Uri('http://feature.librdf.org/raptor-writeBaseURI'), Node(literal='0')._node) for k, v in list(ns.__dict__.items()): if type(v) is NS: s.set_namespace(k, Uri(v._prefix)) return s.serialize_model_to_string(self._g, base_uri=self._base)
def start(self, automation_raw): self.parsed_json = [] self.parseAutomation(automation_raw) g = Graph() for part in self.parsed_json: g.parse(data=json.dumps(part), format='json-ld') automation_string = (g.serialize(format='turtle')).decode('utf-8') tp = TurtleParser() DGraph.getModel().add_statements( tp.parse_string_as_stream( automation_string, Uri('http://kadjanderman.com/ontology/')))
#!/usr/bin/env python from operator import attrgetter from pprint import pprint as P from datetime import datetime, timedelta from RDF import Node, Uri, Statement, Storage, Model OUR_LAND = 'http://choicedocs.com/ref/' OUR_LAND_URI = Uri(OUR_LAND) PROVIDER = Uri(OUR_LAND + 'Provider') TRENCHE = Uri(OUR_LAND + 'Trenche') TREATMENT = Uri(OUR_LAND + 'Treatment') PROCTYPE = Uri(OUR_LAND + 'ProcedureType') CATEGORY = Uri(OUR_LAND + 'Category') SUBCAT = Uri(OUR_LAND + 'SubCategory') SUPPORTS = Uri(OUR_LAND + 'SupportsTreatment') AVAIL = Uri(OUR_LAND + 'AvailabilitySlot') DATE = Uri(OUR_LAND + 'Date') WHERE = Uri(OUR_LAND + 'Location') FROM_TIME = Uri(OUR_LAND + 'from_time') TO_TIME = Uri(OUR_LAND + 'to_time') EMPLOYS = Uri(OUR_LAND + 'Employs') NAME = Uri('http://xmlns.com/foaf/0.1/name') LABEL = Uri('http://www.w3.org/2000/01/rdf-schema#label') TYPE = Uri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type') PREFIX = """\ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX cd: <http://choicedocs.com/ref/> """
def new_merchant_URI(self, merchant): return Uri('cd:' + merchant)
import sys, os sys.path.append(os.path.abspath(os.path.join('lib', 'redland', 'bindings', 'python'))) from RDF import Uri, Statement from dome.db.graph import Graph from dome.config import DOME if (len(sys.argv) != 2): sys.exit() resource = sys.argv[1] for stmt in Graph.getModel().find_statements(Statement(Uri(resource), None, None)): del Graph.getModel()[stmt] for stmt in Graph.getModel().find_statements(Statement(None, None, Uri(resource))): del Graph.getModel()[stmt]
def verifyCondition(condition): target = Graph.getModel().get_target(condition, DOME.target) operator = str(Graph.getModel().get_target(condition, DOME.operatortype)) prop = Graph.getModel().get_target(condition, DOME.observes) value = Graph.getModel().get_target(Uri(str(prop)), DOME.value) return compare(value, operator, target)