--- /dev/null
+package org.simantics.structural.synchronization.base;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+\r
+/**\r
+ * Utility for updating UIDs in the given component to correspond\r
+ * the RVIs of the given variable. This operation is needed when\r
+ * the mapping is part of a model that is imported to a new database\r
+ * and resource ids have been changed.\r
+ * \r
+ * @author Hannu Niemistö\r
+ */\r
+public class UpdateComponentUids {\r
+ \r
+ public static <T extends ComponentBase<T>> void update(ReadGraph graph, T component, Variable variable) throws DatabaseException {\r
+ component.uid = variable.getRVI(graph).toString();\r
+ for(Variable childVariable : variable.getChildren(graph)) {\r
+ String childName = childVariable.getName(graph);\r
+ T childComponent = component.getChild(childName);\r
+ if(childComponent != null)\r
+ update(graph, childComponent, childVariable);\r
+ }\r
+ }\r
+ \r
+}\r