Search in sources :

Example 56 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project goobi-workflow by intranda.

the class XsltPreparatorDocket method startExport.

/**
 * This method exports the production metadata for a list of processes as a single file to a given stream.
 *
 * @param processList
 * @param outputStream
 * @param xslt
 */
public void startExport(List<Process> processList, OutputStream outputStream, String xslt) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile");
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (Process p : processList) {
        Document doc = createDocument(p, false, true);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                outputStream = null;
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Process(org.goobi.beans.Process) IOException(java.io.IOException) Document(org.jdom2.Document) Namespace(org.jdom2.Namespace)

Example 57 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project goobi-workflow by intranda.

the class XsltPreparatorDocket method startTransformation.

public void startTransformation(Process p, OutputStream out, String filename) throws ConfigurationException, XSLTransformException, IOException {
    Document doc = createDocument(p, true, true);
    XmlTransformation(out, doc, filename);
}
Also used : Document(org.jdom2.Document)

Example 58 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project goobi-workflow by intranda.

the class XsltPreparatorDocket method createExtendedDocument.

/**
 * Creates a new xml document containing all relevant process data. It can be used to import the process into another system.
 *
 * @param process the process to export
 * @return a new xml document
 * @throws ConfigurationException
 */
public Document createExtendedDocument(Process process) {
    Element rootElement = new Element("process", xmlns);
    Document doc = new Document(rootElement);
    getProcessData(process, rootElement);
    // prozesse.batchID
    if (process.getBatch() != null) {
        rootElement.addContent(getBatchData(process));
    }
    // prozesse.docketID
    if (process.getDocket() != null) {
        rootElement.addContent(getDocketData(process));
    // getDocketData(process, rootElement);
    }
    // ProjekteID
    rootElement.addContent(getProjectData(process));
    // process log
    if (process.getProcessLog() != null && !process.getProcessLog().isEmpty()) {
        rootElement.addContent(getProcessLogData(process));
    }
    // process properties
    if (!process.getEigenschaften().isEmpty()) {
        rootElement.addContent(getProcessPropertyData(process));
    }
    // template properties
    if (!process.getVorlagenList().isEmpty()) {
        rootElement.addContent(getTemplatePropertyData(process));
    }
    // workpiece properties
    if (!process.getWerkstueckeList().isEmpty()) {
        rootElement.addContent(getWorkpiecePropertyData(process));
    }
    // tasks
    Element tasks = new Element("tasks", xmlns);
    rootElement.addContent(tasks);
    for (Step step : process.getSchritte()) {
        tasks.addContent(getTaskData(step));
    }
    return doc;
}
Also used : Element(org.jdom2.Element) Step(org.goobi.beans.Step) Document(org.jdom2.Document)

Example 59 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project goobi-workflow by intranda.

the class XsltPreparatorMetadata method startExport.

/**
 * This method exports the production metadata for a list of processes as a single file to a given stream.
 *
 * @param processList
 * @param outputStream
 * @param xslt
 */
public void startExport(List<Process> processList, OutputStream outputStream, String xslt) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace("http://www.goobi.io/logfile");
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", "http://www.goobi.io/logfile" + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (Process p : processList) {
        Document doc = createDocument(p, false);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                outputStream = null;
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Process(org.goobi.beans.Process) IOException(java.io.IOException) Document(org.jdom2.Document) DigitalDocument(ugh.dl.DigitalDocument) Namespace(org.jdom2.Namespace)

Example 60 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document in project goobi-workflow by intranda.

the class XsltPreparatorMetadata method startExport.

/**
 * This method exports the METS metadata as xml to a given stream.
 *
 * @param process the process to export
 * @param os the OutputStream to write the contents to
 * @throws IOException
 * @throws ExportFileException
 */
@Override
public void startExport(Process process, OutputStream os, String xslt) throws IOException {
    try {
        this.prefs = process.getRegelsatz().getPreferences();
        Fileformat ff = process.readMetadataFile();
        DigitalDocument document = ff.getDigitalDocument();
        this.metahelper = new MetadatenHelper(prefs, document);
        Document doc = createDocument(process, true);
        XMLOutputter outp = new XMLOutputter();
        outp.setFormat(Format.getPrettyFormat());
        outp.output(doc, os);
        os.close();
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) MetadatenHelper(de.sub.goobi.metadaten.MetadatenHelper) Fileformat(ugh.dl.Fileformat) IOException(java.io.IOException) DigitalDocument(ugh.dl.DigitalDocument) Document(org.jdom2.Document) DigitalDocument(ugh.dl.DigitalDocument) ExportFileException(de.sub.goobi.helper.exceptions.ExportFileException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.apache.commons.configuration.ConfigurationException)

Aggregations

Document (org.jdom2.Document)1034 Element (org.jdom2.Element)587 Test (org.junit.Test)340 SAXBuilder (org.jdom2.input.SAXBuilder)271 IOException (java.io.IOException)266 XMLOutputter (org.jdom2.output.XMLOutputter)182 JDOMException (org.jdom2.JDOMException)162 File (java.io.File)148 ArrayList (java.util.ArrayList)75 InputStream (java.io.InputStream)74 StringReader (java.io.StringReader)63 Path (java.nio.file.Path)59 HashMap (java.util.HashMap)57 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Attribute (org.jdom2.Attribute)44 List (java.util.List)42 Namespace (org.jdom2.Namespace)39