Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  UBO-385 Tolerate surrounding mycoreobject when filtering mods
  Added OA Diamond (#447)
  UBO-378 Allow to choose data sources used for enrichment in list import (#446)
  UBO-372 layout fixes in import list (#441)
  UBO-383 Update to current pica2mods version 2.11 (#444)
  UBO-382 Allow to set preconfigured classification values during scopus import (#443)
  UBO-381 Added leading brace to role when role is interviewer (#442)
  UBO-380 Allow to disable generation of data-subtext attributes in myc… (#440)
  UBO-372 fixed missing jquery-ui
  UBO-372 Replace chosen with bootstrap-select
  UBO-373 Fixed NullPointerException, store realm attribute of user in MCRJob (#438)
  UBO-370 Do not discard already assign roles
  hotfix - set mycore parent version back to 53, 55 is for MyCoRe 2024.06
  UBO-369 Add link to destatis metadata to find all objects of a given destatis categid (#433)
  UBO-369 Support resolving of values of destatis category id's in response-facets.xsl (#432)
  UBO-367 FSU040THUL-5319 Set MCR.ContentTransformer.solr2csv.TransformerFactoryClass = net.sf.saxon.TransformerFactoryImpl, fixed XSLT-3 function invocations (#431)
  UBO-366 Updated i18n ubo.destatis to 'DESTATIS Fachsystematik'
  UBO-366 Removed obsolete index code for destatis by fachreferate (once needed by ThUniBib)
  UBO-366 Display destatis as metadata
  UBO-365 FSU040THUL-5159 Support "person_dgs" option in import-search.xed (#429)
  • Loading branch information
kkrebs committed Jan 21, 2025
2 parents 3001c65 + 4befe0d commit 746dc00
Show file tree
Hide file tree
Showing 37 changed files with 486 additions and 586 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<properties>
<MCR.AppName>ubo</MCR.AppName>
<axis1.version>1.4</axis1.version>
<bootstrap-select.version>1.13.18</bootstrap-select.version>
<bootstrap.version>4.4.1</bootstrap.version>
<chosen.version>1.8.7</chosen.version>
<font-awesome.version>5.13.0</font-awesome.version>
<jakarta.activation.version>2.0.1</jakarta.activation.version>
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
Expand All @@ -55,7 +55,7 @@
<jquery.version>3.5.1</jquery.version>
<mycore.version>2023.06.3-SNAPSHOT</mycore.version>
<node.version>v16.0.0</node.version>
<pica2mods.version>2.10</pica2mods.version>
<pica2mods.version>2.11</pica2mods.version>
<sortpom.sortDeps>scope,groupId,artifactId</sortpom.sortDeps>
<sortpom.sortFile>https://gist.githubusercontent.com/yagee-de/dfd3698c1b49173dbf251f74eb6a9297/raw/406460c088ff3cb6354e4ae6b40535e6f841607d/mycore_sort.xml</sortpom.sortFile>
<sortpom.sortProps>true</sortpom.sortProps>
Expand Down Expand Up @@ -362,6 +362,11 @@
<artifactId>bootstrap</artifactId>
<version>${bootstrap.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-select</artifactId>
<version>${bootstrap-select.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
Expand All @@ -382,11 +387,6 @@
<artifactId>jquery-ui</artifactId>
<version>${jquery.ui.version}</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>chosen-js</artifactId>
<version>${chosen.version}</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
Expand Down
12 changes: 6 additions & 6 deletions ubo-cli/src/main/setup/classifications/oa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<label xml:lang="de" text="OA Gold" />
<label xml:lang="en" text="OA Gold" />
<label xml:lang="x-color" text="#FFFF00" />
<category ID="platin">
<!-- OA Erstveröffentlichung ohne APCs -->
<label xml:lang="de" text="OA Platin" />
<label xml:lang="en" text="OA Platinum" />
<label xml:lang="x-color" text="#CECECE" />
</category>
<category ID="diamond">
<!-- OA Erstveröffentlichung ohne APCs -->
<label xml:lang="de" text="OA Diamond" />
<label xml:lang="en" text="OA Diamond" />
<label xml:lang="x-color" text="#CECECE" />
</category>
</category>
<category ID="hybrid">
<!-- Publikation ist in einer lizenzpflichtigen Zeitschrift erschienen, in der einzelne Artikel gegen Zahlung einer Publikationsgebühr Open Access erscheinen. -->
Expand Down
20 changes: 10 additions & 10 deletions ubo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@
<configuration>
<target>
<echo append="true" file="${project.build.directory}/classes/config/${artifactId}/mycore.properties"># generated by ubo-common/pom.xml
UBO.Frontend.jquery.version = ${jquery.version}
UBO.Frontend.jquery-ui.version = ${jquery.ui.version}
UBO.Frontend.chosen.version = ${chosen.version}
UBO.Frontend.bootstrap.version = ${bootstrap.version}
UBO.Frontend.font-awesome.version = ${font-awesome.version}</echo>
UBO.Frontend.jquery.version = ${jquery.version}
UBO.Frontend.jquery-ui.version = ${jquery.ui.version}
UBO.Frontend.bootstrap.version = ${bootstrap.version}
UBO.Frontend.bootstrap-select.version = ${bootstrap-select.version}
UBO.Frontend.font-awesome.version = ${font-awesome.version}</echo>
</target>
</configuration>
</execution>
Expand Down Expand Up @@ -372,6 +372,11 @@
<artifactId>bootstrap</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-select</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
Expand All @@ -392,11 +397,6 @@
<artifactId>jquery-ui</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>chosen-js</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ private void handleImportJob(HttpServletRequest req, HttpServletResponse res) th
if ("true".equals(doAsync)) {
MCRJob job = new MCRJob(ImportListJobAction.class);
job.setParameter(ImportListJobAction.EDITOR_SUBMISSION_PARAMETER, new XMLOutputter().outputString(doc));
job.setParameter(ImportListJobAction.USER_ID_PARAMETER, MCRUserManager.getCurrentUser().getUserName());
job.setParameter(ImportListJobAction.USER_ID_PARAMETER,
MCRUserManager.getCurrentUser().getUserName() + "@" + MCRUserManager.getCurrentUser().getRealmID());
MCRJobQueueManager.getInstance().getJobQueue(ImportListJobAction.class).offer(job);

String referer = req.getHeader("Referer");
Expand All @@ -73,7 +74,12 @@ private void handleImportJob(HttpServletRequest req, HttpServletResponse res) th

boolean enrich = "true".equals(formInput.getAttributeValue("enrich"));
if (enrich) {
importJob.enrich();
String enricherId = EnrichmentConfigMgr.getEnricherId(formInput);
if (enricherId != null) {
importJob.enrich(enricherId);
} else {
importJob.enrich();
}
}

String targetType = formInput.getAttributeValue("targetType");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.mycore.ubo.importer;

import org.jdom2.Element;
import org.mycore.common.config.MCRConfiguration2;

import java.util.Optional;

/**
* Class retrieves the enricher id from the form input of import-list.xed.
*
* @author shermann (Silvio Hermann)
*/
public class EnrichmentConfigMgr {
static final String DEFAULT_CONFIG_ID = "custom";

private EnrichmentConfigMgr() {
}

/**
* Retrieves the enricher id from the import list form element.
* If the value of the DataSource element is a valid enrichment config id that id is returned. Otherwise,
* it assumed a list of enrichment sources e.g. <em>GBV Unpaywall ...</em> is provided. In that case a new
* configuration with id <code>custom</code> is created and the returned id will be <code>custom</code>.
*
* @param formInput the form input (usually provided by import-list.xed)
*
* @return the enricher id or <code>null</code>
*/
public static String getEnricherId(Element formInput) {
Optional<Element> dataSource = formInput.getChildren("DataSources")
.stream()
.filter(element -> !element.getText().isEmpty())
.findFirst();

if (dataSource.isEmpty()) {
return null;
}

String dataSrcTxt = dataSource.get().getText();
if (MCRConfiguration2.getString("MCR.MODS.EnrichmentResolver.DataSources." + dataSrcTxt).isPresent()) {
return dataSrcTxt;
} else {
String property = "MCR.MODS.EnrichmentResolver.DataSources." + DEFAULT_CONFIG_ID;
MCRConfiguration2.set(property, dataSrcTxt);
return DEFAULT_CONFIG_ID;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ public void transform(MCRContent source) throws IOException, JDOMException, SAXE
}
}

public void enrich(String configId){
for (Document publication : publications) {
MCREnricher enricher = new MCREnricher(configId);
enricher.enrich(getContainedMODS(publication));
}
}

public void enrich() {
for (Document publication : publications) {
MCREnricher enricher = new MCREnricher(ENRICHER_CONFIG_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public void execute() throws ExecutionException {
job.setParameter(IMPORT_JOB_ID_PARAMETER, importJob.getID());

if ("true".equals(formInput.getAttributeValue("enrich"))) {
importJob.enrich();
String enricherId = EnrichmentConfigMgr.getEnricherId(formInput);
if (enricherId != null) {
importJob.enrich(enricherId);
} else {
importJob.enrich();
}
}

try {
Expand All @@ -79,6 +84,12 @@ public void execute() throws ExecutionException {
private void sendMail(ImportJob importJob) {
String userName = job.getParameter(ImportListJobAction.USER_ID_PARAMETER);
MCRUser mcrUser = MCRUserManager.getUser(userName);

if (mcrUser == null) {
LOGGER.error("User {} not found", userName);
return;
}

String eMailAddress = mcrUser.getEMailAddress();

if (eMailAddress == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -49,6 +56,8 @@ class ScopusImporter {

private static String MAIL_XSL;

private static XPathExpression<Element> MODS_XPATH = XPATH_FACTORY
.compile(".//mods:mods", Filters.element(), null, MODS_NAMESPACE);
private List<MCRObject> importedObjects = new ArrayList<>();

static {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -119,6 +129,28 @@ private MCRObject buildMCRObject(Element publicationXML) {
return obj;
}

private void setPreconfiguredClasses(Element publicationXML) {
List<String> 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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ private boolean containsLeadID(Element modsNameElement) {

private void handleUser(Element modsName, MCRUser user) {
connectModsNameElementWithMCRUser(modsName, user);
user.assignRole(defaultRoleForNewlyCreatedUsers);

MCRUser storedUser = MCRUserManager.getUser(user.getUserName() + "@" + user.getRealmID());
if (storedUser == null) {
user.assignRole(defaultRoleForNewlyCreatedUsers);
} else {
for (String role : storedUser.getSystemRoleIDs().stream().toList()) {
user.assignRole(role);
}
}

MCRUserManager.updateUser(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="card-body">
<xed:form xmlns:xed="http://www.mycore.de/xeditor" method="post" role="form">

<xed:source uri="cache:enrichmentConfig:custom" />
<xed:source uri="enrichmentConfig:custom" />

<xed:bind xpath="enrichmentDebugger">

Expand Down
Binary file not shown.
Loading

0 comments on commit 746dc00

Please sign in to comment.