Search in sources :

Example 1 with CallInformation

use of org.iobserve.analysis.clustering.filter.models.CallInformation in project iobserve-analysis by research-iobserve.

the class TBehaviorModelCreation 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);
        node.getEntryCallInformation().add(callInformation);
        return Optional.of(node);
    } else {
        return Optional.empty();
    }
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode)

Example 2 with CallInformation

use of org.iobserve.analysis.clustering.filter.models.CallInformation in project iobserve-analysis by research-iobserve.

the class ComparisonOutputStage method generateAllEntryCallInformationList.

private Set<CallInformation> generateAllEntryCallInformationList(final Set<CallInformation> entryCallInformation, final Set<CallInformation> supplementalCallInfo) {
    final Set<CallInformation> allEntryCallInformation = new HashSet<>();
    allEntryCallInformation.addAll(entryCallInformation);
    for (final CallInformation information : supplementalCallInfo) {
        boolean exists = false;
        for (final CallInformation referenceInfo : allEntryCallInformation) {
            if (referenceInfo.getInformationSignature().equals(information.getInformationSignature()) && referenceInfo.getInformationCode() == information.getInformationCode()) {
                exists = true;
            }
        }
        if (!exists) {
            allEntryCallInformation.add(information);
        }
    }
    return allEntryCallInformation;
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) HashSet(java.util.HashSet)

Example 3 with CallInformation

use of org.iobserve.analysis.clustering.filter.models.CallInformation in project iobserve-analysis by research-iobserve.

the class ComparisonOutputStage method execute.

@Override
protected void execute(final ComparisonResult result) throws IOException {
    final FileWriter fw = new FileWriter(this.outputFile);
    final BufferedWriter writer = new BufferedWriter(fw);
    final int baselineNodeCount = result.getBaselineNodes().size();
    final int testModelNodeCount = result.getTestModelNodes().size();
    final int missingNodeCount = result.getMissingNodes().size();
    final int additionalNodeCount = result.getAdditionalNodes().size();
    final int baselineEdgeCount = result.getBaselineEdges().size();
    final int testModelEdgeCount = result.getTestModelEdges().size();
    final int missingEdgeCount = result.getMissingEdgeCount();
    final int additionalEdgeCount = result.getAdditionalEdgeCount();
    writer.write("CP;" + this.outputFile.getName() + ";" + baselineNodeCount + ";" + baselineEdgeCount + ";" + testModelNodeCount + ";" + testModelEdgeCount + ";" + missingNodeCount + ";" + additionalNodeCount + ";" + missingEdgeCount + ";" + additionalEdgeCount + ";" + (double) missingNodeCount / (double) baselineNodeCount + ";" + (double) additionalNodeCount / (double) baselineNodeCount + ";" + (double) missingEdgeCount / (double) baselineEdgeCount + ";" + (double) additionalEdgeCount / (double) baselineEdgeCount + "\n");
    final List<EntryCallNode> allNodes = this.createAllNodesList(result.getBaselineNodes(), result.getTestModelNodes());
    final List<EntryCallEdge> allEdges = this.createAllEdgesList(result.getBaselineEdges(), result.getTestModelEdges());
    this.generateNodeCallInformation(writer, "baseline;" + this.outputFile.getName() + ";", allNodes, result.getBaselineNodes());
    this.generateNodeCallInformation(writer, "compared;" + this.outputFile.getName() + ";", allNodes, result.getTestModelNodes());
    writer.write("baseline;------------------------------------------ edges\n");
    writer.write("compared;------------------------------------------ edges\n");
    this.generateEdges(writer, "baseline;" + this.outputFile.getName() + ";", allEdges, result.getBaselineEdges());
    this.generateEdges(writer, "compared;" + this.outputFile.getName() + ";", allEdges, result.getTestModelEdges());
    writer.write("Nodes:\n\tmissing=" + result.getMissingNodes().size() + "\n\tadditional=" + result.getAdditionalNodes().size() + "\n");
    for (final EntryCallNode node : result.getMissingNodes()) {
        writer.write("\t - " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getAdditionalNodes()) {
        writer.write("\t + " + node.getSignature() + "\n");
    }
    for (final EntryCallNode node : result.getSimilarNodes()) {
        writer.write("\t = " + node.getSignature() + "\n");
    }
    writer.write("Edges:\n\tmissing=" + result.getMissingEdgeCount() + "\n\tadditional=" + result.getAdditionalEdgeCount() + "\n");
    writer.write("Node differences:\n");
    for (final NodeDifference difference : result.getNodeDifferences()) {
        writer.write("\tNode" + difference.getReferenceNode().getSignature() + "\n");
        writer.write("\t\tMissing");
        String separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
        writer.write("\t\tAdditional");
        separator = "=";
        for (final CallInformation callInformation : difference.getMissingInformation()) {
            writer.write(separator + callInformation);
            separator = ", ";
        }
        writer.write("\n");
    }
    writer.close();
    fw.close();
}
Also used : EntryCallEdge(org.iobserve.analysis.clustering.filter.models.EntryCallEdge) CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) FileWriter(java.io.FileWriter) NodeDifference(org.iobserve.evaluation.data.NodeDifference) BufferedWriter(java.io.BufferedWriter)

Example 4 with CallInformation

use of org.iobserve.analysis.clustering.filter.models.CallInformation in project iobserve-analysis by research-iobserve.

the class TBehaviorModelVisualization method createNodes.

/**
 * Create new nodes at visualisation backend.
 *
 * @param entryCallNodes
 *            entryCallNodes
 */
private void createNodes(final Set<EntryCallNode> entryCallNodes, final long modelId) {
    final ArrayNode nodes = this.objectMapper.createArrayNode();
    for (final EntryCallNode entryCallNode : entryCallNodes) {
        final ObjectNode json = this.objectMapper.createObjectNode();
        json.put("id", 0);
        json.put("name", this.signatureStrategy.getSignature(entryCallNode));
        final ObjectNode extras = this.objectMapper.createObjectNode();
        for (final CallInformation callInformation : entryCallNode.getEntryCallInformation()) {
            extras.put(callInformation.getInformationSignature(), callInformation.getInformationCode());
        }
        json.put("extra", extras);
        // TODO visualizations doesn't accept lists.
        // TODO is this a requirement request?
        nodes.add(json);
        final JsonNode node = this.postElement(json, this.getNodeUrl(modelId));
        this.nodeMap.put(entryCallNode.getSignature(), node);
    }
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 5 with CallInformation

use of org.iobserve.analysis.clustering.filter.models.CallInformation in project iobserve-analysis by research-iobserve.

the class ComparisonOutputStage method generateNodeCallInformation.

private void generateNodeCallInformation(final BufferedWriter writer, final String prefix, final List<EntryCallNode> allNodes, final List<EntryCallNode> selectedNodes) throws IOException {
    for (final EntryCallNode referenceNode : allNodes) {
        final EntryCallNode printNode = this.findNode(selectedNodes, referenceNode);
        if (printNode != null) {
            final Set<CallInformation> allEntryCallInformation = this.generateAllEntryCallInformationList(referenceNode.getEntryCallInformation(), printNode.getEntryCallInformation());
            writer.write(prefix + printNode.getSignature().substring(18) + "\n");
            this.generateCallInformation(writer, prefix + "\t", allEntryCallInformation, printNode.getEntryCallInformation());
        } else {
            writer.write(prefix + " -- \n");
        }
    }
}
Also used : CallInformation(org.iobserve.analysis.clustering.filter.models.CallInformation) EntryCallNode(org.iobserve.analysis.clustering.filter.models.EntryCallNode)

Aggregations

CallInformation (org.iobserve.analysis.clustering.filter.models.CallInformation)7 EntryCallNode (org.iobserve.analysis.clustering.filter.models.EntryCallNode)5 NodeDifference (org.iobserve.evaluation.data.NodeDifference)3 EntryCallEdge (org.iobserve.analysis.clustering.filter.models.EntryCallEdge)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ComparisonResult (org.iobserve.evaluation.data.ComparisonResult)1 Before (org.junit.Before)1