Module Simantics/DiagramMapping

This module is undocumented. This is a list of its definitions.

applyConnectionTypes :: MMap.T (DiagramElement Resource) (Resource, Resource) -> <Proc,WriteGraph,ReadGraph> ()

Determines and writes the connection type of every connection of the given element map. The map is the one that store fills in during a translation: it maps an element specification to its source and its target resource, and the connection type is written to the target.

compositeOf :: Resource -> <ReadGraph> Resource

Returns the configuration composite of the given diagram resource. The opposite direction of diagramOf.

diagramOf :: Resource -> <ReadGraph> Resource

Returns the diagram resource of the given configuration composite. The opposite direction of compositeOf.

doElementPostProcessing :: MMap.T (DiagramElement Resource) (Resource, Resource) -> (DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ()) -> <WriteGraph,Proc> ()
doElementPostProcessing elementMap elementPostProcessing

Calls elementPostProcessing once for every entry of the given element map with the element specification, its source resource and its target resource. The entries are processed grouped by the database cluster of the target resource.

getTargetComponent :: Resource -> Resource -> <ReadGraph> Maybe Resource
getTargetDiagram :: Resource -> Resource -> <ReadGraph> Maybe Resource
makeSpec :: Resource -> Resource -> Resource -> Resource -> <WriteGraph,ReadGraph> DiagramSpec
makeSpec targetModel sourceDiagram folderType compositeType

Returns the DiagramSpec for translating sourceDiagram into targetModel: the existing diagram at the same model configuration relative path if the target model already has one, and otherwise a new diagram at that path with the given folder and composite types.

possibleDrawingTemplate :: Resource -> Resource -> <ReadGraph> Maybe Resource
possibleDrawingTemplate model diagram

Returns the drawing template of model that has the same name as the drawing template of the given diagram. Nothing if the diagram has no drawing template or if the model has no template of that name. Fails if the model has no Diagram Templates library.

store :: MMap.T (DiagramElement Resource) (Resource, Resource) -> DiagramElement Resource -> Resource -> Resource -> <Proc,WriteGraph,ReadGraph> ()
store elementMap elementSpec sourceResource targetResource

Records in elementMap that elementSpec was read from sourceResource and written as targetResource.

translateDiagram :: Resource -> Resource -> Resource -> Resource -> (Resource -> <ReadGraph> [(DiagramElement Resource, Resource)]) -> (Dynamic -> <WriteGraph> Resource) -> MMap.T (DiagramElement Resource) (Resource, Resource) -> (Resource -> Resource -> <WriteGraph,Proc> ()) -> Resource -> <WriteGraph,Proc> ()
translateDiagram sourceModel targetModel folderType compositeType f joinMap
                 elementMap diagramPostProcessing sourceDiagram

Translates one diagram of a model into targetModel, which is what translateDiagrams does for a list of diagrams. Dependency tracking is disabled for the write. The drawing template of the target diagram is replaced with the template of targetModel that has the same name as the template of the source diagram, and removed if there is no such template. The source and the target resource of every written element are stored in elementMap and diagramPostProcessing is called with the source and the target diagram in the end. The sourceModel argument is not used.

translateDiagram2 :: Resource -> Resource -> Resource -> Resource -> (Resource -> <ReadGraph> [(DiagramElement Resource, Resource)]) -> (Dynamic -> <WriteGraph> Resource) -> MMap.T (DiagramElement Resource) (Resource, Resource) -> <WriteGraph,Proc> Resource
translateDiagram2 targetModel sourceDiagram folderType compositeType f
                  joinMap elementMap

Writes the elements that f reads from sourceDiagram into the corresponding diagram of targetModel and returns that diagram. Connections and monitors are written after the other elements because they refer to them. The source and the target resource of every element are stored in elementMap.

translateDiagrams :: Resource -> Resource -> Resource -> Resource -> (Resource -> <ReadGraph> [(DiagramElement Resource, Resource)]) -> (Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ()) -> (DiagramElement Resource -> Resource -> Resource -> <Proc,ReadGraph,WriteGraph> ()) -> [Resource] -> <WriteGraph,Proc> ()
translateDiagrams sourceModel targetModel folderType compositeType
                  diagramConstructor diagramPostProcessing
                  elementPostProcessing sourceDiagrams

Copies the given diagrams of sourceModel into targetModel.

Each source diagram is read into a list of element specifications by diagramConstructor and those elements are written into the diagram that has the same model configuration relative path in the target model. A target diagram that does not exist yet is created as a composite of compositeType, and the folders leading to it as composites of folderType. diagramPostProcessing is called with the source and the target diagram right after the elements of one diagram have been written.

All the diagrams are translated with one shared join map, so flags of different diagrams can be joined to each other. When every diagram has been written, the connection types are applied to the translated connections, the diagram to composite mapping is run for each target diagram and elementPostProcessing is called for every translated element.