Beispiel #1
0
 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"])
Beispiel #2
0
 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)
Beispiel #3
0
 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")
Beispiel #4
0
 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})
Beispiel #5
0
 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
     })
Beispiel #6
0
 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})
Beispiel #7
0
 def delete(self, graphName):
     if semanticweb.graphExists(graphName):
         semanticweb.dropGraph(graphName)
         MyRequestHandler.resp(self, 204)
     else:
         MyRequestHandler.resp(self, 500, "graph does not exist")
Beispiel #8
0
 def get(self):
     graphs = semanticweb.listGraphs()
     MyRequestHandler.resp(self, 200, {"graphs": graphs})