Commit 5993985b authored by Steinberg, Jan's avatar Steinberg, Jan
Browse files

Merge branch 'master' of git.gesis.org:dda/dda-wizard

parents 1b098309 6dd78548
...@@ -46,8 +46,8 @@ import org.xml.sax.InputSource; ...@@ -46,8 +46,8 @@ import org.xml.sax.InputSource;
import net.sf.saxon.TransformerFactoryImpl; import net.sf.saxon.TransformerFactoryImpl;
import net.sf.saxon.trans.XPathException; import net.sf.saxon.trans.XPathException;
public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSource, ErrorListener {
public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSource, ErrorListener {
private final static Logger LOG = LoggerFactory.getLogger(XsltTransformerOaiPmhBundlesStreamSource.class); private final static Logger LOG = LoggerFactory.getLogger(XsltTransformerOaiPmhBundlesStreamSource.class);
...@@ -66,14 +66,16 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -66,14 +66,16 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
client = new OaiPmhClient(oaiPmhEndpoint); client = new OaiPmhClient(oaiPmhEndpoint);
} }
public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, Map<String, String> metadataPrefix2XsltMap, LocalDate from, LocalDate until) { public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, Map<String, String> metadataPrefix2XsltMap,
LocalDate from, LocalDate until) {
this(oaiPmhEndpoint, metadataPrefix2XsltMap); this(oaiPmhEndpoint, metadataPrefix2XsltMap);
this.intervalType = HarvestingIntervalType.DAY_INTERVAL_HARVEST; this.intervalType = HarvestingIntervalType.DAY_INTERVAL_HARVEST;
this.dayFrom = from; this.dayFrom = from;
this.dayUntil = until; this.dayUntil = until;
} }
public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, Map<String, String> metadataPrefix2XsltMap, Instant from, Instant until) { public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, Map<String, String> metadataPrefix2XsltMap,
Instant from, Instant until) {
this(oaiPmhEndpoint, metadataPrefix2XsltMap); this(oaiPmhEndpoint, metadataPrefix2XsltMap);
this.intervalType = HarvestingIntervalType.SECOND_INTERVAL_HARVEST; this.intervalType = HarvestingIntervalType.SECOND_INTERVAL_HARVEST;
this.secondFrom = from; this.secondFrom = from;
...@@ -81,7 +83,8 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -81,7 +83,8 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
} }
// And here come the same methods but with set specification // And here come the same methods but with set specification
public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec, Map<String, String> metadataPrefix2XsltMap) { public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec,
Map<String, String> metadataPrefix2XsltMap) {
this.oaiPmhEndpoint = oaiPmhEndpoint; this.oaiPmhEndpoint = oaiPmhEndpoint;
this.setSpec = setSpec; this.setSpec = setSpec;
this.metadataPrefix2XsltMap = metadataPrefix2XsltMap; this.metadataPrefix2XsltMap = metadataPrefix2XsltMap;
...@@ -89,14 +92,16 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -89,14 +92,16 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
client = new OaiPmhClient(oaiPmhEndpoint); client = new OaiPmhClient(oaiPmhEndpoint);
} }
public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec, Map<String, String> metadataPrefix2XsltMap, LocalDate from, LocalDate until) { public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec,
Map<String, String> metadataPrefix2XsltMap, LocalDate from, LocalDate until) {
this(oaiPmhEndpoint, setSpec, metadataPrefix2XsltMap); this(oaiPmhEndpoint, setSpec, metadataPrefix2XsltMap);
this.intervalType = HarvestingIntervalType.DAY_INTERVAL_HARVEST; this.intervalType = HarvestingIntervalType.DAY_INTERVAL_HARVEST;
this.dayFrom = from; this.dayFrom = from;
this.dayUntil = until; this.dayUntil = until;
} }
public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec, Map<String, String> metadataPrefix2XsltMap, Instant from, Instant until) { public XsltTransformerOaiPmhBundlesStreamSource(String oaiPmhEndpoint, String setSpec,
Map<String, String> metadataPrefix2XsltMap, Instant from, Instant until) {
this(oaiPmhEndpoint, setSpec, metadataPrefix2XsltMap); this(oaiPmhEndpoint, setSpec, metadataPrefix2XsltMap);
this.intervalType = HarvestingIntervalType.SECOND_INTERVAL_HARVEST; this.intervalType = HarvestingIntervalType.SECOND_INTERVAL_HARVEST;
this.secondFrom = from; this.secondFrom = from;
...@@ -129,40 +134,47 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -129,40 +134,47 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
break; break;
} }
// some record's metadata may not be available for all specified metadataPrefixes // some record's metadata may not be available for all specified
// therefore collecting the union of all identifiers over all specified metadataPrefixes // metadataPrefixes
Stream<OAIPMHtype> listIdentifiersResponseStream = metadataPrefixes. // therefore collecting the union of all identifiers over all specified
stream(). // metadataPrefixes
flatMap(mp -> { Stream<OAIPMHtype> listIdentifiersResponseStream = metadataPrefixes.stream().flatMap(mp -> {
LOG.debug("filling list identifier stream with mp {}, from {}, until {}, setSpec {}", mp, from, until, setSpec); LOG.info("filling list identifier stream with mp {}, from {}, until {}, setSpec {}", mp, from, until,
if (setSpec == null|| setSpec.trim().isEmpty()) { setSpec);
// exeley only takes "YYY-mm-dd" as from date
String exeleyFrom = from.split("T")[0];
// String exeleyUntil= until.split("T")[0];
LOG.info("exeley specials: {} -> {}", exeleyFrom, until);
if (setSpec == null || setSpec.trim().isEmpty() && mp.equals("pam")) {
return client.listIdentifiersStream(mp, exeleyFrom, until, null);
} else if (setSpec == null || setSpec.trim().isEmpty()) {
return client.listIdentifiersStream(mp, from, until, null); return client.listIdentifiersStream(mp, from, until, null);
} }
if ( mp.equals("pam") ) {
return client.listIdentifiersStream(mp, exeleyFrom, until, setSpec);
}
return client.listIdentifiersStream(mp, from, until, setSpec); return client.listIdentifiersStream(mp, from, until, setSpec);
}); });
Stream<String> uniqueIdentifiersStream = listIdentifiersResponseStream.flatMap( oaiPmhType -> { Stream<String> uniqueIdentifiersStream = listIdentifiersResponseStream.flatMap(oaiPmhType -> {
/*return oaiPmhType. /*
getListIdentifiers(). * return oaiPmhType. getListIdentifiers(). getHeader(). stream().map(h ->
getHeader(). * h.getIdentifier() );
stream().map(h -> h.getIdentifier() );
*/ */
Stream<String> result = Stream.empty(); Stream<String> result = Stream.empty();
ListIdentifiersType listIdentifiersType = oaiPmhType.getListIdentifiers(); ListIdentifiersType listIdentifiersType = oaiPmhType.getListIdentifiers();
if (null != listIdentifiersType) { if (null != listIdentifiersType) {
List<HeaderType> headers = listIdentifiersType.getHeader(); List<HeaderType> headers = listIdentifiersType.getHeader();
if (null != headers) { if (null != headers) {
result = headers.stream().map(h -> h.getIdentifier() ); result = headers.stream().map(h -> h.getIdentifier());
} }
} }
return result; return result;
}). }).filter(Objects::nonNull).distinct();
filter(Objects::nonNull).
distinct();
List<String> uniqueIdentifiers = uniqueIdentifiersStream.collect( Collectors.toList() ); List<String> uniqueIdentifiers = uniqueIdentifiersStream.collect(Collectors.toList());
//uniqueIdentifiers.forEach(LOG::debug); // uniqueIdentifiers.forEach(LOG::debug);
resultBundleStream = uniqueIdentifiers.stream().map(this::getBundle).filter(Objects::nonNull); resultBundleStream = uniqueIdentifiers.stream().map(this::getBundle).filter(Objects::nonNull);
return resultBundleStream; return resultBundleStream;
...@@ -170,38 +182,33 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -170,38 +182,33 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
public Bundle getBundle(String oaiPmhIdentifier) { public Bundle getBundle(String oaiPmhIdentifier) {
LOG.debug("GetBundle - {}", oaiPmhIdentifier); LOG.debug("GetBundle - {}", oaiPmhIdentifier);
//Bundle bundleResult = new AutonomouslyContentResolvingBundle(ImmutableSet.of() ); // Bundle bundleResult = new
// AutonomouslyContentResolvingBundle(ImmutableSet.of() );
Set<Metadatum> bundleMetadata = new HashSet<>(); Set<Metadatum> bundleMetadata = new HashSet<>();
Set<String> metadataPrefixes = metadataPrefix2XsltMap.keySet(); Set<String> metadataPrefixes = metadataPrefix2XsltMap.keySet();
String lastModifiedString = ""; String lastModifiedString = "";
Bundle resultBundle = null; Bundle resultBundle = null;
//LOG.info("looking up {}", id); // LOG.info("looking up {}", id);
for (String metadataPrefix : metadataPrefixes) { for (String metadataPrefix : metadataPrefixes) {
try { try {
// --- STEP 1: get XML input // --- STEP 1: get XML input
String getRecordXmlDocumentResponseString = client.getRecordString(oaiPmhIdentifier, metadataPrefix); String getRecordXmlDocumentResponseString = client.getRecordString(oaiPmhIdentifier, metadataPrefix);
// try to make exeley data transformable ( & -> &amp; to start with)
// ToDo: find the right location for it! // LOG.info("--------------------------");
if ( getRecordXmlDocumentResponseString.contains("identifier=\"oai:exeley.com:10.") ) { // LOG.info("{}", getRecordXmlDocumentResponseString);
getRecordXmlDocumentResponseString = getRecordXmlDocumentResponseString.replace("&", "&amp;"); if (isDeletedRecord(getRecordXmlDocumentResponseString)) {
}
//LOG.info("--------------------------");
//LOG.info("{}", getRecordXmlDocumentResponseString);
if ( isDeletedRecord(getRecordXmlDocumentResponseString) ) {
resultBundle = null; resultBundle = null;
break; break;
} }
else { else {
// --- STEP 2: convert XML input according to XSLT // --- STEP 2: convert XML input according to XSLT
TransformerFactory factory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", TransformerFactoryImpl.class.getClassLoader() ); TransformerFactory factory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl",
TransformerFactoryImpl.class.getClassLoader());
Templates xslTemplate = factory.newTemplates( Templates xslTemplate = factory.newTemplates(
new StreamSource( new StreamSource(new StringReader(metadataPrefix2XsltMap.get(metadataPrefix))));
new StringReader(
metadataPrefix2XsltMap.
get(metadataPrefix) ) ) );
Source xmlInput = new StreamSource( new StringReader(getRecordXmlDocumentResponseString) ); Source xmlInput = new StreamSource(new StringReader(getRecordXmlDocumentResponseString));
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
Result xmlOutput = new StreamResult(writer); Result xmlOutput = new StreamResult(writer);
...@@ -217,7 +224,8 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -217,7 +224,8 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
// STEP 3: convert XSLT-converted XML output to Java JAXB object // STEP 3: convert XSLT-converted XML output to Java JAXB object
JAXBContext jaxbContext = JAXBContext.newInstance(XmlBundle.class); JAXBContext jaxbContext = JAXBContext.newInstance(XmlBundle.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
InputStream convertedXmlInputStream = new ByteArrayInputStream(xsltConvertedXmlOutput.getBytes(StandardCharsets.UTF_8) ); InputStream convertedXmlInputStream = new ByteArrayInputStream(
xsltConvertedXmlOutput.getBytes(StandardCharsets.UTF_8));
Bundle currentPartBundle = (Bundle) unmarshaller.unmarshal(convertedXmlInputStream); Bundle currentPartBundle = (Bundle) unmarshaller.unmarshal(convertedXmlInputStream);
Set<Metadatum> metadata = currentPartBundle.getMetadata(); Set<Metadatum> metadata = currentPartBundle.getMetadata();
...@@ -225,46 +233,47 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -225,46 +233,47 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
// STEP 4: extract lastModifiedDate // STEP 4: extract lastModifiedDate
StringReader sr = new StringReader(getRecordXmlDocumentResponseString); StringReader sr = new StringReader(getRecordXmlDocumentResponseString);
//LOG.info("sr=\n{}", getRecordXmlDocumentResponseString); // LOG.info("sr=\n{}", getRecordXmlDocumentResponseString);
JAXBContext oaiPmhjaxbContext = JAXBContext.newInstance(OAIPMHtype.class); JAXBContext oaiPmhjaxbContext = JAXBContext.newInstance(OAIPMHtype.class);
Unmarshaller oaiPmhUnmarshaller = oaiPmhjaxbContext.createUnmarshaller(); Unmarshaller oaiPmhUnmarshaller = oaiPmhjaxbContext.createUnmarshaller();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
JAXBElement<OAIPMHtype> wrappedResponseObject = (JAXBElement<OAIPMHtype>) oaiPmhUnmarshaller.unmarshal(sr); JAXBElement<OAIPMHtype> wrappedResponseObject = (JAXBElement<OAIPMHtype>) oaiPmhUnmarshaller
.unmarshal(sr);
OAIPMHtype response = wrappedResponseObject.getValue(); OAIPMHtype response = wrappedResponseObject.getValue();
lastModifiedString = response.getGetRecord().getRecord().getHeader().getDatestamp(); lastModifiedString = response.getGetRecord().getRecord().getHeader().getDatestamp();
// STEP 5: add identifier metadatum // STEP 5: add identifier metadatum
Metadatum reference = new SimpleMetadatum("internal.dda.reference", oaiPmhEndpoint + "@@" + oaiPmhIdentifier); Metadatum reference = new SimpleMetadatum("internal.dda.reference",
oaiPmhEndpoint + "@@" + oaiPmhIdentifier);
bundleMetadata.add(reference); bundleMetadata.add(reference);
resultBundle = BundleBuilder.create().withMetadata(bundleMetadata).withLastModifiedString(lastModifiedString).build(); resultBundle = BundleBuilder.create().withMetadata(bundleMetadata)
.withLastModifiedString(lastModifiedString).build();
} }
} } catch (XPathException e) {
catch (XPathException e) {
LOG.debug("Catched XPathException"); LOG.debug("Catched XPathException");
String errorCode = e.getErrorCodeLocalPart(); String errorCode = e.getErrorCodeLocalPart();
if (null != errorCode) { if (null != errorCode) {
if ("filteraway".equals(errorCode) ) { if ("filteraway".equals(errorCode)) {
LOG.info("1- filtering away oaiPmhIdentifier={}", oaiPmhIdentifier); LOG.info("1- filtering away oaiPmhIdentifier={}", oaiPmhIdentifier);
LOG.info("Error detail: {}", e.getCause().getLocalizedMessage()); LOG.info("Error detail: {}", e.getCause().getLocalizedMessage());
resultBundle = null; resultBundle = null;
// test if this break is really necessary, taken out. STJ // test if this break is really necessary, taken out. STJ
// break; // break;
} } else {
else {
LOG.warn("2- fatalError. Filtering away oaiPmhIdentifier=" + oaiPmhIdentifier, e); LOG.warn("2- fatalError. Filtering away oaiPmhIdentifier=" + oaiPmhIdentifier, e);
} }
} } else {
else {
LOG.warn("3- fatalError. Filtering away oaiPmhIdentifier=" + oaiPmhIdentifier, e); LOG.warn("3- fatalError. Filtering away oaiPmhIdentifier=" + oaiPmhIdentifier, e);
} }
resultBundle = null; resultBundle = null;
} }
catch (Throwable t) { catch (Throwable t) {
LOG.warn("Problem getting record with id " + oaiPmhIdentifier + " and metadataPrefix " + metadataPrefix + ". Skipping it.", t); LOG.warn("Problem getting record with id " + oaiPmhIdentifier + " and metadataPrefix " + metadataPrefix
+ ". Skipping it.", t);
resultBundle = null; resultBundle = null;
} }
...@@ -276,27 +285,25 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -276,27 +285,25 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
public static boolean isDeletedRecord(String getRecordXmlDocumentResponseString) { public static boolean isDeletedRecord(String getRecordXmlDocumentResponseString) {
XPath xpath = XPathFactory.newInstance().newXPath(); XPath xpath = XPathFactory.newInstance().newXPath();
InputSource inputSource = new InputSource( new StringReader(getRecordXmlDocumentResponseString) ); InputSource inputSource = new InputSource(new StringReader(getRecordXmlDocumentResponseString));
String headerStatus; String headerStatus;
boolean result; boolean result;
try { try {
//see https://stackoverflow.com/a/6397369/923560 // see https://stackoverflow.com/a/6397369/923560
XPathExpression expr = xpath.compile( XPathExpression expr = xpath
"//*[local-name()='OAI-PMH' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']" .compile("//*[local-name()='OAI-PMH' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']"
+ "/*[local-name()='GetRecord' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']" + "/*[local-name()='GetRecord' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']"
+ "/*[local-name()='record' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']" + "/*[local-name()='record' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']"
+ "/*[local-name()='header' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']/" + "/*[local-name()='header' and namespace-uri()='http://www.openarchives.org/OAI/2.0/']/"
+ "@status"); + "@status");
headerStatus = expr.evaluate(inputSource); headerStatus = expr.evaluate(inputSource);
if ( "deleted".equals(headerStatus) ) { if ("deleted".equals(headerStatus)) {
result = true; result = true;
} } else {
else {
result = false; result = false;
} }
} } catch (XPathExpressionException e) {
catch (XPathExpressionException e) {
LOG.error("Problem identifying if deleted record", e); LOG.error("Problem identifying if deleted record", e);
result = true; result = true;
} }
...@@ -319,14 +326,14 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -319,14 +326,14 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
public static String convertInstantToOaiPmhString(Instant instant) { public static String convertInstantToOaiPmhString(Instant instant) {
String result; String result;
result = instant != null? instant.toString() : null; result = instant != null ? instant.toString() : null;
return result; return result;
} }
public static String convertLocalDateToOaiPmhString(LocalDate localDate) { public static String convertLocalDateToOaiPmhString(LocalDate localDate) {
String result; String result;
result = localDate != null? localDate.toString() : null; result = localDate != null ? localDate.toString() : null;
return result; return result;
} }
...@@ -342,15 +349,13 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo ...@@ -342,15 +349,13 @@ public class XsltTransformerOaiPmhBundlesStreamSource implements BundlesStreamSo
XPathException xPathException = (XPathException) arg0; XPathException xPathException = (XPathException) arg0;
String errorCode = xPathException.getErrorCodeLocalPart(); String errorCode = xPathException.getErrorCodeLocalPart();
if (null != errorCode) { if (null != errorCode) {
if (! "filteraway".equals(errorCode) ) { if (!"filteraway".equals(errorCode)) {
LOG.error("fatalError", arg0); LOG.error("fatalError", arg0);
} }
} } else {
else {
LOG.error("fatalError", arg0); LOG.error("fatalError", arg0);
} }
} } else {
else {
LOG.error("fatalError", arg0); LOG.error("fatalError", arg0);
} }
} }
......
...@@ -238,9 +238,9 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest { ...@@ -238,9 +238,9 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
getClass(). getClass().
getClassLoader(). getClassLoader().
getResourceAsStream("xslt/exeley-pam-2-xmlbundle.xslt"), StandardCharsets.UTF_8); getResourceAsStream("xslt/exeley-pam-2-xmlbundle.xslt"), StandardCharsets.UTF_8);
map.put("oai_dc", oaiDcXsltString); map.put("pam", oaiDcXsltString);
XsltTransformerOaiPmhBundlesStreamSource bss = new XsltTransformerOaiPmhBundlesStreamSource("http://www.exeley.com/oai/", map); XsltTransformerOaiPmhBundlesStreamSource bss = new XsltTransformerOaiPmhBundlesStreamSource("http://www.exeley.com/oai/OAIRequest", map);
Bundle bundle = bss.getBundle("oai:exeley.com:10.21307/joss-2018-001"); Bundle bundle = bss.getBundle("oai:exeley.com:10.21307/joss-2018-001");
...@@ -249,7 +249,7 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest { ...@@ -249,7 +249,7 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
metadata.stream().map(Object::toString).forEach(LOG::info); metadata.stream().map(Object::toString).forEach(LOG::info);
assertTrue( metadata.contains( new SimpleMetadatum("dc.type.stock", "article") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.type.stock", "article") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.type.document", "32") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.type.document", "32") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.source.journal", "1439") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.source.journal", "1632") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.description.pubstatus", "1") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.description.pubstatus", "1") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Krishna, M.") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Krishna, M.") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Bino Paul, G.D.") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.contributor.author", "Bino Paul, G.D.") ) );
...@@ -265,7 +265,7 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest { ...@@ -265,7 +265,7 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
assertTrue( metadata.contains( new SimpleMetadatum("dc.language", "en") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.language", "en") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issue", "1") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issue", "1") ) );
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issue") ).count() ); assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issue") ).count() );
assertTrue( metadata.contains( new SimpleMetadatum("dc.rights.licence", "16") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.rights.licence", "32") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issuetopic", "OBEN_UNTEN : Bilder vom Leben der Anderen") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("dc.source.issuetopic", "OBEN_UNTEN : Bilder vom Leben der Anderen") ) );
// assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issuetopic") ).count() ); // assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.source.issuetopic") ).count() );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.source.pageinfo", "3-6") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("dc.source.pageinfo", "3-6") ) );
...@@ -274,21 +274,21 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest { ...@@ -274,21 +274,21 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.title") ).count() ); assertEquals(1, metadata.stream().filter(m -> m.getKey().equals("dc.title") ).count() );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.urn", "urn:nbn:de:gbv:18-8-7560") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.urn", "urn:nbn:de:gbv:18-8-7560") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.doi", "https://doi.org/10.21307/joss-2018-001") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.identifier.doi", "https://doi.org/10.21307/joss-2018-001") ) );
assertTrue( metadata.contains( new SimpleMetadatum("internal.dda.reference", "http://www.exeley.com/oai/@@oai:exeley.com:10.21307/joss-2018-001") ) ); assertTrue( metadata.contains( new SimpleMetadatum("internal.dda.reference", "http://www.exeley.com/oai/OAIRequest@@oai:exeley.com:10.21307/joss-2018-001") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.publisher.country", "USA") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.publisher.country", "USA") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.classoz", "10900") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.classoz", "10900") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.classoz", "10900") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.classoz", "10900") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.ddc", "300") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("internal.identifier.ddc", "300") ) );
// assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.ddc", "300") ) ); // assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.ddc", "300") ) );
assertTrue( metadata.contains( new SimpleMetadatum("internal.status", "formal und inhaltlich fertig erschlossen") ) ); assertTrue( metadata.contains( new SimpleMetadatum("internal.status", "formal und inhaltlich fertig erschlossen") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.other", "Collaboration") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "Collaboration") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.other", "Structure") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "Structure") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.other", "Networks") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "Networks") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.other", "Degree") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "Degree") ) );
assertTrue( metadata.contains( new SimpleMetadatum("dc.source.other", "Indian economics") ) ); assertTrue( metadata.contains( new SimpleMetadatum("dc.subject.other", "en", "Indian economics") ) );
Set<InputStream> fileSet = bundle.getContents(); Set<InputStream> fileSet = bundle.getContents();
assertEquals( 1, fileSet.size()); assertEquals( 2, fileSet.size());
} }
@Test @Test
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
xmlns:zoai="http://git.gesis.org/dda/zoai" xmlns:zoai="http://git.gesis.org/dda/zoai"
> >
<xsl:output indent="yes"/> <xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/> <xsl:strip-space elements="*"/>
<!-- <xsl:message terminate="no">here is the tree at the current node <xsl:copy-of select="."/> </xsl:message> --> <!-- <xsl:message terminate="no">here is the tree at the current node <xsl:copy-of select="."/> </xsl:message> -->
<!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> --> <!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<xsl:element name="bundle"> <xsl:element name="bundle">
<xsl:element name="metadata"> <xsl:element name="metadata">
<xsl:variable name="ddaReference" select="concat(oai:OAI-PMH/oai:request[@verb='GetRecord']/text(), '@@', oai:OAI-PMH/oai:request[@verb='GetRecord']/@identifier)" /> <xsl:variable name="ddaReference" select="concat(oai:OAI-PMH/oai:request[@verb='GetRecord']/text(), '@@', oai:OAI-PMH/oai:request[@verb='GetRecord']/@identifier)" />
<xsl:variable name="setSpec" select="/oai:OAI-PMH/oai:GetRecord/oai:record/oai:header/oai:setSpec/text()"/>
<xsl:call-template name="new-metadatum"> <xsl:call-template name="new-metadatum">
<xsl:with-param name="key" select="'internal.dda.reference'"/> <xsl:with-param name="key" select="'internal.dda.reference'"/>
<xsl:with-param name="language" select="''"/> <xsl:with-param name="language" select="''"/>
...@@ -44,17 +45,62 @@ ...@@ -44,17 +45,62 @@
<xsl:with-param name="value" select="'32'"/> <xsl:with-param name="value" select="'32'"/>
</xsl:call-template> </xsl:call-template>
<xsl:choose>
<xsl:when test="$setSpec = 'journal_of_social_structure'">