Skip to content

Commit d2e18f4

Browse files
committed
fix restoring of deleted suids, refs #319
1 parent 59ad601 commit d2e18f4

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/model/io/SessionModelIO.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,21 @@ private boolean restoreModelFromTables(CySession session) {
162162
private static Set<Long> mapSuids(Set<Long> oldSuids, CySession session, Class<? extends CyIdentifiable> type) {
163163
Set<Long> newSuids = new HashSet<>();
164164

165-
for (Long suid : oldSuids) {
165+
for (Long oldSuid : oldSuids) {
166166
if (session != null) {
167-
// If we are loading from a session file then we need to re-map the ids
168-
CyIdentifiable obj = session.getObject(suid, type);
169-
suid = obj.getSUID();
167+
// If we are loading from a session file then we need to re-map the IDs.
168+
CyIdentifiable obj = session.getObject(oldSuid, type);
169+
if(obj == null) {
170+
// Case where nodes/edges might have been deleted.
171+
// We have to do the check here because older session files might not be saved properly.
172+
System.err.println("EnrichmentMap: SUID not found: " + oldSuid);
173+
} else {
174+
Long suid = obj.getSUID();
175+
newSuids.add(suid);
176+
}
177+
} else {
178+
newSuids.add(oldSuid);
170179
}
171-
newSuids.add(suid);
172180
}
173181
return newSuids;
174182
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/legend/CreationParametersPanel.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.awt.BorderLayout;
66
import java.io.File;
77
import java.io.StringWriter;
8+
import java.util.List;
89
import java.util.Map;
910

1011
import javax.swing.JPanel;
@@ -89,10 +90,14 @@ else if (params.getSimilarityMetric() == SimilarityMetric.COMBINED)
8990
ol();
9091
map.getDataSetList().forEach(this::addDataSet);
9192
end();
92-
addTitle("Signature Data Sets");
93-
ol();
94-
map.getSignatureSetList().forEach(this::addSignatureDataSet);
95-
end();
93+
94+
List<EMSignatureDataSet> sigSets = map.getSignatureSetList();
95+
if(sigSets != null && !sigSets.isEmpty()) {
96+
addTitle("Signature Data Sets");
97+
ol();
98+
sigSets.forEach(this::addSignatureDataSet);
99+
end();
100+
}
96101
end();
97102
endAll();
98103
done();

0 commit comments

Comments
 (0)