Fix duplicate creations, closes #2206
This commit is contained in:
parent
11c7788239
commit
ec5c9cd418
@ -89,6 +89,7 @@ public class ReconEntityRewriter extends DatamodelConverter {
|
||||
}
|
||||
|
||||
public ItemUpdate rewrite(ItemUpdate update) {
|
||||
ItemIdValue subject = copy(update.getItemId());
|
||||
Set<MonolingualTextValue> labels = update.getLabels().stream().map(l -> copy(l)).collect(Collectors.toSet());
|
||||
Set<MonolingualTextValue> labelsIfNew = update.getLabelsIfNew().stream().map(l -> copy(l)).collect(Collectors.toSet());
|
||||
Set<MonolingualTextValue> descriptions = update.getDescriptions().stream().map(l -> copy(l))
|
||||
@ -100,6 +101,6 @@ public class ReconEntityRewriter extends DatamodelConverter {
|
||||
.collect(Collectors.toList());
|
||||
Set<Statement> deletedStatements = update.getDeletedStatements().stream().map(l -> copy(l))
|
||||
.collect(Collectors.toSet());
|
||||
return new ItemUpdate(update.getItemId(), addedStatements, deletedStatements, labels, labelsIfNew, descriptions, descriptionsIfNew, aliases);
|
||||
return new ItemUpdate(subject, addedStatements, deletedStatements, labels, labelsIfNew, descriptions, descriptionsIfNew, aliases);
|
||||
}
|
||||
}
|
||||
|
@ -407,13 +407,21 @@ public class ItemUpdate {
|
||||
builder.append("<Update on ");
|
||||
builder.append(qid);
|
||||
if (!labels.isEmpty()) {
|
||||
builder.append("\n Labels: ");
|
||||
builder.append("\n Labels (override): ");
|
||||
builder.append(labels);
|
||||
}
|
||||
if (!labelsIfNew.isEmpty()) {
|
||||
builder.append("\n Labels (if new): ");
|
||||
builder.append(labelsIfNew);
|
||||
}
|
||||
if (!descriptions.isEmpty()) {
|
||||
builder.append("\n Descriptions: ");
|
||||
builder.append("\n Descriptions (override): ");
|
||||
builder.append(descriptions);
|
||||
}
|
||||
if (!descriptionsIfNew.isEmpty()) {
|
||||
builder.append("\n Descriptions (if new): ");
|
||||
builder.append(descriptionsIfNew);
|
||||
}
|
||||
if (!aliases.isEmpty()) {
|
||||
builder.append("\n Aliases: ");
|
||||
builder.append(aliases);
|
||||
|
@ -83,6 +83,19 @@ public class ReconEntityRewriterTest {
|
||||
.addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true)
|
||||
.addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false)
|
||||
.addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
|
||||
assertEquals(expected, rewritten);
|
||||
assertEquals(rewritten, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRewriteCreation() {
|
||||
library.setQid(4567L, "Q1234");
|
||||
ItemUpdate update = new ItemUpdateBuilder(TestingData.newIdB)
|
||||
.addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false)
|
||||
.addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
|
||||
ItemUpdate rewritten = rewriter.rewrite(update);
|
||||
ItemUpdate expected = new ItemUpdateBuilder(newlyCreated)
|
||||
.addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false)
|
||||
.addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
|
||||
assertEquals(rewritten, expected);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user