use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.
the class BehaviorModelCreationStage method createNode.
/**
* Creates an node from a node representing attribute string and value.
*
* @param name
* attribute name
* @param value
* attribute value
*
* @return EntryCallNode
*/
private Optional<EntryCallNode> createNode(final String name, final Double value) {
final String[] signatures = this.splitSignature(AbstractBehaviorModelTable.INFORMATION_INDICATOR_PATTERN, AbstractBehaviorModelTable.INFORMATION_DIVIDER_PATTERN, name);
if (signatures.length == 2) {
final EntryCallNode node = new EntryCallNode(signatures[0]);
final CallInformation callInformation = new CallInformation(signatures[1], value.toString());
node.mergeCallInformation(callInformation);
return Optional.of(node);
} else {
return Optional.empty();
}
}
use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.
the class BehaviorModelCreationStage method createEdge.
/**
* Creates an edge from an edge representing attribute string and value.
*
* @param name
* attribute name
* @param value
* attribute value
*
* @return EntryCallEdge
*/
private Optional<EntryCallEdge> createEdge(final String name, final Double value) {
// only create relevant edges
final double roundedValue = Math.floor(value);
if (roundedValue > 0.5) {
final String[] nodeNames = this.splitSignature(AbstractBehaviorModelTable.EDGE_INDICATOR_PATTERN, AbstractBehaviorModelTable.EDGE_DIVIDER_PATTERN, name);
if (nodeNames.length == 2) {
final EntryCallNode from = new EntryCallNode(nodeNames[0]);
final EntryCallNode to = new EntryCallNode(nodeNames[1]);
// rount
final EntryCallEdge edge = new EntryCallEdge(from, to, roundedValue);
return Optional.of(edge);
}
}
return Optional.empty();
}
use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.
the class IntersectionModelGenerationStrategy method intersect.
private BehaviorModel intersect(final BehaviorModel a, final BehaviorModel b) {
final BehaviorModel result = new BehaviorModel();
Optional<EntryCallEdge> matchingEdge;
for (final EntryCallEdge edgeA : a.getEdges()) {
matchingEdge = b.findEdge(edgeA.getSource().getSignature(), edgeA.getTarget().getSignature());
if (matchingEdge.isPresent()) {
final EntryCallNode newSource = this.intersectNode(edgeA.getSource(), matchingEdge.get().getSource());
final EntryCallNode newTarget = this.intersectNode(edgeA.getTarget(), matchingEdge.get().getTarget());
final int edgeCount = (int) Math.min(edgeA.getCalls(), matchingEdge.get().getCalls());
final EntryCallEdge newEdge = new EntryCallEdge(newSource, newTarget, edgeCount);
result.addEdge(newEdge, false);
}
}
return result;
}
use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.
the class IntersectionModelGenerationStrategy method intersectNode.
private EntryCallNode intersectNode(final EntryCallNode a, final EntryCallNode b) {
final EntryCallNode result = new EntryCallNode();
result.setSignature(a.getSignature());
Optional<CallInformation> matchingInfo;
for (final CallInformation infoA : a.getEntryCallInformation()) {
matchingInfo = b.findCallInformation(infoA.getInformationSignature(), infoA.getInformationParameter());
if (matchingInfo.isPresent()) {
final int newCalls = Math.min(infoA.getCount(), matchingInfo.get().getCount());
final CallInformation newInfo = new CallInformation(infoA.getInformationSignature(), infoA.getInformationParameter(), newCalls);
result.mergeCallInformation(newInfo);
}
}
return result;
}
use of org.iobserve.analysis.behavior.models.extended.EntryCallNode in project iobserve-analysis by research-iobserve.
the class SessionToBehaviorModelTransformation method convert.
/**
* Convert a user session into a behavior model.
*
* @param session
* user session
* @return returns a behavior model
*/
public BehaviorModel convert(final UserSession session) {
final BehaviorModel model = new BehaviorModel();
model.setName(this.prefix);
final List<EntryCallEvent> entryCalls = session.getEvents();
final Iterator<EntryCallEvent> iterator = entryCalls.iterator();
// Assume list has at least one element
if (iterator.hasNext()) {
EntryCallNode lastNode = this.createNode((PayloadAwareEntryCallEvent) iterator.next());
EntryCallNode currentNode;
while (iterator.hasNext()) {
currentNode = this.createNode((PayloadAwareEntryCallEvent) iterator.next());
model.addNode(currentNode, true);
model.addEdge(new EntryCallEdge(lastNode, currentNode), false);
lastNode = currentNode;
}
return model;
} else {
SessionToBehaviorModelTransformation.LOGGER.error("Empty user session creates empty model");
return model;
}
}
Aggregations