Search in sources :

Example 6 with BehaviorModelNode

use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode in project iobserve-analysis by research-iobserve.

the class TestHelper method addNode.

public static void addNode(final BehaviorModelGED model, final String nodeName) {
    final BehaviorModelNode node = new BehaviorModelNode(nodeName);
    model.getNodes().put(nodeName, node);
}
Also used : BehaviorModelNode(org.iobserve.service.behavior.analysis.model.BehaviorModelNode)

Example 7 with BehaviorModelNode

use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode in project iobserve-analysis by research-iobserve.

the class UserSessionToModelConverter method eventsToModel.

/**
 * Converts a list of events into a behavior model
 *
 * @param events
 *            The list of events
 * @return The behavior model
 */
public static BehaviorModelGED eventsToModel(final List<EntryCallEvent> events) {
    final BehaviorModelGED model = new BehaviorModelGED();
    final Iterator<EntryCallEvent> iterator = events.iterator();
    // start with the node "init"
    BehaviorModelNode currentNode = new BehaviorModelNode("Init");
    model.getNodes().put("Init", currentNode);
    BehaviorModelNode lastNode = currentNode;
    // for all events
    while (iterator.hasNext()) {
        final PayloadAwareEntryCallEvent event = (PayloadAwareEntryCallEvent) iterator.next();
        // current node is an existing node with the same name or if non-existing a new node
        currentNode = model.getNodes().get(event.getOperationSignature());
        if (currentNode == null) {
            currentNode = new BehaviorModelNode(event.getOperationSignature());
        }
        // add node to model
        model.getNodes().put(event.getOperationSignature(), currentNode);
        // add edge to model
        UserSessionToModelConverter.addEdge(event, model, lastNode, currentNode);
        lastNode = currentNode;
    }
    return model;
}
Also used : PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) BehaviorModelNode(org.iobserve.service.behavior.analysis.model.BehaviorModelNode) EntryCallEvent(org.iobserve.stages.general.data.EntryCallEvent) PayloadAwareEntryCallEvent(org.iobserve.stages.general.data.PayloadAwareEntryCallEvent) BehaviorModelGED(org.iobserve.service.behavior.analysis.model.BehaviorModelGED)

Example 8 with BehaviorModelNode

use of org.iobserve.service.behavior.analysis.model.BehaviorModelNode in project iobserve-analysis by research-iobserve.

the class GraphEditDistance method nodeDistance.

/**
 * Calculates the distance between two nodes. This includes the distance between the ingoing
 * edges
 */
private double nodeDistance(final BehaviorModelNode node1, final BehaviorModelNode node2) {
    double distance = 0;
    for (final BehaviorModelEdge edge : node1.getIngoingEdges().values()) {
        final BehaviorModelNode source1 = edge.getSource();
        final BehaviorModelNode source2 = this.model2.getNodes().get(source1.getName());
        final BehaviorModelEdge match = node2.getIngoingEdges().get(source2);
        if (match == null) {
            // edge only occurs in one node => must be inserted
            distance += this.edgeInsertionCost(edge);
        } else {
            // edge occurs in both nodes => must be compared
            distance += this.edgeDistance(edge, match);
        }
    }
    for (final BehaviorModelEdge edge : node2.getIngoingEdges().values()) {
        final BehaviorModelNode source2 = edge.getSource();
        final BehaviorModelNode source1 = this.model1.getNodes().get(source2.getName());
        final BehaviorModelEdge match = node1.getIngoingEdges().get(source1);
        // edge only occurs in one node => must be inserted
        if (match == null) {
            distance += this.edgeInsertionCost(edge);
        }
    }
    return distance;
}
Also used : BehaviorModelNode(org.iobserve.service.behavior.analysis.model.BehaviorModelNode) BehaviorModelEdge(org.iobserve.service.behavior.analysis.model.BehaviorModelEdge)

Aggregations

BehaviorModelNode (org.iobserve.service.behavior.analysis.model.BehaviorModelNode)8 BehaviorModelEdge (org.iobserve.service.behavior.analysis.model.BehaviorModelEdge)4 BehaviorModelGED (org.iobserve.service.behavior.analysis.model.BehaviorModelGED)3 PayloadAwareEntryCallEvent (org.iobserve.stages.general.data.PayloadAwareEntryCallEvent)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 EventGroup (org.iobserve.service.behavior.analysis.model.EventGroup)1 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)1 Test (org.junit.Test)1