@Test public void locationMapperTest() { LocationRecord locationRecord = LocationRecord.newBuilder() .setId("1") .setCountry(Country.COSTA_RICA.name()) .setCountryCode(Country.COSTA_RICA.getIso2LetterCode()) .setDecimalLatitude(9.934739) .setDecimalLongitude(-84.087502) .setContinent(Continent.NORTH_AMERICA.name()) .setHasCoordinate(Boolean.TRUE) .setCoordinatePrecision(0.1) .setCoordinateUncertaintyInMeters(1.0) .setDepth(5.0) .setDepthAccuracy(0.1) .setElevation(0.0) .setElevationAccuracy(0.1) .setHasGeospatialIssue(Boolean.FALSE) .setRepatriated(Boolean.TRUE) .setStateProvince("Limon") .setWaterBody("Atlantic") .setMaximumDepthInMeters(0.1) .setMinimumDepthInMeters(0.1) .setMaximumDistanceAboveSurfaceInMeters(0.1) .setMaximumElevationInMeters(0.1) .setMinimumElevationInMeters(0.1) .build(); OccurrenceHdfsRecord hdfsRecord = toOccurrenceHdfsRecord(locationRecord); Assert.assertEquals(Country.COSTA_RICA.getIso2LetterCode(), hdfsRecord.getCountrycode()); Assert.assertEquals(Double.valueOf(9.934739d), hdfsRecord.getDecimallatitude()); Assert.assertEquals(Double.valueOf(-84.087502d), hdfsRecord.getDecimallongitude()); Assert.assertEquals(Continent.NORTH_AMERICA.name(), hdfsRecord.getContinent()); Assert.assertEquals(Boolean.TRUE, hdfsRecord.getHascoordinate()); Assert.assertEquals(Double.valueOf(0.1d), hdfsRecord.getCoordinateprecision()); Assert.assertEquals(Double.valueOf(1.0d), hdfsRecord.getCoordinateuncertaintyinmeters()); Assert.assertEquals(Double.valueOf(5.0d), hdfsRecord.getDepth()); Assert.assertEquals(Double.valueOf(0.1d), hdfsRecord.getDepthaccuracy()); Assert.assertEquals(Double.valueOf(0.0d), hdfsRecord.getElevation()); Assert.assertEquals(Double.valueOf(0.1d), hdfsRecord.getElevationaccuracy()); Assert.assertEquals(Boolean.FALSE, hdfsRecord.getHasgeospatialissues()); Assert.assertEquals(Boolean.TRUE, hdfsRecord.getRepatriated()); Assert.assertEquals("Limon", hdfsRecord.getStateprovince()); Assert.assertEquals("Atlantic", hdfsRecord.getWaterbody()); }
private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> locationMapper() { return (hr, sr) -> { LocationRecord lr = (LocationRecord) sr; hr.setCountrycode(lr.getCountryCode()); hr.setContinent(lr.getContinent()); hr.setDecimallatitude(lr.getDecimalLatitude()); hr.setDecimallongitude(lr.getDecimalLongitude()); hr.setCoordinateprecision(lr.getCoordinatePrecision()); hr.setCoordinateuncertaintyinmeters(lr.getCoordinateUncertaintyInMeters()); hr.setDepth(lr.getDepth()); hr.setDepthaccuracy(lr.getDepthAccuracy()); hr.setElevation(lr.getElevation()); hr.setElevationaccuracy(lr.getElevationAccuracy()); if (Objects.nonNull(lr.getMaximumDistanceAboveSurfaceInMeters())) { hr.setMaximumdistanceabovesurfaceinmeters( lr.getMaximumDistanceAboveSurfaceInMeters().toString()); } if (Objects.nonNull(lr.getMinimumDistanceAboveSurfaceInMeters())) { hr.setMinimumdistanceabovesurfaceinmeters( lr.getMinimumDistanceAboveSurfaceInMeters().toString()); } hr.setStateprovince(lr.getStateProvince()); hr.setWaterbody(lr.getWaterBody()); hr.setHascoordinate(lr.getHasCoordinate()); hr.setHasgeospatialissues(lr.getHasGeospatialIssue()); hr.setRepatriated(lr.getRepatriated()); hr.setLocality(lr.getLocality()); hr.setPublishingcountry(lr.getPublishingCountry()); Optional.ofNullable(lr.getGadm()) .ifPresent( g -> { hr.setLevel0gid(g.getLevel0Gid()); hr.setLevel1gid(g.getLevel1Gid()); hr.setLevel2gid(g.getLevel2Gid()); hr.setLevel3gid(g.getLevel3Gid()); hr.setLevel0name(g.getLevel0Name()); hr.setLevel1name(g.getLevel1Name()); hr.setLevel2name(g.getLevel2Name()); hr.setLevel3name(g.getLevel3Name()); }); setCreatedIfGreater(hr, lr.getCreated()); addIssues(lr.getIssues(), hr); }; }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> locationMapper() { return (hr, sr) -> { LocationRecord lr = (LocationRecord) sr; hr.setCountrycode(lr.getCountryCode()); hr.setContinent(lr.getContinent()); hr.setDecimallatitude(lr.getDecimalLatitude()); hr.setDecimallongitude(lr.getDecimalLongitude()); hr.setCoordinateprecision(lr.getCoordinatePrecision()); hr.setCoordinateuncertaintyinmeters(lr.getCoordinateUncertaintyInMeters()); hr.setDepth(lr.getDepth()); hr.setDepthaccuracy(lr.getDepthAccuracy()); hr.setElevation(lr.getElevation()); hr.setElevationaccuracy(lr.getElevationAccuracy()); if (Objects.nonNull(lr.getMaximumDistanceAboveSurfaceInMeters())) { hr.setMaximumdistanceabovesurfaceinmeters( lr.getMaximumDistanceAboveSurfaceInMeters().toString()); } if (Objects.nonNull(lr.getMinimumDistanceAboveSurfaceInMeters())) { hr.setMinimumdistanceabovesurfaceinmeters( lr.getMinimumDistanceAboveSurfaceInMeters().toString()); } hr.setStateprovince(lr.getStateProvince()); hr.setWaterbody(lr.getWaterBody()); hr.setHascoordinate(lr.getHasCoordinate()); hr.setHasgeospatialissues(lr.getHasGeospatialIssue()); hr.setRepatriated(lr.getRepatriated()); hr.setLocality(lr.getLocality()); hr.setPublishingcountry(lr.getPublishingCountry()); Optional.ofNullable(lr.getGadm()) .ifPresent( g -> { hr.setLevel0gid(g.getLevel0Gid()); hr.setLevel1gid(g.getLevel1Gid()); hr.setLevel2gid(g.getLevel2Gid()); hr.setLevel3gid(g.getLevel3Gid()); hr.setLevel0name(g.getLevel0Name()); hr.setLevel1name(g.getLevel1Name()); hr.setLevel2name(g.getLevel2Name()); hr.setLevel3name(g.getLevel3Name()); }); setCreatedIfGreater(hr, lr.getCreated()); addIssues(lr.getIssues(), hr); }; } }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> locationMapper() { return (hr, sr) -> { LocationRecord lr = (LocationRecord) sr; hr.setCountrycode(lr.getCountryCode()); hr.setContinent(lr.getContinent()); hr.setDecimallatitude(lr.getDecimalLatitude()); hr.setDecimallongitude(lr.getDecimalLongitude()); hr.setCoordinateprecision(lr.getCoordinatePrecision()); hr.setCoordinateuncertaintyinmeters(lr.getCoordinateUncertaintyInMeters()); hr.setDepth(lr.getDepth()); hr.setDepthaccuracy(lr.getDepthAccuracy()); hr.setElevation(lr.getElevation()); hr.setElevationaccuracy(lr.getElevationAccuracy()); if (Objects.nonNull(lr.getMaximumDistanceAboveSurfaceInMeters())) { hr.setMaximumdistanceabovesurfaceinmeters( lr.getMaximumDistanceAboveSurfaceInMeters().toString()); } if (Objects.nonNull(lr.getMinimumDistanceAboveSurfaceInMeters())) { hr.setMinimumdistanceabovesurfaceinmeters( lr.getMinimumDistanceAboveSurfaceInMeters().toString()); } hr.setStateprovince(lr.getStateProvince()); hr.setWaterbody(lr.getWaterBody()); hr.setHascoordinate(lr.getHasCoordinate()); hr.setHasgeospatialissues(lr.getHasGeospatialIssue()); hr.setRepatriated(lr.getRepatriated()); hr.setLocality(lr.getLocality()); hr.setPublishingcountry(lr.getPublishingCountry()); Optional.ofNullable(lr.getGadm()) .ifPresent( g -> { hr.setLevel0gid(g.getLevel0Gid()); hr.setLevel1gid(g.getLevel1Gid()); hr.setLevel2gid(g.getLevel2Gid()); hr.setLevel3gid(g.getLevel3Gid()); hr.setLevel0name(g.getLevel0Name()); hr.setLevel1name(g.getLevel1Name()); hr.setLevel2name(g.getLevel2Name()); hr.setLevel3name(g.getLevel3Name()); }); setCreatedIfGreater(hr, lr.getCreated()); addIssues(lr.getIssues(), hr); }; }  }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> locationMapper() { return (hr, sr) -> { LocationRecord lr = (LocationRecord) sr; hr.setCountrycode(lr.getCountryCode()); hr.setContinent(lr.getContinent()); hr.setDecimallatitude(lr.getDecimalLatitude()); hr.setDecimallongitude(lr.getDecimalLongitude()); hr.setCoordinateprecision(lr.getCoordinatePrecision()); hr.setCoordinateuncertaintyinmeters(lr.getCoordinateUncertaintyInMeters()); hr.setDepth(lr.getDepth()); hr.setDepthaccuracy(lr.getDepthAccuracy()); hr.setElevation(lr.getElevation()); hr.setElevationaccuracy(lr.getElevationAccuracy()); if (Objects.nonNull(lr.getMaximumDistanceAboveSurfaceInMeters())) { hr.setMaximumdistanceabovesurfaceinmeters( lr.getMaximumDistanceAboveSurfaceInMeters().toString()); } if (Objects.nonNull(lr.getMinimumDistanceAboveSurfaceInMeters())) { hr.setMinimumdistanceabovesurfaceinmeters( lr.getMinimumDistanceAboveSurfaceInMeters().toString()); } hr.setStateprovince(lr.getStateProvince()); hr.setWaterbody(lr.getWaterBody()); hr.setHascoordinate(lr.getHasCoordinate()); hr.setHasgeospatialissues(lr.getHasGeospatialIssue()); hr.setRepatriated(lr.getRepatriated()); hr.setLocality(lr.getLocality()); hr.setPublishingcountry(lr.getPublishingCountry()); Optional.ofNullable(lr.getGadm()) .ifPresent( g -> { hr.setLevel0gid(g.getLevel0Gid()); hr.setLevel1gid(g.getLevel1Gid()); hr.setLevel2gid(g.getLevel2Gid()); hr.setLevel3gid(g.getLevel3Gid()); hr.setLevel0name(g.getLevel0Name()); hr.setLevel1name(g.getLevel1Name()); hr.setLevel2name(g.getLevel2Name()); hr.setLevel3name(g.getLevel3Name()); }); setCreatedIfGreater(hr, lr.getCreated()); addIssues(lr.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records); }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> locationMapper() { return (hr, sr) -> { LocationRecord lr = (LocationRecord) sr; hr.setCountrycode(lr.getCountryCode()); hr.setContinent(lr.getContinent()); hr.setDecimallatitude(lr.getDecimalLatitude()); hr.setDecimallongitude(lr.getDecimalLongitude()); hr.setCoordinateprecision(lr.getCoordinatePrecision()); hr.setCoordinateuncertaintyinmeters(lr.getCoordinateUncertaintyInMeters()); hr.setDepth(lr.getDepth()); hr.setDepthaccuracy(lr.getDepthAccuracy()); hr.setElevation(lr.getElevation()); hr.setElevationaccuracy(lr.getElevationAccuracy()); if (Objects.nonNull(lr.getMaximumDistanceAboveSurfaceInMeters())) { hr.setMaximumdistanceabovesurfaceinmeters( lr.getMaximumDistanceAboveSurfaceInMeters().toString()); } if (Objects.nonNull(lr.getMinimumDistanceAboveSurfaceInMeters())) { hr.setMinimumdistanceabovesurfaceinmeters( lr.getMinimumDistanceAboveSurfaceInMeters().toString()); } hr.setStateprovince(lr.getStateProvince()); hr.setWaterbody(lr.getWaterBody()); hr.setHascoordinate(lr.getHasCoordinate()); hr.setHasgeospatialissues(lr.getHasGeospatialIssue()); hr.setRepatriated(lr.getRepatriated()); hr.setLocality(lr.getLocality()); hr.setPublishingcountry(lr.getPublishingCountry()); Optional.ofNullable(lr.getGadm()) .ifPresent( g -> { hr.setLevel0gid(g.getLevel0Gid()); hr.setLevel1gid(g.getLevel1Gid()); hr.setLevel2gid(g.getLevel2Gid()); hr.setLevel3gid(g.getLevel3Gid()); hr.setLevel0name(g.getLevel0Name()); hr.setLevel1name(g.getLevel1Name()); hr.setLevel2name(g.getLevel2Name()); hr.setLevel3name(g.getLevel3Name()); }); setCreatedIfGreater(hr, lr.getCreated()); addIssues(lr.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records);  }