diff --git a/src/main/java/beamline/mappers/DirectlyFollowsRelation.java b/src/main/java/beamline/mappers/DirectlyFollowsRelation.java new file mode 100644 index 0000000..333c6db --- /dev/null +++ b/src/main/java/beamline/mappers/DirectlyFollowsRelation.java @@ -0,0 +1,28 @@ +package beamline.mappers; + +import org.deckfour.xes.model.XEvent; + +public class DirectlyFollowsRelation { + + private String caseId; + public XEvent first; + public XEvent second; + + public DirectlyFollowsRelation(String caseId, XEvent first, XEvent second) { + this.caseId = caseId; + this.first = first; + this.second = second; + } + + public String getCaseId() { + return caseId; + } + + public XEvent getFirst() { + return first; + } + + public XEvent getSecond() { + return second; + } +} diff --git a/src/main/java/beamline/mappers/InfiniteSizeDirectlyFollowsMapper.java b/src/main/java/beamline/mappers/InfiniteSizeDirectlyFollowsMapper.java new file mode 100644 index 0000000..a6c6dac --- /dev/null +++ b/src/main/java/beamline/mappers/InfiniteSizeDirectlyFollowsMapper.java @@ -0,0 +1,37 @@ +package beamline.mappers; + +import java.util.HashMap; +import java.util.Map; + +import org.deckfour.xes.extension.std.XConceptExtension; +import org.deckfour.xes.model.XEvent; +import org.deckfour.xes.model.XTrace; + +import io.reactivex.rxjava3.annotations.NonNull; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.core.ObservableSource; +import io.reactivex.rxjava3.functions.Function; + +public class InfiniteSizeDirectlyFollowsMapper implements Function> { + + private Map map = new HashMap(); + + @Override + public @NonNull ObservableSource apply(@NonNull XTrace t) throws Throwable { + String caseId = XConceptExtension.instance().extractName(t); + DirectlyFollowsRelation toRet = null; + + if (map.containsKey(caseId)) { + toRet = new DirectlyFollowsRelation(caseId, map.get(caseId), t.get(0)); + } + + map.put(caseId, t.get(0)); + + if (toRet == null) { + return Observable.empty(); + } else { + return Observable.just(toRet); + } + } + +}