@Test public void parseValueLongEOLTaxonId() { final DatasetImporterForMetaTable.Column column = new DatasetImporterForMetaTable.Column("foo", null); column.setDataTypeBase("long"); column.setValueUrl("http: final String parsedValue = DatasetImporterForMetaTable.parseValue("123", column); assertThat(parsedValue, is("EOL:123")); }
public static String parseValue(String value, Column column) throws IllegalFormatException { String convertedValue = null; if (StringUtils.isNotBlank(value)) { if ("long".equalsIgnoreCase(column.getDataTypeBase())) { if (!NumberUtils.isDigits(value)) { return null; } } convertedValue = populateValueUrlOrNull(value, column, convertedValue); if (null == convertedValue) { if ("https: final String[] parts = value.trim().split("[^0-9]"); convertedValue = TaxonomyProvider.NATIONAL_OCEANOGRAPHIC_DATA_CENTER.getIdPrefix() + parts[0].replace("00", ""); } else if ("http: final String id = value.trim(); if (NumberUtils.isDigits(id)) { convertedValue = TaxonomyProvider.NCBI.getIdPrefix() + id; } } else if ("http: convertedValue = TaxonomyProvider.ID_PREFIX_EOL + value.trim(); } else if ("date".equals(column.getDataTypeBase())) { final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value) .toString(ISODateTimeFormat.dateTime().withZoneUTC()); } else { convertedValue = value; } } } return StringUtils.trim(convertedValue); }
DatasetImporterForMetaTable extends DatasetImporterWithListener { public static String parseValue(String value, Column column) throws IllegalFormatException { String convertedValue = null; if (StringUtils.isNotBlank(value)) { if ("long".equalsIgnoreCase(column.getDataTypeBase())) { if (!NumberUtils.isDigits(value)) { return null; } } convertedValue = populateValueUrlOrNull(value, column, convertedValue); if (null == convertedValue) { if ("https: final String[] parts = value.trim().split("[^0-9]"); convertedValue = TaxonomyProvider.NATIONAL_OCEANOGRAPHIC_DATA_CENTER.getIdPrefix() + parts[0].replace("00", ""); } else if ("http: final String id = value.trim(); if (NumberUtils.isDigits(id)) { convertedValue = TaxonomyProvider.NCBI.getIdPrefix() + id; } } else if ("http: convertedValue = TaxonomyProvider.ID_PREFIX_EOL + value.trim(); } else if ("date".equals(column.getDataTypeBase())) { final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value) .toString(ISODateTimeFormat.dateTime().withZoneUTC()); } else { convertedValue = value; } } } return StringUtils.trim(convertedValue); } }
DatasetImporterForMetaTable extends DatasetImporterWithListener { public static String parseValue(String value, Column column) throws IllegalFormatException { String convertedValue = null; if (StringUtils.isNotBlank(value)) { if ("long".equalsIgnoreCase(column.getDataTypeBase())) { if (!NumberUtils.isDigits(value)) { return null; } } convertedValue = populateValueUrlOrNull(value, column, convertedValue); if (null == convertedValue) { if ("https: final String[] parts = value.trim().split("[^0-9]"); convertedValue = TaxonomyProvider.NATIONAL_OCEANOGRAPHIC_DATA_CENTER.getIdPrefix() + parts[0].replace("00", ""); } else if ("http: final String id = value.trim(); if (NumberUtils.isDigits(id)) { convertedValue = TaxonomyProvider.NCBI.getIdPrefix() + id; } } else if ("http: convertedValue = TaxonomyProvider.ID_PREFIX_EOL + value.trim(); } else if ("date".equals(column.getDataTypeBase())) { final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value) .toString(ISODateTimeFormat.dateTime().withZoneUTC()); } else { convertedValue = value; } } } return StringUtils.trim(convertedValue); } DatasetImporterForMetaTable(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForMetaTable extends DatasetImporterWithListener { public static String parseValue(String value, Column column) throws IllegalFormatException { String convertedValue = null; if (StringUtils.isNotBlank(value)) { if ("long".equalsIgnoreCase(column.getDataTypeBase())) { if (!NumberUtils.isDigits(value)) { return null; } } convertedValue = populateValueUrlOrNull(value, column, convertedValue); if (null == convertedValue) { if ("https: final String[] parts = value.trim().split("[^0-9]"); convertedValue = TaxonomyProvider.NATIONAL_OCEANOGRAPHIC_DATA_CENTER.getIdPrefix() + parts[0].replace("00", ""); } else if ("http: final String id = value.trim(); if (NumberUtils.isDigits(id)) { convertedValue = TaxonomyProvider.NCBI.getIdPrefix() + id; } } else if ("http: convertedValue = TaxonomyProvider.ID_PREFIX_EOL + value.trim(); } else if ("date".equals(column.getDataTypeBase())) { final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value) .toString(ISODateTimeFormat.dateTime().withZoneUTC()); } else { convertedValue = value; } } } return StringUtils.trim(convertedValue); } DatasetImporterForMetaTable(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static void append(StringBuilder citation, String value, String suffix, String prefix); static void append(StringBuilder citation, String value, String continuation); static InteractType generateInteractionType(Map<String, String> properties, InteractTypeMapper mapper); JsonNode getConfig(); String getBaseUrl(); static void importAll(InteractionListener interactionListener,
                                 List<Column> columnNames,
                                 CSVParse csvParse, JsonNode config, ImportLogger importLogger); static void parseColumnValue(ImportLogger importLogger, Map<String, String> mappedLine, String value, Column column); static void logParseWarning(ImportLogger importLogger, Map<String, String> mappedLine, String value, Column column); static String valueOrDefault(String value, Column column); static void setInteractionType(Map<String, String> properties, InteractType type); static String parseValue(String value, Column column); void setDataset(Dataset dataset); Dataset getDataset(); static List<Column> columnNamesForMetaTable(JsonNode config); static List<Column> columnNamesForSchema(JsonNode tableSchema); static Column createStringColumn(JsonNode columnName); }
DatasetImporterForMetaTable extends DatasetImporterWithListener { public static String parseValue(String value, Column column) throws IllegalFormatException { String convertedValue = null; if (StringUtils.isNotBlank(value)) { if ("long".equalsIgnoreCase(column.getDataTypeBase())) { if (!NumberUtils.isDigits(value)) { return null; } } convertedValue = populateValueUrlOrNull(value, column, convertedValue); if (null == convertedValue) { if ("https: final String[] parts = value.trim().split("[^0-9]"); convertedValue = TaxonomyProvider.NATIONAL_OCEANOGRAPHIC_DATA_CENTER.getIdPrefix() + parts[0].replace("00", ""); } else if ("http: final String id = value.trim(); if (NumberUtils.isDigits(id)) { convertedValue = TaxonomyProvider.NCBI.getIdPrefix() + id; } } else if ("http: convertedValue = TaxonomyProvider.ID_PREFIX_EOL + value.trim(); } else if ("date".equals(column.getDataTypeBase())) { final DateTimeFormatter dateTimeFormatter = StringUtils.isNotBlank(column.getDataTypeFormat()) ? DateTimeFormat.forPattern(column.getDataTypeFormat()) : DateTimeFormat.fullDateTime(); convertedValue = dateTimeFormatter.withZoneUTC() .parseDateTime(value) .toString(ISODateTimeFormat.dateTime().withZoneUTC()); } else { convertedValue = value; } } } return StringUtils.trim(convertedValue); } DatasetImporterForMetaTable(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static void append(StringBuilder citation, String value, String suffix, String prefix); static void append(StringBuilder citation, String value, String continuation); static InteractType generateInteractionType(Map<String, String> properties, InteractTypeMapper mapper); JsonNode getConfig(); String getBaseUrl(); static void importAll(InteractionListener interactionListener,
                                 List<Column> columnNames,
                                 CSVParse csvParse, JsonNode config, ImportLogger importLogger); static void parseColumnValue(ImportLogger importLogger, Map<String, String> mappedLine, String value, Column column); static void logParseWarning(ImportLogger importLogger, Map<String, String> mappedLine, String value, Column column); static String valueOrDefault(String value, Column column); static void setInteractionType(Map<String, String> properties, InteractType type); static String parseValue(String value, Column column); void setDataset(Dataset dataset); Dataset getDataset(); static List<Column> columnNamesForMetaTable(JsonNode config); static List<Column> columnNamesForSchema(JsonNode tableSchema); static Column createStringColumn(JsonNode columnName); static final String AUTHOR; static final String TITLE; static final String YEAR; static final String JOURNAL; static final String VOLUME; static final String NUMBER; static final String PAGES; static final String LONGITUDE; static final String LATITUDE; static final String EVENT_DATE; }