Search in sources :

Example 6 with TestSuiteNew

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

the class TestingFrameworkWindowManager method updateSimRunningStatus.

/**
 * Insert the method's description here.
 * Creation date: (11/16/2004 7:44:27 AM)
 */
public String updateSimRunningStatus(ClientTaskStatusSupport pp, TestSuiteInfoNew tsin) {
    if (tsin.isLocked()) {
        return null;
    }
    StringBuffer errors = new StringBuffer();
    Vector<TestCriteriaNew> runningTCrits = new Vector<TestCriteriaNew>();
    try {
        TestSuiteInfoNew[] tsinfos = getRequestManager().getDocumentManager().getTestSuiteInfos();
        if (tsinfos != null && tsinfos.length > 0) {
            for (int i = 0; i < tsinfos.length; i += 1) {
                try {
                    if (tsin != null && !tsinfos[i].getTSKey().equals(tsin.getTSKey())) {
                        continue;
                    }
                    pp.setProgress(i * 50 / tsinfos.length);
                    pp.setMessage("Update SimsRunning, Getting Testsuite " + tsinfos[i].getTSID());
                    TestSuiteNew tsn = getRequestManager().getDocumentManager().getTestSuite(tsinfos[i].getTSKey());
                    TestCaseNew[] tcnArr = tsn.getTestCases();
                    if (tcnArr != null) {
                        for (int j = 0; tcnArr != null && j < tcnArr.length; j += 1) {
                            TestCriteriaNew[] tcritArr = tcnArr[j].getTestCriterias();
                            if (tcritArr != null) {
                                for (int k = 0; tcritArr != null && k < tcritArr.length; k += 1) {
                                    if (tcritArr[k].getReportStatus() != null && tcritArr[k].getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_SIMRUNNING) || tcritArr[k].getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE)) {
                                        runningTCrits.add(tcritArr[k]);
                                    }
                                }
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    errors.append(e.getClass().getName() + " " + e.getMessage());
                }
            }
            for (int i = 0; i < runningTCrits.size(); i += 1) {
                try {
                    TestCriteriaNew tcn = (TestCriteriaNew) runningTCrits.elementAt(i);
                    SimulationInfo simInfo = tcn.getSimInfo();
                    pp.setProgress((int) (50 + (i * 50 / runningTCrits.size())));
                    pp.setMessage("Update SimsRunning, Setting Status " + simInfo.getName());
                    // Check if there is some status different from "running"
                    if (simInfo != null) {
                        SimulationStatus simStatus = getRequestManager().getServerSimulationStatus(simInfo);
                        if (simStatus != null) {
                            if (simStatus.isFailed()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMFAILED, "Sim msg=" + simStatus.getJob0SimulationMessage().getDisplayMessage());
                            } else if (simStatus.isJob0Completed()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT, null);
                            } else if (!simStatus.isRunning()) {
                                updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE, "Sim jobstatus " + simStatus.toString() + " " + simStatus.getJob0SimulationMessage().getDisplayMessage());
                            }
                        } else {
                            updateTCritStatus(tcn, TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE, "Can't get sim job status " + (simStatus == null ? "jobStatus is null" : ""));
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    errors.append(e.getClass().getName() + " " + e.getMessage());
                }
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
        errors.append(e.getClass().getName() + " " + e.getMessage());
    }
    if (errors.length() > 0) {
        errors.insert(0, "Error updating simstatus\n");
        return errors.toString();
    }
    return null;
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) SimulationStatus(cbit.vcell.server.SimulationStatus) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) Vector(java.util.Vector) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 7 with TestSuiteNew

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

the class TestingFrameworkWindowManager method generateTestSuiteReport.

/**
 * Insert the method's description here.
 * Creation date: (8/18/2003 5:36:47 PM)
 */
public String generateTestSuiteReport(TestSuiteInfoNew testSuiteInfo, ClientTaskStatusSupport pp) {
    if (testSuiteInfo == null) {
        return "Test Suite is null";
    }
    StringBuffer sb = new StringBuffer();
    try {
        // Iterate thro' testSuiteInfo to add annotation to reportTSBuffer and get all test cases
        // Get TestSuite corresponding to argument testSuiteInfo
        TestSuiteNew testSuite = getRequestManager().getDocumentManager().getTestSuite(testSuiteInfo.getTSKey());
        // Get MathmodelInfos associated with each test suite
        TestCaseNew[] testCases = null;
        testCases = testSuite.getTestCases();
        if (testCases == null) {
            return testSuiteInfo.toString() + " has not testcases";
        }
        // Iterate thro' test cases to get all simulations and get the variableSimulationSummary, add to buffer
        sb.append("\n" + testSuiteInfo.toString() + "\n");
        for (int j = 0; j < testCases.length; j++) {
            pp.setProgress(1 + (int) ((((double) j / (double) testCases.length) * 100)));
            sb.append(generateTestCaseReport(testCases[j], null, pp, null));
        }
    } catch (UserCancelException e) {
        throw e;
    } catch (Throwable e) {
        e.printStackTrace();
        sb.append("ERROR " + e.getClass().getName() + " mesg=" + e.getMessage());
    }
    return sb.toString();
}
Also used : TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) UserCancelException(org.vcell.util.UserCancelException) TestCaseNew(cbit.vcell.numericstest.TestCaseNew)

Example 8 with TestSuiteNew

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

the class TestingFrmwkTreeModel method refreshTree.

// public void refreshTree(LoadTestInfoOpResults loadTestInfoOpResults) {
// BioModelNode rootNode = getLoadTestRoot();
// //Create Load Test Info Tree
// BioModelNode loadTestInfoNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_INFO_NAME, true);
// for (int i = 0; i < loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps().length; i++) {
// LoadTestTreeInfo loadTestTreeInfo = new LoadTestTreeInfo();
// loadTestTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i];
// loadTestTreeInfo.userid = null;
// loadTestTreeInfo.bioOrMathModelKey = null;
// String progress = "";
// if(loadTestInfoOpResults.getLoadTestInfoEmptyCounts()[i] != null){
// double progPercent =
// (double)(loadTestInfoOpResults.getLoadTestInfoCounts()[i]-loadTestInfoOpResults.getLoadTestInfoEmptyCounts()[i])/
// (double)loadTestInfoOpResults.getLoadTestInfoCounts()[i];
// progress = " [working "+NumberUtils.formatNumber(progPercent*100, 3)+"%]";
// }
// loadTestTreeInfo.treeDisplayText =
// loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i].getSoftwareVersion()+
// " "+loadTestInfoOpResults.getLoadTestSoftwareVersionTimeStamps()[i].getRunTimeStamp()+
// " "+loadTestInfoOpResults.getLoadTestInfoCounts()[i]+" ("+
// loadTestInfoOpResults.getTotalBioAndMathmodelCount()+")"+
// progress;
// 
// BioModelNode infoNode =
// new BioModelNode(loadTestTreeInfo,false);
// loadTestInfoNode.add(infoNode);
// }
// for (int i = 0; i < rootNode.getChildCount(); i++) {
// BioModelNode childNode = (BioModelNode)rootNode.getChildAt(i);
// if(childNode.getUserObject().equals(TestingFrmwkTreeModel.LOAD_TEST_INFO_NAME)){
// removeNodeFromParent(childNode);
// insertNodeInto(loadTestInfoNode, rootNode, i);
// }
// }
// 
// //Create Load Test failed tree
// BioModelNode loadTestFailNode = new BioModelNode(TestingFrmwkTreeModel.LOAD_TEST_FAIL_NAME, true);
// Enumeration<LoadTestSoftwareVersionTimeStamp> failEnum = loadTestInfoOpResults.getLoadTestFailedHash().keys();
// while(failEnum.hasMoreElements()){
// LoadTestSoftwareVersionTimeStamp loadTestSoftwareVersionTimeStamp =
// failEnum.nextElement();
// Vector<LoadTestFailedDetails> faildetailsV = loadTestInfoOpResults.getLoadTestFailedHash().get(loadTestSoftwareVersionTimeStamp);
// BioModelNode loadTestSoftwareVersionTimeStampNode =
// new BioModelNode("("+faildetailsV.size()+") "+loadTestSoftwareVersionTimeStamp.getSoftwareVersion()+" "+
// loadTestSoftwareVersionTimeStamp.getRunTimeStamp(),true);
// loadTestFailNode.add(loadTestSoftwareVersionTimeStampNode);
// LoadTestFailedDetails[] sortedDetails = faildetailsV.toArray(new LoadTestFailedDetails[0]);
// Arrays.sort(sortedDetails,new Comparator<LoadTestFailedDetails>() {
// public int compare(LoadTestFailedDetails o1, LoadTestFailedDetails o2) {
// // TODO Auto-generated method stub
// return o1.errorMessage.compareToIgnoreCase(o2.errorMessage);
// }
// });
// for (int i = 0; i < sortedDetails.length; i++) {
// LoadTestTreeInfo loadTestTreeInfo = new LoadTestTreeInfo();
// loadTestTreeInfo.loadTestSoftwareVersionTimeStamp = loadTestSoftwareVersionTimeStamp;
// loadTestTreeInfo.userid = sortedDetails[i].userid;
// loadTestTreeInfo.bioOrMathModelKey = sortedDetails[i].modelKeyValue;
// loadTestTreeInfo.treeDisplayText =
// sortedDetails[i].userid+" ["+sortedDetails[i].modelType+"] '"+
// sortedDetails[i].modelName+"'     "+sortedDetails[i].errorMessage;
// 
// BioModelNode detailNode = new BioModelNode(loadTestTreeInfo, false);
// loadTestSoftwareVersionTimeStampNode.add(detailNode);
// }
// 
// 
// }
// for (int i = 0; i < rootNode.getChildCount(); i++) {
// BioModelNode childNode = (BioModelNode)rootNode.getChildAt(i);
// if(childNode.getUserObject().equals(TestingFrmwkTreeModel.LOAD_TEST_FAIL_NAME)){
// removeNodeFromParent(childNode);
// insertNodeInto(loadTestFailNode, rootNode, i);
// //			firePropertyChange(TS_NODE_REFRESH, childNode, finalNode);
// }
// }
// 
// }
/**
 * Insert the method's description here.
 * Creation date: (2/14/01 3:50:24 PM)
 */
public void refreshTree(final TestSuiteInfoNew tsin) {
    if (getDocumentManager() != null && getDocumentManager().getUser() != null) {
        if (getDocumentManager().getUser().isTestAccount()) {
            AsynchClientTask GetTestSuites = new AsynchClientTask("Refresh Testing FrameWork Display", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    TestSuiteGroup tsg = new TestSuiteGroup();
                    boolean bRemove = false;
                    try {
                        TestSuiteInfoNew[] latestTestSuiteInfos = null;
                        TestSuiteNew latestTestSuite = null;
                        boolean hadUpdateTSError = false;
                        if (getDocumentManager() != null) {
                            TestSuiteInfoNew[] testSuiteInfos = null;
                            getClientTaskStatusSupport().setMessage("Getting TestsuiteInfos");
                            try {
                                testSuiteInfos = getDocumentManager().getTestSuiteInfos();
                            } catch (Throwable e) {
                                e.printStackTrace();
                                hadUpdateTSError = true;
                            }
                            if (testSuiteInfos != null) {
                                latestTestSuiteInfos = testSuiteInfos;
                                if (tsin != null) {
                                    try {
                                        getClientTaskStatusSupport().setProgress(50);
                                        if (tsin.getTSKey() != null) {
                                            // from Refesh or remove TestSuite
                                            bRemove = true;
                                            for (int i = 0; i < testSuiteInfos.length; i++) {
                                                if (testSuiteInfos[i].getTSKey().equals(tsin.getTSKey())) {
                                                    bRemove = false;
                                                    break;
                                                }
                                            }
                                            if (!bRemove) {
                                                getClientTaskStatusSupport().setMessage("Getting Testsuite " + tsin.getTSID());
                                                latestTestSuite = getDocumentManager().getTestSuite(tsin.getTSKey());
                                            } else {
                                                getClientTaskStatusSupport().setMessage("Remove Testsuite " + tsin.getTSID());
                                                latestTestSuiteInfos = new TestSuiteInfoNew[] { tsin };
                                            }
                                        } else {
                                            // from Duplicate TestSuite
                                            for (int i = 0; i < testSuiteInfos.length; i++) {
                                                if (testSuiteInfos[i].getTSID().equals(tsin.getTSID())) {
                                                    latestTestSuite = getDocumentManager().getTestSuite(testSuiteInfos[i].getTSKey());
                                                    break;
                                                }
                                            }
                                        }
                                    } catch (DataAccessException e) {
                                        tsg = new TestSuiteGroup();
                                        throw e;
                                    }
                                }
                            }
                        }
                        tsg.latestTestSuiteInfos = latestTestSuiteInfos;
                        tsg.latestTestSuite = latestTestSuite;
                        tsg.hadUpdateTSError = hadUpdateTSError;
                    } finally {
                        if (tsg.latestTestSuiteInfos != null) {
                            getClientTaskStatusSupport().setProgress(tsg.latestTestSuiteInfos.length * 100 / (tsg.latestTestSuiteInfos.length + 1));
                        }
                        hashTable.put("tsg", tsg);
                        hashTable.put("bRemove", bRemove);
                    }
                }
            };
            AsynchClientTask updateTreeTask = new AsynchClientTask("Refresh Testing FrameWork Display", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                @Override
                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    TestSuiteGroup tsg = (TestSuiteGroup) hashTable.get("tsg");
                    boolean bRemove = (Boolean) hashTable.get("bRemove");
                    updateTree(tsg, bRemove);
                }
            };
            ClientTaskDispatcher.dispatch(treeOwner.getParent(), new Hashtable<String, Object>(), new AsynchClientTask[] { GetTestSuites, updateTreeTask }, false);
        } else {
            setRoot(new BioModelNode(getDocumentManager().getUser().getName() + " Not TestAccount User"));
        }
    } else {
        setRoot(new BioModelNode("empty"));
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) Hashtable(java.util.Hashtable) BioModelNode(cbit.vcell.desktop.BioModelNode) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) DataAccessException(org.vcell.util.DataAccessException)

Example 9 with TestSuiteNew

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

the class DbDriver method testSuiteGet.

/**
 * Insert the method's description here.
 * Creation date: (10/16/2004 2:39:49 PM)
 * @return cbit.vcell.numericstest.TestSuiteInfoNew[]
 */
public static TestSuiteNew testSuiteGet(BigDecimal getThisTS, Connection con, User user, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    if (!user.isTestAccount()) {
        throw new PermissionException("User=" + user.getName() + " not allowed TestSuiteInfo");
    }
    // if(testSuiteHash.containsKey(getThisTS)){
    // return (cbit.vcell.numericstest.TestSuiteNew)testSuiteHash.get(getThisTS);
    // }
    Hashtable simulationInfoH = new Hashtable();
    Hashtable mathModelInfoH = new Hashtable();
    Hashtable bioModelInfoH = new Hashtable();
    Statement stmt = null;
    ResultSet rset = null;
    String sql = null;
    Level origLogLevel = DatabasePolicySQL.lg.getLevel();
    try {
        DatabasePolicySQL.lg.setLevel(Level.WARN);
        // double begTime=System.currentTimeMillis();
        // int counter = 0;
        stmt = con.createStatement();
        // Get VariableComparisonSummaries
        Hashtable vcsH = new Hashtable();
        {
            sql = "SELECT " + TFTestResultTable.table.getTableName() + ".*" + " FROM " + TFTestResultTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + TFTestResultTable.table.testCriteriaRef.getQualifiedColName() + " ORDER BY UPPER(" + TFTestResultTable.table.varName.getQualifiedColName() + ")";
            rset = stmt.executeQuery(sql);
            while (rset.next()) {
                BigDecimal tcritRef = rset.getBigDecimal(TFTestResultTable.table.testCriteriaRef.getUnqualifiedColName());
                String varName = rset.getString(TFTestResultTable.table.varName.getUnqualifiedColName());
                double absError = rset.getDouble(TFTestResultTable.table.absError.getUnqualifiedColName());
                double relError = rset.getDouble(TFTestResultTable.table.relError.getUnqualifiedColName());
                double maxRef = rset.getDouble(TFTestResultTable.table.maxRef.getUnqualifiedColName());
                double minRef = rset.getDouble(TFTestResultTable.table.minRef.getUnqualifiedColName());
                double mse = rset.getDouble(TFTestResultTable.table.meanSqrError.getUnqualifiedColName());
                double timeAbsError = rset.getDouble(TFTestResultTable.table.timeAbsError.getUnqualifiedColName());
                int indexAbsError = rset.getInt(TFTestResultTable.table.indexAbsError.getUnqualifiedColName());
                double timeRelError = rset.getDouble(TFTestResultTable.table.timeRelError.getUnqualifiedColName());
                int indexRelError = rset.getInt(TFTestResultTable.table.indexRelError.getUnqualifiedColName());
                Vector v = (Vector) vcsH.get(tcritRef);
                if (v == null) {
                    v = new Vector();
                    vcsH.put(tcritRef, v);
                }
                v.add(new VariableComparisonSummary(varName, minRef, maxRef, absError, relError, mse, timeAbsError, indexAbsError, timeRelError, indexRelError));
            // counter+= 1;
            }
            // System.out.println("VCS count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
            rset.close();
        }
        // begTime=System.currentTimeMillis();
        // counter = 0;
        // Get TestCriteria for mathModel based TestCases
        Hashtable tcritH = new Hashtable();
        {
            sql = "SELECT " + TFTestCriteriaTable.table.getTableName() + ".*" + "," + MathModelSimulationLinkTable.table.getTableName() + ".*" + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + MathModelSimulationLinkTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " IS NOT NULL " + " AND " + TFTestCriteriaTable.table.simulationRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.regressionMMSimRef.getQualifiedColName() + "=" + MathModelSimulationLinkTable.table.id.getQualifiedColName() + "(+)" + " ORDER BY UPPER(" + SimulationTable.table.name.getQualifiedColName() + ")";
            // System.out.println(sql);
            rset = stmt.executeQuery(sql);
            while (rset.next()) {
                BigDecimal tcritKey = rset.getBigDecimal(TFTestCriteriaTable.table.id.getUnqualifiedColName());
                BigDecimal tcaseRef = rset.getBigDecimal(TFTestCriteriaTable.table.testCaseRef.getUnqualifiedColName());
                BigDecimal simRef = rset.getBigDecimal(TFTestCriteriaTable.table.simulationRef.getUnqualifiedColName());
                BigDecimal simRegrRef = rset.getBigDecimal(MathModelSimulationLinkTable.table.simRef.getUnqualifiedColName());
                if (rset.wasNull()) {
                    simRegrRef = null;
                }
                BigDecimal mathRegrRef = rset.getBigDecimal(MathModelSimulationLinkTable.table.mathModelRef.getUnqualifiedColName());
                if (rset.wasNull()) {
                    mathRegrRef = null;
                }
                Double maxRelError = null;
                double dtemp = rset.getDouble(TFTestCriteriaTable.table.maxRelError.getUnqualifiedColName());
                if (rset.wasNull()) {
                    maxRelError = null;
                } else {
                    maxRelError = new Double(dtemp);
                }
                Double maxAbsError = null;
                dtemp = rset.getDouble(TFTestCriteriaTable.table.maxAbsError.getUnqualifiedColName());
                if (rset.wasNull()) {
                    maxAbsError = null;
                } else {
                    maxAbsError = new Double(dtemp);
                }
                String reportStatus = rset.getString(TFTestCriteriaTable.table.reportStatus.getUnqualifiedColName());
                if (rset.wasNull()) {
                    reportStatus = TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT;
                }
                String reportStatusMessage = rset.getString(TFTestCriteriaTable.table.reportMessage.getUnqualifiedColName());
                if (rset.wasNull()) {
                    reportStatusMessage = null;
                }
                if (reportStatusMessage != null && reportStatusMessage.length() > 0) {
                    reportStatusMessage = TokenMangler.getSQLRestoredString(reportStatusMessage);
                }
                Vector v = (Vector) tcritH.get(tcaseRef);
                if (v == null) {
                    v = new Vector();
                    tcritH.put(tcaseRef, v);
                }
                SimulationInfo simInfo = (SimulationInfo) simulationInfoH.get(simRef);
                if (simInfo == null) {
                    Vector<VersionInfo> simVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(simRef), false, dbSyntax);
                    if (simVector != null && simVector.size() > 0) {
                        simInfo = (SimulationInfo) simVector.firstElement();
                        simulationInfoH.put(simRef, simInfo);
                    }
                }
                SimulationInfo regrSimInfo = null;
                MathModelInfo regrMathModelInfo = null;
                if (simRegrRef != null) {
                    regrSimInfo = (SimulationInfo) simulationInfoH.get(simRegrRef);
                    if (regrSimInfo == null) {
                        Vector<VersionInfo> regSimVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(simRegrRef), false, dbSyntax);
                        if (regSimVector != null && regSimVector.size() > 0) {
                            regrSimInfo = (SimulationInfo) regSimVector.firstElement();
                            simulationInfoH.put(simRegrRef, regrSimInfo);
                        }
                    }
                    regrMathModelInfo = (MathModelInfo) mathModelInfoH.get(mathRegrRef);
                    if (regrMathModelInfo == null) {
                        Vector<VersionInfo> regMathVector = getVersionableInfos(con, user, VersionableType.MathModelMetaData, false, new KeyValue(mathRegrRef), false, dbSyntax);
                        if (regMathVector != null && regMathVector.size() > 0) {
                            regrMathModelInfo = (MathModelInfo) regMathVector.firstElement();
                            mathModelInfoH.put(mathRegrRef, regrMathModelInfo);
                        }
                    }
                }
                // 
                VariableComparisonSummary[] neededVCSArr = null;
                Vector vcsV = (Vector) vcsH.get(tcritKey);
                if (vcsV != null) {
                    neededVCSArr = new VariableComparisonSummary[vcsV.size()];
                    vcsV.copyInto(neededVCSArr);
                }
                // 
                TestCriteriaNew tcn = null;
                if (simInfo != null) {
                    tcn = new TestCriteriaNewMathModel(tcritKey, simInfo, regrMathModelInfo, regrSimInfo, maxRelError, maxAbsError, neededVCSArr, reportStatus, reportStatusMessage);
                    v.add(tcn);
                }
            // counter+= 1;
            }
            // System.out.println("TCrit count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
            rset.close();
        }
        // Get TestCriteria for bioModel based TestCases
        // Hashtable tcritH = new Hashtable();
        {
            final String REGRSIMREF = "REGRSIMREF";
            final String SCNAME = "SCNAME";
            sql = "SELECT " + TFTestCriteriaTable.table.getTableName() + ".*" + "," + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "," + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + " " + REGRSIMREF + "," + SimContextTable.table.name.getQualifiedColName() + " " + SCNAME + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + BioModelSimulationLinkTable.table.getTableName() + // SimulationTable.table.getTableName()+
            " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " IS NOT NULL " + " AND " + TFTestCriteriaTable.table.regressionBMAPPRef.getQualifiedColName() + "=" + BioModelSimContextLinkTable.table.id.getQualifiedColName() + "(+)" + " AND " + BioModelSimContextLinkTable.table.simContextRef + " = " + SimContextTable.table.id.getQualifiedColName() + "(+)" + // SimContextTable.table.mathRef.getQualifiedColName()+" = "+SimulationTable.table.mathRef.getQualifiedColName()+"(+)" +
            " AND " + TFTestCriteriaTable.table.regressionBMSimRef.getQualifiedColName() + " = " + BioModelSimulationLinkTable.table.id.getQualifiedColName() + "(+)";
            // System.out.println(sql);
            rset = stmt.executeQuery(sql);
            while (rset.next()) {
                BigDecimal tcritKey = rset.getBigDecimal(TFTestCriteriaTable.table.id.getUnqualifiedColName());
                BigDecimal tcaseRef = rset.getBigDecimal(TFTestCriteriaTable.table.testCaseRef.getUnqualifiedColName());
                BigDecimal tcSimRef = rset.getBigDecimal(TFTestCriteriaTable.table.simulationRef.getUnqualifiedColName());
                BigDecimal regrSimRef = rset.getBigDecimal(REGRSIMREF);
                // BigDecimal regrSimRef = rset.getBigDecimal(SimulationTable.table.id.getUnqualifiedColName());
                if (rset.wasNull()) {
                    regrSimRef = null;
                }
                BigDecimal regrBioModelRef = rset.getBigDecimal(BioModelSimContextLinkTable.table.bioModelRef.getUnqualifiedColName());
                if (rset.wasNull()) {
                    regrBioModelRef = null;
                }
                String regrSCName = rset.getString(SCNAME);
                if (rset.wasNull()) {
                    regrSCName = null;
                }
                Double maxRelError = null;
                double dtemp = rset.getDouble(TFTestCriteriaTable.table.maxRelError.getUnqualifiedColName());
                if (rset.wasNull()) {
                    maxRelError = null;
                } else {
                    maxRelError = new Double(dtemp);
                }
                Double maxAbsError = null;
                dtemp = rset.getDouble(TFTestCriteriaTable.table.maxAbsError.getUnqualifiedColName());
                if (rset.wasNull()) {
                    maxAbsError = null;
                } else {
                    maxAbsError = new Double(dtemp);
                }
                String reportStatus = rset.getString(TFTestCriteriaTable.table.reportStatus.getUnqualifiedColName());
                if (rset.wasNull()) {
                    reportStatus = TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT;
                }
                String reportStatusMessage = rset.getString(TFTestCriteriaTable.table.reportMessage.getUnqualifiedColName());
                if (rset.wasNull()) {
                    reportStatusMessage = null;
                }
                if (reportStatusMessage != null && reportStatusMessage.length() > 0) {
                    reportStatusMessage = TokenMangler.getSQLRestoredString(reportStatusMessage);
                }
                Vector v = (Vector) tcritH.get(tcaseRef);
                if (v == null) {
                    v = new Vector();
                    tcritH.put(tcaseRef, v);
                }
                SimulationInfo simInfo = (SimulationInfo) simulationInfoH.get(tcSimRef);
                if (simInfo == null) {
                    Vector<VersionInfo> simVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(tcSimRef), false, dbSyntax);
                    if (simVector != null && simVector.size() == 1) {
                        simInfo = (SimulationInfo) simVector.firstElement();
                        simulationInfoH.put(tcSimRef, simInfo);
                    } else {
                        throw new DataAccessException("Found more than 1 versionable for tcsimRef=" + tcSimRef);
                    }
                }
                SimulationInfo regrSimInfo = null;
                BioModelInfo regrBioModelInfo = null;
                if (regrSimRef != null) {
                    regrSimInfo = (SimulationInfo) simulationInfoH.get(regrSimRef);
                    if (regrSimInfo == null) {
                        Vector<VersionInfo> regSimVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(regrSimRef), false, dbSyntax);
                        if (regSimVector != null && regSimVector.size() == 1) {
                            regrSimInfo = (SimulationInfo) regSimVector.firstElement();
                            simulationInfoH.put(regrSimRef, regrSimInfo);
                        } else {
                            throw new DataAccessException("Found more than 1 versionable for simregRef=" + regrSimRef);
                        }
                    }
                    regrBioModelInfo = (BioModelInfo) mathModelInfoH.get(regrBioModelRef);
                    if (regrBioModelInfo == null) {
                        Vector<VersionInfo> regBioModelVector = getVersionableInfos(con, user, VersionableType.BioModelMetaData, false, new KeyValue(regrBioModelRef), false, dbSyntax);
                        if (regBioModelVector != null && regBioModelVector.size() == 1) {
                            regrBioModelInfo = (BioModelInfo) regBioModelVector.firstElement();
                            mathModelInfoH.put(regrBioModelRef, regrBioModelInfo);
                        } else {
                            throw new DataAccessException("Found more than 1 versionable for reegrbiomodelRef=" + regrBioModelRef);
                        }
                    }
                }
                // 
                VariableComparisonSummary[] neededVCSArr = null;
                Vector vcsV = (Vector) vcsH.get(tcritKey);
                if (vcsV != null) {
                    neededVCSArr = new VariableComparisonSummary[vcsV.size()];
                    vcsV.copyInto(neededVCSArr);
                }
                // 
                TestCriteriaNew tcn = null;
                if (simInfo != null) {
                    tcn = new TestCriteriaNewBioModel(tcritKey, simInfo, regrBioModelInfo, regrSCName, regrSimInfo, maxRelError, maxAbsError, neededVCSArr, reportStatus, reportStatusMessage);
                    v.add(tcn);
                }
            // counter+= 1;
            }
            // System.out.println("TCrit count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
            rset.close();
        }
        // Get TestCases
        Vector tcV = new Vector();
        // begTime=System.currentTimeMillis();
        // counter = 0;
        {
            // final String BMSCL = "bmscl";
            final String OBTCTYPECOLUMN = "OBTCTYPECOLUMN";
            final String OBNAMECOLUMN = "OBNAMECOLUMN";
            final String BMSCBMRNAME = "BMSCBMRNAME";
            final String BMSCSCRNAME = "BMSCSCRNAME";
            final String SCNAME = "SCNAME";
            final String SORTHELP1 = "SORTHELP1";
            final String SORTHELP2 = "SORTHELP2";
            sql = "SELECT " + "UPPER(" + MathModelTable.table.name.getQualifiedColName() + ") " + SORTHELP1 + "," + "TO_CHAR(NULL) " + SORTHELP2 + "," + TFTestCaseTable.table.getTableName() + ".*" + "," + "TO_NUMBER(NULL) " + BMSCBMRNAME + "," + "TO_NUMBER(NULL) " + BMSCSCRNAME + "," + "TO_CHAR(NULL) " + SCNAME + "," + "'MM' " + OBTCTYPECOLUMN + "," + MathModelTable.table.name.getQualifiedColName() + " " + OBNAMECOLUMN + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + MathModelTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " IS NOT NULL" + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " = " + MathModelTable.table.id.getQualifiedColName() + " UNION " + "SELECT " + "UPPER(" + BioModelTable.table.name.getQualifiedColName() + ") " + SORTHELP1 + ",UPPER(" + SimContextTable.table.name.getQualifiedColName() + ") " + SORTHELP2 + "," + TFTestCaseTable.table.getTableName() + ".*" + "," + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + " " + BMSCBMRNAME + "," + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " " + BMSCSCRNAME + "," + SimContextTable.table.name.getQualifiedColName() + " " + SCNAME + "," + "'BM' " + OBTCTYPECOLUMN + "," + BioModelTable.table.name.getQualifiedColName() + " " + OBNAMECOLUMN + " FROM " + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + BioModelTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " IS NOT NULL" + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " = " + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " = " + SimContextTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + BioModelTable.table.id.getQualifiedColName() + // " ORDER BY 11,"+"UPPER(12)"+","+"UPPER(10)";
            " ORDER BY 13,1,2";
            rset = stmt.executeQuery(sql);
            while (rset.next()) {
                BigDecimal tcaseKey = rset.getBigDecimal(TFTestCaseTable.table.id.getUnqualifiedColName());
                BigDecimal mmRef = rset.getBigDecimal(TFTestCaseTable.table.mathModelRef.getUnqualifiedColName());
                if (rset.wasNull()) {
                    mmRef = null;
                }
                BigDecimal simContextRef = rset.getBigDecimal(BMSCSCRNAME);
                if (rset.wasNull()) {
                    simContextRef = null;
                }
                BigDecimal bioModelRef = rset.getBigDecimal(BMSCBMRNAME);
                if (rset.wasNull()) {
                    bioModelRef = null;
                }
                String simContextName = rset.getString(SCNAME);
                if (rset.wasNull()) {
                    simContextName = null;
                }
                String tcType = rset.getString(TFTestCaseTable.table.tcSolutionType.getUnqualifiedColName());
                String tcAnnot = rset.getString(TFTestCaseTable.table.tcAnnotation.getUnqualifiedColName());
                if (rset.wasNull()) {
                    tcAnnot = "";
                } else {
                    tcAnnot = TokenMangler.getSQLRestoredString(tcAnnot);
                }
                java.util.Date tcDate = VersionTable.getDate(rset, TFTestCaseTable.table.creationDate.getUnqualifiedColName());
                MathModelInfo mmInfo = null;
                BioModelInfo bmInfo = null;
                if (mmRef != null) {
                    mmInfo = (MathModelInfo) mathModelInfoH.get(mmRef);
                    if (mmInfo == null) {
                        Vector<VersionInfo> mathVector = getVersionableInfos(con, user, VersionableType.MathModelMetaData, false, new KeyValue(mmRef), false, dbSyntax);
                        if (mathVector != null && mathVector.size() > 0) {
                            mmInfo = (MathModelInfo) mathVector.firstElement();
                            mathModelInfoH.put(mmRef, mmInfo);
                        }
                    }
                } else if (bioModelRef != null) {
                    bmInfo = (BioModelInfo) bioModelInfoH.get(bioModelRef);
                    if (bmInfo == null) {
                        Vector<VersionInfo> bmAppVector = getVersionableInfos(con, user, VersionableType.BioModelMetaData, false, new KeyValue(bioModelRef), false, dbSyntax);
                        if (bmAppVector != null && bmAppVector.size() > 0) {
                            bmInfo = (BioModelInfo) bmAppVector.firstElement();
                            bioModelInfoH.put(bioModelRef, bmInfo);
                        }
                    }
                } else {
                    throw new RuntimeException("Test case in DB does not have MathmodelRef or BioModelAppRef");
                }
                TestCriteriaNew[] neededTcritArr = null;
                Vector needTcritV = (Vector) tcritH.get(tcaseKey);
                if (needTcritV != null) {
                    neededTcritArr = new TestCriteriaNew[needTcritV.size()];
                    needTcritV.copyInto(neededTcritArr);
                }
                TestCaseNew tcn = null;
                if (mmInfo != null) {
                    tcn = new TestCaseNewMathModel(tcaseKey, mmInfo, tcType, tcAnnot, neededTcritArr);
                    tcV.add(tcn);
                } else if (bmInfo != null) {
                    tcn = new TestCaseNewBioModel(tcaseKey, bmInfo, simContextName, new KeyValue(simContextRef), tcType, tcAnnot, neededTcritArr);
                    tcV.add(tcn);
                } else {
                // throw new RuntimeException("Expected testCase MathModelInfo or BioModelInfo to be not null");
                }
            // counter+= 1;
            }
            // System.out.println("TCase count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
            rset.close();
        }
        // Get TestSuite
        {
            TestCaseNew[] tcnArr = null;
            if (tcV.size() > 0) {
                tcnArr = new TestCaseNew[tcV.size()];
                tcV.copyInto(tcnArr);
            }
            sql = "SELECT " + TFTestSuiteTable.table.getTableName() + ".*" + " FROM " + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " ORDER BY UPPER(" + TFTestSuiteTable.table.tsVersion.getQualifiedColName() + ")";
            rset = stmt.executeQuery(sql);
            BigDecimal tsKey = null;
            String tsVersion = null;
            String tsVCBuild = null;
            String tsNumericsBuild = null;
            java.util.Date tsDate = null;
            String tsAnnot = null;
            boolean islocked = true;
            if (rset.next()) {
                tsKey = rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName());
                tsVersion = rset.getString(TFTestSuiteTable.table.tsVersion.getUnqualifiedColName());
                tsVCBuild = rset.getString(TFTestSuiteTable.table.vcBuildVersion.getUnqualifiedColName());
                tsNumericsBuild = rset.getString(TFTestSuiteTable.table.vcNumericsVersion.getUnqualifiedColName());
                tsDate = VersionTable.getDate(rset, TFTestSuiteTable.table.creationDate.getUnqualifiedColName());
                tsAnnot = rset.getString(TFTestSuiteTable.table.tsAnnotation.getUnqualifiedColName());
                islocked = rset.getBoolean(TFTestSuiteTable.table.isLocked.getUnqualifiedColName());
            } else {
                throw new ObjectNotFoundException("TestSuite with key=" + getThisTS + " not found");
            }
            rset.close();
            TestSuiteInfoNew tsiNew = new TestSuiteInfoNew(tsKey, tsVersion, tsVCBuild, tsNumericsBuild, tsDate, tsAnnot, islocked);
            TestSuiteNew tsn = new TestSuiteNew(tsiNew, tcnArr);
            // testSuiteHash.put(tsKey,tsn);
            return tsn;
        }
    } catch (SQLException e) {
        lg.error("failed: (" + sql + "): " + e.getMessage(), e);
        throw e;
    } finally {
        DatabasePolicySQL.lg.setLevel(origLogLevel);
        if (stmt != null) {
            stmt.close();
        }
    }
}
Also used : PermissionException(org.vcell.util.PermissionException) KeyValue(org.vcell.util.document.KeyValue) SQLException(java.sql.SQLException) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) ResultSet(java.sql.ResultSet) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException) TestSuiteNew(cbit.vcell.numericstest.TestSuiteNew) Hashtable(java.util.Hashtable) InsertHashtable(cbit.sql.InsertHashtable) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) BigDecimal(java.math.BigDecimal) VersionInfo(org.vcell.util.document.VersionInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) Level(org.apache.log4j.Level) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Aggregations

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