Search in sources :

Example 1 with TestCriteriaCrossRefOPResults

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

the class TestingFrameworkWindowManager method queryTCritCrossRef.

@SuppressWarnings("serial")
public void queryTCritCrossRef(final TestSuiteInfoNew tsin, final TestCriteriaNew tcrit, final String varName) {
    try {
        QueryTestCriteriaCrossRefOP queryTestCriteriaCrossRefOP = new QueryTestCriteriaCrossRefOP(tsin.getTSKey(), tcrit.getTCritKey(), varName);
        TestCriteriaCrossRefOPResults testCriteriaCrossRefOPResults = (TestCriteriaCrossRefOPResults) getRequestManager().getDocumentManager().doTestSuiteOP(queryTestCriteriaCrossRefOP);
        final Vector<TestCriteriaCrossRefOPResults.CrossRefData> xrefDataV = testCriteriaCrossRefOPResults.getCrossRefData();
        final TestSuiteInfoNew[] testSuiteInfos = getRequestManager().getDocumentManager().getTestSuiteInfos();
        Vector<TestSuiteInfoNew> missingTestSuites = new Vector<TestSuiteInfoNew>();
        for (int i = 0; i < testSuiteInfos.length; i++) {
            boolean bFound = false;
            for (int j = 0; j < xrefDataV.size(); j++) {
                if (xrefDataV.elementAt(j).tsVersion.equals(testSuiteInfos[i].getTSID())) {
                    bFound = true;
                    break;
                }
            }
            if (!bFound) {
                missingTestSuites.add(testSuiteInfos[i]);
            }
        }
        TestCriteriaCrossRefOPResults.CrossRefData xrefDataSource = null;
        for (int i = 0; i < xrefDataV.size(); i++) {
            if (xrefDataV.elementAt(i).tcritKey.equals(tcrit.getTCritKey())) {
                xrefDataSource = xrefDataV.elementAt(i);
                break;
            }
        }
        if (xrefDataSource == null) {
            throw new RuntimeException("Couldn't find source Test Criteria in query results.");
        }
        final int numColumns = 8;
        final int XREFDATA_ALLOWANCE = 1;
        final int TSKEY_ALLOWANCE = 1;
        final int XREFDATA_OFFSET = numColumns;
        final int TSDATE_OFFSET = 1;
        final int VARNAME_OFFSET = 3;
        final int TSKEYMISSING_OFFSET = numColumns + 1;
        final String[] colNames = new String[numColumns];
        final Object[][] sourceRows = new Object[xrefDataV.size() + missingTestSuites.size()][numColumns + XREFDATA_ALLOWANCE + TSKEY_ALLOWANCE];
        String sourceTestSuite = null;
        colNames[0] = "tsVersion";
        colNames[1] = "tsDate";
        colNames[2] = "tsBaseVersion";
        colNames[3] = "varName";
        colNames[4] = "RelErorr";
        colNames[5] = "limitRelErorr";
        colNames[6] = "limitAbsErorr";
        colNames[7] = "AbsErorr";
        for (int i = 0; i < xrefDataV.size(); i++) {
            sourceRows[i][colNames.length] = xrefDataV.elementAt(i);
            if (xrefDataV.elementAt(i).tcritKey.equals(queryTestCriteriaCrossRefOP.getTestCriterium())) {
                sourceTestSuite = xrefDataV.elementAt(i).tsVersion;
            }
            sourceRows[i][0] = xrefDataV.elementAt(i).tsVersion;
            sourceRows[i][2] = (xrefDataV.elementAt(i).tsRefVersion == null ? (xrefDataV.elementAt(i).regressionModelID == null ? /* && xrefDataV.elementAt(i).regressionMMref==null*/
            "" : "Ref Model exist BUT outside of TestSuites") : xrefDataV.elementAt(i).tsRefVersion);
            sourceRows[i][6] = xrefDataV.elementAt(i).maxAbsErorr;
            sourceRows[i][5] = xrefDataV.elementAt(i).maxRelErorr;
            if (xrefDataV.elementAt(i).varName != null) {
                sourceRows[i][VARNAME_OFFSET] = xrefDataV.elementAt(i).varName;
                sourceRows[i][4] = xrefDataV.elementAt(i).varCompSummary.getRelativeError();
                sourceRows[i][7] = xrefDataV.elementAt(i).varCompSummary.getAbsoluteError();
            } else {
                sourceRows[i][VARNAME_OFFSET] = "-No Report-";
                // "No Report";
                sourceRows[i][4] = null;
                // "No Report";
                sourceRows[i][7] = null;
            }
            for (int j = 0; j < testSuiteInfos.length; j++) {
                if (xrefDataV.elementAt(i).tsVersion.equals(testSuiteInfos[j].getTSID())) {
                    sourceRows[i][1] = testSuiteInfos[j].getTSDate();
                    break;
                }
            }
        }
        for (int i = xrefDataV.size(); i < sourceRows.length; i++) {
            sourceRows[i][0] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSID();
            sourceRows[i][TSDATE_OFFSET] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSDate();
            sourceRows[i][TSKEYMISSING_OFFSET] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSKey();
        }
        // Arrays.sort(rows,
        // new Comparator<Object[]>(){
        // public int compare(Object[] o1, Object[] o2) {
        // return ((String)o1[0]).compareToIgnoreCase((String)o2[0]);
        // //						if(o1[0].equals(o2[0])){
        // //							return o1[3].compareToIgnoreCase(o2[3]);
        // //						}
        // //						return o1[0].compareToIgnoreCase(o2[0]);
        // }
        // }
        // );
        final VCellSortTableModel<Object[]> tableModel = new VCellSortTableModel<Object[]>(colNames) {

            public Class<?> getColumnClass(int columnIndex) {
                if (columnIndex == TSDATE_OFFSET) {
                    return Date.class;
                } else if (columnIndex >= 4 && columnIndex <= 7) {
                    return Double.class;
                }
                return String.class;
            }

            public boolean isCellEditable(int row, int column) {
                return false;
            }

            public Object getValueAt(int rowIndex, int columnIndex) {
                return getValueAt(rowIndex)[columnIndex];
            }

            public Comparator<Object[]> getComparator(final int col, final boolean ascending) {
                return new Comparator<Object[]>() {

                    public int compare(Object[] o1, Object[] o2) {
                        if (o1[col] == null && o2[col] == null) {
                            return 0;
                        }
                        // if(ascending){
                        if (o1[col] == null) {
                            return 1;
                        }
                        if (o2[col] == null) {
                            return -1;
                        }
                        // }
                        if (getColumnClass(col).equals(String.class)) {
                            if (ascending) {
                                return ((String) o1[col]).compareToIgnoreCase(((String) o2[col]));
                            } else {
                                return ((String) o2[col]).compareToIgnoreCase(((String) o1[col]));
                            }
                        } else if (getColumnClass(col).equals(Date.class)) {
                            if (ascending) {
                                return ((Date) o1[col]).compareTo(((Date) o2[col]));
                            }
                            return ((Date) o2[col]).compareTo(((Date) o1[col]));
                        } else if (getColumnClass(col).equals(Double.class)) {
                            if (ascending) {
                                return ((Double) o1[col]).compareTo(((Double) o2[col]));
                            }
                            return ((Double) o2[col]).compareTo(((Double) o1[col]));
                        }
                        throw new RuntimeException("TestSuite XRef Query unexpecte column class " + getColumnClass(col).getName());
                    }
                };
            }
        };
        tableModel.setData(Arrays.asList(sourceRows));
        // Create table
        final JSortTable table = new JSortTable();
        table.setModel(tableModel);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        final JScrollPane scrollPaneContentPane = new JScrollPane(table);
        table.setPreferredScrollableViewportSize(new Dimension(500, 250));
        table.getColumnModel().getColumn(TSDATE_OFFSET).setCellRenderer(new DefaultTableCellRenderer() {

            // DateFormat formatter = DateFormat.getDateTimeInstance();
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                return super.getTableCellRendererComponent(table, (value == null ? null : ((Date) value).toString()), /*formatter.format((Date)value)*/
                isSelected, hasFocus, row, column);
            }
        });
        DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() {

            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                return super.getTableCellRendererComponent(table, (value == null ? null : ((Double) value).toString()), /*formatter.format((Date)value)*/
                isSelected, hasFocus, row, column);
            }
        };
        table.getColumnModel().getColumn(4).setCellRenderer(dtcr);
        table.getColumnModel().getColumn(5).setCellRenderer(dtcr);
        table.getColumnModel().getColumn(6).setCellRenderer(dtcr);
        table.getColumnModel().getColumn(7).setCellRenderer(dtcr);
        // table.getColumnModel().getColumn(4).setCellRenderer(
        // new DefaultTableCellRenderer(){
        // public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        // return super.getTableCellRendererComponent(table,(value == null?null:((Double)value).toString())/*formatter.format((Date)value)*/, isSelected, hasFocus, row, column);
        // }
        // }
        // );
        // table.getTableHeader().setReorderingAllowed(false);
        // Popup Menu
        final TestCriteriaCrossRefOPResults.CrossRefData xrefDataSourceFinal = xrefDataSource;
        final JPopupMenu queryPopupMenu = new JPopupMenu();
        final JMenuItem changeLimitsMenuItem = new JMenuItem("Change Selected Error Limits...");
        final String OPEN_MODEL = "Open Model(s)";
        final JMenuItem openModelMenuItem = new JMenuItem(OPEN_MODEL);
        final String OPEN_REGRREFMODEL = "Open Regr Ref Model(s)";
        final JMenuItem openRegrRefModelMenuItem = new JMenuItem(OPEN_REGRREFMODEL);
        final String SELECT_REF_IN_TREE = "Select in Tree View";
        final JMenuItem showInTreeMenuItem = new JMenuItem(SELECT_REF_IN_TREE);
        final String SELECT_REGR_REF_IN_TREE = "Select RegrRef TCase in Tree View";
        final JMenuItem showRegrRefInTreeMenuItem = new JMenuItem(SELECT_REGR_REF_IN_TREE);
        queryPopupMenu.add(changeLimitsMenuItem);
        queryPopupMenu.add(openModelMenuItem);
        queryPopupMenu.add(openRegrRefModelMenuItem);
        queryPopupMenu.add(showInTreeMenuItem);
        queryPopupMenu.add(showRegrRefInTreeMenuItem);
        ActionListener showInTreeActionListener = new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows == null || selectedRows.length != 1) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Action " + actionEvent.getActionCommand() + " accepts only single selection!");
                    return;
                }
                TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[0], XREFDATA_OFFSET);
                BigDecimal missingTSKey = (BigDecimal) tableModel.getValueAt(selectedRows[0], TSKEYMISSING_OFFSET);
                if (actionEvent.getActionCommand().equals(SELECT_REF_IN_TREE)) {
                    getTestingFrameworkWindowPanel().selectInTreeView((xrefData != null ? xrefData.tsKey : missingTSKey), (xrefData != null ? xrefData.tcaseKey : null), (xrefData != null ? xrefData.tcritKey : null));
                } else if (actionEvent.getActionCommand().equals(SELECT_REGR_REF_IN_TREE)) {
                    if (xrefData == null) {
                        PopupGenerator.showErrorDialog(getComponent(), "No Regression Reference info available.");
                        return;
                    }
                    getTestingFrameworkWindowPanel().selectInTreeView((xrefData != null ? xrefData.regressionModelTSuiteID : null), (xrefData != null ? xrefData.regressionModelTCaseID : null), (xrefData != null ? xrefData.regressionModelTCritID : null));
                }
                ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
                if (childWindow != null) {
                    childWindow.show();
                }
            }
        };
        showInTreeMenuItem.addActionListener(showInTreeActionListener);
        showRegrRefInTreeMenuItem.addActionListener(showInTreeActionListener);
        ActionListener openModelsActionListener = new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                int[] selectedRows = table.getSelectedRows();
                String failureS = "";
                TestCriteriaCrossRefOPResults.CrossRefData xrefData = null;
                int openCount = 0;
                for (int i = 0; i < selectedRows.length; i++) {
                    try {
                        xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[i], XREFDATA_OFFSET);
                        if (xrefData != null && (actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID != null : true)) {
                            openCount += 1;
                            VCDocumentInfo vcDocInfo = null;
                            if (xrefData.isBioModel) {
                                vcDocInfo = getRequestManager().getDocumentManager().getBioModelInfo(new KeyValue((actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID : xrefData.modelID)));
                            } else {
                                vcDocInfo = getRequestManager().getDocumentManager().getMathModelInfo(new KeyValue((actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID : xrefData.modelID)));
                            }
                            getRequestManager().openDocument(vcDocInfo, TestingFrameworkWindowManager.this, true);
                        }
                    } catch (Exception e) {
                        failureS += failureS + "key=" + xrefData.modelID + " " + e.getMessage() + "\n";
                        e.printStackTrace();
                    }
                }
                if (failureS.length() > 0 || openCount == 0) {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Failed to open some models\n" + failureS + (openCount == 0 ? "Selection(s) had no model(s)" : ""));
                }
                ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
                if (childWindow != null) {
                    childWindow.show();
                }
            }
        };
        openModelMenuItem.addActionListener(openModelsActionListener);
        openRegrRefModelMenuItem.addActionListener(openModelsActionListener);
        changeLimitsMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent actionEvent) {
                int[] selectedRows = table.getSelectedRows();
                Vector<TestCriteriaCrossRefOPResults.CrossRefData> changeTCritV = new Vector<TestCriteriaCrossRefOPResults.CrossRefData>();
                for (int i = 0; i < selectedRows.length; i++) {
                    TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[i], XREFDATA_OFFSET);
                    if (xrefData != null) {
                        boolean bFound = false;
                        for (int j = 0; j < changeTCritV.size(); j++) {
                            if (changeTCritV.elementAt(j).tcritKey.equals(xrefData.tcritKey)) {
                                bFound = true;
                                break;
                            }
                        }
                        if (!bFound) {
                            changeTCritV.add(xrefData);
                        }
                    }
                }
                if (changeTCritV.size() > 0) {
                    Double relativeErrorLimit = null;
                    Double absoluteErrorLimit = null;
                    while (true) {
                        try {
                            String ret = PopupGenerator.showInputDialog(getComponent(), "Enter new TestCriteria Error Limits for '" + xrefDataSourceFinal.simName + "'.  '-'(dash) to keep original value.", "RelativeErrorLimit,AbsoluteErrorLimit");
                            int commaPosition = ret.indexOf(',');
                            if (commaPosition == -1) {
                                throw new Exception("No comma found separating RelativeErrorLimit AbsoluteErrorLimit");
                            }
                            if (commaPosition != ret.lastIndexOf(',')) {
                                throw new Exception("Only 1 comma allowed separating RelativeErrorLimit and AbsoluteErrorLimit");
                            }
                            final String KEEP_ORIGINAL_VALUE = "-";
                            String relativeErrorS = ret.substring(0, commaPosition);
                            String absoluteErrorS = ret.substring(commaPosition + 1, ret.length());
                            if (!relativeErrorS.equals(KEEP_ORIGINAL_VALUE)) {
                                relativeErrorLimit = Double.parseDouble(relativeErrorS);
                            }
                            if (!absoluteErrorS.equals(KEEP_ORIGINAL_VALUE)) {
                                absoluteErrorLimit = Double.parseDouble(absoluteErrorS);
                            }
                            if ((relativeErrorLimit != null && relativeErrorLimit <= 0) || (absoluteErrorLimit != null && absoluteErrorLimit <= 0)) {
                                throw new Exception("Error limits must be greater than 0");
                            }
                            break;
                        } catch (UserCancelException e) {
                            ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
                            if (childWindow != null) {
                                childWindow.show();
                            }
                            return;
                        } catch (Exception e) {
                            PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Error parsing Error Limits\n" + e.getMessage());
                        }
                    }
                    double[] relErrorLimitArr = new double[changeTCritV.size()];
                    double[] absErrorLimitArr = new double[changeTCritV.size()];
                    Object[][] rows = new Object[changeTCritV.size()][5];
                    for (int j = 0; j < changeTCritV.size(); j++) {
                        relErrorLimitArr[j] = (relativeErrorLimit != null ? relativeErrorLimit.doubleValue() : changeTCritV.elementAt(j).maxRelErorr);
                        absErrorLimitArr[j] = (absoluteErrorLimit != null ? absoluteErrorLimit.doubleValue() : changeTCritV.elementAt(j).maxAbsErorr);
                        rows[j][2] = new Double(relErrorLimitArr[j]);
                        rows[j][4] = new Double(absErrorLimitArr[j]);
                        rows[j][1] = new Double(changeTCritV.elementAt(j).maxRelErorr);
                        rows[j][3] = new Double(changeTCritV.elementAt(j).maxAbsErorr);
                        rows[j][0] = changeTCritV.elementAt(j).tsVersion;
                    }
                    try {
                        PopupGenerator.showComponentOKCancelTableList(getComponent(), "Confirm Error Limit Changes", new String[] { "TSVersion", "Orig RelErrorLimit", "New RelErrorLimit", "Orig AbsErrorLimit", "New AbsErrorLimit" }, rows, null);
                    } catch (UserCancelException e) {
                        ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
                        if (childWindow != null) {
                            childWindow.show();
                        }
                        return;
                    }
                    // Get information needed to generate new TestCriteria Reports
                    final String YES_ANSWER = "Yes";
                    Hashtable<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>> genReportHash = null;
                    String genRepResult = PopupGenerator.showWarningDialog(getComponent(), "Generate Reports for changed Test Criterias?", new String[] { YES_ANSWER, "No" }, YES_ANSWER);
                    if (genRepResult != null && genRepResult.equals(YES_ANSWER)) {
                        genReportHash = new Hashtable<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>>();
                        for (int i = 0; i < changeTCritV.size(); i++) {
                            boolean bFound = false;
                            for (int j = 0; j < testSuiteInfos.length; j++) {
                                if (changeTCritV.elementAt(i).tsVersion.equals(testSuiteInfos[j].getTSID())) {
                                    bFound = true;
                                    Vector<TestCriteriaCrossRefOPResults.CrossRefData> tempV = genReportHash.get(testSuiteInfos[j]);
                                    if (tempV == null) {
                                        tempV = new Vector<TestCriteriaCrossRefOPResults.CrossRefData>();
                                        genReportHash.put(testSuiteInfos[j], tempV);
                                    }
                                    tempV.add(changeTCritV.elementAt(i));
                                }
                            }
                            if (!bFound) {
                                PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Couldn't find testsuiteinfo for testcriteria");
                                return;
                            }
                        }
                    }
                    BigDecimal[] changeTCritBDArr = new BigDecimal[changeTCritV.size()];
                    for (int i = 0; i < changeTCritV.size(); i++) {
                        changeTCritBDArr[i] = changeTCritV.elementAt(i).tcritKey;
                    }
                    ChangeTestCriteriaErrorLimitOP changeTestCriteriaErrorLimitOP = new ChangeTestCriteriaErrorLimitOP(changeTCritBDArr, absErrorLimitArr, relErrorLimitArr);
                    try {
                        getTestingFrameworkWindowPanel().getDocumentManager().doTestSuiteOP(changeTestCriteriaErrorLimitOP);
                    } catch (Exception e) {
                        PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Failed Changing Error limits for selected " + xrefDataSourceFinal.simName + "\n" + e.getMessage());
                        return;
                    }
                    ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
                    if (childWindow != null) {
                        childWindow.close();
                    }
                    getTestingFrameworkWindowPanel().refreshTree((TestSuiteInfoNew) null);
                    if (genReportHash != null) {
                        updateReports(genReportHash);
                    } else {
                        new Thread(new Runnable() {

                            public void run() {
                                TestingFrameworkWindowManager.this.queryTCritCrossRef(tsin, tcrit, varName);
                            }
                        }).start();
                    }
                } else {
                    PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "No selected rows contain Test Criteria.");
                }
            }
        });
        table.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                checkPopup(e);
            }

            @Override
            public void mousePressed(MouseEvent e) {
                super.mousePressed(e);
                checkPopup(e);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                super.mouseReleased(e);
                checkPopup(e);
            }

            private void checkPopup(MouseEvent mouseEvent) {
                if (mouseEvent.isPopupTrigger()) {
                    // Not use because popupmenu will not show at edge
                    // if(table.getSelectedRowCount() <= 1){
                    // table.getSelectionModel().setSelectionInterval(table.rowAtPoint(mouseEvent.getPoint()),table.rowAtPoint(mouseEvent.getPoint()));
                    // }
                    doPopup(mouseEvent);
                } else {
                    queryPopupMenu.setVisible(false);
                }
            }

            private void doPopup(MouseEvent mouseEvent) {
                // queryPopupMenu.add(showInTreeMenuItem);
                if (table.getSelectedRowCount() == 0) {
                    changeLimitsMenuItem.setEnabled(false);
                    openModelMenuItem.setEnabled(false);
                    openRegrRefModelMenuItem.setEnabled(false);
                    showInTreeMenuItem.setEnabled(false);
                    showRegrRefInTreeMenuItem.setEnabled(false);
                } else {
                    changeLimitsMenuItem.setEnabled(true);
                    openModelMenuItem.setEnabled(true);
                    openRegrRefModelMenuItem.setEnabled(true);
                    showInTreeMenuItem.setEnabled(true);
                    if (table.getSelectedRowCount() == 1) {
                        TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(table.getSelectedRow(), numColumns);
                        showRegrRefInTreeMenuItem.setEnabled(xrefData != null && xrefData.regressionModelID != null && xrefData.tsRefVersion != null);
                    }
                }
                queryPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
            }
        });
        String title = (xrefDataSource.isBioModel ? "BM" : "MM") + " " + xrefDataSource.tcSolutionType + " (" + sourceTestSuite + ") " + " \"" + (xrefDataSource.isBioModel ? xrefDataSource.bmName : xrefDataSource.mmName) + "\"  ::  " + (xrefDataSource.isBioModel ? "app=\"" + xrefDataSource.bmAppName + "\"  ::  sim=\"" + xrefDataSource.simName + "\"" : "sim=\"" + xrefDataSource.simName + "\"");
        ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).addChildWindow(scrollPaneContentPane, scrollPaneContentPane, title);
        // childWindow.setSize(600,400);
        childWindow.setIsCenteredOnParent();
        childWindow.pack();
        childWindow.setResizable(true);
        childWindow.show();
    } catch (DataAccessException e) {
        e.printStackTrace();
        PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Error Query TestCriteria Cross Ref:\n" + e.getMessage());
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) ActionEvent(java.awt.event.ActionEvent) UserCancelException(org.vcell.util.UserCancelException) Comparator(java.util.Comparator) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) Component(java.awt.Component) JComponent(javax.swing.JComponent) JMenuItem(javax.swing.JMenuItem) Vector(java.util.Vector) CrossRefData(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults.CrossRefData) DataAccessException(org.vcell.util.DataAccessException) JScrollPane(javax.swing.JScrollPane) QueryTestCriteriaCrossRefOP(cbit.vcell.numericstest.QueryTestCriteriaCrossRefOP) MouseEvent(java.awt.event.MouseEvent) Hashtable(java.util.Hashtable) MouseAdapter(java.awt.event.MouseAdapter) TestCriteriaCrossRefOPResults(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults) Dimension(java.awt.Dimension) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) Date(java.util.Date) JPopupMenu(javax.swing.JPopupMenu) BigDecimal(java.math.BigDecimal) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) CrossRefData(cbit.vcell.numericstest.TestCriteriaCrossRefOPResults.CrossRefData) JSortTable(org.vcell.util.gui.sorttable.JSortTable) ActionListener(java.awt.event.ActionListener) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) ChangeTestCriteriaErrorLimitOP(cbit.vcell.numericstest.ChangeTestCriteriaErrorLimitOP) JTable(javax.swing.JTable) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Example 2 with TestCriteriaCrossRefOPResults

use of cbit.vcell.numericstest.TestCriteriaCrossRefOPResults 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

ChangeTestCriteriaErrorLimitOP (cbit.vcell.numericstest.ChangeTestCriteriaErrorLimitOP)2 QueryTestCriteriaCrossRefOP (cbit.vcell.numericstest.QueryTestCriteriaCrossRefOP)2 TestCriteriaCrossRefOPResults (cbit.vcell.numericstest.TestCriteriaCrossRefOPResults)2 BigDecimal (java.math.BigDecimal)2 Hashtable (java.util.Hashtable)2 Vector (java.util.Vector)2 DataAccessException (org.vcell.util.DataAccessException)2 KeyValue (org.vcell.util.document.KeyValue)2 InsertHashtable (cbit.sql.InsertHashtable)1 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1 VCellSortTableModel (cbit.vcell.client.desktop.biomodel.VCellSortTableModel)1 AddTestCasesOP (cbit.vcell.numericstest.AddTestCasesOP)1 AddTestCasesOPBioModel (cbit.vcell.numericstest.AddTestCasesOPBioModel)1 AddTestCasesOPMathModel (cbit.vcell.numericstest.AddTestCasesOPMathModel)1 AddTestCriteriaOPBioModel (cbit.vcell.numericstest.AddTestCriteriaOPBioModel)1 AddTestCriteriaOPMathModel (cbit.vcell.numericstest.AddTestCriteriaOPMathModel)1 AddTestResultsOP (cbit.vcell.numericstest.AddTestResultsOP)1 AddTestSuiteOP (cbit.vcell.numericstest.AddTestSuiteOP)1 EditTestCasesOP (cbit.vcell.numericstest.EditTestCasesOP)1 EditTestCriteriaOPBioModel (cbit.vcell.numericstest.EditTestCriteriaOPBioModel)1