Skip to content

Commit

Permalink
Fix fusions loosing relations (#48)
Browse files Browse the repository at this point in the history
* Cleaning and stack friendly fixes

* Cleaning

* Fix fusions

* Finally fix Fusion dropping relations, aka. "Neo4j fix your shit" commit.
  • Loading branch information
AlexPresso authored Jan 18, 2025
1 parent 02540b7 commit 9ad6df8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ public String getGraphObjectId() {
public String getId() {
return this.id;
}
public BaseGraphObject setId(String id) {
this.id = id;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
public class Fusion extends BaseGraphObject {
@Relationship(type = "FUSION_INPUT", direction = Relationship.Direction.INCOMING)
private Set<FusionToInput> inputs = new HashSet<>();
@JsonProperty("item")
@Relationship(type = "FUSION_RESULT", direction = Relationship.Direction.OUTGOING)
private Item result;

Expand Down Expand Up @@ -58,4 +57,10 @@ public Fusion setResult(final Item item) {
this.result = item;
return this;
}

@JsonProperty("item")
public void unpackResultItem(final Item item) {
this.result = item;
this.setId(item.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ public void updateFusions(final Map<String, Item> items) throws IOException, Int

final var fusions = this.fetchFusions();
final var dbFusions = this.getFusions().stream()
.collect(Collectors.toMap(f -> f.getResult().getId(), Function.identity()));
.collect(Collectors.toMap(Fusion::getId, Function.identity()));

fusions.forEach(f -> dbFusions.put(f.getResult().getId(), dbFusions.getOrDefault(f.getResult().getId(), f)
.setResult(items.getOrDefault(f.getResult().getId(), f.getResult()))
fusions.forEach(f -> dbFusions.put(f.getId(), dbFusions.getOrDefault(f.getId(), f)
.setResult(items.get(f.getId()))
.setInputs(f.getInputs().stream()
.collect(Collectors.toMap(in -> items.get(in.getItem().getId()), FusionToInput::getQuantity))
)
Expand Down

0 comments on commit 9ad6df8

Please sign in to comment.