@Test public void overlapping2() { final TaxonImpl taxonA = new TaxonImpl("name","id"); taxonA.setPath("one | two | three"); final TaxonImpl taxonB = new TaxonImpl("otherName", "id"); taxonB.setPath("one | two"); final TaxonImpl taxonC = new TaxonImpl("otherName", "ids"); taxonC.setPath("three | four"); final List<Taxon> taxons = TaxonUtil.determineNonOverlappingTaxa( Arrays.asList(taxonA, taxonB, taxonC)); assertThat(taxons.size(), is(2)); assertThat(taxons.get(0).getPath(), is("one | two")); }
public static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa) { List<Taxon> nonOverlapping = new ArrayList<>(collectTaxa); List<Taxon> overlapping; while ((overlapping = nextOverlapping(nonOverlapping)).size() == 2) { final Taxon first = overlapping.get(0); final String[] split1 = split(first.getPath(), CharsetConstant.SEPARATOR_CHAR); final Taxon second = overlapping.get(1); final String[] split2 = split(second.getPath(), CharsetConstant.SEPARATOR_CHAR); if (split1 != null && split2 != null && split1.length > split2.length) { nonOverlapping.remove(first); } else { nonOverlapping.remove(second); } } return nonOverlapping; }
TaxonUtil { public static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa) { List<Taxon> nonOverlapping = new ArrayList<>(collectTaxa); List<Taxon> overlapping; while ((overlapping = nextOverlapping(nonOverlapping)).size() == 2) { final Taxon first = overlapping.get(0); final String[] split1 = split(first.getPath(), CharsetConstant.SEPARATOR_CHAR); final Taxon second = overlapping.get(1); final String[] split2 = split(second.getPath(), CharsetConstant.SEPARATOR_CHAR); if (split1 != null && split2 != null && split1.length > split2.length) { nonOverlapping.remove(first); } else { nonOverlapping.remove(second); } } return nonOverlapping; } }
TaxonUtil { public static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa) { List<Taxon> nonOverlapping = new ArrayList<>(collectTaxa); List<Taxon> overlapping; while ((overlapping = nextOverlapping(nonOverlapping)).size() == 2) { final Taxon first = overlapping.get(0); final String[] split1 = split(first.getPath(), CharsetConstant.SEPARATOR_CHAR); final Taxon second = overlapping.get(1); final String[] split2 = split(second.getPath(), CharsetConstant.SEPARATOR_CHAR); if (split1 != null && split2 != null && split1.length > split2.length) { nonOverlapping.remove(first); } else { nonOverlapping.remove(second); } } return nonOverlapping; }  }
TaxonUtil { public static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa) { List<Taxon> nonOverlapping = new ArrayList<>(collectTaxa); List<Taxon> overlapping; while ((overlapping = nextOverlapping(nonOverlapping)).size() == 2) { final Taxon first = overlapping.get(0); final String[] split1 = split(first.getPath(), CharsetConstant.SEPARATOR_CHAR); final Taxon second = overlapping.get(1); final String[] split2 = split(second.getPath(), CharsetConstant.SEPARATOR_CHAR); if (split1 != null && split2 != null && split1.length > split2.length) { nonOverlapping.remove(first); } else { nonOverlapping.remove(second); } } return nonOverlapping; }  static Map<String, String> taxonToMap(Taxon taxon); static Map<String, String> taxonToMap(Taxon taxon, String prefix); static void mapToTaxon(Map<String, String> properties, Taxon taxon); static Taxon enrich(PropertyEnricher enricher, Taxon taxon); static Taxon mapToTaxon(Map<String, String> properties); static Taxon copy(Taxon taxon); static Taxon copy(Taxon srcTaxon, Taxon targetTaxon); static boolean likelyHomonym(Taxon taxonA, Taxon taxonB); static boolean overlap(Taxon taxonA, Taxon taxonB); static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa); static List<Taxon> nextOverlapping(List<Taxon> collectTaxa); static boolean taxonPathLengthMismatch(Map<String, String> pathMapA, Map<String, String> pathMapB); static Map<String, String> toPathNameMap(Taxon taxonA); static Map<String, String> toPathIdMap(Taxon taxonA); static TaxonImage enrichTaxonImageWithTaxon(Map<String, String> taxon, TaxonImage taxonImage); static TaxonImage enrichTaxonImageWithTaxon(
            Map<String, String> taxon,
            TaxonImage taxonImage,
            String preferredLanguage); static boolean isResolved(Taxon taxon); static boolean isResolved(Map<String, String> properties); static boolean isNonEmptyValue(String value); static boolean isEmptyValue(String value); static String generateTargetTaxonPath(Map<String, String> properties); static String generateTaxonPath(Map<String, String> properties,
                                           List<String> allRanks,
                                           String genusRank,
                                           String specificEpithetRank,
                                           String subspecificEpithetRank); static String generateTaxonPath(Map<String, String> properties,
                                           List<String> allRanks,
                                           String genusRank,
                                           String specificEpithetRank,
                                           String subspecificEpithetRank,
                                           String speciesRank); static String generateTaxonPathNames(Map<String, String> properties,
                                                List<String> allRanks,
                                                String keyPrefix,
                                                String genusRank,
                                                String specificEpithetRank,
                                                String subspecificEpithetRank,
                                                String speciesRank); final static List<String> getAllTargetTaxonRanks(); final static List<String> getAllSourceTaxonRanks(); static String generateTargetTaxonPathNames(Map<String, String> properties); static String generateSourceTaxonPath(Map<String, String> properties); static String generateSourceTaxonPathNames(Map<String, String> properties); static String generateTaxonName(Map<String, String> properties,
                                           List<String> higherOrderRankKeys,
                                           String genusKey,
                                           String specificEpithetKey,
                                           String subspecificEpithetKey,
                                           String speciesKey); static String generateSpeciesName(Map<String, String> properties, String genusKey, String specificEpithetKey, String subspecificEpithetKey, String speciesKey); static String generateSourceTaxonName(Map<String, String> properties); static String generateTargetTaxonName(Map<String, String> properties); static void enrichTaxonNames(Map<String, String> properties); static boolean nonBlankNodeOrNonBlankId(Taxon taxon); static String generateTaxonPath(Map<String, String> nameMap); static String generateTaxonPathNames(Map<String, String> nameMap); static boolean hasLiteratureReference(Taxon taxon); }
TaxonUtil { public static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa) { List<Taxon> nonOverlapping = new ArrayList<>(collectTaxa); List<Taxon> overlapping; while ((overlapping = nextOverlapping(nonOverlapping)).size() == 2) { final Taxon first = overlapping.get(0); final String[] split1 = split(first.getPath(), CharsetConstant.SEPARATOR_CHAR); final Taxon second = overlapping.get(1); final String[] split2 = split(second.getPath(), CharsetConstant.SEPARATOR_CHAR); if (split1 != null && split2 != null && split1.length > split2.length) { nonOverlapping.remove(first); } else { nonOverlapping.remove(second); } } return nonOverlapping; }  static Map<String, String> taxonToMap(Taxon taxon); static Map<String, String> taxonToMap(Taxon taxon, String prefix); static void mapToTaxon(Map<String, String> properties, Taxon taxon); static Taxon enrich(PropertyEnricher enricher, Taxon taxon); static Taxon mapToTaxon(Map<String, String> properties); static Taxon copy(Taxon taxon); static Taxon copy(Taxon srcTaxon, Taxon targetTaxon); static boolean likelyHomonym(Taxon taxonA, Taxon taxonB); static boolean overlap(Taxon taxonA, Taxon taxonB); static List<Taxon> determineNonOverlappingTaxa(List<Taxon> collectTaxa); static List<Taxon> nextOverlapping(List<Taxon> collectTaxa); static boolean taxonPathLengthMismatch(Map<String, String> pathMapA, Map<String, String> pathMapB); static Map<String, String> toPathNameMap(Taxon taxonA); static Map<String, String> toPathIdMap(Taxon taxonA); static TaxonImage enrichTaxonImageWithTaxon(Map<String, String> taxon, TaxonImage taxonImage); static TaxonImage enrichTaxonImageWithTaxon(
            Map<String, String> taxon,
            TaxonImage taxonImage,
            String preferredLanguage); static boolean isResolved(Taxon taxon); static boolean isResolved(Map<String, String> properties); static boolean isNonEmptyValue(String value); static boolean isEmptyValue(String value); static String generateTargetTaxonPath(Map<String, String> properties); static String generateTaxonPath(Map<String, String> properties,
                                           List<String> allRanks,
                                           String genusRank,
                                           String specificEpithetRank,
                                           String subspecificEpithetRank); static String generateTaxonPath(Map<String, String> properties,
                                           List<String> allRanks,
                                           String genusRank,
                                           String specificEpithetRank,
                                           String subspecificEpithetRank,
                                           String speciesRank); static String generateTaxonPathNames(Map<String, String> properties,
                                                List<String> allRanks,
                                                String keyPrefix,
                                                String genusRank,
                                                String specificEpithetRank,
                                                String subspecificEpithetRank,
                                                String speciesRank); final static List<String> getAllTargetTaxonRanks(); final static List<String> getAllSourceTaxonRanks(); static String generateTargetTaxonPathNames(Map<String, String> properties); static String generateSourceTaxonPath(Map<String, String> properties); static String generateSourceTaxonPathNames(Map<String, String> properties); static String generateTaxonName(Map<String, String> properties,
                                           List<String> higherOrderRankKeys,
                                           String genusKey,
                                           String specificEpithetKey,
                                           String subspecificEpithetKey,
                                           String speciesKey); static String generateSpeciesName(Map<String, String> properties, String genusKey, String specificEpithetKey, String subspecificEpithetKey, String speciesKey); static String generateSourceTaxonName(Map<String, String> properties); static String generateTargetTaxonName(Map<String, String> properties); static void enrichTaxonNames(Map<String, String> properties); static boolean nonBlankNodeOrNonBlankId(Taxon taxon); static String generateTaxonPath(Map<String, String> nameMap); static String generateTaxonPathNames(Map<String, String> nameMap); static boolean hasLiteratureReference(Taxon taxon); static final String SOURCE_TAXON; static final String SOURCE_TAXON_KINGDOM; static final String SOURCE_TAXON_PHYLUM; static final String SOURCE_TAXON_CLASS; static final String SOURCE_TAXON_SUBCLASS; static final String SOURCE_TAXON_SUPERORDER; static final String SOURCE_TAXON_ORDER; static final String SOURCE_TAXON_SUBORDER; static final String SOURCE_TAXON_INFRAORDER; static final String SOURCE_TAXON_PARVORDER; static final String SOURCE_TAXON_SUPERFAMILY; static final String SOURCE_TAXON_FAMILY; static final String SOURCE_TAXON_SUBFAMILY; static final String SOURCE_TAXON_GENUS; static final String SOURCE_TAXON_SUBGENUS; static final String SOURCE_TAXON_SPECIFIC_EPITHET; static final String SOURCE_TAXON_SUBSPECIFIC_EPITHET; static final List<String> SOURCE_TAXON_HIGHER_ORDER_RANK_KEYS; static final String TARGET_TAXON; static final String TARGET_TAXON_KINGDOM; static final String TARGET_TAXON_PHYLUM; static final String TARGET_TAXON_CLASS; static final String TARGET_TAXON_SUBCLASS; static final String TARGET_TAXON_SUPERORDER; static final String TARGET_TAXON_ORDER; static final String TARGET_TAXON_SUBORDER; static final String TARGET_TAXON_INFRAORDER; static final String TARGET_TAXON_PARVORDER; static final String TARGET_TAXON_SUPERFAMILY; static final String TARGET_TAXON_FAMILY; static final String TARGET_TAXON_SUBFAMILY; static final String TARGET_TAXON_GENUS; static final String TARGET_TAXON_SUBGENUS; static final String TARGET_TAXON_SPECIFIC_EPITHET; static final String TARGET_TAXON_SUBSPECIFIC_EPITHET; static final List<String> TARGET_TAXON_HIGHER_ORDER_RANK_KEYS; static final String SOURCE_TAXON_NAME; static final String SOURCE_TAXON_ID; static final String SOURCE_TAXON_PATH; static final String SOURCE_TAXON_PATH_NAMES; static final String TARGET_TAXON_PATH; static final String TARGET_TAXON_PATH_NAMES; static final String TARGET_TAXON_ID; static final String TARGET_TAXON_NAME; static final List<String> TAXON_RANK_PROPERTY_NAMES; static final String SOURCE_TAXON_RANK; static final String SOURCE_TAXON_PATH_IDS; static final String TARGET_TAXON_PATH_IDS; static final String TARGET_TAXON_RANK; static final String TARGET_TAXON_SPECIES; static final String SOURCE_TAXON_SPECIES; static final List<String> TAXON_RANK_NAMES; }