All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.uni.freiburg.iig.telematik.sewol.converter.MXMLSequentializer Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.0.2
Show newest version
package de.uni.freiburg.iig.telematik.sewol.converter;

import java.io.File;
import java.io.FileWriter;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
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:
					if (stax.getLocalName().equals("ProcessInstance")) {
						output.write('\n');
					} else if(stax.getLocalName().equals("WorkflowModelElement")){
						output.write('	');
					}
				}
			}
			output.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	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");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy