diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java index 9b31eefa174..5741743b97b 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/PaginationPanel.java @@ -271,6 +271,8 @@ private void prepareSelectPaginationModeItems() { "paginierung_spalte.svg")); selectPaginationModeItems.add(new IllustratedSelectItem(PaginatorMode.FOLIATION, "sheetCounting", "paginierung_blatt.svg")); + selectPaginationModeItems.add(new IllustratedSelectItem(PaginatorMode.FOLIATION_WITH_EMPTY_PAGE, "sheetCountingWithEmptyPage", + "paginierung_blatt_leerseite.svg")); selectPaginationModeItems.add(new IllustratedSelectItem(PaginatorMode.RECTOVERSO_FOLIATION, "sheetCountingRectoVerso", "paginierung_blatt_rectoverso.svg")); selectPaginationModeItems.add(new IllustratedSelectItem(PaginatorMode.VERSORECTO_FOLIATION, "sheetCountingVersoRecto", diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeral.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeral.java index eda3c30d1a9..3bee542ef6d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeral.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeral.java @@ -27,8 +27,17 @@ public class AlphabeticNumeral implements Fragment { */ private HalfInteger increment; - AlphabeticNumeral(String value) { + /** + * Indicates the pagination context for the numeral. + * A value of {@code true} represents an odd (left) page. + * A value of {@code false} represents an even (right) page. + * A value of {@code null} indicates that the numeral can appear on any page. + */ + private final Boolean page; + + AlphabeticNumeral(String value, Boolean page) { this.value = parseInt(value); + this.page = page; } /** @@ -65,7 +74,7 @@ public void setIncrement(HalfInteger increment) { @Override public String toString() { - return format(value) + (Objects.nonNull(increment) ? " (" + increment + ")" : " (default)"); + return format(new HalfInteger(value, false)) + (Objects.nonNull(increment) ? " (" + increment + ")" : " (default)"); } /** @@ -76,16 +85,20 @@ public String toString() { */ @Override public String format(HalfInteger value) { - return format(value.intValue()); + return format(value, page); } /** * Returns the value formatted as alphabetic characters. * - * @param number numeric value to format + * @param value + * numeric value to format + * @param page + * Indicates on which type of page this AlphabeticNumeral should be shown (true = odd pages, false = even pages, null = all pages) * @return the formatted value */ - public static String format(int number) { + public static String format(HalfInteger value, Boolean page) { + int number = value.intValue(); StringBuilder result = new StringBuilder(); while (number > 0) { @@ -95,8 +108,11 @@ public static String format(int number) { result.insert(0, letter); number = number / ALPHABET_SIZE; } - - return result.toString(); + if (page == null || page == value.isHalf()) { + return result.toString(); + } else { + return ""; + } } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/DecimalNumeral.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/DecimalNumeral.java index f9ee9c316d0..e97dfff81a1 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/DecimalNumeral.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/DecimalNumeral.java @@ -31,14 +31,23 @@ public class DecimalNumeral implements Fragment { */ private HalfInteger increment; + /** + * Indicates the pagination context for the numeral. + * A value of {@code true} represents an odd (left) page. + * A value of {@code false} represents an even (right) page. + * A value of {@code null} indicates that the numeral can appear on any page. + */ + private final Boolean page; + /** * The initial value of this numeral. */ private int value; - DecimalNumeral(String value) { + DecimalNumeral(String value, Boolean page) { this.value = Integer.parseInt(value); this.digits = "%0" + value.length() + "d"; + this.page = page; } /** @@ -47,7 +56,11 @@ public class DecimalNumeral implements Fragment { */ @Override public String format(HalfInteger value) { - return String.format(digits, value.intValue()); + if (page == null || page == value.isHalf()) { + return String.format(digits, value.intValue()); + } else { + return ""; + } } @Override diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/Paginator.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/Paginator.java index 4c6e5f2a2cf..7f2d815cd36 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/Paginator.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/Paginator.java @@ -146,14 +146,13 @@ private void parse(String initializer) { * page information */ private void createFragment(StringBuilder stringBuilder, PaginatorState fragmentType, Boolean pageType) { - if (pageType == null && fragmentType.equals(PaginatorState.DECIMAL)) { - fragments.addLast(new DecimalNumeral(stringBuilder.toString())); - } else if (pageType == null && (fragmentType.equals(PaginatorState.UPPERCASE_ROMAN) - || fragmentType.equals(PaginatorState.LOWERCASE_ROMAN))) { + if (fragmentType.equals(PaginatorState.DECIMAL)) { + fragments.addLast(new DecimalNumeral(stringBuilder.toString(), pageType)); + } else if (fragmentType.equals(PaginatorState.UPPERCASE_ROMAN) || fragmentType.equals(PaginatorState.LOWERCASE_ROMAN)) { fragments.addLast( - new RomanNumeral(stringBuilder.toString(), fragmentType.equals(PaginatorState.UPPERCASE_ROMAN))); - } else if (pageType == null && fragmentType.equals(PaginatorState.ALPHABETIC)) { - fragments.addLast(new AlphabeticNumeral(stringBuilder.toString())); + new RomanNumeral(stringBuilder.toString(), fragmentType.equals(PaginatorState.UPPERCASE_ROMAN), pageType)); + } else if (fragmentType.equals(PaginatorState.ALPHABETIC)) { + fragments.addLast(new AlphabeticNumeral(stringBuilder.toString(), pageType)); } else if (fragmentType.equals(PaginatorState.INCREMENT)) { if (fragments.isEmpty() || Objects.isNull(fragments.peekLast())) { fragments.addLast(new StaticText("", pageType)); diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorMode.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorMode.java index 17a95bb0fdc..0d7eff430e2 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorMode.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorMode.java @@ -62,6 +62,22 @@ String format(String value, String next, boolean fictitious, String separator) { } }, + /** + * The counter is increased on every second page. The pages are numbered alternating counter and "UNCOUNTED". + * (1, UNCOUNTED, 2, UNCOUNTED, … / [1], [UNCOUNTED], [2], [UNCOUNTED], …) + */ + FOLIATION_WITH_EMPTY_PAGE(8) { + @Override + String format(String value, String next, boolean fictitious, String separator) { + if (fictitious) { + return "[¿UNCOUNTED¡" + value + "½]"; + } else { + return "¿UNCOUNTED¡" + value + "½"; + } + } + }, + + /** * Normal pagination (1, 2, 3, 4, … / [1], [2], [3], [4], …). */ @@ -99,9 +115,9 @@ String format(String value, String next, boolean fictitious, String separator) { @Override String format(String value, String next, boolean fictitious, String separator) { if (fictitious) { - return '[' + value + "°]¡r¿v½"; + return '[' + value + "°]¡r¿`v`½"; } else { - return value.concat("°¡r¿v½"); + return value.concat("°¡r¿`v`½"); } } }, @@ -114,9 +130,9 @@ String format(String value, String next, boolean fictitious, String separator) { @Override String format(String value, String next, boolean fictitious, String separator) { if (fictitious) { - return "½[" + value + "°]¡r¿v½"; + return "½[" + value + "°]¡r¿`v`½"; } else { - return '½' + value + "°¡r¿v½"; + return '½' + value + "°¡r¿`v`½"; } } }; diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorType.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorType.java index 1f010b9bdae..23e69eb6a03 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorType.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/PaginatorType.java @@ -41,8 +41,12 @@ public String format(PaginatorMode mode, String valueString, boolean fictitious, throw b; } } - return mode.format('´' + AlphabeticNumeral.format(value) + '´', '´' + AlphabeticNumeral.format(value + 1) + '´', fictitious, - separator); + return mode.format( + '´' + AlphabeticNumeral.format(new HalfInteger(value, false), null) + '´', + '´' + AlphabeticNumeral.format(new HalfInteger(value + 1, false), null) + '´', + fictitious, + separator + ); } }, @@ -92,8 +96,12 @@ public String format(PaginatorMode mode, String valueString, boolean fictitious, throw b; } } - return mode.format(RomanNumeral.format(value, true), RomanNumeral.format(value + 1, true), fictitious, - separator); + return mode.format( + RomanNumeral.format(new HalfInteger(value, false), true, null), + RomanNumeral.format(new HalfInteger(value + 1, false), true, null), + fictitious, + separator + ); } }, diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/RomanNumeral.java b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/RomanNumeral.java index 60e9bcee923..00e43d8b610 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/RomanNumeral.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/metadata/pagination/RomanNumeral.java @@ -50,11 +50,13 @@ public class RomanNumeral implements Fragment { * @param inputValue * value to format * @param uppercase - * if true, the Roman numeral is upper case, otherwise lower case + * If true, produces upper case roman numerals, else lower case + * @param page + * Indicates on which type of page this RomanNumeral should be shown (true = odd pages, false = even pages, null = all pages) * @return Roman numeral for the value */ - public static String format(int inputValue, boolean uppercase) { - int value = inputValue; + public static String format(HalfInteger inputValue, boolean uppercase, Boolean page) { + int value = inputValue.intValue(); StringBuilder result = new StringBuilder(); while (value >= 1000) { result.append(uppercase ? 'M' : 'm'); @@ -64,12 +66,22 @@ public static String format(int inputValue, boolean uppercase) { value %= 100; result.append(TENS[value / 10]); result.append(ONES[value % 10]); - return uppercase ? result.toString().toUpperCase() : result.toString(); + if (page == null || page == inputValue.isHalf()) { + return uppercase ? result.toString().toUpperCase() : result.toString(); + } else { + return ""; + } } + /** + * Returns the Roman numeral for the value as string. + * @param value + * value to format + * @return Roman numeral for the value + */ @Override public String format(HalfInteger value) { - return format(value.intValue(), uppercase); + return format(value, uppercase, page); } /** @@ -127,6 +139,14 @@ private static int updateResult(int result, int threshold, int difference) { */ private HalfInteger increment; + /** + * Indicates the pagination context for the numeral. + * A value of {@code true} represents an odd (left) page. + * A value of {@code false} represents an even (right) page. + * A value of {@code null} indicates that the numeral can appear on any page. + */ + private final Boolean page; + /** * If true, produces upper case roman numerals, else lower case. */ @@ -137,9 +157,10 @@ private static int updateResult(int result, int threshold, int difference) { */ private final int value; - RomanNumeral(String value, boolean uppercase) { + RomanNumeral(String value, boolean uppercase, Boolean page) { this.value = parseInt(value); this.uppercase = uppercase; + this.page = page; } @Override @@ -164,6 +185,6 @@ public void setIncrement(HalfInteger increment) { */ @Override public String toString() { - return format(value, uppercase) + (Objects.nonNull(increment) ? " (" + increment + ")" : " (default)"); + return format(new HalfInteger(value, false)) + (Objects.nonNull(increment) ? " (" + increment + ")" : " (default)"); } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 114db81706c..05fdcab7735 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -1159,6 +1159,7 @@ setImportConfigurationForSelectedProcessesText=Bitte wählen Sie die Importkonfi setRepresentative=Repräsentant setzen\: settings=Einstellungen sheetCounting=Blattzählung +sheetCountingWithEmptyPage=Blattzählung mit Leerseite sheetCountingRectoVerso=Blattzählung recto-verso sheetCountingVersoRecto=Blattzählung verso-recto shortcuts=Tastaturkürzel diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 86c21369278..04f1fbaad77 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -1159,6 +1159,7 @@ setImportConfigurationForSelectedProcessesText=Please select the import configur setRepresentative=Set representative\: settings=Settings sheetCounting=Sheet counting +sheetCountingWithEmptyPage=Sheet counting with empty page sheetCountingRectoVerso=RectoVerso Pagination sheetCountingVersoRecto=VersoRecto Pagination shortcuts=Keyboard shortcuts diff --git a/Kitodo/src/main/resources/messages/messages_es.properties b/Kitodo/src/main/resources/messages/messages_es.properties index b03e57dfd8e..c8fbc1008a3 100644 --- a/Kitodo/src/main/resources/messages/messages_es.properties +++ b/Kitodo/src/main/resources/messages/messages_es.properties @@ -1152,6 +1152,8 @@ setImportConfigurationForSelectedProcessesText=Por favor seleccione la configura setRepresentative=Establecer representante\: settings=Ajustes sheetCounting=Recuento de hojas +# please check google translation below +sheetCountingWithEmptyPage=Recuento de hojas con página en blanco sheetCountingRectoVerso=Recuento de hojas recto-verso sheetCountingVersoRecto=Recuento de hojas verso-recto shortcuts=Atajos de teclado diff --git a/Kitodo/src/main/webapp/pages/images/buttons/paginierung_blatt_leerseite.svg b/Kitodo/src/main/webapp/pages/images/buttons/paginierung_blatt_leerseite.svg new file mode 100644 index 00000000000..ad4e0ec6266 --- /dev/null +++ b/Kitodo/src/main/webapp/pages/images/buttons/paginierung_blatt_leerseite.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + \ No newline at end of file diff --git a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeralTest.java b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeralTest.java index 7ace56e1765..d5ff6db871d 100644 --- a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeralTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/AlphabeticNumeralTest.java @@ -20,7 +20,7 @@ public class AlphabeticNumeralTest { @Test public void testOutputInput() { for (int i = 1; i <= 4999; i++) { - String encoded = AlphabeticNumeral.format(i); + String encoded = AlphabeticNumeral.format(new HalfInteger(i, false), null); int decoded = AlphabeticNumeral.parseInt(encoded); assertEquals(i, decoded); } @@ -37,9 +37,9 @@ public void testParseInt() { @Test public void testFormat() { - assertEquals("c", AlphabeticNumeral.format(3)); - assertEquals("z", AlphabeticNumeral.format(26)); - assertEquals("bb", AlphabeticNumeral.format(54)); - assertEquals("qwf", AlphabeticNumeral.format(12096)); + assertEquals("c", AlphabeticNumeral.format(new HalfInteger(3, false), null)); + assertEquals("z", AlphabeticNumeral.format(new HalfInteger(26, false), null)); + assertEquals("bb", AlphabeticNumeral.format(new HalfInteger(54, false), null)); + assertEquals("qwf", AlphabeticNumeral.format(new HalfInteger(12096, false), null)); } } diff --git a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTest.java b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTest.java index 5be39674bde..98cb2c95881 100644 --- a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTest.java @@ -92,7 +92,7 @@ public void inteleavePaginationThree() { @Test public void rectoVersoPagination() { - Paginator paginator = new Paginator("1° ¡r¿v½"); + Paginator paginator = new Paginator("1° ¡r¿`v`½"); assertEquals("1 r", paginator.next()); assertEquals("1 v", paginator.next()); assertEquals("2 r", paginator.next()); @@ -101,7 +101,7 @@ public void rectoVersoPagination() { @Test public void rectoVersoPaginationStartRight() { - Paginator paginator = new Paginator("½1° ¡r¿v½"); + Paginator paginator = new Paginator("½1° ¡r¿`v`½"); assertEquals("1 v", paginator.next()); assertEquals("2 r", paginator.next()); assertEquals("2 v", paginator.next()); @@ -181,7 +181,7 @@ public void ignoreRomanNumeralsThatArePartsOfWordsWithLowercaseRoman() { @Test public void handleRectoVersoForWhiteSpaceCharacterAsWell() { - Paginator paginator = new Paginator("1°¿ ¿(¿R¿ü¿c¿k¿s¿e¿i¿t¿e¿)½"); + Paginator paginator = new Paginator("1°¿ ¿(¿R¿ü¿`c`¿k¿s¿e¿`i`¿t¿e¿)½"); assertEquals("1", paginator.next()); assertEquals("1 (Rückseite)", paginator.next()); assertEquals("2", paginator.next()); @@ -208,7 +208,7 @@ public void alphabeticPagination() { @Test public void alphabeticPaginationRectoVerso() { - Paginator paginator = new Paginator("´a´° ¡r¿v½"); + Paginator paginator = new Paginator("´a´° ¡r¿`v`½"); assertEquals("a r", paginator.next()); assertEquals("a v", paginator.next()); assertEquals("b r", paginator.next()); @@ -216,4 +216,26 @@ public void alphabeticPaginationRectoVerso() { assertEquals("c r", paginator.next()); assertEquals("c v", paginator.next()); } + + @Test + public void foliationWithEmptyPage() { + Paginator paginator = new Paginator("¿UNCOUNTED¡1½"); + assertEquals("1", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + assertEquals("2", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + + paginator = new Paginator("¿UNCOUNTED¡VI½"); + assertEquals("VI", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + assertEquals("VII", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + + paginator = new Paginator("¿UNCOUNTED¡´z´½"); + assertEquals("z", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + assertEquals("aa", paginator.next()); + assertEquals("UNCOUNTED", paginator.next()); + } + } diff --git a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTypeTest.java b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTypeTest.java index 52da83e0e90..845c04b3a08 100644 --- a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTypeTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/PaginatorTypeTest.java @@ -160,17 +160,17 @@ public void testArabicFormatPagesFromUppercaseRoman() { @Test public void testArabicFormatRectoversoFoliationFictiousFromArabic() { - assertEquals("[4°]¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "4", true, UNUSED_STRING)); + assertEquals("[4°]¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "4", true, UNUSED_STRING)); } @Test public void testArabicFormatRectoversoFoliationFictiousFromLowercaseRoman() { - assertEquals("[4°]¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "iv", true, UNUSED_STRING)); + assertEquals("[4°]¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "iv", true, UNUSED_STRING)); } @Test public void testArabicFormatRectoversoFoliationFictiousFromUppercaseRoman() { - assertEquals("[4°]¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "IV", true, UNUSED_STRING)); + assertEquals("[4°]¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "IV", true, UNUSED_STRING)); } @Test @@ -208,17 +208,27 @@ public void testArabicFormatRectoversoFromUppercaseRoman() { @Test public void testArabicFormatRectoversoFoliationFromArabic() { - assertEquals("1°¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "1", false, UNUSED_STRING)); + assertEquals("1°¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "1", false, UNUSED_STRING)); } @Test public void testArabicFormatRectoversoFoliationFromLowercaseRoman() { - assertEquals("1°¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "i", false, UNUSED_STRING)); + assertEquals("1°¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "i", false, UNUSED_STRING)); } @Test public void testArabicFormatRectoversoFoliationFromUppercaseRoman() { - assertEquals("1°¡r¿v½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "I", false, UNUSED_STRING)); + assertEquals("1°¡r¿`v`½", PaginatorType.ARABIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "I", false, UNUSED_STRING)); + } + + @Test + public void testArabicFormatFoliationWithEmptyPage() { + assertEquals("¿UNCOUNTED¡1½", PaginatorType.ARABIC.format(PaginatorMode.FOLIATION_WITH_EMPTY_PAGE, "1", false, UNUSED_STRING)); + } + + @Test + public void testArabicFormatFoliationWithEmptyPageFictious() { + assertEquals("[¿UNCOUNTED¡1½]", PaginatorType.ARABIC.format(PaginatorMode.FOLIATION_WITH_EMPTY_PAGE, "1", true, UNUSED_STRING)); } @Test @@ -271,13 +281,13 @@ public void testFreetextFormatPagesFictious() { @Test public void testFreetextFormatRectoversoFoliation() { - assertEquals("`Hello world!`°¡r¿v½", + assertEquals("`Hello world!`°¡r¿`v`½", PaginatorType.FREETEXT.format(PaginatorMode.RECTOVERSO_FOLIATION, HELLO_WORLD_STRING, false, UNUSED_STRING)); } @Test public void testFreetextFormatRectoversoFoliationFictious() { - assertEquals("[`Hello world!`°]¡r¿v½", + assertEquals("[`Hello world!`°]¡r¿`v`½", PaginatorType.FREETEXT.format(PaginatorMode.RECTOVERSO_FOLIATION, HELLO_WORLD_STRING, true, UNUSED_STRING)); } @@ -422,17 +432,17 @@ public void testRomanFormatPagesFromUppercaseRoman() { @Test public void testRomanFormatRectoversoFoliationFictiousFromArabic() { - assertEquals("[VIII°]¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "8", true, UNUSED_STRING)); + assertEquals("[VIII°]¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "8", true, UNUSED_STRING)); } @Test public void testRomanFormatRectoversoFoliationFictiousFromLowercaseRoman() { - assertEquals("[VIII°]¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "viii", true, UNUSED_STRING)); + assertEquals("[VIII°]¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "viii", true, UNUSED_STRING)); } @Test public void testRomanFormatRectoversoFoliationFictiousFromUppercaseRoman() { - assertEquals("[VIII°]¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "VIII", true, UNUSED_STRING)); + assertEquals("[VIII°]¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "VIII", true, UNUSED_STRING)); } @Test @@ -470,17 +480,22 @@ public void testRomanFormatRectoversoFromUppercaseRoman() { @Test public void testRomanFormatRectoversoFoliationFromArabic() { - assertEquals("VI°¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "6", false, UNUSED_STRING)); + assertEquals("VI°¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "6", false, UNUSED_STRING)); } @Test public void testRomanFormatRectoversoFoliationFromLowercaseRoman() { - assertEquals("VI°¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "vi", false, UNUSED_STRING)); + assertEquals("VI°¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "vi", false, UNUSED_STRING)); } @Test public void testRomanFormatRectoversoFoliationFromUppercaseRoman() { - assertEquals("VI°¡r¿v½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "VI", false, UNUSED_STRING)); + assertEquals("VI°¡r¿`v`½", PaginatorType.ROMAN.format(PaginatorMode.RECTOVERSO_FOLIATION, "VI", false, UNUSED_STRING)); + } + + @Test + public void testRomanFormatFoliationWithEmptyPage() { + assertEquals("¿UNCOUNTED¡III½", PaginatorType.ROMAN.format(PaginatorMode.FOLIATION_WITH_EMPTY_PAGE, "3", false, UNUSED_STRING)); } @Test @@ -505,10 +520,16 @@ public void testAlphabeticFormatRectoverso() { @Test public void testAlphabeticFormatRectoversoFoliation() { - assertEquals("´m´°¡r¿v½", PaginatorType.ALPHABETIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "m", false, UNUSED_STRING)); + assertEquals("´m´°¡r¿`v`½", PaginatorType.ALPHABETIC.format(PaginatorMode.RECTOVERSO_FOLIATION, "m", false, UNUSED_STRING)); } - + @Test + public void testAlphabeticFormatFoliationWithEmptyPage() { + assertEquals( + "¿UNCOUNTED¡´x´½", + PaginatorType.ALPHABETIC.format(PaginatorMode.FOLIATION_WITH_EMPTY_PAGE, "x", false, UNUSED_STRING) + ); + } @Test public void testUncountedFormatColumns() { @@ -560,13 +581,13 @@ public void testUncountedFormatPagesFictious() { @Test public void testUncountedFormatRectoversoFoliation() { - assertEquals("`uncounted`°¡r¿v½", + assertEquals("`uncounted`°¡r¿`v`½", PaginatorType.UNCOUNTED.format(PaginatorMode.RECTOVERSO_FOLIATION, UNUSED_STRING, false, UNUSED_STRING)); } @Test public void testUncountedFormatRectoversoFoliationFictious() { - assertEquals("[`uncounted`°]¡r¿v½", + assertEquals("[`uncounted`°]¡r¿`v`½", PaginatorType.UNCOUNTED.format(PaginatorMode.RECTOVERSO_FOLIATION, UNUSED_STRING, true, UNUSED_STRING)); } diff --git a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/RomanNumeralTest.java b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/RomanNumeralTest.java index 2a22a11c79b..efb6b6837db 100644 --- a/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/RomanNumeralTest.java +++ b/Kitodo/src/test/java/org/kitodo/production/helper/metadata/pagination/RomanNumeralTest.java @@ -20,7 +20,7 @@ public class RomanNumeralTest { @Test public void testOutputInputLowercase() { for (int i = 1; i <= 4999; i++) { - String encoded = RomanNumeral.format(i, false); + String encoded = RomanNumeral.format(new HalfInteger(i, false), false, null); int decoded = RomanNumeral.parseInt(encoded); assertEquals(i, decoded); } @@ -29,7 +29,7 @@ public void testOutputInputLowercase() { @Test public void testOutputInputUppercase() { for (int i = 1; i <= 4999; i++) { - String encoded = RomanNumeral.format(i, true); + String encoded = RomanNumeral.format(new HalfInteger(i, false), true, null); int decoded = RomanNumeral.parseInt(encoded); assertEquals(i, decoded); } @@ -53,17 +53,17 @@ public void testParseIntLowercase() { @Test public void testFormatUppercase() { - assertEquals("XV", RomanNumeral.format(15, true)); - assertEquals("CDI", RomanNumeral.format(401, true)); - assertEquals("CMII", RomanNumeral.format(902, true)); - assertEquals("MMMMCDXLIII", RomanNumeral.format(4443, true)); + assertEquals("XV", RomanNumeral.format(new HalfInteger(15, false), true, null)); + assertEquals("CDI", RomanNumeral.format(new HalfInteger(401, false), true, null)); + assertEquals("CMII", RomanNumeral.format(new HalfInteger(902, false), true, null)); + assertEquals("MMMMCDXLIII", RomanNumeral.format(new HalfInteger(4443, false), true, null)); } @Test public void testFormatLowercase() { - assertEquals("xxv", RomanNumeral.format(25, false)); - assertEquals("miii", RomanNumeral.format(1003, false)); - assertEquals("cmxii", RomanNumeral.format(912, false)); - assertEquals("mmmmdcclxvi", RomanNumeral.format(4766, false)); + assertEquals("xxv", RomanNumeral.format(new HalfInteger(25, false), false, null)); + assertEquals("miii", RomanNumeral.format(new HalfInteger(1003, false), false, null)); + assertEquals("cmxii", RomanNumeral.format(new HalfInteger(912, false), false, null)); + assertEquals("mmmmdcclxvi", RomanNumeral.format(new HalfInteger(4766, false), false, null)); } }