@Test public void testPropertyFilterForLexeme() { LexemeIdValue l = Datamodel.makeWikidataLexemeIdValue("L42"); FormIdValue f = Datamodel.makeWikidataFormIdValue("L42-F1"); SenseIdValue s = Datamodel.makeWikidataSenseIdValue("L42-S1"); PropertyIdValue p1 = Datamodel.makeWikidataPropertyIdValue("P1"); PropertyIdValue p2 = Datamodel.makeWikidataPropertyIdValue("P2"); PropertyIdValue p3 = Datamodel.makeWikidataPropertyIdValue("P3"); PropertyIdValue p4 = Datamodel.makeWikidataPropertyIdValue("P4"); Set<PropertyIdValue> propertyFilter = new HashSet<>(); propertyFilter.add(p1); propertyFilter.add(p3); DocumentDataFilter documentDataFilter = new DocumentDataFilter(); documentDataFilter.setPropertyFilter(propertyFilter); DatamodelFilter filter = new DatamodelFilter(new DataObjectFactoryImpl(), documentDataFilter); LexemeDocument lexemeDocument = Datamodel.makeLexemeDocument( l, Datamodel.makeWikidataItemIdValue("Q1"), Datamodel.makeWikidataItemIdValue("Q1"), Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Arrays.asList( makeTestStatementGroup(p1, l), makeTestStatementGroup(p2, l), makeTestStatementGroup(p3, l), makeTestStatementGroup(p4, l) ), Collections.singletonList(Datamodel.makeFormDocument( f, Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Collections.emptyList(), Arrays.asList( makeTestStatementGroup(p1, f), makeTestStatementGroup(p2, f), makeTestStatementGroup(p3, f) ) )), Collections.singletonList(Datamodel.makeSenseDocument( s, Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Arrays.asList( makeTestStatementGroup(p1, s), makeTestStatementGroup(p2, s), makeTestStatementGroup(p3, s) ) )) ); LexemeDocument lexemeDocumentFiltered = Datamodel.makeLexemeDocument( l, Datamodel.makeWikidataItemIdValue("Q1"), Datamodel.makeWikidataItemIdValue("Q1"), Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Arrays.asList( makeTestStatementGroup(p1, l), makeTestStatementGroup(p3, l) ), Collections.singletonList(Datamodel.makeFormDocument( f, Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Collections.emptyList(), Arrays.asList( makeTestStatementGroup(p1, f), makeTestStatementGroup(p3, f) ) )), Collections.singletonList(Datamodel.makeSenseDocument( s, Collections.singletonList(Datamodel.makeMonolingualTextValue("foo", "en")), Arrays.asList( makeTestStatementGroup(p1, s), makeTestStatementGroup(p3, s) ) )) ); assertEquals(lexemeDocumentFiltered, filter.filter(lexemeDocument)); }
public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); }
DatamodelFilter { public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); } }
DatamodelFilter { public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); } DatamodelFilter(DataObjectFactory dataObjectFactory, DocumentDataFilter filter); }
DatamodelFilter { public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); } DatamodelFilter(DataObjectFactory dataObjectFactory, DocumentDataFilter filter); ItemDocument filter(ItemDocument item); PropertyDocument filter(PropertyDocument property); MediaInfoDocument filter(MediaInfoDocument mediaInfo); LexemeDocument filter(LexemeDocument lexeme); FormDocument filter(FormDocument form); SenseDocument filter(SenseDocument sense); }
DatamodelFilter { public ItemDocument filter(ItemDocument item) { return dataObjectFactory.getItemDocument( item.getEntityId(), filterMonoLingualTextValues(item.getLabels().values()), filterMonoLingualTextValues(item.getDescriptions().values()), filterMonoLingualTextValues(flatten(item.getAliases().values())), filterStatementGroups(item.getStatementGroups()), filterSiteLinks(item.getSiteLinks()), item.getRevisionId() ); } DatamodelFilter(DataObjectFactory dataObjectFactory, DocumentDataFilter filter); ItemDocument filter(ItemDocument item); PropertyDocument filter(PropertyDocument property); MediaInfoDocument filter(MediaInfoDocument mediaInfo); LexemeDocument filter(LexemeDocument lexeme); FormDocument filter(FormDocument form); SenseDocument filter(SenseDocument sense);  }