Search in sources :

Example 1 with TestSuiteNew

use of cbit.vcell.numericstest.TestSuiteNew 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;
}
Also used : AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) ArrayList(java.util.ArrayList) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) GeometryContext(cbit.vcell.mapping.GeometryContext) HashSet(java.util.HashSet) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) MathMapping(cbit.vcell.mapping.MathMapping) MathModel(cbit.vcell.mathmodel.MathModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) KeyValue(org.vcell.util.document.KeyValue) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOP(cbit.vcell.numericstest.AddTestCasesOP) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) SimulationContext(cbit.vcell.mapping.SimulationContext) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) BigDecimal(java.math.BigDecimal) Simulation(cbit.vcell.solver.Simulation) MembraneVoltage(cbit.vcell.model.Membrane.MembraneVoltage) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) BioModel(cbit.vcell.biomodel.BioModel) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel)

Example 2 with TestSuiteNew

use of cbit.vcell.numericstest.TestSuiteNew 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;
    }
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) AddTestSuiteOP(cbit.vcell.numericstest.AddTestSuiteOP) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) DataAccessException(org.vcell.util.DataAccessException)

Example 3 with TestSuiteNew

use of cbit.vcell.numericstest.TestSuiteNew 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;
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) Vector(java.util.Vector)

Example 4 with TestSuiteNew

use of cbit.vcell.numericstest.TestSuiteNew in project vcell by virtualcell.

the class TestingFrameworkWindowPanel method testingFrameworkPanel_actionPerformed.

/**
 * Comment
 */
private void testingFrameworkPanel_actionPerformed(final ActionEvent e) {
    if (tfRefreshTreeTask == null) {
        tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager());
    }
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
    try {
        final TreePath[] selectedTreePaths = gettestingFrameworkPanel().getSelectedTreePaths();
        if (selectedTreePaths != null && selectedTreePaths.length > 1) {
            Object refObj = ((BioModelNode) selectedTreePaths[0].getLastPathComponent()).getUserObject();
            for (int i = 1; i < selectedTreePaths.length; i++) {
                Object currentObj = ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                if ((refObj == null && currentObj == null) || ((refObj != null && currentObj != null) && (refObj.getClass().equals(currentObj.getClass()))) || (refObj instanceof TestCaseNew && currentObj instanceof TestCaseNew)) {
                    continue;
                } else {
                    throw new IllegalArgumentException("Multiple selections must all be of same type");
                }
            }
        }
        final Object selectedObj = gettestingFrameworkPanel().getTreeSelection();
        if (e.getActionCommand().equals(TestingFrameworkPanel.DELETE_XML_LOAD_TEST)) {
            int result = DialogUtils.showComponentOKCancelDialog(this, new JLabel("Delete " + selectedTreePaths.length + " Load Tests?"), "Confirm Load Test Delete");
            if (result != JOptionPane.OK_OPTION) {
                return;
            }
            AsynchClientTask deleteLoadTestTask = new AsynchClientTask("Deleting Load Test...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    LoadTestInfoOP deleteLoadTestInfoOP = new LoadTestInfoOP(LoadTestOpFlag.delete, null, null);
                    LoadTestSoftwareVersionTimeStamp[] deleteTheseversTimestamps = new LoadTestSoftwareVersionTimeStamp[selectedTreePaths.length];
                    for (int i = 0; i < selectedTreePaths.length; i++) {
                        deleteTheseversTimestamps[i] = ((LoadTestTreeInfo) ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject()).loadTestSoftwareVersionTimeStamp;
                    }
                    deleteLoadTestInfoOP.setDeleteInfo(deleteTheseversTimestamps);
                    getTestingFrameworkWindowManager().getRequestManager().getDocumentManager().doTestSuiteOP(deleteLoadTestInfoOP);
                    final ActionEvent refreshAction = new ActionEvent(this, 0, TestingFrameworkPanel.REFRESH_XML_LOAD_TEST);
                    new Thread(new Runnable() {

                        public void run() {
                            testingFrameworkPanel_actionPerformed(refreshAction);
                        }
                    }).start();
                }
            };
            tasksV.add(deleteLoadTestTask);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_All) || e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_MODELS) || e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_USERS)) {
            final Date[] beginDate = new Date[1];
            final Date[] endDate = new Date[1];
            final TreeSet<String> uniqueUserIDTreeSet = new TreeSet<String>();
            final Vector<KeyValue> bioAndMathModelKeyValueV = new Vector<KeyValue>();
            String typeMsg = "All";
            if (!e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_All)) {
                if (selectedTreePaths != null && selectedTreePaths.length > 0) {
                    Object refObj = ((BioModelNode) selectedTreePaths[0].getLastPathComponent()).getUserObject();
                    if (refObj instanceof TestingFrmwkTreeModel.LoadTestTreeInfo) {
                        for (int i = 0; i < selectedTreePaths.length; i++) {
                            refObj = ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                            uniqueUserIDTreeSet.add(((TestingFrmwkTreeModel.LoadTestTreeInfo) refObj).userid);
                            if (!e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_USERS)) {
                                bioAndMathModelKeyValueV.add(((TestingFrmwkTreeModel.LoadTestTreeInfo) refObj).bioOrMathModelKey);
                            }
                        }
                    }
                }
            } else {
                // TreeSet<VCDocumentInfo> dateRangeDocInfoTreeSet =
                // new TreeSet<VCDocumentInfo>(new Comparator<VCDocumentInfo>() {
                // public int compare(VCDocumentInfo o1, VCDocumentInfo o2) {
                // return o1.getVersion().getDate().compareTo(o2.getVersion().getDate());
                // }
                // });
                // BioModelInfo[] allBioModelInfos = getDocumentManager().getBioModelInfos();
                // dateRangeDocInfoTreeSet.addAll(Arrays.asList(allBioModelInfos));
                // MathModelInfo[] allMathModelInfos = getDocumentManager().getMathModelInfos();
                // dateRangeDocInfoTreeSet.addAll(Arrays.asList(allMathModelInfos));
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                // Date firstDate = simpleDateFormat.parse(simpleDateFormat.format(dateRangeDocInfoTreeSet.first().getVersion().getDate()));
                // Date lastDate = simpleDateFormat.parse(simpleDateFormat.format(dateRangeDocInfoTreeSet.last().getVersion().getDate()));
                Date firstDate = simpleDateFormat.parse("2000-01-01");
                Date lastDate = simpleDateFormat.parse(simpleDateFormat.format(Calendar.getInstance().getTime()));
                String allDateRangeString = simpleDateFormat.format(firstDate) + "," + simpleDateFormat.format(lastDate);
                while (beginDate[0] == null || endDate[0] == null) {
                    try {
                        String dateRangeString = DialogUtils.showInputDialog0(this, "Enter Date Range (begin,end) to include (e.g. '" + allDateRangeString + "')", allDateRangeString);
                        beginDate[0] = simpleDateFormat.parse(dateRangeString.substring(0, dateRangeString.indexOf(",")));
                        endDate[0] = simpleDateFormat.parse(dateRangeString.substring(dateRangeString.indexOf(",") + 1));
                    // if(beginDate.compareTo(firstDate) != 0 ||
                    // endDate.compareTo(lastDate) != 0){
                    // Iterator<VCDocumentInfo> vcDocIter = dateRangeDocInfoTreeSet.iterator();
                    // while(vcDocIter.hasNext()){
                    // VCDocumentInfo vcDocInfo = vcDocIter.next();
                    // Date docDate = simpleDateFormat.parse(simpleDateFormat.format(vcDocInfo.getVersion().getDate()));
                    // if(docDate.compareTo(beginDate) < 0 ||
                    // docDate.compareTo(endDate) > 0){
                    // continue;
                    // }
                    // uniqueUserIDTreeSet.add(vcDocInfo.getVersion().getOwner().getName());
                    // bioAndMathModelKeyValueV.add(vcDocInfo.getVersion().getVersionKey());
                    // }
                    // }
                    } catch (UtilCancelException uce) {
                        return;
                    } catch (Exception e2) {
                        DialogUtils.showErrorDialog(this, e2.getMessage());
                    }
                }
                if (beginDate[0].compareTo(firstDate) == 0 && endDate[0].compareTo(lastDate) == 0) {
                    beginDate[0] = null;
                    endDate[0] = null;
                } else {
                    typeMsg = "between " + simpleDateFormat.format(beginDate[0]) + "," + simpleDateFormat.format(endDate[0]);
                }
            }
            if (e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_MODELS)) {
                typeMsg = "Models (" + bioAndMathModelKeyValueV.size() + ")";
            } else if (e.getActionCommand().equals(TestingFrameworkPanel.RUN_XML_LOAD_TEST_USERS)) {
                typeMsg = "Users (" + uniqueUserIDTreeSet.size() + ")";
            }
            int result = DialogUtils.showComponentOKCancelDialog(TestingFrameworkWindowPanel.this, new JLabel("Run " + typeMsg + " Load Tests?"), "Confirm Load Test Run");
            if (result != JOptionPane.OK_OPTION) {
                return;
            }
            result = DialogUtils.showComponentOKCancelDialog(this, enterDBAndSoftwareVersPanel, "Enter Software Version running load test");
            if (result != JOptionPane.OK_OPTION) {
                return;
            }
            AsynchClientTask runXMLLoadTestTask = new AsynchClientTask("Running XML Load Test...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    String[] uniqueUserIDArr = null;
                    KeyValue[] bioAndMathModelKeyValueArr = null;
                    if (beginDate[0] != null && endDate[0] != null) {
                        LoadTestInfoOpResults loadTestInfoOpResults = getTestingFrameworkWindowManager().getLoadTestInfoBetweenDates(beginDate[0], endDate[0]);
                        uniqueUserIDArr = loadTestInfoOpResults.getUniqueUserIDsBetweenDates();
                        bioAndMathModelKeyValueArr = loadTestInfoOpResults.getKeyValuesBetweenDates();
                    } else {
                        uniqueUserIDArr = (uniqueUserIDTreeSet.size() == 0 ? null : uniqueUserIDTreeSet.toArray(new String[0]));
                        bioAndMathModelKeyValueArr = (bioAndMathModelKeyValueV.size() == 0 ? null : bioAndMathModelKeyValueV.toArray(new KeyValue[0]));
                    }
                    throw new RuntimeException(TestingFrameworkWindowPanel.class.getSimpleName() + ".runXMLLoadTestTask(): Run Load Test disabled, directly dependend on MathVerifier.runLoadTest(), should move to standalone admin tool.");
                // MathVerifier mathVerifier = MathVerifier.createMathVerifier(
                // enterDBAndSoftwareVersPanel.getDBHost(),
                // enterDBAndSoftwareVersPanel.getDBName(),
                // enterDBAndSoftwareVersPanel.getDBSchema(),
                // enterDBAndSoftwareVersPanel.getDBPassword());
                // mathVerifier.runLoadTest(
                // uniqueUserIDArr,
                // bioAndMathModelKeyValueArr,
                // enterDBAndSoftwareVersPanel.getSoftwareVersion(),
                // (enterDBAndSoftwareVersPanel.getSoftwareVersion().length()==0?false:true),
                // (enterDBAndSoftwareVersPanel.getSoftwareVersion().length()==0?Compare.DEFAULT_COMPARE_LOGGER:null));
                }
            };
            tasksV.add(runXMLLoadTestTask);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REFRESH_XML_LOAD_TEST)) /*||
				e.getActionCommand().equals(TestingFrameworkPanel.REFRESH_INCLUDE_SLOW_XML_LOAD_TEST)*/
        {
            final String LOADTESTDETAILS_KEY = "LOADTESTDETAILS_KEY";
            AsynchClientTask getFailedLoadTest = new AsynchClientTask("Getting FailedLoadTests...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    /*						Integer slowLoadThreshold = null;
						if(e.getActionCommand().equals(TestingFrameworkPanel.REFRESH_INCLUDE_SLOW_XML_LOAD_TEST)){
							String result = DialogUtils.showInputDialog0(TestingFrameworkWindowPanel.this, "Enter load time threshold (millseconds)","10000");
							slowLoadThreshold = new Integer(result);
						}
*/
                    if (gettestingFrameworkPanel().getSlowLoadThreshold() != null && gettestingFrameworkPanel().getLoadTestSQLCondition() != null) {
                        throw new IllegalArgumentException("SlowLoadThreshold and 'SQL Condition' cannot both be non-null at the same time.");
                    }
                    hashTable.put(LOADTESTDETAILS_KEY, getTestingFrameworkWindowManager().getLoadTestDetails(gettestingFrameworkPanel().getSlowLoadThreshold(), gettestingFrameworkPanel().getLoadTestSQLCondition()));
                }
            };
            AsynchClientTask refreshFailedLoadTest = new AsynchClientTask("Refreshing FailedLoadTests...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    getTestingFrameworkWindowManager().refreshLoadTest((LoadTestInfoOpResults) hashTable.get(LOADTESTDETAILS_KEY));
                }
            };
            tasksV.add(getFailedLoadTest);
            tasksV.add(refreshFailedLoadTest);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.QUERY_TCRITVAR_CROSSREF)) {
            if (selectedObj instanceof TestingFrmwkTreeModel.TestCriteriaVarUserObj && selectedTreePaths.length == 1) {
                final TestingFrmwkTreeModel.TestCriteriaVarUserObj tcritVaruserObj = (TestingFrmwkTreeModel.TestCriteriaVarUserObj) selectedObj;
                final TestSuiteInfoNew tsInfoNew = gettestingFrameworkPanel().getTestSuiteInfoOfTreePath(selectedTreePaths[0]);
                AsynchClientTask queryTCritCrossRef = new AsynchClientTask("Query TCrit Var Cross Ref", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        getTestingFrameworkWindowManager().queryTCritCrossRef(tsInfoNew, tcritVaruserObj.getTestCriteria(), tcritVaruserObj.getVariableComparisonSummary().getName());
                    }
                };
                tasksV.add(queryTCritCrossRef);
            } else {
                throw new Exception("Selected Object is not a TestCriteria Variable! Failed to Query Var Cross Ref.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.QUERY_TCRIT_CROSSREF)) {
            if (selectedObj instanceof TestCriteriaNew) {
                final TestCriteriaNew tcritNew = (TestCriteriaNew) selectedObj;
                final TestSuiteInfoNew tsInfoNew = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCriteria();
                AsynchClientTask queryTCritCrossRef = new AsynchClientTask("Query TCrit Cross Ref", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        getTestingFrameworkWindowManager().queryTCritCrossRef(tsInfoNew, tcritNew, null);
                    }
                };
                tasksV.add(queryTCritCrossRef);
            } else {
                throw new Exception("Selected Object is not a TestCriteria! Failed to Query Cross Ref.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.LOCK_TESTSUITE)) {
            if (selectedObj instanceof TestSuiteInfoNew) {
                final TestSuiteInfoNew tsInfoNew = (TestSuiteInfoNew) selectedObj;
                AsynchClientTask lockTestSuiteTask = new AsynchClientTask("Lock TestSuite", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        getTestingFrameworkWindowManager().lockTestSuite(tsInfoNew);
                    }
                };
                tasksV.add(lockTestSuiteTask);
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfoNew);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestSuite! Failed to Lock TestSuite.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.EDIT_ANNOT_TESTSUITE)) {
            if (selectedObj instanceof TestSuiteInfoNew) {
                final TestSuiteInfoNew tsInfoNew = (TestSuiteInfoNew) selectedObj;
                String newAnnotation;
                // initialize fields
                String oldAnnotation = tsInfoNew.getTSAnnotation();
                // show the editor
                newAnnotation = org.vcell.util.gui.DialogUtils.showAnnotationDialog(this, oldAnnotation);
                final String finalAnnotation = newAnnotation;
                AsynchClientTask editTestSuiteAnnotation = new AsynchClientTask("Edit TestSuite Annotation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        getTestingFrameworkWindowManager().updateTestSuiteAnnotation(tsInfoNew, finalAnnotation);
                    }
                };
                tasksV.add(editTestSuiteAnnotation);
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfoNew);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestSuite! Failed to Edit TestSuite Annotation.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.EDIT_ANNOT_TESTCASE)) {
            if (selectedObj instanceof TestCaseNew) {
                final TestCaseNew tcNew = (TestCaseNew) selectedObj;
                String newAnnotation;
                // initialize fields
                String oldAnnotation = tcNew.getAnnotation();
                // show the editor
                newAnnotation = org.vcell.util.gui.DialogUtils.showAnnotationDialog(this, oldAnnotation);
                final String finalAnnotation = newAnnotation;
                AsynchClientTask editTestCaseAnnotation = new AsynchClientTask("Edit TestCase Annotation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        getTestingFrameworkWindowManager().updateTestCaseAnnotation(tcNew, finalAnnotation);
                    }
                };
                tasksV.add(editTestCaseAnnotation);
                TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCase();
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestCase! Failed to Edit TestCase Annotation.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.TOGGLE_STEADYSTATE)) {
            if (selectedObj instanceof TestCaseNew) {
                final TestCaseNew testCase = (TestCaseNew) selectedObj;
                String okString = "Ok";
                String confirm = PopupGenerator.showWarningDialog(this, "Toggle TestCase '" + testCase.getVersion().getName() + "'\nfrom " + testCase.getType() + " to " + (testCase.getType().equals(TestCaseNew.EXACT) ? TestCaseNew.EXACT_STEADY : TestCaseNew.EXACT), new String[] { okString, "Cancel" }, okString);
                if (confirm.equals(okString)) {
                    AsynchClientTask toggleSteadyState = new AsynchClientTask("Toggle Steady State", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            getTestingFrameworkWindowManager().toggleTestCaseSteadyState(new TestCaseNew[] { testCase });
                        }
                    };
                    tasksV.add(toggleSteadyState);
                    TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCase();
                    tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                    tasksV.add(tfRefreshTreeTask);
                } else {
                    throw UserCancelException.CANCEL_GENERIC;
                }
            } else {
                throw new Exception("Selected Object is not a TestCase! Cannot Toggle SteadyState");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.ADD_TESTSUITE)) {
            TestingFrameworkWindowManager.NewTestSuiteUserInformation newTestSuiteUserInfo = getTestingFrameworkWindowManager().getNewTestSuiteInfoFromUser(null, null);
            tasksV.add(new TFAddTestSuite(getTestingFrameworkWindowManager(), newTestSuiteUserInfo.testSuiteInfoNew));
            tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), newTestSuiteUserInfo.testSuiteInfoNew);
            tasksV.add(tfRefreshTreeTask);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REFRESH_TESTSUITE)) {
            TestSuiteInfoNew tsin = null;
            if (selectedObj instanceof TestSuiteInfoNew) {
                tsin = (TestSuiteInfoNew) selectedObj;
            } else if (selectedObj instanceof TestCaseNew) {
                tsin = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCase();
            } else if (selectedObj instanceof TestCriteriaNew) {
                tsin = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCriteria();
            }
            if (tsin == null) {
                throw new IllegalArgumentException("Refresh error: Unexpected tree selection type=" + selectedObj.getClass().getName());
            }
            tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsin);
            tasksV.add(new TFUpdateRunningStatus(getTestingFrameworkWindowManager(), tsin));
            tasksV.add(tfRefreshTreeTask);
        // getTestingFrameworkWindowManager().updateSimRunningStatus();
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.ADD_TESTCASE)) {
            if (selectedObj instanceof TestSuiteInfoNew) {
                TestSuiteInfoNew tsInfo = (TestSuiteInfoNew) selectedObj;
                TestCaseNew[] tcnArr = getTestingFrameworkWindowManager().getNewTestCaseArr();
                tasksV.add(new cbit.vcell.client.task.TFAddTestCases(getTestingFrameworkWindowManager(), tsInfo, tcnArr));
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a test suite! Cannot add a test case");
            }
        } else if (e.getActionCommand().equals("Run All")) {
            if (selectedTreePaths == null || selectedTreePaths.length != 1) {
                throw new IllegalArgumentException("Command '" + e.getActionCommand() + "' Single Selection Only!");
            }
            if (selectedObj instanceof TestSuiteInfoNew) {
                TestSuiteInfoNew tsInfo = (TestSuiteInfoNew) selectedObj;
                String okString = "Ok";
                String confirm = PopupGenerator.showWarningDialog(this, "Run All Sims for TestSuite '" + tsInfo.getTSID() + "'?", new String[] { okString, "Cancel" }, okString);
                if (confirm.equals(okString)) {
                    tasksV.add(new TFRunSims(getTestingFrameworkWindowManager(), tsInfo));
                    tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                    tasksV.add(tfRefreshTreeTask);
                }
            } else {
                throw new Exception("Selected Object is not a test suite!");
            }
        } else if (e.getActionCommand().equals("Run Simulations")) {
            if (selectedTreePaths == null || selectedTreePaths.length != 1) {
                throw new IllegalArgumentException("Command '" + e.getActionCommand() + "' Single Selection Only!");
            }
            if (selectedObj instanceof TestCaseNew) {
                TestCaseNew testCase = (TestCaseNew) selectedObj;
                String okString = "Ok";
                String confirm = PopupGenerator.showWarningDialog(this, "Run All Sims for TestCase '" + testCase.getVersion().getName() + "'?", new String[] { okString, "Cancel" }, okString);
                if (confirm.equals(okString)) {
                    tasksV.add(new TFRunSims(getTestingFrameworkWindowManager(), testCase));
                    TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCase();
                    tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                    tasksV.add(tfRefreshTreeTask);
                }
            } else {
                throw new Exception("Selected Object is not a TestCase! Cannot run simulations");
            }
        } else if (e.getActionCommand().equals("Run")) {
            if (selectedTreePaths != null && selectedTreePaths.length > 0 && selectedTreePaths[0].getLastPathComponent() instanceof BioModelNode && ((BioModelNode) selectedTreePaths[0].getLastPathComponent()).getUserObject() instanceof TestCriteriaNew) {
                for (int i = 0; i < selectedTreePaths.length; i += 1) {
                    TestCriteriaNew tCriteria = (TestCriteriaNew) ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                    tasksV.add(new TFRunSims(getTestingFrameworkWindowManager(), tCriteria));
                }
                TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCriteria();
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestCriteria!");
            }
        } else if (e.getActionCommand().equals("View Results")) {
            if (selectedObj instanceof cbit.vcell.numericstest.TestCriteriaNew) {
                TestCriteriaNew tCriteria = (TestCriteriaNew) selectedObj;
                getTestingFrameworkWindowManager().viewResults(tCriteria);
            } else {
                PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, "Selected Object is not a TestCriteria!");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.COMPARERREGR_INTERNALREF_TESTCRITERIA) || e.getActionCommand().equals(TestingFrameworkPanel.COMPARERREGR_USERDEFREF_TESTCRITERIA)) {
            if (selectedObj instanceof cbit.vcell.numericstest.TestCriteriaNew) {
                TestCriteriaNew tCriteria = (TestCriteriaNew) selectedObj;
                SimulationStatus simStatus = getTestingFrameworkWindowManager().getRequestManager().getServerSimulationStatus(tCriteria.getSimInfo());
                if (simStatus.isRunning()) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, "Selected simulation is still running!");
                    return;
                }
                SimulationInfo simulationInfo = tCriteria.getRegressionSimInfo();
                if (e.getActionCommand().equals(TestingFrameworkPanel.COMPARERREGR_USERDEFREF_TESTCRITERIA)) {
                    try {
                        simulationInfo = getUserSelectedSimulationInfo().getSimInfo();
                    } catch (UserCancelException e2) {
                        return;
                    }
                }
                if (simulationInfo == null) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, "Either the selected simulation does not belong to a REGRESSION test or the regression simInfo is not set!");
                    return;
                }
                getTestingFrameworkWindowManager().compare(tCriteria, simulationInfo);
            } else {
                PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, "Selected Object is not a TestCriteria!");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.DUPLICATE_TESTSUITE)) {
            if (selectedObj instanceof TestSuiteInfoNew) {
                TestSuiteInfoNew tsInfoOriginal = (TestSuiteInfoNew) selectedObj;
                TestingFrameworkWindowManager.NewTestSuiteUserInformation newTestSuiteUserInfo = getTestingFrameworkWindowManager().getNewTestSuiteInfoFromUser(tsInfoOriginal.getTSAnnotation(), tsInfoOriginal.getTSID());
                tasksV.add(new TFDuplicateTestSuite(getTestingFrameworkWindowManager(), tsInfoOriginal, newTestSuiteUserInfo.testSuiteInfoNew, newTestSuiteUserInfo.regrRefFlag));
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), newTestSuiteUserInfo.testSuiteInfoNew);
                tasksV.add(tfRefreshTreeTask);
            // getTestingFrameworkWindowManager().duplicateTestSuite(tsInfo);
            } else {
                throw new Exception("Selected Object is not a test suite! Cannot duplicate");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REMOVE_TESTCASE)) {
            if (selectedObj instanceof TestCaseNew) {
                String[][] rowData = new String[selectedTreePaths.length][3];
                TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCase();
                for (int i = 0; i < selectedTreePaths.length; i += 1) {
                    TestCaseNew tCase = (TestCaseNew) ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                    rowData[i][0] = tsInfo.getTSID();
                    tasksV.add(new TFRemove(getTestingFrameworkWindowManager(), tCase));
                    if (tCase instanceof TestCaseNewBioModel) {
                        rowData[i][1] = "BM " + tCase.getVersion().getName();
                        rowData[i][2] = ((TestCaseNewBioModel) tCase).getSimContextName();
                    } else {
                        rowData[i][1] = "MM " + tCase.getVersion().getName();
                        rowData[i][2] = "N/A";
                    }
                }
                DialogUtils.showComponentOKCancelTableList(this, "Confirm Remove TestCase(s)", new String[] { "Test Suite", "Test Case", "App" }, rowData, null);
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestCase, cannot remove selection!");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REMOVE_TESTSUITE)) {
            if (selectedObj instanceof TestSuiteInfoNew) {
                TestSuiteInfoNew tsInfo = (TestSuiteInfoNew) selectedObj;
                String confirm = PopupGenerator.showWarningDialog(this, UserMessage.warn_deleteDocument.getMessage(tsInfo.getTSID()), UserMessage.warn_deleteDocument.getOptions(), UserMessage.warn_deleteDocument.getDefaultSelection());
                if (confirm.equals(UserMessage.OPTION_DELETE)) {
                    tasksV.add(new TFRemove(getTestingFrameworkWindowManager(), tsInfo));
                    tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                    tasksV.add(tfRefreshTreeTask);
                } else {
                    throw UserCancelException.CANCEL_GENERIC;
                }
            // getTestingFrameworkWindowManager().removeTestSuite(tsInfo);
            } else {
                throw new Exception("Selected Object is not a test suite! Cannot add a test case");
            }
        } else if (e.getActionCommand().equals("Generate TestSuite Report")) {
            final TreePath[] selectedTreePathsLocal = selectedTreePaths;
            new Thread(new Runnable() {

                public void run() {
                    try {
                        for (int i = 0; selectedTreePathsLocal != null && i < selectedTreePathsLocal.length; i += 1) {
                            Object selTreeNode = ((BioModelNode) selectedTreePathsLocal[i].getLastPathComponent()).getUserObject();
                            if (selTreeNode instanceof TestSuiteInfoNew) {
                                Vector<AsynchClientTask> tasksVLocal = new java.util.Vector<AsynchClientTask>();
                                TestSuiteInfoNew tsInfo = (TestSuiteInfoNew) selTreeNode;
                                tasksVLocal.add(new cbit.vcell.client.task.TFUpdateRunningStatus(getTestingFrameworkWindowManager(), tsInfo));
                                tasksVLocal.add(new TFGenerateReport(getTestingFrameworkWindowManager(), tsInfo));
                                final String END_NOTIFIER = "END NOTIFIER";
                                tasksVLocal.add(new AsynchClientTask(END_NOTIFIER, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {

                                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                                        hashTable.put(END_NOTIFIER, END_NOTIFIER);
                                    }
                                });
                                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                                tasksVLocal.add(tfRefreshTreeTask);
                                AsynchClientTask[] tasksArr = new AsynchClientTask[tasksVLocal.size()];
                                tasksVLocal.copyInto(tasksArr);
                                Hashtable<String, Object> hashLocal = new Hashtable<String, Object>();
                                ClientTaskDispatcher.dispatch(TestingFrameworkWindowPanel.this, hashLocal, tasksArr, true);
                                // Wait for each report to complete before going on to next because report methods are not thread safe?
                                while (!hashLocal.contains(END_NOTIFIER)) {
                                    Thread.sleep(100);
                                }
                            } else {
                                throw new Exception("Error GenerateTestSuiteReport\nSelected Object is not a TestSuite");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, "Error GenerateTestSuiteReport\n" + e.getMessage(), e);
                        return;
                    }
                }
            }).start();
            return;
        } else if (e.getActionCommand().equals("Generate TestCase Report")) {
            Vector<TestSuiteInfoNew> tsinV = new Vector<TestSuiteInfoNew>();
            for (int i = 0; selectedTreePaths != null && i < selectedTreePaths.length; i += 1) {
                Object selTreeNode = ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                if (selTreeNode instanceof TestCaseNew) {
                    TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfTreePath(selectedTreePaths[i]);
                    if (!tsinV.contains(tsInfo)) {
                        tsinV.add(tsInfo);
                        tasksV.add(new cbit.vcell.client.task.TFUpdateRunningStatus(getTestingFrameworkWindowManager(), tsInfo));
                    }
                    tasksV.add(new TFGenerateReport(getTestingFrameworkWindowManager(), (TestCaseNew) selTreeNode));
                } else {
                    throw new Exception("Selected Object is not a TestCase");
                }
            }
            tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), (tsinV.size() == 1 ? tsinV.elementAt(0) : null));
            tasksV.add(tfRefreshTreeTask);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.GENTCRITREPORT_INTERNALREF_TESTCRITERIA) || e.getActionCommand().equals(TestingFrameworkPanel.GENTCRITREPORT_USERDEFREF_TESTCRITERIA)) {
            TFGenerateReport.VCDocumentAndSimInfo userDefinedRegrRef = null;
            if (e.getActionCommand().equals(TestingFrameworkPanel.GENTCRITREPORT_USERDEFREF_TESTCRITERIA)) {
                try {
                    userDefinedRegrRef = getUserSelectedSimulationInfo();
                } catch (UserCancelException e2) {
                    return;
                }
            }
            Vector<TestSuiteInfoNew> tsinV = new Vector<TestSuiteInfoNew>();
            for (int i = 0; selectedTreePaths != null && i < selectedTreePaths.length; i += 1) {
                Object selTreeNode = ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                if (selTreeNode instanceof TestCriteriaNew) {
                    TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfTreePath(selectedTreePaths[i]);
                    if (!tsinV.contains(tsInfo)) {
                        tsinV.add(tsInfo);
                        tasksV.add(new cbit.vcell.client.task.TFUpdateRunningStatus(getTestingFrameworkWindowManager(), tsInfo));
                    }
                    tasksV.add(new TFGenerateReport(getTestingFrameworkWindowManager(), (TestCaseNew) ((BioModelNode) selectedTreePaths[i].getParentPath().getLastPathComponent()).getUserObject(), (TestCriteriaNew) selTreeNode, userDefinedRegrRef));
                } else {
                    throw new Exception("Selected Object is not a TestCriteria");
                }
            }
            tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), (tsinV.size() == 1 ? tsinV.elementAt(0) : null));
            tasksV.add(tfRefreshTreeTask);
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REMOVE_DIFF_TESTCRITERIA)) {
            final int OLDER = 0;
            final int NEWER = 1;
            final TestSuiteInfoNew[] testSuiteInfoHolder = new TestSuiteInfoNew[2];
            if (selectedTreePaths.length == 2 && ((BioModelNode) selectedTreePaths[0].getLastPathComponent()).getUserObject() instanceof TestSuiteInfoNew && ((BioModelNode) selectedTreePaths[1].getLastPathComponent()).getUserObject() instanceof TestSuiteInfoNew) {
                // do outside task because its quick
                TestSuiteInfoNew testSuiteInfoOlder = (TestSuiteInfoNew) ((BioModelNode) selectedTreePaths[0].getLastPathComponent()).getUserObject();
                TestSuiteInfoNew testSuiteInfoNewer = (TestSuiteInfoNew) ((BioModelNode) selectedTreePaths[1].getLastPathComponent()).getUserObject();
                if (testSuiteInfoOlder.getTSDate().compareTo(testSuiteInfoNewer.getTSDate()) > 0) {
                    TestSuiteInfoNew temp = testSuiteInfoOlder;
                    testSuiteInfoOlder = testSuiteInfoNewer;
                    testSuiteInfoNewer = temp;
                }
                testSuiteInfoHolder[OLDER] = testSuiteInfoOlder;
                testSuiteInfoHolder[NEWER] = testSuiteInfoNewer;
                AsynchClientTask showDiffTask = new AsynchClientTask("Show Differential TestCriteria...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        ArrayList<TestSuiteNew> bothTestSuites = new ArrayList<TestSuiteNew>();
                        if (getClientTaskStatusSupport() != null) {
                            getClientTaskStatusSupport().setProgress(25);
                            getClientTaskStatusSupport().setMessage("Getting TestSuiteInfo '" + testSuiteInfoHolder[OLDER].getTSID() + "'");
                        }
                        bothTestSuites.add(getDocumentManager().getTestSuite(testSuiteInfoHolder[OLDER].getTSKey()));
                        if (getClientTaskStatusSupport() != null) {
                            getClientTaskStatusSupport().setProgress(50);
                            getClientTaskStatusSupport().setMessage("Getting TestSuiteInfo '" + testSuiteInfoHolder[NEWER].getTSID() + "'");
                        }
                        bothTestSuites.add(getDocumentManager().getTestSuite(testSuiteInfoHolder[NEWER].getTSKey()));
                        HashMap<String, TestCriteriaNew> olderTestCritHashMap = new HashMap<String, TestCriteriaNew>();
                        ArrayList<String> olderTestCaseBaseNames = new ArrayList<String>();
                        TreeMap<String, TestCriteriaNew> newDiffTestCriteria = new TreeMap<String, TestCriteriaNew>();
                        int excludedCount = 0;
                        for (TestSuiteNew currentTestSuite : bothTestSuites) {
                            BigDecimal currentTestSuiteKey = currentTestSuite.getTSInfoNew().getTSKey();
                            for (TestCaseNew tcn : currentTestSuite.getTestCases()) {
                                String prefixInfo = "TS='" + currentTestSuite.getTSInfoNew().getTSID() + "' Type='" + tcn.getType() + "' ";
                                String baseName = (tcn instanceof TestCaseNewBioModel ? "BioModel='" + ((TestCaseNewBioModel) tcn).getBioModelInfo().getVersion().getName() + "' App='" + ((TestCaseNewBioModel) tcn).getSimContextName() + "'" : "MathModel='" + ((TestCaseNewMathModel) tcn).getMathModelInfo().getVersion().getName()) + "'";
                                if (currentTestSuite.getTSInfoNew().getTSKey().equals(testSuiteInfoHolder[OLDER].getTSKey())) {
                                    if (!olderTestCaseBaseNames.contains(baseName)) {
                                        olderTestCaseBaseNames.add(baseName);
                                    } else {
                                        throw new Exception("Old testcase names duplicated.");
                                    }
                                }
                                for (TestCriteriaNew tcrit : tcn.getTestCriterias()) {
                                    String name = baseName + " Sim='" + tcrit.getSimInfo().getName() + "'";
                                    if (olderTestCritHashMap.containsKey(name)) {
                                        if (currentTestSuiteKey.equals(testSuiteInfoHolder[OLDER].getTSKey())) {
                                            throw new Exception("---Problem--- Older names not unique");
                                        }
                                        continue;
                                    } else if (currentTestSuiteKey.equals(testSuiteInfoHolder[NEWER].getTSKey())) {
                                        if (!olderTestCaseBaseNames.contains(baseName)) {
                                            // this happens when new TestSuite has added TestCase after duplication
                                            excludedCount += 1;
                                        } else if (newDiffTestCriteria.put(prefixInfo + name, tcrit) != null) {
                                            throw new Exception("---Problem--- Newer added names not unique");
                                        }
                                        continue;
                                    }
                                    olderTestCritHashMap.put(name, tcrit);
                                }
                            }
                        }
                        if (newDiffTestCriteria.size() > 0) {
                            if (getClientTaskStatusSupport() != null) {
                                getClientTaskStatusSupport().setMessage("Showing Differential list...");
                            }
                            String[][] rowData = new String[newDiffTestCriteria.size()][1];
                            String[] addedNamesArr = newDiffTestCriteria.keySet().toArray(new String[0]);
                            for (int i = 0; i < addedNamesArr.length; i++) {
                                rowData[i][0] = addedNamesArr[i];
                            }
                            final String DELETE = "Delete";
                            TableListResult result = DialogUtils.showComponentOptionsTableList(gettestingFrameworkPanel(), "Remove TestCriteria in TS='" + testSuiteInfoHolder[NEWER].getTSID() + "' that were not in TS='" + testSuiteInfoHolder[OLDER].getTSID() + "' (count=" + rowData.length + " of " + olderTestCritHashMap.size() + ", excluded=" + excludedCount + ")", new String[] { "Diff TestCriteria" }, rowData, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, null, new String[] { DELETE, "Cancel" }, DELETE, null);
                            if (result != null && result.selectedOption != null && result.selectedOption.equals(DELETE) && result.selectedTableRows != null && result.selectedTableRows.length > 0) {
                                TestCriteriaNew[] allNewDiffTeestCritArr = newDiffTestCriteria.values().toArray(new TestCriteriaNew[0]);
                                TestCriteriaNew[] selTestCritsArr = new TestCriteriaNew[result.selectedTableRows.length];
                                for (int i = 0; i < result.selectedTableRows.length; i++) {
                                    selTestCritsArr[i] = allNewDiffTeestCritArr[result.selectedTableRows[i]];
                                // System.out.println("Selected= "+rowData[result.selectedTableRows[i]][0]+"  --  SimName="+selTestCritsArrHolder[0][i].getSimInfo().getVersion().getName());
                                }
                                hashTable.put(TFRemoveTestCriteria.REMOVE_THESE_TESTCRITERIAS, selTestCritsArr);
                            } else {
                                throw UserCancelException.CANCEL_GENERIC;
                            }
                        } else {
                            throw new Exception("No differential TestCriteria found");
                        }
                    }
                };
                AsynchClientTask shouldRefreshTask = new // Prevent annoying refresh if cancel
                AsynchClientTask(// Prevent annoying refresh if cancel
                "", // Prevent annoying refresh if cancel
                AsynchClientTask.TASKTYPE_SWING_NONBLOCKING) {

                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        new TFRefresh(getTestingFrameworkWindowManager(), testSuiteInfoHolder[NEWER]).run(hashTable);
                    }
                };
                tasksV.add(showDiffTask);
                tasksV.add(new TFRemoveTestCriteria(getTestingFrameworkWindowManager()));
                tasksV.add(shouldRefreshTask);
            // tasksV.add(new TFRefresh(getTestingFrameworkWindowManager(),testSuiteInfoHolder[NEWER]));
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.REMOVE_TESTCRITERIA)) {
            if (selectedObj instanceof TestCriteriaNew) {
                ArrayList<TestCriteriaNew> selTestCritsArr = new ArrayList<TestCriteriaNew>();
                for (int i = 0; selectedTreePaths != null && i < selectedTreePaths.length; i += 1) {
                    Object selTreeNode = ((BioModelNode) selectedTreePaths[i].getLastPathComponent()).getUserObject();
                    if (selTreeNode instanceof TestCriteriaNew) {
                        selTestCritsArr.add(((TestCriteriaNew) selTreeNode));
                    }
                }
                final String DELETE = "Delete";
                String response = DialogUtils.showWarningDialog(gettestingFrameworkPanel(), "Delete " + selTestCritsArr.size() + " TestCriterias?", new String[] { DELETE, "Cancel" }, DELETE);
                if (response != null && response.equals(DELETE)) {
                    tasksV.add(new TFRemoveTestCriteria(getTestingFrameworkWindowManager(), selTestCritsArr.toArray(new TestCriteriaNew[0])));
                    TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCriteria();
                    tasksV.add(new TFRefresh(getTestingFrameworkWindowManager(), tsInfo));
                } else {
                    throw UserCancelException.CANCEL_GENERIC;
                }
            } else {
                throw new Exception("Selected Object is not a TestCriteria! Cannot remove test criteria.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.EDIT_TESTCRITERIA)) {
            if (selectedObj instanceof TestCriteriaNew) {
                TestCriteriaNew tCriteria = (TestCriteriaNew) selectedObj;
                TestCaseNew testCase = gettestingFrameworkPanel().getTestCaseOfSelectedCriteria();
                TestCriteriaNew tcritNew = getTestingFrameworkWindowManager().getNewTestCriteriaFromUser(testCase.getType(), tCriteria);
                tasksV.add(new TFUpdateTestCriteria(getTestingFrameworkWindowManager(), tCriteria, tcritNew));
                TestSuiteInfoNew tsInfo = gettestingFrameworkPanel().getTestSuiteInfoOfSelectedTestCriteria();
                tfRefreshTreeTask = new TFRefresh(getTestingFrameworkWindowManager(), tsInfo);
                tasksV.add(tfRefreshTreeTask);
            } else {
                throw new Exception("Selected Object is not a TestCriteria! Cannot edit test criteria.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.COPY_TCRIT_SIMID)) {
            if (selectedObj instanceof TestCriteriaNew) {
                TestCriteriaNew tCriteria = (TestCriteriaNew) selectedObj;
                KeyValue testCritSimID = tCriteria.getSimInfo().getVersion().getVersionKey();
                VCellTransferable.sendToClipboard(testCritSimID.toString());
                return;
            } else {
                throw new Exception("Selected Object is not a TestCriteria! Copy simid failed.");
            }
        } else if (e.getActionCommand().equals(TestingFrameworkPanel.LOAD_MODEL)) {
            final String LOAD_THIS_MODEL = "LOAD_THIS_MODEL";
            AsynchClientTask modelInfoTask = new AsynchClientTask("Finding Model Info...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    VCDocumentInfo vcDocumentInfo = null;
                    if (selectedObj instanceof TestCaseNew) {
                        TestCaseNew testCase = (TestCaseNew) selectedObj;
                        if (testCase instanceof TestCaseNewMathModel) {
                            vcDocumentInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
                        } else if (testCase instanceof TestCaseNewBioModel) {
                            vcDocumentInfo = ((TestCaseNewBioModel) testCase).getBioModelInfo();
                        } else {
                            throw new IllegalArgumentException("Unexpected TestCase type=" + testCase.getClass().getName());
                        }
                        hashTable.put(LOAD_THIS_MODEL, vcDocumentInfo);
                    } else if (selectedObj instanceof LoadTestTreeInfo) {
                        throw new Exception("Not yet implemented for LoadTest.");
                    // LoadTestTreeInfo loadTestTreeInfo = (LoadTestTreeInfo)selectedObj;
                    // if(loadTestTreeInfo.modelType.equals(LoadTestInfoOpResults.MODELTYPE_BIO)){
                    // vcDocumentInfo = getDocumentManager().getBioModelInfo(loadTestTreeInfo.bioOrMathModelKey);
                    // }else if(loadTestTreeInfo.modelType.equals(LoadTestInfoOpResults.MODELTYPE_MATH)){
                    // vcDocumentInfo = getDocumentManager().getMathModelInfo(loadTestTreeInfo.bioOrMathModelKey);
                    // }else{
                    // throw new IllegalArgumentException("Unexpected LoadTestTreeInfo type="+loadTestTreeInfo.modelType);
                    // }
                    // hashTable.put(LOAD_THIS_MODEL, vcDocumentInfo);
                    }
                }
            };
            AsynchClientTask openModelTask = new AsynchClientTask("Opening model...", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    if (selectedObj instanceof TestCaseNew) {
                        getTestingFrameworkWindowManager().loadModel((VCDocumentInfo) hashTable.get(LOAD_THIS_MODEL));
                    } else if (selectedObj instanceof LoadTestTreeInfo) {
                        throw new Exception("Not yet implemented for LoadTest.");
                    } else {
                        throw new Exception("Load Model expecting TestCaseNew or LoadTestTreeInfo but got " + selectedObj.getClass().getName());
                    }
                }
            };
            tasksV.add(modelInfoTask);
            tasksV.add(openModelTask);
        }
        // tasksV.add(tfRefreshTreeTask);
        AsynchClientTask[] tasksArr = new AsynchClientTask[tasksV.size()];
        tasksV.copyInto(tasksArr);
        ClientTaskDispatcher.dispatch(this, hash, tasksArr, true);
    } catch (Throwable exc) {
        if (!(exc instanceof UserCancelException) && !(exc instanceof UtilCancelException)) {
            exc.printStackTrace(System.out);
            PopupGenerator.showErrorDialog(TestingFrameworkWindowPanel.this, exc.getMessage(), exc);
        }
    }
}
Also used : HashMap(java.util.HashMap) ActionEvent(java.awt.event.ActionEvent) LoadTestInfoOpResults(cbit.vcell.numericstest.LoadTestInfoOpResults) UserCancelException(org.vcell.util.UserCancelException) ArrayList(java.util.ArrayList) TFUpdateRunningStatus(cbit.vcell.client.task.TFUpdateRunningStatus) LoadTestSoftwareVersionTimeStamp(cbit.vcell.numericstest.LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp) TFRemove(cbit.vcell.client.task.TFRemove) TFRemoveTestCriteria(cbit.vcell.client.task.TFRemoveTestCriteria) TreeSet(java.util.TreeSet) Vector(java.util.Vector) UtilCancelException(org.vcell.util.UtilCancelException) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) SimulationStatus(cbit.vcell.server.SimulationStatus) TFDuplicateTestSuite(cbit.vcell.client.task.TFDuplicateTestSuite) SimulationInfo(cbit.vcell.solver.SimulationInfo) TableListResult(org.vcell.util.gui.DialogUtils.TableListResult) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) KeyValue(org.vcell.util.document.KeyValue) LoadTestInfoOP(cbit.vcell.numericstest.LoadTestInfoOP) BioModelNode(cbit.vcell.desktop.BioModelNode) TestingFrmwkTreeModel(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TFAddTestSuite(cbit.vcell.client.task.TFAddTestSuite) Hashtable(java.util.Hashtable) LoadTestTreeInfo(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.LoadTestTreeInfo) JLabel(javax.swing.JLabel) TreeMap(java.util.TreeMap) Date(java.util.Date) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException) BigDecimal(java.math.BigDecimal) TFUpdateRunningStatus(cbit.vcell.client.task.TFUpdateRunningStatus) LoadTestTreeInfo(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.LoadTestTreeInfo) TreePath(javax.swing.tree.TreePath) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) TFUpdateTestCriteria(cbit.vcell.client.task.TFUpdateTestCriteria) TFRunSims(cbit.vcell.client.task.TFRunSims) TFRefresh(cbit.vcell.client.task.TFRefresh) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) SimpleDateFormat(java.text.SimpleDateFormat) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Example 5 with TestSuiteNew

use of cbit.vcell.numericstest.TestSuiteNew in project vcell by virtualcell.

the class TestingFrameworkWindowManager method updateReports.

private void updateReports(final Hashtable<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>> genReportHash) {
    new Thread(new Runnable() {

        public void run() {
            Set<java.util.Map.Entry<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>>> tsInfoEntry = genReportHash.entrySet();
            Iterator<java.util.Map.Entry<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>>> tsInfoIter = tsInfoEntry.iterator();
            while (tsInfoIter.hasNext()) {
                try {
                    Entry<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>> entry = tsInfoIter.next();
                    TestSuiteInfoNew tsInfo = entry.getKey();
                    Vector<TestCriteriaCrossRefOPResults.CrossRefData> xrefDataV = entry.getValue();
                    // 
                    Vector<AsynchClientTask> tasksVLocal = new java.util.Vector<AsynchClientTask>();
                    tasksVLocal.add(new TFUpdateRunningStatus(TestingFrameworkWindowManager.this, tsInfo));
                    TestSuiteNew tsNew = getTestingFrameworkWindowPanel().getDocumentManager().getTestSuite(tsInfo.getTSKey());
                    for (int i = 0; i < xrefDataV.size(); i++) {
                        CrossRefData crossRefData = xrefDataV.elementAt(i);
                        boolean bDone = false;
                        for (int j = 0; j < tsNew.getTestCases().length; j++) {
                            TestCaseNew testCaseNew = tsNew.getTestCases()[j];
                            if (testCaseNew.getTCKey().equals(crossRefData.tcaseKey)) {
                                for (int k = 0; k < testCaseNew.getTestCriterias().length; k++) {
                                    TestCriteriaNew testCriteria = testCaseNew.getTestCriterias()[k];
                                    if (testCriteria.getTCritKey().equals(crossRefData.tcritKey)) {
                                        tasksVLocal.add(new TFGenerateReport(TestingFrameworkWindowManager.this, testCaseNew, testCriteria, null));
                                        bDone = true;
                                        break;
                                    }
                                }
                            }
                            if (bDone) {
                                break;
                            }
                        }
                    }
                    final String END_NOTIFIER = "END NOTIFIER";
                    tasksVLocal.add(new AsynchClientTask(END_NOTIFIER, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {

                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            hashTable.put(END_NOTIFIER, END_NOTIFIER);
                        }
                    });
                    tasksVLocal.add(new TFRefresh(TestingFrameworkWindowManager.this, tsInfo));
                    AsynchClientTask[] tasksArr = new AsynchClientTask[tasksVLocal.size()];
                    tasksVLocal.copyInto(tasksArr);
                    java.util.Hashtable<String, Object> hashLocal = new java.util.Hashtable<String, Object>();
                    ClientTaskDispatcher.dispatch(getTestingFrameworkWindowPanel(), hashLocal, tasksArr, true);
                    // Wait for each report to complete before going on to next because report methods are not thread safe?
                    while (!hashLocal.contains(END_NOTIFIER)) {
                        Thread.sleep(100);
                    }
                } catch (Exception e) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Error updating reports\n" + e.getMessage());
                    return;
                }
            }
        }
    }).start();
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) Entry(java.util.Map.Entry) Vector(java.util.Vector) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) Hashtable(java.util.Hashtable) TestCriteriaCrossRefOPResults(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) TFUpdateRunningStatus(cbit.vcell.client.task.TFUpdateRunningStatus) CrossRefData(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults.CrossRefData) TFRefresh(cbit.vcell.client.task.TFRefresh) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Aggregations

TestSuiteNew (cbit.vcell.numericstest.TestSuiteNew)9 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)8 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)6 TestSuiteInfoNew (cbit.vcell.numericstest.TestSuiteInfoNew)6 Vector (java.util.Vector)5 DataAccessException (org.vcell.util.DataAccessException)5 TestCaseNewBioModel (cbit.vcell.numericstest.TestCaseNewBioModel)4 TestCaseNewMathModel (cbit.vcell.numericstest.TestCaseNewMathModel)4 UserCancelException (org.vcell.util.UserCancelException)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)3 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)3 BigDecimal (java.math.BigDecimal)3 Hashtable (java.util.Hashtable)3 KeyValue (org.vcell.util.document.KeyValue)3 TFGenerateReport (cbit.vcell.client.task.TFGenerateReport)2 TFRefresh (cbit.vcell.client.task.TFRefresh)2 TFUpdateRunningStatus (cbit.vcell.client.task.TFUpdateRunningStatus)2 BioModelNode (cbit.vcell.desktop.BioModelNode)2 SimulationInfo (cbit.vcell.solver.SimulationInfo)2