-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QUED-93 adjust citatation styles and adds export section to download … (
#38) * QUED-93 adjust citatation styles and adds export section to download source files * QUED-93 update content and add initial project DOI * QUED-93 update import command in README file * QUED-93 update to current content version * fixed typo * add download files given from dhi * fixed typo No. -> no. * QUED-93 update data and fix build - switch to newest mycore-lts - use ubuntu jammy to get newer sed version - update cms data from testserver - allow internal nuxt links with cms * QUED-93 prepare DOI generation * QUED-93 added last missing text --------- Co-authored-by: Kathleen Neumann <[email protected]> Co-authored-by: Sebastian Hofmann <[email protected]>
- Loading branch information
1 parent
3e19d78
commit cf6dc21
Showing
32 changed files
with
8,403 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ackend/edition-archive-backend-module/src/main/java/de/gbv/metadata/pi/GPODOIService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.gbv.metadata.pi; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.mycore.datamodel.metadata.MCRBase; | ||
import org.mycore.datamodel.metadata.MCRObject; | ||
import org.mycore.pi.doi.MCRDOIService; | ||
|
||
import de.gbv.metadata.MetaJSONHelper; | ||
import de.gbv.metadata.model.Regest; | ||
|
||
public class GPODOIService extends MCRDOIService { | ||
|
||
@Override | ||
public URI getRegisteredURI(MCRBase base) throws URISyntaxException { | ||
String registerURL = getRegisterURL(); | ||
if (!(base instanceof MCRObject obj)) { | ||
throw new IllegalArgumentException("Only MCRObjects are supported"); | ||
} | ||
|
||
Regest regest = MetaJSONHelper.getMetaJsonObject(obj, "regest"); | ||
String idno = regest.getIdno(); | ||
|
||
return new URI(registerURL + idno); | ||
} | ||
|
||
} |
85 changes: 85 additions & 0 deletions
85
...ition-archive-backend-module/src/main/java/de/gbv/metadata/pi/GPODataciteTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package de.gbv.metadata.pi; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
import org.jdom2.Document; | ||
import org.jdom2.Element; | ||
import org.jdom2.JDOMException; | ||
import org.jdom2.Namespace; | ||
import org.jdom2.Text; | ||
import org.jdom2.filter.Filters; | ||
import org.jdom2.input.SAXBuilder; | ||
import org.jdom2.xpath.XPathExpression; | ||
import org.jdom2.xpath.XPathFactory; | ||
import org.mycore.common.MCRClassTools; | ||
import org.mycore.common.MCRConstants; | ||
import org.mycore.common.MCRException; | ||
import org.mycore.common.content.MCRContent; | ||
import org.mycore.common.content.MCRJDOMContent; | ||
import org.mycore.common.content.transformer.MCRContentTransformer; | ||
import org.mycore.datamodel.metadata.MCRObject; | ||
import org.mycore.datamodel.metadata.MetaJSON; | ||
import org.xml.sax.SAXException; | ||
|
||
import de.gbv.metadata.MetaJSONHelper; | ||
import de.gbv.metadata.model.Regest; | ||
|
||
public class GPODataciteTransformer extends MCRContentTransformer { | ||
private static Regest loadRegest(MCRContent mcrContent) throws IOException { | ||
MCRObject object; | ||
|
||
try { | ||
Document xml = mcrContent.asXML(); | ||
object = new MCRObject(xml); | ||
} catch (JDOMException | SAXException e) { | ||
throw new MCRException(e); | ||
} | ||
|
||
Regest regest = MetaJSONHelper.getMetaJsonObject(object, "regest"); | ||
return regest; | ||
} | ||
|
||
private static Document loadTemplate() { | ||
try (InputStream templateStream | ||
= MCRClassTools.getClassLoader().getResourceAsStream("reims-gpo-doi-template.xml")) { | ||
SAXBuilder saxBuilder = new SAXBuilder(); | ||
return saxBuilder.build(templateStream); | ||
} catch (IOException | JDOMException e) { | ||
throw new MCRException("Could not load template", e); | ||
} | ||
} | ||
|
||
@Override | ||
public MCRContent transform(MCRContent mcrContent) throws IOException { | ||
Regest regestObject = loadRegest(mcrContent); | ||
Document template = loadTemplate(); | ||
|
||
|
||
getXpathSingleElement(template, "/datacite:resource/datacite:identifier").setText(regestObject.getDoi()); | ||
getXpathElements(template.getRootElement(), ".//datacite:nrReplace").forEach(e-> { | ||
int i = e.getParent().indexOf(e); | ||
e.getParent().addContent(i, new Text(regestObject.getIdno())); | ||
e.detach(); | ||
}); | ||
|
||
return new MCRJDOMContent(template); | ||
} | ||
|
||
public Element getXpathSingleElement(Document element, String xpath) { | ||
XPathExpression<Element> expr | ||
= XPathFactory.instance().compile(xpath, Filters.element(), null, MCRConstants.XLINK_NAMESPACE, | ||
Namespace.getNamespace("datacite", "http://datacite.org/schema/kernel-4")); | ||
|
||
return expr.evaluateFirst(element); | ||
} | ||
|
||
public List<Element> getXpathElements(Element element, String xpath) { | ||
XPathExpression<Element> expr | ||
= XPathFactory.instance().compile(xpath, Filters.element(), null, MCRConstants.XLINK_NAMESPACE, | ||
Namespace.getNamespace("datacite", "http://datacite.org/schema/kernel-4")); | ||
|
||
return expr.evaluate(element); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...d/edition-archive-backend-module/src/main/java/de/gbv/metadata/pi/GPOMetadataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package de.gbv.metadata.pi; | ||
|
||
import java.util.Optional; | ||
|
||
import org.mycore.datamodel.metadata.MCRBase; | ||
import org.mycore.datamodel.metadata.MCRObject; | ||
import org.mycore.datamodel.metadata.MetaJSON; | ||
import org.mycore.pi.MCRPIMetadataService; | ||
import org.mycore.pi.MCRPersistentIdentifier; | ||
import org.mycore.pi.doi.MCRDOIParser; | ||
import org.mycore.pi.doi.MCRDigitalObjectIdentifier; | ||
import org.mycore.pi.exceptions.MCRPersistentIdentifierException; | ||
|
||
import de.gbv.metadata.MetaJSONHelper; | ||
import de.gbv.metadata.model.Regest; | ||
|
||
public class GPOMetadataService extends MCRPIMetadataService<MCRDigitalObjectIdentifier> { | ||
|
||
@Override | ||
public void insertIdentifier(MCRDigitalObjectIdentifier doi, MCRBase mcrBase, String additional) | ||
throws MCRPersistentIdentifierException { | ||
if (!(mcrBase instanceof MCRObject mcrObject)) { | ||
throw new MCRPersistentIdentifierException("Only MCRObjects are supported"); | ||
} | ||
Regest regest = MetaJSONHelper.getMetaJsonObject(mcrObject, "regest"); | ||
regest.setDoi(doi.asString()); | ||
MetaJSONHelper.setMetaJsonObject(mcrObject, "regest", regest); | ||
} | ||
|
||
@Override | ||
public void removeIdentifier(MCRDigitalObjectIdentifier doi, MCRBase mcrBase, String additional) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Optional<MCRPersistentIdentifier> getIdentifier(MCRBase mcrBase, String additional) | ||
throws MCRPersistentIdentifierException { | ||
if (!(mcrBase instanceof MCRObject mcrObject)) { | ||
throw new MCRPersistentIdentifierException("Only MCRObjects are supported"); | ||
} | ||
Regest regest = MetaJSONHelper.getMetaJsonObject(mcrObject, "regest"); | ||
String doi = regest.getDoi(); | ||
MCRDOIParser parser = new MCRDOIParser(); | ||
return parser.parse(doi).map(MCRDigitalObjectIdentifier.class::cast); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.