Skip to content

Commit f7930a9

Browse files
committed
Deprecate procedures and functions that are easy to do in Cypher and are more performant in Cypher as well.
1 parent cc3b7d5 commit f7930a9

17 files changed

Lines changed: 12444 additions & 8503 deletions

File tree

core/src/main/java/apoc/agg/Graph.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.neo4j.graphdb.Node;
2828
import org.neo4j.graphdb.Path;
2929
import org.neo4j.graphdb.Relationship;
30+
import org.neo4j.kernel.api.QueryLanguage;
31+
import org.neo4j.kernel.api.procedure.QueryLanguageScope;
3032
import org.neo4j.procedure.*;
3133

3234
/**
@@ -35,6 +37,16 @@
3537
*/
3638
public class Graph {
3739
@UserAggregationFunction("apoc.agg.graph")
40+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
41+
@Description(
42+
"Returns all distinct `NODE` and `RELATIONSHIP` values collected into a `MAP` with the keys `nodes` and `relationships`.")
43+
public GraphAggregation graphCypher5() {
44+
return new GraphAggregation();
45+
}
46+
47+
@Deprecated
48+
@UserAggregationFunction(name = "apoc.agg.graph", deprecatedBy = "Cypher's `COLLECT {}` expression.")
49+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
3850
@Description(
3951
"Returns all distinct `NODE` and `RELATIONSHIP` values collected into a `MAP` with the keys `nodes` and `relationships`.")
4052
public GraphAggregation graph() {

core/src/main/java/apoc/agg/Product.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package apoc.agg;
2020

21+
import org.neo4j.kernel.api.QueryLanguage;
22+
import org.neo4j.kernel.api.procedure.QueryLanguageScope;
2123
import org.neo4j.procedure.*;
2224

2325
/**
@@ -26,6 +28,15 @@
2628
*/
2729
public class Product {
2830
@UserAggregationFunction("apoc.agg.product")
31+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
32+
@Description("Returns the product of all non-null `INTEGER` and `FLOAT` values in the collection.")
33+
public ProductFunction productCypher5() {
34+
return new ProductFunction();
35+
}
36+
37+
@Deprecated
38+
@UserAggregationFunction(name = "apoc.agg.product", deprecatedBy = "Cypher's `reduce()`: `RETURN reduce(x = 1, i IN values | x * i)`.")
39+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
2940
@Description("Returns the product of all non-null `INTEGER` and `FLOAT` values in the collection.")
3041
public ProductFunction product() {
3142
return new ProductFunction();

core/src/main/java/apoc/algo/Cover.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.neo4j.graphdb.Node;
3030
import org.neo4j.graphdb.Relationship;
3131
import org.neo4j.graphdb.Transaction;
32+
import org.neo4j.kernel.api.QueryLanguage;
33+
import org.neo4j.kernel.api.procedure.QueryLanguageScope;
3234
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
3335
import org.neo4j.procedure.Context;
3436
import org.neo4j.procedure.Description;
@@ -44,6 +46,17 @@ public record AlgoCoverRelationshipResult(
4446
@Description("The relationships connected to the given nodes.") Relationship rel) {}
4547

4648
@Procedure("apoc.algo.cover")
49+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
50+
@Description("Returns all `RELATIONSHIP` values connecting the given set of `NODE` values.")
51+
public Stream<AlgoCoverRelationshipResult> coverCypher5(
52+
@Name(value = "nodes", description = "The nodes to look for connected relationships on.") Object nodes) {
53+
Set<Node> nodeSet = Util.nodeStream((InternalTransaction) tx, nodes).collect(Collectors.toSet());
54+
return coverNodes(nodeSet).map(AlgoCoverRelationshipResult::new);
55+
}
56+
57+
@Deprecated
58+
@Procedure(name = "apoc.algo.cover", deprecatedBy = "Cypher's `MATCH` and `IN` clauses.")
59+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
4760
@Description("Returns all `RELATIONSHIP` values connecting the given set of `NODE` values.")
4861
public Stream<AlgoCoverRelationshipResult> cover(
4962
@Name(value = "nodes", description = "The nodes to look for connected relationships on.") Object nodes) {

core/src/main/java/apoc/coll/Coll.java

Lines changed: 237 additions & 0 deletions
Large diffs are not rendered by default.

core/src/main/java/apoc/convert/Convert.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.neo4j.graphdb.Entity;
3030
import org.neo4j.graphdb.Node;
3131
import org.neo4j.graphdb.Relationship;
32+
import org.neo4j.kernel.api.QueryLanguage;
33+
import org.neo4j.kernel.api.procedure.QueryLanguageScope;
3234
import org.neo4j.procedure.Description;
3335
import org.neo4j.procedure.Name;
3436
import org.neo4j.procedure.UserFunction;
@@ -54,6 +56,15 @@ public Map<String, Object> toMap(
5456
}
5557

5658
@UserFunction("apoc.convert.toList")
59+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
60+
@Description("Converts the given value into a `LIST<ANY>`.")
61+
public List<Object> toListCypher5(@Name(value = "value", description = "The value to convert into a list.") Object list) {
62+
return ConvertUtils.convertToList(list);
63+
}
64+
65+
@Deprecated
66+
@UserFunction(name = "apoc.convert.toList", deprecatedBy = "Cypher's conversion functions, see the docs for more information.")
67+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
5768
@Description("Converts the given value into a `LIST<ANY>`.")
5869
public List<Object> toList(@Name(value = "value", description = "The value to convert into a list.") Object list) {
5970
return ConvertUtils.convertToList(list);

core/src/main/java/apoc/create/Create.java

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ public class Create {
4545
public Transaction tx;
4646

4747
@Procedure(name = "apoc.create.node", mode = Mode.WRITE)
48+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
49+
@Description("Creates a `NODE` with the given dynamic labels.")
50+
public Stream<CreatedNodeResult> nodeCypher5(
51+
@Name(value = "labels", description = "The labels to assign to the new node.") List<String> labelNames,
52+
@Name(value = "props", description = "The properties to assign to the new node.")
53+
Map<String, Object> props) {
54+
return node(labelNames, props);
55+
}
56+
57+
@Deprecated
58+
@Procedure(name = "apoc.create.node", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic labels: `CREATE (n:$(labels)) SET n = props`")
59+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
4860
@Description("Creates a `NODE` with the given dynamic labels.")
4961
public Stream<CreatedNodeResult> node(
5062
@Name(value = "labels", description = "The labels to assign to the new node.") List<String> labelNames,
@@ -54,6 +66,17 @@ public Stream<CreatedNodeResult> node(
5466
}
5567

5668
@Procedure(name = "apoc.create.addLabels", mode = Mode.WRITE)
69+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
70+
@Description("Adds the given labels to the given `NODE` values.")
71+
public Stream<UpdatedNodeResult> addLabelsCypher5(
72+
@Name(value = "nodes", description = "The nodes to add labels to.") Object nodes,
73+
@Name(value = "labels", description = "The labels to add to the nodes.") List<String> labelNames) {
74+
return addLabels(nodes, labelNames);
75+
}
76+
77+
@Deprecated
78+
@Procedure(name = "apoc.create.addLabels", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic labels; `SET n:$(labels)`.")
79+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
5780
@Description("Adds the given labels to the given `NODE` values.")
5881
public Stream<UpdatedNodeResult> addLabels(
5982
@Name(value = "nodes", description = "The nodes to add labels to.") Object nodes,
@@ -69,6 +92,18 @@ public Stream<UpdatedNodeResult> addLabels(
6992
}
7093

7194
@Procedure(name = "apoc.create.setProperty", mode = Mode.WRITE)
95+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
96+
@Description("Sets the given property to the given `NODE` values.")
97+
public Stream<UpdatedNodeResult> setPropertyCypher5(
98+
@Name(value = "nodes", description = "The nodes to set a property on.") Object nodes,
99+
@Name(value = "key", description = "The name of the property key to set.") String key,
100+
@Name(value = "value", description = "The value of the property to set.") Object value) {
101+
return setProperty(nodes, key, value);
102+
}
103+
104+
@Deprecated
105+
@Procedure(name = "apoc.create.setProperty", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `SET node[key] = value`.")
106+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
72107
@Description("Sets the given property to the given `NODE` values.")
73108
public Stream<UpdatedNodeResult> setProperty(
74109
@Name(value = "nodes", description = "The nodes to set a property on.") Object nodes,
@@ -81,6 +116,18 @@ public Stream<UpdatedNodeResult> setProperty(
81116
}
82117

83118
@Procedure(name = "apoc.create.setRelProperty", mode = Mode.WRITE)
119+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
120+
@Description("Sets the given property on the `RELATIONSHIP` values.")
121+
public Stream<UpdatedRelationshipResult> setRelPropertyCypher5(
122+
@Name(value = "rels", description = "The relationships to set a property on.") Object rels,
123+
@Name(value = "key", description = "The name of the property key to set.") String key,
124+
@Name(value = "value", description = "The value of the property to set.") Object value) {
125+
return setRelProperty(rels, key, value);
126+
}
127+
128+
@Deprecated
129+
@Procedure(name = "apoc.create.setRelProperty", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `SET rel[key] = value`.")
130+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
84131
@Description("Sets the given property on the `RELATIONSHIP` values.")
85132
public Stream<UpdatedRelationshipResult> setRelProperty(
86133
@Name(value = "rels", description = "The relationships to set a property on.") Object rels,
@@ -93,6 +140,19 @@ public Stream<UpdatedRelationshipResult> setRelProperty(
93140
}
94141

95142
@Procedure(name = "apoc.create.setProperties", mode = Mode.WRITE)
143+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
144+
@Description("Sets the given properties to the given `NODE` values.")
145+
public Stream<UpdatedNodeResult> setPropertiesCypher5(
146+
@Name(value = "nodes", description = "The nodes to set properties on.") Object nodes,
147+
@Name(value = "keys", description = "The property keys to set on the given nodes.") List<String> keys,
148+
@Name(value = "values", description = "The values to assign to the properties on the given nodes.")
149+
List<Object> values) {
150+
return setProperties(nodes, keys, values);
151+
}
152+
153+
@Deprecated
154+
@Procedure(name = "apoc.create.setProperties", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `SET node[key] = value`.")
155+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
96156
@Description("Sets the given properties to the given `NODE` values.")
97157
public Stream<UpdatedNodeResult> setProperties(
98158
@Name(value = "nodes", description = "The nodes to set properties on.") Object nodes,
@@ -106,6 +166,18 @@ public Stream<UpdatedNodeResult> setProperties(
106166
}
107167

108168
@Procedure(name = "apoc.create.removeProperties", mode = Mode.WRITE)
169+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
170+
@Description("Removes the given properties from the given `NODE` values.")
171+
public Stream<UpdatedNodeResult> removePropertiesCypher5(
172+
@Name(value = "nodes", description = "The nodes to remove properties from.") Object nodes,
173+
@Name(value = "keys", description = "The property keys to remove from the given nodes.")
174+
List<String> keys) {
175+
return removeProperties(nodes, keys);
176+
}
177+
178+
@Deprecated
179+
@Procedure(name = "apoc.create.removeProperties", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `REMOVE node[key]`.")
180+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
109181
@Description("Removes the given properties from the given `NODE` values.")
110182
public Stream<UpdatedNodeResult> removeProperties(
111183
@Name(value = "nodes", description = "The nodes to remove properties from.") Object nodes,
@@ -118,6 +190,20 @@ public Stream<UpdatedNodeResult> removeProperties(
118190
}
119191

120192
@Procedure(name = "apoc.create.setRelProperties", mode = Mode.WRITE)
193+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
194+
@Description("Sets the given properties on the `RELATIONSHIP` values.")
195+
public Stream<UpdatedRelationshipResult> setRelPropertiesCypher5(
196+
@Name(value = "rels", description = "The relationships to set properties on.") Object rels,
197+
@Name(value = "keys", description = "The keys of the properties to set on the given relationships.")
198+
List<String> keys,
199+
@Name(value = "values", description = "The values of the properties to set on the given relationships.")
200+
List<Object> values) {
201+
return setRelProperties(rels, keys, values);
202+
}
203+
204+
@Deprecated
205+
@Procedure(name = "apoc.create.setRelProperties", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `SET rel[key] = value`.")
206+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
121207
@Description("Sets the given properties on the `RELATIONSHIP` values.")
122208
public Stream<UpdatedRelationshipResult> setRelProperties(
123209
@Name(value = "rels", description = "The relationships to set properties on.") Object rels,
@@ -132,6 +218,18 @@ public Stream<UpdatedRelationshipResult> setRelProperties(
132218
}
133219

134220
@Procedure(name = "apoc.create.removeRelProperties", mode = Mode.WRITE)
221+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
222+
@Description("Removes the given properties from the given `RELATIONSHIP` values.")
223+
public Stream<UpdatedRelationshipResult> removeRelPropertiesCypher5(
224+
@Name(value = "rels", description = "The relationships to remove properties from.") Object rels,
225+
@Name(value = "keys", description = "The property keys to remove from the given nodes.")
226+
List<String> keys) {
227+
return removeRelProperties(rels, keys);
228+
}
229+
230+
@Deprecated
231+
@Procedure(name = "apoc.create.removeRelProperties", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic properties: `REMOVE rel[key]`.")
232+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
135233
@Description("Removes the given properties from the given `RELATIONSHIP` values.")
136234
public Stream<UpdatedRelationshipResult> removeRelProperties(
137235
@Name(value = "rels", description = "The relationships to remove properties from.") Object rels,
@@ -144,6 +242,17 @@ public Stream<UpdatedRelationshipResult> removeRelProperties(
144242
}
145243

146244
@Procedure(name = "apoc.create.setLabels", mode = Mode.WRITE)
245+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
246+
@Description("Sets the given labels to the given `NODE` values. Non-matching labels are removed from the nodes.")
247+
public Stream<UpdatedNodeResult> setLabelsCypher5(
248+
@Name(value = "nodes", description = "The nodes to set labels on.") Object nodes,
249+
@Name(value = "labels", description = "The labels to set on the given nodes.") List<String> labelNames) {
250+
return setLabels(nodes, labelNames);
251+
}
252+
253+
@Deprecated
254+
@Procedure(name = "apoc.create.setLabels", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic labels; `SET n:$(labels)`.")
255+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
147256
@Description("Sets the given labels to the given `NODE` values. Non-matching labels are removed from the nodes.")
148257
public Stream<UpdatedNodeResult> setLabels(
149258
@Name(value = "nodes", description = "The nodes to set labels on.") Object nodes,
@@ -164,6 +273,18 @@ public Stream<UpdatedNodeResult> setLabels(
164273
}
165274

166275
@Procedure(name = "apoc.create.removeLabels", mode = Mode.WRITE)
276+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
277+
@Description("Removes the given labels from the given `NODE` values.")
278+
public Stream<UpdatedNodeResult> removeLabelsCypher(
279+
@Name(value = "nodes", description = "The node to remove labels from.") Object nodes,
280+
@Name(value = "labels", description = "The labels to remove from the given node.")
281+
List<String> labelNames) {
282+
return removeLabels(nodes, labelNames);
283+
}
284+
285+
@Deprecated
286+
@Procedure(name = "apoc.create.removeLabels", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic labels: `REMOVE node:$(labels)`")
287+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
167288
@Description("Removes the given labels from the given `NODE` values.")
168289
public Stream<UpdatedNodeResult> removeLabels(
169290
@Name(value = "nodes", description = "The node to remove labels from.") Object nodes,
@@ -180,6 +301,18 @@ public Stream<UpdatedNodeResult> removeLabels(
180301
}
181302

182303
@Procedure(name = "apoc.create.nodes", mode = Mode.WRITE)
304+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
305+
@Description("Creates `NODE` values with the given dynamic labels.")
306+
public Stream<CreatedNodeResult> nodesCypher5(
307+
@Name(value = "labels", description = "The labels to assign to the new nodes.") List<String> labelNames,
308+
@Name(value = "props", description = "The properties to assign to the new nodes.")
309+
List<Map<String, Object>> props) {
310+
return nodes(labelNames, props);
311+
}
312+
313+
@Deprecated
314+
@Procedure(name = "apoc.create.nodes", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic labels: `UNWIND props AS p CREATE (n:$(labels)) SET n = p`")
315+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
183316
@Description("Creates `NODE` values with the given dynamic labels.")
184317
public Stream<CreatedNodeResult> nodes(
185318
@Name(value = "labels", description = "The labels to assign to the new nodes.") List<String> labelNames,
@@ -190,6 +323,21 @@ public Stream<CreatedNodeResult> nodes(
190323
}
191324

192325
@Procedure(name = "apoc.create.relationship", mode = Mode.WRITE)
326+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_5})
327+
@Description("Creates a `RELATIONSHIP` with the given dynamic relationship type.")
328+
public Stream<CreatedRelationshipResult> relationshipCypher5(
329+
@Name(value = "from", description = "The node from which the outgoing relationship will start.") Node from,
330+
@Name(value = "relType", description = "The type to assign to the new relationship.") String relType,
331+
@Name(value = "props", description = "The properties to assign to the new relationship.")
332+
Map<String, Object> props,
333+
@Name(value = "to", description = "The node to which the incoming relationship will be connected.")
334+
Node to) {
335+
return relationship(from, relType, props, to);
336+
}
337+
338+
@Deprecated
339+
@Procedure(name = "apoc.create.relationship", mode = Mode.WRITE, deprecatedBy = "Cypher's dynamic types: `CREATE (from)-[n:$(relType)]->(to) SET n = props`")
340+
@QueryLanguageScope(scope = {QueryLanguage.CYPHER_25})
193341
@Description("Creates a `RELATIONSHIP` with the given dynamic relationship type.")
194342
public Stream<CreatedRelationshipResult> relationship(
195343
@Name(value = "from", description = "The node from which the outgoing relationship will start.") Node from,

0 commit comments

Comments
 (0)