Class DrawflowGraphFormat.GraphWriter
java.lang.Object
de.iip_ecosphere.platform.configuration.DrawflowGraphFormat.GraphWriter
- Enclosing class:
DrawflowGraphFormat
Instance to map and write a graph.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IvmlGraphMapper.IvmlGraphprivate Map<IvmlGraphMapper.IvmlGraphNode, Integer> private Map<IvmlGraphMapper.IvmlGraphNode, String> private Map<IvmlGraphMapper.IvmlGraphNode, Integer> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCreates a writer forgraph. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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, Predicate<Boolean> direction, Consumer<String> consumer) Collects IIP-Ecosphere data types.private StringgetId(IvmlGraphMapper.IvmlGraphNode node, String dflt) Returns the ID of the node in terms of its IVML variable name.private voidmapNodes()Maps the nodes ofgraphto ids.private intReturns 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, 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, Iterable<? extends IvmlGraphMapper.IvmlGraphEdge> edges, boolean inputEdges) Writes the given edges.private StringWrites the graph to a JSON string.private org.json.simple.JSONObjectWrites the "home" data section.
-
Field Details
-
node2id
-
graph
-
inputCounts
-
outputCounts
-
-
Constructor Details
-
GraphWriter
Creates a writer forgraph.- Parameters:
graph- the graph to write
-
-
Method Details
-
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, 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
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
Writes the graph to a JSON string.- Returns:
- the JSON string
-
writeEdges
private org.json.simple.JSONObject writeEdges(IvmlGraphMapper.IvmlGraphNode node, 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, Predicate<Boolean> direction, Consumer<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, Map<IvmlGraphMapper.IvmlGraphNode, 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
-