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" 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..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,18 +57,11 @@ public void startUp(ServletContext servletContext) { } private boolean alreadyDone() { - EntityManager manager = MCREntityManagerProvider.getCurrentEntityManager(); - CriteriaBuilder builder = manager.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(MCRJob.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.where(predicates.toArray(new Predicate[] {})); - List resultList = manager.createQuery(criteria).getResultList(); - - return resultList.size() > 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); } } 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 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..b452bc794d 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 @@ - + + + + + + + + + + + +