slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00053
[Merge] lp:~ralf-claussnitzer/goobi-production/bug-918204 into lp:goobi-production
Ralf Claussnitzer has proposed merging lp:~ralf-claussnitzer/goobi-production/bug-918204 into lp:goobi-production.
Requested reviews:
Henning Gerhardt (henning-gerhardt)
Related bugs:
Bug #918204 in Goobi.Production: "application crashes on pagination"
https://bugs.launchpad.net/goobi-production/+bug/918204
For more details, see:
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/bug-918204/+merge/93941
--
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/bug-918204/+merge/93941
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== modified file 'build.xml'
--- build.xml 2011-12-20 08:07:09 +0000
+++ build.xml 2012-02-21 09:13:40 +0000
@@ -294,7 +294,6 @@
<!-- JUnit tests -->
<target name="junit" depends="compile-tests" description="Run JUnit tests">
-
<junit printsummary="on">
<classpath refid="test.classpath"/>
<formatter type="xml" usefile="true"/>
@@ -302,7 +301,16 @@
<fileset dir="${build.classes}" includes="**/*Test.class"/>
</batchtest>
</junit>
+ </target>
+ <target name="run-test" depends="compile-tests" description="Run specific JUnit test">
+ <fail unless="junit.test.name" message="Property not set: junit.test.name"/>
+ <junit>
+ <classpath refid="test.classpath"/>
+ <formatter type="plain" usefile="false"/>
+ <test name="${junit.test.name}" haltonfailure="yes" unless="junit.test.methods"/>
+ <test name="${junit.test.name}" haltonfailure="yes" methods="${junit.test.methods}" if="junit.test.methods"/>
+ </junit>
</target>
</project>
=== modified file 'pages/incMeta/Paginierung.jsp'
--- pages/incMeta/Paginierung.jsp 2012-01-11 13:31:26 +0000
+++ pages/incMeta/Paginierung.jsp 2012-02-21 09:13:40 +0000
@@ -78,17 +78,22 @@
<h:selectOneMenu value="#{Metadaten.paginierungArt}"
style="width: 250px" onchange="paginierungWertAnzeigen(this);">
<f:selectItem itemValue="1" itemLabel="#{msgs.arabisch}" />
- <f:selectItem itemValue="4" itemLabel="#{msgs.arabischBracket}" />
<f:selectItem itemValue="2" itemLabel="#{msgs.roemisch}" />
- <f:selectItem itemValue="5" itemLabel="#{msgs.roemischBracket}" />
<f:selectItem itemValue="3" itemLabel="#{msgs.unnummeriert}" />
</h:selectOneMenu>
+
<htm:br />
+
<x:inputText id="paginierungWert" forceId="true"
value="#{Metadaten.paginierungWert}"
style="width: 250px;margin-top:15px;margin-bottom:5px"/>
<htm:br />
+ <htm:div style="margin: 15px">
+ <h:outputLabel for="checkbox-fictitious" value="#{msgs.paginationFictitious}"/>
+ <h:selectBooleanCheckbox id="checkbox-fictitious" value="#{Metadaten.fictitious}"/>
+ </htm:div>
+
<a4j:commandLink rendered="#{Metadaten.paginierungSeitenProImage!=1}"
title="#{msgs.seitenzaehlung}" reRender="PaginierungActionBox,myMessages">
<h:graphicImage
=== modified file 'src/de/sub/goobi/metadaten/Metadaten.java'
--- src/de/sub/goobi/metadaten/Metadaten.java 2011-12-20 08:07:09 +0000
+++ src/de/sub/goobi/metadaten/Metadaten.java 2012-02-21 09:13:40 +0000
@@ -127,6 +127,7 @@
private int paginierungAbSeiteOderMarkierung;
private String paginierungArt;
private int paginierungSeitenProImage = 1; // 1=normale Paginierung, 2=zwei
+ private boolean fictitious = false;
// Spalten auf einem Image,
// 3=nur jede zweite Seite hat
// Seitennummer
@@ -447,7 +448,7 @@
myList.add(new SelectItem(mdt.getName(), metahelper.getMetadatatypeLanguage(mdt)));
try {
Metadata md = new Metadata(mdt);
- Metadatum mdum = new Metadatum(md, counter, myPrefs, myProzess);
+ Metadatum mdum = new MetadatumImpl(md, counter, myPrefs, myProzess);
counter++;
tempMetadatumList.add(mdum);
@@ -728,7 +729,7 @@
.getManagedBeanValue("#{LoginForm.myBenutzer.metadatenSprache}"), false, myProzess);
if (myTempMetadata != null)
for (Metadata metadata : myTempMetadata)
- lsMeta.add(new Metadatum(metadata, 0, myPrefs, myProzess));
+ lsMeta.add(new MetadatumImpl(metadata, 0, myPrefs, myProzess));
/*
* -------------------------------- alle Personen ermitteln --------------------------------
@@ -1169,7 +1170,7 @@
for (DocStruct mySeitenDocStruct : meineListe) {
List<? extends Metadata> mySeitenDocStructMetadaten = mySeitenDocStruct.getAllMetadataByType(mdt);
for (Metadata meineSeite : mySeitenDocStructMetadaten) {
- alleSeitenNeu[zaehler] = new Metadatum(meineSeite, zaehler, myPrefs, myProzess);
+ alleSeitenNeu[zaehler] = new MetadatumImpl(meineSeite, zaehler, myPrefs, myProzess);
alleSeiten[zaehler] = new SelectItem(String.valueOf(zaehler), MetadatenErmitteln(meineSeite.getDocStruct(), "physPageNumber")
.trim()
+ ": " + meineSeite.getValue());
@@ -1247,7 +1248,7 @@
if (listMetadaten == null || listMetadaten.size() == 0)
return;
for (Metadata meineSeite : listMetadaten) {
- structSeitenNeu[inZaehler] = new Metadatum(meineSeite, inZaehler, myPrefs, myProzess);
+ structSeitenNeu[inZaehler] = new MetadatumImpl(meineSeite, inZaehler, myPrefs, myProzess);
structSeiten[inZaehler] = new SelectItem(String.valueOf(inZaehler), MetadatenErmitteln(meineSeite.getDocStruct(), "physPageNumber")
.trim()
+ ": " + meineSeite.getValue());
@@ -1268,24 +1269,74 @@
return rueckgabe;
}
- /**
- * die Paginierung ändern
- */
-
- public String Paginierung() {
- Pagination p = new Pagination(alleSeitenAuswahl, alleSeitenNeu, paginierungAbSeiteOderMarkierung, paginierungArt, paginierungSeitenProImage,
- paginierungWert);
- String result = p.doPagination();
- /*
- * zum Schluss nochmal alle Seiten neu einlesen
- */
- alleSeitenAuswahl = null;
- retrieveAllImages();
- if (!SperrungAktualisieren()) {
- return "SperrungAbgelaufen";
- }
- return result;
- }
+ /**
+ * die Paginierung ändern
+ * ================================================================
+ */
+ public String Paginierung() {
+
+ int[] pageSelection = new int[alleSeitenAuswahl.length];
+ for(int i = 0; i < alleSeitenAuswahl.length; i++) {
+ pageSelection[i] = Integer.parseInt(alleSeitenAuswahl[i]);
+ }
+
+ Paginator.Mode mode;
+ switch (paginierungSeitenProImage) {
+ case 2: mode = Paginator.Mode.COLUMNS;
+ break;
+ case 3: mode = Paginator.Mode.FOLIATION;
+ break;
+ case 4: mode = Paginator.Mode.RECTOVERSO;
+ break;
+ case 5: mode = Paginator.Mode.RECTOVERSO_FOLIATION;
+ break;
+ default: mode = Paginator.Mode.PAGES;
+ }
+
+ Paginator.Type type;
+ switch (Integer.parseInt(paginierungArt)) {
+ case 1: type = Paginator.Type.ARABIC;
+ break;
+ case 2: type = Paginator.Type.ROMAN;
+ break;
+ default: type = Paginator.Type.UNCOUNTED;
+ break;
+ }
+
+ Paginator.Scope scope;
+ switch (paginierungAbSeiteOderMarkierung) {
+ case 1: scope = Paginator.Scope.FROMFIRST;
+ break;
+ default: scope = Paginator.Scope.SELECTED;
+ break;
+ }
+
+ try {
+ Paginator p = new Paginator()
+ .setPageSelection(pageSelection)
+ .setPagesToPaginate(alleSeitenNeu)
+ .setPaginationScope(scope)
+ .setPaginationType(type)
+ .setPaginationMode(mode)
+ .setFictitious(fictitious)
+ .setPaginationStartValue(paginierungWert);
+ p.run();
+ } catch (IllegalArgumentException iae) {
+ help.setFehlerMeldung("fehlerBeimEinlesen", iae.getMessage());
+ }
+
+ /*
+ * -------------------------------- zum Schluss nochmal alle Seiten neu
+ * einlesen --------------------------------
+ */
+ alleSeitenAuswahl = null;
+ retrieveAllImages();
+ if (!SperrungAktualisieren()) {
+ return "SperrungAbgelaufen";
+ }
+
+ return null;
+ }
/**
* alle Knoten des Baums expanden oder collapsen ================================================================
@@ -2046,7 +2097,7 @@
MetadataType mdt = myPrefs.getMetadataTypeByName(tempTyp);
try {
Metadata md = new Metadata(mdt);
- selectedMetadatum = new Metadatum(md, myMetadaten.size() + 1, myPrefs, myProzess);
+ selectedMetadatum = new MetadatumImpl(md, myMetadaten.size() + 1, myPrefs, myProzess);
} catch (MetadataTypeNotAllowedException e) {
myLogger.error(e.getMessage());
}
@@ -2439,4 +2490,11 @@
return true;
}
+ public boolean getFictitious() {
+ return fictitious;
+ }
+
+ public void setFictitious(boolean fictitious) {
+ this.fictitious = fictitious;
+ }
}
=== modified file 'src/de/sub/goobi/metadaten/Metadatum.java'
--- src/de/sub/goobi/metadaten/Metadatum.java 2011-12-20 08:07:09 +0000
+++ src/de/sub/goobi/metadaten/Metadatum.java 2012-02-21 09:13:40 +0000
@@ -23,243 +23,55 @@
package de.sub.goobi.metadaten;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import javax.faces.model.SelectItem;
-import org.goobi.api.display.DisplayCase;
import org.goobi.api.display.Item;
-import org.goobi.api.display.Modes;
-import org.goobi.api.display.enums.BindState;
import ugh.dl.Metadata;
-import ugh.dl.MetadataType;
-import ugh.dl.Prefs;
-import de.sub.goobi.beans.Prozess;
-import de.sub.goobi.helper.Helper;
-
-//TODO: Use a correct comment here
-/**
- * Die Klasse Schritt ist ein Bean für einen einzelnen Schritt
- * mit dessen Eigenschaften und erlaubt die Bearbeitung
- * der Schrittdetails
- *
- * @author Steffen Hankiewicz
- * @version 1.00 - 10.01.2005
- */
-
-
-public class Metadatum {
- private Metadata md;
- private int identifier;
- private Prefs myPrefs;
- private Prozess myProcess;
- private HashMap<String, DisplayCase> myValues = new HashMap<String, DisplayCase>();
- private List<SelectItem> items;
- private List<String> selectedItems;
-
-
- /**
- * Allgemeiner Konstruktor ()
- */
- public Metadatum(Metadata m, int inID, Prefs inPrefs, Prozess inProcess) {
- md = m;
- identifier = inID;
- myPrefs = inPrefs;
- myProcess = inProcess;
- for (BindState state : BindState.values()) {
- myValues.put(state.getTitle(), new DisplayCase(myProcess, state.getTitle(), md.getType().getName()));
- }
- }
-
- public ArrayList<Item> getWert() {
- String value = md.getValue();
- if (value != null) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
- if (i.getValue().equals(value)) {
- i.setIsSelected(true);
- } else {
- i.setIsSelected(false);
- }
- }
- }
- return myValues.get(Modes.getBindState().getTitle()).getItemList();
- }
-
- public void setWert(String inWert) {
- md.setValue(inWert.trim());
- }
-
-
-
- public String getTyp() {
- String label = md.getType().getLanguage((String) Helper
- .getManagedBeanValue("#{LoginForm.myBenutzer.metadatenSprache}"));
- if (label == null) {
- label = md.getType().getName();
- }
- return label;
- }
-
- public void setTyp(String inTyp) {
- MetadataType mdt = myPrefs.getMetadataTypeByName(inTyp);
- md.setType(mdt);
- }
-
- /*#####################################################
- #####################################################
- ##
- ## Getter und Setter
- ##
- #####################################################
- ####################################################*/
-
- public int getIdentifier() {
- return identifier;
- }
-
- public void setIdentifier(int identifier) {
- this.identifier = identifier;
- }
-
- public Metadata getMd() {
- return md;
- }
-
- public void setMd(Metadata md) {
- this.md = md;
- }
-
- /******************************************************
- *
- * new functions for use of display configuration
- * whithin xml files
- *
- *****************************************************/
-
-
-
- public String getOutputType() {
- return myValues.get(Modes.getBindState().getTitle()).getDisplayType().getTitle();
- }
-
-
-
- public List<SelectItem> getItems() {
- items = new ArrayList<SelectItem>();
- selectedItems = new ArrayList<String>();
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- items.add(new SelectItem(i.getLabel()));
- if (i.getIsSelected()) {
- selectedItems.add(i.getLabel());
- }
- }
- return items;
- }
-
- public void setItems(List<SelectItem> items) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- i.setIsSelected(false);
- }
- String val = "";
- for (SelectItem sel : items) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- if (i.getLabel().equals(sel.getValue())) {
- i.setIsSelected(true);
- val += i.getValue();
- }
- }
- }
- setWert(val);
- }
-
-
-
-
- public List<String> getSelectedItems() {
- selectedItems = new ArrayList<String>();
- String values = md.getValue();
- while (values != null && values != "" && values.length() != 0) {
- int semicolon = values.indexOf(";");
- if (semicolon != -1) {
- String value = values.substring(0, semicolon);
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
- if (i.getValue().equals(value)){
- selectedItems.add(i.getLabel());
- i.setIsSelected(true);
- }
- }
- int length = values.length();
- values = values.substring(semicolon+1, length);
- } else {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
- if (i.getValue().equals(values)){
- selectedItems.add(i.getLabel());
- i.setIsSelected(true);
- }
- }
- values = "";
- }
- }
- return selectedItems;
- }
-
-
- public void setSelectedItems(List<String> selectedItems) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- i.setIsSelected(false);
- }
- for (String sel : selectedItems) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- if (i.getLabel().equals(sel)) {
- i.setIsSelected(true);
- }
- }
- }
- String val = "";
- for (Item i :myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- if (i.getIsSelected()) {
- val += i.getValue() + ";";
- }
- }
- setWert(val);
- }
-
-
- public String getSelectedItem() {
- String value = md.getValue();
- if (value != "") {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
- if (i.getValue().equals(value)){
- i.setIsSelected(true);
- return i.getLabel();
- }
- }
- }
- return "";
- }
-
-
- public void setSelectedItem(String selectedItem) {
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
- i.setIsSelected(false);
- }
- for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
- if (i.getLabel().equals(selectedItem)) {
- setWert(i.getValue());
- }
- }
- }
-
- public void setValue(String value) {
- setWert(value);
- }
-
-
-
- public String getValue(){
- return md.getValue();
- }
-
-}
+
+public interface Metadatum {
+
+ public abstract ArrayList<Item> getWert();
+
+ public abstract void setWert(String inWert);
+
+ public abstract String getTyp();
+
+ public abstract void setTyp(String inTyp);
+
+ public abstract int getIdentifier();
+
+ public abstract void setIdentifier(int identifier);
+
+ public abstract Metadata getMd();
+
+ public abstract void setMd(Metadata md);
+
+ /******************************************************
+ *
+ * new functions for use of display configuration
+ * whithin xml files
+ *
+ *****************************************************/
+
+ public abstract String getOutputType();
+
+ public abstract List<SelectItem> getItems();
+
+ public abstract void setItems(List<SelectItem> items);
+
+ public abstract List<String> getSelectedItems();
+
+ public abstract void setSelectedItems(List<String> selectedItems);
+
+ public abstract String getSelectedItem();
+
+ public abstract void setSelectedItem(String selectedItem);
+
+ public abstract void setValue(String value);
+
+ public abstract String getValue();
+
+}
\ No newline at end of file
=== added file 'src/de/sub/goobi/metadaten/MetadatumImpl.java'
--- src/de/sub/goobi/metadaten/MetadatumImpl.java 1970-01-01 00:00:00 +0000
+++ src/de/sub/goobi/metadaten/MetadatumImpl.java 2012-02-21 09:13:40 +0000
@@ -0,0 +1,265 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ * - http://gdz.sub.uni-goettingen.de
+ * - http://www.goobi.org
+ * - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package de.sub.goobi.metadaten;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.faces.model.SelectItem;
+
+import org.goobi.api.display.DisplayCase;
+import org.goobi.api.display.Item;
+import org.goobi.api.display.Modes;
+import org.goobi.api.display.enums.BindState;
+
+import ugh.dl.Metadata;
+import ugh.dl.MetadataType;
+import ugh.dl.Prefs;
+import de.sub.goobi.beans.Prozess;
+import de.sub.goobi.helper.Helper;
+
+//TODO: Use a correct comment here
+/**
+ * Die Klasse Schritt ist ein Bean für einen einzelnen Schritt
+ * mit dessen Eigenschaften und erlaubt die Bearbeitung
+ * der Schrittdetails
+ *
+ * @author Steffen Hankiewicz
+ * @version 1.00 - 10.01.2005
+ */
+
+
+public class MetadatumImpl implements Metadatum {
+ private Metadata md;
+ private int identifier;
+ private Prefs myPrefs;
+ private Prozess myProcess;
+ private HashMap<String, DisplayCase> myValues = new HashMap<String, DisplayCase>();
+ private List<SelectItem> items;
+ private List<String> selectedItems;
+
+
+ /**
+ * Allgemeiner Konstruktor ()
+ */
+ public MetadatumImpl(Metadata m, int inID, Prefs inPrefs, Prozess inProcess) {
+ md = m;
+ identifier = inID;
+ myPrefs = inPrefs;
+ myProcess = inProcess;
+ for (BindState state : BindState.values()) {
+ myValues.put(state.getTitle(), new DisplayCase(myProcess, state.getTitle(), md.getType().getName()));
+ }
+ }
+
+ public ArrayList<Item> getWert() {
+ String value = md.getValue();
+ if (value != null) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
+ if (i.getValue().equals(value)) {
+ i.setIsSelected(true);
+ } else {
+ i.setIsSelected(false);
+ }
+ }
+ }
+ return myValues.get(Modes.getBindState().getTitle()).getItemList();
+ }
+
+ public void setWert(String inWert) {
+ md.setValue(inWert.trim());
+ }
+
+
+
+ public String getTyp() {
+ String label = md.getType().getLanguage((String) Helper
+ .getManagedBeanValue("#{LoginForm.myBenutzer.metadatenSprache}"));
+ if (label == null) {
+ label = md.getType().getName();
+ }
+ return label;
+ }
+
+ public void setTyp(String inTyp) {
+ MetadataType mdt = myPrefs.getMetadataTypeByName(inTyp);
+ md.setType(mdt);
+ }
+
+ /*#####################################################
+ #####################################################
+ ##
+ ## Getter und Setter
+ ##
+ #####################################################
+ ####################################################*/
+
+ public int getIdentifier() {
+ return identifier;
+ }
+
+ public void setIdentifier(int identifier) {
+ this.identifier = identifier;
+ }
+
+ public Metadata getMd() {
+ return md;
+ }
+
+ public void setMd(Metadata md) {
+ this.md = md;
+ }
+
+ /******************************************************
+ *
+ * new functions for use of display configuration
+ * whithin xml files
+ *
+ *****************************************************/
+
+
+
+ public String getOutputType() {
+ return myValues.get(Modes.getBindState().getTitle()).getDisplayType().getTitle();
+ }
+
+
+
+ public List<SelectItem> getItems() {
+ items = new ArrayList<SelectItem>();
+ selectedItems = new ArrayList<String>();
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ items.add(new SelectItem(i.getLabel()));
+ if (i.getIsSelected()) {
+ selectedItems.add(i.getLabel());
+ }
+ }
+ return items;
+ }
+
+ public void setItems(List<SelectItem> items) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ i.setIsSelected(false);
+ }
+ String val = "";
+ for (SelectItem sel : items) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ if (i.getLabel().equals(sel.getValue())) {
+ i.setIsSelected(true);
+ val += i.getValue();
+ }
+ }
+ }
+ setWert(val);
+ }
+
+
+
+
+ public List<String> getSelectedItems() {
+ selectedItems = new ArrayList<String>();
+ String values = md.getValue();
+ while (values != null && values != "" && values.length() != 0) {
+ int semicolon = values.indexOf(";");
+ if (semicolon != -1) {
+ String value = values.substring(0, semicolon);
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
+ if (i.getValue().equals(value)){
+ selectedItems.add(i.getLabel());
+ i.setIsSelected(true);
+ }
+ }
+ int length = values.length();
+ values = values.substring(semicolon+1, length);
+ } else {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
+ if (i.getValue().equals(values)){
+ selectedItems.add(i.getLabel());
+ i.setIsSelected(true);
+ }
+ }
+ values = "";
+ }
+ }
+ return selectedItems;
+ }
+
+
+ public void setSelectedItems(List<String> selectedItems) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ i.setIsSelected(false);
+ }
+ for (String sel : selectedItems) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ if (i.getLabel().equals(sel)) {
+ i.setIsSelected(true);
+ }
+ }
+ }
+ String val = "";
+ for (Item i :myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ if (i.getIsSelected()) {
+ val += i.getValue() + ";";
+ }
+ }
+ setWert(val);
+ }
+
+
+ public String getSelectedItem() {
+ String value = md.getValue();
+ if (value != "") {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
+ if (i.getValue().equals(value)){
+ i.setIsSelected(true);
+ return i.getLabel();
+ }
+ }
+ }
+ return "";
+ }
+
+
+ public void setSelectedItem(String selectedItem) {
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()){
+ i.setIsSelected(false);
+ }
+ for (Item i : myValues.get(Modes.getBindState().getTitle()).getItemList()) {
+ if (i.getLabel().equals(selectedItem)) {
+ setWert(i.getValue());
+ }
+ }
+ }
+
+ public void setValue(String value) {
+ setWert(value);
+ }
+
+
+
+ public String getValue(){
+ return md.getValue();
+ }
+
+}
=== removed file 'src/de/sub/goobi/metadaten/Pagination.java'
--- src/de/sub/goobi/metadaten/Pagination.java 2012-01-10 16:21:09 +0000
+++ src/de/sub/goobi/metadaten/Pagination.java 1970-01-01 00:00:00 +0000
@@ -1,374 +0,0 @@
-/*
- * This file is part of the Goobi Application - a Workflow tool for the support of
- * mass digitization.
- *
- * Visit the websites for more information.
- * - http://gdz.sub.uni-goettingen.de
- * - http://www.goobi.org
- * - http://launchpad.net/goobi-production
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA 02111-1307 USA
- */
-
-package de.sub.goobi.metadaten;
-
-import ugh.dl.RomanNumeral;
-import de.sub.goobi.helper.Helper;
-
-public class Pagination {
-
- /**
- * 1, 2, 3, ..
- */
- public static final String PAGINATION_ARABIC = "1";
-
- /**
- * i, ii, iii, iv,...
- */
- public static final String PAGINATION_ROMAN = "2";
-
- /**
- * " ", "uncounted", "-", etc
- */
-
- public static final String PAGINATION_UNCOUNTED = "3";
-
- /**
- * [1], [2], [3], ...
- */
- public static final String PAGINATION_ARABIC_BRACKET = "4";
-
- /**
- * [i], [ii], [iii], [iv],...
- */
- public static final String PAGINATION_ROMAN_BRACKET = "5";
-
- public static final int ALL_PAGES = 1;
-
- public static final int SELECTED_PAGES = 2;
-
- public static final int COUNTING_PAGINATION = 1;
-
- public static final int COUNTING_COLUMNS = 2;
-
- public static final int COUNTING_FOLIATION = 3;
-
- public static final int COUNTING_FOLIATION_RECTOVERSO = 4;
-
- public static final int COUNTING_PAGINATION_RECTOVERSO = 5;
-
- private String[] allSelectedPages;
-
- private Metadatum[] newPaginated;
-
- private int paginationMode;
-
- private int paginationScope;
-
- private String paginationStartValue;
-
- private String paginationType;
-
- /**
- * Consturctor
- *
- * @param allSelectedPages
- * selected pages as string
- * @param newPaginated
- * metadata of physical DocStrct 'BoundBook'
- * @param paginationScope
- * scope of pagination ( all pages = 1,only selected pages = 2)
- * @param paginationType
- * type of pagination label (arabic = 1, roman = 2, uncounted = 3)
- * @param paginationMode
- * type of pagination (pages = 1, columns = 2, foliation = 3, foliation rectoVerso = 4, pagination rectoVerso = 5)
- * @param paginationStartValue
- * start value
- */
-
- public Pagination(String[] allSelectedPages, Metadatum[] newPaginated, int paginationScope, String paginationType, int paginationMode,
- String paginationStartValue) {
- this.allSelectedPages = allSelectedPages;
- this.newPaginated = newPaginated;
- this.paginationScope = paginationScope;
- this.paginationType = paginationType;
- this.paginationMode = paginationMode;
- this.paginationStartValue = paginationStartValue;
- }
-
- /**
- * creates pagination for scope
- *
- * @return
- */
-
- public String doPagination() {
-
- // return on empty selection or invalid pagination start value
- if (isSelectionEmpty() || !isValidPaginationStartValue()) {
- return null;
- }
-
- // return and set error message when 'uncounted' and 'foliation' selected as options
- if ((paginationMode == COUNTING_FOLIATION_RECTOVERSO) && (paginationType.equals(PAGINATION_UNCOUNTED))) {
- Helper.setFehlerMeldung("pagination.error.uncountedFoliationNotAllowed");
- return null;
- }
-
- // set "uncounted" pagination value
- if (paginationType.equals(PAGINATION_UNCOUNTED)) {
- paginationStartValue = "uncounted";
- }
-
- // set all selected pages to start value
- if (paginationScope == SELECTED_PAGES) {
- setSelectedPagesToPaginationStartValue();
- return null;
- }
-
- // determining first page number
- int firstPageNumber = Integer.parseInt(allSelectedPages[0]);
-
- // determine pagination base
- int paginationBaseValue = getPaginationBaseValue();
-
- double currentPageNumber = firstPageNumber;
-
- for (int i = firstPageNumber; i < newPaginated.length; i++) {
- String nextPaginationLabel = "";
- if (paginationMode == COUNTING_FOLIATION_RECTOVERSO || paginationMode == COUNTING_PAGINATION_RECTOVERSO) {
- nextPaginationLabel = getNextPaginationLabel(firstPageNumber, paginationBaseValue, currentPageNumber);
- } else {
- nextPaginationLabel = getNextPaginationLabel(firstPageNumber, paginationBaseValue, currentPageNumber);
- }
-
- if (paginationMode == COUNTING_FOLIATION_RECTOVERSO) {
- nextPaginationLabel = getRectoVersoSuffixForFoliation(Integer.valueOf(nextPaginationLabel));
- }
- if (paginationMode == COUNTING_PAGINATION_RECTOVERSO) {
- if (paginationType.equals(PAGINATION_UNCOUNTED)) {
- nextPaginationLabel = getRectoVersoSuffixForPagination(currentPageNumber);
- } else {
- nextPaginationLabel += getRectoVersoSuffixForPagination(currentPageNumber);
- }
- }
-
- newPaginated[i].setWert(nextPaginationLabel);
-
- currentPageNumber = getNextPageNumber(currentPageNumber);
- }
-
- return "";
- }
-
- private String getNextPaginationLabel(int firstPageNumber, int paginationBaseValue, double currentPageNumber) {
- String actualPaginationLabel;
- if (paginationType.equals(PAGINATION_ARABIC)) {
- actualPaginationLabel = String.valueOf(paginationBaseValue + (int) currentPageNumber - firstPageNumber);
- } else if (paginationType.equals(PAGINATION_ROMAN)) {
- RomanNumeral r = new RomanNumeral();
- r.setValue(paginationBaseValue + (int) currentPageNumber - firstPageNumber);
- actualPaginationLabel = r.toString();
- } else if (paginationType.equals(PAGINATION_ARABIC_BRACKET)) {
- actualPaginationLabel = String.valueOf(paginationBaseValue + (int) currentPageNumber - firstPageNumber);
- actualPaginationLabel = "[" + actualPaginationLabel + "]";
- } else if (paginationType.equals(PAGINATION_ROMAN_BRACKET)) {
- RomanNumeral r = new RomanNumeral();
- r.setValue(paginationBaseValue + (int) currentPageNumber - firstPageNumber);
- actualPaginationLabel = "[" + r.toString() + "]";
- } else {
- actualPaginationLabel = paginationStartValue;
- }
-
- return actualPaginationLabel;
- }
-
- private String getRectoVersoSuffixForFoliation(int imageNumber) {
- return imageNumber + "v " + (imageNumber + 1) + "r";
- }
-
- private String getRectoVersoSuffixForPagination(double number) {
- if (((number * 2) % 2) == 0) {
- return "r";
- } else {
- return "v";
- }
- }
-
- private double getNextPageNumber(double currentPageNumber) {
- switch (paginationMode) {
- case COUNTING_PAGINATION:
- case COUNTING_FOLIATION_RECTOVERSO:
- currentPageNumber++;
- break;
- case COUNTING_COLUMNS:
- currentPageNumber = currentPageNumber + 2;
- break;
- case COUNTING_FOLIATION:
- case COUNTING_PAGINATION_RECTOVERSO:
- currentPageNumber = currentPageNumber + 0.5;
- break;
- }
- return currentPageNumber;
- }
-
- private int getPaginationBaseValue() {
-
- int paginationBaseValue = 1;
-
- if (paginationType.equals(PAGINATION_ARABIC) || paginationType.equals(PAGINATION_ARABIC_BRACKET)) {
- paginationBaseValue = Integer.parseInt(paginationStartValue);
- } else if (paginationType.equals(PAGINATION_ROMAN) || paginationType.equals(PAGINATION_ROMAN_BRACKET)) {
- RomanNumeral r = new RomanNumeral();
- r.setValue(paginationStartValue);
- paginationBaseValue = r.intValue();
- }
-
- return paginationBaseValue;
-
- }
-
- public String[] getAllSelectedPages() {
- return allSelectedPages;
- }
-
- public Metadatum[] getNewPaginated() {
- return newPaginated;
- }
-
- public int getPaginationMode() {
- return paginationMode;
- }
-
- public int getPaginationScope() {
- return paginationScope;
- }
-
- public String getPaginationStartValue() {
- return paginationStartValue;
- }
-
- public String getPaginationType() {
- return paginationType;
- }
-
- private boolean isSelectionEmpty() {
- return allSelectedPages == null || allSelectedPages.length == 0;
- }
-
- private boolean isValidArabicNumber() {
- try {
- Integer.parseInt(paginationStartValue);
- return true;
- } catch (NumberFormatException nfe) {
- Helper.setFehlerMeldung("fehlerBeimEinlesen", nfe.getMessage());
- return false;
- }
- }
-
- private boolean isValidPaginationStartValue() {
- // arabic numbers
- if (paginationType.equals(PAGINATION_ARABIC)) {
- return isValidArabicNumber();
- }
-
- // roman numbers
- if (paginationType.equals(PAGINATION_ROMAN)) {
- return isValidRomanNumber();
- }
-
- return true;
- }
-
- private boolean isValidRomanNumber() {
- try {
- RomanNumeral roman = new RomanNumeral();
- paginationStartValue = paginationStartValue.toUpperCase();
- roman.setValue(paginationStartValue);
- return true;
- } catch (NumberFormatException nfe) {
- Helper.setFehlerMeldung("fehlerBeimEinlesen", nfe.getMessage());
- return false;
- }
- }
-
- public void setAllSelectedPages(String[] selectedPages) {
- this.allSelectedPages = selectedPages;
-
- }
-
- public void setNewPaginated(Metadatum[] newPaginated) {
- this.newPaginated = newPaginated;
-
- }
-
- public void setPaginationMode(int numberOfPagesPerImage) {
- this.paginationMode = numberOfPagesPerImage;
-
- }
-
- public void setPaginationScope(int paginationScope) {
- this.paginationScope = paginationScope;
-
- }
-
- public void setPaginationStartValue(String paginationStartValue) {
- this.paginationStartValue = paginationStartValue;
-
- }
-
- public void setPaginationType(String paginationType) {
- this.paginationType = paginationType;
-
- }
-
- private void setSelectedPagesToPaginationStartValue() {
- int firstPageNumber = Integer.parseInt(allSelectedPages[0]);
- int paginationBaseValue = getPaginationBaseValue();
- double currentPageNumber = firstPageNumber;
-
- if (paginationMode == COUNTING_PAGINATION_RECTOVERSO) {
- currentPageNumber = currentPageNumber + 0.5;
- }
-
- for (int i = 0; i < allSelectedPages.length; i++) {
- int aktuelleID = Integer.parseInt(allSelectedPages[i]);
- String nextPaginationLabel = "";
- if (paginationMode == COUNTING_FOLIATION_RECTOVERSO || paginationMode == COUNTING_PAGINATION_RECTOVERSO) {
- nextPaginationLabel = getNextPaginationLabel(firstPageNumber, paginationBaseValue, currentPageNumber);
- } else {
- nextPaginationLabel = getNextPaginationLabel(firstPageNumber, paginationBaseValue, currentPageNumber);
- }
-
- if (paginationMode == COUNTING_FOLIATION_RECTOVERSO) {
- // if (paginationType.equals(PAGINATION_UNCOUNTED)) {
- // if (i == 1) {
- nextPaginationLabel = getRectoVersoSuffixForFoliation(Integer.valueOf(nextPaginationLabel));
- // } else {
- // nextPaginationLabel = getRectoVersoSuffixForFoliation(i + 1);
- // }
- }
- if (paginationMode == COUNTING_PAGINATION_RECTOVERSO) {
- if (paginationType.equals(PAGINATION_UNCOUNTED)) {
- nextPaginationLabel = getRectoVersoSuffixForPagination(currentPageNumber);
- } else {
- nextPaginationLabel += getRectoVersoSuffixForPagination(currentPageNumber);
- }
- }
- newPaginated[aktuelleID].setWert(nextPaginationLabel);
-
- currentPageNumber = getNextPageNumber(currentPageNumber);
- }
- }
-
-}
=== added file 'src/de/sub/goobi/metadaten/Paginator.java'
--- src/de/sub/goobi/metadaten/Paginator.java 1970-01-01 00:00:00 +0000
+++ src/de/sub/goobi/metadaten/Paginator.java 2012-02-21 09:13:40 +0000
@@ -0,0 +1,340 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ * - http://gdz.sub.uni-goettingen.de
+ * - http://www.goobi.org
+ * - http://launchpad.net/goobi-production
+ *
+ * Copyright 2011, Center for Retrospective Digitization, Göttingen (GDZ),
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package de.sub.goobi.metadaten;
+
+import org.goobi.pagination.IntegerSequence;
+import org.goobi.pagination.RomanNumberSequence;
+import ugh.dl.RomanNumeral;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Sets new labels to a given set of pages.
+ */
+public class Paginator {
+
+ public enum Mode {
+ PAGES, COLUMNS, FOLIATION, RECTOVERSO_FOLIATION, RECTOVERSO
+ }
+
+ public enum Type {ARABIC, ROMAN, UNCOUNTED}
+
+ public enum Scope {FROMFIRST, SELECTED}
+
+ private int[] selectedPages;
+
+ private Metadatum[] pagesToPaginate;
+
+ private Mode paginationMode = Paginator.Mode.PAGES;
+
+ private Scope paginationScope = Paginator.Scope.FROMFIRST;
+
+ private String paginationStartValue = "uncounted";
+
+ private Type paginationType = Paginator.Type.UNCOUNTED;
+
+ private boolean fictitiousPagination = false;
+
+ /**
+ * Perform pagination.
+ *
+ * @throws IllegalArgumentException Thrown if invalid config parameters have been set.
+ */
+ public void run() throws IllegalArgumentException {
+
+ assertSelectionIsNotNull();
+ assertValidPaginationStartValue();
+
+ List sequence = createPaginationSequence();
+
+ applyPaginationSequence(sequence);
+
+ }
+
+ private void applyPaginationSequence(List sequence) {
+ if (paginationScope == Scope.SELECTED) {
+ applyToSelected(sequence);
+ } else if (paginationScope == Scope.FROMFIRST) {
+ applyFromFirstSelected(sequence);
+ }
+ }
+
+ private void assertSelectionIsNotNull() {
+ if (selectedPages == null || selectedPages.length == 0) {
+ throw new IllegalArgumentException("No pages selected for pagination.");
+ }
+ }
+
+ private void assertValidPaginationStartValue() {
+ // arabic numbers
+ if (paginationType == Paginator.Type.ARABIC) {
+ Integer.parseInt(paginationStartValue);
+ }
+ // roman numbers
+ if (paginationType == Paginator.Type.ROMAN) {
+ RomanNumeral roman = new RomanNumeral();
+ roman.setValue(paginationStartValue);
+ }
+ }
+
+ private List createPaginationSequence() {
+
+ int increment =
+ determineIncrementFromPaginationMode();
+ int start =
+ determinePaginationBaseValue();
+ int end =
+ determinePaginationEndValue(increment, start);
+ List sequence =
+ determineSequenceFromPaginationType(increment, start, end);
+
+ if (fictitiousPagination) {
+ sequence = addSquareBracketsToEachInSequence(sequence);
+ }
+
+ if (paginationMode == Paginator.Mode.FOLIATION) {
+
+ sequence = cloneEachInSequence(sequence);
+
+ } else if (paginationType != Paginator.Type.UNCOUNTED) {
+ if (paginationMode == Paginator.Mode.RECTOVERSO) {
+
+ sequence = addAlternatingRectoVersoSuffixToEachInSequence(sequence);
+
+ } else if (paginationMode == Mode.RECTOVERSO_FOLIATION) {
+
+ sequence = addRectoVersoSuffixToEachInSequence(sequence);
+
+ }
+ }
+
+ return sequence;
+ }
+
+ private List addSquareBracketsToEachInSequence(List sequence) {
+ List<Object> fictitiousSequence = new ArrayList<Object>(sequence.size());
+ for (Object o : sequence) {
+ String newLabel = o.toString();
+ fictitiousSequence.add("[" + newLabel + "]");
+ }
+ return fictitiousSequence;
+ }
+
+ private List addAlternatingRectoVersoSuffixToEachInSequence(List sequence) {
+ List<Object> rectoversoSequence = new ArrayList<Object>(sequence.size() * 2);
+ for (Object o : sequence) {
+ String newLabel = o.toString();
+ rectoversoSequence.add(newLabel + "r");
+ rectoversoSequence.add(newLabel + "v");
+ }
+
+ sequence = rectoversoSequence;
+ return sequence;
+ }
+
+ private List addRectoVersoSuffixToEachInSequence(List sequence) {
+ List<Object> rectoversoSequence = new ArrayList<Object>(sequence.size() * 2);
+ for (Object o : sequence) {
+ String newLabel = o.toString();
+ rectoversoSequence.add(newLabel + "r " + newLabel + "v");
+ }
+
+ sequence = rectoversoSequence;
+ return sequence;
+ }
+
+ private List cloneEachInSequence(List sequence) {
+ List<Object> foliationSequence = new ArrayList<Object>(sequence.size() * 2);
+ for (Object o : sequence) {
+ foliationSequence.add(o);
+ foliationSequence.add(o);
+ }
+
+ sequence = foliationSequence;
+ return sequence;
+ }
+
+ private List determineSequenceFromPaginationType(int increment, int start, int end) {
+ List sequence = null;
+
+ switch (paginationType) {
+ case UNCOUNTED:
+ sequence = new ArrayList(1);
+ sequence.add("uncounted");
+ break;
+ case ROMAN:
+ sequence = new RomanNumberSequence(start, end, increment);
+ break;
+ case ARABIC:
+ sequence = new IntegerSequence(start, end, increment);
+ break;
+ }
+ return sequence;
+ }
+
+ private int determineIncrementFromPaginationMode() {
+ int increment = 1;
+ if (paginationMode == Paginator.Mode.COLUMNS) {
+ increment = 2;
+ }
+ return increment;
+ }
+
+ private int determinePaginationEndValue(int increment, int start) {
+ int numSelectedPages = selectedPages.length;
+ if (paginationScope == Paginator.Scope.FROMFIRST) {
+ int first = selectedPages[0];
+ numSelectedPages = pagesToPaginate.length - first;
+ }
+ return start + numSelectedPages + increment;
+ }
+
+ private void applyFromFirstSelected(List sequence) {
+ int first = selectedPages[0];
+ Iterator seqit = sequence.iterator();
+ for (int pageNum = first; pageNum < pagesToPaginate.length; pageNum++) {
+ if (!seqit.hasNext()) {
+ seqit = sequence.iterator();
+ }
+ pagesToPaginate[pageNum].setWert(String.valueOf(seqit.next()));
+ }
+ }
+
+ private void applyToSelected(List sequence) {
+ Iterator seqit = sequence.iterator();
+ for (int num : selectedPages) {
+ if (!seqit.hasNext()) {
+ seqit = sequence.iterator();
+ }
+ pagesToPaginate[num].setWert(String.valueOf(seqit.next()));
+ }
+ }
+
+ private int determinePaginationBaseValue() {
+
+ int paginationBaseValue = 1;
+
+ if (paginationType == Paginator.Type.ARABIC) {
+ paginationBaseValue = Integer.parseInt(paginationStartValue);
+ } else if (paginationType == Paginator.Type.ROMAN) {
+ RomanNumeral r = new RomanNumeral();
+ r.setValue(paginationStartValue);
+ paginationBaseValue = r.intValue();
+ }
+
+ return paginationBaseValue;
+
+ }
+
+ /**
+ * Get pages provided with new pagination label.
+ *
+ * @return Array of <code>Metadatum</code> instances.
+ */
+ public Metadatum[] getPagesToPaginate() {
+ return pagesToPaginate;
+ }
+
+
+ /**
+ * Give a list of page numbers to select pages to actually paginate.
+ *
+ * @param selectedPages Array numbers, each pointing to a given page set via <code>setPagesToPaginate</code>
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPageSelection(int[] selectedPages) {
+ this.selectedPages = selectedPages;
+ return this;
+ }
+
+ /**
+ * Give page objects to apply new page labels on.
+ *
+ * @param newPaginated Array of page objects.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPagesToPaginate(Metadatum[] newPaginated) {
+ this.pagesToPaginate = newPaginated;
+ return this;
+ }
+
+ /**
+ * Set pagination mode.
+ *
+ * @param paginationMode Mode of counting pages.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPaginationMode(Mode paginationMode) {
+ this.paginationMode = paginationMode;
+ return this;
+ }
+
+ /**
+ * Set scope of pagination.
+ *
+ * @param paginationScope Set which pages from a selection get labeled.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPaginationScope(Scope paginationScope) {
+ this.paginationScope = paginationScope;
+ return this;
+ }
+
+ /**
+ * Set start value of pagination. Counting up starts here depending on the pagination mode set.
+ *
+ * @param paginationStartValue May contain arabic or roman number.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPaginationStartValue(String paginationStartValue) {
+ this.paginationStartValue = paginationStartValue;
+ return this;
+ }
+
+ /**
+ * Determine weather arabic or roman numbers should be used when counting.
+ *
+ * @param paginationType Set style of pagination numbers.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setPaginationType(Type paginationType) {
+ this.paginationType = paginationType;
+ return this;
+ }
+
+ /**
+ * Enable or disable fictitious pagination using square bracktes around numbers.
+ *
+ * @param b True, fictitious pagination. False, regular pagination.
+ * @return This object for fluent interfacing.
+ */
+ public Paginator setFictitious(boolean b) {
+ this.fictitiousPagination = b;
+ return this;
+ }
+
+}
=== modified file 'src/messages/messages_de.properties'
--- src/messages/messages_de.properties 2012-01-10 16:21:09 +0000
+++ src/messages/messages_de.properties 2012-02-21 09:13:40 +0000
@@ -762,4 +762,5 @@
zurueckZurStartseite=Zur\u00FCck zur Startseite
zusaetzlicheDetails=Zus\u00E4tzliche Details
zusammenfassung=Zusammenfassung
-pagination.error.uncountedFoliationNotAllowed=Blattzaehlung ohne Nummerierung nicht erlaubt
\ No newline at end of file
+pagination.error.uncountedFoliationNotAllowed=Blattzaehlung ohne Nummerierung nicht erlaubt
+paginationFictitious=Fiktive Paginierung
\ No newline at end of file
=== modified file 'src/messages/messages_en.properties'
--- src/messages/messages_en.properties 2012-01-10 16:21:09 +0000
+++ src/messages/messages_en.properties 2012-02-21 09:13:40 +0000
@@ -762,4 +762,5 @@
zurueckZurStartseite=Back to start page
zusaetzlicheDetails=Additional details
zusammenfassung=Summary
-pagination.error.uncountedFoliationNotAllowed=Foliation not allowed when using 'uncounted'
\ No newline at end of file
+pagination.error.uncountedFoliationNotAllowed=Foliation not allowed when using 'uncounted'
+paginationFictitious=Fictitious paginating
\ No newline at end of file
=== added directory 'test/src/de/sub/goobi/metadaten'
=== added file 'test/src/de/sub/goobi/metadaten/MockMetadatum.java'
--- test/src/de/sub/goobi/metadaten/MockMetadatum.java 1970-01-01 00:00:00 +0000
+++ test/src/de/sub/goobi/metadaten/MockMetadatum.java 2012-02-21 09:13:40 +0000
@@ -0,0 +1,105 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ * - http://gdz.sub.uni-goettingen.de
+ * - http://www.goobi.org
+ * - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package de.sub.goobi.metadaten;
+
+import org.goobi.api.display.Item;
+import ugh.dl.Metadata;
+
+import javax.faces.model.SelectItem;
+import java.util.ArrayList;
+import java.util.List;
+
+class MockMetadatum implements Metadatum {
+
+ private String value;
+
+
+ public MockMetadatum() {
+ }
+
+ public MockMetadatum(String value) {
+ this.value = value;
+ }
+
+ public int getIdentifier() {
+ return 0;
+ }
+
+ public List<SelectItem> getItems() {
+ return null;
+ }
+
+ public Metadata getMd() {
+ return null;
+ }
+
+ public String getOutputType() {
+ return null;
+ }
+
+ public String getSelectedItem() {
+ return null;
+ }
+
+ public List<String> getSelectedItems() {
+ return null;
+ }
+
+ public String getTyp() {
+ return null;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public ArrayList<Item> getWert() {
+ return null;
+ }
+
+ public void setIdentifier(int identifier) {
+ }
+
+ public void setItems(List<SelectItem> items) {
+ }
+
+ public void setMd(Metadata md) {
+ }
+
+ public void setSelectedItem(String selectedItem) {
+ }
+
+ public void setSelectedItems(List<String> selectedItems) {
+ }
+
+ public void setTyp(String inTyp) {
+ }
+
+ public void setValue(String value) {
+ }
+
+ public void setWert(String inWert) {
+ value = inWert;
+ }
+
+}
=== added file 'test/src/de/sub/goobi/metadaten/PaginatorTest.java'
--- test/src/de/sub/goobi/metadaten/PaginatorTest.java 1970-01-01 00:00:00 +0000
+++ test/src/de/sub/goobi/metadaten/PaginatorTest.java 2012-02-21 09:13:40 +0000
@@ -0,0 +1,374 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ * - http://gdz.sub.uni-goettingen.de
+ * - http://www.goobi.org
+ * - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package de.sub.goobi.metadaten;
+
+import org.junit.Test;
+import org.junit.internal.ArrayComparisonFailure;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class PaginatorTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void throwsExceptionOnEmptyPageSelection() {
+ Paginator paginator = new Paginator();
+ paginator.run();
+ }
+
+ @Test(expected = NumberFormatException.class)
+ public void throwsExceptionWhenCalledWithInvalidStartValue() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{1, 2})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("II");
+ paginator.run();
+ }
+
+ @Test
+ public void setsSelectedPagesToUncounted() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0, 1, 2})
+ .setPaginationType(Paginator.Type.UNCOUNTED)
+ .setPaginationScope(Paginator.Scope.SELECTED)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertAllPagenumbersSetToValue(paginator, "uncounted");
+ }
+
+ @Test
+ public void setsSelectedPagesToUncountedNoMatterWhatStartValueIsGiven() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0, 1, 2})
+ .setPaginationType(Paginator.Type.UNCOUNTED)
+ .setPaginationScope(Paginator.Scope.SELECTED)
+ .setPaginationStartValue("Foo")
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertAllPagenumbersSetToValue(paginator, "uncounted");
+ }
+
+ @Test
+ public void setsAllPagesToUncounted() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.UNCOUNTED)
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertAllPagenumbersSetToValue(paginator, "uncounted");
+ }
+
+ @Test
+ public void setsPagesToSequenceOfArabicNumbers() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("50")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.PAGES)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"50", "51", "52"});
+ }
+
+ @Test
+ public void setsPagesToSequenceOfRomanNumbers() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ROMAN)
+ .setPaginationStartValue("II")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.PAGES)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"II", "III", "IV"});
+ }
+
+ @Test
+ public void paginateCountingColumns() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.COLUMNS)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"1", "3", "5"});
+ }
+
+ @Test
+ public void paginateUsingFoliation() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.FOLIATION)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"1", "1", "2", "2"});
+ }
+
+ @Test
+ public void paginateRectoVersoFoliation() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0, 1, 2, 3})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.SELECTED)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"1r", "1v", "2r", "2v"});
+ }
+
+ @Test
+ public void setsAllToUncountedWhenRectoVersoFoliationModeAndTypeUncounted() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.UNCOUNTED)
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertAllPagenumbersSetToValue(paginator, "uncounted");
+ }
+
+ @Test
+ public void rectoVersoPaginationShouldStartWithRectoOnSkippedPages() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{1, 2, 3})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationScope(Paginator.Scope.SELECTED)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO)
+ .setPaginationStartValue("1");
+ paginator.setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum("uncounted"),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"uncounted", "1r", "1v", "2r"});
+ }
+
+ @Test
+ public void fictitiousArabicPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("50")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.PAGES)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[50]", "[51]", "[52]"});
+ }
+
+ @Test
+ public void fictitiousArabicRectoVersoPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("4711")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[4711]r", "[4711]v", "[4712]r", "[4712]v"});
+ }
+
+ @Test
+ public void fictitiousRomanNumberPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ROMAN)
+ .setPaginationStartValue("III")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.PAGES)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[III]", "[IV]", "[V]"});
+ }
+
+ @Test
+ public void fictitiousPaginationUsingFoliation() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.FOLIATION)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[1]", "[1]", "[2]", "[2]"});
+ }
+
+ @Test
+ public void rectoVersoPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO_FOLIATION)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"1r 1v", "2r 2v", "3r 3v"});
+ }
+
+ @Test
+ public void fictitiousRectoVersoPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ARABIC)
+ .setPaginationStartValue("1")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO_FOLIATION)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[1]r [1]v", "[2]r [2]v", "[3]r [3]v"});
+ }
+
+ @Test
+ public void fictitiousRomanRectoVersoPagination() {
+ Paginator paginator = new Paginator()
+ .setPageSelection(new int[]{0})
+ .setPaginationType(Paginator.Type.ROMAN)
+ .setPaginationStartValue("XX")
+ .setPaginationScope(Paginator.Scope.FROMFIRST)
+ .setPaginationMode(Paginator.Mode.RECTOVERSO_FOLIATION)
+ .setFictitious(true)
+ .setPagesToPaginate(new Metadatum[]{
+ new MockMetadatum(),
+ new MockMetadatum(),
+ new MockMetadatum()
+ });
+ paginator.run();
+ assertPagenumberSequence(paginator, new String[]{"[XX]r [XX]v", "[XXI]r [XXI]v", "[XXII]r [XXII]v"});
+ }
+
+ private void assertPagenumberSequence(Paginator paginator,
+ String[] sequence) {
+
+ Metadatum[] newPaginated = paginator.getPagesToPaginate();
+
+ assertNotNull("Expected paginator result set.", newPaginated);
+
+ assertEquals("Unexpected number of paginated pages.", sequence.length,
+ newPaginated.length);
+
+ for (int i = 0; i < sequence.length; i++) {
+ assertEquals("Actual paginator value did not match expected.",
+ sequence[i], newPaginated[i].getValue());
+ }
+
+ }
+
+ private void assertAllPagenumbersSetToValue(Paginator paginator,
+ String expectedValue) throws ArrayComparisonFailure {
+
+ Metadatum[] newPaginated = paginator.getPagesToPaginate();
+
+ assertNotNull("Expected paginator result set.", newPaginated);
+
+ for (Metadatum m : newPaginated) {
+ assertEquals("Actual paginator value did not match expected.",
+ expectedValue, m.getValue());
+ }
+
+ }
+
+}
Follow ups