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