Class GremlinController


  • @RestController
    @RequestMapping("/rest/gremlin")
    public class GremlinController
    extends Object
    • Constructor Summary

      Constructors 
      Constructor Description
      GremlinController​(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource g, AbstractUserFactory userFactory, Long requestTimeout)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> cypherExecute​(org.springframework.http.HttpHeaders httpHeaders, String cypherQuery)
      Endpoint for running a cypher query through gremlin, will respond with an output stream of GraphSONv3 JSON.
      String cypherExplain​(org.springframework.http.HttpHeaders httpHeaders, String cypherQuery)
      Explains what Gaffer operations are ran for a given cypher query, will translate to Gremlin using CypherAst before executing.
      org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> execute​(org.springframework.http.HttpHeaders httpHeaders, String gremlinQuery)
      Endpoint for running a gremlin groovy query, will respond with an output stream of GraphSONv3 JSON.
      String explain​(org.springframework.http.HttpHeaders httpHeaders, String gremlinQuery)
      Explains what Gaffer operations are run for a given gremlin query.
      static org.json.JSONObject getGafferPopExplanation​(GafferPopGraph graph)
      Gets an explanation of the last chain of operations ran on a GafferPop graph.
    • Field Detail

      • GRAPHSON_V3_MAPPER

        public static final org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper GRAPHSON_V3_MAPPER
        The mapper for converting to GraphSONv3.
      • GRAPHSON_V3_WRITER

        public static final org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter GRAPHSON_V3_WRITER
        Writer for writing GraphSONv3 output to output streams.
    • Constructor Detail

      • GremlinController

        @Autowired
        public GremlinController​(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource g,
                                 AbstractUserFactory userFactory,
                                 Long requestTimeout)
    • Method Detail

      • explain

        @PostMapping(path="/explain",
                     consumes="text/plain",
                     produces="application/json")
        public String explain​(@RequestHeader
                              org.springframework.http.HttpHeaders httpHeaders,
                              @RequestBody
                              String gremlinQuery)
        Explains what Gaffer operations are run for a given gremlin query.
        Parameters:
        httpHeaders - The request headers.
        gremlinQuery - The gremlin groovy query.
        Returns:
        JSON response with explanation in.
      • execute

        @PostMapping(path="/execute",
                     consumes="text/plain",
                     produces="application/x-ndjson")
        public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> execute​(@RequestHeader
                                                                                                                                            org.springframework.http.HttpHeaders httpHeaders,
                                                                                                                                            @RequestBody
                                                                                                                                            String gremlinQuery)
                                                                                                                                     throws IOException
        Endpoint for running a gremlin groovy query, will respond with an output stream of GraphSONv3 JSON.
        Parameters:
        httpHeaders - The request headers.
        gremlinQuery - The gremlin groovy query.
        Returns:
        A response output stream of GraphSONv3.
        Throws:
        IOException - If issue writing output.
      • cypherExplain

        @PostMapping(path="/cypher/explain",
                     consumes="text/plain",
                     produces="application/json")
        public String cypherExplain​(@RequestHeader
                                    org.springframework.http.HttpHeaders httpHeaders,
                                    @RequestBody
                                    String cypherQuery)
        Explains what Gaffer operations are ran for a given cypher query, will translate to Gremlin using CypherAst before executing.
        Parameters:
        httpHeaders - The request headers.
        cypherQuery - Opencypher query.
        Returns:
        JSON response with explanation in.
      • cypherExecute

        @PostMapping(path="/cypher/execute",
                     consumes="text/plain",
                     produces="application/x-ndjson")
        public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> cypherExecute​(@RequestHeader
                                                                                                                                                  org.springframework.http.HttpHeaders httpHeaders,
                                                                                                                                                  @RequestBody
                                                                                                                                                  String cypherQuery)
                                                                                                                                           throws IOException
        Endpoint for running a cypher query through gremlin, will respond with an output stream of GraphSONv3 JSON.
        Parameters:
        httpHeaders - The request headers.
        cypherQuery - The cypher query.
        Returns:
        The output stream of GraphSONv3.
        Throws:
        IOException - If issue writing output.
      • getGafferPopExplanation

        public static org.json.JSONObject getGafferPopExplanation​(GafferPopGraph graph)
        Gets an explanation of the last chain of operations ran on a GafferPop graph. This essentially shows how a Gremlin query mapped to a Gaffer operation chain. Note due to how Gaffer maps to Tinkerpop some filtering steps in the Gremlin query may be absent from the operation chains in the explain as it may have been done in the Tinkerpop framework instead.
        Parameters:
        graph - The GafferPop graph
        Returns:
        A JSON payload with an overview and full JSON representation of the chain in.