Skip to content

Commit

Permalink
in Health monitor, set BioModel keys to random prior to save
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Mar 20, 2023
1 parent be96c86 commit a0dc87c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void runsimLoop() {

BioModel templateBioModel = XmlHelper.XMLToBioModel(new XMLSource(vcmlString));
templateBioModel.clearVersion();
templateBioModel.visitChildVersionables(new BioModel.ClearVersion());
templateBioModel.visitChildVersionables(new BioModel.SetRandomVersionKeys());
String newBiomodelName = "test_"+System.currentTimeMillis();
templateBioModel.setName(newBiomodelName);
// remove all existing simulations from stored template model, and add new one
Expand Down
10 changes: 10 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 @@ -194,6 +194,15 @@ public void accept(Versionable versionable) {
}
}

public final static class SetRandomVersionKeys implements Consumer<Versionable> {
@Override
public void accept(Versionable versionable) {
if (versionable.getVersion()!=null){
versionable.getVersion().testFixtureRandomizeKeys();
}
}
}

public void visitChildVersionables(Consumer<Versionable> operation) {
operation.accept(getModel());
for (SimulationContext sc : getSimulationContexts()){
Expand All @@ -213,6 +222,7 @@ public void visitChildVersionables(Consumer<Versionable> operation) {
}
}


/**
* The addPropertyChangeListener method was generated to support the propertyChange field.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public SimulationVersion(KeyValue versionKeyNew, String versionNameNew, org.vcel
this.parentSimulationReference = argParentSimulationReference;
}

@Deprecated
public void testFixtureRandomizeKeys() {
super.testFixtureRandomizeKeys();
parentSimulationReference = null;
}

/**
* Insert the method's description here.
Expand Down
11 changes: 7 additions & 4 deletions vcell-core/src/main/java/org/vcell/util/document/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.*;

import org.vcell.util.BeanUtils;
import org.vcell.util.Compare;
Expand Down Expand Up @@ -59,6 +56,12 @@ public Version(String name, User owner) {
this.versionOwner = owner;
}

@Deprecated
public void testFixtureRandomizeKeys() {
versionKey = new KeyValue(Long.toString(new Random().nextLong()));
versionBranchID = new BigDecimal(Long.toString(new Random().nextLong()));
}

public List<Object> compare(Object obj) {

List<Object> diff = new ArrayList<Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@ public String saveBioModel(QueryHashtable dbc, User user, String bioModelXML, St
List<BioModel.VersionableInfo> versionableInfos = origBioModel.gatherChildVersionableInfos();
lg.info("Cached Biomodel("+key+"): "+versionableInfos);
}
// }else{
// User forceClearVersionUser = new User("forceClearVersionUser",new KeyValue("0"));
// forceDeepDirtyIfForeign(forceClearVersionUser, bioModel);
}

boolean bSomethingChanged = false;
Expand Down

0 comments on commit a0dc87c

Please sign in to comment.