forked from kitodo/kitodo-production
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add relation between import configurations and clients (kitodo#6124)
* Add relation between import configurations and clients * Add special permission to assign import configurations to clients * Fix import order * Rename constant * Automatically assign new import configurations to the current client * Add test * Adjust tests * Omit unnecessary cast to 'Long'
- Loading branch information
Showing
26 changed files
with
329 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...in/resources/db/migration/V2_130__Add_relation_between_importconfiguration_and_client.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-- | ||
-- (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. | ||
-- | ||
|
||
-- | ||
-- Migration: Create relation between ImportConfigurations and Clients | ||
-- | ||
|
||
SET SQL_SAFE_UPDATES = 0; | ||
|
||
-- 1. create cross table | ||
CREATE TABLE IF NOT EXISTS client_x_importconfiguration ( | ||
client_id INT(11) NOT NULL, | ||
importconfiguration_id INT(11) NOT NULL, | ||
PRIMARY KEY ( client_id, importconfiguration_id ), | ||
KEY FK_client_x_importconfiguration_client_id (client_id), | ||
KEY FK_client_x_importconfiguration_importconfiguration_id (importconfiguration_id), | ||
CONSTRAINT FK_client_x_importconfiguration_client_id FOREIGN KEY (client_id) REFERENCES client(id), | ||
CONSTRAINT FK_client_x_importconfiguration_importconfiguration_id FOREIGN KEY (importconfiguration_id) REFERENCES importconfiguration(id) | ||
) DEFAULT CHARACTER SET = utf8mb4 | ||
COLLATE utf8mb4_unicode_ci; | ||
|
||
-- 2. initially map all clients to all import configurations to retain status quo | ||
INSERT INTO client_x_importconfiguration SELECT client.id, importconfiguration.id FROM client, importconfiguration; | ||
|
||
-- 3. add new special permission to allow users to map import configuration to clients | ||
INSERT IGNORE INTO authority (title) VALUES ('assignImportConfigurationToClient_globalAssignable'); | ||
|
||
SET SQL_SAFE_UPDATES = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../main/java/org/kitodo/production/forms/validators/ImportConfigurationClientValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* (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.validators; | ||
|
||
import java.util.ArrayList; | ||
|
||
import javax.faces.application.FacesMessage; | ||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.validator.FacesValidator; | ||
import javax.faces.validator.Validator; | ||
import javax.faces.validator.ValidatorException; | ||
|
||
import org.kitodo.constants.StringConstants; | ||
|
||
@FacesValidator("ImportConfigurationClientValidator") | ||
public class ImportConfigurationClientValidator implements Validator<ArrayList<?>> { | ||
|
||
@Override | ||
public void validate(FacesContext context, UIComponent component, ArrayList<?> clientList) | ||
throws ValidatorException { | ||
// only validate when saving | ||
if (!context.getExternalContext().getRequestParameterMap().containsKey(StringConstants.EDIT_FORM_SAVE)) { | ||
return; | ||
} | ||
if (clientList.isEmpty()) { | ||
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, | ||
"The import configuration must be assigned to at least one client", null)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.