@Test public void associatedOccurrencesMalformed() { assertThat(parseAssociatedOccurrences("(eaten by)").size(), is(0)); }
static List<Map<String, String>> parseAssociatedOccurrences(String s) { List<Map<String, String>> propertyList = new ArrayList<>(); String[] relationships = StringUtils.split(s, ";"); for (String relationship : relationships) { String relationshipTrimmed = StringUtils.trim(relationship); int i1 = StringUtils.indexOf(relationshipTrimmed, ")"); if (i1 > -1 && i1 < relationshipTrimmed.length()) { String relation = StringUtils.substring(relationshipTrimmed, 0, i1 + 1); String targetCollectionAndOccurrenceId = StringUtils.trim(StringUtils.substring(relationshipTrimmed, i1 + 1)); int i = StringUtils.indexOf(targetCollectionAndOccurrenceId, " "); if (i > -1) { String occurrenceId = StringUtils.substring(targetCollectionAndOccurrenceId, i); if (StringUtils.isNotBlank(occurrenceId)) { TreeMap<String, String> properties = new TreeMap<>(); properties.put(TARGET_OCCURRENCE_ID, StringUtils.trim(occurrenceId)); properties.put(INTERACTION_TYPE_NAME, StringUtils.trim(relation)); propertyList.add(properties); } } } } return propertyList; }
DatasetImporterForDwCA extends DatasetImporterWithListener { static List<Map<String, String>> parseAssociatedOccurrences(String s) { List<Map<String, String>> propertyList = new ArrayList<>(); String[] relationships = StringUtils.split(s, ";"); for (String relationship : relationships) { String relationshipTrimmed = StringUtils.trim(relationship); int i1 = StringUtils.indexOf(relationshipTrimmed, ")"); if (i1 > -1 && i1 < relationshipTrimmed.length()) { String relation = StringUtils.substring(relationshipTrimmed, 0, i1 + 1); String targetCollectionAndOccurrenceId = StringUtils.trim(StringUtils.substring(relationshipTrimmed, i1 + 1)); int i = StringUtils.indexOf(targetCollectionAndOccurrenceId, " "); if (i > -1) { String occurrenceId = StringUtils.substring(targetCollectionAndOccurrenceId, i); if (StringUtils.isNotBlank(occurrenceId)) { TreeMap<String, String> properties = new TreeMap<>(); properties.put(TARGET_OCCURRENCE_ID, StringUtils.trim(occurrenceId)); properties.put(INTERACTION_TYPE_NAME, StringUtils.trim(relation)); propertyList.add(properties); } } } } return propertyList; } }
DatasetImporterForDwCA extends DatasetImporterWithListener { static List<Map<String, String>> parseAssociatedOccurrences(String s) { List<Map<String, String>> propertyList = new ArrayList<>(); String[] relationships = StringUtils.split(s, ";"); for (String relationship : relationships) { String relationshipTrimmed = StringUtils.trim(relationship); int i1 = StringUtils.indexOf(relationshipTrimmed, ")"); if (i1 > -1 && i1 < relationshipTrimmed.length()) { String relation = StringUtils.substring(relationshipTrimmed, 0, i1 + 1); String targetCollectionAndOccurrenceId = StringUtils.trim(StringUtils.substring(relationshipTrimmed, i1 + 1)); int i = StringUtils.indexOf(targetCollectionAndOccurrenceId, " "); if (i > -1) { String occurrenceId = StringUtils.substring(targetCollectionAndOccurrenceId, i); if (StringUtils.isNotBlank(occurrenceId)) { TreeMap<String, String> properties = new TreeMap<>(); properties.put(TARGET_OCCURRENCE_ID, StringUtils.trim(occurrenceId)); properties.put(INTERACTION_TYPE_NAME, StringUtils.trim(relation)); propertyList.add(properties); } } } } return propertyList; } DatasetImporterForDwCA(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForDwCA extends DatasetImporterWithListener { static List<Map<String, String>> parseAssociatedOccurrences(String s) { List<Map<String, String>> propertyList = new ArrayList<>(); String[] relationships = StringUtils.split(s, ";"); for (String relationship : relationships) { String relationshipTrimmed = StringUtils.trim(relationship); int i1 = StringUtils.indexOf(relationshipTrimmed, ")"); if (i1 > -1 && i1 < relationshipTrimmed.length()) { String relation = StringUtils.substring(relationshipTrimmed, 0, i1 + 1); String targetCollectionAndOccurrenceId = StringUtils.trim(StringUtils.substring(relationshipTrimmed, i1 + 1)); int i = StringUtils.indexOf(targetCollectionAndOccurrenceId, " "); if (i > -1) { String occurrenceId = StringUtils.substring(targetCollectionAndOccurrenceId, i); if (StringUtils.isNotBlank(occurrenceId)) { TreeMap<String, String> properties = new TreeMap<>(); properties.put(TARGET_OCCURRENCE_ID, StringUtils.trim(occurrenceId)); properties.put(INTERACTION_TYPE_NAME, StringUtils.trim(relation)); propertyList.add(properties); } } } } return propertyList; } DatasetImporterForDwCA(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); int importCore(Archive archive, InteractionListener interactionListener); void handleRecord(InteractionListener interactionListener, Record rec); static void addRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static Map<String, String> parseRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(String occurrenceRemarks); void addUSNMStyleHostOccurrenceRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static void mapCoreProperties(Record rec, Map<String, String> interactionProperties); static void mapLocationAndReferenceInfo(Record rec, Map<String, String> interactionProperties); static void mapSourceProperties(Record rec, Map<String, String> interactionProperties); static void mapIfAvailable(Record rec, Map<String, String> interactionProperties, String key, Term term); static void mapIfAvailable(Map<String, String> interactionProperties, String key, String value); static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks); static Map<String, String> parseJsonChunk(String candidateJsonChunk); }
DatasetImporterForDwCA extends DatasetImporterWithListener { static List<Map<String, String>> parseAssociatedOccurrences(String s) { List<Map<String, String>> propertyList = new ArrayList<>(); String[] relationships = StringUtils.split(s, ";"); for (String relationship : relationships) { String relationshipTrimmed = StringUtils.trim(relationship); int i1 = StringUtils.indexOf(relationshipTrimmed, ")"); if (i1 > -1 && i1 < relationshipTrimmed.length()) { String relation = StringUtils.substring(relationshipTrimmed, 0, i1 + 1); String targetCollectionAndOccurrenceId = StringUtils.trim(StringUtils.substring(relationshipTrimmed, i1 + 1)); int i = StringUtils.indexOf(targetCollectionAndOccurrenceId, " "); if (i > -1) { String occurrenceId = StringUtils.substring(targetCollectionAndOccurrenceId, i); if (StringUtils.isNotBlank(occurrenceId)) { TreeMap<String, String> properties = new TreeMap<>(); properties.put(TARGET_OCCURRENCE_ID, StringUtils.trim(occurrenceId)); properties.put(INTERACTION_TYPE_NAME, StringUtils.trim(relation)); propertyList.add(properties); } } } } return propertyList; } DatasetImporterForDwCA(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); int importCore(Archive archive, InteractionListener interactionListener); void handleRecord(InteractionListener interactionListener, Record rec); static void addRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static Map<String, String> parseRoyalSaskatchewanMuseumOwlPelletCollectionStyleRemarks(String occurrenceRemarks); void addUSNMStyleHostOccurrenceRemarks(List<Map<String, String>> interactionCandidates, String occurrenceRemarks); static void mapCoreProperties(Record rec, Map<String, String> interactionProperties); static void mapLocationAndReferenceInfo(Record rec, Map<String, String> interactionProperties); static void mapSourceProperties(Record rec, Map<String, String> interactionProperties); static void mapIfAvailable(Record rec, Map<String, String> interactionProperties, String key, Term term); static void mapIfAvailable(Map<String, String> interactionProperties, String key, String value); static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks); static Map<String, String> parseJsonChunk(String candidateJsonChunk); static final String EXTENSION_ASSOCIATED_TAXA; static final String EXTENSION_RESOURCE_RELATIONSHIP; static final String EXTENSION_TAXON; static final Pattern EX_NOTATION; static final Pattern REARED_EX_NOTATION; static final Pattern PATTERN_ASSOCIATED_TAXA_IDEA; static final Pattern PATTERN_ASSOCIATED_TAXA_EAE; }