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

Full coverage for BEvent

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