Skip to content

Commit

Permalink
Added first mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
delas committed Dec 30, 2021
1 parent e249444 commit c4f079c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/java/beamline/mappers/DirectlyFollowsRelation.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<XTrace, ObservableSource<DirectlyFollowsRelation>> {

private Map<String, XEvent> map = new HashMap<String, XEvent>();

@Override
public @NonNull ObservableSource<DirectlyFollowsRelation> 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);
}
}

}

0 comments on commit c4f079c

Please sign in to comment.