use of org.iobserve.analysis.clustering.filter.models.BehaviorModel in project iobserve-analysis by research-iobserve.
the class TUsageModelToBehaviorModel method createBehaviorModel.
/**
* send user behavior to ui.
*
* @param behavior
* user behavior
*
* @return behaviorModel
*/
private Optional<BehaviorModel> createBehaviorModel(final ScenarioBehaviour behavior) {
if (!behavior.getActions_ScenarioBehaviour().isEmpty()) {
final BehaviorModel behaviorModel = new BehaviorModel();
this.traverseScenarioBehavior(behavior, behaviorModel, Optional.empty());
behaviorModel.setName("mpe-behavior");
return Optional.of(behaviorModel);
} else {
return Optional.empty();
}
}
use of org.iobserve.analysis.clustering.filter.models.BehaviorModel in project iobserve-analysis by research-iobserve.
the class TUsageModelToBehaviorModel method traverseAction.
private Map<EntryCallNode, Double> traverseAction(final BehaviorModel behaviorModel, final Optional<Map<EntryCallNode, Double>> optPreviousNodes, final AbstractUserAction action) {
if (action instanceof Branch) {
final Branch branch = (Branch) action;
return this.traverseBranch(behaviorModel, optPreviousNodes, branch);
} else if (action instanceof Loop) {
final Loop loop = (Loop) action;
return this.traverseLoop(behaviorModel, optPreviousNodes, loop);
} else if (action instanceof EntryLevelSystemCall) {
final Map<EntryCallNode, Double> endNodes = new HashMap<>();
final EntryLevelSystemCall entryLevelSystemCall = (EntryLevelSystemCall) action;
final EntryCallNode entryCallNode = this.createEntryCallNode(entryLevelSystemCall);
behaviorModel.addNode(entryCallNode);
if (optPreviousNodes.isPresent()) {
optPreviousNodes.get().keySet().stream().map(previousNode -> new EntryCallEdge(previousNode, entryCallNode, optPreviousNodes.get().get(previousNode))).forEach(behaviorModel::addEdge);
}
endNodes.put(entryCallNode, 1.0);
return this.traverseAction(behaviorModel, Optional.of(endNodes), action.getSuccessor());
} else if (action instanceof Stop) {
return optPreviousNodes.isPresent() ? optPreviousNodes.get() : new HashMap<>();
} else {
// skip action
return this.traverseAction(behaviorModel, optPreviousNodes, action.getSuccessor());
}
}
Aggregations