@Test public void testGetGatheringEvent() throws Exception { ETLStatistics etlStatistics = new ETLStatistics(); CrsMultiMediaTransformer crsMultiMediaTransformer = new CrsMultiMediaTransformer(etlStatistics); CrsExtractor extractor = new CrsExtractor(multimediaFile, etlStatistics); GatheringEvent ge = null; for (XMLRecordInfo extracted : extractor) { CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "objectID", "RMNH.INS.867435"); CommonReflectionUtil.setField(AbstractTransformer.class, crsMultiMediaTransformer, "input", extracted); Element oaiDcElem = getDescendant(extracted.getRecord(), "oai_dc:dc"); Object obj = ReflectionUtil.call(crsMultiMediaTransformer, "getGatheringEvent", new Class[] {Element.class}, new Object[] {oaiDcElem}); ge = (GatheringEvent) obj; } GatheringEvent expectedGe = new GatheringEvent(); expectedGe.setWorldRegion("Asia"); expectedGe.setCountry("Indonesia"); expectedGe.setProvinceState("Southeast Sulawesi"); expectedGe.setSublocality("Kabaena, Pulau"); assertNotNull("01", ge); assertEquals("02", expectedGe.getCountry(), ge.getCountry()); assertEquals("03", expectedGe.getWorldRegion(), ge.getWorldRegion()); assertEquals("04", expectedGe.getProvinceState(), ge.getProvinceState()); assertEquals("05", expectedGe.getSublocality(), ge.getSublocality()); }
private MultiMediaGatheringEvent getGatheringEvent(Element oaiDcElem) { MultiMediaGatheringEvent ge = new MultiMediaGatheringEvent(); ge.setWorldRegion(val(oaiDcElem, "Iptc4xmpExt:WorldRegion")); ge.setCountry(val(oaiDcElem, "Iptc4xmpExt:CountryName")); ge.setProvinceState(val(oaiDcElem, "Iptc4xmpExt:ProvinceState")); ge.setSublocality(val(oaiDcElem, "Iptc4xmpExt:Sublocation")); Double lat = dval(oaiDcElem, "dwc:decimalLatitude"); if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) { warn("Invalid latitude: " + lat); } lat = null; } Double lon = dval(oaiDcElem, "dwc:decimalLongitude"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) { warn("Invalid latitude: " + lon); } lon = null; } if (lat != null || lon != null) { GatheringSiteCoordinates coords; coords = new GatheringSiteCoordinates(lat, lon); ge.setSiteCoordinates(Arrays.asList(coords)); } String s = val(oaiDcElem, "abcd:GatheringAgent"); if (s != null) { Person agent = new Person(); ge.setGatheringPersons(Arrays.asList(agent)); agent.setFullName(s); } return ge; }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private MultiMediaGatheringEvent getGatheringEvent(Element oaiDcElem) { MultiMediaGatheringEvent ge = new MultiMediaGatheringEvent(); ge.setWorldRegion(val(oaiDcElem, "Iptc4xmpExt:WorldRegion")); ge.setCountry(val(oaiDcElem, "Iptc4xmpExt:CountryName")); ge.setProvinceState(val(oaiDcElem, "Iptc4xmpExt:ProvinceState")); ge.setSublocality(val(oaiDcElem, "Iptc4xmpExt:Sublocation")); Double lat = dval(oaiDcElem, "dwc:decimalLatitude"); if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) { warn("Invalid latitude: " + lat); } lat = null; } Double lon = dval(oaiDcElem, "dwc:decimalLongitude"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) { warn("Invalid latitude: " + lon); } lon = null; } if (lat != null || lon != null) { GatheringSiteCoordinates coords; coords = new GatheringSiteCoordinates(lat, lon); ge.setSiteCoordinates(Arrays.asList(coords)); } String s = val(oaiDcElem, "abcd:GatheringAgent"); if (s != null) { Person agent = new Person(); ge.setGatheringPersons(Arrays.asList(agent)); agent.setFullName(s); } return ge; } }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private MultiMediaGatheringEvent getGatheringEvent(Element oaiDcElem) { MultiMediaGatheringEvent ge = new MultiMediaGatheringEvent(); ge.setWorldRegion(val(oaiDcElem, "Iptc4xmpExt:WorldRegion")); ge.setCountry(val(oaiDcElem, "Iptc4xmpExt:CountryName")); ge.setProvinceState(val(oaiDcElem, "Iptc4xmpExt:ProvinceState")); ge.setSublocality(val(oaiDcElem, "Iptc4xmpExt:Sublocation")); Double lat = dval(oaiDcElem, "dwc:decimalLatitude"); if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) { warn("Invalid latitude: " + lat); } lat = null; } Double lon = dval(oaiDcElem, "dwc:decimalLongitude"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) { warn("Invalid latitude: " + lon); } lon = null; } if (lat != null || lon != null) { GatheringSiteCoordinates coords; coords = new GatheringSiteCoordinates(lat, lon); ge.setSiteCoordinates(Arrays.asList(coords)); } String s = val(oaiDcElem, "abcd:GatheringAgent"); if (s != null) { Person agent = new Person(); ge.setGatheringPersons(Arrays.asList(agent)); agent.setFullName(s); } return ge; } CrsMultiMediaTransformer(ETLStatistics stats); }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private MultiMediaGatheringEvent getGatheringEvent(Element oaiDcElem) { MultiMediaGatheringEvent ge = new MultiMediaGatheringEvent(); ge.setWorldRegion(val(oaiDcElem, "Iptc4xmpExt:WorldRegion")); ge.setCountry(val(oaiDcElem, "Iptc4xmpExt:CountryName")); ge.setProvinceState(val(oaiDcElem, "Iptc4xmpExt:ProvinceState")); ge.setSublocality(val(oaiDcElem, "Iptc4xmpExt:Sublocation")); Double lat = dval(oaiDcElem, "dwc:decimalLatitude"); if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) { warn("Invalid latitude: " + lat); } lat = null; } Double lon = dval(oaiDcElem, "dwc:decimalLongitude"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) { warn("Invalid latitude: " + lon); } lon = null; } if (lat != null || lon != null) { GatheringSiteCoordinates coords; coords = new GatheringSiteCoordinates(lat, lon); ge.setSiteCoordinates(Arrays.asList(coords)); } String s = val(oaiDcElem, "abcd:GatheringAgent"); if (s != null) { Person agent = new Person(); ge.setGatheringPersons(Arrays.asList(agent)); agent.setFullName(s); } return ge; } CrsMultiMediaTransformer(ETLStatistics stats);  }
CrsMultiMediaTransformer extends AbstractXMLTransformer<MultiMediaObject> { private MultiMediaGatheringEvent getGatheringEvent(Element oaiDcElem) { MultiMediaGatheringEvent ge = new MultiMediaGatheringEvent(); ge.setWorldRegion(val(oaiDcElem, "Iptc4xmpExt:WorldRegion")); ge.setCountry(val(oaiDcElem, "Iptc4xmpExt:CountryName")); ge.setProvinceState(val(oaiDcElem, "Iptc4xmpExt:ProvinceState")); ge.setSublocality(val(oaiDcElem, "Iptc4xmpExt:Sublocation")); Double lat = dval(oaiDcElem, "dwc:decimalLatitude"); if (lat != null && (lat < -90 || lat > 90)) { if (!suppressErrors) { warn("Invalid latitude: " + lat); } lat = null; } Double lon = dval(oaiDcElem, "dwc:decimalLongitude"); if (lon != null && (lon < -180 || lon > 180)) { if (!suppressErrors) { warn("Invalid latitude: " + lon); } lon = null; } if (lat != null || lon != null) { GatheringSiteCoordinates coords; coords = new GatheringSiteCoordinates(lat, lon); ge.setSiteCoordinates(Arrays.asList(coords)); } String s = val(oaiDcElem, "abcd:GatheringAgent"); if (s != null) { Person agent = new Person(); ge.setGatheringPersons(Arrays.asList(agent)); agent.setFullName(s); } return ge; } CrsMultiMediaTransformer(ETLStatistics stats);   }