Skip to content

Commit

Permalink
Deprecate apoc.refactor.deleteAndReconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
loveleif committed Dec 11, 2024
1 parent f6a13c9 commit 35380cb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
43 changes: 41 additions & 2 deletions core/src/main/java/apoc/refactor/GraphRefactoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import java.util.stream.Stream;
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.schema.ConstraintType;
import org.neo4j.kernel.api.QueryLanguage;
import org.neo4j.kernel.api.procedure.QueryLanguageScope;
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
import org.neo4j.logging.Log;
import org.neo4j.procedure.*;
Expand Down Expand Up @@ -624,9 +626,46 @@ public record RefactorGraphResult(
@Description("The remaining nodes.") List<Node> nodes,
@Description("The new connecting relationships.") List<Relationship> relationships) {}

@Procedure(
name = "apoc.refactor.deleteAndReconnect",
mode = Mode.WRITE,
deprecatedBy =
"Deprecated for removal without a direct replacement, use plain Cypher or create a custom procedure.")
@Description(
"""
Removes the given `NODE` values from the `PATH` (and graph, including all of its relationships) and reconnects the remaining `NODE` values.
Note, undefined behaviour for paths that visits the same node multiple times.
Note, nodes that are not connected in the same direction as the path will not be reconnected, for example `MATCH p=(:A)-->(b:B)<--(:C) CALL apoc.refactor.deleteAndReconnect(p, [b]) ...` will not reconnect the :A and :C nodes.""")
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
public Stream<RefactorGraphResult> deleteAndReconnectCypher25(
@Name(
value = "path",
description =
"The path containing the nodes to delete and the remaining nodes to reconnect.")
Path path,
@Name(value = "nodes", description = "The nodes to delete.") List<Node> nodesToRemove,
@Name(
value = "config",
defaultValue = "{}",
description =
"""
{
relationshipSelectionStrategy = "incoming" :: ["incoming", "outgoing", "merge"]
properties :: ["overwrite", "discard", "combine"]
}
""")
Map<String, Object> config) {
return deleteAndReconnectCypher5(path, nodesToRemove, config);
}

@Procedure(name = "apoc.refactor.deleteAndReconnect", mode = Mode.WRITE)
@Description("Removes the given `NODE` values from the `PATH` and reconnects the remaining `NODE` values.")
public Stream<RefactorGraphResult> deleteAndReconnect(
@Description(
"""
Removes the given `NODE` values from the `PATH` (and graph, including all of its relationships) and reconnects the remaining `NODE` values.
Note, undefined behaviour for paths that visits the same node multiple times.
Note, nodes that are not connected in the same direction as the path will not be reconnected, for example `MATCH p=(:A)-->(b:B)<--(:C) CALL apoc.refactor.deleteAndReconnect(p, [b]) ...` will not reconnect the :A and :C nodes.""")
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
public Stream<RefactorGraphResult> deleteAndReconnectCypher5(
@Name(
value = "path",
description =
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/resources/procedures.json
Original file line number Diff line number Diff line change
Expand Up @@ -6586,7 +6586,7 @@
"isDeprecated" : false,
"signature" : "apoc.refactor.deleteAndReconnect(path :: PATH, nodes :: LIST<NODE>, config = {} :: MAP) :: (nodes :: LIST<NODE>, relationships :: LIST<RELATIONSHIP>)",
"name" : "apoc.refactor.deleteAndReconnect",
"description" : "Removes the given `NODE` values from the `PATH` and reconnects the remaining `NODE` values.",
"description" : "Removes the given `NODE` values from the `PATH` (and graph, including all of its relationships) and reconnects the remaining `NODE` values.\nNote, undefined behaviour for paths that visits the same node multiple times.\nNote, nodes that are not connected in the same direction as the path will not be reconnected, for example `MATCH p=(:A)-->(b:B)<--(:C) CALL apoc.refactor.deleteAndReconnect(p, [b]) ...` will not reconnect the :A and :C nodes.",
"returnDescription" : [ {
"name" : "nodes",
"description" : "The remaining nodes.",
Expand Down

0 comments on commit 35380cb

Please sign in to comment.