use of org.goobi.beans.Step in project goobi-workflow by intranda.
the class DelayJob method execute.
@Override
public void execute() {
if (log.isDebugEnabled()) {
log.debug("execute delay job");
}
List<Step> stepsWithDelay = getListOfStepsWithDelay();
if (log.isDebugEnabled()) {
log.debug(stepsWithDelay.size() + " steps are waiting");
}
for (Step step : stepsWithDelay) {
IStepPlugin plugin = (IStepPlugin) PluginLoader.getPluginByTitle(PluginType.Step, step.getStepPlugin());
if (plugin != null && plugin instanceof IDelayPlugin) {
IDelayPlugin delay = (IDelayPlugin) plugin;
delay.initialize(step, "");
if (delay.delayIsExhausted()) {
LogEntry logEntry = new LogEntry();
logEntry.setContent(Helper.getTranslation("blockingDelayIsExhausted"));
logEntry.setCreationDate(new Date());
logEntry.setProcessId(step.getProzess().getId());
logEntry.setType(LogType.DEBUG);
logEntry.setUserName("-delay-");
ProcessManager.saveLogEntry(logEntry);
new HelperSchritte().CloseStepObjectAutomatic(step);
} else {
if (log.isTraceEnabled()) {
log.trace(step.getProzess().getTitel() + ": remaining delay is " + delay.getRemainingDelay());
}
}
}
}
}
use of org.goobi.beans.Step in project goobi-workflow by intranda.
the class StepBean method BatchesEdit.
public String BatchesEdit() {
// find all steps with same batch id and step status
List<Step> currentStepsOfBatch = new ArrayList<>();
String steptitle = this.mySchritt.getTitel();
Integer batchNumber = null;
if (mySchritt.getProzess().getBatch() != null) {
batchNumber = this.mySchritt.getProzess().getBatch().getBatchId();
}
if (batchNumber != null) {
// only steps with same title
currentStepsOfBatch = StepManager.getSteps(null, "schritte.titel = '" + steptitle + "' AND batchStep = true AND schritte.prozesseID in (select prozesse.prozesseID from prozesse where batchID = " + batchNumber + ")", 0, Integer.MAX_VALUE);
// Session session = Helper.getHibernateSession();
// Criteria crit = session.createCriteria(Step.class);
// crit.add(Restrictions.eq("titel", steptitle));
// // only steps with same batchid
// crit.createCriteria("prozess", "proc");
// crit.add(Restrictions.eq("proc.batchID", batchNumber));
// crit.add(Restrictions.eq("batchStep", true));
//
// currentStepsOfBatch = crit.list();
} else {
return "task_edit";
}
if (currentStepsOfBatch.size() == 1) {
return "task_edit";
}
this.setBatchHelper(new BatchStepHelper(currentStepsOfBatch, mySchritt));
return "task_edit_batch";
}
use of org.goobi.beans.Step in project goobi-workflow by intranda.
the class StepBean method SelectionNone.
@SuppressWarnings("unchecked")
public void SelectionNone() {
for (Iterator<Step> iter = (Iterator<Step>) this.paginator.getList().iterator(); iter.hasNext(); ) {
Step s = iter.next();
s.setSelected(false);
}
}
use of org.goobi.beans.Step in project goobi-workflow by intranda.
the class CopyProcess method NeuenProzessAnlegen2.
/**
* Anlegen des Prozesses und Speichern der Metadaten ================================================================
*
* @throws DAOException
* @throws SwapException
* @throws WriteException
*/
public Process NeuenProzessAnlegen2() throws ReadException, IOException, InterruptedException, PreferencesException, SwapException, DAOException, WriteException {
this.prozessKopie.setId(null);
EigenschaftenHinzufuegen(null);
for (Step step : this.prozessKopie.getSchritteList()) {
/*
* -------------------------------- always save date and user for each step --------------------------------
*/
step.setBearbeitungszeitpunkt(this.prozessKopie.getErstellungsdatum());
step.setEditTypeEnum(StepEditType.AUTOMATIC);
User user = Helper.getCurrentUser();
if (user != null) {
step.setBearbeitungsbenutzer(user);
}
/*
* -------------------------------- only if its done, set edit start and end date --------------------------------
*/
if (step.getBearbeitungsstatusEnum() == StepStatus.DONE) {
step.setBearbeitungsbeginn(this.prozessKopie.getErstellungsdatum());
// this concerns steps, which are set as done right on creation
// bearbeitungsbeginn is set to creation timestamp of process
// because the creation of it is basically begin of work
Date myDate = new Date();
step.setBearbeitungszeitpunkt(myDate);
step.setBearbeitungsende(myDate);
}
}
try {
ProcessManager.saveProcess(this.prozessKopie);
// dao.refresh(this.prozessKopie);
} catch (DAOException e) {
e.printStackTrace();
log.error("error on save: ", e);
return this.prozessKopie;
}
/*
* wenn noch keine RDF-Datei vorhanden ist (weil keine Opac-Abfrage stattfand, dann jetzt eine anlegen
*/
if (this.myRdf == null) {
createNewFileformat();
}
// * --------------------------------*/
if (this.updateData) {
if (this.myRdf != null) {
for (AdditionalField field : this.additionalFields) {
if (field.isUghbinding() && field.getShowDependingOnDoctype(getDocType())) {
/* welches Docstruct */
DocStruct myTempStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct();
DocStruct myTempChild = null;
if (field.getDocstruct().equals("firstchild")) {
try {
myTempStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct().getAllChildren().get(0);
} catch (RuntimeException e) {
/*
* das Firstchild unterhalb des Topstructs konnte nicht ermittelt werden
*/
}
}
/*
* falls topstruct und firstchild das Metadatum bekommen sollen
*/
if (!field.getDocstruct().equals("firstchild") && field.getDocstruct().contains("firstchild")) {
try {
myTempChild = this.myRdf.getDigitalDocument().getLogicalDocStruct().getAllChildren().get(0);
} catch (RuntimeException e) {
}
}
if (field.getDocstruct().equals("boundbook")) {
myTempStruct = this.myRdf.getDigitalDocument().getPhysicalDocStruct();
}
/* welches Metadatum */
try {
/*
* bis auf die Autoren alle additionals in die Metadaten übernehmen
*/
if (!field.getMetadata().equals("ListOfCreators")) {
MetadataType mdt = this.ughHelp.getMetadataType(this.prozessKopie.getRegelsatz().getPreferences(), field.getMetadata());
Metadata md = this.ughHelp.getMetadata(myTempStruct, mdt);
/*
* wenn das Metadatum null ist, dann jetzt initialisieren
*/
if (md == null) {
md = new Metadata(mdt);
md.setParent(myTempStruct);
myTempStruct.addMetadata(md);
}
md.setValue(field.getWert());
/*
* wenn dem Topstruct und dem Firstchild der Wert gegeben werden soll
*/
if (myTempChild != null) {
md = this.ughHelp.getMetadata(myTempChild, mdt);
md.setValue(field.getWert());
}
}
} catch (NullPointerException e) {
} catch (UghHelperException e) {
} catch (MetadataTypeNotAllowedException e) {
}
}
// end if ughbinding
}
// end for
/*
* -------------------------------- Collectionen hinzufügen --------------------------------
*/
DocStruct colStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct();
try {
addCollections(colStruct);
/*
* falls ein erstes Kind vorhanden ist, sind die Collectionen dafür
*/
colStruct = colStruct.getAllChildren().get(0);
addCollections(colStruct);
} catch (RuntimeException e) {
/*
* das Firstchild unterhalb des Topstructs konnte nicht ermittelt werden
*/
}
/*
* -------------------------------- Imagepfad hinzufügen (evtl. vorhandene zunächst löschen) --------------------------------
*/
try {
DigitalDocument dd = this.myRdf.getDigitalDocument();
DocStructType dst = this.prozessVorlage.getRegelsatz().getPreferences().getDocStrctTypeByName("BoundBook");
DocStruct dsBoundBook = dd.createDocStruct(dst);
dd.setPhysicalDocStruct(dsBoundBook);
UghHelper ughhelp = new UghHelper();
MetadataType mdt = ughhelp.getMetadataType(this.prozessKopie, "pathimagefiles");
if (this.myRdf != null && this.myRdf.getDigitalDocument() != null && this.myRdf.getDigitalDocument().getPhysicalDocStruct() != null) {
List<? extends Metadata> alleImagepfade = this.myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadataByType(mdt);
if (alleImagepfade != null && alleImagepfade.size() > 0) {
for (Metadata md : alleImagepfade) {
this.myRdf.getDigitalDocument().getPhysicalDocStruct().getAllMetadata().remove(md);
}
}
Metadata newmd = new Metadata(mdt);
newmd.setValue(prozessKopie.getImagesTifDirectory(false));
this.myRdf.getDigitalDocument().getPhysicalDocStruct().addMetadata(newmd);
}
/* Rdf-File schreiben */
this.prozessKopie.writeMetadataFile(this.myRdf);
/*
* -------------------------------- soll der Prozess als Vorlage verwendet werden? --------------------------------
*/
if (this.useTemplates && this.prozessKopie.isInAuswahllisteAnzeigen()) {
this.prozessKopie.writeMetadataAsTemplateFile(this.myRdf);
}
} catch (ugh.exceptions.DocStructHasNoTypeException e) {
Helper.setFehlerMeldung("DocStructHasNoTypeException", e.getMessage());
log.error("creation of new process throws an error: ", e);
} catch (UghHelperException e) {
Helper.setFehlerMeldung("UghHelperException", e.getMessage());
log.error("creation of new process throws an error: ", e);
} catch (MetadataTypeNotAllowedException e) {
Helper.setFehlerMeldung("MetadataTypeNotAllowedException", e.getMessage());
log.error("creation of new process throws an error: ", e);
} catch (TypeNotAllowedForParentException e) {
log.error(e);
}
}
} else {
this.prozessKopie.writeMetadataFile(this.myRdf);
}
// Adding process to history
if (!HistoryAnalyserJob.updateHistoryForProzess(this.prozessKopie)) {
Helper.setFehlerMeldung("historyNotUpdated");
} else {
try {
ProcessManager.saveProcess(this.prozessKopie);
} catch (DAOException e) {
e.printStackTrace();
log.error("error on save: ", e);
return this.prozessKopie;
}
}
this.prozessKopie.readMetadataFile();
return this.prozessKopie;
}
use of org.goobi.beans.Step in project goobi-workflow by intranda.
the class CopyProcess method Prepare.
public String Prepare() {
if (this.prozessVorlage.getContainsUnreachableSteps()) {
for (Step s : this.prozessVorlage.getSchritteList()) {
if (s.getBenutzergruppenSize() == 0 && s.getBenutzerSize() == 0) {
Helper.setFehlerMeldung("Kein Benutzer festgelegt für: ", s.getTitel());
}
}
return "";
}
clearValues();
this.co = ConfigOpac.getInstance();
try {
String type = MetadatenHelper.getMetaFileType(metadataFile);
this.myRdf = MetadatenHelper.getFileformatByName(type, prozessVorlage.getRegelsatz());
this.myRdf.read(this.metadataFile);
} catch (ReadException e) {
log.error(e);
} catch (IOException e) {
log.error(e);
}
;
this.prozessKopie = new Process();
this.prozessKopie.setTitel("");
this.prozessKopie.setIstTemplate(false);
this.prozessKopie.setInAuswahllisteAnzeigen(false);
this.prozessKopie.setProjekt(this.prozessVorlage.getProjekt());
this.prozessKopie.setRegelsatz(this.prozessVorlage.getRegelsatz());
this.digitalCollections = new ArrayList<>();
/*
* -------------------------------- Kopie der Prozessvorlage anlegen --------------------------------
*/
this.bhelp.SchritteKopieren(this.prozessVorlage, this.prozessKopie);
this.bhelp.ScanvorlagenKopieren(this.prozessVorlage, this.prozessKopie);
this.bhelp.WerkstueckeKopieren(this.prozessVorlage, this.prozessKopie);
this.bhelp.EigenschaftenKopieren(this.prozessVorlage, this.prozessKopie);
initializePossibleDigitalCollections();
return this.naviFirstPage;
}
Aggregations