The map can be used to migrate also some other structures containing
uids.
[PRIVATE-12930]
Change-Id: I9b621eb83a86dcf424b56010249e170cc4bc8741
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
+import gnu.trove.map.hash.THashMap;
+
/**
* 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.
/**
* 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ö
* @author Tuukka Lehtonen
*/
* @author Hannu Niemistö
* @author Tuukka Lehtonen
*/
void componentsDone(int components, int componentCount);
}
void componentsDone(int components, int componentCount);
}
+ private THashMap<String, String> oldToNewUids;
private IProgressMonitor monitor;
private ComponentUpdateProgressMonitor componentMonitor;
private ReadGraph graph;
private IProgressMonitor monitor;
private ComponentUpdateProgressMonitor componentMonitor;
private ReadGraph graph;
- private int componentCount;
+ private int componentCount;
private int counter;
private UpdateComponentUids(IProgressMonitor monitor, ReadGraph graph, int componentCount) {
private int counter;
private UpdateComponentUids(IProgressMonitor monitor, ReadGraph graph, int componentCount) {
}
private void update(T component, Variable variable) throws DatabaseException {
}
private void update(T component, Variable variable) throws DatabaseException {
- component.uid = variable.getRVI(graph).toString();
+ String newUid = variable.getRVI(graph).toString();
+ oldToNewUids.put(component.uid, newUid);
+ component.uid = newUid;
// Handle progress monitoring and cancellation
counter++;
// Handle progress monitoring and cancellation
counter++;
- public static <T extends ComponentBase<T>> void update(ReadGraph graph, T component, Variable variable) throws DatabaseException {
- update(null, graph, component, variable);
+ public static <T extends ComponentBase<T>> THashMap<String, String> update(ReadGraph graph, T component, Variable variable) throws DatabaseException {
+ return update(null, graph, component, variable);
- public static <T extends ComponentBase<T>> void update(IProgressMonitor monitor, ReadGraph graph, T component, Variable variable) throws DatabaseException {
- new UpdateComponentUids<T>(monitor, graph, countComponents(component)).update(component, variable);
+ public static <T extends ComponentBase<T>> THashMap<String, String> update(IProgressMonitor monitor, ReadGraph graph, T component, Variable variable) throws DatabaseException {
+ UpdateComponentUids<T> updateComponentUids = new UpdateComponentUids<T>(monitor, graph, countComponents(component));
+ updateComponentUids.update(component, variable);
+ return updateComponentUids.oldToNewUids;
}
public static <T extends ComponentBase<T>> int countComponents(T component) {
}
public static <T extends ComponentBase<T>> int countComponents(T component) {