Search in sources :

Example 51 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class TestingFrameworkWindowManager method getUserSelectedRefSimInfo.

public SimulationInfo getUserSelectedRefSimInfo(RequestManager currentRequstManager, VCDocumentInfo vcDocInfo) throws Exception {
    final int MODELTYPE_INDEX = 0;
    final int MODELKEY_INDEX = 2;
    final int SIMNAME_INDEX = 5;
    final String[] ROWDATACOLNAMES = new String[] { "Type", "Model", "Model Key", "Owner", "App", "Sim", "Date" };
    Vector<Object[]> simInfoV = new Vector<Object[]>();
    // BioModelMetaData[] bmMetaDataArr = getRequestManager().getDocumentManager().getSessionManager().getUserMetaDbServer().getBioModelMetaDatas(true);
    // bmMetaDataArr[0].
    BioModelInfo[] bioModelInfoArr = null;
    if (vcDocInfo == null) {
        bioModelInfoArr = currentRequstManager.getDocumentManager().getBioModelInfos();
    } else if (vcDocInfo instanceof BioModelInfo) {
        bioModelInfoArr = new BioModelInfo[] { (BioModelInfo) vcDocInfo };
    }
    for (int i = 0; bioModelInfoArr != null && i < bioModelInfoArr.length; i++) {
        if (bioModelInfoArr[i].getBioModelChildSummary() != null) {
            String[] bmSimContextNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationContextNames();
            for (int j = 0; bmSimContextNamesArr != null && j < bmSimContextNamesArr.length; j++) {
                String[] bmSimNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationNames(bmSimContextNamesArr[j]);
                for (int k = 0; bmSimNamesArr != null && k < bmSimNamesArr.length; k++) {
                    // System.out.println("BM "+
                    // bioModelInfoArr[i].getVersion().getOwner().getName()+" "+
                    // bioModelInfoArr[i].getVersion().getName()+
                    // " app="+bmSimContextNamesArr[j]+
                    // " sim="+bmSimNamesArr[k]);
                    simInfoV.add(new Object[] { "BM", bioModelInfoArr[i].getVersion().getName(), bioModelInfoArr[i].getVersion().getVersionKey(), bioModelInfoArr[i].getVersion().getOwner().getName(), bmSimContextNamesArr[j], bmSimNamesArr[k], bioModelInfoArr[i].getVersion().getDate() });
                }
            }
        }
    }
    MathModelInfo[] mathModelInfoArr = null;
    if (vcDocInfo == null) {
        mathModelInfoArr = currentRequstManager.getDocumentManager().getMathModelInfos();
    } else if (vcDocInfo instanceof MathModelInfo) {
        mathModelInfoArr = new MathModelInfo[] { (MathModelInfo) vcDocInfo };
    }
    for (int i = 0; mathModelInfoArr != null && i < mathModelInfoArr.length; i++) {
        if (mathModelInfoArr[i].getMathModelChildSummary() != null) {
            String[] mathSimNamesArr = mathModelInfoArr[i].getMathModelChildSummary().getSimulationNames();
            for (int j = 0; mathSimNamesArr != null && j < mathSimNamesArr.length; j++) {
                // System.out.println("MM "+
                // mathModelInfoArr[i].getVersion().getOwner().getName()+" "+
                // mathModelInfoArr[i].getVersion().getName()+
                // " sim="+mathSimNamesArr[j]);
                simInfoV.add(new Object[] { "MM", mathModelInfoArr[i].getVersion().getName(), mathModelInfoArr[i].getVersion().getVersionKey(), mathModelInfoArr[i].getVersion().getOwner().getName(), null, mathSimNamesArr[j], mathModelInfoArr[i].getVersion().getDate() });
            }
        }
    }
    Object[][] rowData = new Object[simInfoV.size()][ROWDATACOLNAMES.length];
    simInfoV.copyInto(rowData);
    int[] simSelection = DialogUtils.showComponentOKCancelTableList(getComponent(), "Choose Ref Simulation", ROWDATACOLNAMES, rowData, ListSelectionModel.SINGLE_SELECTION);
    if (simSelection == null || simSelection.length == 0) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    Simulation[] simArr = null;
    if (rowData[simSelection[0]][MODELTYPE_INDEX].equals("BM")) {
        BioModel bm = currentRequstManager.getDocumentManager().getBioModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
        simArr = bm.getSimulations();
    } else {
        MathModel mm = currentRequstManager.getDocumentManager().getMathModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
        simArr = mm.getSimulations();
    }
    for (int i = 0; simArr != null && i < simArr.length; i++) {
        if (simArr[i].getName().equals(rowData[simSelection[0]][SIMNAME_INDEX])) {
            return simArr[i].getSimulationInfo();
        }
    }
    throw new Exception("Couldn't find selected simulation");
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) Simulation(cbit.vcell.solver.Simulation) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) BioModel(cbit.vcell.biomodel.BioModel) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) Vector(java.util.Vector)

Example 52 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class TestingFrameworkWindowManager method generateTestCriteriaReport.

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

Example 53 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class TestingFrameworkWindowManager method loadModel.

/**
 * Insert the method's description here.
 * Creation date: (4/9/2003 1:31:08 PM)
 * @return cbit.vcell.numericstestingframework.TestSuiteInfo
 */
public void loadModel(VCDocumentInfo vcDocumentInfo) throws DataAccessException {
    VCDocumentInfo vcDocInfo = null;
    if (vcDocumentInfo instanceof MathModelInfo) {
        vcDocInfo = getRequestManager().getDocumentManager().getMathModelInfo(vcDocumentInfo.getVersion().getVersionKey());
    } else if (vcDocumentInfo instanceof BioModelInfo) {
        vcDocInfo = getRequestManager().getDocumentManager().getBioModelInfo(vcDocumentInfo.getVersion().getVersionKey());
    }
    getRequestManager().openDocument(vcDocInfo, this, true);
}
Also used : VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 54 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelPropertiesPanel method updateInterface.

/**
 * Comment
 */
private void updateInterface() {
    if (bioModel == null || bioModelWindowManager == null) {
        return;
    }
    nameLabel.setText(bioModel.getName());
    Version version = bioModel.getVersion();
    if (version != null) {
        ownerLabel.setText(version.getOwner().getName());
        lastModifiedLabel.setText(version.getDate().toString());
        try {
            BioModelInfo bioModelInfo = bioModelWindowManager.getRequestManager().getDocumentManager().getBioModelInfo(version.getVersionKey());
            permissionLabel.setText(bioModelInfo.getVersion().getGroupAccess().getDescription());
        } catch (DataAccessException e) {
            e.printStackTrace();
        }
        changePermissionButton.setEnabled(true);
    }
    webLinksPanel.removeAll();
    webLinksPanel.setLayout(new GridLayout(0, 1));
    Set<MiriamRefGroup> resources = new HashSet<MiriamRefGroup>();
    Set<MiriamRefGroup> isDescribedByAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_isDescribedBy);
    Set<MiriamRefGroup> isAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_is);
    resources.addAll(isDescribedByAnnotation);
    resources.addAll(isAnnotation);
    for (MiriamRefGroup refGroup : resources) {
        for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
            LinkNode linkNode = new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_isDescribedBy, miriamResources);
            final String link = linkNode.getLink();
            String labelText = miriamResources.getDataType() == null ? "" : miriamResources.getDataType().getDataTypeName();
            String toolTip = null;
            if (link != null) {
                toolTip = "double-click to open link " + link;
                labelText = "<html><b>" + labelText + "</b>&nbsp;" + "<font color=blue><a href=" + link + ">" + link + "</a></font></html>";
            }
            JLabel label = new JLabel(labelText);
            label.addMouseListener(new MouseListener() {

                public void mouseReleased(MouseEvent e) {
                }

                public void mousePressed(MouseEvent e) {
                }

                public void mouseExited(MouseEvent e) {
                }

                public void mouseEntered(MouseEvent e) {
                }

                public void mouseClicked(MouseEvent e) {
                    if (e.getClickCount() == 2) {
                        DialogUtils.browserLauncher(BioModelPropertiesPanel.this, link, "failed to open " + link);
                    }
                }
            });
            label.setToolTipText(toolTip);
            webLinksPanel.add(label);
        }
    }
    applicationsPanel.removeAll();
    int gridy = 0;
    SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
    if (simulationContexts != null) {
        for (int i = 0; i < simulationContexts.length; i++) {
            SimulationContext simContext = simulationContexts[i];
            JLabel label = new JLabel(simContext.getName());
            label.setFont(label.getFont().deriveFont(Font.BOLD));
            if (simContext.isRuleBased()) {
                if (simContext.getGeometry().getDimension() == 0) {
                    label.setIcon(VCellIcons.appRbmNonspIcon);
                }
            } else if (simContext.isStoch()) {
                if (simContext.getGeometry().getDimension() == 0) {
                    label.setIcon(VCellIcons.appStoNonspIcon);
                } else {
                    label.setIcon(VCellIcons.appStoSpatialIcon);
                }
            } else {
                // deterministic
                if (simContext.getGeometry().getDimension() == 0) {
                    label.setIcon(VCellIcons.appDetNonspIcon);
                } else {
                    label.setIcon(VCellIcons.appDetSpatialIcon);
                }
            }
            GridBagConstraints gbc = new java.awt.GridBagConstraints();
            gbc.gridx = 0;
            gbc.gridy = gridy++;
            gbc.weightx = 1.0;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            gbc.anchor = GridBagConstraints.FIRST_LINE_START;
            if (i > 0) {
                gbc.insets = new Insets(4, 0, 0, 0);
            }
            applicationsPanel.add(label, gbc);
            Geometry geometry = simContext.getGeometry();
            String geometryText = "Compartmental geometry";
            if (geometry != null) {
                Version geometryVersion = geometry.getVersion();
                int dimension = geometry.getDimension();
                if (dimension > 0) {
                    String description = geometry.getDimension() + "D " + (geometry.getGeometrySpec().hasImage() ? "image" : "analytic") + " geometry";
                    geometryText = description;
                    if (geometryVersion != null) {
                        geometryText += " - " + geometryVersion.getName();
                    }
                }
            }
            JLabel geometryLabel = new JLabel(geometryText);
            geometryLabel.setIcon(VCellIcons.geometryIcon);
            JLabel detStochLabel = new JLabel(simContext.getMathType().getDescription());
            detStochLabel.setIcon(VCellIcons.mathTypeIcon);
            gbc.insets = new Insets(2, 20, 2, 2);
            gbc.gridy = gridy++;
            applicationsPanel.add(detStochLabel, gbc);
            gbc.gridy = gridy++;
            if (i == simulationContexts.length - 1) {
                gbc.weighty = 1.0;
            }
            applicationsPanel.add(geometryLabel, gbc);
        }
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) MouseEvent(java.awt.event.MouseEvent) Insets(java.awt.Insets) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) GridLayout(java.awt.GridLayout) MouseListener(java.awt.event.MouseListener) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) Version(org.vcell.util.document.Version) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) DataAccessException(org.vcell.util.DataAccessException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) HashSet(java.util.HashSet)

Example 55 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class ClientRequestManager method deleteDocument.

/**
 * Insert the method's description here.
 * Creation date: (6/22/2004 10:50:34 PM)
 * @param documentInfo cbit.vcell.document.VCDocumentInfo
 */
public void deleteDocument(final VCDocumentInfo documentInfo, final TopLevelWindowManager requester) {
    if (documentInfo != null) {
        // see if we have this open
        String documentID = documentInfo.getVersion().getVersionKey().toString();
        if (getMdiManager().haveWindow(documentID)) {
            // already open, refuse
            PopupGenerator.showErrorDialog(requester, "Selected edition is open, cannot delete");
            return;
        } else {
            // don't have it open, try to delete it
            String confirm = PopupGenerator.showWarningDialog(requester, getUserPreferences(), UserMessage.warn_deleteDocument, documentInfo.getVersion().getName());
            if (confirm.equals(UserMessage.OPTION_DELETE)) {
                AsynchClientTask task1 = new AsynchClientTask("Deleting document...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    @Override
                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        if (documentInfo instanceof BioModelInfo) {
                            getDocumentManager().delete((BioModelInfo) documentInfo);
                        } else if (documentInfo instanceof MathModelInfo) {
                            getDocumentManager().delete((MathModelInfo) documentInfo);
                        } else if (documentInfo instanceof GeometryInfo) {
                            getDocumentManager().delete((GeometryInfo) documentInfo);
                        } else {
                            throw new RuntimeException("delete not supported for VCDocumentInfo type " + documentInfo.getClass().getName());
                        }
                    }
                };
                ClientTaskDispatcher.dispatch(requester.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1 }, false);
            } else {
                // user canceled
                return;
            }
        }
    } else {
        // nothing selected
        return;
    }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) CSGObject(cbit.vcell.geometry.CSGObject) MathModelInfo(org.vcell.util.document.MathModelInfo)

Aggregations

BioModelInfo (org.vcell.util.document.BioModelInfo)79 DataAccessException (org.vcell.util.DataAccessException)38 MathModelInfo (org.vcell.util.document.MathModelInfo)37 BioModel (cbit.vcell.biomodel.BioModel)25 GeometryInfo (cbit.vcell.geometry.GeometryInfo)22 KeyValue (org.vcell.util.document.KeyValue)18 SimulationContext (cbit.vcell.mapping.SimulationContext)17 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)15 BigString (org.vcell.util.BigString)14 User (org.vcell.util.document.User)14 Vector (java.util.Vector)13 Simulation (cbit.vcell.solver.Simulation)12 XmlParseException (cbit.vcell.xml.XmlParseException)12 SQLException (java.sql.SQLException)12 XMLSource (cbit.vcell.xml.XMLSource)10 MathModel (cbit.vcell.mathmodel.MathModel)9 Hashtable (java.util.Hashtable)9 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)9 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)8 Geometry (cbit.vcell.geometry.Geometry)7