@Test public void multimediaMapperTest() { MultimediaRecord multimediaRecord = new MultimediaRecord(); multimediaRecord.setId("1"); Multimedia multimedia = new Multimedia(); multimedia.setType(MediaType.StillImage.name()); multimedia.setLicense(License.CC_BY_4_0.name()); multimedia.setSource("image.jpg"); multimediaRecord.setMultimediaItems(Collections.singletonList(multimedia)); OccurrenceHdfsRecord hdfsRecord = toOccurrenceHdfsRecord(multimediaRecord); List<Multimedia> media = MediaSerDeserUtils.fromJson(hdfsRecord.getExtMultimedia()); Assert.assertEquals(media.get(0), multimedia); Assert.assertTrue(hdfsRecord.getMediatype().contains(MediaType.StillImage.name())); }
private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> multimediaMapper() { return (hr, sr) -> { MultimediaRecord mr = (MultimediaRecord) sr; List<String> mediaTypes = mr.getMultimediaItems().stream() .filter(i -> !Strings.isNullOrEmpty(i.getType())) .map(Multimedia::getType) .map(TextNode::valueOf) .map(TextNode::asText) .collect(Collectors.toList()); hr.setExtMultimedia(MediaSerDeserUtils.toJson(mr.getMultimediaItems())); setCreatedIfGreater(hr, mr.getCreated()); hr.setMediatype(mediaTypes); }; }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> multimediaMapper() { return (hr, sr) -> { MultimediaRecord mr = (MultimediaRecord) sr; List<String> mediaTypes = mr.getMultimediaItems().stream() .filter(i -> !Strings.isNullOrEmpty(i.getType())) .map(Multimedia::getType) .map(TextNode::valueOf) .map(TextNode::asText) .collect(Collectors.toList()); hr.setExtMultimedia(MediaSerDeserUtils.toJson(mr.getMultimediaItems())); setCreatedIfGreater(hr, mr.getCreated()); hr.setMediatype(mediaTypes); }; } }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> multimediaMapper() { return (hr, sr) -> { MultimediaRecord mr = (MultimediaRecord) sr; List<String> mediaTypes = mr.getMultimediaItems().stream() .filter(i -> !Strings.isNullOrEmpty(i.getType())) .map(Multimedia::getType) .map(TextNode::valueOf) .map(TextNode::asText) .collect(Collectors.toList()); hr.setExtMultimedia(MediaSerDeserUtils.toJson(mr.getMultimediaItems())); setCreatedIfGreater(hr, mr.getCreated()); hr.setMediatype(mediaTypes); }; }  }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> multimediaMapper() { return (hr, sr) -> { MultimediaRecord mr = (MultimediaRecord) sr; List<String> mediaTypes = mr.getMultimediaItems().stream() .filter(i -> !Strings.isNullOrEmpty(i.getType())) .map(Multimedia::getType) .map(TextNode::valueOf) .map(TextNode::asText) .collect(Collectors.toList()); hr.setExtMultimedia(MediaSerDeserUtils.toJson(mr.getMultimediaItems())); setCreatedIfGreater(hr, mr.getCreated()); hr.setMediatype(mediaTypes); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records); }
OccurrenceHdfsRecordConverter { private static BiConsumer<OccurrenceHdfsRecord, SpecificRecordBase> multimediaMapper() { return (hr, sr) -> { MultimediaRecord mr = (MultimediaRecord) sr; List<String> mediaTypes = mr.getMultimediaItems().stream() .filter(i -> !Strings.isNullOrEmpty(i.getType())) .map(Multimedia::getType) .map(TextNode::valueOf) .map(TextNode::asText) .collect(Collectors.toList()); hr.setExtMultimedia(MediaSerDeserUtils.toJson(mr.getMultimediaItems())); setCreatedIfGreater(hr, mr.getCreated()); hr.setMediatype(mediaTypes); }; }  static OccurrenceHdfsRecord toOccurrenceHdfsRecord(SpecificRecordBase... records);  }