def delete(self, graphName, food, eater): if not semanticweb.graphExists(graphName): MyRequestHandler.resp(self, 500, "graph does not exist") code = semanticweb.dropRelation(graphName, str(food).capitalize(), str(eater).capitalize()) MyRequestHandler.resp(self, code["code"])
def post(self, graphName): graphs = semanticweb.listGraphs() if semanticweb.graphExists(graphName): MyRequestHandler.resp(self, 500, "graph already exists") else: semanticweb.initGraph(graphName) MyRequestHandler.resp(self)
def post(self, graphName, food, eater): if semanticweb.graphExists(graphName): code = semanticweb.addRelation(graphName, str(food).capitalize(), str(eater).capitalize()) MyRequestHandler.resp(self, code["code"]) else: MyRequestHandler.resp(self, 500, "graph does not exist")
def get(self, graphName): if not semanticweb.graphExists(graphName): MyRequestHandler.resp(self, 500, "graph does not exist") startEnd = semanticweb.listStartEnd(graphName) chains = [] for pair in startEnd: chains = chains + semanticweb.listFoodChains( graphName, pair[0], pair[1]) MyRequestHandler.resp(self, 200, {"foodChains": chains})
def get(self, graphName): if not semanticweb.graphExists(graphName): MyRequestHandler.resp(self, 500, "graph does not exist") resrouces = semanticweb.listDBresource(graphName) relations = semanticweb.listFoodRelations(graphName) MyRequestHandler.resp(self, 200, { "resources": resrouces, "relations": relations })
def get(self, graphName): if not semanticweb.graphExists(graphName): MyRequestHandler.resp(self, 500, "graph does not exist") hungry = semanticweb.findHungryAnimals(graphName) MyRequestHandler.resp(self, 200, {"hungryAnimals": hungry})
def delete(self, graphName): if semanticweb.graphExists(graphName): semanticweb.dropGraph(graphName) MyRequestHandler.resp(self, 204) else: MyRequestHandler.resp(self, 500, "graph does not exist")
def get(self): graphs = semanticweb.listGraphs() MyRequestHandler.resp(self, 200, {"graphs": graphs})