Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Use index as entity name in arrays of objects (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Nov 19, 2021
1 parent 181d36d commit bd902fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion metafix/src/main/java/org/metafacture/metafix/Metafix.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void emit(final String field, final Value value) {
final Value arrayValue = array.get(i);

if (arrayValue.isHash()) {
outputStreamReceiver.startEntity(isMulti ? "" : field);
outputStreamReceiver.startEntity(isMulti ? (i + 1) + "" : field);
arrayValue.asHash().forEach(this::emit);
outputStreamReceiver.endEntity();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public void doListWithAppendAndLast() {
}, (o, f) -> {
o.get().startRecord("1");
o.get().startEntity("author[]");
o.get().startEntity("");
o.get().startEntity("1");
o.get().literal("name", "A University");
// o.get().literal("type", "Default"); // FIXME: bind scope broken
o.get().endEntity();
o.get().startEntity("");
o.get().startEntity("2");
o.get().literal("name", "Max");
o.get().literal("type", "Default");
f.apply(2).endEntity();
Expand Down Expand Up @@ -182,11 +182,11 @@ public void doListEntitesToEntities() {
}, (o, f) -> {
o.get().startRecord("1");
o.get().startEntity("author[]");
o.get().startEntity("");
o.get().startEntity("1");
o.get().literal("name", "A University");
o.get().literal("type", "Organization");
o.get().endEntity();
o.get().startEntity("");
o.get().startEntity("2");
o.get().literal("name", "Max");
o.get().literal("type", "Person");
f.apply(2).endEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ public void copyIntoArrayOfObjects() {
}, (o, f) -> {
o.get().startRecord("1");
o.get().startEntity("author[]");
o.get().startEntity("");
o.get().startEntity("1");
o.get().literal("name", "max");
o.get().endEntity();
o.get().startEntity("");
o.get().startEntity("2");
o.get().literal("name", "mo");
f.apply(2).endEntity();
o.get().endRecord();
Expand Down Expand Up @@ -653,7 +653,7 @@ public void mixedArray() {
o.get().startRecord("1");
o.get().startEntity("@context[]");
o.get().literal("1", "https://w3id.org/kim/lrmi-profile/draft/context.jsonld");
o.get().startEntity("");
o.get().startEntity("2");
o.get().literal("@language", "de");
f.apply(2).endEntity();
o.get().endRecord();
Expand Down

0 comments on commit bd902fd

Please sign in to comment.