@Test public void testTransformOne() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CSVRecordInfo<BrahmsCsvField> record = mock(CSVRecordInfo.class); when(record.get(BrahmsCsvField.SPECIES)).thenReturn("Rhododendron ferrugineum L."); when(record.get(BrahmsCsvField.AUTHOR2)).thenReturn("L."); when(record.get(BrahmsCsvField.GENUS)).thenReturn("Rhododendron"); when(record.get(BrahmsCsvField.SP1)).thenReturn("ferrugineum"); when(record.get(BrahmsCsvField.RANK2)).thenReturn("testInfraSpecifc"); when(record.get(BrahmsCsvField.SP2)).thenReturn(""); when(record.get(BrahmsCsvField.BARCODE)).thenReturn("L.3355550"); when(record.get(BrahmsCsvField.NOTONLINE)).thenReturn(""); when(record.get(BrahmsCsvField.PLANTDESC)).thenReturn("TestDesc"); when(record.get(BrahmsCsvField.CATEGORY)).thenReturn("L"); when(record.get(BrahmsCsvField.COLLECTOR, false)).thenReturn("Unknown "); when(record.get(BrahmsCsvField.PREFIX, false)).thenReturn(" "); when(record.get(BrahmsCsvField.NUMBER, false)).thenReturn("s.n. "); when(record.get(BrahmsCsvField.SUFFIX, false)).thenReturn(" "); when(record.get(BrahmsCsvField.TYPE)).thenReturn(""); when(record.get(BrahmsCsvField.DETBY)).thenReturn(""); when(record.get(BrahmsCsvField.VERNACULAR)).thenReturn(""); when(record.get(BrahmsCsvField.YEARIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.MONTHIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.DAYIDENT)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.IMAGELIST)).thenReturn("http: when(record.get(BrahmsCsvField.CONTINENT)).thenReturn("Europe"); when(record.get(BrahmsCsvField.COUNTRY)).thenReturn("Netherlands"); when(record.get(BrahmsCsvField.MAJORAREA)).thenReturn(""); when(record.get(BrahmsCsvField.LOCNOTES)).thenReturn("Io een rotsachtige rij vochtige berghelling bij het Kolmhans."); when(record.get(BrahmsCsvField.YEAR)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.MONTH)).thenReturn(" 8.000000"); when(record.get(BrahmsCsvField.DAY)).thenReturn(" 3.000000"); when(record.get(BrahmsCsvField.LATITUDE)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.LONGITUDE)).thenReturn(" 0.000000"); when(record.get(BrahmsCsvField.BRAHMS)).thenReturn("1993139.000000"); BrahmsMultiMediaTransformer brahmsMultiMediaTransformer = new BrahmsMultiMediaTransformer(etlStatistics); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "objectID", "L.3355550"); CommonReflectionUtil.setField(AbstractTransformer.class, brahmsMultiMediaTransformer, "input", record); String url = "http: String expectedAssociatedSpecimenRef = "L.3355550@BRAHMS"; Object obj = CommonReflectionUtil.callMethod(url, String.class, brahmsMultiMediaTransformer, "transformOne"); MultiMediaObject mediaObject = (MultiMediaObject) obj; assertNotNull("01", mediaObject); assertEquals("02", expectedAssociatedSpecimenRef, mediaObject.getAssociatedSpecimenReference()); }
private MultiMediaObject transformOne(String url) { stats.objectsProcessed++; try { URI uri = getUri(url); MultiMediaObject mmo = newMultiMediaObject(); String uriHash = String.valueOf(uri.toString().hashCode()).replace('-', '0'); ServiceAccessPoint sap = newServiceAccessPoint(uri); if (sap == null) return null; mmo.addServiceAccessPoint(sap); mmo.setUnitID(objectID + '_' + uriHash); mmo.setId(getElasticsearchId(BRAHMS, mmo.getUnitID())); mmo.setSourceSystemId(mmo.getUnitID()); String specimenID = getElasticsearchId(BRAHMS, objectID); mmo.setAssociatedSpecimenReference(specimenID); List<String> themes = themeCache.lookup(objectID, MULTI_MEDIA_OBJECT, BRAHMS); mmo.setTheme(themes); String description = input.get(PLANTDESC, true); if (description != null) mmo.setDescription(description.replaceAll("\u00001", "")); mmo.setGatheringEvents(Arrays.asList(getMultiMediaGatheringEvent(input))); mmo.setIdentifications(Arrays.asList(getIdentification())); if (doEnrich()) { enrichIdentification(mmo); } stats.objectsAccepted++; return mmo; } catch (URISyntaxException e) { stats.objectsRejected++; if (!suppressErrors) error("Invalid image URL: " + url); return null; } catch (Throwable t) { handleError(t); return null; } }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private MultiMediaObject transformOne(String url) { stats.objectsProcessed++; try { URI uri = getUri(url); MultiMediaObject mmo = newMultiMediaObject(); String uriHash = String.valueOf(uri.toString().hashCode()).replace('-', '0'); ServiceAccessPoint sap = newServiceAccessPoint(uri); if (sap == null) return null; mmo.addServiceAccessPoint(sap); mmo.setUnitID(objectID + '_' + uriHash); mmo.setId(getElasticsearchId(BRAHMS, mmo.getUnitID())); mmo.setSourceSystemId(mmo.getUnitID()); String specimenID = getElasticsearchId(BRAHMS, objectID); mmo.setAssociatedSpecimenReference(specimenID); List<String> themes = themeCache.lookup(objectID, MULTI_MEDIA_OBJECT, BRAHMS); mmo.setTheme(themes); String description = input.get(PLANTDESC, true); if (description != null) mmo.setDescription(description.replaceAll("\u00001", "")); mmo.setGatheringEvents(Arrays.asList(getMultiMediaGatheringEvent(input))); mmo.setIdentifications(Arrays.asList(getIdentification())); if (doEnrich()) { enrichIdentification(mmo); } stats.objectsAccepted++; return mmo; } catch (URISyntaxException e) { stats.objectsRejected++; if (!suppressErrors) error("Invalid image URL: " + url); return null; } catch (Throwable t) { handleError(t); return null; } } }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private MultiMediaObject transformOne(String url) { stats.objectsProcessed++; try { URI uri = getUri(url); MultiMediaObject mmo = newMultiMediaObject(); String uriHash = String.valueOf(uri.toString().hashCode()).replace('-', '0'); ServiceAccessPoint sap = newServiceAccessPoint(uri); if (sap == null) return null; mmo.addServiceAccessPoint(sap); mmo.setUnitID(objectID + '_' + uriHash); mmo.setId(getElasticsearchId(BRAHMS, mmo.getUnitID())); mmo.setSourceSystemId(mmo.getUnitID()); String specimenID = getElasticsearchId(BRAHMS, objectID); mmo.setAssociatedSpecimenReference(specimenID); List<String> themes = themeCache.lookup(objectID, MULTI_MEDIA_OBJECT, BRAHMS); mmo.setTheme(themes); String description = input.get(PLANTDESC, true); if (description != null) mmo.setDescription(description.replaceAll("\u00001", "")); mmo.setGatheringEvents(Arrays.asList(getMultiMediaGatheringEvent(input))); mmo.setIdentifications(Arrays.asList(getIdentification())); if (doEnrich()) { enrichIdentification(mmo); } stats.objectsAccepted++; return mmo; } catch (URISyntaxException e) { stats.objectsRejected++; if (!suppressErrors) error("Invalid image URL: " + url); return null; } catch (Throwable t) { handleError(t); return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats); }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private MultiMediaObject transformOne(String url) { stats.objectsProcessed++; try { URI uri = getUri(url); MultiMediaObject mmo = newMultiMediaObject(); String uriHash = String.valueOf(uri.toString().hashCode()).replace('-', '0'); ServiceAccessPoint sap = newServiceAccessPoint(uri); if (sap == null) return null; mmo.addServiceAccessPoint(sap); mmo.setUnitID(objectID + '_' + uriHash); mmo.setId(getElasticsearchId(BRAHMS, mmo.getUnitID())); mmo.setSourceSystemId(mmo.getUnitID()); String specimenID = getElasticsearchId(BRAHMS, objectID); mmo.setAssociatedSpecimenReference(specimenID); List<String> themes = themeCache.lookup(objectID, MULTI_MEDIA_OBJECT, BRAHMS); mmo.setTheme(themes); String description = input.get(PLANTDESC, true); if (description != null) mmo.setDescription(description.replaceAll("\u00001", "")); mmo.setGatheringEvents(Arrays.asList(getMultiMediaGatheringEvent(input))); mmo.setIdentifications(Arrays.asList(getIdentification())); if (doEnrich()) { enrichIdentification(mmo); } stats.objectsAccepted++; return mmo; } catch (URISyntaxException e) { stats.objectsRejected++; if (!suppressErrors) error("Invalid image URL: " + url); return null; } catch (Throwable t) { handleError(t); return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats);  }
BrahmsMultiMediaTransformer extends BrahmsTransformer<MultiMediaObject> { private MultiMediaObject transformOne(String url) { stats.objectsProcessed++; try { URI uri = getUri(url); MultiMediaObject mmo = newMultiMediaObject(); String uriHash = String.valueOf(uri.toString().hashCode()).replace('-', '0'); ServiceAccessPoint sap = newServiceAccessPoint(uri); if (sap == null) return null; mmo.addServiceAccessPoint(sap); mmo.setUnitID(objectID + '_' + uriHash); mmo.setId(getElasticsearchId(BRAHMS, mmo.getUnitID())); mmo.setSourceSystemId(mmo.getUnitID()); String specimenID = getElasticsearchId(BRAHMS, objectID); mmo.setAssociatedSpecimenReference(specimenID); List<String> themes = themeCache.lookup(objectID, MULTI_MEDIA_OBJECT, BRAHMS); mmo.setTheme(themes); String description = input.get(PLANTDESC, true); if (description != null) mmo.setDescription(description.replaceAll("\u00001", "")); mmo.setGatheringEvents(Arrays.asList(getMultiMediaGatheringEvent(input))); mmo.setIdentifications(Arrays.asList(getIdentification())); if (doEnrich()) { enrichIdentification(mmo); } stats.objectsAccepted++; return mmo; } catch (URISyntaxException e) { stats.objectsRejected++; if (!suppressErrors) error("Invalid image URL: " + url); return null; } catch (Throwable t) { handleError(t); return null; } } BrahmsMultiMediaTransformer(ETLStatistics stats);   }