use of cbit.vcell.numericstest.TestCaseNew in project vcell by virtualcell.
the class TestingFrameworkWindowManager method addTestCases.
/**
* Insert the method's description here.
* Creation date: (4/10/2003 11:27:32 AM)
* @param testCase cbit.vcell.numericstestingframework.TestCase
*/
public String addTestCases(final TestSuiteInfoNew tsInfo, final TestCaseNew[] testCaseArray, int regrRefFlag, ClientTaskStatusSupport pp) {
if (tsInfo == null) {
throw new IllegalArgumentException("TestSuiteInfo cannot be null");
}
if (testCaseArray == null || testCaseArray.length == 0) {
throw new IllegalArgumentException("TestCases cannot be null / empty");
}
// make modifiable list
List<TestCaseNew> testCases = new ArrayList<>(Arrays.asList(testCaseArray));
StringBuffer errors = new StringBuffer();
// When a testCase (mathmodel/biomodel) is added to a testSuite, a new version of the mathModel/biomodel should be created.
// Also, the simulations in the original mathmodel/biomodel should be rid of their parent simulation reference.
pp.setMessage("Getting testSuite");
pp.setProgress(1);
TestSuiteNew testSuite = null;
try {
testSuite = getRequestManager().getDocumentManager().getTestSuite(tsInfo.getTSKey());
} catch (Throwable e) {
throw new RuntimeException("couldn't get test suite " + tsInfo.getTSID() + "\n" + e.getClass().getName() + " mesg=" + e.getMessage() + "\n");
}
if (testSuite != null && testSuite.getTSInfoNew().isLocked()) {
throw new RuntimeException("Cannot addTestCases to locked table");
}
if (testSuite != null) {
// Saving BioModels
TestCaseNew[] existingTestCases = testSuite.getTestCases();
java.util.HashMap<KeyValue, BioModel> bioModelHashMap = new java.util.HashMap<KeyValue, BioModel>();
// if(existingTestCases != null){
// Find BioModels, Using the same BM reference for sibling Applications
int pcounter = 0;
// use iterator to allow removal of test case from collection if exception
Iterator<TestCaseNew> iter = testCases.iterator();
while (iter.hasNext()) {
TestCaseNew testCase = iter.next();
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
//
if (bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey()) == null) {
pp.setMessage("Getting BM " + testCase.getVersion().getName());
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
if (!bioModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
throw new Exception("BioModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
}
//
// if biomodel already exists in same testsuite, then use this BioModel edition
//
BioModel newBioModel = null;
if (existingTestCases != null) {
for (int j = 0; newBioModel == null && j < existingTestCases.length; j++) {
if (existingTestCases[j] instanceof TestCaseNewBioModel) {
TestCaseNewBioModel existingTestCaseBioModel = (TestCaseNewBioModel) existingTestCases[j];
//
if (existingTestCaseBioModel.getBioModelInfo().getVersion().getBranchID().equals(bioTestCase.getBioModelInfo().getVersion().getBranchID())) {
//
if (existingTestCaseBioModel.getBioModelInfo().getVersion().getVersionKey().equals(bioTestCase.getBioModelInfo().getVersion().getVersionKey())) {
//
// same, store this "unchanged" in bioModelHashMap
//
newBioModel = bioModel;
} else {
//
throw new Exception("can't add new test case using (" + bioTestCase.getBioModelInfo().getVersion().getName() + " " + bioTestCase.getBioModelInfo().getVersion().getDate() + ")\n" + "a test case already exists with different edition of same BioModel dated " + existingTestCaseBioModel.getBioModelInfo().getVersion().getDate());
}
}
}
}
}
if (newBioModel == null) {
pp.setMessage("Saving BM " + testCase.getVersion().getName());
//
// some older models have membrane voltage variable names which are not unique
// (e.g. membranes 'pm' and 'nm' both have membrane voltage variables named 'Voltage_Membrane0')
//
// if this is the case, we will try to repair the conflict (for math testing purposes only) by renaming the voltage variables to their default values.
//
// Ordinarily, the conflict will be identified as an "Error" issue and the user will be prompted to repair before saving or math generation.
//
bioModel.refreshDependencies();
boolean bFoundIdentifierConflictUponLoading = hasDuplicateIdentifiers(bioModel);
if (bFoundIdentifierConflictUponLoading) {
//
// look for two MembraneVoltage instances with same variable name, rename all
//
HashSet<String> membraneVoltageVarNames = new HashSet<String>();
ArrayList<MembraneVoltage> membraneVoltageVars = new ArrayList<MembraneVoltage>();
for (Structure struct : bioModel.getModel().getStructures()) {
if (struct instanceof Membrane) {
MembraneVoltage membraneVoltage = ((Membrane) struct).getMembraneVoltage();
if (membraneVoltage != null) {
membraneVoltageVars.add(membraneVoltage);
membraneVoltageVarNames.add(membraneVoltage.getName());
}
}
}
if (membraneVoltageVars.size() != membraneVoltageVarNames.size()) {
// rename them all to the default names
for (MembraneVoltage memVoltage : membraneVoltageVars) {
memVoltage.setName(Membrane.getDefaultMembraneVoltageName(memVoltage.getMembrane().getName()));
}
}
}
SimulationContext[] simContexts = bioModel.getSimulationContexts();
for (int j = 0; j < simContexts.length; j++) {
simContexts[j].clearVersion();
GeometrySurfaceDescription gsd = simContexts[j].getGeometry().getGeometrySurfaceDescription();
if (gsd != null) {
GeometricRegion[] grArr = gsd.getGeometricRegions();
if (grArr == null) {
gsd.updateAll();
}
}
MathMapping mathMapping = simContexts[j].createNewMathMapping();
// for older models that do not have absolute compartment sizes set, but have relative sizes (SVR/VF); or if there is only one compartment with size not set,
// compute absolute compartment sizes using relative sizes and assuming a default value of '1' for one of the compartments.
// Otherwise, the math generation will fail, since for the relaxed topology (VCell 5.3 and later) absolute compartment sizes are required.
GeometryContext gc = simContexts[j].getGeometryContext();
if (simContexts[j].getGeometry().getDimension() == 0 && ((gc.isAllSizeSpecifiedNull() && !gc.isAllVolFracAndSurfVolSpecifiedNull()) || (gc.getModel().getStructures().length == 1 && gc.isAllSizeSpecifiedNull()))) {
// choose the first structure in model and set its size to '1'.
Structure struct = simContexts[j].getModel().getStructure(0);
double structSize = 1.0;
StructureSizeSolver.updateAbsoluteStructureSizes(simContexts[j], struct, structSize, struct.getStructureSize().getUnitDefinition());
}
simContexts[j].setMathDescription(mathMapping.getMathDescription());
}
Simulation[] sims = bioModel.getSimulations();
String[] simNames = new String[sims.length];
for (int j = 0; j < sims.length; j++) {
// prevents parent simulation (from the original mathmodel) reference connection
// Otherwise it will refer to data from previous (parent) simulation.
sims[j].clearVersion();
simNames[j] = sims[j].getName();
// if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
// sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
// }
}
newBioModel = getRequestManager().getDocumentManager().save(bioModel, simNames);
}
bioModelHashMap.put(bioTestCase.getBioModelInfo().getVersion().getVersionKey(), newBioModel);
}
}
} catch (Throwable e) {
String identifier = testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey();
if (lg.isInfoEnabled()) {
lg.info(identifier, e);
}
errors.append("Error collecting BioModel for TestCase " + identifier + '\n' + e.getClass().getName() + " " + e.getMessage() + '\n');
// remove to avoid further processing attempts
iter.remove();
}
}
// }
// then process each BioModelTestCase individually
// if(bioModelHashMap != null){
pcounter = 0;
for (TestCaseNew testCase : testCases) {
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
AddTestCasesOP testCaseOP = null;
if (testCase instanceof TestCaseNewBioModel) {
pp.setMessage("Processing BM " + testCase.getVersion().getName());
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
BioModel newBioModel = (BioModel) bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
if (newBioModel == null) {
throw new Exception("BioModel not found");
}
SimulationContext simContext = null;
for (int j = 0; j < newBioModel.getSimulationContexts().length; j++) {
if (newBioModel.getSimulationContext(j).getName().equals(bioTestCase.getSimContextName())) {
simContext = newBioModel.getSimulationContext(j);
}
}
Simulation[] newSimulations = simContext.getSimulations();
AddTestCriteriaOPBioModel[] testCriteriaOPs = new AddTestCriteriaOPBioModel[newSimulations.length];
for (int j = 0; j < newSimulations.length; j++) {
TestCriteriaNewBioModel tcritOrigForSimName = null;
for (int k = 0; bioTestCase.getTestCriterias() != null && k < bioTestCase.getTestCriterias().length; k += 1) {
if (bioTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
tcritOrigForSimName = (TestCriteriaNewBioModel) bioTestCase.getTestCriterias()[k];
break;
}
}
KeyValue regressionBioModelKey = null;
KeyValue regressionBioModelSimKey = null;
if (bioTestCase.getType().equals(TestCaseNew.REGRESSION)) {
if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
regressionBioModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionBioModelInfo() != null ? tcritOrigForSimName.getRegressionBioModelInfo().getVersion().getVersionKey() : null);
regressionBioModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
regressionBioModelKey = (tcritOrigForSimName != null ? bioTestCase.getBioModelInfo().getVersion().getVersionKey() : null);
regressionBioModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
regressionBioModelKey = newBioModel.getVersion().getVersionKey();
regressionBioModelSimKey = newSimulations[j].getVersion().getVersionKey();
} else {
throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) BIOMODEL Unknown Regression Operation Flag");
}
}
testCriteriaOPs[j] = new AddTestCriteriaOPBioModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionBioModelKey, regressionBioModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
}
testCaseOP = new AddTestCasesOPBioModel(new BigDecimal(tsInfo.getTSKey().toString()), newBioModel.getVersion().getVersionKey(), simContext.getKey(), bioTestCase.getType(), bioTestCase.getAnnotation(), testCriteriaOPs);
getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
}
} catch (Throwable e) {
errors.append("Error processing Biomodel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
}
}
// }
// Process MathModels
pcounter = 0;
for (TestCaseNew testCase : testCases) {
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
AddTestCasesOP testCaseOP = null;
if (testCase instanceof TestCaseNewMathModel) {
TestCaseNewMathModel mathTestCase = (TestCaseNewMathModel) testCase;
pp.setMessage("Getting MathModel " + testCase.getVersion().getName());
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mathTestCase.getMathModelInfo().getVersion().getVersionKey());
if (!mathModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
throw new Exception("MathModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
}
Simulation[] sims = mathModel.getSimulations();
String[] simNames = new String[sims.length];
for (int j = 0; j < sims.length; j++) {
// prevents parent simulation (from the original mathmodel) reference connection
// Otherwise it will refer to data from previous (parent) simulation.
sims[j].clearVersion();
simNames[j] = sims[j].getName();
// if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
// sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
// }
}
pp.setMessage("Saving MathModel " + testCase.getVersion().getName());
MathModel newMathModel = getRequestManager().getDocumentManager().save(mathModel, simNames);
Simulation[] newSimulations = newMathModel.getSimulations();
AddTestCriteriaOPMathModel[] testCriteriaOPs = new AddTestCriteriaOPMathModel[newSimulations.length];
for (int j = 0; j < newSimulations.length; j++) {
TestCriteriaNewMathModel tcritOrigForSimName = null;
for (int k = 0; mathTestCase.getTestCriterias() != null && k < mathTestCase.getTestCriterias().length; k += 1) {
if (mathTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
tcritOrigForSimName = (TestCriteriaNewMathModel) mathTestCase.getTestCriterias()[k];
break;
}
}
KeyValue regressionMathModelKey = null;
KeyValue regressionMathModelSimKey = null;
if (mathTestCase.getType().equals(TestCaseNew.REGRESSION)) {
if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
regressionMathModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionMathModelInfo() != null ? tcritOrigForSimName.getRegressionMathModelInfo().getVersion().getVersionKey() : null);
regressionMathModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
regressionMathModelKey = (tcritOrigForSimName != null ? mathTestCase.getMathModelInfo().getVersion().getVersionKey() : null);
regressionMathModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
regressionMathModelKey = newMathModel.getVersion().getVersionKey();
regressionMathModelSimKey = newSimulations[j].getVersion().getVersionKey();
} else {
throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) MATHMODEL Unknown Regression Operation Flag");
}
}
testCriteriaOPs[j] = new AddTestCriteriaOPMathModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionMathModelKey, regressionMathModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
}
testCaseOP = new AddTestCasesOPMathModel(new BigDecimal(tsInfo.getTSKey().toString()), newMathModel.getVersion().getVersionKey(), mathTestCase.getType(), mathTestCase.getAnnotation(), testCriteriaOPs);
getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
}
} catch (Throwable e) {
errors.append("Error processing MathModel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
}
}
}
if (errors.length() > 0) {
return errors.toString();
}
return null;
}
use of cbit.vcell.numericstest.TestCaseNew in project vcell by virtualcell.
the class TestingFrameworkWindowManager method duplicateTestSuite.
/**
* Insert the method's description here.
* Creation date: (4/10/2003 11:27:32 AM)
* @param testCase cbit.vcell.numericstestingframework.TestCase
*/
public String duplicateTestSuite(final TestSuiteInfoNew testSuiteInfo_Original, final TestSuiteInfoNew newTestSuiteInfo, int regrRefFlag, ClientTaskStatusSupport pp) throws DataAccessException {
if (testSuiteInfo_Original == null || newTestSuiteInfo == null) {
throw new IllegalArgumentException(this.getClass().getName() + "duplicateTestSuite_Private: TestSuite cannot be null");
}
checkNewTestSuiteInfo(newTestSuiteInfo);
TestSuiteNew testSuite_Original = getRequestManager().getDocumentManager().getTestSuite(testSuiteInfo_Original.getTSKey());
if (testSuite_Original == null) {
throw new DataAccessException("Couldn't get TestSuite for tsInfo " + testSuiteInfo_Original.getTSID());
}
AddTestSuiteOP testSuiteOP = new AddTestSuiteOP(newTestSuiteInfo.getTSID(), newTestSuiteInfo.getTSVCellBuild(), newTestSuiteInfo.getTSNumericsBuild(), null, newTestSuiteInfo.getTSAnnotation());
getRequestManager().getDocumentManager().doTestSuiteOP(testSuiteOP);
TestSuiteInfoNew[] tsinArr = getRequestManager().getDocumentManager().getTestSuiteInfos();
TestSuiteInfoNew tsin = null;
for (int i = 0; i < tsinArr.length; i += 1) {
if (tsinArr[i].getTSID().equals(newTestSuiteInfo.getTSID())) {
tsin = tsinArr[i];
break;
}
}
if (tsin == null) {
throw new DataAccessException("couldn't find new TestSuiteInfo " + newTestSuiteInfo.getTSID() + " in DB");
}
TestCaseNew[] originalTestCases = testSuite_Original.getTestCases();
TestCaseNew[] newTestCases = null;
if (originalTestCases != null && originalTestCases.length > 0) {
newTestCases = new TestCaseNew[originalTestCases.length];
for (int i = 0; i < originalTestCases.length; i += 1) {
if (originalTestCases[i] instanceof TestCaseNewMathModel) {
TestCaseNewMathModel tcnmm = (TestCaseNewMathModel) originalTestCases[i];
TestCriteriaNew[] tcritnmm = (TestCriteriaNew[]) tcnmm.getTestCriterias();
TestCriteriaNewMathModel[] newTCrits = null;
if (tcritnmm != null && tcritnmm.length > 0) {
// Copy regression and errors
newTCrits = new TestCriteriaNewMathModel[tcritnmm.length];
for (int j = 0; j < tcritnmm.length; j += 1) {
newTCrits[j] = new TestCriteriaNewMathModel(null, tcritnmm[j].getSimInfo(), ((TestCriteriaNewMathModel) tcritnmm[j]).getRegressionMathModelInfo(), tcritnmm[j].getRegressionSimInfo(), tcritnmm[j].getMaxRelError(), tcritnmm[j].getMaxAbsError(), null, // new will have no data
TestCriteriaNew.TCRIT_STATUS_NODATA, // new will have no data
null);
}
}
// copy mathmodel,type and annotation and copied tcrits
newTestCases[i] = new TestCaseNewMathModel(null, tcnmm.getMathModelInfo(), tcnmm.getType(), tcnmm.getAnnotation(), newTCrits);
} else if (originalTestCases[i] instanceof TestCaseNewBioModel) {
TestCaseNewBioModel tcnbm = (TestCaseNewBioModel) originalTestCases[i];
TestCriteriaNew[] tcritnbm = (TestCriteriaNew[]) tcnbm.getTestCriterias();
TestCriteriaNewBioModel[] newTCrits = null;
if (tcritnbm != null && tcritnbm.length > 0) {
// Copy regression and errors
newTCrits = new TestCriteriaNewBioModel[tcritnbm.length];
for (int j = 0; j < tcritnbm.length; j += 1) {
newTCrits[j] = new TestCriteriaNewBioModel(null, tcritnbm[j].getSimInfo(), ((TestCriteriaNewBioModel) tcritnbm[j]).getRegressionBioModelInfo(), ((TestCriteriaNewBioModel) tcritnbm[j]).getRegressionApplicationName(), tcritnbm[j].getRegressionSimInfo(), tcritnbm[j].getMaxRelError(), tcritnbm[j].getMaxAbsError(), null, // new will have no data
TestCriteriaNew.TCRIT_STATUS_NODATA, // new will have no data
null);
}
}
// copy mathmodel,type and annotation and copied tcrits
newTestCases[i] = new TestCaseNewBioModel(null, tcnbm.getBioModelInfo(), tcnbm.getSimContextName(), tcnbm.getSimContextKey(), tcnbm.getType(), tcnbm.getAnnotation(), newTCrits);
} else {
throw new RuntimeException("Unsupported TestCase type " + originalTestCases[i].getClass().getName());
}
}
}
// Add the new TestCases
if (newTestCases != null && newTestCases.length > 0) {
return addTestCases(tsin, newTestCases, regrRefFlag, pp);
} else {
return null;
}
}
use of cbit.vcell.numericstest.TestCaseNew in project vcell by virtualcell.
the class TestingFrameworkWindowManager method startTestSuiteSimulations.
/**
* Insert the method's description here.
* Creation date: (1/20/2003 11:52:18 AM)
* @return boolean
* @param mathDesc cbit.vcell.math.MathDescription
*/
public String startTestSuiteSimulations(TestSuiteInfoNew testSuiteInfo, ClientTaskStatusSupport pp) {
StringBuffer errors = new StringBuffer();
try {
pp.setProgress(1);
pp.setMessage("Getting TestSuite " + testSuiteInfo.getTSID());
TestSuiteNew testSuite = getRequestManager().getDocumentManager().getTestSuite(testSuiteInfo.getTSKey());
Vector<TestCriteriaNew> tcritVector = new Vector<TestCriteriaNew>();
TestCaseNew[] testCases = testSuite.getTestCases();
if (testCases != null) {
for (int i = 0; i < testCases.length; i++) {
TestCriteriaNew[] tCriteria = testCases[i].getTestCriterias();
if (tCriteria != null) {
for (int j = 0; j < tCriteria.length; j++) {
tcritVector.add(tCriteria[j]);
}
}
}
if (tcritVector.size() > 0) {
TestCriteriaNew[] tcritArray = (TestCriteriaNew[]) BeanUtils.getArray(tcritVector, TestCriteriaNew.class);
String errorString = startSimulations(tcritArray, pp);
if (errorString != null) {
errors.append(errorString + "\n");
}
}
}
} catch (Throwable e) {
errors.append(e.getClass().getName() + " " + e.getMessage());
}
if (errors.length() > 0) {
errors.insert(0, "Error starting TestSuite simulations\n");
return errors.toString();
}
return null;
}
use of cbit.vcell.numericstest.TestCaseNew in project vcell by virtualcell.
the class NumericsTestCellRenderer method getTreeCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (7/27/2000 6:41:57 PM)
* @return java.awt.Component
*/
public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
//
try {
if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
if (node.getUserObject() instanceof TestSuiteInfoNew) {
TestSuiteInfoNew tsn = (TestSuiteInfoNew) node.getUserObject();
// component.setText(tsn.getTSID()+" "+tsn.getTSVCellBuild()+" "+tsn.getTSNumericsBuild());
} else if (node.getUserObject() instanceof TestCaseNew) {
TestCaseNew testCase = (TestCaseNew) node.getUserObject();
boolean hasUnknown = false;
boolean isSimRunning = false;
boolean isSimFailed = false;
boolean isSimNotRunFialOrDone = false;
boolean hasReportErrors = false;
// boolean hasResult = false;
boolean hasNoRefRegr = false;
boolean hasFailures = false;
// AT LEAST ONE SIMULATION HAS NO DATA ...
boolean hasNoData = false;
boolean needsReport = false;
// }
if (testCase.getTestCriterias() != null) {
for (int i = 0; i < testCase.getTestCriterias().length; i += 1) {
TestCriteriaNew tcrit = testCase.getTestCriterias()[i];
if (tcrit.getReportStatus() != null) {
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT)) {
needsReport = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_RPERROR)) {
hasReportErrors = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NOREFREGR)) {
hasNoRefRegr = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_FAILEDVARS)) {
hasFailures = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NODATA)) {
hasNoData = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMRUNNING)) {
isSimRunning = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMFAILED)) {
isSimFailed = true;
}
if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE)) {
isSimNotRunFialOrDone = true;
}
}
}
}
// if(node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.SIMULATIONS_NO_REPORT) instanceof Boolean){
// Boolean tc_NR = (Boolean)node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.SIMULATIONS_NO_REPORT);
// if(tc_NR.booleanValue()){
// hasResult = false;
// }
// }
setComponentProperties(component, (TestCaseNew) node.getUserObject(), /*hasResult,*/
hasFailures, hasNoData, hasNoRefRegr, hasReportErrors, isSimRunning, isSimFailed, needsReport, isSimNotRunFialOrDone);
} else if (node.getUserObject() instanceof TestCriteriaNew) {
TestCriteriaNew testCriteria = (TestCriteriaNew) node.getUserObject();
String extraText = null;
if (!testCriteria.getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_PASSED)) {
extraText = testCriteria.getReportStatus() + " " + (testCriteria.getReportStatusMessage() != null ? " " + testCriteria.getReportStatusMessage().substring(0, Math.min(100, testCriteria.getReportStatusMessage().length())) : "");
}
component.setText("[" + testCriteria.getSimInfo().getVersion().getVersionKey() + "] " + testCriteria.getSimInfo().getVersion().getName() + (extraText != null ? " (" + extraText + ")" : ""));
component.setToolTipText(" Test Criteria info");
if (extraText != null) {
component.setForeground(java.awt.Color.magenta);
}
if (testCriteria.getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_FAILEDVARS)) {
component.setForeground(java.awt.Color.red);
}
// //TestCaseNew tcn = null;
// //javax.swing.tree.DefaultMutableTreeNode prevNode = (javax.swing.tree.DefaultMutableTreeNode)node.getParent();
// //if(prevNode != null && prevNode.getUserObject() instanceof cbit.vcell.numericstest.TestCaseNew){
// //tcn = (TestCaseNew)prevNode.getUserObject();
// //}
// boolean hasResult = false;
// TestCriteriaNew testCriteria = (TestCriteriaNew)node.getUserObject();
// if(testCriteria.getVarComparisonSummaries() != null && testCriteria.getVarComparisonSummaries().length != 0){
// hasResult = true;
// }
// //boolean hasNoRefRegr = false;
// //if(tcn != null){
// //if(tcn.getType().equals(cbit.vcell.numericstest.TestCaseNew.REGRESSION) &&
// //testCriteria.getRegressionSimInfo() == null){
// //hasNoRefRegr = true;
// //}
// //}
// if(!hasResult /*|| hasNoRefRegr*/){
// component.setForeground(java.awt.Color.magenta);
// }
// component.setText(testCriteria.getSimInfo().getVersion().getName()+
// (testCriteria.getReportStatus() != null &&
// testCriteria.getReportStatus().startsWith(TestCriteriaNew.TCRIT_STATUS_SIMRUNNING)?"(SimRunning)":"")+
// (testCriteria.getReportStatus() != null &&
// testCriteria.getReportStatus().startsWith(TestCriteriaNew.TCRIT_STATUS_SIMFAILED)?"(SimFailed)":"")
// /*+(hasNoRefRegr?" (No Ref Regr)":"")*/);
// component.setToolTipText(" Test Criteria info");
} else if (node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.FAILED_VARIABLE_MAE_MRE) instanceof Boolean) {
Boolean fv_MAE_MRE = (Boolean) node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.FAILED_VARIABLE_MAE_MRE);
if (fv_MAE_MRE.booleanValue()) {
component.setForeground(java.awt.Color.red);
} else {
component.setForeground(java.awt.Color.black);
}
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
//
return component;
}
use of cbit.vcell.numericstest.TestCaseNew in project vcell by virtualcell.
the class TestingFrameworkPanel method actionsOnMouseClick.
/**
* Comment
*/
private void actionsOnMouseClick(MouseEvent mouseEvent) {
if (mouseEvent.isPopupTrigger()) {
if (getJTree1().getSelectionCount() <= 1) {
getJTree1().setSelectionPath(getJTree1().getPathForLocation(mouseEvent.getPoint().x, mouseEvent.getPoint().y));
}
if (!checkAllSameType()) {
JPopupMenu jPopupMenu = new JPopupMenu();
jPopupMenu.add(selectIncompatibleWarning);
jPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
return;
}
if (isLoadTestPopup()) {
getLoadTestMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
} else if (getTreeSelection() instanceof String) {
if (((String) getTreeSelection()).equals(TestingFrmwkTreeModel.TEST_SUITE_SUBTREE_NAME)) {
getMainPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
} else if (getTreeSelection() instanceof TestingFrmwkTreeModel.TestCriteriaVarUserObj) {
getTCritVarPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
} else if (getTreeSelection() instanceof TestSuiteInfoNew) {
getRemoveDiffTestCriteriaJMenuItem().setEnabled(false);
if (getJTree1().getSelectionCount() == 2) {
TestSuiteInfoNew testSuiteInfoNew0 = (TestSuiteInfoNew) ((BioModelNode) getSelectedTreePaths()[0].getLastPathComponent()).getUserObject();
TestSuiteInfoNew testSuiteInfoNew1 = (TestSuiteInfoNew) ((BioModelNode) getSelectedTreePaths()[1].getLastPathComponent()).getUserObject();
if (testSuiteInfoNew0.getTSDate().compareTo(testSuiteInfoNew1.getTSDate()) < 0) {
getRemoveDiffTestCriteriaJMenuItem().setEnabled(!testSuiteInfoNew1.isLocked());
} else {
getRemoveDiffTestCriteriaJMenuItem().setEnabled(!testSuiteInfoNew0.isLocked());
}
}
boolean bMenuValid = getJTree1().getSelectionCount() == 1;
getRefreshTestSuiteJMenuItem().setEnabled(bMenuValid);
boolean isLocked = false;
if (getJTree1().getSelectionCount() == 1) {
isLocked = ((TestSuiteInfoNew) getTreeSelection()).isLocked();
}
// Disable if TestSuite locked
getDuplicateTSMenuItem().setEnabled(bMenuValid);
getRunAllMenuItem().setEnabled(bMenuValid && !isLocked);
getGenTSReportMenuItem().setEnabled(!checkAnyLocked());
getAddTestCaseMenuItem().setEnabled(bMenuValid && !isLocked);
getRemoveTSMenuItem().setEnabled(bMenuValid && !isLocked);
getEditAnnotationTestSuiteMenuItem().setEnabled(bMenuValid && !isLocked);
getLockTestSuiteMenuItem().setEnabled(bMenuValid && !isLocked);
getRemoveCompiledSolversJMenuItem().setEnabled(bMenuValid && !isLocked);
// Set enable based on conditions if not locked
if (bMenuValid && !isLocked) {
if (((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getChildCount() == 0) {
getDuplicateTSMenuItem().setEnabled(false);
getRunAllMenuItem().setEnabled(false);
getGenTSReportMenuItem().setEnabled(false);
} else {
getDuplicateTSMenuItem().setEnabled(true);
getRunAllMenuItem().setEnabled(true);
getGenTSReportMenuItem().setEnabled(true);
}
}
getTestSuitePopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
} else if (getTreeSelection() instanceof TestCaseNew) {
boolean bMenuValid = getJTree1().getSelectionCount() == 1;
getRefreshTestCaseJMenuItem().setEnabled(bMenuValid);
getLoadMenuItem().setEnabled(bMenuValid);
boolean isLocked = false;
if (getJTree1().getSelectionCount() == 1) {
isLocked = ((TestSuiteInfoNew) ((BioModelNode) ((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getParent()).getUserObject()).isLocked();
}
getRemoveMenuItem().setEnabled(!checkAnyLocked());
getRunSimsMenuItem().setEnabled(bMenuValid && !isLocked);
getGenerateTCReportMenuItem().setEnabled(!checkAnyLocked());
getChangeTypeToSteadyMenuItem().setEnabled(bMenuValid && !isLocked);
getEditAnnotationTestCaseMenuItem().setEnabled(bMenuValid && !isLocked);
if (bMenuValid && !isLocked) {
TestCaseNew tcNew = (TestCaseNew) getTreeSelection();
if (tcNew.getType().equals(TestCaseNew.EXACT) || tcNew.getType().equals(TestCaseNew.EXACT_STEADY)) {
getChangeTypeToSteadyMenuItem().setEnabled(true);
} else {
getChangeTypeToSteadyMenuItem().setEnabled(false);
}
}
getTestCasePopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
} else if (getTreeSelection() instanceof TestCriteriaNew) {
boolean bMenuValid = getJTree1().getSelectionCount() == 1;
getRefreshTestCriteriaJMenuItem().setEnabled(bMenuValid);
getViewMenuItem().setEnabled(bMenuValid);
getCompareMenuItem().setEnabled(bMenuValid);
getCompareUserDefinedMenuItem().setEnabled(bMenuValid);
getQueryTCritCrossRefMenuItem1().setEnabled(bMenuValid);
getTestCriteriaCopySimKeyMenuItem().setEnabled(bMenuValid);
boolean isLocked = false;
if (getJTree1().getSelectionCount() == 1) {
isLocked = ((TestSuiteInfoNew) ((BioModelNode) ((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getParent().getParent()).getUserObject()).isLocked();
}
getRunSimMenuItem().setEnabled(!checkAnyLocked());
getEditTCrMenuItem().setEnabled(bMenuValid && !isLocked);
getRemoveTestCritMenuItem().setEnabled(!checkAnyLocked());
getGenerateTCRitReportMenuItem1().setEnabled(!checkAnyLocked());
getGenerateTCRitReportUserDefinedReferenceMenuItem1().setEnabled(!checkAnyLocked());
if (bMenuValid && !isLocked) {
TestCriteriaNew testCriteria = (TestCriteriaNew) getTreeSelection();
if (testCriteria.getRegressionSimInfo() == null) {
getCompareMenuItem().setEnabled(false);
} else {
getCompareMenuItem().setEnabled(true);
}
}
getSimulationPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
} else {
getMainPopupMenu().setVisible(false);
getTestSuitePopupMenu().setVisible(false);
getTestCasePopupMenu().setVisible(false);
getTCritVarPopupMenu().setVisible(false);
getSimulationPopupMenu().setVisible(false);
}
}
Aggregations