Search in sources :

Example 1 with VariableComparisonSummary

use of cbit.vcell.solver.test.VariableComparisonSummary in project vcell by virtualcell.

the class MathTestingReportGenerator method main.

public static void main(String[] args) {
    ClientServerManager clientServerManager = null;
    try {
        if (args.length != 3) {
            System.out.println("usage: MathTestingReportGenerator apihost apiport password");
            System.exit(1);
        }
        String userid = "vcelltestaccount";
        String apihost = args[0];
        Integer apiport = Integer.parseInt(args[1]);
        String password = args[2];
        clientServerManager = ClientFactory.createRemoteClientServerManager(apihost, apiport, userid, password);
        DocumentManager documentManager = clientServerManager.getDocumentManager();
        TestSuiteInfoNew[] testSuiteInfos = documentManager.getTestSuiteInfos();
        for (TestSuiteInfoNew testSuiteInfo : testSuiteInfos) {
            System.out.println(testSuiteInfo.toShortString());
        }
        // 
        // sorted by TSKey
        // 
        Arrays.sort(testSuiteInfos, new Comparator<TestSuiteInfoNew>() {

            @Override
            public int compare(TestSuiteInfoNew o1, TestSuiteInfoNew o2) {
                return o1.getTSKey().compareTo(o2.getTSKey());
            }
        });
        // 
        // print out details of the last one.
        // 
        TestSuiteNew testSuite = documentManager.getTestSuite(testSuiteInfos[testSuiteInfos.length - 1].getTSKey());
        for (TestCaseNew testCase : testSuite.getTestCases()) {
            System.out.println("TEST CASE: " + testCase.getAnnotation());
            TestCriteriaNew[] testCriterias = testCase.getTestCriterias();
            for (TestCriteriaNew testCriteria : testCriterias) {
                System.out.println("   CRITERIA: " + testCriteria.getReportStatusMessage());
                for (VariableComparisonSummary summary : testCriteria.getVarComparisonSummaries()) {
                    System.out.println("        SUMMARY: " + summary.toShortString());
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
    } finally {
        if (clientServerManager != null) {
            clientServerManager.cleanup();
        }
    }
}
Also used : DocumentManager(cbit.vcell.clientdb.DocumentManager) ClientServerManager(cbit.vcell.client.server.ClientServerManager) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary)

Example 2 with VariableComparisonSummary

use of cbit.vcell.solver.test.VariableComparisonSummary in project vcell by virtualcell.

the class TestingFrameworkWindowManager method generateTestCriteriaReport.

/**
 * Insert the method's description here.
 * Creation date: (8/18/2003 5:36:47 PM)
 */
private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew testCriteria, Simulation testSim, TFGenerateReport.VCDocumentAndSimInfo userSelectedRefSimInfo) /*,VCDocument refDoc,VCDocument testDocument*/
{
    if (testSim.getScanCount() != 1) {
        throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
    }
    SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(testSim, 0);
    String simReportStatus = null;
    String simReportStatusMessage = null;
    StringBuffer reportTCBuffer = new StringBuffer();
    VariableComparisonSummary[] failVarSummaries = null;
    VariableComparisonSummary[] allVarSummaries = null;
    double absErr = 0;
    double relErr = 0;
    if (testCriteria != null) {
        absErr = testCriteria.getMaxAbsError().doubleValue();
        relErr = testCriteria.getMaxRelError().doubleValue();
    }
    try {
        VCDocument testDoc = null;
        if (testCase instanceof TestCaseNewMathModel) {
            MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
            MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
            testDoc = mathModel;
        } else if (testCase instanceof TestCaseNewBioModel) {
            TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
            // bioTestCase.
            BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
            BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
            testDoc = bioModel;
        }
        TFGenerateReport.VCDocumentAndSimInfo refVCDocumentAndSimInfo = null;
        if (userSelectedRefSimInfo == null) {
            SimulationInfo refSimInfo = testCriteria.getRegressionSimInfo();
            if (refSimInfo != null) {
                VCDocument refDoc = null;
                if (testCriteria instanceof TestCriteriaNewMathModel) {
                    MathModelInfo mmInfo = ((TestCriteriaNewMathModel) testCriteria).getRegressionMathModelInfo();
                    MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
                    refDoc = mathModel;
                } else if (testCriteria instanceof TestCriteriaNewBioModel) {
                    BioModelInfo bmInfo = ((TestCriteriaNewBioModel) testCriteria).getRegressionBioModelInfo();
                    BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
                    refDoc = bioModel;
                }
                refVCDocumentAndSimInfo = new TFGenerateReport.VCDocumentAndSimInfo(refSimInfo, refDoc);
            }
            reportTCBuffer.append("\t\t" + testSim.getName() + (refVCDocumentAndSimInfo != null ? " (Using TestCrit RegrRefSim)" : "") + " : " + "\n");
        } else {
            refVCDocumentAndSimInfo = userSelectedRefSimInfo;
            reportTCBuffer.append("\t\t" + testSim.getName() + " (Using UserDefined RegrRefSim '" + userSelectedRefSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier() + "') : " + "\n");
        }
        if (testCase.getType().equals(TestCaseNew.REGRESSION) && refVCDocumentAndSimInfo == null) {
            reportTCBuffer.append("\t\t\tNo reference SimInfo, SimInfoKey=" + testCriteria.getSimInfo().getVersion().getName() + ". Cannot perform Regression Test!\n");
            simReportStatus = TestCriteriaNew.TCRIT_STATUS_NOREFREGR;
        } else {
            VCDataIdentifier vcdID = new VCSimulationDataIdentifier(testSim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
            DataManager simDataManager = getRequestManager().getDataManager(null, vcdID, testSim.isSpatial());
            double[] timeArray = null;
            // can be histogram, so there won't be time array
            try {
                timeArray = simDataManager.getDataSetTimes();
            } catch (Exception ex) {
                ex.printStackTrace(System.out);
            }
            NonspatialStochSimOptions stochOpt = testSim.getSolverTaskDescription().getStochOpt();
            if ((stochOpt == null || stochOpt.getNumOfTrials() == 1) && (timeArray == null || timeArray.length == 0)) {
                reportTCBuffer.append("\t\t\tNO DATA : Simulation not run yet.\n");
                simReportStatus = TestCriteriaNew.TCRIT_STATUS_NODATA;
            } else {
                // SPATIAL simulation
                if (testSim.getMathDescription().isSpatial()) {
                    PDEDataManager pdeDataManager = (PDEDataManager) simDataManager;
                    // Get EXACT solution if test case type is EXACT, Compare with numerical
                    if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    // Get CONSTRUCTED solution if test case type is CONSTRUCTED, Compare with numerical
                    } else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    } else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
                        Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(refVCDocumentAndSimInfo.getSimInfo());
                        VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        PDEDataManager refDataManager = (PDEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
                        if (refSim.getScanCount() != 1) {
                            throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
                        }
                        SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
                        SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResults(simSymbolTable, pdeDataManager, refSimSymbolTable, refDataManager, varsToCompare, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), refVCDocumentAndSimInfo.getVCDocument(), getDataInfoProvider(refVCDocumentAndSimInfo.getVCDocument(), refDataManager.getPDEDataContext(), refSim.getName()), testDoc, getDataInfoProvider(testDoc, pdeDataManager.getPDEDataContext(), testSim.getName()));
                        // Failed var summaries
                        failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    }
                } else {
                    // NON-SPATIAL CASE
                    ODEDataManager odeDataManager = (ODEDataManager) simDataManager;
                    ODESolverResultSet numericalResultSet = odeDataManager.getODESolverResultSet();
                    // Get EXACT result set if test case type is EXACT, Compare with numerical
                    if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
                        ODESolverResultSet exactResultSet = MathTestingUtilities.getExactResultSet(testSim.getMathDescription(), timeArray, testSim.getSolverTaskDescription().getSensitivityParameter());
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
                        SimulationComparisonSummary simCompSummary_exact = MathTestingUtilities.compareResultSets(numericalResultSet, exactResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Get all the variable comparison summaries and the failed ones to print out report for EXACT solution comparison.
                        failVarSummaries = simCompSummary_exact.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_exact.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    // Get CONSTRUCTED result set if test case type is CONSTRUCTED , compare with numerical
                    } else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
                        ODESolverResultSet constructedResultSet = MathTestingUtilities.getConstructedResultSet(testSim.getMathDescription(), timeArray);
                        String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
                        SimulationComparisonSummary simCompSummary_constr = MathTestingUtilities.compareResultSets(numericalResultSet, constructedResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
                        // Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
                        failVarSummaries = simCompSummary_constr.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_constr.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    } else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
                        Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(testCriteria.getRegressionSimInfo());
                        if (refSim.getScanCount() != 1) {
                            throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
                        }
                        SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
                        String[] varsToTest = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
                        VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        ODEDataManager refDataManager = (ODEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
                        ODESolverResultSet referenceResultSet = refDataManager.getODESolverResultSet();
                        SimulationComparisonSummary simCompSummary_regr = null;
                        int interpolationOrder = 1;
                        SolverTaskDescription solverTaskDescription = refSim.getSolverTaskDescription();
                        if (solverTaskDescription.getOutputTimeSpec().isDefault() && ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepEvery() == 1) {
                            SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
                            if ((!solverDescription.supportsAll(SolverDescription.DiscontinutiesFeatures)) || !refSim.getMathDescription().hasDiscontinuities()) {
                                interpolationOrder = solverDescription.getTimeOrder();
                            }
                        }
                        simCompSummary_regr = MathTestingUtilities.compareUnEqualResultSets(numericalResultSet, referenceResultSet, varsToTest, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), interpolationOrder);
                        // Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
                        failVarSummaries = simCompSummary_regr.getFailingVariableComparisonSummaries(absErr, relErr);
                        allVarSummaries = simCompSummary_regr.getVariableComparisonSummaries();
                        if (failVarSummaries.length > 0) {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
                            // Failed simulation
                            reportTCBuffer.append("\t\tTolerance test FAILED \n");
                            reportTCBuffer.append("\t\tFailed Variables : \n");
                            for (int m = 0; m < failVarSummaries.length; m++) {
                                reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
                            }
                        } else {
                            simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
                            reportTCBuffer.append("\t\tTolerance test PASSED \n");
                        }
                        reportTCBuffer.append("\t\tPassed Variables : \n");
                        // Check if varSummary exists in failed summaries list. If not, simulation passed.
                        for (int m = 0; m < allVarSummaries.length; m++) {
                            if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
                                reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        simReportStatus = TestCriteriaNew.TCRIT_STATUS_RPERROR;
        simReportStatusMessage = e.getClass().getName() + " " + e.getMessage();
        reportTCBuffer.append("\t\t" + simReportStatusMessage + "\n");
        e.printStackTrace(System.out);
    }
    if (userSelectedRefSimInfo == null) {
        try {
            // Remove any test results already present for testCriteria
            RemoveTestResultsOP removeResultsOP = new RemoveTestResultsOP(new BigDecimal[] { testCriteria.getTCritKey() });
            // testResultsOPsVector.add(removeResultsOP);
            getRequestManager().getDocumentManager().doTestSuiteOP(removeResultsOP);
            // Create new AddTestREsultsOP object for the current simulation./testCriteria.
            if (allVarSummaries != null) {
                AddTestResultsOP testResultsOP = new AddTestResultsOP(testCriteria.getTCritKey(), allVarSummaries);
                // testResultsOPsVector.add(testResultsOP);
                // Write the testResults for simulation/TestCriteria into the database ...
                getRequestManager().getDocumentManager().doTestSuiteOP(testResultsOP);
            }
            // Update report status
            updateTCritStatus(testCriteria, simReportStatus, simReportStatusMessage);
        } catch (Throwable e) {
            reportTCBuffer.append("\t\tUpdate DB Results failed. " + e.getClass().getName() + " " + e.getMessage() + "\n");
            try {
                getRequestManager().getDocumentManager().doTestSuiteOP(new EditTestCriteriaOPReportStatus(testCriteria.getTCritKey(), TestCriteriaNew.TCRIT_STATUS_RPERROR, e.getClass().getName() + " " + e.getMessage()));
            } catch (Throwable e2) {
            // Nothing more can be done
            }
        }
    }
    return reportTCBuffer.toString();
}
Also used : 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) SolverDescription(cbit.vcell.solver.SolverDescription) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) RemoveTestResultsOP(cbit.vcell.numericstest.RemoveTestResultsOP) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) AddTestResultsOP(cbit.vcell.numericstest.AddTestResultsOP) SimulationComparisonSummary(cbit.vcell.solver.test.SimulationComparisonSummary) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) EditTestCriteriaOPReportStatus(cbit.vcell.numericstest.EditTestCriteriaOPReportStatus) VCDocument(org.vcell.util.document.VCDocument) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) BioModelInfo(org.vcell.util.document.BioModelInfo) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) MathModelInfo(org.vcell.util.document.MathModelInfo) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) Simulation(cbit.vcell.solver.Simulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) 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) ODEDataManager(cbit.vcell.simdata.ODEDataManager) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 3 with VariableComparisonSummary

use of cbit.vcell.solver.test.VariableComparisonSummary in project vcell by virtualcell.

the class BiomodelsDB_TestSuite method main.

public static void main(String[] args) {
    try {
        Logging.init();
        /*sanity check -- we currently only have a copasi_java dll for 32-bit, so let's make sure 
			 * we're running on the right JVM. (Note we can run this on 64 bit machine, just have to install
			 * a 32 bit JVM...)
			 */
        OperatingSystemInfo osi = OperatingSystemInfo.getInstance();
        if (!osi.isWindows() || osi.is64bit()) {
            System.err.println("run on 32 bit JVM");
            System.exit(99);
        }
        // following are set in command line processing
        SortedSet<BiomodelsNetEntry> modelIDs = new TreeSet<BiomodelsNetEntry>();
        BioModelsWebServices service = null;
        File outDir = null;
        boolean isDetailed;
        {
            // scope for command line processing
            Options commandOptions = new Options();
            Option help = new Option("help", false, "show help");
            commandOptions.addOption(help);
            Option detailed = new Option("detailed", false, "record detailed information");
            commandOptions.addOption(detailed);
            Option output = new Option("output", true, "output directory");
            output.setRequired(true);
            commandOptions.addOption(output);
            OptionGroup primary = new OptionGroup();
            LOption min = new LOption("min", true, "minimum number of model to import", true);
            min.setType(Number.class);
            LOption only = new LOption("only", true, "run only this model", false);
            only.setType(Number.class);
            LOption include = new LOption("include", true, "run on models in specified file", false);
            include.setType(String.class);
            LOption exclude = new LOption("exclude", true, "exclude models in specified file", true);
            exclude.setType(String.class);
            primary.addOption(min).addOption(only).addOption(include).addOption(exclude);
            for (Object obj : primary.getOptions()) {
                // CLI old, non-generic API
                commandOptions.addOption((Option) obj);
            }
            CommandLine cmdLine = null;
            try {
                CommandLineParser parser = new DefaultParser();
                cmdLine = parser.parse(commandOptions, args);
            } catch (ParseException e1) {
                e1.printStackTrace();
                HelpFormatter hf = new HelpFormatter();
                hf.printHelp("BiomodelsDB_TestSuite", commandOptions);
                System.exit(2);
            }
            Option[] present = cmdLine.getOptions();
            Set<Option> optionSet = new HashSet<Option>(Arrays.asList(present));
            if (optionSet.contains(help)) {
                HelpFormatter hf = new HelpFormatter();
                hf.printHelp("BiomodelsDB_TestSuite", commandOptions);
                System.exit(0);
            }
            // placeholder, avoid messing with nulls
            LOption primaryOpt = new LOption("", false, "", true);
            @SuppressWarnings("unchecked") Collection<? extends Option> priOpts = primary.getOptions();
            priOpts.retainAll(optionSet);
            if (!priOpts.isEmpty()) {
                assert (priOpts.size() == 1);
                primaryOpt = (LOption) priOpts.iterator().next();
            }
            outDir = new File(cmdLine.getOptionValue(output.getOpt()));
            if (!outDir.exists()) {
                outDir.mkdirs();
            }
            isDetailed = optionSet.contains(detailed);
            BioModelsWebServicesServiceLocator locator = new BioModelsWebServicesServiceLocator();
            service = locator.getBioModelsWebServices();
            if (primaryOpt.downloads) {
                String[] modelStrings = service.getAllCuratedModelsId();
                for (String s : modelStrings) {
                    modelIDs.add(new BiomodelsNetEntry(s));
                }
            }
            if (primaryOpt == only) {
                Long only1 = (Long) cmdLine.getParsedOptionValue(only.getOpt());
                modelIDs.add(new BiomodelsNetEntry(only1.intValue()));
            } else if (primaryOpt == min) {
                Long lv = (Long) cmdLine.getParsedOptionValue(min.getOpt());
                int minimumModel = lv.intValue();
                for (int m = 0; m < minimumModel; m++) {
                    modelIDs.remove(new BiomodelsNetEntry(m));
                }
            } else if (primaryOpt == include) {
                FileBaseFilter fbf = new FileBaseFilter(cmdLine.getOptionValue(include.getOpt()));
                modelIDs.addAll(fbf.models);
            } else if (primaryOpt == exclude) {
                FileBaseFilter fbf = new FileBaseFilter(cmdLine.getOptionValue(exclude.getOpt()));
                modelIDs.removeAll(fbf.models);
            }
        }
        // end command line processing
        WriterFlusher flusher = new WriterFlusher(10);
        PrintWriter detailWriter;
        PrintWriter bngWriter;
        PrintWriter sbmlWriter;
        SBMLExceptionSorter sbmlExceptions;
        if (isDetailed) {
            detailWriter = new PrintWriter(new File(outDir, "compareDetail.txt"));
            bngWriter = new PrintWriter(new File(outDir, "bngErrors.txt"));
            sbmlWriter = new PrintWriter(new File(outDir, "sbmlErrors.txt"));
            sbmlExceptions = new LiveSorter();
            flusher.add(detailWriter);
            flusher.add(bngWriter);
            flusher.add(sbmlWriter);
        } else {
            detailWriter = new PrintWriter(new NullWriter());
            bngWriter = new PrintWriter(new NullWriter());
            sbmlWriter = new PrintWriter(new NullWriter());
            sbmlExceptions = new NullSorter();
        }
        PropertyLoader.loadProperties();
        /**
         * example properties
         *
         * vcell.COPASI.executable = "C:\\Program Files\\COPASI\\bin\\CopasiSE.exe"
         * vcell.mathSBML.directory = "c:\\developer\\eclipse\\workspace\\mathsbml\\"
         * vcell.mathematica.kernel.executable = "C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\MathKernel.exe"
         */
        ResourceUtil.setNativeLibraryDirectory();
        PrintWriter printWriter = new PrintWriter(new FileWriter(new File(outDir, "summary.log"), true));
        flusher.add(printWriter);
        listModels(printWriter, modelIDs);
        // SBMLSolver copasiSBMLSolver = new CopasiSBMLSolver();
        SBMLSolver copasiSBMLSolver = new SBMLSolver() {

            @Override
            public File solve(String filePrefix, File outDir, String sbmlText, SimSpec testSpec) throws IOException, SolverException, SbmlException {
                throw new RuntimeException("COPASI SOLVER REMOVED, REIMPLEMENT");
            }

            @Override
            public String getResultsFileColumnDelimiter() {
                throw new RuntimeException("COPASI SOLVER REMOVED, REIMPLEMENT");
            }
        };
        try {
            printWriter.println(" | *BIOMODEL ID* | *BioModel name* | *PASS* | *Rel Error (VC/COP)(VC/MSBML)(COP/MSBML)* | *Exception* | ");
            removeToxic(modelIDs, printWriter);
            for (BiomodelsNetEntry modelID : modelIDs) {
                String modelName = service.getModelNameById(modelID.toString());
                String modelSBML = service.getModelById(modelID.toString());
                Element bioModelInfo = new Element(BioModelsNetPanel.BIOMODELINFO_ELEMENT_NAME);
                bioModelInfo.setAttribute(BioModelsNetPanel.ID_ATTRIBUTE_NAME, modelID.toString());
                bioModelInfo.setAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME, "false");
                bioModelInfo.setAttribute("vcell_ran", "false");
                bioModelInfo.setAttribute("COPASI_ran", "false");
                bioModelInfo.setAttribute("mSBML_ran", "false");
                bioModelInfo.setAttribute(BioModelsNetPanel.MODELNAME_ATTRIBUTE_NAME, modelName);
                boolean bUseUTF8 = true;
                File sbmlFile = new File(outDir, modelID + ".sbml");
                XmlUtil.writeXMLStringToFile(modelSBML, sbmlFile.getAbsolutePath(), bUseUTF8);
                PrintStream saved_sysout = System.out;
                PrintStream saved_syserr = System.err;
                PrintStream new_sysout = null;
                PrintStream new_syserr = null;
                try {
                    String filePrefix = modelID.toString();
                    String sbmlText = modelSBML;
                    File logFile = new File(outDir, filePrefix + ".log");
                    new_sysout = new PrintStream(logFile);
                    new_syserr = new_sysout;
                    System.setOut(new_sysout);
                    System.setErr(new_syserr);
                    StringBuffer combinedErrorBuffer = new StringBuffer();
                    SimSpec simSpec = SimSpec.fromSBML(modelSBML);
                    String[] varsToTest = simSpec.getVarsList();
                    printWriter.print("ModelId: " + modelID + ": ");
                    // if a model crashes out the libSBML dll, we will terminate abruptly. Flush
                    // summary log before that happens
                    printWriter.flush();
                    try {
                        // 
                        // get VCell solution with an embedded "ROUND TRIP" (time and species concentrations)
                        // 
                        ODESolverResultSet vcellResults_RT = null;
                        try {
                            VCellSBMLSolver vcellSBMLSolver_RT = new VCellSBMLSolver();
                            vcellSBMLSolver_RT.setRoundTrip(false);
                            // TODO try with round-trip later.
                            String columnDelimiter = vcellSBMLSolver_RT.getResultsFileColumnDelimiter();
                            File resultFile = vcellSBMLSolver_RT.solve(filePrefix, outDir, sbmlFile.getAbsolutePath(), simSpec);
                            vcellResults_RT = readResultFile(resultFile, columnDelimiter);
                            bioModelInfo.setAttribute("vcell_ran", "true");
                        } catch (BNGException e) {
                            bngWriter.println(modelID + " " + e.getMessage());
                            throw e;
                        } catch (SBMLImportException e) {
                            ModelException me = new ModelException(modelID, e);
                            write(sbmlWriter, me);
                            sbmlExceptions.add(me);
                            throw e;
                        } catch (Exception e) {
                            printWriter.println("vcell solve(roundtrip=true) failed");
                            e.printStackTrace(printWriter);
                            System.out.println("vcell solve(roundtrip=true) failed");
                            e.printStackTrace(System.out);
                            combinedErrorBuffer.append(" *VCELL_RT* _" + e.getMessage() + "_ ");
                            Element vcellSolverReport = new Element("SolverReport");
                            vcellSolverReport.setAttribute("solverName", "vcell");
                            vcellSolverReport.setAttribute("errorMessage", e.getMessage());
                            bioModelInfo.addContent(vcellSolverReport);
                            bioModelInfo.setAttribute("vcell_ran", "false");
                        }
                        // 
                        // get COPASI solution (time and species concentrations)
                        // 
                        ODESolverResultSet copasiResults = null;
                        try {
                            String columnDelimiter = copasiSBMLSolver.getResultsFileColumnDelimiter();
                            File resultFile = copasiSBMLSolver.solve(filePrefix, outDir, sbmlText, simSpec);
                            copasiResults = readResultFile(resultFile, columnDelimiter);
                            bioModelInfo.setAttribute("COPASI_ran", "true");
                        } catch (Exception e) {
                            printWriter.println("Copasi solve() failed");
                            e.printStackTrace(printWriter);
                            System.out.println("Copasi solve() failed");
                            e.printStackTrace(System.out);
                            combinedErrorBuffer.append(" *COPASI* _" + e.getMessage() + "_ ");
                            Element copasiSolverReport = new Element("SolverReport");
                            copasiSolverReport.setAttribute("solverName", "COPASI");
                            copasiSolverReport.setAttribute("errorMessage", e.getMessage());
                            bioModelInfo.addContent(copasiSolverReport);
                            bioModelInfo.setAttribute("COPASI_ran", "false");
                        }
                        // 
                        // get mSBML solution (time and species concentrations)
                        // 
                        /*
							ODESolverResultSet mSBMLResults = null;
							if (idInt != 246 && idInt != 250 && idInt != 285 && idInt != 301) {
								try {
									MathSBMLSolver mSBMLSolver = new MathSBMLSolver();
									String columnDelimiter = mSBMLSolver.getResultsFileColumnDelimiter();
									org.sbml.libsbml.SBMLDocument sbmlDocument = new SBMLReader().readSBML(sbmlFile.getAbsolutePath());
									long level = sbmlDocument.getLevel();
									long version = sbmlDocument.getVersion();
									String mathsbmlFilePrefix = filePrefix;
									if (level!=2 || (level==2 && version>3)){
	//									sbmlDocument.setConsistencyChecksForConversion(libsbmlConstants.LIBSBML_CAT_MODELING_PRACTICE, false);
										long numErrors = sbmlDocument.checkL2v3Compatibility();

										if (numErrors==0){
											boolean bConversionWorked = sbmlDocument.setLevelAndVersion(2, 3, false);
											SBMLDocument doc = new SBMLDocument(sbmlDocument);
											doc.setLevelAndVersion(2,3,false);
											if (bConversionWorked){
												mathsbmlFilePrefix = filePrefix+"_L2V3";
												long newVersion = doc.getVersion();
												SBMLWriter sbmlWriter = new SBMLWriter();
												sbmlText = sbmlWriter.writeToString(doc);
												try {
													XmlUtil.writeXMLStringToFile(sbmlText, mathsbmlFilePrefix+".sbml", true);
												} catch (IOException e1) {
													e1.printStackTrace(System.out);
												} 
											}else{
												throw new RuntimeException("couldn't convert SBML from L"+level+"V"+version+" to L2V3");
											}
										}else{
											throw new RuntimeException("couldn't convert SBML from L"+level+"V"+version+" to L2V3, not compatible: "+sbmlDocument.getError(0));
										}
									}
									File resultFile = mSBMLSolver.solve(mathsbmlFilePrefix, outDir, sbmlText, simSpec);
									mSBMLResults = readResultFile(resultFile, columnDelimiter); 
									bioModelInfo.setAttribute("mSBML_ran","true");
								}catch (Exception e){
									printWriter.println("mSBML solve() failed");
									e.printStackTrace(printWriter);
									System.out.println("mSBML solve() failed");
									e.printStackTrace(System.out);
									combinedErrorBuffer.append(" *mSBML* _"+e.getMessage()+"_ ");

									Element mSBMLSolverReport = new Element("SolverReport");
									mSBMLSolverReport.setAttribute("solverName","mSBML");
									mSBMLSolverReport.setAttribute("errorMessage",e.getMessage());
									bioModelInfo.addContent(mSBMLSolverReport);

									bioModelInfo.setAttribute("mSBML_ran","false");
								}
							}
							 */
                        // 
                        // compare results from COPASI and VCELL_RT
                        // 
                        Boolean bCOPASI_VCELL_matched = null;
                        if (copasiResults != null && vcellResults_RT != null) {
                            try {
                                SimulationComparisonSummary summary = MathTestingUtilities.compareResultSets(copasiResults, vcellResults_RT, varsToTest, TestCaseNew.REGRESSION, 1e-5, 1e-5);
                                double maxRelError = summary.getMaxRelativeError();
                                bioModelInfo.setAttribute("COPASI_VCELL_maxRelErr", Double.toString(maxRelError));
                                if (maxRelError < 1) {
                                    bCOPASI_VCELL_matched = true;
                                } else {
                                    detailWriter.println(modelID + " " + modelName);
                                    bCOPASI_VCELL_matched = false;
                                    Element solverComparison = new Element("SolverComparison");
                                    solverComparison.setAttribute("solver1", "vcell");
                                    solverComparison.setAttribute("solver2", "COPASI");
                                    VariableComparisonSummary[] failedVCSummaries = summary.getFailingVariableComparisonSummaries(1e-5, 1e-5);
                                    for (VariableComparisonSummary vcSummary : failedVCSummaries) {
                                        Element failedVariableSummary = getVariableSummary(vcSummary);
                                        solverComparison.addContent(failedVariableSummary);
                                        String ss = vcSummary.toShortString();
                                        detailWriter.print('\t');
                                        detailWriter.println(ss);
                                        System.out.println(ss);
                                    }
                                    detailWriter.println();
                                    bioModelInfo.addContent(solverComparison);
                                }
                            } catch (Exception e) {
                                printWriter.println("COMPARE VC/COPASI failed");
                                e.printStackTrace(printWriter);
                                System.out.println("COMPARE VC/COPASI failed");
                                e.printStackTrace(System.out);
                                combinedErrorBuffer.append(" *COMPARE VC/COPASI* _" + e.getMessage() + "_ ");
                                Element solverComparison = new Element("SolverComparison");
                                solverComparison.setAttribute("solver1", "vcell");
                                solverComparison.setAttribute("solver2", "COPASI");
                                solverComparison.setAttribute("error", e.getMessage());
                                bioModelInfo.addContent(solverComparison);
                            }
                        }
                        /*						
							Boolean bmSBML_VCELL_matched = null;
							if (mSBMLResults!=null && vcellResults_RT!=null){
								try {
									SimulationComparisonSummary summary = MathTestingUtilities.compareUnEqualResultSets(mSBMLResults, vcellResults_RT, varsToTest, 1e-5, 1e-5, 1);
									double maxRelError = summary.getMaxRelativeError();
									bioModelInfo.setAttribute("mSBML_VCELL_maxRelErr", Double.toString(maxRelError));

									if (maxRelError<1){
										bmSBML_VCELL_matched = true;
									}else{
										bmSBML_VCELL_matched = false;
										Element solverComparison = new Element("SolverComparison");
										solverComparison.setAttribute("solver1","vcell");
										solverComparison.setAttribute("solver2","mSBML");
										VariableComparisonSummary[] failedVCSummaries = summary.getFailingVariableComparisonSummaries(1e-5, 1e-5);
										for (VariableComparisonSummary vcSummary : failedVCSummaries){
											Element failedVariableSummary = getVariableSummary(vcSummary);
											solverComparison.addContent(failedVariableSummary);
											System.out.println(vcSummary.toShortString());
										}
										bioModelInfo.addContent(solverComparison);
									}
								} catch (Exception e) {
									printWriter.println("COMPARE VCRT/mSBML failed");
									e.printStackTrace(printWriter);
									System.out.println("COMPARE VCRT/mSBML failed");
									e.printStackTrace(System.out);
									combinedErrorBuffer.append(" *COMPARE VCRT/mSBML* _"+e.getMessage()+"_ ");

									Element solverComparison = new Element("SolverComparison");
									solverComparison.setAttribute("solver1","vcell");
									solverComparison.setAttribute("solver2","mSBML");
									solverComparison.setAttribute("error",e.getMessage());
									bioModelInfo.addContent(solverComparison);
								}
							}

							//
							// compare results from COPASI and mSBML
							//
							Boolean bCOPASI_mSBML_matched = null;
							if (copasiResults!=null && mSBMLResults!=null){
								try {
									SimulationComparisonSummary summary = MathTestingUtilities.compareUnEqualResultSets(copasiResults, mSBMLResults, varsToTest, 1e-5, 1e-5, 1);
									double maxRelError = summary.getMaxRelativeError();
									bioModelInfo.setAttribute("COPASI_mSBML_maxRelErr", Double.toString(maxRelError));

									if (maxRelError<1){
										bCOPASI_mSBML_matched = true;
									}else{
										bCOPASI_mSBML_matched = false;
										Element solverComparison = new Element("SolverComparison");
										solverComparison.setAttribute("solver1","COPASI");
										solverComparison.setAttribute("solver2","mSBML");
										solverComparison.setAttribute("result","failed");
										VariableComparisonSummary[] vcSummaries = summary.getVariableComparisonSummaries();
										for (VariableComparisonSummary vcSummary : vcSummaries){
											Element failedVariableSummary = getVariableSummary(vcSummary);
											solverComparison.addContent(failedVariableSummary);
											System.out.println(vcSummary.toShortString());
										}
										bioModelInfo.addContent(solverComparison);
									}
								} catch (Exception e) {
									printWriter.println("COMPARE COPASI/mSBML failed");
									e.printStackTrace(printWriter);
									System.out.println("COMPARE COPASI/mSBML failed");
									e.printStackTrace(System.out);
									combinedErrorBuffer.append(" *COMPARE COPASI/mSBML* _"+e.getMessage()+"_ ");

									Element solverComparison = new Element("SolverComparison");
									solverComparison.setAttribute("solver1","COPASI");
									solverComparison.setAttribute("solver2","mSBML");
									solverComparison.setAttribute("error",e.getMessage());
								}
							}
							 */
                        if ((bCOPASI_VCELL_matched != null && bCOPASI_VCELL_matched.booleanValue())) {
                            // || /*(bmSBML_VCELL_matched!=null && bmSBML_VCELL_matched.booleanValue()) */ )
                            bioModelInfo.setAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME, "true");
                            printWriter.println("PASS");
                        } else {
                            bioModelInfo.setAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME, "false");
                            printWriter.println("FAIL");
                        }
                    } catch (Exception e) {
                        e.printStackTrace(printWriter);
                        combinedErrorBuffer.append(" *UNKNOWN* _" + e.getMessage() + "_ ");
                        bioModelInfo.setAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME, "false");
                        bioModelInfo.setAttribute("exception", e.getMessage());
                    }
                    printWriter.flush();
                    // write for each model just in case files get corrupted (it happened).
                    write(bioModelInfo, new File(outDir, modelID + "_report.xml"));
                } finally {
                    if (new_sysout != null) {
                        new_sysout.close();
                        new_sysout = null;
                    }
                    if (new_syserr != null) {
                        new_syserr.close();
                        new_syserr = null;
                    }
                    System.setOut(saved_sysout);
                    System.setOut(saved_syserr);
                }
            }
            // this writes out the SBML import exceptions grouped by type
            if (!sbmlExceptions.isEmpty()) {
                Map<Category, Collection<ModelException>> map = sbmlExceptions.getMap();
                try (PrintWriter pw = new PrintWriter(new File(outDir, "sbmlSorted.txt"))) {
                    // SBMLImportException.Category
                    for (Category c : Category.values()) {
                        Collection<ModelException> meCollection = map.get(c);
                        for (ModelException me : meCollection) {
                            write(pw, me);
                        }
                    }
                }
            }
        } finally {
            printWriter.close();
            detailWriter.close();
            bngWriter.close();
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        e.printStackTrace(System.err);
    }
    System.exit(0);
}
Also used : BNGException(cbit.vcell.server.bionetgen.BNGException) HelpFormatter(org.apache.commons.cli.HelpFormatter) TreeSet(java.util.TreeSet) SBMLSolver(org.vcell.sbml.SBMLSolver) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) BioModelsWebServicesServiceLocator(uk.ac.ebi.www.biomodels_main.services.BioModelsWebServices.BioModelsWebServicesServiceLocator) Collection(java.util.Collection) Option(org.apache.commons.cli.Option) File(java.io.File) Options(org.apache.commons.cli.Options) SortedSet(java.util.SortedSet) Set(java.util.Set) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Category(org.vcell.sbml.vcell.SBMLImportException.Category) OperatingSystemInfo(cbit.vcell.resource.OperatingSystemInfo) FileWriter(java.io.FileWriter) Element(org.jdom.Element) NullWriter(org.apache.commons.io.output.NullWriter) OptionGroup(org.apache.commons.cli.OptionGroup) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) SimulationComparisonSummary(cbit.vcell.solver.test.SimulationComparisonSummary) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser) PrintWriter(java.io.PrintWriter) PrintStream(java.io.PrintStream) SBMLImportException(org.vcell.sbml.vcell.SBMLImportException) SimSpec(org.vcell.sbml.SimSpec) SbmlException(org.vcell.sbml.SbmlException) FileNotFoundException(java.io.FileNotFoundException) BNGException(cbit.vcell.server.bionetgen.BNGException) SBMLImportException(org.vcell.sbml.vcell.SBMLImportException) ParseException(org.apache.commons.cli.ParseException) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) BioModelsWebServices(uk.ac.ebi.www.biomodels_main.services.BioModelsWebServices.BioModelsWebServices) CommandLine(org.apache.commons.cli.CommandLine) ParseException(org.apache.commons.cli.ParseException)

Example 4 with VariableComparisonSummary

use of cbit.vcell.solver.test.VariableComparisonSummary in project vcell by virtualcell.

the class TestingFrmwkTreeModel method createSimulationSubTree.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 1:06:51 PM)
 * @return cbit.vcell.desktop.BioModelNode
 * @param docManager cbit.vcell.clientdb.DocumentManager
 */
private BioModelNode createSimulationSubTree(TestCriteriaNew tcInfo, BioModelNode simInfoNode, boolean refSimNull) throws DataAccessException {
    // 
    // add 'reportInfo' node (with nodes for status and comparison summaries for variables) - sim results
    // 
    VariableComparisonSummary[] varCompSummaries = tcInfo.getVarComparisonSummaries();
    BioModelNode reportInfoNode = null;
    boolean hasFailedVars = false;
    if (tcInfo != null) {
        // Calculate actual MAE,MRE
        double actualMAE = Double.NEGATIVE_INFINITY;
        double actualMRE = Double.NEGATIVE_INFINITY;
        if (varCompSummaries != null) {
            for (int i = 0; i < varCompSummaries.length; i++) {
                VariableComparisonSummary var1 = varCompSummaries[i];
                actualMAE = Math.max(actualMAE, var1.getAbsoluteError().doubleValue());
                actualMRE = Math.max(actualMRE, var1.getRelativeError().doubleValue());
            }
            reportInfoNode = new BioModelNode("Report Info: maxActualMAE=" + actualMAE + " maxActualMRE=" + actualMRE, true);
            // reportInfoNode.add(new BioModelNode("TBI", false));
            for (int i = 0; i < varCompSummaries.length; i++) {
                // For each Variable, get the corresponding varComparisonSummary,
                // Create a node varNode for varName, minRef,maxRef.
                // Create nodes for errors and add them as children to varNode
                // To enhance readability of errors in ResultSetsubtree on panel ...
                VariableComparisonSummary var1 = varCompSummaries[i];
                TestCriteriaVarUserObj tcritVarUserObj = new TestCriteriaVarUserObj(tcInfo, var1);
                // String varInfo = "Var = " + var1.getName() + " MAE = " + var1.getAbsoluteError() + " MRE = " + var1.getRelativeError();
                BioModelNode varInfoNode = new BioModelNode(tcritVarUserObj, true);
                if (VariableComparisonSummary.isFailed(var1)) {
                    varInfoNode.setRenderHint(FAILED_VARIABLE_MAE_MRE, Boolean.TRUE);
                    hasFailedVars = true;
                }
                String varInfo = "Mean Square Error = " + var1.getMeanSqError();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "minRef = " + var1.getMinRef();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "maxRef = " + var1.getMaxRef();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "timeAbsError = " + var1.getTimeAbsoluteError();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "indexAbsError = " + var1.getIndexAbsoluteError();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "timeRelError = " + var1.getTimeRelativeError();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                varInfo = "indexRelError = " + var1.getIndexRelativeError();
                varInfoNode.add(new cbit.vcell.desktop.BioModelNode(varInfo, false));
                reportInfoNode.add(varInfoNode);
            }
            if (hasFailedVars) {
                reportInfoNode.insert(new BioModelNode("FAILED", false), 0);
            } else {
                reportInfoNode.insert(new BioModelNode("PASSED", false), 0);
            }
        } else {
            String status = "NO DATA";
            if (refSimNull) {
                status = status + " : REFERENCE SIMULATION NOT SPECIFIED";
            }
            reportInfoNode = new BioModelNode(status, false);
            reportInfoNode.setRenderHint(SIMULATIONS_NO_REPORT, Boolean.TRUE);
        }
    }
    if (hasFailedVars) {
        simInfoNode.setRenderHint(FAILED_VARIABLE_MAE_MRE, Boolean.TRUE);
    } else {
        simInfoNode.setRenderHint(FAILED_VARIABLE_MAE_MRE, Boolean.FALSE);
    }
    return reportInfoNode;
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode) BioModelNode(cbit.vcell.desktop.BioModelNode) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary)

Example 5 with VariableComparisonSummary

use of cbit.vcell.solver.test.VariableComparisonSummary in project vcell by virtualcell.

the class DbDriver method testSuiteOP.

/**
 * Insert the method's description here.
 * Creation date: (10/19/2004 6:55:36 AM)
 * @return cbit.vcell.numericstest.TestSuiteNew
 * @param tsop cbit.vcell.numericstest.TestSuiteOP
 */
public static TestSuiteOPResults testSuiteOP(TestSuiteOP tsop, Connection con, User user, KeyFactory keyFactory) throws SQLException, DataAccessException {
    java.util.TreeSet<BigDecimal> changedTestSuiteKeys = new java.util.TreeSet<BigDecimal>();
    String sql = null;
    Statement stmt = null;
    try {
        if (tsop instanceof ModelGeometryOP) {
            ModelGeometryOP modelGeometryOP = (ModelGeometryOP) tsop;
            if (modelGeometryOP.getVCDocumentInfo() instanceof BioModelInfo) {
                BioModelInfo bioModelInfo = (BioModelInfo) modelGeometryOP.getVCDocumentInfo();
                sql = "SELECT " + SimContextTable.table.geometryRef.getQualifiedColName() + " FROM " + SimContextTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + " WHERE " + SimContextTable.table.name.getQualifiedColName() + " = '" + modelGeometryOP.getBioModelApplicationName() + "'" + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " = " + SimContextTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + " = " + bioModelInfo.getVersion().getVersionKey().toString();
            } else if (modelGeometryOP.getVCDocumentInfo() instanceof MathModelInfo) {
                MathModelInfo mathModelInfo = (MathModelInfo) modelGeometryOP.getVCDocumentInfo();
                sql = "SELECT " + MathDescTable.table.geometryRef.getQualifiedColName() + " FROM " + MathDescTable.table.getTableName() + "," + MathModelTable.table.getTableName() + " WHERE " + MathModelTable.table.id.getQualifiedColName() + " = " + mathModelInfo.getVersion().getVersionKey().toString() + " AND " + MathModelTable.table.mathRef.getQualifiedColName() + " = " + MathDescTable.table.id.getQualifiedColName();
            } else {
                throw new IllegalArgumentException("UnImplemented VCDocumentInfo type=" + modelGeometryOP.getVCDocumentInfo().getClass().getName());
            }
            stmt = con.createStatement();
            ResultSet rset = stmt.executeQuery(sql);
            BigDecimal geometryKey = null;
            if (rset.next()) {
                geometryKey = rset.getBigDecimal(1);
                if (rset.next()) {
                    throw new DataAccessException("Expecting only 1 Geometry but found at least 2");
                }
            } else {
                throw new DataAccessException("No Geometry found using criteria");
            }
            rset.close();
            stmt.close();
            return new ModelGeometryOPResults(new KeyValue(geometryKey));
        } else // 
        if (tsop instanceof LoadTestInfoOP) {
            // 
            if (((LoadTestInfoOP) tsop).getLoadTestOpFlag() == LoadTestOpFlag.delete) {
                // Delete before return details
                LoadTestSoftwareVersionTimeStamp[] deleteTheseVersTimeStamps = ((LoadTestInfoOP) tsop).getLoadTestSoftwareVersionTimeStamps();
                for (int i = 0; i < deleteTheseVersTimeStamps.length; i++) {
                    sql = "DELETE FROM " + LoadModelsStatTable.table.getTableName() + " WHERE " + LoadModelsStatTable.table.softwareVers + " = " + "'" + deleteTheseVersTimeStamps[i].getSoftwareVersion() + "'" + " AND " + LoadModelsStatTable.table.timeStamp + " = " + "'" + deleteTheseVersTimeStamps[i].getRunTimeStamp() + "'";
                    DbDriver.updateCleanSQL(con, sql);
                }
                return null;
            }
            // Check if Date info is requested
            if (((LoadTestInfoOP) tsop).getLoadTestOpFlag() == LoadTestOpFlag.info && ((LoadTestInfoOP) tsop).getBeginDate() != null) {
                final String YMD_FORMAT_STRING = "yyyy-MM-dd";
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat(YMD_FORMAT_STRING);
                final String BETWEEN_CONDITION = " BETWEEN " + " TO_DATE('" + simpleDateFormat.format(((LoadTestInfoOP) tsop).getBeginDate()) + " 00:00:00', '" + YMD_FORMAT_STRING + " HH24:MI:SS') " + " AND " + " TO_DATE('" + simpleDateFormat.format(((LoadTestInfoOP) tsop).getEndDate()) + " 23:59:59', '" + YMD_FORMAT_STRING + " HH24:MI:SS') ";
                sql = "SELECT " + BioModelTable.table.id.getQualifiedColName() + "," + UserTable.table.userid.getUnqualifiedColName() + " FROM " + BioModelTable.table.getTableName() + "," + UserTable.table.getTableName() + " WHERE " + UserTable.table.id.getQualifiedColName() + " = " + BioModelTable.table.ownerRef.getQualifiedColName() + " AND " + BioModelTable.table.versionDate.getQualifiedColName() + BETWEEN_CONDITION + " UNION " + "SELECT " + MathModelTable.table.id.getQualifiedColName() + "," + UserTable.table.userid.getUnqualifiedColName() + " FROM " + MathModelTable.table.getTableName() + "," + UserTable.table.getTableName() + " WHERE " + UserTable.table.id.getQualifiedColName() + " = " + MathModelTable.table.ownerRef.getQualifiedColName() + " AND " + MathModelTable.table.versionDate.getQualifiedColName() + BETWEEN_CONDITION;
                stmt = con.createStatement();
                ResultSet rset = stmt.executeQuery(sql);
                TreeSet<String> uniqueUserIDTreeSet = new TreeSet<String>();
                Vector<KeyValue> keyValuesBetweenDatesV = new Vector<KeyValue>();
                while (rset.next()) {
                    uniqueUserIDTreeSet.add(rset.getString(UserTable.table.userid.getUnqualifiedColName()));
                    keyValuesBetweenDatesV.add(new KeyValue(rset.getBigDecimal(1)));
                }
                rset.close();
                stmt.close();
                return new LoadTestInfoOpResults(((LoadTestInfoOP) tsop).getBeginDate(), ((LoadTestInfoOP) tsop).getEndDate(), keyValuesBetweenDatesV.toArray(new KeyValue[0]), uniqueUserIDTreeSet.toArray(new String[0]));
            }
            // 
            // Get LoadTest Info
            // 
            // Get existing SoftwareVersion-Timestamp  count
            // 
            Vector<Integer> loadTestInfoCountV = new Vector<Integer>();
            stmt = con.createStatement();
            sql = "SELECT COUNT(*)," + LoadModelsStatTable.table.softwareVers.getUnqualifiedColName() + "," + LoadModelsStatTable.table.timeStamp.getUnqualifiedColName() + " FROM " + LoadModelsStatTable.table.getTableName() + " GROUP BY " + LoadModelsStatTable.table.softwareVers.getUnqualifiedColName() + "," + LoadModelsStatTable.table.timeStamp.getUnqualifiedColName();
            Vector<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp> loadTestSoftwareVersionTimeStampsExistingV = new Vector<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp>();
            ResultSet rset = stmt.executeQuery(sql);
            while (rset.next()) {
                String softwareVersion = TokenMangler.getSQLRestoredString(rset.getString(LoadModelsStatTable.table.softwareVers.getUnqualifiedColName()));
                String runTimeStamp = rset.getString(LoadModelsStatTable.table.timeStamp.getUnqualifiedColName());
                loadTestSoftwareVersionTimeStampsExistingV.add(new LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp(softwareVersion, runTimeStamp));
                loadTestInfoCountV.add(rset.getInt(1));
            }
            rset.close();
            stmt.close();
            // 
            // Get empty test info count (models that haven't been checked yet during a test run)
            // 
            stmt = con.createStatement();
            sql = "SELECT COUNT(*)," + LoadModelsStatTable.table.softwareVers.getUnqualifiedColName() + "," + LoadModelsStatTable.table.timeStamp.getUnqualifiedColName() + " FROM " + LoadModelsStatTable.table.getTableName() + " WHERE " + LoadModelsStatTable.table.resultFlag.getUnqualifiedColName() + " IS NULL" + " GROUP BY " + LoadModelsStatTable.table.softwareVers.getUnqualifiedColName() + "," + LoadModelsStatTable.table.timeStamp.getUnqualifiedColName();
            Vector<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp> loadTestSoftwareVersionTimeStampsEmptyV = new Vector<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp>();
            rset = stmt.executeQuery(sql);
            Integer[] loadTestInfoCountEmptyArr = new Integer[loadTestInfoCountV.size()];
            while (rset.next()) {
                String softwareVersion = TokenMangler.getSQLRestoredString(rset.getString(LoadModelsStatTable.table.softwareVers.getUnqualifiedColName()));
                String runTimeStamp = rset.getString(LoadModelsStatTable.table.timeStamp.getUnqualifiedColName());
                loadTestSoftwareVersionTimeStampsEmptyV.add(new LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp(softwareVersion, runTimeStamp));
                // match to existing array index so full and empty match
                for (int i = 0; i < loadTestSoftwareVersionTimeStampsExistingV.size(); i++) {
                    if (loadTestSoftwareVersionTimeStampsExistingV.elementAt(i).getSoftwareVersion().equals(softwareVersion) && loadTestSoftwareVersionTimeStampsExistingV.elementAt(i).getRunTimeStamp().equals(runTimeStamp)) {
                        loadTestInfoCountEmptyArr[i] = rset.getInt(1);
                    }
                }
            }
            rset.close();
            stmt.close();
            // 
            // Get total Math and Bio model count
            // 
            int totalBioMathModelCount = 0;
            stmt = con.createStatement();
            sql = "SELECT COUNT(*) FROM " + BioModelTable.table.getTableName() + " UNION " + "SELECT COUNT(*) FROM " + MathModelTable.table.getTableName();
            rset = stmt.executeQuery(sql);
            if (rset.next()) {
                totalBioMathModelCount = rset.getInt(1);
                if (rset.next()) {
                    totalBioMathModelCount += rset.getInt(1);
                } else {
                    totalBioMathModelCount = 0;
                }
            }
            if (totalBioMathModelCount == 0) {
                throw new DataAccessException("No results when querying bio and Mathmodel count");
            }
            rset.close();
            stmt.close();
            // 
            // Get slow Loads
            // 
            Object loadTestSlowHash = null;
            if (((LoadTestInfoOP) tsop).getSlowLoadThresholdMilliSec() != null) {
                Integer slowLoaderThreshold = ((LoadTestInfoOP) tsop).getSlowLoadThresholdMilliSec();
                loadTestSlowHash = getLoadTestDetails(con, slowLoaderThreshold, null);
            }
            // 
            // Get failed loads
            // 
            Object loadTestFailHash = getLoadTestDetails(con, null, null);
            // 
            // Get user specified query info.
            // 
            Object loadTestUserQueryHash = null;
            if (((LoadTestInfoOP) tsop).getUserQueryCondition() != null) {
                loadTestUserQueryHash = getLoadTestDetails(con, null, ((LoadTestInfoOP) tsop).getUserQueryCondition());
            }
            return new LoadTestInfoOpResults(loadTestInfoCountV.toArray(new Integer[0]), loadTestInfoCountEmptyArr, totalBioMathModelCount, loadTestSoftwareVersionTimeStampsExistingV.toArray(new LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp[0]), (Hashtable<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp, Vector<LoadTestInfoOpResults.LoadTestFailDetails>>) loadTestFailHash, (Hashtable<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp, Vector<LoadTestInfoOpResults.LoadTestSlowDetails>>) loadTestSlowHash, (Hashtable<LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp, Vector<LoadTestInfoOpResults.LoadTestDetails>>) loadTestUserQueryHash, ((LoadTestInfoOP) tsop).getSlowLoadThresholdMilliSec());
        }
        // 
        // TestSuite operations ---------------------------------------------------------------------------------------------------
        // 
        stmt = con.createStatement();
        if (tsop instanceof AddTestSuiteOP) {
            AddTestSuiteOP addts_tsop = (AddTestSuiteOP) tsop;
            String annotation = addts_tsop.getTestSuiteAnnotation();
            if (annotation != null) {
                if (annotation.length() == 0) {
                    annotation = null;
                } else {
                    annotation = TokenMangler.getSQLEscapedString(annotation);
                }
            }
            BigDecimal changedTSKey = keyFactory.getUniqueBigDecimal(con);
            final int NOT_LOCKED = 0;
            sql = "INSERT INTO " + TFTestSuiteTable.table.getTableName() + " VALUES(" + changedTSKey + ",'" + addts_tsop.getTestSuiteVersionID() + "'," + "'" + addts_tsop.getVCellBuildVersionID() + "'" + "," + "'" + addts_tsop.getNumericsBuildVersionID() + "'" + "," + "current_timestamp,current_timestamp," + (annotation == null ? "NULL" : "'" + annotation + "'") + "," + NOT_LOCKED + ")";
            stmt.executeUpdate(sql);
            if (addts_tsop.getAddTestCasesOPs() != null) {
                for (int i = 0; i < addts_tsop.getAddTestCasesOPs().length; i += 1) {
                    // Set new TSKey and do child OPs
                    AddTestCasesOP atcOP = addts_tsop.getAddTestCasesOPs()[i];
                    if (atcOP instanceof AddTestCasesOPMathModel) {
                        testSuiteOP(new AddTestCasesOPMathModel(changedTSKey, ((AddTestCasesOPMathModel) atcOP).getMathModelKey(), atcOP.getTestCaseType(), atcOP.getAnnotation(), ((AddTestCasesOPMathModel) atcOP).getAddTestCriteriaOPsMathModel()), con, user, keyFactory);
                    } else if (atcOP instanceof AddTestCasesOPBioModel) {
                        testSuiteOP(new AddTestCasesOPBioModel(changedTSKey, ((AddTestCasesOPBioModel) atcOP).getBioModelKey(), ((AddTestCasesOPBioModel) atcOP).getSimContextKey(), atcOP.getTestCaseType(), atcOP.getAnnotation(), ((AddTestCasesOPBioModel) atcOP).getAddTestCriteriaOPsBioModel()), con, user, keyFactory);
                    }
                }
            }
            changedTestSuiteKeys.add(changedTSKey);
        } else if (tsop instanceof AddTestCasesOPBioModel) {
            AddTestCasesOPBioModel addtc_tsop = (AddTestCasesOPBioModel) tsop;
            // 
            BigDecimal bmSimContextLinkRef = null;
            // Convert BioModelKey and SimContextKey to bmsimcontext key
            sql = "SELECT " + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " FROM " + BioModelSimContextLinkTable.table.getTableName() + " WHERE " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + addtc_tsop.getBioModelKey().toString() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + "=" + addtc_tsop.getSimContextKey().toString();
            ResultSet rset = stmt.executeQuery(sql);
            if (rset.next()) {
                bmSimContextLinkRef = rset.getBigDecimal(BioModelSimContextLinkTable.table.id.getUnqualifiedColName());
                if (rset.next()) {
                    throw new DataAccessException("Too many MathModelSimLink found for bmKey=" + addtc_tsop.getBioModelKey() + " simContextKey=" + addtc_tsop.getSimContextKey());
                }
            } else {
                throw new DataAccessException("No BioModelSimcontextLink found for bmKey=" + addtc_tsop.getBioModelKey() + " simContextKey=" + addtc_tsop.getSimContextKey());
            }
            rset.close();
            // 
            BigDecimal tcKey = keyFactory.getUniqueBigDecimal(con);
            String annotation = addtc_tsop.getAnnotation();
            if (annotation != null) {
                annotation = TokenMangler.getSQLEscapedString(annotation);
            }
            stmt.executeUpdate("INSERT INTO " + TFTestCaseTable.table.getTableName() + " VALUES(" + tcKey.toString() + "," + addtc_tsop.getTestSuiteKey().toString() + ",NULL," + "'" + addtc_tsop.getTestCaseType() + "'" + "," + "'" + annotation + "'" + "," + "current_timestamp" + "," + bmSimContextLinkRef.toString() + ")");
            if (addtc_tsop.getAddTestCriteriaOPsBioModel() != null) {
                for (int i = 0; i < addtc_tsop.getAddTestCriteriaOPsBioModel().length; i += 1) {
                    // Set new TSKey,TCaseKey and do child OPs
                    AddTestCriteriaOPBioModel atcritOP = addtc_tsop.getAddTestCriteriaOPsBioModel()[i];
                    testSuiteOP(new AddTestCriteriaOPBioModel(tcKey, atcritOP.getBioModelSimKey(), atcritOP.getRegressionBioModelKey(), atcritOP.getRegressionBioModelSimKey(), atcritOP.getMaxAbsoluteError(), atcritOP.getMaxRelativeError(), atcritOP.getAddTestResultsOP()), con, user, keyFactory);
                }
            }
            changedTestSuiteKeys.add(addtc_tsop.getTestSuiteKey());
        } else if (tsop instanceof AddTestCasesOPMathModel) {
            AddTestCasesOPMathModel addtc_tsop = (AddTestCasesOPMathModel) tsop;
            BigDecimal tcKey = keyFactory.getUniqueBigDecimal(con);
            KeyValue mmKey = addtc_tsop.getMathModelKey();
            String annotation = addtc_tsop.getAnnotation();
            if (annotation != null) {
                annotation = TokenMangler.getSQLEscapedString(annotation);
            }
            stmt.executeUpdate("INSERT INTO " + TFTestCaseTable.table.getTableName() + " VALUES(" + tcKey.toString() + "," + addtc_tsop.getTestSuiteKey().toString() + "," + mmKey.toString() + "," + "'" + addtc_tsop.getTestCaseType() + "'" + "," + "'" + annotation + "'" + "," + "current_timestamp" + ",NULL)");
            if (addtc_tsop.getAddTestCriteriaOPsMathModel() != null) {
                for (int i = 0; i < addtc_tsop.getAddTestCriteriaOPsMathModel().length; i += 1) {
                    // Set new TSKey,TCaseKey and do child OPs
                    AddTestCriteriaOPMathModel atcritOP = addtc_tsop.getAddTestCriteriaOPsMathModel()[i];
                    testSuiteOP(new AddTestCriteriaOPMathModel(tcKey, atcritOP.getMathModelSimKey(), atcritOP.getRegressionMathModelKey(), atcritOP.getRegressionMathModelSimKey(), atcritOP.getMaxAbsoluteError(), atcritOP.getMaxRelativeError(), atcritOP.getAddTestResultsOP()), con, user, keyFactory);
                }
            }
            changedTestSuiteKeys.add(addtc_tsop.getTestSuiteKey());
        } else if (tsop instanceof RemoveTestCasesOP) {
            RemoveTestCasesOP removetc_tsop = (RemoveTestCasesOP) tsop;
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < removetc_tsop.getTestCasesKeys().length; i += 1) {
                if (i != 0) {
                    sb.append(",");
                }
                sb.append(removetc_tsop.getTestCasesKeys()[i].toString());
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + " IN (" + sb.toString() + ")" + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
            int numRowsUpdated = stmt.executeUpdate("DELETE FROM " + TFTestCaseTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getUnqualifiedColName() + " IN (" + sb.toString() + ")");
            if (numRowsUpdated != removetc_tsop.getTestCasesKeys().length) {
                throw new DataAccessException("Remove TestCase keys=" + sb.toString() + " from TSKey=" + removetc_tsop.getTestSuiteKey() + " removed row count=" + numRowsUpdated + " expected " + removetc_tsop.getTestCasesKeys().length);
            }
        } else if (tsop instanceof AddTestCriteriaOPMathModel) {
            AddTestCriteriaOPMathModel addtcrit_tsop = (AddTestCriteriaOPMathModel) tsop;
            BigDecimal tcritKey = keyFactory.getUniqueBigDecimal(con);
            BigDecimal tcKey = addtcrit_tsop.getTestCaseKey();
            KeyValue simKey = addtcrit_tsop.getMathModelSimKey();
            // Check that there is a single mathmodel associated with simkey and parentsimref is null
            sql = "SELECT " + MathModelSimulationLinkTable.table.id.getQualifiedColName() + " FROM " + MathModelSimulationLinkTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + MathModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + simKey.toString() + " AND " + MathModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + SimulationTable.table.getTableName() + "." + SimulationTable.versionParentSimRef_ColumnName + " IS NULL";
            ResultSet rset = stmt.executeQuery(sql);
            if (rset.next()) {
                if (rset.next()) {
                    throw new DataAccessException("Too many MathModelSimulationLink found for simKey=" + simKey);
                }
            } else {
                throw new DataAccessException("No MathModelSimulationLink found for simKey=" + simKey);
            }
            rset.close();
            // //
            // //Make sure TestCase type and regressionRef match
            // sql = "SELECT "+TFTestCaseTable.table.id.getQualifiedColName()+
            // " FROM "+TFTestCaseTable.table.getTableName()+
            // " WHERE "+
            // TFTestCaseTable.table.id.getQualifiedColName()+"="+tcKey.toString()+
            // " AND "+
            // TFTestCaseTable.table.tcSolutionType.getQualifiedColName()+
            // (regrSimKey != null?"=":"!=")+
            // "'"+cbit.vcell.numericstest.TestCaseNew.REGRESSION+"'";
            // rset = stmt.executeQuery(sql);
            // if(!rset.next()){
            // throw new DataAccessException("TestCase type not compatible with regressionSimKey");
            // }
            // rset.close();
            // 
            // 
            // Get simDataRef from simKey
            BigDecimal simDataRef = null;
            // sql =
            // "SELECT "+ResultSetMetaDataTable.table.id.getQualifiedColName()+
            // " FROM " +ResultSetMetaDataTable.table.getTableName()+
            // " WHERE "+
            // ResultSetMetaDataTable.table.simRef.getQualifiedColName()+"="+simKey.toString();
            // rset = stmt.executeQuery(sql);
            // if(rset.next()){
            // simDataRef = rset.getBigDecimal(MathModelSimulationLinkTable.table.id.getUnqualifiedColName());
            // if(rset.next()){
            // throw new DataAccessException("Too many ResultSetMetaData found for simKey="+simKey);
            // }
            // }
            // else{
            // throw new DataAccessException("No ResultSetMetaData found for simKey="+simKey);
            // }
            rset.close();
            // 
            // Insert TestCriteria
            sql = "INSERT INTO " + TFTestCriteriaTable.table.getTableName() + " VALUES(" + tcritKey.toString() + "," + tcKey.toString() + "," + simKey.toString() + "," + (simDataRef != null ? simDataRef.toString() : null) + "," + "NULL" + "," + (addtcrit_tsop.getMaxRelativeError() != null ? "TO_NUMBER('" + addtcrit_tsop.getMaxRelativeError().toString() + "')" : "null") + "," + (addtcrit_tsop.getMaxAbsoluteError() != null ? "TO_NUMBER('" + addtcrit_tsop.getMaxAbsoluteError().toString() + "')" : "null") + "," + "NULL,NULL," + "'" + TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT + "'" + ",null" + ")";
            stmt.executeUpdate(sql);
            if (addtcrit_tsop.getRegressionMathModelSimKey() != null) {
                testSuiteOP(new EditTestCriteriaOPMathModel(tcritKey, addtcrit_tsop.getRegressionMathModelKey(), addtcrit_tsop.getRegressionMathModelSimKey(), addtcrit_tsop.getMaxAbsoluteError(), addtcrit_tsop.getMaxRelativeError()), con, user, keyFactory);
            }
            if (addtcrit_tsop.getAddTestResultsOP() != null) {
                AddTestResultsOP atrOP = addtcrit_tsop.getAddTestResultsOP();
                // Set new TSKey,TCritKey and do child OPs
                testSuiteOP(new AddTestResultsOP(tcritKey, atrOP.getVariableComparisonSummaries()), con, user, keyFactory);
            }
            rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKey.toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof AddTestCriteriaOPBioModel) {
            AddTestCriteriaOPBioModel addtcrit_tsop = (AddTestCriteriaOPBioModel) tsop;
            BigDecimal tcritKey = keyFactory.getUniqueBigDecimal(con);
            BigDecimal tcKey = addtcrit_tsop.getTestCaseKey();
            KeyValue simKey = addtcrit_tsop.getBioModelSimKey();
            // Check that there is a single biomodel associated with simkey and parentsimref is null
            sql = "SELECT " + BioModelSimulationLinkTable.table.id.getQualifiedColName() + " FROM " + BioModelSimulationLinkTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + simKey.toString() + " AND " + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + SimulationTable.table.getTableName() + "." + SimulationTable.versionParentSimRef_ColumnName + " IS NULL";
            ResultSet rset = stmt.executeQuery(sql);
            if (rset.next()) {
                if (rset.next()) {
                    throw new DataAccessException("Too many BioModelSimulationLink found for simKey=" + simKey);
                }
            } else {
                throw new DataAccessException("No BioModelSimulationLink found for simKey=" + simKey);
            }
            rset.close();
            // //
            // //Make sure TestCase type and regressionRef match
            // sql = "SELECT "+TFTestCaseTable.table.id.getQualifiedColName()+
            // " FROM "+TFTestCaseTable.table.getTableName()+
            // " WHERE "+
            // TFTestCaseTable.table.id.getQualifiedColName()+"="+tcKey.toString()+
            // " AND "+
            // TFTestCaseTable.table.tcSolutionType.getQualifiedColName()+
            // (regrSimKey != null?"=":"!=")+
            // "'"+cbit.vcell.numericstest.TestCaseNew.REGRESSION+"'";
            // rset = stmt.executeQuery(sql);
            // if(!rset.next()){
            // throw new DataAccessException("TestCase type not compatible with regressionSimKey");
            // }
            // rset.close();
            // 
            // 
            // Get simDataRef from simKey
            BigDecimal simDataRef = null;
            // sql =
            // "SELECT "+ResultSetMetaDataTable.table.id.getQualifiedColName()+
            // " FROM " +ResultSetMetaDataTable.table.getTableName()+
            // " WHERE "+
            // ResultSetMetaDataTable.table.simRef.getQualifiedColName()+"="+simKey.toString();
            // rset = stmt.executeQuery(sql);
            // if(rset.next()){
            // simDataRef = rset.getBigDecimal(BioModelSimulationLinkTable.table.id.getUnqualifiedColName());
            // if(rset.next()){
            // throw new DataAccessException("Too many ResultSetMetaData found for simKey="+simKey);
            // }
            // }
            // else{
            // throw new DataAccessException("No ResultSetMetaData found for simKey="+simKey);
            // }
            rset.close();
            // 
            // Insert TestCriteria
            sql = "INSERT INTO " + TFTestCriteriaTable.table.getTableName() + " VALUES(" + tcritKey.toString() + "," + tcKey.toString() + "," + simKey.toString() + "," + (simDataRef != null ? simDataRef.toString() : null) + "," + "null" + "," + (addtcrit_tsop.getMaxRelativeError() != null ? "TO_NUMBER('" + addtcrit_tsop.getMaxRelativeError().toString() + "')" : "null") + "," + (addtcrit_tsop.getMaxAbsoluteError() != null ? "TO_NUMBER('" + addtcrit_tsop.getMaxAbsoluteError().toString() + "')" : "null") + "," + "NULL,NULL," + "'" + TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT + "'" + ",null" + ")";
            stmt.executeUpdate(sql);
            if (addtcrit_tsop.getRegressionBioModelSimKey() != null) {
                testSuiteOP(new EditTestCriteriaOPBioModel(tcritKey, addtcrit_tsop.getRegressionBioModelKey(), addtcrit_tsop.getRegressionBioModelSimKey(), addtcrit_tsop.getMaxAbsoluteError(), addtcrit_tsop.getMaxRelativeError()), con, user, keyFactory);
            }
            if (addtcrit_tsop.getAddTestResultsOP() != null) {
                AddTestResultsOP atrOP = addtcrit_tsop.getAddTestResultsOP();
                // Set new TSKey,TCritKey and do child OPs
                testSuiteOP(new AddTestResultsOP(tcritKey, atrOP.getVariableComparisonSummaries()), con, user, keyFactory);
            }
            rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKey.toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof RemoveTestCriteriaOP) {
            RemoveTestCriteriaOP removetcrit_tsop = (RemoveTestCriteriaOP) tsop;
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < removetcrit_tsop.getTestCriterias().length; i += 1) {
                if (i != 0) {
                    sb.append(",");
                }
                sb.append(removetcrit_tsop.getTestCriterias()[i].getTCritKey().toString());
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " IN (" + sb.toString() + ")" + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
            int numRowsUpdated = stmt.executeUpdate("DELETE FROM " + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getUnqualifiedColName() + " IN (" + sb.toString() + ")");
            if (numRowsUpdated != removetcrit_tsop.getTestCriterias().length) {
                throw new DataAccessException("Remove TestCriteria keys=" + sb.toString() + " removed row count=" + numRowsUpdated + " expected " + removetcrit_tsop.getTestCriterias().length);
            }
        } else if (tsop instanceof RemoveTestSuiteOP) {
            RemoveTestSuiteOP removets_tsop = (RemoveTestSuiteOP) tsop;
            int numRowsUpdated = stmt.executeUpdate("DELETE FROM " + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getUnqualifiedColName() + "=" + removets_tsop.getTestSuiteKey().toString());
            if (numRowsUpdated != 1) {
                throw new DataAccessException("Remove SINGLE TestSuite - key=" + removets_tsop.getTestSuiteKey().toString() + " removed row count=" + numRowsUpdated);
            }
            changedTestSuiteKeys.add(removets_tsop.getTestSuiteKey());
        } else if (tsop instanceof AddTestResultsOP) {
            AddTestResultsOP addtr_tsop = (AddTestResultsOP) tsop;
            VariableComparisonSummary[] vcs = addtr_tsop.getVariableComparisonSummaries();
            if (vcs == null || vcs.length == 0) {
                throw new DataAccessException(RemoveTestCasesOP.class.getName() + " had no TestResults");
            }
            for (int i = 0; i < vcs.length; i += 1) {
                if (vcs[i] == null) {
                    throw new DataAccessException(RemoveTestCasesOP.class.getName() + " Array element was null");
                }
            }
            ResultSet rset = stmt.executeQuery("SELECT " + TFTestResultTable.table.id.getUnqualifiedColName() + " FROM " + TFTestResultTable.table.getTableName() + " WHERE " + TFTestResultTable.table.testCriteriaRef.getUnqualifiedColName() + "=" + addtr_tsop.getTestCriteriaKey().toString());
            if (rset.next()) {
                throw new DataAccessException("AddTestResultsOP Criteria key=" + addtr_tsop.getTestCriteriaKey() + " has results");
            }
            rset.close();
            for (int i = 0; i < vcs.length; i += 1) {
                sql = "INSERT INTO " + TFTestResultTable.table.getTableName() + " VALUES(" + "NEWSEQ.NEXTVAL" + "," + addtr_tsop.getTestCriteriaKey().toString() + "," + "'" + vcs[i].getName() + "'" + "," + "TO_NUMBER('" + vcs[i].getAbsoluteError() + "')" + "," + "TO_NUMBER('" + vcs[i].getRelativeError() + "')" + "," + "TO_NUMBER('" + vcs[i].getMaxRef() + "')" + "," + "TO_NUMBER('" + vcs[i].getMinRef() + "')" + "," + "TO_NUMBER('" + vcs[i].getMeanSqError() + "')" + "," + "TO_NUMBER('" + vcs[i].getTimeAbsoluteError() + "')" + "," + "TO_NUMBER('" + vcs[i].getIndexAbsoluteError() + "')" + "," + "TO_NUMBER('" + vcs[i].getTimeRelativeError() + "')" + "," + "TO_NUMBER('" + vcs[i].getIndexRelativeError() + "')" + ")";
                stmt.executeUpdate(sql);
            }
            rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + addtr_tsop.getTestCriteriaKey().toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof RemoveTestResultsOP) {
            RemoveTestResultsOP removetr_tsop = (RemoveTestResultsOP) tsop;
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < removetr_tsop.getTestCriteriaKeys().length; i += 1) {
                if (i != 0) {
                    sb.append(",");
                }
                sb.append(removetr_tsop.getTestCriteriaKeys()[i].toString());
                stmt.executeUpdate("DELETE FROM " + TFTestResultTable.table.getTableName() + " WHERE " + TFTestResultTable.table.testCriteriaRef.getUnqualifiedColName() + "=" + removetr_tsop.getTestCriteriaKeys()[i].toString());
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " IN (" + sb.toString() + ")" + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof EditTestCriteriaOPReportStatus) {
            EditTestCriteriaOPReportStatus edittcrit_tsop = (EditTestCriteriaOPReportStatus) tsop;
            BigDecimal tcritKey = edittcrit_tsop.getTestCriteriaKey();
            if (tcritKey == null) {
                throw new DataAccessException(tsop.getClass().getName() + " had no TestCriteria keys");
            }
            String newRS = edittcrit_tsop.getNewReportStatus();
            if (newRS == null || (!newRS.equals(TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_FAILEDVARS) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_NODATA) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_NOREFREGR) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_PASSED) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_RPERROR) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_SIMFAILED) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_SIMRUNNING) && !newRS.equals(TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE))) {
                throw new DataAccessException("Unsupported ReportStatus=" + edittcrit_tsop.getNewReportStatus());
            }
            String reportStatusMessage = edittcrit_tsop.getNewReportStatusMessage();
            if (reportStatusMessage != null) {
                reportStatusMessage = TokenMangler.getSQLEscapedString(reportStatusMessage);
                reportStatusMessage = reportStatusMessage.substring(0, Math.min(TFTestCriteriaTable.MAX_MESSAGE_SIZE, reportStatusMessage.length()));
            }
            stmt.executeUpdate("UPDATE " + TFTestCriteriaTable.table.getTableName() + " SET " + TFTestCriteriaTable.table.reportStatus.getQualifiedColName() + "=" + (newRS != null ? "'" + newRS + "'" : "null") + "," + TFTestCriteriaTable.table.reportMessage.getQualifiedColName() + "=" + (reportStatusMessage != null ? "'" + reportStatusMessage + "'" : "null") + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKey.toString());
            if (newRS.equals(TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT)) {
                testSuiteOP(new RemoveTestResultsOP(new BigDecimal[] { tcritKey }), con, user, keyFactory);
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " = " + tcritKey.toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof EditTestCriteriaOPMathModel) {
            EditTestCriteriaOPMathModel edittcrit_tsop = (EditTestCriteriaOPMathModel) tsop;
            BigDecimal tcritKey = edittcrit_tsop.getTestCriteriaKey();
            if (tcritKey == null) {
                throw new DataAccessException(tsop.getClass().getName() + " had no TestCriteria keys");
            }
            if ((edittcrit_tsop.getMathModelRegressionRef() == null && edittcrit_tsop.getMathModelRegressionSimRef() != null) || (edittcrit_tsop.getMathModelRegressionRef() != null && edittcrit_tsop.getMathModelRegressionSimRef() == null)) {
                throw new DataAccessException(tsop.getClass().getName() + " MathRef and SimRef must both be null or both not null");
            }
            Double maxAbsError = edittcrit_tsop.getNewMaxAbsError();
            Double maxRelError = edittcrit_tsop.getNewMaxRelError();
            KeyValue regrSimRef = edittcrit_tsop.getMathModelRegressionSimRef();
            // Convert regrSimKey to regrMathModelSimLinkKey
            BigDecimal regrMathModelSimLink = null;
            if (regrSimRef != null) {
                sql = "SELECT " + MathModelSimulationLinkTable.table.id.getQualifiedColName() + " FROM " + MathModelSimulationLinkTable.table.getTableName() + " WHERE " + MathModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + regrSimRef.toString();
                ResultSet rset = stmt.executeQuery(sql);
                if (rset.next()) {
                    regrMathModelSimLink = rset.getBigDecimal(MathModelSimulationLinkTable.table.id.getUnqualifiedColName());
                    if (rset.next()) {
                        throw new DataAccessException("Too many MathModelSimLink found for regrSimKey=" + regrSimRef);
                    }
                } else {
                    throw new DataAccessException("No MathModelSimLink found for regrSimKey=" + regrSimRef);
                }
                rset.close();
            }
            stmt.executeUpdate("UPDATE " + TFTestCriteriaTable.table.getTableName() + " SET " + TFTestCriteriaTable.table.maxAbsError.getQualifiedColName() + "=" + (maxAbsError != null ? "TO_NUMBER(" + maxAbsError.toString() + ")" : "null") + "," + TFTestCriteriaTable.table.maxRelError.getQualifiedColName() + "=" + (maxRelError != null ? "TO_NUMBER(" + maxRelError.toString() + ")" : "null") + "," + TFTestCriteriaTable.table.regressionMMSimRef.getQualifiedColName() + "=" + (regrMathModelSimLink != null ? regrMathModelSimLink.toString() : "null") + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKey.toString());
            testSuiteOP(new EditTestCriteriaOPReportStatus(tcritKey, TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null), con, user, keyFactory);
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " = " + tcritKey.toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof EditTestCriteriaOPBioModel) {
            EditTestCriteriaOPBioModel edittcrit_tsop = (EditTestCriteriaOPBioModel) tsop;
            BigDecimal tcritKey = edittcrit_tsop.getTestCriteriaKey();
            if (tcritKey == null) {
                throw new DataAccessException(tsop.getClass().getName() + " had no TestCriteria keys");
            }
            if ((edittcrit_tsop.getBioModelRegressionRef() == null && edittcrit_tsop.getBioModelRegressionSimRef() != null) || (edittcrit_tsop.getBioModelRegressionRef() != null && edittcrit_tsop.getBioModelRegressionSimRef() == null)) {
                throw new DataAccessException(tsop.getClass().getName() + " ApplicationRef and SimRef must both be null or both not null");
            }
            Double maxAbsError = edittcrit_tsop.getNewMaxAbsError();
            Double maxRelError = edittcrit_tsop.getNewMaxRelError();
            BigDecimal bmscAppKey = null;
            BigDecimal bmsltSimKey = null;
            final String BMSLT = "BMSLT";
            if (edittcrit_tsop.getBioModelRegressionSimRef() != null) {
                sql = "SELECT " + BioModelSimContextLinkTable.table.id.getQualifiedColName() + "," + BioModelSimulationLinkTable.table.id.getQualifiedColName() + " " + BMSLT + " FROM " + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + SimulationTable.table.getTableName() + "," + BioModelSimulationLinkTable.table.getTableName() + " WHERE " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + edittcrit_tsop.getBioModelRegressionRef() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + "=" + SimContextTable.table.id.getQualifiedColName() + " AND " + SimContextTable.table.mathRef.getQualifiedColName() + "=" + SimulationTable.table.mathRef.getQualifiedColName() + " AND " + SimulationTable.table.id.getQualifiedColName() + "=" + edittcrit_tsop.getBioModelRegressionSimRef().toString() + " AND " + BioModelSimulationLinkTable.table.bioModelRef.getQualifiedColName() + " = " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + " AND " + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + " = " + SimulationTable.table.id.getQualifiedColName();
                ResultSet rset = stmt.executeQuery(sql);
                if (rset.next()) {
                    bmscAppKey = rset.getBigDecimal(BioModelSimContextLinkTable.table.id.getUnqualifiedColName());
                    bmsltSimKey = rset.getBigDecimal(BMSLT);
                    if (rset.next()) {
                        throw new DataAccessException("Too many ResultSetMetaData found for simKey=" + edittcrit_tsop.getBioModelRegressionSimRef());
                    }
                }
                rset.close();
            }
            stmt.executeUpdate("UPDATE " + TFTestCriteriaTable.table.getTableName() + " SET " + TFTestCriteriaTable.table.maxAbsError.getQualifiedColName() + "=" + (maxAbsError != null ? "TO_NUMBER(" + maxAbsError.toString() + ")" : "null") + "," + TFTestCriteriaTable.table.maxRelError.getQualifiedColName() + "=" + (maxRelError != null ? "TO_NUMBER(" + maxRelError.toString() + ")" : "null") + "," + TFTestCriteriaTable.table.regressionBMAPPRef.getQualifiedColName() + "=" + (bmscAppKey != null ? bmscAppKey.toString() : "NULL") + "," + TFTestCriteriaTable.table.regressionBMSimRef.getQualifiedColName() + "=" + (bmsltSimKey != null ? bmsltSimKey.toString() : "NULL") + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKey.toString());
            testSuiteOP(new EditTestCriteriaOPReportStatus(tcritKey, TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null), con, user, keyFactory);
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " = " + tcritKey.toString() + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof ChangeTestCriteriaErrorLimitOP) {
            ChangeTestCriteriaErrorLimitOP edittcrit_tsop = (ChangeTestCriteriaErrorLimitOP) tsop;
            BigDecimal[] tcritKeyArr = edittcrit_tsop.getTestCriteriaKeys();
            double[] maxAbsErrorArr = edittcrit_tsop.getAbsErrorLimits();
            double[] maxRelErrorArr = edittcrit_tsop.getRelErrorLimits();
            if (tcritKeyArr == null || (maxAbsErrorArr != null && maxAbsErrorArr.length != tcritKeyArr.length) || (maxAbsErrorArr != null && maxRelErrorArr.length != tcritKeyArr.length)) {
                throw new DataAccessException(tsop.getClass().getName() + " Improper arguments.");
            }
            StringBuffer tcritList = new StringBuffer();
            for (int i = 0; i < tcritKeyArr.length; i++) {
                if (i != 0) {
                    tcritList.append(",");
                }
                tcritList.append(tcritKeyArr[i]);
                stmt.executeUpdate("UPDATE " + TFTestCriteriaTable.table.getTableName() + " SET " + (maxAbsErrorArr != null ? TFTestCriteriaTable.table.maxAbsError.getQualifiedColName() + "=" + maxAbsErrorArr[i] : "") + (maxAbsErrorArr != null && maxRelErrorArr != null ? "," : "") + (maxRelErrorArr != null ? TFTestCriteriaTable.table.maxRelError.getQualifiedColName() + "=" + maxRelErrorArr[i] : "") + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + tcritKeyArr[i].toString());
                testSuiteOP(new EditTestCriteriaOPReportStatus(tcritKeyArr[i], TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null), con, user, keyFactory);
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + " IN (" + tcritList.toString() + ")" + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
        } else if (tsop instanceof EditTestCasesOP) {
            EditTestCasesOP edittc_tsop = (EditTestCasesOP) tsop;
            BigDecimal[] tcaseKeys = edittc_tsop.getTestCasesKeys();
            String[] annots = edittc_tsop.getNewAnnotations();
            boolean[] newSteadyStates = edittc_tsop.getNewSteadyStates();
            if (tcaseKeys == null || tcaseKeys.length == 0) {
                throw new DataAccessException(tsop.getClass().getName() + " had no TestCase keys");
            }
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < tcaseKeys.length; i += 1) {
                if (i != 0) {
                    sb.append(",");
                }
                sb.append(tcaseKeys[i].toString());
                if (annots != null) {
                    String annotation = annots[i];
                    if (annotation != null) {
                        if (annotation.length() == 0) {
                            annotation = null;
                        } else {
                            annotation = TokenMangler.getSQLEscapedString(annotation);
                        }
                    }
                    stmt.executeUpdate("UPDATE " + TFTestCaseTable.table.getTableName() + " SET " + TFTestCaseTable.table.tcAnnotation.getQualifiedColName() + "=" + (annotation == null ? "NULL" : "'" + annotation + "'") + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + tcaseKeys[i].toString());
                }
                if (newSteadyStates != null) {
                    // Make sure the change is for EXACT type
                    ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestCriteriaTable.table.id.getQualifiedColName() + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + tcaseKeys[i].toString() + " AND " + "(" + TFTestCaseTable.table.tcSolutionType.getQualifiedColName() + "='" + TestCaseNew.EXACT + "'" + " OR " + TFTestCaseTable.table.tcSolutionType.getQualifiedColName() + "='" + TestCaseNew.EXACT_STEADY + "'" + ")" + " AND " + TFTestCriteriaTable.table.testCaseRef + "=" + TFTestCaseTable.table.id.getQualifiedColName());
                    // Get TestCriteria Keys for Test case
                    Vector<BigDecimal> tcritKeyV = new Vector<BigDecimal>();
                    while (rset.next()) {
                        tcritKeyV.add(rset.getBigDecimal(TFTestCriteriaTable.table.id.getUnqualifiedColName()));
                    }
                    if (tcritKeyV.size() == 0) {
                        throw new DataAccessException("Updating SteadyState on TestCase that is not EXACT is NOT allowed.");
                    }
                    rset.close();
                    // Change SteadyState type for TestCase
                    boolean newSteadyState = newSteadyStates[i];
                    stmt.executeUpdate("UPDATE " + TFTestCaseTable.table.getTableName() + " SET " + TFTestCaseTable.table.tcSolutionType.getQualifiedColName() + "=" + (newSteadyState ? "'" + TestCaseNew.EXACT_STEADY + "'" : "'" + TestCaseNew.EXACT + "'") + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + tcaseKeys[i].toString());
                    // Change Report status
                    for (int j = 0; j < tcritKeyV.size(); j++) {
                        EditTestCriteriaOPReportStatus etcors = new EditTestCriteriaOPReportStatus(tcritKeyV.elementAt(j), TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null);
                        testSuiteOP(etcors, con, user, keyFactory);
                    }
                }
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + " WHERE " + TFTestCaseTable.table.id.getQualifiedColName() + " IN (" + sb.toString() + ")" + " AND " + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + "=" + TFTestSuiteTable.table.id.getQualifiedColName());
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof EditTestSuiteOP) {
            EditTestSuiteOP editts_tsop = (EditTestSuiteOP) tsop;
            BigDecimal[] tsKeys = editts_tsop.getTestSuiteKeys();
            String[] annots = editts_tsop.getNewAnnotations();
            if (tsKeys == null || tsKeys.length == 0) {
                throw new DataAccessException(tsop.getClass().getName() + " had no TestSuite keys");
            }
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < tsKeys.length; i += 1) {
                if (i != 0) {
                    sb.append(",");
                }
                sb.append(tsKeys[i].toString());
                if (editts_tsop.isLock() != null) {
                    stmt.executeUpdate("UPDATE " + TFTestSuiteTable.table.getTableName() + " SET " + TFTestSuiteTable.table.isLocked.getQualifiedColName() + "= 1" + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + tsKeys[i].toString());
                } else {
                    if (annots != null) {
                        String annotation = annots[i];
                        if (annotation != null) {
                            if (annotation.length() == 0) {
                                annotation = null;
                            } else {
                                annotation = TokenMangler.getSQLEscapedString(annotation);
                            }
                        }
                        stmt.executeUpdate("UPDATE " + TFTestSuiteTable.table.getTableName() + " SET " + TFTestSuiteTable.table.tsAnnotation.getQualifiedColName() + "=" + (annotation == null ? "NULL" : "'" + annotation + "'") + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + tsKeys[i].toString());
                    }
                }
            }
            ResultSet rset = stmt.executeQuery("SELECT DISTINCT " + TFTestSuiteTable.table.id.getQualifiedColName() + " FROM " + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + " IN (" + sb.toString() + ")");
            while (rset.next()) {
                changedTestSuiteKeys.add(rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName()));
            }
            rset.close();
        } else if (tsop instanceof QueryTestCriteriaCrossRefOP) {
            QueryTestCriteriaCrossRefOP qtcritxr_tsop = (QueryTestCriteriaCrossRefOP) tsop;
            Vector<TestCriteriaCrossRefOPResults.CrossRefData> crossRefV = new Vector<TestCriteriaCrossRefOPResults.CrossRefData>();
            // 
            // BioModel query
            // 
            String TSID = "tsid";
            String TCID = "tcid";
            String TCRID = "tcrid";
            String BMNAME = "bmname";
            String SCNAME = "scname";
            String SIMNAME = "simname";
            String TSALT = "TSALT";
            String TCALT = "TCALT";
            String TCRALT = "TCRALT";
            String BSCALT = "BSCALT";
            String MMSIMALT = "MMSIMALT";
            String MODELID = "MODELID";
            String REFTSUITEKEY = "REFTSUITEKEY";
            String REFTCASEKEY = "REFTCASEKEY";
            String REFTCRITKEY = "REFTCRITKEY";
            // String TCRALT2 = "TCRALT2";
            // String SIM2 = "SIM2";
            sql = "SELECT DISTINCT " + TFTestSuiteTable.table.tsVersion.getQualifiedColName() + "," + TFTestSuiteTable.table.id.getQualifiedColName() + " " + TSID + "," + TFTestCaseTable.table.id.getQualifiedColName() + " " + TCID + "," + TFTestCriteriaTable.table.id.getQualifiedColName() + " " + TCRID + "," + BioModelTable.table.name.getQualifiedColName() + " " + BMNAME + "," + SimContextTable.table.name.getQualifiedColName() + " " + SCNAME + "," + SimulationTable.table.name.getQualifiedColName() + " " + SIMNAME + "," + TFTestCriteriaTable.table.maxAbsError.getQualifiedColName() + "," + TFTestCriteriaTable.table.maxRelError.getQualifiedColName() + "," + TFTestResultTable.table.varName.getQualifiedColName() + "," + TFTestResultTable.table.minRef.getQualifiedColName() + "," + TFTestResultTable.table.maxRef.getQualifiedColName() + "," + TFTestResultTable.table.absError.getQualifiedColName() + "," + TFTestResultTable.table.relError.getQualifiedColName() + "," + TFTestResultTable.table.meanSqrError.getQualifiedColName() + "," + TFTestResultTable.table.timeAbsError.getQualifiedColName() + "," + TFTestResultTable.table.indexAbsError.getQualifiedColName() + "," + TFTestResultTable.table.timeRelError.getQualifiedColName() + "," + TFTestResultTable.table.indexRelError.getQualifiedColName() + "," + TSALT + "." + TFTestSuiteTable.table.tsVersion.getUnqualifiedColName() + "," + BSCALT + "." + BioModelSimContextLinkTable.table.bioModelRef.getUnqualifiedColName() + "," + TFTestCaseTable.table.tcSolutionType.getQualifiedColName() + "," + BioModelTable.table.id.getQualifiedColName() + " " + MODELID + "," + TSALT + "." + TFTestSuiteTable.table.id.getUnqualifiedColName() + " " + REFTSUITEKEY + "," + TCALT + "." + TFTestCaseTable.table.id.getUnqualifiedColName() + " " + REFTCASEKEY + "," + "NULL " + // TCRALT2+"."+TFTestCriteriaTable.table.id.getUnqualifiedColName() +" "+REFTCRITKEY +
            REFTCRITKEY + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + TFTestResultTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + BioModelTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + SimulationTable.table.getTableName() + "," + BioModelSimulationLinkTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + " " + TSALT + "," + TFTestCaseTable.table.getTableName() + " " + TCALT + "," + TFTestCriteriaTable.table.getTableName() + " " + TCRALT + "," + BioModelSimContextLinkTable.table.getTableName() + " " + BSCALT + // ","+TFTestCriteriaTable.table.getTableName()+" "+TCRALT2+
            " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + "=" + TFTestCaseTable.table.id.getQualifiedColName() + " AND " + TFTestResultTable.table.testCriteriaRef.getQualifiedColName() + "(+)" + "=" + TFTestCriteriaTable.table.id.getQualifiedColName() + (qtcritxr_tsop.getVarName() != null ? " AND " + TFTestResultTable.table.varName.getQualifiedColName() + "(+)" + "=" + "'" + qtcritxr_tsop.getVarName() + "'" : "") + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + "=" + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + BioModelTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + "=" + SimContextTable.table.id.getQualifiedColName() + " AND " + BioModelSimulationLinkTable.table.bioModelRef.getQualifiedColName() + "=" + BioModelTable.table.id.getQualifiedColName() + " AND " + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + BioModelTable.table.versionBranchID.getQualifiedColName() + "=" + "(" + "SELECT DISTINCT " + BioModelTable.table.versionBranchID.getQualifiedColName() + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + BioModelTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + qtcritxr_tsop.getTestCriterium() + " AND " + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + "=" + TFTestCaseTable.table.id.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + "=" + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + BioModelTable.table.id.getQualifiedColName() + ")" + " AND " + SimContextTable.table.name.getQualifiedColName() + "=" + "(" + "SELECT DISTINCT " + SimContextTable.table.name.getQualifiedColName() + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + qtcritxr_tsop.getTestCriterium() + " AND " + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + "=" + TFTestCaseTable.table.id.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + "=" + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + "=" + SimContextTable.table.id.getQualifiedColName() + ")" + " AND " + SimulationTable.table.name.getQualifiedColName() + "=" + "(" + "SELECT DISTINCT " + SimulationTable.table.name.getQualifiedColName() + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + qtcritxr_tsop.getTestCriterium() + " AND " + TFTestCriteriaTable.table.simulationRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + ")" + // reference info
            " AND " + TSALT + "." + TFTestSuiteTable.table.id.getUnqualifiedColName() + "(+)" + "=" + TCALT + "." + TFTestCaseTable.table.testSuiteRef.getUnqualifiedColName() + " AND " + BSCALT + "." + BioModelSimContextLinkTable.table.id.getUnqualifiedColName() + "(+)" + "=" + TCRALT + "." + TFTestCriteriaTable.table.regressionBMAPPRef.getUnqualifiedColName() + " AND " + TCALT + "." + TFTestCaseTable.table.bmAppRef.getUnqualifiedColName() + "(+)" + "=" + TCRALT + "." + TFTestCriteriaTable.table.regressionBMAPPRef.getUnqualifiedColName() + " AND " + TCRALT + "." + TFTestCriteriaTable.table.id.getUnqualifiedColName() + "=" + TFTestCriteriaTable.table.id.getQualifiedColName() + // SIM2+"."+SimulationTable.table.name.getUnqualifiedColName()+"="+SimulationTable.table.name.getQualifiedColName()+
            " ORDER BY " + TSID;
            ResultSet rset = stmt.executeQuery(sql);
            while (rset.next()) {
                crossRefV.add(new TestCriteriaCrossRefOPResults.CrossRefData(rset, true));
            }
            rset.close();
            // 
            // MathModel query
            // 
            String MMNAME = "mmname";
            sql = "SELECT DISTINCT " + TFTestSuiteTable.table.tsVersion.getQualifiedColName() + "," + TFTestSuiteTable.table.id.getQualifiedColName() + " " + TSID + "," + TFTestCaseTable.table.id.getQualifiedColName() + " " + TCID + "," + TFTestCriteriaTable.table.id.getQualifiedColName() + " " + TCRID + "," + MathModelTable.table.name.getQualifiedColName() + " " + MMNAME + "," + SimulationTable.table.name.getQualifiedColName() + " " + SIMNAME + "," + TFTestCriteriaTable.table.maxAbsError.getQualifiedColName() + "," + TFTestCriteriaTable.table.maxRelError.getQualifiedColName() + "," + TFTestResultTable.table.varName.getQualifiedColName() + "," + TFTestResultTable.table.minRef.getQualifiedColName() + "," + TFTestResultTable.table.maxRef.getQualifiedColName() + "," + TFTestResultTable.table.absError.getQualifiedColName() + "," + TFTestResultTable.table.relError.getQualifiedColName() + "," + TFTestResultTable.table.meanSqrError.getQualifiedColName() + "," + TFTestResultTable.table.timeAbsError.getQualifiedColName() + "," + TFTestResultTable.table.indexAbsError.getQualifiedColName() + "," + TFTestResultTable.table.timeRelError.getQualifiedColName() + "," + TFTestResultTable.table.indexRelError.getQualifiedColName() + "," + TSALT + "." + TFTestSuiteTable.table.tsVersion.getUnqualifiedColName() + "," + MMSIMALT + "." + MathModelSimulationLinkTable.table.mathModelRef.getUnqualifiedColName() + "," + TFTestCaseTable.table.tcSolutionType.getQualifiedColName() + "," + MathModelTable.table.id.getQualifiedColName() + " " + MODELID + "," + TSALT + "." + TFTestSuiteTable.table.id.getUnqualifiedColName() + " " + REFTSUITEKEY + "," + TCALT + "." + TFTestCaseTable.table.id.getUnqualifiedColName() + " " + REFTCASEKEY + "," + "NULL " + // TCRALT2+"."+TFTestCriteriaTable.table.id.getUnqualifiedColName() +" "+REFTCRITKEY +
            REFTCRITKEY + " FROM " + TFTestSuiteTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + TFTestResultTable.table.getTableName() + "," + MathModelTable.table.getTableName() + "," + SimulationTable.table.getTableName() + "," + MathModelSimulationLinkTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + " " + TSALT + "," + TFTestCaseTable.table.getTableName() + " " + TCALT + "," + TFTestCriteriaTable.table.getTableName() + " " + TCRALT + "," + MathModelSimulationLinkTable.table.getTableName() + " " + MMSIMALT + // ","+TFTestCriteriaTable.table.getTableName()+" "+TCRALT2+
            " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + "=" + TFTestCaseTable.table.id.getQualifiedColName() + " AND " + TFTestResultTable.table.testCriteriaRef.getQualifiedColName() + "(+)" + "=" + TFTestCriteriaTable.table.id.getQualifiedColName() + (qtcritxr_tsop.getVarName() != null ? " AND " + TFTestResultTable.table.varName.getQualifiedColName() + "(+)" + "=" + "'" + qtcritxr_tsop.getVarName() + "'" : "") + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + "=" + MathModelTable.table.id.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.simulationRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + "=" + MathModelTable.table.id.getQualifiedColName() + " AND " + MathModelSimulationLinkTable.table.simRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + MathModelTable.table.versionBranchID.getQualifiedColName() + "=" + "(" + "SELECT DISTINCT " + MathModelTable.table.versionBranchID.getQualifiedColName() + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + MathModelTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + qtcritxr_tsop.getTestCriterium() + " AND " + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + "=" + TFTestCaseTable.table.id.getQualifiedColName() + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + "=" + MathModelTable.table.id.getQualifiedColName() + ")" + " AND " + SimulationTable.table.name.getQualifiedColName() + "=" + "(" + "SELECT DISTINCT " + SimulationTable.table.name.getQualifiedColName() + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + qtcritxr_tsop.getTestCriterium() + " AND " + TFTestCriteriaTable.table.simulationRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + ")" + // reference info
            " AND " + TSALT + "." + TFTestSuiteTable.table.id.getUnqualifiedColName() + "(+)" + "=" + TCALT + "." + TFTestCaseTable.table.testSuiteRef.getUnqualifiedColName() + " AND " + TCALT + "." + TFTestCaseTable.table.mathModelRef.getUnqualifiedColName() + "(+)" + "=" + MMSIMALT + "." + MathModelSimulationLinkTable.table.mathModelRef.getUnqualifiedColName() + " AND " + TCRALT + "." + TFTestCriteriaTable.table.regressionMMSimRef.getUnqualifiedColName() + "=" + MMSIMALT + "." + MathModelSimulationLinkTable.table.id.getUnqualifiedColName() + "(+)" + " AND " + TCRALT + "." + TFTestCriteriaTable.table.id.getUnqualifiedColName() + "=" + TFTestCriteriaTable.table.id.getQualifiedColName() + // SIM2+"."+SimulationTable.table.name.getUnqualifiedColName()+"="+SimulationTable.table.name.getQualifiedColName()+
            " ORDER BY " + TSID;
            rset = stmt.executeQuery(sql);
            while (rset.next()) {
                crossRefV.add(new TestCriteriaCrossRefOPResults.CrossRefData(rset, false));
            }
            rset.close();
            return new TestCriteriaCrossRefOPResults(qtcritxr_tsop.getTestSuiteKey(), qtcritxr_tsop.getTestCriterium(), crossRefV);
        } else {
            throw new IllegalArgumentException("Unsupported OP+" + tsop);
        }
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
    Object[] changedTSKeys = changedTestSuiteKeys.toArray();
    for (int i = 0; i < changedTSKeys.length; i += 1) {
        System.out.println("TestSuite " + changedTSKeys[i].toString() + " changed");
    // testSuiteHash.remove(changedTSKeys[i]);
    }
    return new TestSuiteOPResults(null);
}
Also used : AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) LoadTestInfoOpResults(cbit.vcell.numericstest.LoadTestInfoOpResults) LoadTestSoftwareVersionTimeStamp(cbit.vcell.numericstest.LoadTestInfoOpResults.LoadTestSoftwareVersionTimeStamp) AddTestResultsOP(cbit.vcell.numericstest.AddTestResultsOP) TreeSet(java.util.TreeSet) ResultSet(java.sql.ResultSet) TestSuiteOPResults(cbit.vcell.numericstest.TestSuiteOPResults) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) Vector(java.util.Vector) TestCriteriaCrossRefOPResults(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults) RemoveTestCasesOP(cbit.vcell.numericstest.RemoveTestCasesOP) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) ModelGeometryOPResults(cbit.vcell.numericstest.ModelGeometryOPResults) RemoveTestSuiteOP(cbit.vcell.numericstest.RemoveTestSuiteOP) KeyValue(org.vcell.util.document.KeyValue) LoadTestInfoOP(cbit.vcell.numericstest.LoadTestInfoOP) AddTestCasesOP(cbit.vcell.numericstest.AddTestCasesOP) EditTestSuiteOP(cbit.vcell.numericstest.EditTestSuiteOP) RemoveTestResultsOP(cbit.vcell.numericstest.RemoveTestResultsOP) RemoveTestCriteriaOP(cbit.vcell.numericstest.RemoveTestCriteriaOP) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestSuiteOP(cbit.vcell.numericstest.AddTestSuiteOP) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) DataAccessException(org.vcell.util.DataAccessException) EditTestCriteriaOPReportStatus(cbit.vcell.numericstest.EditTestCriteriaOPReportStatus) ModelGeometryOP(cbit.vcell.numericstest.ModelGeometryOP) QueryTestCriteriaCrossRefOP(cbit.vcell.numericstest.QueryTestCriteriaCrossRefOP) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Hashtable(java.util.Hashtable) InsertHashtable(cbit.sql.InsertHashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) BigDecimal(java.math.BigDecimal) EditTestCasesOP(cbit.vcell.numericstest.EditTestCasesOP) ChangeTestCriteriaErrorLimitOP(cbit.vcell.numericstest.ChangeTestCriteriaErrorLimitOP) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

VariableComparisonSummary (cbit.vcell.solver.test.VariableComparisonSummary)6 DataAccessException (org.vcell.util.DataAccessException)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 MathModelInfo (org.vcell.util.document.MathModelInfo)3 InsertHashtable (cbit.sql.InsertHashtable)2 AddTestCasesOPBioModel (cbit.vcell.numericstest.AddTestCasesOPBioModel)2 AddTestCasesOPMathModel (cbit.vcell.numericstest.AddTestCasesOPMathModel)2 AddTestCriteriaOPBioModel (cbit.vcell.numericstest.AddTestCriteriaOPBioModel)2 AddTestCriteriaOPMathModel (cbit.vcell.numericstest.AddTestCriteriaOPMathModel)2 AddTestResultsOP (cbit.vcell.numericstest.AddTestResultsOP)2 EditTestCriteriaOPBioModel (cbit.vcell.numericstest.EditTestCriteriaOPBioModel)2 EditTestCriteriaOPMathModel (cbit.vcell.numericstest.EditTestCriteriaOPMathModel)2 EditTestCriteriaOPReportStatus (cbit.vcell.numericstest.EditTestCriteriaOPReportStatus)2 RemoveTestResultsOP (cbit.vcell.numericstest.RemoveTestResultsOP)2 TestCaseNewBioModel (cbit.vcell.numericstest.TestCaseNewBioModel)2 TestCaseNewMathModel (cbit.vcell.numericstest.TestCaseNewMathModel)2 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)2 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)2 SimulationInfo (cbit.vcell.solver.SimulationInfo)2 ODESolverResultSet (cbit.vcell.solver.ode.ODESolverResultSet)2