@Test public void occurrenceRemarks3() throws IOException { String occurrenceRemarks = "AFA Acetocarmine Canada balsam " + "{\"hostGen\":\"Bryconamericus\"," + "\"hostSpec\":\"scleroparius\"," + "\"hostBodyLoc\":\"intestine\"," + "\"hostFldNo\":\"AChoudhury-BA-CR98-3\"}"; Map<String, String> properties = DatasetImporterForDwCA.parseUSNMStyleHostOccurrenceRemarks(occurrenceRemarks); assertThat(properties.get(TaxonUtil.TARGET_TAXON_NAME), is("Bryconamericus scleroparius")); assertThat(properties.get(TaxonUtil.TARGET_TAXON_GENUS), is("Bryconamericus")); assertThat(properties.get(TaxonUtil.TARGET_TAXON_SPECIFIC_EPITHET), is("scleroparius")); assertThat(properties.get(TaxonUtil.TARGET_TAXON_PATH), is("Bryconamericus | Bryconamericus scleroparius")); assertThat(properties.get(TaxonUtil.TARGET_TAXON_PATH_NAMES), is("genus | species")); assertThat(properties.get(TARGET_BODY_PART_NAME), is("intestine")); assertThat(properties.get(INTERACTION_TYPE_NAME), is(InteractType.HAS_HOST.getLabel())); assertThat(properties.get(INTERACTION_TYPE_ID), is(InteractType.HAS_HOST.getIRI())); }
public static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks) throws IOException { Map<String, String> properties = Collections.emptyMap(); String candidateJsonChunk = null; String[] split = StringUtils.splitPreserveAllTokens(occurrenceRemarks, "{"); if (split.length > 1) { String[] splitClosing = StringUtils.splitPreserveAllTokens(split[1], "}"); if (splitClosing.length > 1) { candidateJsonChunk = "{" + splitClosing[0] + "}"; } } if (StringUtils.isNotBlank(candidateJsonChunk)) { try { properties = parseJsonChunk(candidateJsonChunk); } catch (IOException ex) { if (StringUtils.contains(candidateJsonChunk, "hostGen")) { throw new IOException("found likely malformed host description [" + candidateJsonChunk + "], see https: } } } return properties; }
DatasetImporterForDwCA extends DatasetImporterWithListener { public static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks) throws IOException { Map<String, String> properties = Collections.emptyMap(); String candidateJsonChunk = null; String[] split = StringUtils.splitPreserveAllTokens(occurrenceRemarks, "{"); if (split.length > 1) { String[] splitClosing = StringUtils.splitPreserveAllTokens(split[1], "}"); if (splitClosing.length > 1) { candidateJsonChunk = "{" + splitClosing[0] + "}"; } } if (StringUtils.isNotBlank(candidateJsonChunk)) { try { properties = parseJsonChunk(candidateJsonChunk); } catch (IOException ex) { if (StringUtils.contains(candidateJsonChunk, "hostGen")) { throw new IOException("found likely malformed host description [" + candidateJsonChunk + "], see https: } } } return properties; } }
DatasetImporterForDwCA extends DatasetImporterWithListener { public static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks) throws IOException { Map<String, String> properties = Collections.emptyMap(); String candidateJsonChunk = null; String[] split = StringUtils.splitPreserveAllTokens(occurrenceRemarks, "{"); if (split.length > 1) { String[] splitClosing = StringUtils.splitPreserveAllTokens(split[1], "}"); if (splitClosing.length > 1) { candidateJsonChunk = "{" + splitClosing[0] + "}"; } } if (StringUtils.isNotBlank(candidateJsonChunk)) { try { properties = parseJsonChunk(candidateJsonChunk); } catch (IOException ex) { if (StringUtils.contains(candidateJsonChunk, "hostGen")) { throw new IOException("found likely malformed host description [" + candidateJsonChunk + "], see https: } } } return properties; } DatasetImporterForDwCA(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForDwCA extends DatasetImporterWithListener { public static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks) throws IOException { Map<String, String> properties = Collections.emptyMap(); String candidateJsonChunk = null; String[] split = StringUtils.splitPreserveAllTokens(occurrenceRemarks, "{"); if (split.length > 1) { String[] splitClosing = StringUtils.splitPreserveAllTokens(split[1], "}"); if (splitClosing.length > 1) { candidateJsonChunk = "{" + splitClosing[0] + "}"; } } if (StringUtils.isNotBlank(candidateJsonChunk)) { try { properties = parseJsonChunk(candidateJsonChunk); } catch (IOException ex) { if (StringUtils.contains(candidateJsonChunk, "hostGen")) { throw new IOException("found likely malformed host description [" + candidateJsonChunk + "], see https: } } } return properties; } 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 { public static Map<String, String> parseUSNMStyleHostOccurrenceRemarks(String occurrenceRemarks) throws IOException { Map<String, String> properties = Collections.emptyMap(); String candidateJsonChunk = null; String[] split = StringUtils.splitPreserveAllTokens(occurrenceRemarks, "{"); if (split.length > 1) { String[] splitClosing = StringUtils.splitPreserveAllTokens(split[1], "}"); if (splitClosing.length > 1) { candidateJsonChunk = "{" + splitClosing[0] + "}"; } } if (StringUtils.isNotBlank(candidateJsonChunk)) { try { properties = parseJsonChunk(candidateJsonChunk); } catch (IOException ex) { if (StringUtils.contains(candidateJsonChunk, "hostGen")) { throw new IOException("found likely malformed host description [" + candidateJsonChunk + "], see https: } } } return properties; } 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; }