Search in sources :

Example 1 with DocketData

use of org.kitodo.api.docket.DocketData in project kitodo-production by kitodo.

the class ExportXmlLog method startMultipleExport.

/**
 * This method exports the production metadata for al list of processes as a
 * single file to a given stream.
 *
 * @param docketDataList
 *            a list of Docket data
 * @param outputStream
 *            The output stream, to write the docket to.
 */
void startMultipleExport(Iterable<DocketData> docketDataList, OutputStream outputStream) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace(NAMESPACE);
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", NAMESPACE + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (DocketData docketData : docketDataList) {
        Document doc = createDocument(docketData, false);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
        logger.error("Generating XML Output failed.", e);
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                logger.error("Closing the output stream failed.", e);
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) DocketData(org.kitodo.api.docket.DocketData) Element(org.jdom2.Element) IOException(java.io.IOException) Document(org.jdom2.Document) Namespace(org.jdom2.Namespace)

Example 2 with DocketData

use of org.kitodo.api.docket.DocketData in project kitodo-production by kitodo.

the class DocketDataGenerator method createDocketData.

public DocketData createDocketData(String processID, String signatur, String docType) {
    DocketData docketdata = new DocketData();
    docketdata.setCreationDate("01.01.2100");
    docketdata.setProcessId(processID);
    docketdata.setProcessName("ProcessTitle");
    docketdata.setProjectName("projectTitle");
    docketdata.setRulesetName("RulesetTitle");
    docketdata.setComment("A comment");
    List<Property> templateProperties = new ArrayList<>();
    Property propertyForDocket = new Property();
    propertyForDocket.setId(12345);
    propertyForDocket.setTitle("Signatur");
    propertyForDocket.setValue(signatur);
    templateProperties.add(propertyForDocket);
    docketdata.setTemplateProperties(templateProperties);
    List<Property> workpieceProperties = new ArrayList<>();
    Property workpiecePropertyForDocket = new Property();
    workpiecePropertyForDocket.setId(12345);
    workpiecePropertyForDocket.setTitle("docType");
    workpiecePropertyForDocket.setValue(docType);
    workpieceProperties.add(workpiecePropertyForDocket);
    docketdata.setWorkpieceProperties(workpieceProperties);
    List<org.kitodo.api.docket.Property> processProperties = new ArrayList<>();
    org.kitodo.api.docket.Property processPropertyForDocket = new org.kitodo.api.docket.Property();
    processPropertyForDocket.setId(12345);
    processPropertyForDocket.setTitle("digitalCollection");
    processPropertyForDocket.setValue("Musik");
    processProperties.add(processPropertyForDocket);
    docketdata.setProcessProperties(processProperties);
    return docketdata;
}
Also used : DocketData(org.kitodo.api.docket.DocketData) ArrayList(java.util.ArrayList) Property(org.kitodo.api.docket.Property) Property(org.kitodo.api.docket.Property)

Example 3 with DocketData

use of org.kitodo.api.docket.DocketData in project kitodo-production by kitodo.

the class ProcessService method getDocketData.

/**
 * Creates the DocketData for a given Process.
 *
 * @param process
 *            The process to create the docket data for.
 * @return The DocketData for the process.
 */
private DocketData getDocketData(Process process) {
    DocketData docketdata = new DocketData();
    docketdata.setCreationDate(process.getCreationDate().toString());
    docketdata.setProcessId(process.getId().toString());
    docketdata.setProcessName(process.getTitle());
    docketdata.setProjectName(process.getProject().getTitle());
    docketdata.setRulesetName(process.getRuleset().getTitle());
    docketdata.setComment(process.getWikiField());
    if (!process.getTemplates().isEmpty()) {
        docketdata.setTemplateProperties(getDocketDataForProperties(process.getTemplates()));
    }
    if (!process.getWorkpieces().isEmpty()) {
        docketdata.setWorkpieceProperties(getDocketDataForProperties(process.getWorkpieces()));
    }
    docketdata.setProcessProperties(getDocketDataForProperties(process.getProperties()));
    return docketdata;
}
Also used : DocketData(org.kitodo.api.docket.DocketData)

Aggregations

DocketData (org.kitodo.api.docket.DocketData)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Attribute (org.jdom2.Attribute)1 Document (org.jdom2.Document)1 Element (org.jdom2.Element)1 Namespace (org.jdom2.Namespace)1 XMLOutputter (org.jdom2.output.XMLOutputter)1 Property (org.kitodo.api.docket.Property)1