Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update catalog metadata #6233

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
abbc09d
Add function to re-import metadata from catalogs
solth Sep 19, 2024
e8da4d0
Improve styling of metadata update dialog
oliver-stoehr Sep 20, 2024
5c4bff3
Add help tooltip for metadata update dialog
oliver-stoehr Sep 20, 2024
3e2c0be
Set correct Domain when updating metadata
solth Sep 23, 2024
7a64552
Add missing JavaDoc
solth Sep 23, 2024
97b5f03
Add unit and integration tests for metadata re-import
solth Sep 24, 2024
608a79e
Add integration test for re-import of process metadata
solth Sep 24, 2024
efc4d09
Add dialog informing user about result of setting import configurations
solth Sep 30, 2024
25c886c
Add functional metadata 'groupDisplayLabel'
solth Oct 2, 2024
226c3c9
Update message files
solth Oct 2, 2024
df5326b
Display translated labels of metadata group elements in comparison table
solth Oct 7, 2024
5c930cf
Fix Checkstyle issue
solth Oct 7, 2024
370bec0
Rename method
solth Oct 7, 2024
befc46a
Rename SQL migration file
solth Oct 9, 2024
1e29135
Add titles to the arrow buttons in the metadata update dialog
solth Oct 15, 2024
e696f65
Update SQL statement and button cursor
solth Oct 22, 2024
e892d90
Incorporate 'minOccurs' and 'maxOccurs' rules into metadata update
solth Oct 22, 2024
c6e6149
Add tooltips to buttons and fix Checkstyle violations
solth Oct 22, 2024
5d50be6
Adjust test to new rules
solth Oct 22, 2024
0a2cbc2
Prevent tooltips from not disappearing when the update dialog is closed
solth Oct 23, 2024
a13f75f
Update Kitodo/src/main/resources/messages/messages_de.properties
solth Oct 28, 2024
c2fa69c
Update Kitodo/src/main/resources/messages/messages_en.properties
solth Oct 28, 2024
80b2fc0
Implement change requests
solth Oct 28, 2024
feb1db4
Fix metadata being unresponsive after update
solth Oct 28, 2024
9a2cf4a
Enable replacing empty metadata values in Kitodo with existing metada…
solth Oct 28, 2024
6b3fd50
Rename method
solth Oct 28, 2024
5f767d0
Update Kitodo/src/main/resources/messages/messages_en.properties
solth Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public enum FunctionalMetadata {
/**
* Document type metadata use for document classification during process import.
*/
DOC_TYPE("docType");
DOC_TYPE("docType"),

/**
* Metadata used as label for metadata groups to be displayed in various UI components.
*/
GROUP_DISPLAY_LABEL("groupDisplayLabel");

/**
* With the logger, text can be written to a log file or to the console.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.dataeditor.ruleset.xml;
package org.kitodo.api.dataeditor.rulesetmanagement;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,15 @@ StructuralElementViewInterface getStructuralElementView(String structuralElement
* @return number of added metadata items
*/
int updateMetadata(String division, Collection<Metadata> metadata, String acquisitionStage, Collection<Metadata> updateItems);

/**
* Return 'Reimport' value for metadata with provided key 'metadataKey'.
*
* @param metadataKey
* key of metadata for which 'Reimport' values is returned
* @param acquisitionStage
* current acquisition stage
* @return 'Reimport' value of metadata with given key
*/
Reimport getMetadataReimport(String metadataKey, String acquisitionStage);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public class StringConstants {
// patterns
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

// acquisition stages
public static final String EDIT = "edit";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.apache.commons.lang3.ArrayUtils;
import org.kitodo.api.Metadata;
import org.kitodo.dataeditor.ruleset.xml.Reimport;
import org.kitodo.api.dataeditor.rulesetmanagement.Reimport;

/**
* Determines the result of re-importing metadata for a single metadata key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.kitodo.api.dataeditor.rulesetmanagement.FunctionalDivision;
import org.kitodo.api.dataeditor.rulesetmanagement.FunctionalMetadata;
import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface;
import org.kitodo.api.dataeditor.rulesetmanagement.Reimport;
import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface;
import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface;
import org.kitodo.dataeditor.ruleset.xml.AcquisitionStage;
Expand Down Expand Up @@ -350,6 +351,12 @@ public int updateMetadata(String division, Collection<Metadata> currentMetadata,
return currentMetadata.size() - sizeBefore;
}

@Override
public Reimport getMetadataReimport(String metadataKey, String acquisitionStage) {
Settings settings = ruleset.getSettings(acquisitionStage);
return settings.getReimport(metadataKey);
}

private Collection<ReimportMetadata> createListOfMetadataToMerge(Collection<Metadata> currentMetadata,
Settings settings, Collection<MetadataViewInterface> allowedMetadata, Collection<Metadata> updateMetadata) {
HashMap<String, ReimportMetadata> unifying = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import org.kitodo.dataeditor.ruleset.xml.Reimport;
import org.kitodo.api.dataeditor.rulesetmanagement.Reimport;
import org.kitodo.dataeditor.ruleset.xml.Setting;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

import org.kitodo.api.dataeditor.rulesetmanagement.Reimport;

/**
* Display settings for the edit mask related to a specific key.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ public class Process extends BaseTemplateBean {
@Transient
private String baseType;

@ManyToOne
@JoinColumn(name = "import_configuration_id", foreignKey = @ForeignKey(name = "FK_process_import_configuration_id"))
private ImportConfiguration importConfiguration;

/**
* Constructor.
*/
Expand Down Expand Up @@ -673,4 +677,22 @@ public String getOcrdWorkflowId() {
public void setOcrdWorkflowId(String ocrdWorkflowId) {
this.ocrdWorkflowId = ocrdWorkflowId;
}

/**
* Get ImportConfiguration used to create this process.
*
* @return ImportConfiguration used to create this process. "null" if process was created manually.
*/
public ImportConfiguration getImportConfiguration() {
return importConfiguration;
}

/**
* Set ImportConfiguration used to create this process.
* @param importConfiguration ImportConfiguration used to create this process
*/
public void setImportConfiguration(ImportConfiguration importConfiguration) {
this.importConfiguration = importConfiguration;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--
-- (c) Kitodo. Key to digital objects e. V. <[email protected]>
--
-- This file is part of the Kitodo project.
--
-- It is licensed under GNU General Public License version 3 or later.
--
-- For the full copyright and license information, please read the
-- GPL3-License.txt file that was distributed with this source code.
--

SET SQL_SAFE_UPDATES = 0;

-- add column "import_configuration_id" to "process" table
ALTER TABLE process ADD import_configuration_id INT;

-- add new permissions to set import configuration for processes and for triggering re-import of catalog metadata
INSERT IGNORE INTO authority (title) VALUES ('setImportConfiguration_clientAssignable');
INSERT IGNORE INTO authority (title) VALUES ('reimportMetadata_clientAssignable');

SET SQL_SAFE_UPDATES = 1;
4 changes: 4 additions & 0 deletions Kitodo/rulesets/ruleset.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@
imported metadata entries from the data source can be updated later.

'title' This field is used as the title to form the author-title key.

'groupDisplayLabel' keys of this type are displayed in the metadata update dialog of the metadata
editor.
</xs:documentation>
</xs:annotation>
<xs:restriction>
Expand All @@ -481,6 +484,7 @@
<xs:enumeration value="higherlevelIdentifier"/>
<xs:enumeration value="processTitle"/>
<xs:enumeration value="recordIdentifier"/>
<xs:enumeration value="groupDisplayLabel"/>
<xs:enumeration value="title"/>
</xs:restriction>
</xs:simpleType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1126,4 +1126,22 @@ public boolean hasAuthorityToLinkToProcessesOfUnassignedProjects() {
public boolean hasAuthorityToMassImportProcesses() {
return securityAccessService.hasAuthorityToUseMassImport() && securityAccessService.hasAuthorityToAddProcess();
}

/**
* Check if the current user has the permission to set import configurations for processes.
*
* @return true if the current user has the permission to set import configurations for processes.
*/
public boolean hasAuthorityToSetImportConfiguration() {
return securityAccessService.hasAuthorityToSetImportConfiguration();
}

/**
* Check if the current user has the permission to re-import metadata in the metadata editor.
*
* @return true if the current user has the permission to re-import metadata in the metadata editor.
*/
public boolean hasAuthorityToReimportMetadata() {
return securityAccessService.hasAuthorityToReimportMetadata();
}
}
64 changes: 64 additions & 0 deletions Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.net.URI;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand All @@ -38,6 +39,7 @@
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;
import org.kitodo.data.database.beans.Docket;
import org.kitodo.data.database.beans.ImportConfiguration;
import org.kitodo.data.database.beans.Process;
import org.kitodo.data.database.beans.Project;
import org.kitodo.data.database.beans.Property;
Expand Down Expand Up @@ -100,6 +102,8 @@ public class ProcessForm extends TemplateBaseForm {
private static final String PROCESS_TABLE_VIEW_ID = "/pages/processes.xhtml";
private static final String PROCESS_TABLE_ID = "processesTabView:processesForm:processesTable";
private final Map<Integer, Boolean> assignedProcesses = new HashMap<>();
private String settingImportConfigurationResultMessage;
private boolean importConfigurationsSetSuccessfully = false;

@Inject
private CustomListColumnInitializer initializer;
Expand Down Expand Up @@ -769,6 +773,20 @@ public List<Ruleset> getRulesets() {
return ServiceManager.getRulesetService().getAllForSelectedClient();
}

/**
* Get list of all import configurations.
*
* @return list of all import configurations.
*/
public List<ImportConfiguration> getImportConfigurations() {
try {
return ServiceManager.getImportConfigurationService().getAll();
} catch (DAOException e) {
Helper.setErrorMessage(e);
return Collections.emptyList();
}
}

/**
* Get task statuses for select list.
*
Expand Down Expand Up @@ -1134,4 +1152,50 @@ public boolean processInAssignedProject(int processId) {
public boolean showLastComment() {
return ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.SHOW_LAST_COMMENT);
}

/**
* Display dialog to set import configuration for selected processes.
*/
public void setImportConfiguration() {
PrimeFaces.current().executeScript("PF('selectImportConfigurationDialog').show();");
}

/**
* Assign import configuration with given ID 'importConfigurationId' to all selected processes.
*
* @param importConfigurationId ID of import configuration to assign to selected processes
*/
public void startSettingImportConfigurations(int importConfigurationId) {
PrimeFaces.current().executeScript("PF('selectImportConfigurationDialog').hide();");
try {
String configName = ServiceManager.getProcessService().setImportConfigurationForMultipleProcesses(
getSelectedProcesses(), importConfigurationId);
settingImportConfigurationResultMessage = Helper.getTranslation("setImportConfigurationSuccessfulDescription",
configName, String.valueOf(selectedProcessesOrProcessDTOs.size()));
importConfigurationsSetSuccessfully = true;
} catch (DAOException e) {
settingImportConfigurationResultMessage = e.getLocalizedMessage();
importConfigurationsSetSuccessfully = false;
}
Ajax.update("importConfigurationsSelectedDialog");
PrimeFaces.current().executeScript("PF('importConfigurationsSelectedDialog').show();");
}

/**
* Get value of 'settingImportConfigurationResultMessage'.
*
* @return value of 'settingImportConfigurationResultMessage'
*/
public String getSettingImportConfigurationResultMessage() {
return settingImportConfigurationResultMessage;
}

/**
* Get value of 'importConfigurationsSetSuccessfully'.
*
* @return value of 'importConfigurationsSetSuccessfully'
*/
public boolean isImportConfigurationsSetSuccessfully() {
return importConfigurationsSetSuccessfully;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.production.forms;

import java.io.Serializable;
import java.util.List;

import javax.faces.view.ViewScoped;
import javax.inject.Named;

import org.kitodo.data.database.beans.ImportConfiguration;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;

@ViewScoped
@Named("SelectImportConfigurationDialogView")
public class SelectImportConfigurationDialogView implements Serializable {

private int selectedImportConfigurationId = 0;
private List<ImportConfiguration> importConfigurations;

/**
* Standard constructor.
*/
public SelectImportConfigurationDialogView() {
try {
importConfigurations = ServiceManager.getImportConfigurationService().getAll();
} catch (DAOException e) {
Helper.setErrorMessage(e.getMessage());
}
}

/**
* Get ID of selected import configuration.
*
* @return ID of selected import configuration
*/
public int getSelectedImportConfigurationId() {
return selectedImportConfigurationId;
}

/**
* Set ID of selected import configuration.
*
* @param selectedImportConfigurationId ID of selected import configuration
*/
public void setSelectedImportConfigurationId(int selectedImportConfigurationId) {
this.selectedImportConfigurationId = selectedImportConfigurationId;
}

/**
* Get list of available import configurations.
*
* @return list of available import configurations
*/
public List<ImportConfiguration> getImportConfigurations() {
return importConfigurations;
}

/**
* Set list of available import configurations.
*
* @param importConfigurations list of available import configurations
*/
public void setImportConfigurations(List<ImportConfiguration> importConfigurations) {
this.importConfigurations = importConfigurations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.api.MdSec;
import org.kitodo.api.Metadata;
import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface;
import org.kitodo.data.database.beans.ImportConfiguration;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.exceptions.InvalidMetadataValueException;
Expand Down Expand Up @@ -128,16 +128,18 @@ public List<ImportConfiguration> getImportConfigurations() {
* The linked list of TempProcess instances
*/
void extendsMetadataTableOfMetadataTab(LinkedList<TempProcess> processes)
throws InvalidMetadataValueException, NoSuchMetadataFieldException {
throws InvalidMetadataValueException, NoSuchMetadataFieldException, IOException {

int countOfAddedMetadata = 0;
if (!processes.isEmpty()) {
TempProcess process = processes.getFirst();
if (process.getMetadataNodes().getLength() > 0) {
if (createProcessForm.getProcessDataTab().getDocType()
.equals(process.getWorkpiece().getLogicalStructure().getType())) {
RulesetManagementInterface rulesetManagementInterface = ServiceManager.getRulesetService()
.openRuleset(process.getProcess().getRuleset());
Collection<Metadata> metadata = ProcessHelper
.convertMetadata(process.getMetadataNodes(), MdSec.DMD_SEC);
.convertMetadata(process.getMetadataNodes(), rulesetManagementInterface);
countOfAddedMetadata = createProcessForm.getProcessMetadata().getProcessDetails()
.addMetadataIfNotExists(metadata);
} else {
Expand Down
Loading
Loading