Exemple #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"])
Exemple #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)
Exemple #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")
Exemple #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})
Exemple #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
     })
Exemple #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})
Exemple #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")
Exemple #8
0
 def get(self):
     graphs = semanticweb.listGraphs()
     MyRequestHandler.resp(self, 200, {"graphs": graphs})