From 833d6f1af448e0b8b0ed6c58bd58efb4a5096179 Mon Sep 17 00:00:00 2001 From: Ikram Maalej Date: Sun, 23 Jan 2022 16:18:21 +0100 Subject: [PATCH 1/6] Improve newspaper creation --- .../converter/ProcessDetailConverter.java | 44 ++++ .../kitodo/production/forms/CalendarForm.java | 15 +- .../model/bibliography/course/Course.java | 3 +- .../bibliography/course/IndividualIssue.java | 33 ++- .../course/metadata/CountableMetadata.java | 44 +++- .../services/calendar/CalendarService.java | 29 ++- .../webapp/WEB-INF/resources/css/kitodo.css | 19 +- .../calendarEdit/calendarBlocks.xhtml | 128 ++++++----- .../calendarEdit/calendarDayDialog.xhtml | 208 ++++++++++++------ .../calendarEdit/calendarDetails.xhtml | 17 +- .../createProcessesConfirmDialog.xhtml | 1 - 11 files changed, 398 insertions(+), 143 deletions(-) create mode 100644 Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java diff --git a/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java b/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java new file mode 100644 index 00000000000..4d2410aed91 --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java @@ -0,0 +1,44 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * 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.converter; + +import java.util.List; +import java.util.Optional; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.inject.Named; + +import org.kitodo.production.forms.createprocess.ProcessDetail; +import org.kitodo.production.forms.createprocess.ProcessFieldedMetadata; + +@Named +public class ProcessDetailConverter implements Converter { + + @Override + public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException { + List list = (List) component.getAttributes().get("allMetadataTypes"); + Optional processDetail = list.parallelStream() + .filter(metadata -> metadata.getMetadataID().equals(value)).findFirst(); + return processDetail.orElseGet(ProcessFieldedMetadata::new); + } + + @Override + public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { + if (value instanceof ProcessDetail) { + return ((ProcessDetail) value).getMetadataID(); + } + return ""; + } +} diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index fd69530ca87..c28dd5493f3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -41,12 +41,13 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.production.forms.createprocess.ProcessDetail; +import org.kitodo.production.forms.createprocess.ProcessTextMetadata; import org.kitodo.production.helper.Helper; import org.kitodo.production.helper.XMLUtils; import org.kitodo.production.helper.tasks.GeneratesNewspaperProcessesThread; @@ -110,7 +111,7 @@ public class CalendarForm implements Serializable { private UploadedFile uploadedFile; private LocalDate selectedDate; private Block selectedBlock = null; - private List metadataTypes = null; + private List metadataTypes = null; /** * The field course holds the course of appearance currently under edit by @@ -745,7 +746,7 @@ public void addMetadata(Issue issue) { if (!selectedBlock.getIssues().isEmpty() && Objects.nonNull(selectedIssue)) { CountableMetadata metadata = new CountableMetadata(selectedBlock, Pair.of(selectedIssue.getDate(), selectedIssue.getIssue())); if (!getAllMetadataTypes().isEmpty()) { - metadata.setMetadataType(getAllMetadataTypes().get(0).getLabel()); + metadata.setMetadataDetail(getAllMetadataTypes().get(0)); } selectedBlock.addMetadata(metadata); } else { @@ -818,11 +819,11 @@ public List getIndividualIssues(Block block) { * * @return the map of metadata types */ - public List getAllMetadataTypes() { + public List getAllMetadataTypes() { if (Objects.isNull(metadataTypes)) { try { Process process = ServiceManager.getProcessService().getById(parentId); - metadataTypes = CalendarService.getAddableMetadata(process); + metadataTypes = CalendarService.getAddableMetadataTable(process); } catch (DAOException | DataException | IOException e) { Helper.setErrorMessage("Unable to load metadata types: " + e.getMessage()); } @@ -863,8 +864,8 @@ public void setLastIssue(CountableMetadata metadata, LocalDate date, Issue issue * @param issue the issue to calculate the metadata for * @return the metadata value as java.lang.String */ - public String getMetadataValue(CountableMetadata metadata, LocalDate date, Issue issue) { - if (Objects.nonNull(metadata)) { + public String getTextMetadataValue(CountableMetadata metadata, LocalDate date, Issue issue) { + if (Objects.nonNull(metadata) && metadata.getMetadataDetail() instanceof ProcessTextMetadata) { return metadata.getValue(new ImmutablePair<>(date, issue), course.getYearStart()); } return ""; diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Course.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Course.java index 15b2d4109d2..23aa2b34f6a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Course.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Course.java @@ -37,6 +37,7 @@ import org.kitodo.production.helper.XMLUtils; import org.kitodo.production.model.bibliography.course.metadata.CountableMetadata; import org.kitodo.production.model.bibliography.course.metadata.RecoveredMetadata; +import org.kitodo.production.services.data.ImportService; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -875,7 +876,7 @@ private void addMetadataToIssue(Document xml, IndividualIssue issue, Element iss if (metaDatum.matches(metaDatum.getMetadataType(), issueId, false)) { metadataNode.setAttribute(ATTRIBUTE_VALUE, ""); } else { - metadataNode.setAttribute(ATTRIBUTE_VALUE, metaDatum.getStartValue()); + metadataNode.setAttribute(ATTRIBUTE_VALUE, ImportService.getProcessDetailValue(metaDatum.getMetadataDetail())); if (metaDatum.getStepSize() != null) { metadataNode.setAttribute(ATTRIBUTE_INCREMENT, metaDatum.getStepSize().toString().toLowerCase()); } diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java index 27572109e00..f8455eceb43 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java @@ -16,13 +16,19 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.WeekFields; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.kitodo.api.Metadata; import org.kitodo.api.MetadataEntry; +import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.UnreachableCodeException; import org.kitodo.production.model.bibliography.course.metadata.CountableMetadata; @@ -32,6 +38,8 @@ * type of issue. */ public class IndividualIssue { + private static final Logger logger = LogManager.getLogger(IndividualIssue.class); + /** * The constant DAY holds a DateTimeFormatter used to get the a two-digit * day (01—31) from the newspaper’s date. @@ -229,7 +237,7 @@ public Map getGenericFields() { * @return a list of pairs, each consisting of the metadata type name and * the value */ - public Iterable getMetadata(int monthOfYear, int dayOfMonth) { + public Iterable getMetadata(int monthOfYear, int dayOfMonth) { return getMetadata(MonthDay.of(monthOfYear, dayOfMonth)); } @@ -242,15 +250,24 @@ public Iterable getMetadata(int monthOfYear, int dayOfMonth) { * @return a list of pairs, each consisting of the metadata type name and * the value */ - public Iterable getMetadata(MonthDay yearStart) { - List result = new ArrayList<>(); + public Iterable getMetadata(MonthDay yearStart) { + List result = new ArrayList<>(); Pair selectedIssue = Pair.of(date, issue); for (CountableMetadata counter : block.getMetadata(selectedIssue, null)) { - String value = counter.getValue(selectedIssue, yearStart); - MetadataEntry entry = new MetadataEntry(); - entry.setKey(counter.getMetadataType()); - entry.setValue(value); - result.add(entry); + Collection metadata = Collections.emptyList(); + try { + metadata = counter.getMetadataDetail().getMetadata(); + } catch (InvalidMetadataValueException e) { + logger.error(e.getLocalizedMessage()); + } + if (counter.getMetadataDetail().getInput().equals("inputText") + || counter.getMetadataDetail().getInput().equals("inputTextarea")) { + String value = counter.getValue(selectedIssue, yearStart); + if (metadata.stream().findFirst().get() instanceof MetadataEntry) { + ((MetadataEntry) metadata.stream().findFirst().get()).setValue(value); + } + } + result.addAll(metadata); } return result; } diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java index be60f7cc9c2..335a0c6da0c 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java @@ -17,6 +17,12 @@ import java.util.Objects; import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.kitodo.api.Metadata; +import org.kitodo.exceptions.InvalidMetadataValueException; +import org.kitodo.production.forms.createprocess.ProcessDetail; +import org.kitodo.production.forms.createprocess.ProcessTextMetadata; import org.kitodo.production.helper.metadata.pagination.Paginator; import org.kitodo.production.model.bibliography.course.Block; import org.kitodo.production.model.bibliography.course.Granularity; @@ -28,6 +34,8 @@ * Generic metadata that is created using a counter. */ public class CountableMetadata { + private static final Logger logger = LogManager.getLogger(CountableMetadata.class); + /** * Block this metadata counter belongs to. The block is needed to have * access to the other issues, which—together with the start value and step @@ -62,6 +70,8 @@ public class CountableMetadata { */ private Granularity stepSize; + private ProcessDetail metadataDetail; + /** * Creates a new countable metadata. * @@ -259,9 +269,29 @@ public void setStepSize(Granularity stepSize) { * the start value to set */ public void setStartValue(String startValue) { + ((ProcessTextMetadata)metadataDetail).setValue(startValue); this.startValue = startValue; } + /** + * Gets metadataDetail. + * + * @return value of metadataDetail + */ + public ProcessDetail getMetadataDetail() { + return metadataDetail; + } + + /** + * Sets metadataDetail. + * + * @param metadataDetail value of metadataDetail + */ + public void setMetadataDetail(ProcessDetail metadataDetail) { + this.metadataDetail = metadataDetail; + this.metadataType = this.metadataDetail.getLabel(); + } + /** * Returns a human-readable concise description of this countable metadata. * @@ -270,7 +300,13 @@ public void setStartValue(String startValue) { @Override public String toString() { StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(startValue); + try { + for (Metadata metadata : metadataDetail.getMetadata()) { + stringBuilder.append(metadata); + } + } catch (InvalidMetadataValueException e) { + logger.error(e.getMessage()); + } stringBuilder.append(" from "); stringBuilder.append(DateTimeFormatter.ISO_DATE.format(create.getLeft())); stringBuilder.append(", "); @@ -283,8 +319,10 @@ public String toString() { stringBuilder.append(", "); stringBuilder.append(delete.getRight().getHeading()); } - stringBuilder.append(", step size "); - stringBuilder.append(stepSize); + if (Objects.nonNull(stepSize)) { + stringBuilder.append(", step size "); + stringBuilder.append(stepSize); + } return stringBuilder.toString(); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java b/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java index c44f06ddea7..089cfc714e7 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java @@ -28,13 +28,17 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.kitodo.api.dataeditor.rulesetmanagement.ComplexMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.RulesetManagementInterface; +import org.kitodo.api.dataeditor.rulesetmanagement.SimpleMetadataViewInterface; import org.kitodo.api.dataeditor.rulesetmanagement.StructuralElementViewInterface; import org.kitodo.config.ConfigCore; import org.kitodo.config.enums.ParameterCore; import org.kitodo.data.database.beans.Process; import org.kitodo.data.exceptions.DataException; +import org.kitodo.production.forms.createprocess.ProcessDetail; +import org.kitodo.production.forms.createprocess.ProcessFieldedMetadata; import org.kitodo.production.model.bibliography.course.Block; import org.kitodo.production.model.bibliography.course.IndividualIssue; import org.kitodo.production.model.bibliography.course.Issue; @@ -117,8 +121,8 @@ public static List getAddableMetadata(Process completeEdi * @param metadataKey the key for the metadata type to be translated * @return localized metadata type as java.lang.String */ - public static String getMetadataTranslation(List metadataList, String metadataKey) { - for (MetadataViewInterface selectItem : metadataList) { + public static String getMetadataTranslation(List metadataList, String metadataKey) { + for (ProcessDetail selectItem : metadataList) { if (selectItem.getLabel().equals(metadataKey)) { return selectItem.getLabel(); } @@ -191,4 +195,25 @@ public static String dateIssueToString(Pair dateIssue) { } return stringBuilder.toString(); } + + /** + * Get all metadata allowed for the future elements that will be generated + * by the NewspaperProcessesGenerator. + * + * @param completeEdition parent process + * @return list of allowed metadata as List of ProcessDetail + * @throws IOException when ruleset file could not be read + */ + public static List getAddableMetadataTable(Process completeEdition) throws IOException, DataException { + ProcessFieldedMetadata table = new ProcessFieldedMetadata(); + List metadataViewInterfaceList = getAddableMetadata(completeEdition); + for (MetadataViewInterface keyView : metadataViewInterfaceList) { + if (keyView.isComplex()) { + table.createMetadataGroupPanel((ComplexMetadataViewInterface) keyView, Collections.emptyList()); + } else { + table.createMetadataEntryEdit((SimpleMetadataViewInterface) keyView, Collections.emptyList()); + } + } + return table.getRows(); + } } diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index d1f4a4ec1a7..daaee8bbc89 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -1648,14 +1648,24 @@ h3#headerText.calendar-heading { #calendarDayDialog .metadata-first-appearance, -#calendarDayDialog .metadata-last-appearance, -#calendarDayDialog .metadata-value { +#calendarDayDialog .metadata-last-appearance { display: inline-block; font-weight: bold; margin: var(--default-half-size); } +#calendarDayDialog .metadata-value { + font-weight: bold; + margin: var(--default-half-size); + vertical-align: top; +} + +#calendarDayDialog .ui-inputtextarea{ + height: 50px; +} + #calendarDayDialog .metadata-value-label { + vertical-align: top; margin-left: var(--default-half-size); } @@ -1667,6 +1677,11 @@ h3#headerText.calendar-heading { margin-bottom: var(--default-full-size); } +#calendarDayDialog .ui-selectlistbox-item { + width: 100%; + display: inline-flex; +} + /*---------------------------------------------------------------------- Metadata Editor ----------------------------------------------------------------------*/ diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml index ab126d3a27d..7070574a790 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml @@ -15,63 +15,90 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:h="http://xmlns.jcp.org/jsf/html"> + + + function hide(element) { + $('.p-datepicker-panel').hide(); + $(element).blur(); + } + + function hideAndFocusNextInput(element) { + hide(element); + var inputs = $('.ui-inputfield'); + var nextInput = inputs.get(inputs.index(document.activeElement) + 1); + if (nextInput) { + nextInput.focus(); + } + } + - + -
- - - - - -
-
- - - - - -
- + + + + + +
+ + + + + + +
+ +
+ +
+ style="padding-left: 10px;padding-right: 10px;" + value="#{block.issues}" rendered="#{block.issues.size() ne 0}"> - - +
+
+
@@ -182,7 +208,11 @@ title="#{msgs['calendar.block.remove']}" styleClass="remove-block" style="display: inline-block" - update="editForm:calendarTabView:calendarDetailsLayout"/> + update="editForm:calendarTabView:calendarDetailsLayout"> + + - +
- + + +
+ @@ -60,54 +77,119 @@ - - - - - - - - - - - - - - - - - - - - +
+ + + + + + +
+ + +
+ + + + + + + + + + + + +
+ +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update="calendarDayForm"/> + update="calendarDayForm"/>
- -
@@ -150,7 +219,8 @@ + + $(document).ready(function(){ + $(document).on("keypress", "#editForm\\:calendarTabView\\:yearInput", function(event) { + if(event.key == 'Enter') { + event.preventDefault(); + event.target.blur(); + document.activeElement = event.currentTarget; + } + }); + }); + + @@ -28,11 +40,14 @@ icon="fa fa-arrow-left" update="editForm:calendarTabView:calendarDetailsLayout"/> - + Date: Tue, 25 Jan 2022 12:34:48 +0100 Subject: [PATCH 2/6] Code improvement --- .../converter/ProcessDetailConverter.java | 10 +++---- .../kitodo/production/forms/CalendarForm.java | 16 ++++++++++ .../model/bibliography/course/Block.java | 19 ++++++++++++ .../bibliography/course/IndividualIssue.java | 3 +- .../course/metadata/CountableMetadata.java | 2 +- .../webapp/WEB-INF/resources/css/kitodo.css | 5 ++++ .../calendarEdit/calendarBlocks.xhtml | 30 +++++++++++++------ .../calendarEdit/calendarDayDialog.xhtml | 2 +- .../calendarEdit/calendarDetails.xhtml | 7 +++++ .../src/main/webapp/pages/calendarEdit.xhtml | 2 +- 10 files changed, 78 insertions(+), 18 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java b/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java index 4d2410aed91..0b08a61123d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java +++ b/Kitodo/src/main/java/org/kitodo/production/converter/ProcessDetailConverter.java @@ -24,10 +24,10 @@ import org.kitodo.production.forms.createprocess.ProcessFieldedMetadata; @Named -public class ProcessDetailConverter implements Converter { +public class ProcessDetailConverter implements Converter { @Override - public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException { + public ProcessDetail getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException { List list = (List) component.getAttributes().get("allMetadataTypes"); Optional processDetail = list.parallelStream() .filter(metadata -> metadata.getMetadataID().equals(value)).findFirst(); @@ -35,9 +35,9 @@ public Object getAsObject(FacesContext context, UIComponent component, String va } @Override - public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException { - if (value instanceof ProcessDetail) { - return ((ProcessDetail) value).getMetadataID(); + public String getAsString(FacesContext context, UIComponent component, ProcessDetail value) throws ConverterException { + if (value != null) { + return value.getMetadataID(); } return ""; } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index c28dd5493f3..eb9fefdc444 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -139,6 +139,7 @@ public class CalendarForm implements Serializable { public CalendarForm() { issueColours = ConfigCore.getParameterOrDefaultValue(ParameterCore.ISSUE_COLOURS).split(";"); course = new Course(); + } /** @@ -896,4 +897,19 @@ public String getMetadataTranslation(String key) { return key; } } + + /** + * Check if course has issues with same name. + */ + public void checkDuplicatesIssues() { + boolean check = false; + for (Block block : course) { + if (block.checkIssuesWithSameHeading()) { + check = true; + } + } + if (!check) { + PrimeFaces.current().executeScript("PF('createProcessesConfirmDialog').show();"); + } + } } diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java index 87e481781f2..31e220aec3f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java @@ -20,6 +20,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; import org.kitodo.production.helper.Helper; @@ -453,6 +454,24 @@ public void removeIssue(Issue issue) { issues.remove(issue); } + /** + * Check if block has issues with same heading. + * @return 'true' if duplicates are found anf 'false' if not. + */ + public boolean checkIssuesWithSameHeading() { + List issuesTitles = issues.stream().map(Issue::getHeading).collect(Collectors.toList()); + List titles = new ArrayList<>(); + for (String title : issuesTitles) { + if (titles.contains(title)) { + Helper.setErrorMessage("duplicatedTitles", " (Block " + (course.indexOf(this) + 1) + ")" ); + return true; + } else { + titles.add(title); + } + } + return false; + } + /** * Sets a LocalDate as day of first * appearance for this Block. diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java index f8455eceb43..97847ff7a6d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/IndividualIssue.java @@ -263,7 +263,8 @@ public Iterable getMetadata(MonthDay yearStart) { if (counter.getMetadataDetail().getInput().equals("inputText") || counter.getMetadataDetail().getInput().equals("inputTextarea")) { String value = counter.getValue(selectedIssue, yearStart); - if (metadata.stream().findFirst().get() instanceof MetadataEntry) { + if (metadata.stream().findFirst().isPresent() + && metadata.stream().findFirst().get() instanceof MetadataEntry) { ((MetadataEntry) metadata.stream().findFirst().get()).setValue(value); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java index 335a0c6da0c..1e0078e6e67 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/metadata/CountableMetadata.java @@ -289,7 +289,7 @@ public ProcessDetail getMetadataDetail() { */ public void setMetadataDetail(ProcessDetail metadataDetail) { this.metadataDetail = metadataDetail; - this.metadataType = this.metadataDetail.getLabel(); + this.metadataType = this.metadataDetail.getMetadataID(); } /** diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index daaee8bbc89..6373dd00102 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -1408,6 +1408,9 @@ h3#headerText.calendar-heading { margin: var(--default-full-size); padding: var(--default-half-size); position: relative; + min-width: calc(100% - 50px); + width: fit-content; + max-width: fit-content; } #editForm\:calendarTabView\:blockList .block-label { @@ -1680,6 +1683,8 @@ h3#headerText.calendar-heading { #calendarDayDialog .ui-selectlistbox-item { width: 100%; display: inline-flex; + height: 30px; + vertical-align: center; } /*---------------------------------------------------------------------- diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml index 7070574a790..8d3cb998795 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml @@ -79,7 +79,7 @@ + style="margin-top: 10px; border: solid 1px var(--medium-gray); width: 100%; padding-bottom: 5px; padding-top: 5px">
- - - + + + + style="background-color: #{CalendarForm.getIssueColor(rowIndex)}; + border-color: #{CalendarForm.getIssueColor(rowIndex)};"/> @@ -116,6 +122,7 @@ @@ -124,6 +131,7 @@ @@ -132,6 +140,7 @@ @@ -140,6 +149,7 @@ @@ -148,6 +158,7 @@ @@ -156,6 +167,7 @@ @@ -168,7 +180,7 @@ update="editForm:calendarTabView:calendarDetailsLayout"/> - +
- Date: Thu, 27 Jan 2022 14:49:12 +0100 Subject: [PATCH 3/6] Fix creation of duplicates during creation of newspaper-processes --- .../kitodo/production/forms/CalendarForm.java | 20 +++++++++-------- .../process/NewspaperProcessesGenerator.java | 22 ++++++++++++++----- .../src/main/webapp/pages/calendarEdit.xhtml | 2 +- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index eb9fefdc444..3dadd39c29d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -35,6 +35,7 @@ import javax.faces.context.FacesContext; import javax.faces.view.ViewScoped; import javax.inject.Named; +import javax.naming.ConfigurationException; import javax.xml.transform.TransformerException; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -46,6 +47,8 @@ import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.exceptions.DoctypeMissingException; +import org.kitodo.exceptions.ProcessGenerationException; import org.kitodo.production.forms.createprocess.ProcessDetail; import org.kitodo.production.forms.createprocess.ProcessTextMetadata; import org.kitodo.production.helper.Helper; @@ -59,6 +62,7 @@ import org.kitodo.production.model.bibliography.course.IndividualIssue; import org.kitodo.production.model.bibliography.course.Issue; import org.kitodo.production.model.bibliography.course.metadata.CountableMetadata; +import org.kitodo.production.process.NewspaperProcessesGenerator; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.calendar.CalendarService; import org.primefaces.PrimeFaces; @@ -899,16 +903,14 @@ public String getMetadataTranslation(String key) { } /** - * Check if course has issues with same name. + * Check if process with the same processtitle already exists. */ - public void checkDuplicatesIssues() { - boolean check = false; - for (Block block : course) { - if (block.checkIssuesWithSameHeading()) { - check = true; - } - } - if (!check) { + public void checkDuplicatedTitles() throws ProcessGenerationException, DataException, DAOException, + ConfigurationException, IOException, DoctypeMissingException { + Process process = ServiceManager.getProcessService().getById(parentId); + NewspaperProcessesGenerator newspaperProcessesGenerator = new NewspaperProcessesGenerator(process, course); + newspaperProcessesGenerator.initialize(); + if (!newspaperProcessesGenerator.isDuplicatedTitles()) { PrimeFaces.current().executeScript("PF('createProcessesConfirmDialog').show();"); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java b/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java index 50af21a9456..3d4c5e50409 100644 --- a/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java +++ b/Kitodo/src/main/java/org/kitodo/production/process/NewspaperProcessesGenerator.java @@ -314,7 +314,7 @@ public boolean nextStep() throws ConfigurationException, DAOException, DataExcep * if something goes wrong when reading or writing one of the * affected files */ - private void initialize() throws ConfigurationException, IOException, DoctypeMissingException { + public void initialize() throws ConfigurationException, IOException, DoctypeMissingException { final long begin = System.nanoTime(); overallMetadataFileUri = processService.getMetadataFileUri(overallProcess); @@ -531,7 +531,13 @@ private void createProcess(int index) throws DAOException, DataException, IOExce } } - private String makeTitle(String definition, Map genericFields) throws ProcessGenerationException { + /** + * Generate process title. + * @param definition as String + * @param genericFields a map with generic fields that can be configured for process + * @return process title as String + */ + public String makeTitle(String definition, Map genericFields) throws ProcessGenerationException { String title; boolean prefixWithProcessTitle = definition.startsWith("+"); if (prefixWithProcessTitle) { @@ -801,20 +807,26 @@ private void finish() throws DataException, IOException { } } - private boolean isDuplicatedTitles() throws ProcessGenerationException, DataException { + /** + * Check if process with the same processtitle already exists. + * @return 'true' if Duplicated titles are found and 'false' if not + */ + public boolean isDuplicatedTitles() throws ProcessGenerationException, DataException { List> processes = course.getProcesses(); List issueTitles = new ArrayList<>(); + boolean check = false; for (List individualProcess : processes) { for (IndividualIssue individualIssue : individualProcess) { Map genericFields = individualIssue.getGenericFields(); String title = makeTitle(issueDivisionView.getProcessTitle().orElse("+'_'+#YEAR+#MONTH+#DAY+#ISSU"), genericFields); if (!ServiceManager.getProcessService().findByTitle(title).isEmpty() || issueTitles.contains(title)) { - return true; + Helper.setErrorMessage("duplicatedTitles", individualIssue.toString()); + check = true; } issueTitles.add(title); } } - return false; + return check; } } diff --git a/Kitodo/src/main/webapp/pages/calendarEdit.xhtml b/Kitodo/src/main/webapp/pages/calendarEdit.xhtml index 14ebc2d3b74..5e393f9ab48 100644 --- a/Kitodo/src/main/webapp/pages/calendarEdit.xhtml +++ b/Kitodo/src/main/webapp/pages/calendarEdit.xhtml @@ -30,7 +30,7 @@ value="#{msgs['granularity.create']}" icon="fa fa-floppy-o fa-lg" iconPos="right" - action="#{CalendarForm.checkDuplicatesIssues()}" + action="#{CalendarForm.checkDuplicatedTitles()}" actionListener="#{CalendarForm.setGranularity(CalendarForm.granularity)}" onclick="setConfirmUnload(false);" update="notifications"/> From 4750711478e500ed888702597ec2b2bc7beef937 Mon Sep 17 00:00:00 2001 From: Ikram Maalej Date: Thu, 27 Jan 2022 14:49:54 +0100 Subject: [PATCH 4/6] Design improvement --- .../kitodo/production/forms/CalendarForm.java | 23 +++++++++++++ .../resources/messages/messages_de.properties | 2 ++ .../resources/messages/messages_en.properties | 2 ++ .../webapp/WEB-INF/resources/css/kitodo.css | 6 ---- .../calendarEdit/calendarBlocks.xhtml | 12 ++----- .../calendarEdit/calendarDayDialog.xhtml | 33 ++++++++++++++----- 6 files changed, 53 insertions(+), 25 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index 3dadd39c29d..96679d5fbe8 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -914,4 +914,27 @@ public void checkDuplicatedTitles() throws ProcessGenerationException, DataExcep PrimeFaces.current().executeScript("PF('createProcessesConfirmDialog').show();"); } } + + /** + * Get first issue that's appear on the selected Date. + * @return issue + */ + public Issue getFirstMatchIssue() { + if (selectedDate != null) { + return getCalendarSheet().get(selectedDate.getDayOfMonth() - 1).get(selectedDate.getMonthValue() - 1).getIssues() + .parallelStream() + .filter(issue -> issue.isMatch(selectedDate)) + .findFirst().orElse(null); + } + return null; + } + + /** + * add Metadata to all Issues that's appear on the selected Date. + */ + public void addMetadataToAllMatchIssues() { + if (getFirstMatchIssue() != null) { + addMetadata(getFirstMatchIssue()); + } + } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index b5f5097627d..0dae421056e 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -120,6 +120,8 @@ calendar.issue.delete=Ausgabe l\u00F6schen calendar.issue.delete.query=Wollen Sie die Augabe l\u00F6schen? calendar.jumpToDay=Zu Tag springen calendar.metadata.add=Metadatum hinzuf\u00FCgen +calendar.metadata.global.add=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen +calendar.metadata.issue.add=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen calendar.metadata.currentValue=Aktueller Wert calendar.metadata.firstAppearance=von calendar.metadata.lastAppearance=bis diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index d41646319e9..614aff3999d 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -124,6 +124,8 @@ calendar.issue.delete=Delete issue calendar.issue.delete.query=Do you want to delete the issue? calendar.jumpToDay=Jump to day calendar.metadata.add=Add metadata +calendar.metadata.global.add=Add metadata to all appeared issues +calendar.metadata.issue.add=Add metadata to all appeared issues from this one onwards calendar.metadata.currentValue=Current value calendar.metadata.firstAppearance=from calendar.metadata.lastAppearance=up to diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 6373dd00102..03c941e6da1 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -1648,8 +1648,6 @@ h3#headerText.calendar-heading { border-bottom: solid var(--default-border-width) var(--cloudy-gray); } - - #calendarDayDialog .metadata-first-appearance, #calendarDayDialog .metadata-last-appearance { display: inline-block; @@ -1663,10 +1661,6 @@ h3#headerText.calendar-heading { vertical-align: top; } -#calendarDayDialog .ui-inputtextarea{ - height: 50px; -} - #calendarDayDialog .metadata-value-label { vertical-align: top; margin-left: var(--default-half-size); diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml index 8d3cb998795..367f1716876 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml @@ -85,7 +85,7 @@ @@ -101,7 +101,6 @@ @@ -113,7 +112,6 @@ @@ -122,7 +120,6 @@ @@ -131,7 +128,6 @@ @@ -140,7 +136,6 @@ @@ -149,7 +144,6 @@ @@ -158,7 +152,6 @@ @@ -167,7 +160,6 @@ @@ -218,7 +210,7 @@ iconPos="right" value="#{msgs['calendar.block.remove']}" title="#{msgs['calendar.block.remove']}" - styleClass="remove-block" + styleClass="remove-block secondary" style="display: inline-block" update="editForm:calendarTabView:calendarDetailsLayout"> -

- #{msgs['calendar.day.'.concat(date.dayOfWeek.value)]} - #{date.toString()} - (#{msgs['calendar.block']} #{CalendarForm.course.indexOf(CalendarForm.getSelectedBlock())+1}) -

+ + +

+ #{msgs['calendar.day.'.concat(date.dayOfWeek.value)]} + #{date.toString()} + (#{msgs['calendar.block']} #{CalendarForm.course.indexOf(CalendarForm.getSelectedBlock())+1}) +

+
+ + + +
@@ -49,13 +65,12 @@ icon="#{issue.isMatch(date) ? 'fa fa-trash' : 'fa fa-plus'}" iconPos="right" styleClass="secondary" - update="editForm:calendarTabView:calendarDetailsLayout - calendarDayForm"/> + update="editForm:calendarTabView:calendarDetailsLayout header calendarDayForm"/> From 9359a4086440a7733734b43d2815a17a75cf02e9 Mon Sep 17 00:00:00 2001 From: Ikram Maalej Date: Tue, 1 Feb 2022 14:40:01 +0100 Subject: [PATCH 5/6] Code improvement 2 --- .../kitodo/production/forms/CalendarForm.java | 14 ++++++++++- .../model/bibliography/course/Block.java | 2 +- .../services/calendar/CalendarService.java | 11 +++++---- .../resources/messages/errors_de.properties | 2 +- .../resources/messages/errors_en.properties | 2 +- .../resources/messages/messages_de.properties | 7 +++--- .../resources/messages/messages_en.properties | 7 +++--- .../webapp/WEB-INF/resources/css/kitodo.css | 24 +++++++++++++++++-- .../calendarEdit/calendarBlocks.xhtml | 4 +++- .../calendarEdit/calendarDayDialog.xhtml | 23 +++++++++--------- 10 files changed, 66 insertions(+), 30 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index 96679d5fbe8..c1855455af9 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -65,6 +65,7 @@ import org.kitodo.production.process.NewspaperProcessesGenerator; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.calendar.CalendarService; +import org.kitodo.production.services.data.ImportService; import org.primefaces.PrimeFaces; import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.StreamedContent; @@ -883,7 +884,7 @@ public String getTextMetadataValue(CountableMetadata metadata, LocalDate date, I * @param block the block to get the metadata for * @return list of pairs containing the metadata type and the date of its earliest occurrence */ - public List> getMetadataSummary(Block block) { + public List> getMetadataSummary(Block block) { return CalendarService.getMetadataSummary(block); } @@ -902,6 +903,17 @@ public String getMetadataTranslation(String key) { } } + /** + * Get the value of the given processDetail. + * + * @param processDetail + * as ProcessDetail + * @return the value as a java.lang.String + */ + public String getMetadataValue(ProcessDetail processDetail) { + return ImportService.getProcessDetailValue(processDetail); + } + /** * Check if process with the same processtitle already exists. */ diff --git a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java index 31e220aec3f..f462ce3500b 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/bibliography/course/Block.java @@ -137,7 +137,7 @@ public Issue addIssue() { * metadata to add */ public void addMetadata(CountableMetadata countableMetadata) { - metadata.add(countableMetadata); + metadata.add(0, countableMetadata); } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java b/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java index 089cfc714e7..95e598b91b3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/calendar/CalendarService.java @@ -46,6 +46,7 @@ import org.kitodo.production.model.bibliography.course.metadata.MetadataEditMode; import org.kitodo.production.security.SecurityUserDetails; import org.kitodo.production.services.ServiceManager; +import org.kitodo.production.services.data.ImportService; public class CalendarService { @@ -123,7 +124,7 @@ public static List getAddableMetadata(Process completeEdi */ public static String getMetadataTranslation(List metadataList, String metadataKey) { for (ProcessDetail selectItem : metadataList) { - if (selectItem.getLabel().equals(metadataKey)) { + if (selectItem.getMetadataID().equals(metadataKey)) { return selectItem.getLabel(); } } @@ -159,16 +160,16 @@ public static List getMetadata(Block block, LocalDate date, I * @param block the block to get the metadata for * @return list of pairs containing the metadata type and the date of its earliest occurrence */ - public static List> getMetadataSummary(Block block) { - Map metadataMap = new HashMap<>(); + public static List> getMetadataSummary(Block block) { + Map metadataMap = new HashMap<>(); if (Objects.nonNull(block)) { for (CountableMetadata metadata : block.getMetadata()) { if (metadataMap.containsKey(metadata.getMetadataType())) { if (metadata.getCreate().getLeft().isBefore(metadataMap.get(metadata.getMetadataType()))) { - metadataMap.replace(metadata.getMetadataType(), metadata.getCreate().getKey()); + metadataMap.replace(metadata.getMetadataDetail(), metadata.getCreate().getKey()); } } else { - metadataMap.put(metadata.getMetadataType(), metadata.getCreate().getKey()); + metadataMap.put(metadata.getMetadataDetail(), metadata.getCreate().getKey()); } } } diff --git a/Kitodo/src/main/resources/messages/errors_de.properties b/Kitodo/src/main/resources/messages/errors_de.properties index 1f2c1539b49..c0b697192bc 100644 --- a/Kitodo/src/main/resources/messages/errors_de.properties +++ b/Kitodo/src/main/resources/messages/errors_de.properties @@ -39,7 +39,7 @@ docketMissing=Die Konfigurationsdatei zur Laufzettelgenerierung existiert nicht docketNotFound=Die angegebene Datei konnte nicht gefunden werden. docketTitleDuplicated=Der Laufzettel mit den gleichen Titel existiert schon. docTypeNotFound=docType ''{0}'' wurde nicht im selektierten Regelsatz gefunden -duplicatedTitles=Es wurden duplizierte Titel gefunden +duplicatedTitles=Es wurden dublette Ausgabe-Bezeichnungen gefunden. Dies erzeugt gegebenenfalls dublette Vorgangstitel! emptySourceFolder=Der Quellordner zur Bildgenerierung ist leer errorDataIncomplete=Unvollst\u00E4ndige Daten\: errorDatabaseReading=Fehler beim Datenbanklesen von ''{0}'' with ID {1}. diff --git a/Kitodo/src/main/resources/messages/errors_en.properties b/Kitodo/src/main/resources/messages/errors_en.properties index 6af66c9d872..8d8bcbf2bf5 100644 --- a/Kitodo/src/main/resources/messages/errors_en.properties +++ b/Kitodo/src/main/resources/messages/errors_en.properties @@ -40,7 +40,7 @@ docketMissing=the configuration file for docket creation is missing docketNotFound=The specified file could not be found. docketTitleDuplicated=The docket with the same title exists already. docTypeNotFound=docType ''{0}'' could not be found in selected ruleset -duplicatedTitles=Duplicated titles found +duplicatedTitles=Duplicate issue designations were found. This may produce duplicate process titles! emptySourceFolder=The source folder is empty errorDataIncomplete=Incomplete data\: errorDatabaseReading=Error on reading database for ''{0}'' with ID {1}. diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 0dae421056e..2e61210ea4e 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -119,9 +119,10 @@ calendar.issue.add=Ausgabe hinzuf\u00FCgen calendar.issue.delete=Ausgabe l\u00F6schen calendar.issue.delete.query=Wollen Sie die Augabe l\u00F6schen? calendar.jumpToDay=Zu Tag springen -calendar.metadata.add=Metadatum hinzuf\u00FCgen -calendar.metadata.global.add=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen -calendar.metadata.issue.add=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen +calendar.metadata.global.add=Metadatum allen Ausgaben hinzuf\u00FCgen +calendar.metadata.issue.add=Metadatum hinzuf\u00FCgen +calendar.metadata.global.add.tooltip=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen +calendar.metadata.issue.add.tooltip=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen calendar.metadata.currentValue=Aktueller Wert calendar.metadata.firstAppearance=von calendar.metadata.lastAppearance=bis diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 614aff3999d..0a26429b151 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -123,9 +123,10 @@ calendar.issue.add=Add issue calendar.issue.delete=Delete issue calendar.issue.delete.query=Do you want to delete the issue? calendar.jumpToDay=Jump to day -calendar.metadata.add=Add metadata -calendar.metadata.global.add=Add metadata to all appeared issues -calendar.metadata.issue.add=Add metadata to all appeared issues from this one onwards +calendar.metadata.global.add=Add metadata to all issues +calendar.metadata.issue.add=Add metadata +calendar.metadata.global.add.tooltip=Add metadata to all appeared issues +calendar.metadata.issue.add.tooltip=Add metadata to all appeared issues from this one onwards calendar.metadata.currentValue=Current value calendar.metadata.firstAppearance=from calendar.metadata.lastAppearance=up to diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 03c941e6da1..0652f2944ab 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -1458,7 +1458,6 @@ h3#headerText.calendar-heading { #editForm\:calendarTabView .metadata-list .ui-dataview-row { border: solid var(--default-border-width) var(--cloudy-gray); - height: calc(var(--input-height) + 2 * var(--default-border-width)); line-height: calc(var(--input-height) + 2 * var(--default-border-width)); } @@ -1604,6 +1603,17 @@ h3#headerText.calendar-heading { color: var(--carbon-blue); } +#calendarDayDialog { + width: 80% !important; + height: 80% !important; + overflow-y: hidden ; +} + +#calendarDayDialog_content { + height: 100% !important; + overflow-y: hidden ; +} + #calendarDayDialog .ui-dialog-content, #calendarDayDialog form, #calendarDayDialog form > .ui-panelgrid, @@ -1613,20 +1623,30 @@ h3#headerText.calendar-heading { #calendarDayDialog form { height: calc(100% - 100px); - overflow-y: scroll; + overflow-y: auto; } #calendarDayDialog .dialogButtonWrapper { bottom: var(--default-full-size); + display: inline-block; + height: 60px; position: absolute; width: calc(100% - var(--default-double-size)); } #calendarDayDialog .dialogFieldWrapper { + min-height: 100%; margin-bottom: 0; overflow-y: hidden; } +#calendarDayDialogHeader { + width: 100%; + padding-left: var(--default-double-size); + padding-right: var(--default-double-size); + padding-bottom: var(--default-full-size); +} + #calendarDayDialog .issue-wrapper:not(:last-child) { border-bottom: solid var(--default-border-width) var(--cloudy-gray); } diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml index 367f1716876..cdf3a861581 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarBlocks.xhtml @@ -189,7 +189,9 @@ value="#{CalendarForm.getMetadataSummary(block)}"> - - + +

#{msgs['calendar.day.'.concat(date.dayOfWeek.value)]} #{date.toString()} @@ -39,15 +36,15 @@ - + @@ -65,12 +62,12 @@ icon="#{issue.isMatch(date) ? 'fa fa-trash' : 'fa fa-plus'}" iconPos="right" styleClass="secondary" - update="editForm:calendarTabView:calendarDetailsLayout header calendarDayForm"/> + update="editForm:calendarTabView:calendarDetailsLayout calendarDayDialogHeader calendarDayForm"/> + + - + From 74ab0e4881df2fb296788cf330d704e16c8c2e71 Mon Sep 17 00:00:00 2001 From: Ikram Maalej Date: Wed, 9 Feb 2022 11:21:41 +0100 Subject: [PATCH 6/6] Fix bugs reported in review comments --- .../org/kitodo/production/forms/CalendarForm.java | 15 +++++++++------ .../resources/messages/messages_de.properties | 2 +- .../includes/calendarEdit/calendarDayDialog.xhtml | 12 ++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java index c1855455af9..2f687b8d021 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CalendarForm.java @@ -603,7 +603,8 @@ public void removeBlock(Block block) { */ public void addIssue(Block block) { if (Objects.nonNull(block)) { - Issue issue = block.addIssue(); + block.addIssue(); + block.checkIssuesWithSameHeading(); } } @@ -919,11 +920,13 @@ public String getMetadataValue(ProcessDetail processDetail) { */ public void checkDuplicatedTitles() throws ProcessGenerationException, DataException, DAOException, ConfigurationException, IOException, DoctypeMissingException { - Process process = ServiceManager.getProcessService().getById(parentId); - NewspaperProcessesGenerator newspaperProcessesGenerator = new NewspaperProcessesGenerator(process, course); - newspaperProcessesGenerator.initialize(); - if (!newspaperProcessesGenerator.isDuplicatedTitles()) { - PrimeFaces.current().executeScript("PF('createProcessesConfirmDialog').show();"); + if (course.parallelStream().noneMatch(block -> Objects.equals(block.checkIssuesWithSameHeading(), true))) { + Process process = ServiceManager.getProcessService().getById(parentId); + NewspaperProcessesGenerator newspaperProcessesGenerator = new NewspaperProcessesGenerator(process, course); + newspaperProcessesGenerator.initialize(); + if (!newspaperProcessesGenerator.isDuplicatedTitles()) { + PrimeFaces.current().executeScript("PF('createProcessesConfirmDialog').show();"); + } } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 2e61210ea4e..713c37a66f7 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -119,7 +119,7 @@ calendar.issue.add=Ausgabe hinzuf\u00FCgen calendar.issue.delete=Ausgabe l\u00F6schen calendar.issue.delete.query=Wollen Sie die Augabe l\u00F6schen? calendar.jumpToDay=Zu Tag springen -calendar.metadata.global.add=Metadatum allen Ausgaben hinzuf\u00FC

gen +calendar.metadata.global.add=Metadatum allen Ausgaben hinzuf\u00FCgen calendar.metadata.issue.add=Metadatum hinzuf\u00FCgen calendar.metadata.global.add.tooltip=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen calendar.metadata.issue.add.tooltip=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarDayDialog.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarDayDialog.xhtml index daaf4de6989..473e5be5ccc 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarDayDialog.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/calendarEdit/calendarDayDialog.xhtml @@ -153,7 +153,7 @@ title="#{metadata.metadataDetail.value}"> - +
@@ -162,7 +162,7 @@ pattern="yyyy-MM-dd" styleClass="input-with-button" showOn="button"> - + @@ -170,7 +170,7 @@ value="#{metadata.metadataDetail.selectedItems}" showCheckbox="true"> - + - + @@ -191,14 +191,14 @@ layout="grid" columns="1"> - + - +