Search in sources :

Example 1 with Processproperty

use of org.goobi.beans.Processproperty in project goobi-workflow by intranda.

the class StepBean method loadProcessProperties.

private void loadProcessProperties() {
    containerAccess = new HashMap<>();
    this.containers = new TreeMap<>();
    this.processPropertyList = PropertyParser.getInstance().getPropertiesForStep(this.mySchritt);
    for (ProcessProperty pt : this.processPropertyList) {
        if (pt.getContainer() != 0 && pt.getCurrentStepAccessCondition() != AccessCondition.READ) {
            containerAccess.put(pt.getContainer(), true);
        }
        if (pt.getProzesseigenschaft() == null) {
            Processproperty pe = new Processproperty();
            pe.setProzess(this.mySchritt.getProzess());
            pt.setProzesseigenschaft(pe);
            this.mySchritt.getProzess().getEigenschaften().add(pe);
            pt.transfer();
        }
        if (!this.containers.keySet().contains(pt.getContainer())) {
            PropertyListObject plo = new PropertyListObject(pt.getContainer());
            plo.addToList(pt);
            this.containers.put(pt.getContainer(), plo);
        } else {
            PropertyListObject plo = this.containers.get(pt.getContainer());
            plo.addToList(pt);
            this.containers.put(pt.getContainer(), plo);
        }
    }
}
Also used : ProcessProperty(org.goobi.production.properties.ProcessProperty) PropertyListObject(de.sub.goobi.helper.PropertyListObject) Processproperty(org.goobi.beans.Processproperty)

Example 2 with Processproperty

use of org.goobi.beans.Processproperty in project goobi-workflow by intranda.

the class StepBean method saveProcessProperties.

public void saveProcessProperties() {
    boolean valid = true;
    for (IProperty p : this.processPropertyList) {
        if (!p.isValid()) {
            String value = Helper.getTranslation("propertyNotValid", p.getName());
            Helper.setFehlerMeldung(value);
            valid = false;
        }
    }
    if (valid) {
        for (ProcessProperty p : this.processPropertyList) {
            if (p.getProzesseigenschaft() == null) {
                Processproperty pe = new Processproperty();
                pe.setProzess(this.mySchritt.getProzess());
                p.setProzesseigenschaft(pe);
                this.mySchritt.getProzess().getEigenschaften().add(pe);
            }
            p.transfer();
            if (!this.mySchritt.getProzess().getEigenschaften().contains(p.getProzesseigenschaft())) {
                this.mySchritt.getProzess().getEigenschaften().add(p.getProzesseigenschaft());
            }
        }
        Process p = this.mySchritt.getProzess();
        List<Processproperty> props = p.getEigenschaftenList();
        for (Processproperty pe : props) {
            if (pe.getTitel() == null) {
                p.getEigenschaften().remove(pe);
            }
        }
        // try {
        PropertyManager.saveProcessProperty(processProperty.getProzesseigenschaft());
        Helper.setMeldung("propertiesSaved");
    // } catch (DAOException e) {
    // mylog.error(e);
    // Helper.setFehlerMeldung("propertiesNotSaved");
    // }
    }
}
Also used : ProcessProperty(org.goobi.production.properties.ProcessProperty) IProperty(org.goobi.production.properties.IProperty) Process(org.goobi.beans.Process) Processproperty(org.goobi.beans.Processproperty)

Example 3 with Processproperty

use of org.goobi.beans.Processproperty in project goobi-workflow by intranda.

the class PropertyMysqlHelper method getProcessPropertiesForProcess.

public static List<Processproperty> getProcessPropertiesForProcess(int processId) throws SQLException {
    String sql = "SELECT * FROM prozesseeigenschaften WHERE prozesseID = ? ORDER BY container, Titel";
    Connection connection = null;
    Object[] param = { processId };
    try {
        connection = MySQLHelper.getInstance().getConnection();
        List<Processproperty> ret = new QueryRunner().query(connection, sql.toString(), resultSetToPropertyListHandler, param);
        return ret;
    } finally {
        if (connection != null) {
            MySQLHelper.closeConnection(connection);
        }
    }
}
Also used : Connection(java.sql.Connection) QueryRunner(org.apache.commons.dbutils.QueryRunner) Processproperty(org.goobi.beans.Processproperty)

Example 4 with Processproperty

use of org.goobi.beans.Processproperty in project goobi-workflow by intranda.

the class ProcessMysqlHelper method deleteProcess.

public static void deleteProcess(Process o) throws SQLException {
    if (o.getId() != null) {
        // delete metadata
        MetadataManager.deleteMetadata(o.getId());
        for (Processproperty object : o.getEigenschaften()) {
            PropertyManager.deleteProcessProperty(object);
        }
        for (Template object : o.getVorlagen()) {
            TemplateManager.deleteTemplate(object);
        }
        // delete masterpieces
        for (Masterpiece object : o.getWerkstuecke()) {
            MasterpieceManager.deleteMasterpiece(object);
        }
        for (Step object : o.getSchritte()) {
            StepManager.deleteStep(object);
        }
        // delete process
        String sql = "DELETE FROM prozesse WHERE ProzesseID = ?";
        Object[] param = { o.getId() };
        Connection connection = null;
        try {
            connection = MySQLHelper.getInstance().getConnection();
            QueryRunner run = new QueryRunner();
            run.update(connection, sql, param);
        } finally {
            if (connection != null) {
                MySQLHelper.closeConnection(connection);
            }
        }
    }
}
Also used : Masterpiece(org.goobi.beans.Masterpiece) Connection(java.sql.Connection) Step(org.goobi.beans.Step) QueryRunner(org.apache.commons.dbutils.QueryRunner) Processproperty(org.goobi.beans.Processproperty) Template(org.goobi.beans.Template)

Example 5 with Processproperty

use of org.goobi.beans.Processproperty in project goobi-workflow by intranda.

the class ProzesskopieForm method TemplateAuswahlAuswerten.

/**
 * Auswahl des Processes auswerten
 *
 * @throws DAOException
 * @throws NamingException
 * @throws SQLException ============================================================== ==
 */
public String TemplateAuswahlAuswerten() throws DAOException {
    /* den ausgewählten Process laden */
    if (auswahl == null || auswahl == 0) {
        Helper.setFehlerMeldung("ErrorTemplateSelectionIsEmpty");
        return "";
    }
    Process tempProcess = ProcessManager.getProcessById(this.auswahl);
    if (tempProcess.getWerkstueckeSize() > 0) {
        /* erstes Werkstück durchlaufen */
        Masterpiece werk = tempProcess.getWerkstueckeList().get(0);
        for (Masterpieceproperty eig : werk.getEigenschaften()) {
            for (AdditionalField field : this.additionalFields) {
                if (field.getTitel().equals(eig.getTitel())) {
                    field.setWert(eig.getWert());
                }
                if (eig.getTitel().equals("DocType")) {
                    docType = eig.getWert();
                }
            }
        }
    }
    if (tempProcess.getVorlagenSize() > 0) {
        /* erste Vorlage durchlaufen */
        Template vor = tempProcess.getVorlagenList().get(0);
        for (Templateproperty eig : vor.getEigenschaften()) {
            for (AdditionalField field : this.additionalFields) {
                if (field.getTitel().equals(eig.getTitel())) {
                    field.setWert(eig.getWert());
                }
            }
        }
    }
    if (tempProcess.getEigenschaftenSize() > 0) {
        for (Processproperty pe : tempProcess.getEigenschaften()) {
            if (pe.getTitel().equals("digitalCollection")) {
                digitalCollections.add(pe.getWert());
            }
        }
    }
    try {
        this.myRdf = tempProcess.readMetadataAsTemplateFile();
    } catch (Exception e) {
        Helper.setFehlerMeldung("Error on reading template-metadata ", e);
    }
    /* falls ein erstes Kind vorhanden ist, sind die Collectionen dafür */
    try {
        DocStruct colStruct = this.myRdf.getDigitalDocument().getLogicalDocStruct();
        removeCollections(colStruct);
        colStruct = colStruct.getAllChildren().get(0);
        removeCollections(colStruct);
    } catch (PreferencesException e) {
        Helper.setFehlerMeldung("Error on creating process", e);
        log.error("Error on creating process", e);
    } catch (RuntimeException e) {
    /*
             * das Firstchild unterhalb des Topstructs konnte nicht ermittelt werden
             */
    }
    return "";
}
Also used : Masterpiece(org.goobi.beans.Masterpiece) Masterpieceproperty(org.goobi.beans.Masterpieceproperty) Templateproperty(org.goobi.beans.Templateproperty) Process(org.goobi.beans.Process) PreferencesException(ugh.exceptions.PreferencesException) NamingException(javax.naming.NamingException) TypeNotAllowedAsChildException(ugh.exceptions.TypeNotAllowedAsChildException) JDOMException(org.jdom2.JDOMException) DAOException(de.sub.goobi.helper.exceptions.DAOException) SwapException(de.sub.goobi.helper.exceptions.SwapException) UghHelperException(de.sub.goobi.helper.exceptions.UghHelperException) PreferencesException(ugh.exceptions.PreferencesException) UGHException(ugh.exceptions.UGHException) WriteException(ugh.exceptions.WriteException) SQLException(java.sql.SQLException) TypeNotAllowedForParentException(ugh.exceptions.TypeNotAllowedForParentException) IOException(java.io.IOException) MetadataTypeNotAllowedException(ugh.exceptions.MetadataTypeNotAllowedException) ReadException(ugh.exceptions.ReadException) DocStructHasNoTypeException(ugh.exceptions.DocStructHasNoTypeException) DocStruct(ugh.dl.DocStruct) Template(org.goobi.beans.Template) Processproperty(org.goobi.beans.Processproperty)

Aggregations

Processproperty (org.goobi.beans.Processproperty)36 Process (org.goobi.beans.Process)14 ProcessProperty (org.goobi.production.properties.ProcessProperty)14 ArrayList (java.util.ArrayList)12 Masterpiece (org.goobi.beans.Masterpiece)7 Template (org.goobi.beans.Template)7 Step (org.goobi.beans.Step)6 DAOException (de.sub.goobi.helper.exceptions.DAOException)5 Masterpieceproperty (org.goobi.beans.Masterpieceproperty)4 Templateproperty (org.goobi.beans.Templateproperty)4 Before (org.junit.Before)3 TypeNotAllowedForParentException (ugh.exceptions.TypeNotAllowedForParentException)3 ConfigProjectsTest (de.sub.goobi.config.ConfigProjectsTest)2 PropertyListObject (de.sub.goobi.helper.PropertyListObject)2 SwapException (de.sub.goobi.helper.exceptions.SwapException)2 UghHelperException (de.sub.goobi.helper.exceptions.UghHelperException)2 MockProcess (de.sub.goobi.mock.MockProcess)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Connection (java.sql.Connection)2