DatamodelConverter implements SnakVisitor<Snak>,
		ValueVisitor<Value> { public ItemIdValue copy(ItemIdValue object) { return dataObjectFactory.getItemIdValue(object.getId(), object.getSiteIri()); } DatamodelConverter(DataObjectFactory dataObjectFactory); @Deprecated boolean hasOptionDeepCopy(); @Deprecated void setOptionDeepCopy(boolean value); @Deprecated boolean hasOptionDeepCopyReferences(); @Deprecated void setOptionDeepCopyReferences(boolean value); @Deprecated void setOptionFilter(DocumentDataFilter filter); @Deprecated Set<String> getOptionLanguageFilter(); @Deprecated void setOptionLanguageFilter(Set<String> languageFilter); @Deprecated Set<PropertyIdValue> getOptionPropertyFilter(); @Deprecated void setOptionPropertyFilter(Set<PropertyIdValue> propertyFilter); @Deprecated Set<String> getOptionSiteLinkFilter(); @Deprecated void setOptionSiteLinkFilter(Set<String> siteLinkFilter); ItemIdValue copy(ItemIdValue object); PropertyIdValue copy(PropertyIdValue object); LexemeIdValue copy(LexemeIdValue object); DatatypeIdValue copy(DatatypeIdValue object); TimeValue copy(TimeValue object); GlobeCoordinatesValue copy(GlobeCoordinatesValue object); StringValue copy(StringValue object); MonolingualTextValue copy(MonolingualTextValue object); QuantityValue copy(QuantityValue object); UnsupportedValue copy(UnsupportedValue object); ValueSnak copy(ValueSnak object); SomeValueSnak copy(SomeValueSnak object); NoValueSnak copy(NoValueSnak object); SnakGroup copy(SnakGroup object); Claim copy(Claim object); Reference copy(Reference object); Statement copy(Statement object); StatementGroup copy(StatementGroup object); SiteLink copy(SiteLink object); PropertyDocument copy(PropertyDocument object); ItemDocument copy(ItemDocument object); Snak copySnak(Snak snak); @Override Snak visit(ValueSnak snak); @Override Snak visit(SomeValueSnak snak); @Override Snak visit(NoValueSnak snak); Value copyValue(Value value); @Override Value visit(EntityIdValue value); @Override Value visit(GlobeCoordinatesValue value); @Override Value visit(MonolingualTextValue value); @Override Value visit(QuantityValue value); @Override Value visit(StringValue value); @Override Value visit(TimeValue value); @Override Value visit(UnsupportedValue value);  }
@Test public void testSingleBrokenStatement() { StatementGroup sg1 = Datamodel.makeStatementGroup(Collections .singletonList(getBrokenStatement())); StatementGroup sg2 = getTestStatementGroup(2, 5, 1, EntityIdValue.ET_ITEM); List<StatementGroup> brokenSgs = new ArrayList<>(); brokenSgs.add(sg1); brokenSgs.add(sg2); List<StatementGroup> fixedSgs = new ArrayList<>(); fixedSgs.add(sg2); ItemDocument brokenId = Datamodel.makeItemDocument( getTestItemIdValue(2), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), brokenSgs, Collections.emptyMap()); ItemDocument fixedId = Datamodel.makeItemDocument( getTestItemIdValue(2), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), fixedSgs, Collections.emptyMap()); DatamodelConverter dmc = new DatamodelConverter( new DataObjectFactoryImpl()); assertEquals(fixedId, dmc.copy(brokenId)); }
@Test public void testBrokenStatement() { List<Statement> brokenSg1Statements = new ArrayList<>(); brokenSg1Statements.add(getTestStatement(2, 5, 1, EntityIdValue.ET_ITEM)); brokenSg1Statements.add(getBrokenStatement()); brokenSg1Statements.add(getTestStatement(2, 5, 2, EntityIdValue.ET_ITEM)); StatementGroup brokenSg1 = Datamodel .makeStatementGroup(brokenSg1Statements); List<Statement> fixedSg1Statements = new ArrayList<>(); fixedSg1Statements.add(getTestStatement(2, 5, 1, EntityIdValue.ET_ITEM)); fixedSg1Statements.add(getTestStatement(2, 5, 2, EntityIdValue.ET_ITEM)); StatementGroup fixedSg1 = Datamodel .makeStatementGroup(fixedSg1Statements); StatementGroup sg2 = getTestStatementGroup(2, 5, 1, EntityIdValue.ET_ITEM); List<StatementGroup> brokenSgs = new ArrayList<>(); brokenSgs.add(brokenSg1); brokenSgs.add(sg2); List<StatementGroup> fixedSgs = new ArrayList<>(); fixedSgs.add(fixedSg1); fixedSgs.add(sg2); ItemDocument brokenId = Datamodel.makeItemDocument( getTestItemIdValue(2), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), brokenSgs, Collections.emptyMap()); ItemDocument fixedId = Datamodel.makeItemDocument( getTestItemIdValue(2), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), fixedSgs, Collections.emptyMap()); DatamodelConverter dmc = new DatamodelConverter( new DataObjectFactoryImpl()); assertEquals(fixedId, dmc.copy(brokenId)); }
@Test public void testGenerationFromOtherItemDocument() { ItemDocument item = Datamodel.makeItemDocument( Datamodel.makeWikidataItemIdValue("Q42"), Collections.singletonList(Datamodel.makeMonolingualTextValue("en", "label")), Collections.singletonList(Datamodel.makeMonolingualTextValue("en", "desc")), Collections.singletonList(Datamodel.makeMonolingualTextValue("en", "alias")), Collections.emptyList(), Collections.singletonMap("enwiki", Datamodel.makeSiteLink("foo", "enwiki", Collections.emptyList())) ); DatamodelConverter converter = new DatamodelConverter(new DataObjectFactoryImpl()); assertEquals(item, converter.copy(item)); }