]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/MigrateModel.java
(refs #7453) Switch component type of the component
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / MigrateModel.java
index 16b8ae92aeca27e2e407f3e0bf911a5fc7c4e2ba..dee74b0e1d1b98bf9d499d48c84a0b43650774b3 100644 (file)
@@ -216,4 +216,10 @@ public class MigrateModel {
        public List<Triple<String, NamedResource, Collection<MigrationOperation>>> instances = new ArrayList<>();
        public List<MigrationOperation> sortedShownInstances = Collections.emptyList();
 
+       public static void changeComponentType(WriteGraph graph, Resource instance, Resource newComponentType) throws DatabaseException {
+           ModelingResources MOD = ModelingResources.getInstance(graph);
+           Resource newSymbol = graph.getSingleObject(newComponentType, MOD.ComponentTypeToSymbol);
+           new MigrationOperation(new NamedResource("", instance), new NamedResource("", newComponentType), new NamedResource("", newSymbol))
+           .perform(graph);
+       }
 }