diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java index 81232142..e66a574c 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/scopus/ScopusImporter.java @@ -8,6 +8,8 @@ import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.filter.ElementFilter; +import org.jdom2.filter.Filters; +import org.jdom2.xpath.XPathExpression; import org.mycore.access.MCRAccessException; import org.mycore.common.MCRConstants; import org.mycore.common.MCRException; @@ -16,9 +18,11 @@ import org.mycore.common.MCRSessionMgr; import org.mycore.common.config.MCRConfiguration2; import org.mycore.common.xml.MCRURIResolver; +import org.mycore.common.xml.MCRXMLFunctions; import org.mycore.datamodel.metadata.MCRMetadataManager; import org.mycore.datamodel.metadata.MCRObject; import org.mycore.datamodel.metadata.MCRObjectID; +import org.mycore.frontend.MCRFrontendUtil; import org.mycore.mods.MCRMODSWrapper; import org.mycore.solr.MCRSolrClientFactory; import org.mycore.solr.MCRSolrUtils; @@ -31,6 +35,9 @@ import java.util.List; import java.util.Locale; +import static org.mycore.common.MCRConstants.MODS_NAMESPACE; +import static org.mycore.common.MCRConstants.XPATH_FACTORY; + class ScopusImporter { private static final Logger LOGGER = LogManager.getLogger(); @@ -49,6 +56,8 @@ class ScopusImporter { private static String MAIL_XSL; + private static XPathExpression MODS_XPATH = XPATH_FACTORY + .compile(".//mods:mods", Filters.element(), null, MODS_NAMESPACE); private List importedObjects = new ArrayList<>(); static { @@ -57,7 +66,6 @@ class ScopusImporter { IMPORT_URI = MCRConfiguration2.getString(prefix + "ImportURI").get(); PROJECT_ID = MCRConfiguration2.getString(prefix + "ProjectID").get(); STATUS = MCRConfiguration2.getString(prefix + "Status").get(); - prefix += "Mail."; MAIL_TO = MCRConfiguration2.getString(prefix + "To").get(); MAIL_PARAM = MCRConfiguration2.getString(prefix + "Param").get(); @@ -110,6 +118,8 @@ private static boolean shouldIgnore(Element publication) { private final static SimpleDateFormat ID_BUILDER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT); private MCRObject buildMCRObject(Element publicationXML) { + setPreconfiguredClasses(publicationXML); + MCRObject obj = new MCRObject(new Document(publicationXML)); MCRMODSWrapper wrapper = new MCRMODSWrapper(obj); wrapper.setServiceFlag("status", STATUS); @@ -119,6 +129,28 @@ private MCRObject buildMCRObject(Element publicationXML) { return obj; } + private void setPreconfiguredClasses(Element publicationXML) { + List list = MCRConfiguration2.getString("UBO.Scopus.Importer.Default.Classifications") + .stream() + .flatMap(MCRConfiguration2::splitValue) + .toList(); + + list.forEach(classification -> { + String[] parts = classification.split(":"); + if (parts.length == 2 && MCRXMLFunctions.isCategoryID(parts[0], parts[1])) { + Element e = MODS_XPATH.evaluateFirst(publicationXML); + if (e != null) { + Element c = new Element("classification", MODS_NAMESPACE); + c.setAttribute("valueURI", + MCRFrontendUtil.getBaseURL() + "classifications/" + parts[0] + "#" + parts[1]); + c.setAttribute("authorityURI", + MCRFrontendUtil.getBaseURL() + "classifications/" + parts[0]); + e.addContent(c); + } + } + }); + } + private String getImportID() { return ID_BUILDER.format(new Date(MCRSessionMgr.getCurrentSession().getLoginTime())); } diff --git a/ubo-common/src/main/resources/config/ubo-common/mycore.properties b/ubo-common/src/main/resources/config/ubo-common/mycore.properties index 3a7186e5..48e107c9 100644 --- a/ubo-common/src/main/resources/config/ubo-common/mycore.properties +++ b/ubo-common/src/main/resources/config/ubo-common/mycore.properties @@ -686,6 +686,7 @@ UBO.Scopus.API.URL=https://api.elsevier.com/content/ UBO.Scopus.Importer.Field2QueryID=id_scopus UBO.Scopus.Importer.ImportURI.Scopus=%UBO.Scopus.API.URL%abstract/scopus_id/{0}?apikey=%UBO.Scopus.API.Key% UBO.Scopus.Importer.ImportURI=xslStyle:mods2mycoreobject:enrich:scopus-import:xslStyle:import/scopus2mods,import/genre2genre,%UBO.SupportedMODSFilterName%:ratelimit:ScopusWeek:ratelimit:ScopusSecond:%UBO.Scopus.Importer.ImportURI.Scopus% +UBO.Scopus.Importer.Default.Classifications= UBO.Scopus.Importer.ProjectID=%UBO.projectid.default% UBO.Scopus.Importer.Status=imported UBO.Scopus.Importer.Mail.To=%MCR.Mail.Address% diff --git a/ubo-common/src/main/resources/xsl/rss-import-e-mail.xsl b/ubo-common/src/main/resources/xsl/rss-import-e-mail.xsl index d8fbd645..5e23c7d0 100644 --- a/ubo-common/src/main/resources/xsl/rss-import-e-mail.xsl +++ b/ubo-common/src/main/resources/xsl/rss-import-e-mail.xsl @@ -1,4 +1,4 @@ - + @@ -29,12 +29,13 @@ + - + @@ -42,7 +43,7 @@ - Universitätsbibliographie: RSS Feed Import + Universitätsbibliographie: RSS Feed Import Liebe Kollegin, lieber Kollege, @@ -66,9 +67,9 @@ die folgenden -Mit freundlichen Grüßen +Mit freundlichen Grüßen -Ihre Universitätsbibliographie +Ihre Universitätsbibliographie