X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FTypicals.scl;fp=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FTypicals.scl;h=a16ea6c0a15d6413097533fa33b56255a7c68d54;hb=8e4e41fa135641b23f68e205832e0696951c5f63;hp=0000000000000000000000000000000000000000;hpb=7a7c389f2ffddb4e4170098e4f5facca1fa8b633;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/scl/Simantics/Typicals.scl b/bundles/org.simantics.modeling/scl/Simantics/Typicals.scl new file mode 100644 index 000000000..a16ea6c0a --- /dev/null +++ b/bundles/org.simantics.modeling/scl/Simantics/Typicals.scl @@ -0,0 +1,55 @@ +import "Simantics/Ontologies" +import "Simantics/Model" + +@private +toDiagrams composites = map (flip singleObject MOD.CompositeToDiagram) composites + +@private +importJava "org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances" where + syncTypicals :: Boolean -> [Resource] -> [Resource] -> () + +""" + syncAllTypicals False currentModel + +Synchronizes all typical master diagrams in the specified model with all +instances of the found typical master diagrams. + +The first argument controls whether a log of the synchronization will be +stored in the database, in the model's Documents folder. +""" +syncAllTypicals :: Boolean -> Resource -> () +syncAllTypicals log model = syncInstancesOfTypicalMasters log masterComposites + where + masterComposites = lift2Read searchByTypeShallow model MOD.MasterTypicalCompositeType + +""" + syncInstancesOfTypicalMasters False [aMasterTypicalComposite] + +Synchronizes all instances of the specified typical master diagram(s). + +The first argument controls whether a log of the synchronization will be +stored in the database, in the model's Documents folder. + +The second argument expects diagram configuration composite resources. +""" +syncInstancesOfTypicalMasters :: Boolean -> [Resource] -> () +syncInstancesOfTypicalMasters log typicalMasterComposites = syncWrite (\_ -> syncTypicals log masterDiagrams []) + where + masterDiagrams = lift1Read toDiagrams typicalMasterComposites + +""" + syncTypicalInstances False [aTypicalInstance] + +Synchronizes the specified typical instance diagram(s) with their master +diagrams. + +The first argument controls whether a log of the synchronization will be +stored in the database, in the model's Documents folder. + +The second argument expects diagram configuration composite resources. +""" +syncTypicalInstances :: Boolean -> [Resource] -> () +syncTypicalInstances log typicalInstanceComposites = let + instanceDiagrams = lift1Read toDiagrams typicalInstanceComposites + in + syncWrite (\_ -> syncTypicals log [] instanceDiagrams)