Class DrawflowGraphFormat.GraphWriter
- java.lang.Object
-
- de.iip_ecosphere.platform.configuration.DrawflowGraphFormat.GraphWriter
-
- Enclosing class:
- DrawflowGraphFormat
private static class DrawflowGraphFormat.GraphWriter extends java.lang.ObjectInstance to map and write a graph.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private IvmlGraphMapper.IvmlGraphgraphprivate java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.Integer>inputCountsprivate java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.String>node2idprivate java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.Integer>outputCounts
-
Constructor Summary
Constructors Modifier Constructor Description privateGraphWriter(IvmlGraphMapper.IvmlGraph graph)Creates a writer forgraph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcollectForwardTypes(IvmlGraphMapper.IvmlGraphNode start, IvmlGraphMapper.IvmlGraphNode end, IvmlGraphMapper.IvmlGraphEdge edge, org.json.simple.JSONObject data)Collects common forward types between the nodes involved inedgeand adds the results as "type"-array todata.private voidcollectTypes(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.private java.lang.StringgetId(IvmlGraphMapper.IvmlGraphNode node, java.lang.String dflt)Returns the ID of the node in terms of its IVML variable name.private voidmapNodes()Maps the nodes ofgraphto ids.private intnextCount(IvmlGraphMapper.IvmlGraphNode node, java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.Integer> counts)Returns the next input/output count fornodewith respect to the counting mapcounts.private voidprocessBackward(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 calledname.private voidserviceToData(net.ssehub.easy.varModel.confModel.IDecisionVariable service, org.json.simple.JSONObject data)Turns service information into data for the editor.private org.json.simple.JSONObjectwriteEdges(IvmlGraphMapper.IvmlGraphNode node, java.lang.Iterable<? extends IvmlGraphMapper.IvmlGraphEdge> edges, boolean inputEdges)Writes the given edges.private java.lang.StringwriteGraph()Writes the graph to a JSON string.private org.json.simple.JSONObjectwriteHomeData()Writes the "home" data section.
-
-
-
Field Detail
-
node2id
private java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.String> node2id
-
graph
private IvmlGraphMapper.IvmlGraph graph
-
inputCounts
private java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.Integer> inputCounts
-
outputCounts
private java.util.Map<IvmlGraphMapper.IvmlGraphNode,java.lang.Integer> outputCounts
-
-
Constructor Detail
-
GraphWriter
private GraphWriter(IvmlGraphMapper.IvmlGraph graph)
Creates a writer forgraph.- Parameters:
graph- the graph to write
-
-
Method Detail
-
mapNodes
private void mapNodes()
Maps the nodes ofgraphto 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 nulldata- 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 calledname.- Parameters:
set- denotes the type set (input/output) to be analyzeddata- the data object to be modifiedname- 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 nodedflt- 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 theedgesedges- the edges to writeinputEdges- 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 inedgeand adds the results as "type"-array todata.- Parameters:
start- the start nodeend- the end nodeedge- 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 processdirection- a directional predicate over forward/backward typesconsumer- 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 fornodewith respect to the counting mapcounts. A call will modifycountsas 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 forcounts- the counting map to use- Returns:
- the counter
-
-