Skip to content

Commit

Permalink
Merge pull request #2540 from neo4j-contrib/5.0-element-id
Browse files Browse the repository at this point in the history
Placeholder implementations for Entity#getElementId() for compilation
  • Loading branch information
tinwelint authored Feb 17, 2022
2 parents 5ea1712 + ba1974e commit 9b286d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/main/java/apoc/result/VirtualNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@ public class VirtualNode implements Node {
private final Map<String, Object> props = new HashMap<>();
private final List<Relationship> rels = new ArrayList<>();
private final long id;
private final String elementId;

public VirtualNode(Label[] labels, Map<String, Object> props) {
this.id = MIN_ID.getAndDecrement();
addLabels(asList(labels));
this.props.putAll(props);
this.elementId = null;
}

public VirtualNode(long nodeId, Label[] labels, Map<String, Object> props) {
this.id = nodeId;
addLabels(asList(labels));
this.props.putAll(props);
this.elementId = null;
}

public VirtualNode(long nodeId) {
this.id = nodeId;
this.elementId = null;
}

public VirtualNode(Node node, List<String> propertyNames) {
Expand All @@ -46,6 +50,7 @@ public VirtualNode(Node node, List<String> propertyNames) {
this.labels.addAll(Util.labelStrings(node));
String[] keys = propertyNames.toArray(new String[propertyNames.size()]);
this.props.putAll(node.getProperties(keys));
this.elementId = node.getElementId();
}

public static VirtualNode from(Node node) {
Expand All @@ -57,6 +62,12 @@ public long getId() {
return id;
}

@Override
public String getElementId()
{
return elementId != null ? elementId : String.valueOf( id );
}

@Override
public void delete() {
for (Relationship rel : rels) {
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/apoc/result/VirtualRelationship.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public long getId() {
return id;
}

@Override
public String getElementId()
{
return String.valueOf( id );
}

@Override
public void delete() {
if (getStartNode() instanceof VirtualNode) ((VirtualNode) getStartNode()).delete(this);
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/apoc/result/WrappedNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public long getId() {
return id;
}

@Override
public String getElementId()
{
return String.valueOf( id );
}

@Override
public void delete() {
for (Relationship rel : rels) {
Expand Down

0 comments on commit 9b286d4

Please sign in to comment.