@Test public void testDoTransform() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); List<MultiMediaObject> transformed = null; CrsMultiMediaTransformer crsMultiMediaTransformer = new CrsMultiMediaTransformer(etlStatistics); String[] testGenera = new String[] {"malus", "parus", "larus", "bombus", "rhododendron", "felix", "tulipa", "rosa", "canis", "passer", "trientalis"}; Class<CrsMultiMediaTransformer> testedClass = CrsMultiMediaTransformer.class; Field privateField = testedClass.getDeclaredField("testGenera"); privateField.setAccessible(true); privateField.set(crsMultiMediaTransformer, testGenera); CrsExtractor extractor = new CrsExtractor(multimediaFile, etlStatistics); for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "objectID", "RMNH.INS.867435"); CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "input", extracted); Object returned = CommonReflectionUtil.callMethod(null, null, crsMultiMediaTransformer, "doTransform"); transformed = (List<MultiMediaObject>) returned; MultiMediaObject sp = transformed.get(0); String id = "RMNH.INS.867435_0"; int expectedNumberOfMmObjects = 2; assertEquals("01", expectedNumberOfMmObjects, transformed.size()); MultiMediaObject expectedMmo = new MultiMediaObject(); expectedMmo.setId(id.concat("@CRS")); expectedMmo.setSourceInstitutionID("Naturalis Biodiversity Center"); expectedMmo.setSourceID("CRS"); expectedMmo.setOwner("Naturalis Biodiversity Center"); expectedMmo.setUnitID(id); expectedMmo.setLicense(CC0_10); expectedMmo.setCollectionType("Diptera"); expectedMmo.setTitle(id); expectedMmo.setAssociatedSpecimenReference("RMNH.INS.867435@CRS"); expectedMmo.setMultiMediaPublic(true); List<ServiceAccessPoint> serviceAccessPoints = new ArrayList<>(); URI expectedUri = URI.create("https: String expectedFormat = "image/jpeg"; String expectedVariant = "ac:GoodQuality"; serviceAccessPoints.add(new ServiceAccessPoint(expectedUri, expectedFormat, expectedVariant)); expectedMmo.setServiceAccessPoints(serviceAccessPoints); assertNotNull("02", sp); assertEquals("03", expectedMmo.getId(), sp.getId()); assertEquals("04", expectedMmo.getSourceInstitutionID(), sp.getSourceInstitutionID()); assertEquals("05", expectedMmo.getSourceID(), sp.getSourceID()); assertEquals("06", expectedMmo.getOwner(), sp.getOwner()); assertEquals("07", expectedMmo.getUnitID(), sp.getUnitID()); assertEquals("08", expectedMmo.getLicense(), sp.getLicense()); assertEquals("09", expectedMmo.getCollectionType(), sp.getCollectionType()); assertEquals("10", expectedMmo.getTitle(), sp.getTitle()); assertEquals("11", expectedMmo.getAssociatedSpecimenReference(), sp.getAssociatedSpecimenReference()); assertEquals("12", expectedMmo.isMultiMediaPublic(), sp.isMultiMediaPublic()); assertEquals("13", expectedMmo.getServiceAccessPoints().get(0).getAccessUri(), sp.getServiceAccessPoints().get(0).getAccessUri()); assertEquals("14", expectedMmo.getServiceAccessPoints().get(0).getFormat(), sp.getServiceAccessPoints().get(0).getFormat()); assertEquals("15", expectedMmo.getServiceAccessPoints().get(0).getVariant(), sp.getServiceAccessPoints().get(0).getVariant()); expectedMmo = new MultiMediaObject(); serviceAccessPoints.clear(); expectedUri = URI.create("https: expectedFormat = "image/jpeg"; expectedVariant = "ac:GoodQuality"; serviceAccessPoints.add(new ServiceAccessPoint(expectedUri, expectedFormat, expectedVariant)); expectedMmo.setServiceAccessPoints(serviceAccessPoints); sp = transformed.get(1); assertEquals("16", expectedMmo.getServiceAccessPoints().get(0).getAccessUri(), sp.getServiceAccessPoints().get(0).getAccessUri()); assertEquals("17", expectedMmo.getServiceAccessPoints().get(0).getFormat(), sp.getServiceAccessPoints().get(0).getFormat()); assertEquals("18", expectedMmo.getServiceAccessPoints().get(0).getVariant(), sp.getServiceAccessPoints().get(0).getVariant()); } }
@Override protected List<MultiMediaObject> doTransform() { Element oaiDcElem = getDescendant(input.getRecord(), "oai_dc:dc"); List<Element> frmDigitaleBestandenElems = getDescendants(oaiDcElem, "frmDigitalebestanden"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); ArrayList<MultiMediaContentIdentification> identifications; String collectionType = val(oaiDcElem, "abcd:CollectionType"); identifications = getIdentifications(ncsrDeterminationElems, collectionType); if (identifications == null) { stats.recordsRejected++; if (!suppressErrors) { error("Invalid/insufficient specimen identification information"); } return null; } stats.recordsAccepted++; first = null; ArrayList<MultiMediaObject> mmos = new ArrayList<>(frmDigitaleBestandenElems.size()); for (int i = 0; i < frmDigitaleBestandenElems.size(); i++) { try { stats.objectsProcessed++; Element frmDigitaleBestandenElem = frmDigitaleBestandenElems.get(i); MultiMediaInfo info = getMultiMediaInfo(frmDigitaleBestandenElem); if (info == null) { continue; } MultiMediaObject mmo = initialize(oaiDcElem, identifications); ServiceAccessPoint sap; sap = new ServiceAccessPoint(info.url, info.mimeType, DEFAULT_IMAGE_QUALITY); mmo.addServiceAccessPoint(sap); String unitID = objectID + '_' + i; mmo.setUnitID(unitID); mmo.setId(getElasticsearchId(CRS, unitID)); mmo.setSourceSystemId(unitID); String title = getTitle(frmDigitaleBestandenElem, unitID); mmo.setTitle(title); mmo.setCaption(title); mmo.setMultiMediaPublic(bval(frmDigitaleBestandenElem, "abcd:MultiMediaPublic")); mmo.setCreator(val(frmDigitaleBestandenElem, "dc:creator")); mmo.setDateLastEdited(getDateModified()); mmos.add(mmo); stats.objectsAccepted++; } catch (Throwable t) { handleError(t); } } return mmos; }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { Element oaiDcElem = getDescendant(input.getRecord(), "oai_dc:dc"); List<Element> frmDigitaleBestandenElems = getDescendants(oaiDcElem, "frmDigitalebestanden"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); ArrayList<MultiMediaContentIdentification> identifications; String collectionType = val(oaiDcElem, "abcd:CollectionType"); identifications = getIdentifications(ncsrDeterminationElems, collectionType); if (identifications == null) { stats.recordsRejected++; if (!suppressErrors) { error("Invalid/insufficient specimen identification information"); } return null; } stats.recordsAccepted++; first = null; ArrayList<MultiMediaObject> mmos = new ArrayList<>(frmDigitaleBestandenElems.size()); for (int i = 0; i < frmDigitaleBestandenElems.size(); i++) { try { stats.objectsProcessed++; Element frmDigitaleBestandenElem = frmDigitaleBestandenElems.get(i); MultiMediaInfo info = getMultiMediaInfo(frmDigitaleBestandenElem); if (info == null) { continue; } MultiMediaObject mmo = initialize(oaiDcElem, identifications); ServiceAccessPoint sap; sap = new ServiceAccessPoint(info.url, info.mimeType, DEFAULT_IMAGE_QUALITY); mmo.addServiceAccessPoint(sap); String unitID = objectID + '_' + i; mmo.setUnitID(unitID); mmo.setId(getElasticsearchId(CRS, unitID)); mmo.setSourceSystemId(unitID); String title = getTitle(frmDigitaleBestandenElem, unitID); mmo.setTitle(title); mmo.setCaption(title); mmo.setMultiMediaPublic(bval(frmDigitaleBestandenElem, "abcd:MultiMediaPublic")); mmo.setCreator(val(frmDigitaleBestandenElem, "dc:creator")); mmo.setDateLastEdited(getDateModified()); mmos.add(mmo); stats.objectsAccepted++; } catch (Throwable t) { handleError(t); } } return mmos; } }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { Element oaiDcElem = getDescendant(input.getRecord(), "oai_dc:dc"); List<Element> frmDigitaleBestandenElems = getDescendants(oaiDcElem, "frmDigitalebestanden"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); ArrayList<MultiMediaContentIdentification> identifications; String collectionType = val(oaiDcElem, "abcd:CollectionType"); identifications = getIdentifications(ncsrDeterminationElems, collectionType); if (identifications == null) { stats.recordsRejected++; if (!suppressErrors) { error("Invalid/insufficient specimen identification information"); } return null; } stats.recordsAccepted++; first = null; ArrayList<MultiMediaObject> mmos = new ArrayList<>(frmDigitaleBestandenElems.size()); for (int i = 0; i < frmDigitaleBestandenElems.size(); i++) { try { stats.objectsProcessed++; Element frmDigitaleBestandenElem = frmDigitaleBestandenElems.get(i); MultiMediaInfo info = getMultiMediaInfo(frmDigitaleBestandenElem); if (info == null) { continue; } MultiMediaObject mmo = initialize(oaiDcElem, identifications); ServiceAccessPoint sap; sap = new ServiceAccessPoint(info.url, info.mimeType, DEFAULT_IMAGE_QUALITY); mmo.addServiceAccessPoint(sap); String unitID = objectID + '_' + i; mmo.setUnitID(unitID); mmo.setId(getElasticsearchId(CRS, unitID)); mmo.setSourceSystemId(unitID); String title = getTitle(frmDigitaleBestandenElem, unitID); mmo.setTitle(title); mmo.setCaption(title); mmo.setMultiMediaPublic(bval(frmDigitaleBestandenElem, "abcd:MultiMediaPublic")); mmo.setCreator(val(frmDigitaleBestandenElem, "dc:creator")); mmo.setDateLastEdited(getDateModified()); mmos.add(mmo); stats.objectsAccepted++; } catch (Throwable t) { handleError(t); } } return mmos; } CrsMultiMediaTransformer(ETLStatistics stats); }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { Element oaiDcElem = getDescendant(input.getRecord(), "oai_dc:dc"); List<Element> frmDigitaleBestandenElems = getDescendants(oaiDcElem, "frmDigitalebestanden"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); ArrayList<MultiMediaContentIdentification> identifications; String collectionType = val(oaiDcElem, "abcd:CollectionType"); identifications = getIdentifications(ncsrDeterminationElems, collectionType); if (identifications == null) { stats.recordsRejected++; if (!suppressErrors) { error("Invalid/insufficient specimen identification information"); } return null; } stats.recordsAccepted++; first = null; ArrayList<MultiMediaObject> mmos = new ArrayList<>(frmDigitaleBestandenElems.size()); for (int i = 0; i < frmDigitaleBestandenElems.size(); i++) { try { stats.objectsProcessed++; Element frmDigitaleBestandenElem = frmDigitaleBestandenElems.get(i); MultiMediaInfo info = getMultiMediaInfo(frmDigitaleBestandenElem); if (info == null) { continue; } MultiMediaObject mmo = initialize(oaiDcElem, identifications); ServiceAccessPoint sap; sap = new ServiceAccessPoint(info.url, info.mimeType, DEFAULT_IMAGE_QUALITY); mmo.addServiceAccessPoint(sap); String unitID = objectID + '_' + i; mmo.setUnitID(unitID); mmo.setId(getElasticsearchId(CRS, unitID)); mmo.setSourceSystemId(unitID); String title = getTitle(frmDigitaleBestandenElem, unitID); mmo.setTitle(title); mmo.setCaption(title); mmo.setMultiMediaPublic(bval(frmDigitaleBestandenElem, "abcd:MultiMediaPublic")); mmo.setCreator(val(frmDigitaleBestandenElem, "dc:creator")); mmo.setDateLastEdited(getDateModified()); mmos.add(mmo); stats.objectsAccepted++; } catch (Throwable t) { handleError(t); } } return mmos; } CrsMultiMediaTransformer(ETLStatistics stats);  }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { @Override protected List<MultiMediaObject> doTransform() { Element oaiDcElem = getDescendant(input.getRecord(), "oai_dc:dc"); List<Element> frmDigitaleBestandenElems = getDescendants(oaiDcElem, "frmDigitalebestanden"); List<Element> ncsrDeterminationElems = getDescendants(oaiDcElem, "ncrsDetermination"); ArrayList<MultiMediaContentIdentification> identifications; String collectionType = val(oaiDcElem, "abcd:CollectionType"); identifications = getIdentifications(ncsrDeterminationElems, collectionType); if (identifications == null) { stats.recordsRejected++; if (!suppressErrors) { error("Invalid/insufficient specimen identification information"); } return null; } stats.recordsAccepted++; first = null; ArrayList<MultiMediaObject> mmos = new ArrayList<>(frmDigitaleBestandenElems.size()); for (int i = 0; i < frmDigitaleBestandenElems.size(); i++) { try { stats.objectsProcessed++; Element frmDigitaleBestandenElem = frmDigitaleBestandenElems.get(i); MultiMediaInfo info = getMultiMediaInfo(frmDigitaleBestandenElem); if (info == null) { continue; } MultiMediaObject mmo = initialize(oaiDcElem, identifications); ServiceAccessPoint sap; sap = new ServiceAccessPoint(info.url, info.mimeType, DEFAULT_IMAGE_QUALITY); mmo.addServiceAccessPoint(sap); String unitID = objectID + '_' + i; mmo.setUnitID(unitID); mmo.setId(getElasticsearchId(CRS, unitID)); mmo.setSourceSystemId(unitID); String title = getTitle(frmDigitaleBestandenElem, unitID); mmo.setTitle(title); mmo.setCaption(title); mmo.setMultiMediaPublic(bval(frmDigitaleBestandenElem, "abcd:MultiMediaPublic")); mmo.setCreator(val(frmDigitaleBestandenElem, "dc:creator")); mmo.setDateLastEdited(getDateModified()); mmos.add(mmo); stats.objectsAccepted++; } catch (Throwable t) { handleError(t); } } return mmos; } CrsMultiMediaTransformer(ETLStatistics stats);   }