Search in sources :

Example 16 with BioModelInfo

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

the class BioModelDbTreePanel method documentManager_DatabaseUpdate.

/**
 * Comment
 */
protected void documentManager_DatabaseUpdate(DatabaseEvent event) {
    if (event.getNewVersionInfo() instanceof BioModelInfo && getSelectedVersionInfo() instanceof BioModelInfo) {
        BioModelInfo selectedBMInfo = (BioModelInfo) getSelectedVersionInfo();
        BioModelInfo eventBMInfo = (BioModelInfo) event.getNewVersionInfo();
        if (eventBMInfo.getVersion().getVersionKey().equals(selectedBMInfo.getVersion().getVersionKey())) {
            setSelectedVersionInfo(event.getNewVersionInfo());
        }
    }
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 17 with BioModelInfo

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

the class BioModelMetaDataPanel method setBioModelInfo.

/**
 * Sets the bioModelInfo property (cbit.vcell.biomodel.BioModelInfo) value.
 * @param bioModelInfo The new value for the property.
 * @see #getBioModelInfo
 */
public void setBioModelInfo(BioModelInfo bioModelInfo) {
    BioModelInfo oldValue = fieldBioModelInfo;
    fieldBioModelInfo = bioModelInfo;
    firePropertyChange("bioModelInfo", oldValue, bioModelInfo);
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 18 with BioModelInfo

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

the class EditTestCriteriaPanel method resetTextFields.

/**
 * Sets the testSuiteInfo property (cbit.vcell.numericstest.TestSuiteInfo) value.
 * @param testSuiteInfo The new value for the property.
 * @see #getTestSuiteInfo
 */
public void resetTextFields() {
    // If the chosen simInfo already has test criteria defined, set the fields with the appropriate values
    // Else set them to blank.
    getRelErrTextField().setText("");
    getAbsErrTextField().setText("");
    if (getExistingTestCriteria() != null) {
        Double relErr = getExistingTestCriteria().getMaxRelError();
        Double absErr = getExistingTestCriteria().getMaxAbsError();
        getRelErrTextField().setText((relErr != null ? relErr.toString() : null));
        getAbsErrTextField().setText((absErr != null ? absErr.toString() : null));
    }
    // Depending on test case soultion type (which is set by testingFrameworkWindowManager based on the test case
    // the simulation belongs to), enable apprpriate (ref MathModel, ref simInfo buttons) fields.
    // if (!getSolutionType().equals(TestCaseNew.REGRESSION)) {
    getRefMathModelLabel().setText(null);
    getRefSimLabel().setText(null);
    getBioModelAppLabel().setText(null);
    getBmAppSimLabel().setText(null);
    getRefMathModelButton().setEnabled(false);
    getRefMathModelLabel().setEnabled(false);
    getRefSimButton().setEnabled(false);
    getRefSimLabel().setEnabled(false);
    getSelectRefBMAppJButton().setEnabled(false);
    getBioModelAppLabel().setEnabled(false);
    getSelectRefSimJButton().setEnabled(false);
    getBmAppSimLabel().setEnabled(false);
    // } else {
    if (getExistingTestCriteria() instanceof TestCriteriaNewMathModel && getSolutionType().equals(TestCaseNew.REGRESSION)) {
        getRefMathModelButton().setEnabled(true);
        getRefMathModelLabel().setEnabled(true);
        getRefSimButton().setEnabled(true);
        getRefSimLabel().setEnabled(true);
    } else if (getExistingTestCriteria() instanceof TestCriteriaNewBioModel && getSolutionType().equals(TestCaseNew.REGRESSION)) {
        getSelectRefBMAppJButton().setEnabled(true);
        getBioModelAppLabel().setEnabled(true);
        getSelectRefSimJButton().setEnabled(true);
        getBmAppSimLabel().setEnabled(true);
    }
    if (getExistingTestCriteria() != null && getExistingTestCriteria().getRegressionSimInfo() != null) {
        if (getExistingTestCriteria() instanceof TestCriteriaNewMathModel) {
            MathModelInfo refMMInfo = ((TestCriteriaNewMathModel) getExistingTestCriteria()).getRegressionMathModelInfo();
            if (refMMInfo == null) {
                PopupGenerator.showErrorDialog(this, "No MathModelInfo found for SimInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            SimulationInfo refSimInfo = null;
            refSimInfo = getExistingTestCriteria().getRegressionSimInfo();
            if (refSimInfo == null) {
                PopupGenerator.showErrorDialog(this, "No SimulationInfo found for simInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            setReferenceMathModelInfo(refMMInfo);
            setReferenceSimInfo(refSimInfo);
            getRefMathModelLabel().setText("<html>" + refMMInfo.getVersion().getName() + "<br>(MathModelKey=" + refMMInfo.getVersion().getVersionKey() + ")<br>" + refMMInfo.getVersion().getDate() + "<html>");
            getRefSimLabel().setText("<html>" + refSimInfo.getVersion().getName() + "<br>(SimulationKey:" + refSimInfo.getVersion().getVersionKey() + ")</html>");
        } else if (getExistingTestCriteria() instanceof TestCriteriaNewBioModel) {
            BioModelInfo refBMInfo = ((TestCriteriaNewBioModel) getExistingTestCriteria()).getRegressionBioModelInfo();
            if (refBMInfo == null) {
                PopupGenerator.showErrorDialog(this, "No bioModelInfo found for SimInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            SimulationInfo refSimInfo = null;
            refSimInfo = getExistingTestCriteria().getRegressionSimInfo();
            if (refSimInfo == null) {
                PopupGenerator.showErrorDialog(this, "No SimulationInfo found for simInfo Key " + getExistingTestCriteria().getRegressionSimInfo().getVersion().getVersionKey());
            }
            setbioModelInfo(refBMInfo);
            setbmAppSimInfo(refSimInfo);
            setappName(((TestCriteriaNewBioModel) getExistingTestCriteria()).getRegressionApplicationName());
            getBioModelAppLabel().setText("<html>" + refBMInfo.getVersion().getName() + "/" + getappName() + "<br>(BioModelKey=" + refBMInfo.getVersion().getVersionKey() + ")<br>" + refBMInfo.getVersion().getDate() + "</html>");
            getBmAppSimLabel().setText("<html>" + refSimInfo.getVersion().getName() + "<br>(SimulationKey:" + refSimInfo.getVersion().getVersionKey() + ")</html>");
        }
    } else {
        setReferenceMathModelInfo(null);
        setReferenceSimInfo(null);
        getRefMathModelLabel().setText("");
        getRefSimLabel().setText("");
        setbioModelInfo(null);
        setbmAppSimInfo(null);
        setappName(null);
        getBioModelAppLabel().setText(null);
        getBmAppSimLabel().setText(null);
    }
// }
}
Also used : TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 19 with BioModelInfo

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

the class NagiosVCellMonitor method checkVCell.

private CheckResults checkVCell(VCELL_CHECK_LEVEL checkLevel, String rmiHostName, int rmiPort, String rmiBootstrapStubName, String vcellNagiosPassword, int criticalTimeout, int monitorPort) throws Exception {
    SimulationStatusPersistent lastSimStatus = null;
    String vcellVersion = null;
    TreeMap<VCELL_CHECK_LEVEL, Long> levelTimesMillisec = new TreeMap<NagiosVCellMonitor.VCELL_CHECK_LEVEL, Long>();
    long startTime = System.currentTimeMillis();
    VCellConnection vcellConnection = null;
    try {
        if (rmiHostName == null || rmiPort == -1) {
            throw new UnexpectedTestStateException("Host name/ip and rmiPort required for testing, rmihostname=" + rmiHostName + " rmiport=" + rmiPort);
        }
        String rmiUrl = "//" + rmiHostName + ":" + rmiPort + "/" + rmiBootstrapStubName;
        VCellBootstrap vcellBootstrap = null;
        try {
            vcellBootstrap = (VCellBootstrap) Naming.lookup(rmiUrl);
        } catch (Exception e) {
            throw new UnexpectedTestStateException("Error during bootstrap lookup, " + e.getClass().getSimpleName() + " " + e.getMessage());
        }
        vcellVersion = vcellBootstrap.getVCellSoftwareVersion();
        levelTimesMillisec.put(VCELL_CHECK_LEVEL.RMI_ONLY_0, System.currentTimeMillis() - startTime);
        if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.CONNECT_1.ordinal()) {
            if (vcellNagiosPassword == null) {
                throw new UnexpectedTestStateException("vcellNagios Password required for " + VCELL_CHECK_LEVEL.CONNECT_1.toString() + " and above");
            }
            UserLoginInfo userLoginInfo = new UserLoginInfo(VCELL_NAGIOS_USER, new DigestedPassword(vcellNagiosPassword));
            vcellConnection = vcellBootstrap.getVCellConnection(userLoginInfo);
            levelTimesMillisec.put(VCELL_CHECK_LEVEL.CONNECT_1, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.RMI_ONLY_0));
            if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.INFOS_2.ordinal()) {
                VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
                levelTimesMillisec.put(VCELL_CHECK_LEVEL.INFOS_2, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.CONNECT_1));
                if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.LOAD_3.ordinal()) {
                    KeyValue bioModelKey = null;
                    final String testModelName = "Solver Suite 5.1 (BETA only ode)";
                    for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
                        if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(testModelName)) {
                            bioModelKey = bioModelInfo.getVersion().getVersionKey();
                            break;
                        }
                    }
                    BigString bioModelXML = vcellConnection.getUserMetaDbServer().getBioModelXML(bioModelKey);
                    BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
                    bioModel.refreshDependencies();
                    levelTimesMillisec.put(VCELL_CHECK_LEVEL.LOAD_3, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.INFOS_2));
                    if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.DATA_4.ordinal()) {
                        final String testSimContextName = "non-spatial ODE";
                        SimulationContext simulationContext = bioModel.getSimulationContext(testSimContextName);
                        final String testSimName = "Copy of combined ida/cvode";
                        Simulation simulation = simulationContext.getSimulation(testSimName);
                        if (simulation == null) {
                            throw new UnexpectedTestStateException("Couldn't find sim '" + testSimName + "' for " + checkLevel.toString());
                        }
                        VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
                        ArrayList<AnnotatedFunction> outputFunctionsList = simulationContext.getOutputFunctionContext().getOutputFunctionsList();
                        OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
                        double[] times = vcellConnection.getDataSetController().getDataSetTimes(vcSimulationDataIdentifier);
                        ODESimData odeSimData = vcellConnection.getDataSetController().getODEData(vcSimulationDataIdentifier);
                        levelTimesMillisec.put(VCELL_CHECK_LEVEL.DATA_4, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.LOAD_3));
                        if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.RUN_5.ordinal()) {
                            KeyValue copy1Key = null;
                            KeyValue copy2Key = null;
                            VCSimulationIdentifier testRunSimID = null;
                            try {
                                if (simulationContext.getSimulations().length != 1) {
                                    throw new UnexpectedTestStateException("Expecting only 1 sim to be copied for " + checkLevel.toString());
                                }
                                SimulationStatusPersistent simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(simulation.getVersion().getVersionKey());
                                if (!simulationStatus.isCompleted()) {
                                    throw new UnexpectedTestStateException("Expecting completed sim to copy for " + checkLevel.toString());
                                }
                                String copyModelName = testModelName + "_" + rmiHostName + "_rmi" + rmiPort + "_siteprt" + monitorPort;
                                boolean bForceCleanup = true;
                                while (true) {
                                    boolean bMessy = false;
                                    for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
                                        if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(copyModelName)) {
                                            bMessy = true;
                                            if (bForceCleanup) {
                                                try {
                                                    vcellConnection.getUserMetaDbServer().deleteBioModel(bioModelInfo.getVersion().getVersionKey());
                                                } catch (Exception e) {
                                                    e.printStackTrace();
                                                }
                                            } else {
                                                throw new MessyTestEnvironmentException("Messy test environment, not expecting " + copyModelName + " and couldn't cleanup");
                                            }
                                        }
                                    }
                                    if (!bMessy) {
                                        break;
                                    }
                                    // get new vcInfoContainer without cleaned-up model
                                    vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
                                    bForceCleanup = false;
                                }
                                BigString copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModelAs(bioModelXML, copyModelName, null);
                                BioModel copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
                                copy1Key = copyBioModel.getVersion().getVersionKey();
                                copyBioModel.refreshDependencies();
                                Simulation copySim = copyBioModel.getSimulationContext(testSimContextName).copySimulation(copyBioModel.getSimulationContext(testSimContextName).getSimulation(testSimName));
                                final String copyTestSimName = "test";
                                copySim.setName(copyTestSimName);
                                copyBioModel.refreshDependencies();
                                copyBioModelXMLStr = new BigString(XmlHelper.bioModelToXML(copyBioModel));
                                copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModel(copyBioModelXMLStr, null);
                                copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
                                copy2Key = copyBioModel.getVersion().getVersionKey();
                                copyBioModel.refreshDependencies();
                                Simulation newSimulation = copyBioModel.getSimulationContext(testSimContextName).getSimulation(copyTestSimName);
                                simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
                                if (simulationStatus != null && !simulationStatus.isNeverRan()) {
                                    throw new UnexpectedTestStateException("Expecting new sim to have 'never ran' status for " + checkLevel.toString());
                                }
                                testRunSimID = new VCSimulationIdentifier(newSimulation.getVersion().getVersionKey(), copyBioModel.getVersion().getOwner());
                                vcellConnection.getSimulationController().startSimulation(testRunSimID, 1);
                                lastSimStatus = simulationStatus;
                                MessageEvent[] messageEvents = null;
                                while (simulationStatus == null || (!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed())) {
                                    Thread.sleep(200);
                                    if (((System.currentTimeMillis() - startTime) / 1000) > criticalTimeout) {
                                        vcellConnection.getSimulationController().stopSimulation(testRunSimID);
                                        vcellConnection.getMessageEvents();
                                        break;
                                    }
                                    simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
                                    if (simulationStatus != null && !simulationStatus.toString().equals((lastSimStatus == null ? null : lastSimStatus.toString()))) {
                                        lastSimStatus = simulationStatus;
                                    }
                                    if (simulationStatus != null && simulationStatus.isFailed()) {
                                        throw new Exception("time " + ((System.currentTimeMillis() - startTime) / 1000) + ", Sim execution failed key:" + testRunSimID.getSimulationKey() + " sim " + newSimulation.getName() + " model " + copyBioModel.getVersion().getName() + " messg " + simulationStatus.getFailedMessage());
                                    }
                                    messageEvents = vcellConnection.getMessageEvents();
                                }
                            } finally {
                                try {
                                    if (copy1Key != null) {
                                        vcellConnection.getUserMetaDbServer().deleteBioModel(copy1Key);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                try {
                                    if (copy2Key != null) {
                                        vcellConnection.getUserMetaDbServer().deleteBioModel(copy2Key);
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                                if (testRunSimID != null) {
                                    deleteSimData(testRunSimID);
                                }
                            }
                            levelTimesMillisec.put(VCELL_CHECK_LEVEL.RUN_5, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.DATA_4));
                        }
                    }
                }
            }
        }
        return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, null);
    } catch (Exception e) {
        return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, e);
    } finally {
        vcellConnection = null;
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) MessageEvent(cbit.rmi.event.MessageEvent) VCellBootstrap(cbit.vcell.server.VCellBootstrap) BigString(org.vcell.util.BigString) ODESimData(cbit.vcell.solver.ode.ODESimData) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword) BigString(org.vcell.util.BigString) VCInfoContainer(org.vcell.util.document.VCInfoContainer) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) VCellConnection(cbit.vcell.server.VCellConnection) BioModelInfo(org.vcell.util.document.BioModelInfo) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) TreeMap(java.util.TreeMap) SimulationContext(cbit.vcell.mapping.SimulationContext) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) IOException(java.io.IOException) OutputContext(cbit.vcell.simdata.OutputContext) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) UserLoginInfo(org.vcell.util.document.UserLoginInfo) XMLSource(cbit.vcell.xml.XMLSource)

Example 20 with BioModelInfo

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

the class BioModelMultiVisitor method visitBioModel.

public void visitBioModel(BioModel bioModel, PrintStream logFilePrintStream) {
    KeyValue currentKey = bioModel.getVersion().getVersionKey();
    BioModelInfo bmInfo = bioModelInfoHash.get(currentKey);
    logFilePrintStream.append(" == SUCEEDED IN READING BIOMODEL " + bmInfo.getVersion().getName() + "; key : " + currentKey.toString() + "\n");
    unparsedBioModels.remove(currentKey);
    for (Iterator<KeyValue> iterator = unparsedBioModels.iterator(); iterator.hasNext(); ) {
        KeyValue key = iterator.next();
        bmInfo = bioModelInfoHash.get(key);
        logFilePrintStream.append(" == FAILED TO READ BIOMODEL : " + bmInfo.getVersion().getName() + "; key : " + key.toString() + "\n");
        iterator.remove();
    }
    return;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) BioModelInfo(org.vcell.util.document.BioModelInfo)

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