Skip to content

Commit

Permalink
Merge branch 'matthias-ronge-issue_286' into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
henning-gerhardt committed Mar 20, 2015
2 parents 9acc778 + 95d15ec commit e51daad
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 18 deletions.
Binary file modified Goobi/WEB-INF/lib/ugh-1.10.jar
Binary file not shown.
13 changes: 12 additions & 1 deletion Goobi/src/de/sub/goobi/helper/ScriptThreadWithoutHibernate.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
import org.goobi.production.plugin.interfaces.IStepPlugin;

import de.sub.goobi.helper.tasks.EmptyTask;
import de.sub.goobi.helper.tasks.INameableTask;
import de.sub.goobi.persistence.apache.MySQLHelper;
import de.sub.goobi.persistence.apache.StepManager;
import de.sub.goobi.persistence.apache.StepObject;

public class ScriptThreadWithoutHibernate extends EmptyTask {
public class ScriptThreadWithoutHibernate extends EmptyTask implements INameableTask {
HelperSchritteWithoutHibernate hs = new HelperSchritteWithoutHibernate();
private final StepObject step;
private static final Logger logger = Logger.getLogger(ScriptThreadWithoutHibernate.class);
Expand Down Expand Up @@ -92,6 +93,16 @@ public ScriptThreadWithoutHibernate(ScriptThreadWithoutHibernate origin) {
hs.setTask(this);
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ScriptThreadWithoutHibernate");
}

@Override
public void run() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
*
* @author Matthias Ronge <[email protected]>
*/
public class CreateNewspaperProcessesTask extends EmptyTask {
public class CreateNewspaperProcessesTask extends EmptyTask implements INameableTask {

/**
* The field batchLabel is set in addToBatches() on the first function call
Expand Down Expand Up @@ -451,6 +451,16 @@ private void flushLogisticsBatch(String processTitle) throws DAOException {
batchLabel = null;
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("CreateNewspaperProcessesTask");
}

/**
* The method saveFullBatch() sets the title for the allover batch and saves
* it to hibernate.
Expand Down Expand Up @@ -498,4 +508,5 @@ private String firstGroupFrom(String s) {
public CreateNewspaperProcessesTask clone() {
return new CreateNewspaperProcessesTask(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,13 @@ public CreatePdfFromServletThread clone() {
return new CreatePdfFromServletThread(this);
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("CreatePdfFromServletThread");
}
}
14 changes: 12 additions & 2 deletions Goobi/src/de/sub/goobi/helper/tasks/EmptyTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*
* @author Matthias Ronge <[email protected]>
*/
public class EmptyTask extends Thread implements Cloneable {
public class EmptyTask extends Thread implements Cloneable, INameableTask {
/**
* The enum Actions lists the available instructions to the housekeeper what
* to do with a terminated thread. These are:
Expand Down Expand Up @@ -209,6 +209,16 @@ Behaviour getBehaviour() {
return behaviour;
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("EmptyTask");
}

/**
* The function getDurationDead() returns the duration the task is dead. If
* a time of death has not yet been recorded, null is returned.
Expand Down Expand Up @@ -457,7 +467,7 @@ public void setException(Throwable exception) {
*/
protected void setNameDetail(String detail) {
StringBuilder composer = new StringBuilder(119);
composer.append(Helper.getTranslation(getClass().getSimpleName()));
composer.append(((INameableTask) this).getDisplayName());
if (detail != null) {
composer.append(": ");
composer.append(detail);
Expand Down
13 changes: 12 additions & 1 deletion Goobi/src/de/sub/goobi/helper/tasks/ExportDmsTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

import de.sub.goobi.beans.Prozess;
import de.sub.goobi.export.dms.ExportDms;
import de.sub.goobi.helper.Helper;

/**
* The class ExportDmsTask accepts an {@link de.sub.goobi.export.dms.ExportDms}
Expand All @@ -49,7 +50,7 @@
*
* @author Matthias Ronge <[email protected]>
*/
public class ExportDmsTask extends EmptyTask {
public class ExportDmsTask extends EmptyTask implements INameableTask {

private final ExportDms exportDms;
private final Prozess process;
Expand Down Expand Up @@ -86,6 +87,16 @@ private ExportDmsTask(ExportDmsTask source) {
this.userHome = source.userHome;
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ExportDmsTask");
}

/**
* If the task is started, it will execute this run() method which will
* start the export on the ExportDms. This task instance is passed in
Expand Down
34 changes: 24 additions & 10 deletions Goobi/src/de/sub/goobi/helper/tasks/ExportNewspaperBatchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@
import de.sub.goobi.export.dms.ExportDms;
import de.sub.goobi.forms.LoginForm;
import de.sub.goobi.helper.ArrayListMap;
import de.sub.goobi.helper.Helper;
import de.sub.goobi.helper.VariableReplacer;
import de.sub.goobi.helper.exceptions.DAOException;
import de.sub.goobi.helper.exceptions.SwapException;

public class ExportNewspaperBatchTask extends EmptyTask {
public class ExportNewspaperBatchTask extends EmptyTask implements INameableTask {
private static final Logger logger = Logger.getLogger(ExportNewspaperBatchTask.class);

private static final double GAUGE_INCREMENT_PER_ACTION = 100 / 3d;
Expand Down Expand Up @@ -250,7 +251,7 @@ public void run() {
if (isInterrupted()) {
return;
}
MetsModsImportExport extendedData = buildExportableMetsMods(process = processesIterator.next(),
MetsMods extendedData = buildExportableMetsMods(process = processesIterator.next(),
collectedYears, aggregation);
setProgress(GAUGE_INCREMENT_PER_ACTION + ++dividend / divisor);

Expand Down Expand Up @@ -438,6 +439,16 @@ private static <T> List<T> skipIfNull(List<T> list) {
return list;
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ExportNewspaperBatchTask");
}

/**
* The function getMetsPointerURL() investigates the METS pointer URL of the
* process.
Expand Down Expand Up @@ -511,14 +522,14 @@ static String getMetsPointerURL(Prozess process) throws PreferencesException, Re
* if a child should be added, but it's DocStruct type isn't
* member of this instance's DocStruct type
*/
private MetsModsImportExport buildExportableMetsMods(Prozess process, HashMap<Integer, String> years,
private MetsMods buildExportableMetsMods(Prozess process, HashMap<Integer, String> years,
ArrayListMap<LocalDate, String> issues) throws PreferencesException, ReadException, SwapException,
DAOException, IOException, InterruptedException, TypeNotAllowedForParentException,
MetadataTypeNotAllowedException, TypeNotAllowedAsChildException {

Prefs ruleSet = process.getRegelsatz().getPreferences();
MetsModsImportExport result = new MetsModsImportExport(ruleSet);
((MetsMods) result).read(process.getMetadataFilePath());
MetsMods result = new MetsMods(ruleSet);
result.read(process.getMetadataFilePath());

DigitalDocument caudexDigitalis = result.getDigitalDocument();
int ownYear = getMetadataIntValueByName(caudexDigitalis.getLogicalDocStruct().getAllChildren().iterator()
Expand Down Expand Up @@ -559,7 +570,8 @@ private void insertReferencesToYears(HashMap<Integer, String> years, int ownYear
for (Integer year : years.keySet()) {
if (year.intValue() != ownYear) {
DocStruct child = getOrCreateChild(act.getLogicalDocStruct(), yearLevelName,
MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, year.toString(), null, act, ruleSet);
MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, year.toString(),
MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, act, ruleSet);
child.addMetadata(MetsModsImportExport.CREATE_MPTR_ELEMENT_TYPE, years.get(year));
}
}
Expand All @@ -579,8 +591,8 @@ private void insertReferencesToYears(HashMap<Integer, String> years, int ownYear
* @param identifier
* value that identifies the DocStruct to return
* @param optionalField
* optionally, adds another meta data field with this name and
* the value used as identifier (may be null)
* adds another meta data field with this name and the value used
* as identifier if the metadata type is allowed
* @param act
* act to create the child in
* @param ruleset
Expand All @@ -605,8 +617,9 @@ private static DocStruct getOrCreateChild(DocStruct parent, String type, String
} catch (NoSuchElementException nose) {
DocStruct child = parent.createChild(type, act, ruleset);
child.addMetadata(identifierField, identifier);
if (optionalField != null) {
try {
child.addMetadata(optionalField, identifier);
} catch (MetadataTypeNotAllowedException e) {
}
return child;
}
Expand Down Expand Up @@ -675,7 +688,8 @@ private void insertReferencesToOtherIssuesInThisYear(ArrayListMap<LocalDate, Str
private void insertIssueReference(DigitalDocument act, Prefs ruleset, LocalDate date, String metsPointerURL)
throws TypeNotAllowedForParentException, TypeNotAllowedAsChildException, MetadataTypeNotAllowedException {
DocStruct year = getOrCreateChild(act.getLogicalDocStruct(), yearLevelName,
MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, Integer.toString(date.getYear()), null, act, ruleset);
MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, Integer.toString(date.getYear()),
MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, act, ruleset);
DocStruct month = getOrCreateChild(year, monthLevelName,
MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, Integer.toString(date.getMonthOfYear()),
MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, act, ruleset);
Expand Down
13 changes: 12 additions & 1 deletion Goobi/src/de/sub/goobi/helper/tasks/ExportSerialBatchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import de.sub.goobi.config.ConfigMain;
import de.sub.goobi.export.dms.ExportDms;
import de.sub.goobi.forms.LoginForm;
import de.sub.goobi.helper.Helper;
import de.sub.goobi.helper.exceptions.DAOException;
import de.sub.goobi.helper.exceptions.SwapException;

Expand All @@ -73,7 +74,7 @@
*
* @author Matthias Ronge &lt;[email protected]&gt;
*/
public class ExportSerialBatchTask extends EmptyTask {
public class ExportSerialBatchTask extends EmptyTask implements INameableTask {

/**
* The batch to export
Expand Down Expand Up @@ -119,6 +120,16 @@ public ExportSerialBatchTask(Batch batch) {
initialiseRuleSets(batch.getProcesses());
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ExportSerialBatchTask");
}

/**
* Initialises the the rule sets of the processes to export that export
* depends on. This cannot be done later because the therad doesn’t have
Expand Down
53 changes: 53 additions & 0 deletions Goobi/src/de/sub/goobi/helper/tasks/INameableTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This file is part of the Goobi Application - a Workflow tool for the support
* of mass digitization.
*
* (c) 2015 Goobi. Digitalisieren im Verein e.V. &lt;[email protected]&gt;
*
* Visit the websites for more information.
* - http://www.goobi.org/en/
* - https://github.com/goobi
*
* 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
*
* Linking this library statically or dynamically with other modules is making a
* combined work based on this library. Thus, the terms and conditions of the
* GNU General Public License cover the whole combination. As a special
* exception, the copyright holders of this library give you permission to link
* this library with independent modules to produce an executable, regardless of
* the license terms of these independent modules, and to copy and distribute
* the resulting executable under terms of your choice, provided that you also
* meet, for each linked independent module, the terms and conditions of the
* license of that module. An independent module is a module which is not
* derived from or based on this library. If you modify this library, you may
* extend this exception to your version of the library, but you are not obliged
* to do so. If you do not wish to do so, delete this exception statement from
* your version.
*/
package de.sub.goobi.helper.tasks;

/**
* A task implementing this interface provides its readable name by a method
* caal.
*
* @author Matthias Ronge &lt;[email protected]&gt;
*/
public interface INameableTask {

/**
* Returns the display name of the task to show to the user.
*/
String getDisplayName();
}
10 changes: 9 additions & 1 deletion Goobi/src/de/sub/goobi/helper/tasks/LongRunningTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @deprecated New task implementations should directly implement EmptyTask.
*/
@Deprecated
public abstract class LongRunningTask extends EmptyTask {
public abstract class LongRunningTask extends EmptyTask implements INameableTask {
/**
* No-argument constructor. Creates an empty long running task. Must be made
* explicit because a constructor taking an argument is present.
Expand Down Expand Up @@ -115,6 +115,14 @@ public void cancel() {
protected void stopped() {
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public abstract String getDisplayName();

/**
* Prozess-Getter
* ================================================================
Expand Down
10 changes: 10 additions & 0 deletions Goobi/src/de/sub/goobi/helper/tasks/ProcessSwapInTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public void initialize(Prozess inProzess) {
setTitle("Einlagerung: " + inProzess.getTitel());
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ProcessSwapInTask");
}

/**
* Aufruf als Thread ================================================================
*/
Expand Down
10 changes: 10 additions & 0 deletions Goobi/src/de/sub/goobi/helper/tasks/ProcessSwapOutTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public ProcessSwapOutTask(ProcessSwapOutTask processSwapOutTask) {
super(processSwapOutTask);
}

/**
* Returns the display name of the task to show to the user.
*
* @see de.sub.goobi.helper.tasks.INameableTask#getDisplayName()
*/
@Override
public String getDisplayName() {
return Helper.getTranslation("ProcessSwapOutTask");
}

@Override
public void initialize(Prozess inProzess) {
super.initialize(inProzess);
Expand Down
Loading

0 comments on commit e51daad

Please sign in to comment.