Interface AddSurrogateKey
- All Superinterfaces:
CustomizableRefactoring<AddSurrogateKey>
,Refactoring
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AddSurrogateKey
Provides a refactoring adding a surrogate key to all the nodes that match at least the primary label and optionally some additional labels.static AddSurrogateKey
toNodesMatching
(String customQuery) Adds a surrogate key to all nodes matching the custom query.static AddSurrogateKey
toRelationships
(String type) Provides a refactoring adding a surrogate key to all the relationships that match the given type.static AddSurrogateKey
toRelationshipsMatching
(String customQuery) Adds a surrogate key to all relationships matching the custom query.withGeneratorFunction
(String name) Alters the generator function to be used.withProperty
(String name) Alters the name of the property that is used for the surrogate key.Methods inherited from interface ac.simons.neo4j.migrations.core.refactorings.CustomizableRefactoring
inBatchesOf, withCustomQuery
Methods inherited from interface ac.simons.neo4j.migrations.core.refactorings.Refactoring
apply
-
Field Details
-
DEFAULT_PROPERTY_NAME
The default property name to store the surrogate key.- See Also:
-
DEFAULT_KEY_GENERATOR
The default function to generate surrogate keys.- See Also:
-
-
Method Details
-
toNodes
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 matchadditionalLabels
- The additional or secondary label to match- Returns:
- The refactoring ready to use
-
toRelationships
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
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
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
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
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 isDEFAULT_KEY_GENERATOR
.The function can be given in the form
foobar
in which we will add opening and closing braces or asfoobar(%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
-