All Superinterfaces:
CustomizableRefactoring<AddSurrogateKey>, Refactoring

public sealed interface AddSurrogateKey extends CustomizableRefactoring<AddSurrogateKey>
This refactoring adds a surrogate key, either to all nodes matching one or more labels or to all relationships matching a given type. Alternatively, a custom query can be used. The name of the property will default to id but can be configured.

The surrogate key will be generated by the build-in randomUUID function or optionally, by a user defined function.

Since:
1.15.2
Author:
Michael J. Simons
Soundtrack
Max Herre - MTV Unplugged Kahedi Radio Show
  • Field Details

    • DEFAULT_PROPERTY_NAME

      static final String DEFAULT_PROPERTY_NAME
      The default property name to store the surrogate key.
      See Also:
    • DEFAULT_KEY_GENERATOR

      static final String DEFAULT_KEY_GENERATOR
      The default function to generate surrogate keys.
      See Also:
  • Method Details

    • toNodes

      static AddSurrogateKey toNodes(String primaryLabel, String... additionalLabels)
      Provides a refactoring adding a surrogate key to all the nodes that match at least the primary label and optionally some additional labels.
      Parameters:
      primaryLabel - The primary label to match
      additionalLabels - The additional or secondary label to match
      Returns:
      The refactoring ready to use
    • toRelationships

      static AddSurrogateKey toRelationships(String type)
      Provides a refactoring adding a surrogate key to all the relationships that match the given type.
      Parameters:
      type - The type to match
      Returns:
      The refactoring ready to use
    • toNodesMatching

      static AddSurrogateKey toNodesMatching(String customQuery)
      Adds a surrogate key to all nodes matching the custom query. The query must return one single variable identifying the nodes.
      Parameters:
      customQuery - The custom query to use
      Returns:
      The refactoring ready to use
    • toRelationshipsMatching

      static AddSurrogateKey toRelationshipsMatching(String customQuery)
      Adds a surrogate key to all relationships matching the custom query. The query must return one single variable identifying the relationships.
      Parameters:
      customQuery - The custom query to use
      Returns:
      The refactoring ready to use
    • withProperty

      AddSurrogateKey withProperty(String name)
      Alters the name of the property that is used for the surrogate key. The default is #DEFAULT_PROPERTY_NAME.
      Parameters:
      name - The new name of the graph property to store the surrogate key, must not be null or blank
      Returns:
      The refactoring ready to use
    • withGeneratorFunction

      AddSurrogateKey withGeneratorFunction(String name)
      Alters the generator function to be used. The function must be either a build-in stored procedure or any user defined function returning a single value supported as storable property. The default is DEFAULT_KEY_GENERATOR.

      The function can be given in the form foobar in which we will add opening and closing braces or as foobar(%s) %s will be replaced by the name of the variable pointing to the entity being processed

      Parameters:
      name - The new name of the generator function to use
      Returns:
      The refactoring ready to use