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