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) {
|
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> 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> labelsIfNew = update.getLabelsIfNew().stream().map(l -> copy(l)).collect(Collectors.toSet());
|
||||||
Set<MonolingualTextValue> descriptions = update.getDescriptions().stream().map(l -> copy(l))
|
Set<MonolingualTextValue> descriptions = update.getDescriptions().stream().map(l -> copy(l))
|
||||||
@ -100,6 +101,6 @@ public class ReconEntityRewriter extends DatamodelConverter {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Set<Statement> deletedStatements = update.getDeletedStatements().stream().map(l -> copy(l))
|
Set<Statement> deletedStatements = update.getDeletedStatements().stream().map(l -> copy(l))
|
||||||
.collect(Collectors.toSet());
|
.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("<Update on ");
|
||||||
builder.append(qid);
|
builder.append(qid);
|
||||||
if (!labels.isEmpty()) {
|
if (!labels.isEmpty()) {
|
||||||
builder.append("\n Labels: ");
|
builder.append("\n Labels (override): ");
|
||||||
builder.append(labels);
|
builder.append(labels);
|
||||||
}
|
}
|
||||||
|
if (!labelsIfNew.isEmpty()) {
|
||||||
|
builder.append("\n Labels (if new): ");
|
||||||
|
builder.append(labelsIfNew);
|
||||||
|
}
|
||||||
if (!descriptions.isEmpty()) {
|
if (!descriptions.isEmpty()) {
|
||||||
builder.append("\n Descriptions: ");
|
builder.append("\n Descriptions (override): ");
|
||||||
builder.append(descriptions);
|
builder.append(descriptions);
|
||||||
}
|
}
|
||||||
|
if (!descriptionsIfNew.isEmpty()) {
|
||||||
|
builder.append("\n Descriptions (if new): ");
|
||||||
|
builder.append(descriptionsIfNew);
|
||||||
|
}
|
||||||
if (!aliases.isEmpty()) {
|
if (!aliases.isEmpty()) {
|
||||||
builder.append("\n Aliases: ");
|
builder.append("\n Aliases: ");
|
||||||
builder.append(aliases);
|
builder.append(aliases);
|
||||||
|
@ -83,6 +83,19 @@ public class ReconEntityRewriterTest {
|
|||||||
.addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true)
|
.addLabel(Datamodel.makeMonolingualTextValue("label", "de"), true)
|
||||||
.addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false)
|
.addDescription(Datamodel.makeMonolingualTextValue("beschreibung", "de"), false)
|
||||||
.addAlias(Datamodel.makeMonolingualTextValue("darstellung", "de")).build();
|
.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