@Test public final void testMergeWithFilter() { BioPAXFactory factory = BioPAXLevel.L3.getDefaultFactory(); Model model = factory.createModel(); BioSource human = model.addNew(BioSource.class, "human"); human.setStandardName("Homo sapiens"); UnificationXref uxHuman = model.addNew(UnificationXref.class, "9606"); uxHuman.setDb("taxonomy"); uxHuman.setId("9606"); human.addXref(uxHuman); ProteinReference pr = model.addNew(ProteinReference.class, "pr"); pr.setDisplayName("one"); pr.setOrganism(human); ProteinReference pr1 = factory.create(ProteinReference.class, "pr"); Xref ux = factory.create(UnificationXref.class, "ux"); ux.setDb("UniProt"); ux.setId("P12345"); pr1.addName("one"); pr1.addName("two"); pr1.addXref(ux); UnificationXref uxHuman1 = factory.create(UnificationXref.class, "9606"); uxHuman1.setDb("Taxonomy"); uxHuman1.setId("9606"); BioSource human1 = factory.create(BioSource.class, "human"); human1.addXref(uxHuman1); human1.setDisplayName("human"); pr1.setOrganism(human1); PublicationXref px = factory.create(PublicationXref.class, "publication"); px.setId("00000"); px.setDb("PubMed"); human1.addXref(px); SimpleMerger merger = new SimpleMerger(SimpleEditorMap.L3, new Filter<BioPAXElement>() { public boolean filter(BioPAXElement object) { return object instanceof EntityReference; } }); merger.merge(model, pr1); assertEquals(5, model.getObjects().size()); ProteinReference mergedPr = (ProteinReference) model.getByID("pr"); assertFalse(mergedPr.getXref().isEmpty()); assertEquals("one", mergedPr.getDisplayName()); assertEquals(2, mergedPr.getName().size()); assertEquals("Homo sapiens", mergedPr.getOrganism().getStandardName()); assertNull(mergedPr.getOrganism().getDisplayName()); assertEquals(1, mergedPr.getOrganism().getName().size()); assertEquals(1, mergedPr.getOrganism().getXref().size()); px = (PublicationXref)model.getByID("publication"); assertNotNull(px); for(XReferrable xReferrable : px.getXrefOf()) assertFalse(model.contains(xReferrable)); merger = new SimpleMerger(SimpleEditorMap.L3, new Filter<BioPAXElement>() { public boolean filter(BioPAXElement object) { return object instanceof EntityReference || object instanceof BioSource; } }); model = factory.createModel(); model.add(pr); model.add(human); model.add(uxHuman); merger.merge(model, pr1); assertEquals(5, model.getObjects().size()); mergedPr = (ProteinReference) model.getByID("pr"); assertFalse(mergedPr.getXref().isEmpty()); assertEquals("one", mergedPr.getDisplayName()); assertEquals(2, mergedPr.getName().size()); assertEquals("Homo sapiens", mergedPr.getOrganism().getStandardName()); assertNull(mergedPr.getOrganism().getDisplayName()); assertEquals(2, mergedPr.getOrganism().getName().size()); assertTrue(mergedPr.getOrganism().getName().contains("human")); assertEquals(2, mergedPr.getOrganism().getXref().size()); px = (PublicationXref)model.getByID("publication"); assertNotNull(px); assertTrue(mergedPr.getOrganism().getXref().contains(px)); assertTrue(mergedPr.getOrganism().getXref().contains(uxHuman)); assertFalse(mergedPr.getOrganism().getXref().contains(uxHuman1)); }
public void merge(Model target, Model... sources) { for (Model source : sources) if (source != null) merge(target, source.getObjects()); }
SimpleMerger { public void merge(Model target, Model... sources) { for (Model source : sources) if (source != null) merge(target, source.getObjects()); } }
SimpleMerger { public void merge(Model target, Model... sources) { for (Model source : sources) if (source != null) merge(target, source.getObjects()); } SimpleMerger(EditorMap map);  SimpleMerger(EditorMap map, Filter<BioPAXElement> mergePropOf); }
SimpleMerger { public void merge(Model target, Model... sources) { for (Model source : sources) if (source != null) merge(target, source.getObjects()); } SimpleMerger(EditorMap map);  SimpleMerger(EditorMap map, Filter<BioPAXElement> mergePropOf); void merge(Model target, Model... sources); void merge(Model target, Collection<? extends BioPAXElement> elements); void merge(Model target, BioPAXElement source); }
SimpleMerger { public void merge(Model target, Model... sources) { for (Model source : sources) if (source != null) merge(target, source.getObjects()); } SimpleMerger(EditorMap map);  SimpleMerger(EditorMap map, Filter<BioPAXElement> mergePropOf); void merge(Model target, Model... sources); void merge(Model target, Collection<? extends BioPAXElement> elements); void merge(Model target, BioPAXElement source);  }