@Test public void metadataMapperTest() { String datasetKey = UUID.randomUUID().toString(); String nodeKey = UUID.randomUUID().toString(); String installationKey = UUID.randomUUID().toString(); String organizationKey = UUID.randomUUID().toString(); List<String> networkKey = Collections.singletonList(UUID.randomUUID().toString()); MetadataRecord metadataRecord = MetadataRecord.newBuilder() .setId("1") .setDatasetKey(datasetKey) .setCrawlId(1) .setDatasetPublishingCountry(Country.COSTA_RICA.getIso2LetterCode()) .setLicense(License.CC_BY_4_0.name()) .setNetworkKeys(networkKey) .setDatasetTitle("TestDataset") .setEndorsingNodeKey(nodeKey) .setInstallationKey(installationKey) .setLastCrawled(new Date().getTime()) .setProtocol(EndpointType.DWC_ARCHIVE.name()) .setPublisherTitle("Pub") .setPublishingOrganizationKey(organizationKey) .build(); OccurrenceHdfsRecord hdfsRecord = toOccurrenceHdfsRecord(metadataRecord); Assert.assertEquals(datasetKey, hdfsRecord.getDatasetkey()); Assert.assertEquals(networkKey, hdfsRecord.getNetworkkey()); Assert.assertEquals(installationKey, hdfsRecord.getInstallationkey()); Assert.assertEquals(organizationKey, hdfsRecord.getPublishingorgkey()); Assert.assertEquals(License.CC_BY_4_0.name(), hdfsRecord.getLicense()); }
private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> metadataMapper() { return (hr, sr) -> { MetadataRecord mr = (MetadataRecord) sr; hr.setCrawlid(mr.getCrawlId()); hr.setDatasetkey(mr.getDatasetKey()); hr.setDatasetname(mr.getDatasetTitle()); hr.setInstallationkey(mr.getInstallationKey()); hr.setProtocol(mr.getProtocol()); hr.setNetworkkey(mr.getNetworkKeys()); hr.setPublisher(mr.getPublisherTitle()); hr.setPublishingorgkey(mr.getPublishingOrganizationKey()); hr.setLastcrawled(mr.getLastCrawled()); hr.setProjectid(mr.getProjectId()); hr.setProgrammeacronym(mr.getProgrammeAcronym()); hr.setHostingorganizationkey(mr.getHostingOrganizationKey()); if (hr.getLicense() == null) { hr.setLicense(mr.getLicense()); } setCreatedIfGreater(hr, mr.getCreated()); addIssues(mr.getIssues(), hr); }; }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> metadataMapper() { return (hr, sr) -> { MetadataRecord mr = (MetadataRecord) sr; hr.setCrawlid(mr.getCrawlId()); hr.setDatasetkey(mr.getDatasetKey()); hr.setDatasetname(mr.getDatasetTitle()); hr.setInstallationkey(mr.getInstallationKey()); hr.setProtocol(mr.getProtocol()); hr.setNetworkkey(mr.getNetworkKeys()); hr.setPublisher(mr.getPublisherTitle()); hr.setPublishingorgkey(mr.getPublishingOrganizationKey()); hr.setLastcrawled(mr.getLastCrawled()); hr.setProjectid(mr.getProjectId()); hr.setProgrammeacronym(mr.getProgrammeAcronym()); hr.setHostingorganizationkey(mr.getHostingOrganizationKey()); if (hr.getLicense() == null) { hr.setLicense(mr.getLicense()); } setCreatedIfGreater(hr, mr.getCreated()); addIssues(mr.getIssues(), hr); }; } }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> metadataMapper() { return (hr, sr) -> { MetadataRecord mr = (MetadataRecord) sr; hr.setCrawlid(mr.getCrawlId()); hr.setDatasetkey(mr.getDatasetKey()); hr.setDatasetname(mr.getDatasetTitle()); hr.setInstallationkey(mr.getInstallationKey()); hr.setProtocol(mr.getProtocol()); hr.setNetworkkey(mr.getNetworkKeys()); hr.setPublisher(mr.getPublisherTitle()); hr.setPublishingorgkey(mr.getPublishingOrganizationKey()); hr.setLastcrawled(mr.getLastCrawled()); hr.setProjectid(mr.getProjectId()); hr.setProgrammeacronym(mr.getProgrammeAcronym()); hr.setHostingorganizationkey(mr.getHostingOrganizationKey()); if (hr.getLicense() == null) { hr.setLicense(mr.getLicense()); } setCreatedIfGreater(hr, mr.getCreated()); addIssues(mr.getIssues(), hr); }; }  }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> metadataMapper() { return (hr, sr) -> { MetadataRecord mr = (MetadataRecord) sr; hr.setCrawlid(mr.getCrawlId()); hr.setDatasetkey(mr.getDatasetKey()); hr.setDatasetname(mr.getDatasetTitle()); hr.setInstallationkey(mr.getInstallationKey()); hr.setProtocol(mr.getProtocol()); hr.setNetworkkey(mr.getNetworkKeys()); hr.setPublisher(mr.getPublisherTitle()); hr.setPublishingorgkey(mr.getPublishingOrganizationKey()); hr.setLastcrawled(mr.getLastCrawled()); hr.setProjectid(mr.getProjectId()); hr.setProgrammeacronym(mr.getProgrammeAcronym()); hr.setHostingorganizationkey(mr.getHostingOrganizationKey()); if (hr.getLicense() == null) { hr.setLicense(mr.getLicense()); } setCreatedIfGreater(hr, mr.getCreated()); addIssues(mr.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records); }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> metadataMapper() { return (hr, sr) -> { MetadataRecord mr = (MetadataRecord) sr; hr.setCrawlid(mr.getCrawlId()); hr.setDatasetkey(mr.getDatasetKey()); hr.setDatasetname(mr.getDatasetTitle()); hr.setInstallationkey(mr.getInstallationKey()); hr.setProtocol(mr.getProtocol()); hr.setNetworkkey(mr.getNetworkKeys()); hr.setPublisher(mr.getPublisherTitle()); hr.setPublishingorgkey(mr.getPublishingOrganizationKey()); hr.setLastcrawled(mr.getLastCrawled()); hr.setProjectid(mr.getProjectId()); hr.setProgrammeacronym(mr.getProgrammeAcronym()); hr.setHostingorganizationkey(mr.getHostingOrganizationKey()); if (hr.getLicense() == null) { hr.setLicense(mr.getLicense()); } setCreatedIfGreater(hr, mr.getCreated()); addIssues(mr.getIssues(), hr); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records);  }