@Test public void basicRecordMapperTest() { long now = new Date().getTime(); BasicRecord basicRecord = new BasicRecord(); basicRecord.setBasisOfRecord(BasisOfRecord.HUMAN_OBSERVATION.name()); basicRecord.setSex(Sex.HERMAPHRODITE.name()); basicRecord.setIndividualCount(99); basicRecord.setLifeStage(LifeStage.GAMETE.name()); basicRecord.setTypeStatus(TypeStatus.ALLOTYPE.name()); basicRecord.setTypifiedName("noName"); basicRecord.setEstablishmentMeans(EstablishmentMeans.INVASIVE.name()); basicRecord.setCreated(now); basicRecord.setGbifId(1L); basicRecord.setOrganismQuantity(2d); basicRecord.setOrganismQuantityType("type"); basicRecord.setSampleSizeUnit("unit"); basicRecord.setSampleSizeValue(2d); basicRecord.setRelativeOrganismQuantity(2d); basicRecord.setLicense(License.UNSPECIFIED.name()); OccurrenceHdfsRecord hdfsRecord = toOccurrenceHdfsRecord(basicRecord); Assert.assertEquals(BasisOfRecord.HUMAN_OBSERVATION.name(), hdfsRecord.getBasisofrecord()); Assert.assertEquals(Sex.HERMAPHRODITE.name(), hdfsRecord.getSex()); Assert.assertEquals(Integer.valueOf(99), hdfsRecord.getIndividualcount()); Assert.assertEquals(LifeStage.GAMETE.name(), hdfsRecord.getLifestage()); Assert.assertEquals(TypeStatus.ALLOTYPE.name(), hdfsRecord.getTypestatus()); Assert.assertEquals("noName", hdfsRecord.getTypifiedname()); Assert.assertEquals(EstablishmentMeans.INVASIVE.name(), hdfsRecord.getEstablishmentmeans()); Assert.assertEquals(Double.valueOf(2d), hdfsRecord.getOrganismquantity()); Assert.assertEquals("type", hdfsRecord.getOrganismquantitytype()); Assert.assertEquals("unit", hdfsRecord.getSamplesizeunit()); Assert.assertEquals(Double.valueOf(2d), hdfsRecord.getSamplesizevalue()); Assert.assertEquals(Double.valueOf(2d), hdfsRecord.getRelativeorganismquantity()); Assert.assertNull(hdfsRecord.getLicense()); }
private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> basicRecordMapper() { return (hr, sr) -> { BasicRecord br = (BasicRecord) sr; if (Objects.nonNull(br.getGbifId())) { hr.setGbifid(br.getGbifId()); } hr.setBasisofrecord(br.getBasisOfRecord()); hr.setEstablishmentmeans(br.getEstablishmentMeans()); hr.setIndividualcount(br.getIndividualCount()); hr.setLifestage(br.getLifeStage()); hr.setReferences(br.getReferences()); hr.setSex(br.getSex()); hr.setTypestatus(br.getTypeStatus()); hr.setTypifiedname(br.getTypifiedName()); hr.setOrganismquantity(br.getOrganismQuantity()); hr.setOrganismquantitytype(br.getOrganismQuantityType()); hr.setSamplesizeunit(br.getSampleSizeUnit()); hr.setSamplesizevalue(br.getSampleSizeValue()); hr.setRelativeorganismquantity(br.getRelativeOrganismQuantity()); hr.setOccurrencestatus(br.getOccurrenceStatus()); Optional.ofNullable(br.getRecordedByIds()) .ifPresent( uis -> hr.setRecordedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); Optional.ofNullable(br.getIdentifiedByIds()) .ifPresent( uis -> hr.setIdentifiedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); if (br.getLicense() != null && !License.UNSUPPORTED.name().equals(br.getLicense()) && !License.UNSPECIFIED.name().equals(br.getLicense())) { hr.setLicense(br.getLicense()); } setCreatedIfGreater(hr, br.getCreated()); addIssues(br.getIssues(), hr); }; }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> basicRecordMapper() { return (hr, sr) -> { BasicRecord br = (BasicRecord) sr; if (Objects.nonNull(br.getGbifId())) { hr.setGbifid(br.getGbifId()); } hr.setBasisofrecord(br.getBasisOfRecord()); hr.setEstablishmentmeans(br.getEstablishmentMeans()); hr.setIndividualcount(br.getIndividualCount()); hr.setLifestage(br.getLifeStage()); hr.setReferences(br.getReferences()); hr.setSex(br.getSex()); hr.setTypestatus(br.getTypeStatus()); hr.setTypifiedname(br.getTypifiedName()); hr.setOrganismquantity(br.getOrganismQuantity()); hr.setOrganismquantitytype(br.getOrganismQuantityType()); hr.setSamplesizeunit(br.getSampleSizeUnit()); hr.setSamplesizevalue(br.getSampleSizeValue()); hr.setRelativeorganismquantity(br.getRelativeOrganismQuantity()); hr.setOccurrencestatus(br.getOccurrenceStatus()); Optional.ofNullable(br.getRecordedByIds()) .ifPresent( uis -> hr.setRecordedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); Optional.ofNullable(br.getIdentifiedByIds()) .ifPresent( uis -> hr.setIdentifiedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); if (br.getLicense() != null && !License.UNSUPPORTED.name().equals(br.getLicense()) && !License.UNSPECIFIED.name().equals(br.getLicense())) { hr.setLicense(br.getLicense()); } setCreatedIfGreater(hr, br.getCreated()); addIssues(br.getIssues(), hr); }; } }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> basicRecordMapper() { return (hr, sr) -> { BasicRecord br = (BasicRecord) sr; if (Objects.nonNull(br.getGbifId())) { hr.setGbifid(br.getGbifId()); } hr.setBasisofrecord(br.getBasisOfRecord()); hr.setEstablishmentmeans(br.getEstablishmentMeans()); hr.setIndividualcount(br.getIndividualCount()); hr.setLifestage(br.getLifeStage()); hr.setReferences(br.getReferences()); hr.setSex(br.getSex()); hr.setTypestatus(br.getTypeStatus()); hr.setTypifiedname(br.getTypifiedName()); hr.setOrganismquantity(br.getOrganismQuantity()); hr.setOrganismquantitytype(br.getOrganismQuantityType()); hr.setSamplesizeunit(br.getSampleSizeUnit()); hr.setSamplesizevalue(br.getSampleSizeValue()); hr.setRelativeorganismquantity(br.getRelativeOrganismQuantity()); hr.setOccurrencestatus(br.getOccurrenceStatus()); Optional.ofNullable(br.getRecordedByIds()) .ifPresent( uis -> hr.setRecordedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); Optional.ofNullable(br.getIdentifiedByIds()) .ifPresent( uis -> hr.setIdentifiedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); if (br.getLicense() != null && !License.UNSUPPORTED.name().equals(br.getLicense()) && !License.UNSPECIFIED.name().equals(br.getLicense())) { hr.setLicense(br.getLicense()); } setCreatedIfGreater(hr, br.getCreated()); addIssues(br.getIssues(), hr); }; }  }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> basicRecordMapper() { return (hr, sr) -> { BasicRecord br = (BasicRecord) sr; if (Objects.nonNull(br.getGbifId())) { hr.setGbifid(br.getGbifId()); } hr.setBasisofrecord(br.getBasisOfRecord()); hr.setEstablishmentmeans(br.getEstablishmentMeans()); hr.setIndividualcount(br.getIndividualCount()); hr.setLifestage(br.getLifeStage()); hr.setReferences(br.getReferences()); hr.setSex(br.getSex()); hr.setTypestatus(br.getTypeStatus()); hr.setTypifiedname(br.getTypifiedName()); hr.setOrganismquantity(br.getOrganismQuantity()); hr.setOrganismquantitytype(br.getOrganismQuantityType()); hr.setSamplesizeunit(br.getSampleSizeUnit()); hr.setSamplesizevalue(br.getSampleSizeValue()); hr.setRelativeorganismquantity(br.getRelativeOrganismQuantity()); hr.setOccurrencestatus(br.getOccurrenceStatus()); Optional.ofNullable(br.getRecordedByIds()) .ifPresent( uis -> hr.setRecordedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); Optional.ofNullable(br.getIdentifiedByIds()) .ifPresent( uis -> hr.setIdentifiedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); if (br.getLicense() != null && !License.UNSUPPORTED.name().equals(br.getLicense()) && !License.UNSPECIFIED.name().equals(br.getLicense())) { hr.setLicense(br.getLicense()); } setCreatedIfGreater(hr, br.getCreated()); addIssues(br.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records); }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> basicRecordMapper() { return (hr, sr) -> { BasicRecord br = (BasicRecord) sr; if (Objects.nonNull(br.getGbifId())) { hr.setGbifid(br.getGbifId()); } hr.setBasisofrecord(br.getBasisOfRecord()); hr.setEstablishmentmeans(br.getEstablishmentMeans()); hr.setIndividualcount(br.getIndividualCount()); hr.setLifestage(br.getLifeStage()); hr.setReferences(br.getReferences()); hr.setSex(br.getSex()); hr.setTypestatus(br.getTypeStatus()); hr.setTypifiedname(br.getTypifiedName()); hr.setOrganismquantity(br.getOrganismQuantity()); hr.setOrganismquantitytype(br.getOrganismQuantityType()); hr.setSamplesizeunit(br.getSampleSizeUnit()); hr.setSamplesizevalue(br.getSampleSizeValue()); hr.setRelativeorganismquantity(br.getRelativeOrganismQuantity()); hr.setOccurrencestatus(br.getOccurrenceStatus()); Optional.ofNullable(br.getRecordedByIds()) .ifPresent( uis -> hr.setRecordedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); Optional.ofNullable(br.getIdentifiedByIds()) .ifPresent( uis -> hr.setIdentifiedbyid( uis.stream().map(AgentIdentifier::getValue).collect(Collectors.toList()))); if (br.getLicense() != null && !License.UNSUPPORTED.name().equals(br.getLicense()) && !License.UNSPECIFIED.name().equals(br.getLicense())) { hr.setLicense(br.getLicense()); } setCreatedIfGreater(hr, br.getCreated()); addIssues(br.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records);  }