import org.simantics.simulation.ontology.HistoryResource;
import org.simantics.simulation.ontology.SimulationResource;
import org.simantics.utils.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.TObjectLongMap;
import gnu.trove.map.hash.TObjectLongHashMap;
*/
public class HistoryUtil {
+ private static final Logger LOGGER = LoggerFactory.getLogger(HistoryUtil.class);
+
private static final boolean DEBUG = false;
private static final boolean PROFILE = true;
try (RandomAccessBinary rab = new BinaryFile(path.toFile())) {
importHistoryArchive(history, rab, result);
return result;
+ } catch (IOException e) {
+ LOGGER.error("Failed to import history from archive {}", path);
+ throw e;
}
}
// TODO these two lines can be removed when IncludedInSimulation -property is given to all composites
if(component.getParent() != null) {
- String parentName = solver.getName(component.getParent().getModuleId());
- solver.includeSubprocess(parentName, subprocessName);
- component.solverComponentName = subprocessName;
- solverComponentNameToComponent.put(subprocessName, component);
+ int nearestParentId = getNearestParentComponentId(component);
+ if (nearestParentId <= 0) {
+ throw new SynchronizationException("Could not find parent with non-zero component id from Component("+name+", " + (component != null ? component.uid : "null") + "," + typeId + ")");
+ }
+ String parentName = solver.getName(nearestParentId);
+ solver.includeSubprocess(parentName, subprocessName);
+ component.solverComponentName = subprocessName;
+ solverComponentNameToComponent.put(subprocessName, component);
}
if(updater.isComposite) {
}
}
+ private static int getNearestParentComponentId(ComponentBase<?> component) {
+ ComponentBase<?> parent = component.getParent();
+ while (parent != null) {
+ int pid = parent.getModuleId();
+ if (pid > 0)
+ return pid;
+ parent = parent.getParent();
+ }
+ return -1;
+ }
+
protected void addPendingRemoval(T component) {
if (TRACE_EVENTS)
System.out.println("addPendingRemoval(" + component.componentId + " : " + component.solverComponentName + ")");