Skip to content

Commit

Permalink
Fixed bug with XLogHelper and added tester
Browse files Browse the repository at this point in the history
  • Loading branch information
delas committed Sep 25, 2023
1 parent 0d53cbe commit e855289
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 104 deletions.
38 changes: 0 additions & 38 deletions .classpath

This file was deleted.

23 changes: 0 additions & 23 deletions .project

This file was deleted.

34 changes: 14 additions & 20 deletions src/main/java/plg/test/TestModel.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package plg.test;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import org.deckfour.xes.model.XLog;
import org.deckfour.xes.out.XesXmlSerializer;
import plg.exceptions.IllegalSequenceException;
import plg.exceptions.InvalidDataObject;
import plg.exceptions.InvalidProcessException;
import plg.generator.ProgressAdapter;
import plg.generator.log.LogGenerator;
import plg.generator.log.SimulationConfiguration;
import plg.generator.process.ProcessGenerator;
import plg.generator.process.RandomizationConfiguration;
import plg.io.exporter.GraphvizBPMNExporter;
import plg.io.importer.PLGImporter;
import plg.model.Process;
import plg.model.activity.Task;
import plg.model.data.DataObject;
Expand All @@ -21,15 +18,12 @@
import plg.model.event.StartEvent;
import plg.model.gateway.Gateway;

import java.io.FileOutputStream;

public class TestModel {

public static void main(String[] args) throws
IllegalSequenceException,
InvalidProcessException,
InvalidDataObject,
FileNotFoundException,
IOException,
InterruptedException, ParserConfigurationException, TransformerException {
Exception {

// for (int i = 0; i < 200; i++) {
// Process p = new Process("test");
Expand All @@ -50,10 +44,7 @@ public static void main(String[] args) throws
// Process p = i.importModel("C:\\Users\\Andrea\\Desktop\\test.plg");
// Process p = i.importModel("C:\\Users\\Andrea\\Desktop\\Hybrid-no-time.bpmn");

// LogGenerator g = new LogGenerator(p, new SimulationConfiguration(1000));
// XLog l = g.generateLog();
// XesXmlGZIPSerializer s = new XesXmlGZIPSerializer();
// s.serialize(l, new FileOutputStream("C:\\Users\\Andrea\\Desktop\\testlog.xes.gz"));


GraphvizBPMNExporter e = new GraphvizBPMNExporter();
e.exportModel(p, "C:\\Users\\andbur\\Desktop\\model.dot");
Expand All @@ -62,8 +53,11 @@ public static void main(String[] args) throws

// Process p = new Process("test");
ProcessGenerator.randomizeProcess(p, RandomizationConfiguration.BASIC_VALUES);



LogGenerator g = new LogGenerator(p, new SimulationConfiguration(1000), new ProgressAdapter());
XLog l = g.generateLog();
XesXmlSerializer s = new XesXmlSerializer();
s.serialize(l, new FileOutputStream("C:\\Users\\andbur\\Desktop\\testlog.xes"));
}

@SuppressWarnings("unused")
Expand Down
27 changes: 4 additions & 23 deletions src/main/java/plg/utils/XLogHelper.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
package plg.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

import org.deckfour.xes.extension.XExtensionManager;
import org.deckfour.xes.extension.std.XConceptExtension;
import org.deckfour.xes.extension.std.XLifecycleExtension;
import org.deckfour.xes.extension.std.XOrganizationalExtension;
import org.deckfour.xes.extension.std.XTimeExtension;
import org.deckfour.xes.factory.XFactory;
import org.deckfour.xes.factory.XFactoryNaiveImpl;
import org.deckfour.xes.model.XAttributable;
import org.deckfour.xes.model.XAttributeBoolean;
import org.deckfour.xes.model.XAttributeContinuous;
import org.deckfour.xes.model.XAttributeDiscrete;
import org.deckfour.xes.model.XAttributeLiteral;
import org.deckfour.xes.model.XAttributeMap;
import org.deckfour.xes.model.XAttributeTimestamp;
import org.deckfour.xes.model.XEvent;
import org.deckfour.xes.model.XLog;
import org.deckfour.xes.model.XTrace;
import org.deckfour.xes.model.buffered.XAttributeMapBufferedImpl;
import org.deckfour.xes.model.buffered.XAttributeMapSerializerImpl;
import org.deckfour.xes.model.buffered.XTraceBufferedImpl;
import org.deckfour.xes.model.impl.XAttributeMapLazyImpl;
import org.deckfour.xes.model.*;

import java.util.*;

/**
* This class is a helper that can be used to handle XLog objects. It is only
Expand Down Expand Up @@ -464,9 +447,7 @@ public static XEvent clone(XEvent event) {
public static List<XTrace> traceToEventsForStream(XTrace trace) {
List<XTrace> traceToStream = new ArrayList<XTrace>();
for (XEvent e : trace) {
XTrace eventWrapper = new XTraceBufferedImpl(
new XAttributeMapLazyImpl<XAttributeMapBufferedImpl>(XAttributeMapBufferedImpl.class),
new XAttributeMapSerializerImpl());
XTrace eventWrapper = new XFactoryNaiveImpl().createTrace();
XAttributeMap am = trace.getAttributes();
for (String key : am.keySet()) {
eventWrapper.getAttributes().put(key, am.get(key));
Expand Down

0 comments on commit e855289

Please sign in to comment.