Skip to content

Commit

Permalink
Merge pull request #839 from virtualcell/838-health-monitor-typical-s…
Browse files Browse the repository at this point in the history
…aves

Health Monitor clears all keys before saving BioModel in sim test.
  • Loading branch information
jcschaff authored Mar 20, 2023
2 parents aca89dd + ff6f12e commit be96c86
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private void runsimLoop() {

BioModel templateBioModel = XmlHelper.XMLToBioModel(new XMLSource(vcmlString));
templateBioModel.clearVersion();
templateBioModel.visitChildVersionables(new BioModel.ClearVersion());
String newBiomodelName = "test_"+System.currentTimeMillis();
templateBioModel.setName(newBiomodelName);
// remove all existing simulations from stored template model, and add new one
Expand Down
27 changes: 27 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/biomodel/BioModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import cbit.image.VCImage;
Expand Down Expand Up @@ -186,6 +187,32 @@ public List<VersionableInfo> gatherChildVersionableInfos() {
return new ArrayList<>(versionSet);
}

public final static class ClearVersion implements Consumer<Versionable> {
@Override
public void accept(Versionable versionable) {
versionable.clearVersion();
}
}

public void visitChildVersionables(Consumer<Versionable> operation) {
operation.accept(getModel());
for (SimulationContext sc : getSimulationContexts()){
operation.accept(sc);
if (sc.getGeometry()!=null){
operation.accept(sc.getGeometry());
if (sc.getGeometry().getGeometrySpec().getImage()!=null){
operation.accept(sc.getGeometry().getGeometrySpec().getImage());
}
}
if (sc.getMathDescription() != null){
operation.accept(sc.getMathDescription());
}
}
for (Simulation sim : getSimulations()){
operation.accept(sim);
}
}

/**
* The addPropertyChangeListener method was generated to support the propertyChange field.
*/
Expand Down

0 comments on commit be96c86

Please sign in to comment.