@Test public void testGetGatheringEvent() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); GatheringEvent event = null; CrsSpecimenTransformer crsSpecimenTransformer = new CrsSpecimenTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(specimenFile, etlStatistics); for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "objectID", "RMNH.MAM.TT.5"); CommonReflectionUtil.setField(AbstractTransformer.class, crsSpecimenTransformer, "input", extracted); Object returned = CommonReflectionUtil.callMethod(null, null, crsSpecimenTransformer, "getGatheringEvent"); event = (GatheringEvent) returned; if (event != null) break; } GatheringEvent expectedGa = new GatheringEvent(); expectedGa.setCountry("Netherlands"); expectedGa.setProvinceState("Noord Holland"); expectedGa.setLocality("Amsterdam"); assertEquals("01",expectedGa.getCountry(), event.getCountry()); assertEquals("02",expectedGa.getProvinceState(), event.getProvinceState()); assertEquals("03",expectedGa.getLocality(), event.getLocality()); }
private GatheringEvent getGatheringEvent() { Element record = input.getRecord(); GatheringEvent ge = new GatheringEvent(); ge.setProjectTitle(val(record, "abcd:ProjectTitle")); ge.setWorldRegion(val(record, "abcd:WorldRegion")); ge.setCountry(val(record, "abcd:Country")); ge.setProvinceState(val(record, "abcd:ProvinceState")); ge.setIsland(val(record, "abcd:Island")); ge.setLocality(val(record, "abcd:Locality")); ge.setLocalityText(val(record, "abcd:LocalityText")); ge.setNamedAreas(getNamedAreas()); ge.setDateTimeBegin(date(record, "abcd:CollectingStartDate")); ge.setDateTimeEnd(date(record, "abcd:CollectingEndDate")); String s = val(record, "abcd:GatheringAgent"); if (s != null) { ge.setGatheringPersons(Collections.singletonList(new Person(s))); } Double lat = dval(record, "abcd:LatitudeDecimal"); Double lon = dval(record, "abcd:LongitudeDecimal"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) warn("Invalid longitude: " + lon); lon = null; } if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) warn("Invalid latitude: " + lat); lat = null; } if (lat != null || lon != null) { ge.setSiteCoordinates(Collections.singletonList(new GatheringSiteCoordinates(lat, lon))); } ge.setAssociatedTaxa(getAssociatedTaxa()); ge.setChronoStratigraphy(getChronoStratigraphyList()); ge.setBioStratigraphy(getBioStratigraphyList()); ge.setLithoStratigraphy(getLithoStratigraphyList()); for (Field f : geFields) { try { if (f.get(ge) != null) { return ge; } } catch (IllegalArgumentException | IllegalAccessException e) { throw new ETLRuntimeException(e); } } return null; }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private GatheringEvent getGatheringEvent() { Element record = input.getRecord(); GatheringEvent ge = new GatheringEvent(); ge.setProjectTitle(val(record, "abcd:ProjectTitle")); ge.setWorldRegion(val(record, "abcd:WorldRegion")); ge.setCountry(val(record, "abcd:Country")); ge.setProvinceState(val(record, "abcd:ProvinceState")); ge.setIsland(val(record, "abcd:Island")); ge.setLocality(val(record, "abcd:Locality")); ge.setLocalityText(val(record, "abcd:LocalityText")); ge.setNamedAreas(getNamedAreas()); ge.setDateTimeBegin(date(record, "abcd:CollectingStartDate")); ge.setDateTimeEnd(date(record, "abcd:CollectingEndDate")); String s = val(record, "abcd:GatheringAgent"); if (s != null) { ge.setGatheringPersons(Collections.singletonList(new Person(s))); } Double lat = dval(record, "abcd:LatitudeDecimal"); Double lon = dval(record, "abcd:LongitudeDecimal"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) warn("Invalid longitude: " + lon); lon = null; } if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) warn("Invalid latitude: " + lat); lat = null; } if (lat != null || lon != null) { ge.setSiteCoordinates(Collections.singletonList(new GatheringSiteCoordinates(lat, lon))); } ge.setAssociatedTaxa(getAssociatedTaxa()); ge.setChronoStratigraphy(getChronoStratigraphyList()); ge.setBioStratigraphy(getBioStratigraphyList()); ge.setLithoStratigraphy(getLithoStratigraphyList()); for (Field f : geFields) { try { if (f.get(ge) != null) { return ge; } } catch (IllegalArgumentException | IllegalAccessException e) { throw new ETLRuntimeException(e); } } return null; } }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private GatheringEvent getGatheringEvent() { Element record = input.getRecord(); GatheringEvent ge = new GatheringEvent(); ge.setProjectTitle(val(record, "abcd:ProjectTitle")); ge.setWorldRegion(val(record, "abcd:WorldRegion")); ge.setCountry(val(record, "abcd:Country")); ge.setProvinceState(val(record, "abcd:ProvinceState")); ge.setIsland(val(record, "abcd:Island")); ge.setLocality(val(record, "abcd:Locality")); ge.setLocalityText(val(record, "abcd:LocalityText")); ge.setNamedAreas(getNamedAreas()); ge.setDateTimeBegin(date(record, "abcd:CollectingStartDate")); ge.setDateTimeEnd(date(record, "abcd:CollectingEndDate")); String s = val(record, "abcd:GatheringAgent"); if (s != null) { ge.setGatheringPersons(Collections.singletonList(new Person(s))); } Double lat = dval(record, "abcd:LatitudeDecimal"); Double lon = dval(record, "abcd:LongitudeDecimal"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) warn("Invalid longitude: " + lon); lon = null; } if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) warn("Invalid latitude: " + lat); lat = null; } if (lat != null || lon != null) { ge.setSiteCoordinates(Collections.singletonList(new GatheringSiteCoordinates(lat, lon))); } ge.setAssociatedTaxa(getAssociatedTaxa()); ge.setChronoStratigraphy(getChronoStratigraphyList()); ge.setBioStratigraphy(getBioStratigraphyList()); ge.setLithoStratigraphy(getLithoStratigraphyList()); for (Field f : geFields) { try { if (f.get(ge) != null) { return ge; } } catch (IllegalArgumentException | IllegalAccessException e) { throw new ETLRuntimeException(e); } } return null; } CrsSpecimenTransformer(ETLStatistics stats); }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private GatheringEvent getGatheringEvent() { Element record = input.getRecord(); GatheringEvent ge = new GatheringEvent(); ge.setProjectTitle(val(record, "abcd:ProjectTitle")); ge.setWorldRegion(val(record, "abcd:WorldRegion")); ge.setCountry(val(record, "abcd:Country")); ge.setProvinceState(val(record, "abcd:ProvinceState")); ge.setIsland(val(record, "abcd:Island")); ge.setLocality(val(record, "abcd:Locality")); ge.setLocalityText(val(record, "abcd:LocalityText")); ge.setNamedAreas(getNamedAreas()); ge.setDateTimeBegin(date(record, "abcd:CollectingStartDate")); ge.setDateTimeEnd(date(record, "abcd:CollectingEndDate")); String s = val(record, "abcd:GatheringAgent"); if (s != null) { ge.setGatheringPersons(Collections.singletonList(new Person(s))); } Double lat = dval(record, "abcd:LatitudeDecimal"); Double lon = dval(record, "abcd:LongitudeDecimal"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) warn("Invalid longitude: " + lon); lon = null; } if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) warn("Invalid latitude: " + lat); lat = null; } if (lat != null || lon != null) { ge.setSiteCoordinates(Collections.singletonList(new GatheringSiteCoordinates(lat, lon))); } ge.setAssociatedTaxa(getAssociatedTaxa()); ge.setChronoStratigraphy(getChronoStratigraphyList()); ge.setBioStratigraphy(getBioStratigraphyList()); ge.setLithoStratigraphy(getLithoStratigraphyList()); for (Field f : geFields) { try { if (f.get(ge) != null) { return ge; } } catch (IllegalArgumentException | IllegalAccessException e) { throw new ETLRuntimeException(e); } } return null; } CrsSpecimenTransformer(ETLStatistics stats);  }
CrsSpecimenTransformer extends AbstractXMLTransformer<Specimen> { private GatheringEvent getGatheringEvent() { Element record = input.getRecord(); GatheringEvent ge = new GatheringEvent(); ge.setProjectTitle(val(record, "abcd:ProjectTitle")); ge.setWorldRegion(val(record, "abcd:WorldRegion")); ge.setCountry(val(record, "abcd:Country")); ge.setProvinceState(val(record, "abcd:ProvinceState")); ge.setIsland(val(record, "abcd:Island")); ge.setLocality(val(record, "abcd:Locality")); ge.setLocalityText(val(record, "abcd:LocalityText")); ge.setNamedAreas(getNamedAreas()); ge.setDateTimeBegin(date(record, "abcd:CollectingStartDate")); ge.setDateTimeEnd(date(record, "abcd:CollectingEndDate")); String s = val(record, "abcd:GatheringAgent"); if (s != null) { ge.setGatheringPersons(Collections.singletonList(new Person(s))); } Double lat = dval(record, "abcd:LatitudeDecimal"); Double lon = dval(record, "abcd:LongitudeDecimal"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) warn("Invalid longitude: " + lon); lon = null; } if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) warn("Invalid latitude: " + lat); lat = null; } if (lat != null || lon != null) { ge.setSiteCoordinates(Collections.singletonList(new GatheringSiteCoordinates(lat, lon))); } ge.setAssociatedTaxa(getAssociatedTaxa()); ge.setChronoStratigraphy(getChronoStratigraphyList()); ge.setBioStratigraphy(getBioStratigraphyList()); ge.setLithoStratigraphy(getLithoStratigraphyList()); for (Field f : geFields) { try { if (f.get(ge) != null) { return ge; } } catch (IllegalArgumentException | IllegalAccessException e) { throw new ETLRuntimeException(e); } } return null; } CrsSpecimenTransformer(ETLStatistics stats);   }