de.uni.freiburg.iig.telematik.sewol.converter.MXMLSequentializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SEWOL Show documentation
Show all versions of SEWOL Show documentation
SEWOL provides support for the handling of workflow traces. Specifically it allows to specify the shape and content of process traces in terms of entries representing the execution of a specific workflow activity. SEWOL also allows to write these traces on disk as a log file with the help of a special file writer for process logs. Currently it supports plain text, Petrify, MXML and XES log file types. In order to specify security-related context information, SEWOL provides access control models such as access control lists (ACL) and role-based access control models (RBAC). All types of models can be conveniently edited with the help of appropriate dialogs.
The newest version!
package de.uni.freiburg.iig.telematik.sewol.converter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;
/**
* Takes an MXML file as input and outputs a non-XML file that contains a
* process trace per line, that simply consists of the plain activity names.
*
* @author Thomas Stocker
*
*/
public class MXMLSequentializer {
public static void convertMXML(String path) throws Exception {
File mxmlfile = new File(path);
try {
File file = new File(mxmlfile.getAbsolutePath().substring(0, mxmlfile.getAbsolutePath().indexOf('.')) + "sequential.txt");
FileWriter output = new FileWriter(file, true);
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLStreamReader stax = inputFactory.createXMLStreamReader(new StreamSource(new File(path)));
boolean element = false;
while (stax.hasNext()) {
switch (stax.next()) {
case XMLStreamConstants.START_ELEMENT:
element = stax.getLocalName().equals("WorkflowModelElement");
break;
case XMLStreamConstants.CDATA:
case XMLStreamConstants.CHARACTERS:
if (!stax.isWhiteSpace() && element) {
output.write(stax.getText());
}
break;
case XMLStreamConstants.END_ELEMENT:
switch (stax.getLocalName()) {
case "ProcessInstance":
output.write('\n');
break;
case "WorkflowModelElement":
output.write(' ');
break;
}
}
}
output.close();
} catch (IOException | XMLStreamException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws Exception {
MXMLSequentializer.convertMXML("/Users/stocker/Documents/Kooperationen/Micronas/Prozessdaten/Testdaten 2/2013/Logistisch/Logistisch - keine AdHoc - ohne offene Rechnungen in Zahlungsfrist.mxml");
}
}