From: Tuukka Lehtonen Date: Wed, 11 Sep 2019 21:41:46 +0000 (+0000) Subject: Merge changes I78c3a258,I7bf72f04 X-Git-Tag: v1.43.0~136^2~70 X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=commitdiff_plain;h=b000e272429e157638c0384878b07b8dcd758472;hp=5e7529d05dde6a355305f9af1682de4cc0b31526 Merge changes I78c3a258,I7bf72f04 * changes: Handle componentless parent nodes of UCs in synchronization Added logging for history archive import failure cases --- diff --git a/bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java b/bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java index 39c084cad..343adefc8 100644 --- a/bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java +++ b/bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java @@ -68,6 +68,8 @@ import org.simantics.simulation.Activator; 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; @@ -80,6 +82,8 @@ import net.jpountz.lz4.LZ4BlockOutputStream; */ public class HistoryUtil { + private static final Logger LOGGER = LoggerFactory.getLogger(HistoryUtil.class); + private static final boolean DEBUG = false; private static final boolean PROFILE = true; @@ -663,6 +667,9 @@ public class HistoryUtil { 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; } } diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java index 67b120b64..095640c4a 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java @@ -201,10 +201,14 @@ public abstract class SynchronizationEventHandlerBase // 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) { @@ -334,6 +338,17 @@ public abstract class SynchronizationEventHandlerBase } } + 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 + ")");