From c069927d73b299749b6078d437c61c5fca025235 Mon Sep 17 00:00:00 2001 From: Sebastian Hofmann Date: Fri, 6 Sep 2024 14:42:34 +0200 Subject: [PATCH 1/7] MIR-1353-wrong command in docker migration function --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 01fad45107..f06a9517c8 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -96,7 +96,7 @@ function migrateJavaxPropertiesToJakarta() { echo "Migrate xmlns in persistence.xml from jcp.org to jakarta.ee" sed -ri "s/xmlns=\".+persistence\"/xmlns=\"https:\/\/jakarta.ee\/xml\/ns\/persistence\"/" "${PERSISTENCE_XML}" echo "Migrate schemaLocation in persistence.xml from jcp.org to jakarta.ee" - grep -ri "s/(xsi:schemaLocation=\").*jcp.org.*(\")/\1https:\/\/jakarta.ee\/xml\/ns\/persistence https:\/\/jakarta.ee\/xml\/ns\/persistence\/persistence_3_0.xsd\2/" "${PERSISTENCE_XML}" + sed -ri "s/(xsi:schemaLocation=\").*jcp.org.*(\")/\1https:\/\/jakarta.ee\/xml\/ns\/persistence https:\/\/jakarta.ee\/xml\/ns\/persistence\/persistence_3_0.xsd\2/" "${PERSISTENCE_XML}" fi if grep -q "version=\"2" "${PERSISTENCE_XML}"; then echo "Migrate version in persistence.xml from 2.* to 3.0" From 6b5d2fe4fc93f1a6d9639b0ac5637fdd102a770d Mon Sep 17 00:00:00 2001 From: Torsten Krause Date: Thu, 12 Sep 2024 09:24:03 +0200 Subject: [PATCH 2/7] MIR-1354 use count query insteand of select --- .../mir/migration/MIRMigrateStaticHistoryContent.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java index 21e382df6c..6dfb4379f9 100644 --- a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java +++ b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java @@ -51,16 +51,17 @@ public void startUp(ServletContext servletContext) { private boolean alreadyDone() { EntityManager manager = MCREntityManagerProvider.getCurrentEntityManager(); CriteriaBuilder builder = manager.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(MCRJob.class); + CriteriaQuery criteria = builder.createQuery(Long.class); Root root = criteria.from(MCRJob.class); - List predicates = new ArrayList(); + List predicates = new ArrayList<>(); predicates.add(builder.equal(root.get(MCRJob_.action), MIRMigrateStaticHistoryContentJobAction.class)); predicates.add(builder.equal(root.get(MCRJob_.status), MCRJobStatus.FINISHED)); + criteria.select(builder.count(root)); criteria.where(predicates.toArray(new Predicate[] {})); - List resultList = manager.createQuery(criteria).getResultList(); + Long result = manager.createQuery(criteria).getSingleResult(); - return resultList.size() > 0; + return result > 0; } } From e628ce6503703cb3d5119e28816db75be204238d Mon Sep 17 00:00:00 2001 From: Possommi Date: Thu, 19 Sep 2024 09:26:49 +0200 Subject: [PATCH 3/7] MIR-1355 Support arbitrary number of mods:abstract in tabs (#1065) * MIR-1355 Support arbitrary number of mods:abstract in tabs * MIR-1355 Support dynamic abstract tab title from classification by providing value for property MIR.Layout.Abstract.Type.Classification * MIR-1355 Sort abstracts by type (if any) * MIR-1355 Add comment to property MIR.Layout.Abstract.Type.Classification in mycore.properties * MIR-1355 Replaced uri resolver by mcrxsl:getDisplayName(...) --- .../resources/config/mir/mycore.properties | 3 ++ .../resources/xsl/metadata/mir-abstract.xsl | 38 +++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/mir-module/src/main/resources/config/mir/mycore.properties b/mir-module/src/main/resources/config/mir/mycore.properties index 999eb36f5d..0794d51110 100644 --- a/mir-module/src/main/resources/config/mir/mycore.properties +++ b/mir-module/src/main/resources/config/mir/mycore.properties @@ -759,6 +759,9 @@ MIR.Layout.Display.Div=mir-edit,mir-abstract-badges #MIR.Layout.Display.Panel.Icon.mir-admindata=fas fa-info-circle #MIR.Layout.Display.Panel.Icon.mir-citation=fas fa-quote-right +# Provide a classification for resolving the human-readable names of the abstract type +MIR.Layout.Abstract.Type.Classification= + MIR.NotFullAccessInfo.Genres= MIR.Viewer.DisableDerivateType=thumbnail ############################################################################## diff --git a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl index 2d874611e6..6f84d4bed0 100644 --- a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl +++ b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl @@ -12,7 +12,7 @@ - + @@ -217,12 +217,29 @@ - + + + + + + + + + + + +
+ + +
@@ -262,13 +280,11 @@ - - + tab-pane ellipsis ellipsis-text active - - + tab-pane ellipsis ellipsis-text active From 14a9645990b15aa1a359faf6fc514c2ce24866eb Mon Sep 17 00:00:00 2001 From: Silvio Hermann Date: Thu, 19 Sep 2024 12:56:21 +0200 Subject: [PATCH 4/7] MIR-1358 Check $first-abstract-in-current-lang-position > 0 since not() is not working as expected --- mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl index 6f84d4bed0..b452bc794d 100644 --- a/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl +++ b/mir-module/src/main/resources/xsl/metadata/mir-abstract.xsl @@ -257,7 +257,7 @@ active nav-link - + active nav-link @@ -284,7 +284,7 @@ tab-pane ellipsis ellipsis-text active - + tab-pane ellipsis ellipsis-text active From 70c9b4e38125b16938a46ce4921a8b557f687bd6 Mon Sep 17 00:00:00 2001 From: Torsten Krause Date: Wed, 4 Sep 2024 16:52:33 +0200 Subject: [PATCH 5/7] MIR-1351 consider case of a fresh repository w/o existing static data --- .../MIRMigrateStaticHistoryContent.java | 48 +++++++++---------- ...RMigrateStaticHistoryContentJobAction.java | 24 ++++------ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java index 6dfb4379f9..b96f7c4806 100644 --- a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java +++ b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java @@ -1,30 +1,34 @@ package org.mycore.mir.migration; -import jakarta.persistence.EntityManager; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Root; import jakarta.servlet.ServletContext; -import org.mycore.backend.jpa.MCREntityManagerProvider; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.mycore.common.config.MCRConfiguration2; import org.mycore.common.events.MCRStartupHandler.AutoExecutable; import org.mycore.services.queuedjob.MCRJob; import org.mycore.services.queuedjob.MCRJobQueue; import org.mycore.services.queuedjob.MCRJobQueueManager; import org.mycore.services.queuedjob.MCRJobStatus; -import org.mycore.services.queuedjob.MCRJob_; import org.mycore.util.concurrent.MCRTransactionableRunnable; -import java.util.ArrayList; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; import java.util.List; /** * Class creates {@link MCRJob} in {@link MCRJobQueue} that migrates all static history content. * * @author shermann (Silvio Hermann) - * */ + */ public class MIRMigrateStaticHistoryContent implements AutoExecutable { + private static final Logger LOGGER = LogManager.getLogger(); + + static final Path STATIC_HISTORY_PATH = Path.of( + MCRConfiguration2.getStringOrThrow("MCR.Object.Static.Content.Default.Path"), "mir-history"); + @Override public String getName() { return MIRMigrateStaticHistoryContent.class.getName(); @@ -38,7 +42,11 @@ public int getPriority() { @Override public void startUp(ServletContext servletContext) { MCRTransactionableRunnable runnable = new MCRTransactionableRunnable(() -> { - if (!alreadyDone()) { + if (Files.notExists(STATIC_HISTORY_PATH)) { + LOGGER.info("No static content exists, nothing to do."); + } else if (alreadyDone()) { + LOGGER.info("Static content migration already scheduled, nothing to do."); + } else if (!alreadyDone()) { MCRJobQueueManager .getInstance() .getJobQueue(MIRMigrateStaticHistoryContentJobAction.class) @@ -49,19 +57,11 @@ public void startUp(ServletContext servletContext) { } private boolean alreadyDone() { - EntityManager manager = MCREntityManagerProvider.getCurrentEntityManager(); - CriteriaBuilder builder = manager.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(Long.class); - Root root = criteria.from(MCRJob.class); - - List predicates = new ArrayList<>(); - predicates.add(builder.equal(root.get(MCRJob_.action), MIRMigrateStaticHistoryContentJobAction.class)); - predicates.add(builder.equal(root.get(MCRJob_.status), MCRJobStatus.FINISHED)); - - criteria.select(builder.count(root)); - criteria.where(predicates.toArray(new Predicate[] {})); - Long result = manager.createQuery(criteria).getSingleResult(); - - return result > 0; + return MCRJobQueueManager + .getInstance() + .getJobDAO() + .getJobCount(MIRMigrateStaticHistoryContentJobAction.class, Collections.emptyMap(), + List.of(MCRJobStatus.FINISHED)) > 0; } + } diff --git a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContentJobAction.java b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContentJobAction.java index a30c786de2..dcd6ad0123 100644 --- a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContentJobAction.java +++ b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContentJobAction.java @@ -1,17 +1,17 @@ package org.mycore.mir.migration; +import static org.mycore.mir.migration.MIRMigrateStaticHistoryContent.STATIC_HISTORY_PATH; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jdom2.Document; import org.jdom2.input.SAXBuilder; -import org.mycore.common.config.MCRConfiguration2; import org.mycore.datamodel.metadata.MCRMetadataManager; import org.mycore.datamodel.metadata.MCRObjectID; import org.mycore.services.queuedjob.MCRJob; import org.mycore.services.queuedjob.MCRJobAction; import org.mycore.services.queuedjob.staticcontent.MCRJobStaticContentGenerator; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.FileVisitResult; @@ -21,31 +21,27 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.concurrent.ExecutionException; + /** * Class converts all static history content on start up automatically. * * @author shermann (Silvio Hermann) * */ public class MIRMigrateStaticHistoryContentJobAction extends MCRJobAction { - private Path staticHistoryPath; - private Logger logger; + + private static final Logger LOGGER = LogManager.getLogger(); public MIRMigrateStaticHistoryContentJobAction(MCRJob job) { super(job); - logger = LogManager.getLogger(MIRMigrateStaticHistoryContentJobAction.class); - - staticHistoryPath = Path.of( - MCRConfiguration2.getStringOrThrow("MCR.Object.Static.Content.Default.Path") + File.separator - + "mir-history"); } @Override public void execute() throws ExecutionException { try { SAXBuilder builder = new SAXBuilder(); - Files.walkFileTree(staticHistoryPath, new SimpleFileVisitor() { + Files.walkFileTree(STATIC_HISTORY_PATH, new SimpleFileVisitor<>() { @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { String filename = file.getFileName().toString(); String id = filename.substring(0, filename.lastIndexOf('.')); @@ -56,19 +52,19 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO try (InputStream is = Files.newInputStream(file)) { Document history = builder.build(is); if ("table".equals(history.getRootElement().getName())) { - logger.info("Migrating static history for object {}", id); + LOGGER.info("Migrating static history for object {}", id); MCRJobStaticContentGenerator generator = new MCRJobStaticContentGenerator( "mir-history"); generator.generate(MCRMetadataManager.retrieveMCRObject(MCRObjectID.getInstance(id))); } } catch (Exception e) { - logger.error("Could not migrate static mcr-history for file {}", file.getFileName(), e); + LOGGER.error("Could not migrate static mcr-history for file {}", file.getFileName(), e); } return FileVisitResult.CONTINUE; } }); } catch (IOException e) { - logger.error("Error occurred during migration of static history content", e); + LOGGER.error("Error occurred during migration of static history content", e); } } From 2c9d4d2fa8257f8a4f2a7f87da01236b190c3a2a Mon Sep 17 00:00:00 2001 From: Possommi Date: Tue, 1 Oct 2024 14:53:12 +0200 Subject: [PATCH 6/7] MIR-1357 Dialog for selecting a related item is not localized and some UI components are broken (#1068) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MIR-1357 Added i18n button.select. Internationalize Select/Auswählen button * MIR-1357 Fixed concatenation of url parameters * MIR-1357 Made magnifier visible * MIR-1357 Avoid duplicate genre filter drop down * MIR-1357 fix invalid filter query if no id is given --------- Co-authored-by: Kathleen Neumann --- .../META-INF/resources/editor/editor-includes.xed | 4 +++- .../resources/js/mir/relatedItem-modal.js | 15 ++++++++++++--- .../resources/config/mir/messages_de.properties | 1 + .../resources/config/mir/messages_en.properties | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mir-module/src/main/resources/META-INF/resources/editor/editor-includes.xed b/mir-module/src/main/resources/META-INF/resources/editor/editor-includes.xed index e8d65c9bb9..4b6609ef4e 100644 --- a/mir-module/src/main/resources/META-INF/resources/editor/editor-includes.xed +++ b/mir-module/src/main/resources/META-INF/resources/editor/editor-includes.xed @@ -1935,7 +1935,9 @@
- +
diff --git a/mir-module/src/main/resources/META-INF/resources/js/mir/relatedItem-modal.js b/mir-module/src/main/resources/META-INF/resources/js/mir/relatedItem-modal.js index 893e2555c6..50fabf2553 100644 --- a/mir-module/src/main/resources/META-INF/resources/js/mir/relatedItem-modal.js +++ b/mir-module/src/main/resources/META-INF/resources/js/mir/relatedItem-modal.js @@ -76,6 +76,10 @@ $(document).ready(function() { var input = button.next().next("input"); var sortType = ""; let fq = button.data("fq"); + //if no id is given set fq empty + if(fq == "-id:") { + fq = ""; + } //load genre classification loadGenres(initContent); @@ -99,7 +103,7 @@ $(document).ready(function() { function initBody() { $("#modalFrame-title").text(button.val()); $("#modalFrame-cancel").text($("button[name='_xed_submit_cancel']").text()); - $("#modalFrame-send").text("Auswählen").attr("disabled", "").removeAttr("style"); + $("#modalFrame-send").attr("disabled", "").removeAttr("style"); // TODO: check if you can remove HTML from js code (e.g. by a js template) $("#modalFrame-body").append("
"); $("#modalFrame-body").append("
"); @@ -108,9 +112,14 @@ $(document).ready(function() { $("#main_right_content").css("padding-left", "10px"); //create pagination $("#modalFrame-body").append(""); - $(".already-linked").after("
"); + + if($(".type-select").length == 0) { + $(".already-linked").after("
"); + } + $("li a").css("cursor", "pointer"); $("#modal-searchInput").removeAttr("hidden"); + $("#modal-searchInput button span").removeAttr("style"); $("#modal-searchInput > input").attr("autocomplete", "off"); $("#modalFrame").modal("show"); } @@ -289,7 +298,7 @@ $(document).ready(function() { dataType = "xml"; break; case "select": - url = "servlets/solr/select?fq=" + fq + "q=" + qry + "&fq=objectType%3A\"mods\"&start=0&rows=10&XSL.Style=xml"; + url = "servlets/solr/select?fq=" + fq + "&q=" + qry + "&fq=objectType%3A\"mods\"&start=0&rows=10&XSL.Style=xml"; dataType = "xml"; break; case "receive": diff --git a/mir-module/src/main/resources/config/mir/messages_de.properties b/mir-module/src/main/resources/config/mir/messages_de.properties index 39e470603e..66b3b81b92 100644 --- a/mir-module/src/main/resources/config/mir/messages_de.properties +++ b/mir-module/src/main/resources/config/mir/messages_de.properties @@ -36,6 +36,7 @@ button.loading = Lade... button.save = Speichern button.saveandredirect = Speichern und hochladen... button.search = Suchen... +button.select = Ausw\u00E4hlen button.selectPerson = Person ausw\u00E4hlen component.mods.metaData.dictionary.identifier.hdl = Handle diff --git a/mir-module/src/main/resources/config/mir/messages_en.properties b/mir-module/src/main/resources/config/mir/messages_en.properties index 95dbe83e20..3e78c44add 100644 --- a/mir-module/src/main/resources/config/mir/messages_en.properties +++ b/mir-module/src/main/resources/config/mir/messages_en.properties @@ -33,6 +33,7 @@ button.loading = Loading... button.save = Save button.saveandredirect = Save and upload ... button.search = Search... +button.select = Select button.selectPerson = Select person component.mods.metaData.dictionary.identifier.hdl = Handle From afcb647fd0424d97bd51bdf1371a8c715a0fefff Mon Sep 17 00:00:00 2001 From: Silvio Hermann Date: Wed, 2 Oct 2024 13:01:19 +0200 Subject: [PATCH 7/7] MIR-1343 Load version history from static xml file (but really) --- .../src/main/resources/xsl/metadata/mir-admindata-box.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mir-module/src/main/resources/xsl/metadata/mir-admindata-box.xsl b/mir-module/src/main/resources/xsl/metadata/mir-admindata-box.xsl index 2602f8ec53..43fd7cf646 100644 --- a/mir-module/src/main/resources/xsl/metadata/mir-admindata-box.xsl +++ b/mir-module/src/main/resources/xsl/metadata/mir-admindata-box.xsl @@ -96,7 +96,7 @@ : - +