Class GraphHelper


  • public class GraphHelper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphHelper()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void closeGraph()
      Close the connection to the graph
      <U> void commit​(java.util.function.BiConsumer<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​U> consumer, U argument, java.util.function.Consumer<java.lang.Exception> errorHandler)
      Helper method that gets a traversal and executes the code that queries the graph
      <V,​U>
      void
      commit​(org.apache.tinkerpop.gremlin.util.function.TriConsumer<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​U> consumer, V argument1, U argument2, java.util.function.Consumer<java.lang.Exception> errorHandler)
      Helper method that gets a traversal and executes the code that queries the graph
      org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource getGraphTraversalSource()
      Returns a traversal that is used to query the graph
      <U,​V>
      U
      getResult​(java.util.function.BiFunction<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​U> function, V argument, java.util.function.BiConsumer<java.lang.Exception,​V> errorHandler)
      Helper method that gets a traversal and executes the code that queries the graph
      <U> U getResult​(java.util.function.Function<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​U> function, java.util.function.Consumer<java.lang.Exception> errorHandler)
      Helper method that gets a traversal and executes the code that queries the graph
      <U,​V,​T>
      U
      getResult​(org.apache.tinkerpop.gremlin.util.function.TriFunction<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​T,​U> function, V argument1, T argument2, org.apache.tinkerpop.gremlin.util.function.TriConsumer<java.lang.Exception,​V,​T> errorHandler)
      Helper method that gets a traversal and executes the code that queries the graph
      boolean isSupportingTransactions()
      return whether the graph is supporting transactions
      void openGraph​(java.lang.String providerClass, java.util.Map<java.lang.String,​java.lang.Object> configurationProperties, AuditLog auditLog)
      Open the graph with the provided configuration
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphHelper

        public GraphHelper()
    • Method Detail

      • openGraph

        public void openGraph​(java.lang.String providerClass,
                              java.util.Map<java.lang.String,​java.lang.Object> configurationProperties,
                              AuditLog auditLog)
                       throws JanusConnectorException,
                              OpenLineageException
        Open the graph with the provided configuration
        Parameters:
        providerClass - - Provider Class name to be used
        configurationProperties - - The configuration properties for janusGraph
        auditLog - - Used for logging errors
        Throws:
        JanusConnectorException - if init fails
        OpenLineageException - if init fails
      • getGraphTraversalSource

        public org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource getGraphTraversalSource()
        Returns a traversal that is used to query the graph
        Returns:
        traversal for the janusgraph
      • isSupportingTransactions

        public boolean isSupportingTransactions()
        return whether the graph is supporting transactions
      • closeGraph

        public void closeGraph()
        Close the connection to the graph
      • commit

        public <U> void commit​(java.util.function.BiConsumer<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​U> consumer,
                               U argument,
                               java.util.function.Consumer<java.lang.Exception> errorHandler)
        Helper method that gets a traversal and executes the code that queries the graph
        Type Parameters:
        U - type of the second parameter of the consumer
        Parameters:
        consumer - must accept a GraphTraversalSource as the first parameter and has a second parameter
        argument - the second argument of the consumer
        errorHandler - function that is called when an error occurs while executing the consumer
      • commit

        public <V,​U> void commit​(org.apache.tinkerpop.gremlin.util.function.TriConsumer<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​U> consumer,
                                       V argument1,
                                       U argument2,
                                       java.util.function.Consumer<java.lang.Exception> errorHandler)
        Helper method that gets a traversal and executes the code that queries the graph
        Type Parameters:
        U - type of the second parameter of the consumer
        V - type of the third parameter of the consumer
        Parameters:
        consumer - must accept a GraphTraversalSource as the first parameter and has two more parameter
        argument1 - the second argument of the consumer
        argument2 - the third argument of the consumer
        errorHandler - function that is called when an error occurs while executing the consumer
      • getResult

        public <U> U getResult​(java.util.function.Function<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​U> function,
                               java.util.function.Consumer<java.lang.Exception> errorHandler)
        Helper method that gets a traversal and executes the code that queries the graph
        Type Parameters:
        U - type of the returned result
        Parameters:
        function - must accept a GraphTraversalSource as the parameter
        errorHandler - consumer that is called when an error occurs while executing the function
        Returns:
        the result of the function
      • getResult

        public <U,​V> U getResult​(java.util.function.BiFunction<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​U> function,
                                       V argument,
                                       java.util.function.BiConsumer<java.lang.Exception,​V> errorHandler)
        Helper method that gets a traversal and executes the code that queries the graph
        Type Parameters:
        V - the type of the parameter of the function
        U - type of the returned result
        Parameters:
        function - must accept a GraphTraversalSource as the first parameter and has a second parameter
        argument - the argument of the function
        errorHandler - consumer that is called when an error occurs while executing the function
        Returns:
        the result of the function
      • getResult

        public <U,​V,​T> U getResult​(org.apache.tinkerpop.gremlin.util.function.TriFunction<org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource,​V,​T,​U> function,
                                               V argument1,
                                               T argument2,
                                               org.apache.tinkerpop.gremlin.util.function.TriConsumer<java.lang.Exception,​V,​T> errorHandler)
        Helper method that gets a traversal and executes the code that queries the graph
        Type Parameters:
        V - the type of the second parameter of the function
        T - the type of the third parameter of the function
        U - type of the returned result
        Parameters:
        function - must accept a GraphTraversalSource as the first parameter and has two more parameters
        argument1 - the first argument of the function
        argument2 - the second argument of the function
        errorHandler - consumer that is called when an error occurs while executing the function
        Returns:
        the result of the function