Class DrawflowGraphFormat.GraphWriter

  • Enclosing class:
    DrawflowGraphFormat

    private static class DrawflowGraphFormat.GraphWriter
    extends java.lang.Object
    Instance to map and write a graph.
    Author:
    Holger Eichelberger, SSE
    • Constructor Detail

      • GraphWriter

        private GraphWriter​(IvmlGraphMapper.IvmlGraph graph)
        Creates a writer for graph.
        Parameters:
        graph - the graph to write
    • Method Detail

      • mapNodes

        private void mapNodes()
        Maps the nodes of graph to ids.
      • serviceToData

        private void serviceToData​(net.ssehub.easy.varModel.confModel.IDecisionVariable service,
                                   org.json.simple.JSONObject data)
        Turns service information into data for the editor.
        Parameters:
        service - the IVML variable representing the service, may be null
        data - the data object to be modified
      • processBackward

        private void processBackward​(net.ssehub.easy.varModel.confModel.IDecisionVariable set,
                                     org.json.simple.JSONObject data,
                                     java.lang.String name)
        Processes backward flows by adding their type names as String array into a JSON field called name.
        Parameters:
        set - denotes the type set (input/output) to be analyzed
        data - the data object to be modified
        name - the name of the field to write the backward flows into
      • writeHomeData

        private org.json.simple.JSONObject writeHomeData()
        Writes the "home" data section.
        Returns:
        the home data JSON object
      • getId

        private java.lang.String getId​(IvmlGraphMapper.IvmlGraphNode node,
                                       java.lang.String dflt)
        Returns the ID of the node in terms of its IVML variable name.
        Parameters:
        node - the node
        dflt - the default value
        Returns:
        the node ID
      • writeGraph

        private java.lang.String writeGraph()
        Writes the graph to a JSON string.
        Returns:
        the JSON string
      • writeEdges

        private org.json.simple.JSONObject writeEdges​(IvmlGraphMapper.IvmlGraphNode node,
                                                      java.lang.Iterable<? extends IvmlGraphMapper.IvmlGraphEdge> edges,
                                                      boolean inputEdges)
        Writes the given edges.
        Parameters:
        node - the start/end node defining the edges
        edges - the edges to write
        inputEdges - are we writing input or output edges
        Returns:
        the edges as JSON object
      • collectForwardTypes

        private void collectForwardTypes​(IvmlGraphMapper.IvmlGraphNode start,
                                         IvmlGraphMapper.IvmlGraphNode end,
                                         IvmlGraphMapper.IvmlGraphEdge edge,
                                         org.json.simple.JSONObject data)
        Collects common forward types between the nodes involved in edge and adds the results as "type"-array to data.
        Parameters:
        start - the start node
        end - the end node
        edge - the edge (for future information)
        data - the data object to add a "types" field
      • collectTypes

        private void collectTypes​(net.ssehub.easy.varModel.confModel.IDecisionVariable set,
                                  java.util.function.Predicate<java.lang.Boolean> direction,
                                  java.util.function.Consumer<java.lang.String> consumer)
        Collects IIP-Ecosphere data types.
        Parameters:
        set - the set of decisions to process
        direction - a directional predicate over forward/backward types
        consumer - processes identified type names
      • nextCount

        private int nextCount​(IvmlGraphMapper.IvmlGraphNode node,
                              java.util.Map<IvmlGraphMapper.IvmlGraphNode,​java.lang.Integer> counts)
        Returns the next input/output count for node with respect to the counting map counts. A call will modify counts as a side effect on the entry for node, either setting it to 1 or incrementing it by one.
        Parameters:
        node - the note to return the count for
        counts - the counting map to use
        Returns:
        the counter