Skip to content

Commit 684734b

Browse files
committed
refactor: ensure inconsistencies are being fixed when adding an id property
This never happened in the tests, but may be useful when reading inconsistent crates.
1 parent d43a8dd commit 684734b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/edu/kit/datamanager/ro_crate/entities/AbstractEntity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ private static boolean addProperty(ObjectNode whereToAdd, String key, JsonNode v
239239
* @param id the "id" of the property.
240240
*/
241241
public void addIdProperty(String name, String id) {
242+
if (id == null || id.isBlank()) { return; }
242243
mergeIdIntoValue(id, this.properties.get(name))
243244
.ifPresent(newValue -> {
244-
this.linkedTo.add(id);
245245
this.properties.set(name, newValue);
246-
this.notifyObservers();
247246
});
247+
this.linkedTo.add(id);
248+
this.notifyObservers();
248249
}
249250

250251
/**

0 commit comments

Comments
 (0)