1 package org.simantics.structural.synchronization.base;
\r
3 import org.simantics.db.ReadGraph;
\r
4 import org.simantics.db.exception.DatabaseException;
\r
5 import org.simantics.db.layer0.variable.Variable;
\r
8 * Utility for updating UIDs in the given component to correspond
\r
9 * the RVIs of the given variable. This operation is needed when
\r
10 * the mapping is part of a model that is imported to a new database
\r
11 * and resource ids have been changed.
\r
13 * @author Hannu Niemistö
\r
15 public class UpdateComponentUids {
\r
17 public static <T extends ComponentBase<T>> void update(ReadGraph graph, T component, Variable variable) throws DatabaseException {
\r
18 component.uid = variable.getRVI(graph).toString();
\r
19 for(Variable childVariable : variable.getChildren(graph)) {
\r
20 String childName = childVariable.getName(graph);
\r
21 T childComponent = component.getChild(childName);
\r
22 if(childComponent != null)
\r
23 update(graph, childComponent, childVariable);
\r