Package apoc.util

Class Util

java.lang.Object
apoc.util.Util

public class Util extends Object
Since:
24.04.16
  • Field Details

  • Constructor Details

    • Util

      public Util()
  • Method Details

    • labelString

      public static String labelString(List<String> labelNames)
    • labelString

      public static String labelString(org.neo4j.graphdb.Node n)
    • joinLabels

      public static String joinLabels(Iterable<org.neo4j.graphdb.Label> labels, String s)
    • labelStrings

      public static List<String> labelStrings(org.neo4j.graphdb.Node n)
    • labels

      public static org.neo4j.graphdb.Label[] labels(Object labelNames)
    • stream

      public static Stream<Object> stream(Object values)
    • nodeStream

      public static Stream<org.neo4j.graphdb.Node> nodeStream(org.neo4j.graphdb.Transaction tx, Object ids)
    • node

      public static org.neo4j.graphdb.Node node(org.neo4j.graphdb.Transaction tx, Object id)
    • relsStream

      public static Stream<org.neo4j.graphdb.Relationship> relsStream(org.neo4j.graphdb.Transaction tx, Object ids)
    • relationship

      public static org.neo4j.graphdb.Relationship relationship(org.neo4j.graphdb.Transaction tx, Object id)
    • retryInTx

      public static <T> T retryInTx(org.neo4j.logging.Log log, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction,T> function, long retry, long maxRetries, Consumer<Long> callbackForRetry)
    • inTxFuture

      public static <T> Future<T> inTxFuture(org.neo4j.logging.Log log, ExecutorService pool, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction,T> function, long maxRetries, Consumer<Long> callbackForRetry, Consumer<Void> callbackAction)
    • inTxFuture

      public static <T> Future<T> inTxFuture(ExecutorService pool, org.neo4j.graphdb.GraphDatabaseService db, Function<org.neo4j.graphdb.Transaction,T> function)
    • inTx

      public static <T> T inTx(org.neo4j.graphdb.GraphDatabaseService db, Pools pools, Function<org.neo4j.graphdb.Transaction,T> function)
    • inThread

      public static <T> T inThread(Pools pools, Callable<T> callable)
    • inFuture

      public static <T> Future<T> inFuture(Pools pools, Callable<T> callable)
    • toDouble

      public static Double toDouble(Object value)
    • subMap

      public static Map<String,Object> subMap(Map<String,?> params, String prefix)
    • toLong

      public static Long toLong(Object value)
    • toInteger

      public static Integer toInteger(Object value)
    • openUrlConnection

      public static URLConnection openUrlConnection(URL src, Map<String,Object> headers) throws IOException
      Throws:
      IOException
    • isRedirect

      public static boolean isRedirect(HttpURLConnection con) throws IOException
      Throws:
      IOException
    • openInputStream

      public static CountingInputStream openInputStream(Object input, Map<String,Object> headers, String payload, String compressionAlgo) throws IOException
      Throws:
      IOException
    • getStreamConnection

      public static StreamConnection getStreamConnection(String urlAddress, Map<String,Object> headers, String payload) throws IOException
      Throws:
      IOException
    • readHttpInputStream

      public static StreamConnection readHttpInputStream(String urlAddress, Map<String,Object> headers, String payload, int redirectLimit) throws IOException
      Throws:
      IOException
    • toBoolean

      public static boolean toBoolean(Object value)
    • toString

      public static String toString(Object string)
    • encodeUrlComponent

      public static String encodeUrlComponent(String value)
    • toJson

      public static String toJson(Object value)
    • fromJson

      public static <T> T fromJson(String value, Class<T> type)
    • partitionSubList

      public static Stream<List<Object>> partitionSubList(List<Object> data, int partitions)
    • partitionSubList

      public static Stream<List<Object>> partitionSubList(List<Object> data, int partitions, List<Object> tombstone)
    • runNumericQuery

      public static Long runNumericQuery(org.neo4j.graphdb.Transaction tx, String query, Map<String,Object> params)
    • nodeCount

      public static long nodeCount(org.neo4j.graphdb.Transaction tx)
    • relCount

      public static long relCount(org.neo4j.graphdb.Transaction tx)
    • readResourceFile

      public static String readResourceFile(String name)
    • readMap

      public static Map<String,Object> readMap(String value)
    • take

      public static <T> List<T> take(Iterator<T> iterator, int batchsize)
    • merge

      public static Map<String,Object> merge(Map<String,Object> first, Map<String,Object> second)
    • map

      public static <T> Map<String,T> map(T... values)
    • map

      public static <T> Map<String,T> map(List<T> pairs)
    • map

      public static <T, R> List<R> map(Stream<T> stream, Function<T,R> mapper)
    • map

      public static <T, R> List<R> map(Collection<T> collection, Function<T,R> mapper)
    • mapFromLists

      public static Map<String,Object> mapFromLists(List<String> keys, List<Object> values)
    • mapFromPairs

      public static Map<String,Object> mapFromPairs(List<List<Object>> pairs)
    • cleanUrl

      public static String cleanUrl(String url)
    • getFuture

      public static <T> T getFuture(Future<T> f, Map<String,Long> errorMessages, AtomicInteger errors, T errorValue)
    • getFutureOrCancel

      public static <T> T getFutureOrCancel(Future<T> f, Map<String,Long> errorMessages, AtomicInteger errors, T errorValue)
    • logErrors

      public static void logErrors(String message, Map<String,Long> errors, org.neo4j.logging.Log log)
    • sleep

      public static void sleep(int millis)
    • quote

      public static String quote(String var)
    • sanitize

      public static String sanitize(String value)
      Sanitizes the given input to be used as a valid schema name
      Parameters:
      value - The value to sanitize
      Returns:
      A value that is safe to be used in string concatenation, an empty optional indicates a value that cannot be safely quoted
    • sanitize

      public static String sanitize(String value, boolean addQuotes)
      Sanitizes the given input to be used as a valid schema name
      Parameters:
      value - The value to sanitize
      addQuotes - If quotation should be added
      Returns:
      A value that is safe to be used in string concatenation, an empty optional indicates a value that cannot be safely quoted
    • param

      public static String param(String var)
    • withMapping

      public static String withMapping(Stream<String> columns, Function<String,String> withMapping)
    • isWriteableInstance

      public static boolean isWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db, org.neo4j.graphdb.Transaction systemTx)
    • isWriteableInstance

      public static boolean isWriteableInstance(org.neo4j.kernel.internal.GraphDatabaseAPI db)
    • transactionIsTerminated

      public static boolean transactionIsTerminated(org.neo4j.procedure.TerminationGuard db)
      Given a context related to the procedure invocation this method checks if the transaction is terminated in some way
      Parameters:
      db -
      Returns:
    • waitForFutures

      public static void waitForFutures(List<Future> futures)
    • removeFinished

      public static void removeFinished(List<Future> futures)
    • close

      public static void close(AutoCloseable closeable, Consumer<Exception> onError)
    • close

      public static void close(AutoCloseable closeable)
    • isNotNullOrEmpty

      public static boolean isNotNullOrEmpty(String s)
    • isNullOrEmpty

      public static boolean isNullOrEmpty(String s)
    • getRequestParameter

      public static Map<String,String> getRequestParameter(String parameters)
    • classExists

      public static boolean classExists(String className)
    • createInstanceOrNull

      public static <T> T createInstanceOrNull(String className)
    • getLoadUrlByConfigFile

      public static Optional<String> getLoadUrlByConfigFile(String loadType, String key, String suffix)
    • getFormat

      public static DateTimeFormatter getFormat(String format)
    • parseCharFromConfig

      public static char parseCharFromConfig(Map<String,Object> config, String key, char defaultValue)
    • flattenMap

      public static Map<String,Object> flattenMap(Map<String,Object> map, String prefix)
    • rebind

      public static org.neo4j.graphdb.Node rebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Node node)
    • rebind

      public static org.neo4j.graphdb.Relationship rebind(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Relationship rel)
    • rebind

      public static <T extends org.neo4j.graphdb.Entity> T rebind(org.neo4j.graphdb.Transaction tx, T e)
    • rebind

      public static <T extends org.neo4j.graphdb.Entity> List<T> rebind(List<T> entities, org.neo4j.graphdb.Transaction tx)
    • mergeNode

      public static org.neo4j.graphdb.Node mergeNode(org.neo4j.graphdb.Transaction tx, org.neo4j.graphdb.Label primaryLabel, org.neo4j.graphdb.Label addtionalLabel, org.apache.commons.lang3.tuple.Pair<String,Object>... pairs)
    • intersection

      public static <T> Set<T> intersection(Collection<T> a, Collection<T> b)
    • validateQuery

      public static void validateQuery(org.neo4j.graphdb.GraphDatabaseService db, String statement, org.neo4j.graphdb.QueryExecutionType.QueryType... supportedQueryTypes)
    • validateQuery

      public static void validateQuery(org.neo4j.graphdb.GraphDatabaseService db, String statement, Set<org.neo4j.procedure.Mode> supportedModes, org.neo4j.graphdb.QueryExecutionType.QueryType... supportedQueryTypes)
    • getAllQueryProcs

      public static void getAllQueryProcs(org.neo4j.graphdb.ExecutionPlanDescription executionPlanDescription, Set<String> procs)
    • newDaemonThread

      public static Thread newDaemonThread(Runnable target)
      all new threads being created within apoc should be daemon threads to allow graceful termination, so use this whenever you need a thread
      Parameters:
      target -
      Returns:
    • encodeUserColonPassToBase64

      public static String encodeUserColonPassToBase64(String userPass)
    • extractCredentialsIfNeeded

      public static Map<String,Object> extractCredentialsIfNeeded(String url, boolean failOnError)
    • isSelfRel

      public static boolean isSelfRel(org.neo4j.graphdb.Relationship rel)
    • toPoint

      public static org.neo4j.values.storable.PointValue toPoint(Map<String,Object> pointMap, Map<String,Object> defaultPointMap)
    • getStringOrCompressedData

      public static Object getStringOrCompressedData(StringWriter writer, ExportConfig config)
    • withTransactionAndRebind

      public static <T extends org.neo4j.graphdb.Entity> T withTransactionAndRebind(org.neo4j.graphdb.GraphDatabaseService db, org.neo4j.graphdb.Transaction transaction, Function<org.neo4j.graphdb.Transaction,T> action)
    • getConstraintCategory

      public static Util.ConstraintCategory getConstraintCategory(org.neo4j.graphdb.schema.ConstraintType type)
    • getConstraintCategory

      public static Util.ConstraintCategory getConstraintCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor)
    • constraintIsUnique

      public static boolean constraintIsUnique(org.neo4j.graphdb.schema.ConstraintType type)
    • isNodeCategory

      public static boolean isNodeCategory(org.neo4j.graphdb.schema.ConstraintType type)
    • isRelationshipCategory

      public static boolean isRelationshipCategory(org.neo4j.graphdb.schema.ConstraintType type)
    • isNodeCategory

      public static boolean isNodeCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor)
    • isRelationshipCategory

      public static boolean isRelationshipCategory(org.neo4j.internal.schema.ConstraintDescriptor descriptor)
    • getNodeId

      public static long getNodeId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, String elementId)
    • getRelationshipId

      public static long getRelationshipId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, String elementId)
    • getNodeElementId

      public static String getNodeElementId(org.neo4j.kernel.impl.coreapi.InternalTransaction tx, long id)
    • isWindows

      public static boolean isWindows()
    • valueEquals

      public static <T> boolean valueEquals(T one, T other)
    • containsValueEquals

      public static boolean containsValueEquals(Collection<Object> collection, Object value)
    • toAnyValues

      public static <T> List<org.neo4j.values.AnyValue> toAnyValues(List<T> list)
    • indexOf

      public static int indexOf(List<Object> list, Object value)
    • getIndexes

      public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction)
    • getIndexes

      public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.Label label)
    • getIndexes

      public static Iterable<org.neo4j.graphdb.schema.IndexDefinition> getIndexes(org.neo4j.graphdb.Transaction transaction, org.neo4j.graphdb.RelationshipType relType)