use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.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;
}
}
}
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.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);
}
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project goobi-workflow by intranda.
the class GeneratePdfFromXsltTest method testXmlLog.
@Test
public void testXmlLog() throws Exception {
XsltPreparatorDocket xmlExport = new XsltPreparatorDocket();
assertNotNull(xmlExport);
File fixture = folder.newFile("log.xml");
xmlExport.startExport(process, fixture.toPath());
assertNotNull(fixture);
SAXBuilder saxBuilder = new SAXBuilder();
Document document = saxBuilder.build(fixture);
Element root = document.getRootElement();
assertEquals("process", root.getName());
assertEquals(root.getAttributeValue("processID"), "1");
Element title = root.getChild("title", xmlns);
assertEquals("testprocess", title.getValue());
Element properties = root.getChild("properties", xmlns);
Element prop = properties.getChildren().get(0);
assertEquals("Test1", prop.getAttributeValue("propertyIdentifier"));
assertEquals("1", prop.getAttributeValue("value"));
Element steps = root.getChild("steps", xmlns);
Element step = steps.getChildren().get(0);
assertEquals("title", step.getChildText("title", xmlns));
assertEquals("1", step.getChildText("processingstatus", xmlns));
Element metadatalist = root.getChild("metadatalist", xmlns);
Element metadata = metadatalist.getChildren().get(0);
assertEquals("title", metadata.getAttributeValue("name"));
assertEquals("value", metadata.getValue());
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project j-Ecdar by Ecdar.
the class SimpleTransitionSystem method toJson.
public void toJson(String filename) {
// String file =" <?xml version="1.0" encoding="utf-8"?><!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'><nta><declaration>// Place global declarations here."
Element nta = new Element("nta");
Document doc = new Document();
Element declaration = new Element("declaration");
nta.addContent(declaration);
String decString = "";
for (Channel c : getInputs()) decString += "broadcast chan " + c.getName() + "; ";
for (Channel c : getOutputs()) decString += "broadcast chan " + c.getName() + "; ";
declaration.addContent(decString);
Element aut = new Element("template");
Element name = new Element("name");
name.addContent(getName());
aut.addContent(name);
Element localDeclaration = new Element("declaration");
aut.addContent(localDeclaration);
String localDecString = "";
for (Clock c : getClocks()) {
localDecString += "clock " + c.getName() + "; ";
}
localDeclaration.addContent(localDecString);
for (Location l : automaton.getLocations()) {
Element loc = new Element("location");
Element locname = new Element("name");
locname.addContent(l.getName());
loc.addContent(locname);
loc.setAttribute("id", l.getName());
loc.setAttribute("x", String.valueOf(l.getX()));
loc.setAttribute("y", String.valueOf(l.getY()));
Element invarLabel = new Element("label");
invarLabel.setAttribute("kind", "invariant");
String guardString = "";
int j = 0;
for (List<Guard> list : l.getInvariant()) {
int i = 0;
String inner = "";
for (Guard g : list) {
// System.out.println(g);
String interm = "";
String lower = "";
String upper = "";
if (g.isStrict()) {
lower = g.getClock().getName() + ">" + g.getLowerBound();
upper = g.getClock().getName() + "<" + g.getUpperBound();
} else {
lower = g.getClock().getName() + ">=" + g.getLowerBound();
upper = g.getClock().getName() + "<=" + g.getUpperBound();
}
if (g.getLowerBound() != 0)
if (interm.isEmpty())
interm += lower;
else
interm += " && " + lower;
if (g.getUpperBound() != 2147483647)
if (interm.isEmpty())
interm += upper;
else
interm += " && " + upper;
if (i == 0)
inner += interm;
else
inner += " && " + interm;
if (!inner.isEmpty())
i++;
}
if (j == 0)
guardString += inner;
else
guardString += " || " + inner;
if (!guardString.isEmpty())
j++;
}
invarLabel.addContent(guardString);
if (l.isInconsistent())
loc.setAttribute("color", "#A66C0F");
loc.addContent(invarLabel);
aut.addContent(loc);
}
Element init = new Element("init");
init.setAttribute("ref", automaton.getInitLoc().getName());
aut.addContent(init);
for (Edge e : automaton.getEdges()) {
Element edge = new Element("transition");
if (getInputs().contains(e.getChannel()))
edge.setAttribute("controllable", "true");
else
edge.setAttribute("controllable", "false");
Element source = new Element("source");
source.setAttribute("ref", e.getSource().getName());
edge.addContent(source);
Element target = new Element("target");
target.setAttribute("ref", e.getTarget().getName());
edge.addContent(target);
Element synchlabel = new Element("label");
synchlabel.setAttribute("kind", "synchronisation");
if (getInputs().contains(e.getChannel()))
synchlabel.addContent(e.getChannel().getName() + "?");
else
synchlabel.addContent(e.getChannel().getName() + "!");
edge.addContent(synchlabel);
Element guardlabel = new Element("label");
guardlabel.setAttribute("kind", "guard");
String guardString = "";
int i = 0;
int j = 0;
for (List<Guard> disjunction : e.getGuards()) {
if (j != 0)
guardString = guardString + " or ";
i = 0;
for (Guard g : disjunction) {
// System.out.println(g);
String interm = "";
String lower = "";
String upper = "";
if (g.isStrict()) {
lower = g.getClock().getName() + ">" + g.getLowerBound();
upper = g.getClock().getName() + "<" + g.getUpperBound();
} else {
lower = g.getClock().getName() + ">=" + g.getLowerBound();
upper = g.getClock().getName() + "<=" + g.getUpperBound();
}
if (g.getLowerBound() != 0)
if (interm.isEmpty())
interm += lower;
else
interm += " && " + lower;
if (g.getUpperBound() != 2147483647)
if (interm.isEmpty())
interm += upper;
else
interm += " && " + upper;
if (i == 0)
guardString += interm;
else
guardString += " && " + interm;
if (!guardString.isEmpty())
i++;
}
j++;
}
guardlabel.addContent(guardString);
edge.addContent(guardlabel);
Element updatelabel = new Element("label");
updatelabel.setAttribute("kind", "assignment");
String updateString = "";
i = 0;
for (Update u : e.getUpdates()) {
if (i == 0) {
updateString += u.getClock().getName();
updateString += " = " + u.getValue();
} else
updateString += ", " + u.getClock().getName() + " = " + u.getValue();
i++;
}
updatelabel.addContent(updateString);
edge.addContent(updatelabel);
aut.addContent(edge);
}
nta.addContent(aut);
Element sys = new Element("system");
sys.addContent("system " + getName() + ";");
nta.addContent(sys);
doc.setRootElement(nta);
XMLOutputter outter = new XMLOutputter();
outter.setFormat(Format.getPrettyFormat());
try {
outter.output(doc, new FileWriter(new File(filename)));
} catch (IOException e) {
e.printStackTrace();
}
// automaton.
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project goobi-workflow by intranda.
the class GoobiScriptExportDatabaseInformation method execute.
@Override
public void execute(GoobiScriptResult gsr) {
Process p = ProcessManager.getProcessById(gsr.getProcessId());
try {
gsr.setProcessTitle(p.getTitel());
gsr.setResultType(GoobiScriptResultType.RUNNING);
gsr.updateTimestamp();
Path dest = null;
try {
dest = Paths.get(p.getProcessDataDirectoryIgnoreSwapping(), p.getId() + "_db_export.xml");
} catch (IOException | InterruptedException | SwapException | DAOException e) {
log.error(e);
gsr.setResultMessage("Cannot read process folder " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
}
OutputStream os = null;
try {
os = Files.newOutputStream(dest);
} catch (IOException e) {
log.error(e);
gsr.setResultMessage("Cannot write into export file " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
}
try {
Document doc = new XsltPreparatorDocket().createExtendedDocument(p);
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
outp.output(doc, os);
} catch (IOException e) {
log.error(e);
gsr.setResultMessage("Cannot write into export file " + e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
} finally {
if (os != null) {
os.close();
}
}
if (gsr.getResultType() != GoobiScriptResultType.ERROR) {
gsr.setResultMessage("Export done successfully");
gsr.setResultType(GoobiScriptResultType.OK);
}
} catch (NoSuchMethodError | Exception e) {
gsr.setResultMessage(e.getMessage());
gsr.setResultType(GoobiScriptResultType.ERROR);
gsr.setErrorText(e.getMessage());
log.error("Exception during the export of database information for id " + p.getId(), e);
}
gsr.updateTimestamp();
}
Aggregations