Skip to content
Snippets Groups Projects
Commit 7b4af2e2 authored by Andrea Burattin's avatar Andrea Burattin
Browse files

Full coverage for BEvent

parent 6e35b236
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ public class BEvent implements Serializable, Comparable<BEvent> {
private Map<String, Serializable> eventAttributes;
private Map<String, Serializable> traceAttributes;
private Map<String, Serializable> logAttributes;
private Map<String, Serializable> processAttributes;
/**
* Constructor of a new event
......@@ -39,7 +39,7 @@ public class BEvent implements Serializable, Comparable<BEvent> {
public BEvent() {
this.eventAttributes = new HashMap<>();
this.traceAttributes = new HashMap<>();
this.logAttributes = new HashMap<>();
this.processAttributes = new HashMap<>();
}
//
......@@ -59,8 +59,8 @@ public class BEvent implements Serializable, Comparable<BEvent> {
*/
public static BEvent create(
String processName,
String activityName,
String caseId,
String activityName,
Date time,
Collection<Pair<String, String>> eventAttributes) throws EventException {
if (processName == null || activityName == null || caseId == null) {
......@@ -96,8 +96,8 @@ public class BEvent implements Serializable, Comparable<BEvent> {
* @throws EventException this exception is thrown is incomplete information
* is provided
*/
public static BEvent create(String processName, String activityName, String caseId, Date time) throws EventException {
return create(processName, activityName, caseId, time, null);
public static BEvent create(String processName, String caseId, String activityName, Date time) throws EventException {
return create(processName, caseId, activityName, time, null);
}
/**
......@@ -111,19 +111,19 @@ public class BEvent implements Serializable, Comparable<BEvent> {
* @throws EventException this exception is thrown is incomplete information
* is provided
*/
public static BEvent create(String processName, String activityName, String caseId) throws EventException {
return create(processName, activityName, caseId, null, null);
public static BEvent create(String processName, String caseId, String activityName) throws EventException {
return create(processName, caseId, activityName, null, null);
}
//
// Specific methods
//
public void setProcessName(String name) {
setLogAttribute(XConceptExtension.KEY_NAME, name);
setProcessAttribute(XConceptExtension.KEY_NAME, name);
}
public String getProcessName() {
return (String) logAttributes.get(XConceptExtension.KEY_NAME);
return (String) processAttributes.get(XConceptExtension.KEY_NAME);
}
public void setTraceName(String name) {
......@@ -162,8 +162,8 @@ public class BEvent implements Serializable, Comparable<BEvent> {
return traceAttributes;
}
public Map<String, Serializable> getLogAttributes() {
return logAttributes;
public Map<String, Serializable> getProcessAttributes() {
return processAttributes;
}
public void setEventAttribute(String name, Serializable value) {
......@@ -182,12 +182,12 @@ public class BEvent implements Serializable, Comparable<BEvent> {
setAttributeFromXAttribute(traceAttributes, name, value);
}
public void setLogAttribute(String name, Serializable value) {
logAttributes.put(name, value);
public void setProcessAttribute(String name, Serializable value) {
processAttributes.put(name, value);
}
public void setLogAttribute(String name, XAttribute value) {
setAttributeFromXAttribute(logAttributes, name, value);
public void setProcessAttribute(String name, XAttribute value) {
setAttributeFromXAttribute(processAttributes, name, value);
}
//
......@@ -196,7 +196,7 @@ public class BEvent implements Serializable, Comparable<BEvent> {
@Override
public String toString() {
return logAttributes.toString() + " - " + traceAttributes.toString() + " - " + eventAttributes.toString();
return processAttributes.toString() + " - " + traceAttributes.toString() + " - " + eventAttributes.toString();
}
@Override
......@@ -220,8 +220,7 @@ public class BEvent implements Serializable, Comparable<BEvent> {
}
BEvent other = (BEvent) obj;
return new EqualsBuilder()
.appendSuper(super.equals(obj))
.append(logAttributes, other.logAttributes)
.append(processAttributes, other.processAttributes)
.append(traceAttributes, other.traceAttributes)
.append(eventAttributes, other.eventAttributes)
.isEquals();
......@@ -231,7 +230,7 @@ public class BEvent implements Serializable, Comparable<BEvent> {
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(logAttributes)
.append(processAttributes)
.append(traceAttributes)
.append(eventAttributes)
.toHashCode();
......@@ -244,14 +243,14 @@ public class BEvent implements Serializable, Comparable<BEvent> {
private void setAttributeFromXAttribute(Map<String, Serializable> map, String name, XAttribute value) {
if (value instanceof XAttributeBoolean) {
map.put(name, ((XAttributeBoolean) value).getValue());
} else if (value instanceof XAttributeTimestamp) {
map.put(name, ((XAttributeTimestamp) value).getValue());
} else if (value instanceof XAttributeContinuous) {
map.put(name, ((XAttributeContinuous) value).getValue());
} else if (value instanceof XAttributeDiscrete) {
map.put(name, ((XAttributeDiscrete) value).getValue());
} else if (value instanceof XAttributeLiteral) {
map.put(name, ((XAttributeLiteral) value).getValue());
} else if (value instanceof XAttributeTimestamp) {
map.put(name, ((XAttributeTimestamp) value).getValue());
}
}
}
......@@ -84,7 +84,7 @@ public class CSVLogSource extends BeamlineAbstractSource {
attributes.add(Pair.of("attribute_" + i, line[i]));
}
synchronized (ctx.getCheckpointLock()) {
ctx.collect(BEvent.create(filename, line[activityNameColumn], line[caseIdColumn], null, attributes));
ctx.collect(BEvent.create(filename, line[caseIdColumn], line[activityNameColumn], null, attributes));
}
}
} catch (IOException e) {
......
......@@ -69,7 +69,7 @@ public class MQTTXesSource extends BeamlineAbstractSource {
String partBeforeActName = topic.substring(0, posLastSlash);
String activityName = topic.substring(posLastSlash + 1);
String caseId = partBeforeActName.substring(partBeforeActName.lastIndexOf("/") + 1);
BEvent b = BEvent.create(processName, activityName, caseId);
BEvent b = BEvent.create(processName, caseId, activityName);
buffer.add(b);
}
......
......@@ -15,7 +15,7 @@ public class StringTestSource extends BeamlineAbstractSource {
public void run(SourceContext<BEvent> ctx) throws Exception {
for (int j = 0; j < traces.length; j++) {
for (int i = 0; i < traces[j].length(); i++) {
ctx.collect(BEvent.create("test-process", traces[j].substring(i, i+1), "case-"+j));
ctx.collect(BEvent.create("test-process", "case-"+j, traces[j].substring(i, i+1)));
}
}
}
......
......@@ -128,13 +128,13 @@ public class XesLogSource extends BeamlineAbstractSource {
for (XEvent e : t) {
BEvent be = BEvent.create(
processName,
XConceptExtension.instance().extractName(e),
XConceptExtension.instance().extractName(t),
XConceptExtension.instance().extractName(e),
XTimeExtension.instance().extractTimestamp(e));
// log attributes
for (Map.Entry<String, XAttribute> v : log.getAttributes().entrySet()) {
be.setLogAttribute(v.getKey(), v.getValue());
be.setProcessAttribute(v.getKey(), v.getValue());
}
// trace attributes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment