Search in sources :

Example 36 with VCDocument

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

the class ClientRequestManager method revertToSaved.

/**
 * Insert the method's description here.
 * Creation date: (6/9/2004 1:07:09 PM)
 * @param vcDocument cbit.vcell.document.VCDocument
 */
public void revertToSaved(DocumentWindowManager documentWindowManager) {
    // make the info
    VCDocument document = documentWindowManager.getVCDocument();
    VCDocumentInfo info = null;
    try {
        KeyValue versionKey = document.getVersion().getVersionKey();
        switch(document.getDocumentType()) {
            case BIOMODEL_DOC:
                {
                    info = getDocumentManager().getBioModelInfo(versionKey);
                    break;
                }
            case MATHMODEL_DOC:
                {
                    info = getDocumentManager().getMathModelInfo(versionKey);
                    break;
                }
            case GEOMETRY_DOC:
                {
                    info = getDocumentManager().getGeometryInfo(versionKey);
                    break;
                }
        }
    } catch (DataAccessException e) {
        e.printStackTrace(System.out);
        throw new RuntimeException(e.getMessage());
    }
    // reload and reset into same window
    openAfterChecking(info, documentWindowManager, false);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) VCDocument(org.vcell.util.document.VCDocument) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 37 with VCDocument

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

the class ClientRequestManager method compareWithOther.

/**
 * Processes the model comparison request.
 * Creation date: (6/9/2004 1:07:09 PM)
 * @param vcDocument cbit.vcell.document.VCDocument
 */
public XmlTreeDiff compareWithOther(final VCDocumentInfo docInfo1, final VCDocumentInfo docInfo2) {
    VCDocument document1, document2;
    try {
        // get the VCDocument versions from documentManager
        if (docInfo1 instanceof BioModelInfo && docInfo2 instanceof BioModelInfo) {
            document1 = getDocumentManager().getBioModel((BioModelInfo) docInfo1);
            document2 = getDocumentManager().getBioModel((BioModelInfo) docInfo2);
        } else if (docInfo1 instanceof MathModelInfo && docInfo2 instanceof MathModelInfo) {
            document1 = getDocumentManager().getMathModel((MathModelInfo) docInfo1);
            document2 = getDocumentManager().getMathModel((MathModelInfo) docInfo2);
        } else if (docInfo1 instanceof GeometryInfo && docInfo2 instanceof GeometryInfo) {
            document1 = getDocumentManager().getGeometry((GeometryInfo) docInfo1);
            document2 = getDocumentManager().getGeometry((GeometryInfo) docInfo2);
        } else {
            throw new IllegalArgumentException("The two documents are invalid or of different types.");
        }
        return compareDocuments(document1, document2, DiffConfiguration.COMPARE_DOCS_OTHER);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException)

Example 38 with VCDocument

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

the class ClientRequestManager method getOpenDesktopDocumentInfos.

public OpenModelInfoHolder[] getOpenDesktopDocumentInfos(boolean bIncludeSimulations) throws DataAccessException {
    Vector<OpenModelInfoHolder> simInfoHolderV = new Vector<OpenModelInfoHolder>();
    for (TopLevelWindowManager tlwm : getMdiManager().getWindowManagers()) {
        if (tlwm instanceof DocumentWindowManager) {
            DocumentWindowManager dwm = (DocumentWindowManager) tlwm;
            VCDocument vcDoc = dwm.getVCDocument();
            // if(vcDoc.getVersion() != null){
            if (vcDoc.getDocumentType() == VCDocumentType.BIOMODEL_DOC) {
                BioModel bioModel = (BioModel) vcDoc;
                // getDocumentManager().getBioModel(vcDoc.getVersion().getVersionKey());
                SimulationContext[] simContexts = bioModel.getSimulationContexts();
                for (int i = 0; i < simContexts.length; i += 1) {
                    if (bIncludeSimulations) {
                        if (simContexts[i].getGeometry() == null) {
                            throw new DataAccessException("Error gathering document info (isCompartmental check failed):\nOpen BioModel document " + bioModel.getName() + " has no Geometry");
                        }
                        Simulation[] sims = simContexts[i].getSimulations();
                        for (int j = 0; j < sims.length; j += 1) {
                            for (int k = 0; k < sims[j].getScanCount(); k += 1) {
                                FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimBioModelInfo(sims[j].getName(), bioModel.getVersion(), simContexts[i], sims[j].getSimulationInfo(), k, // !sims[j].getSolverTaskDescription().getSolverDescription().hasVariableTimestep(),
                                simContexts[i].getGeometry().getDimension() == 0);
                                simInfoHolderV.add(simInfoHolder);
                            }
                        }
                    } else {
                        FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimBioModelInfo(null, bioModel.getVersion(), simContexts[i], null, -1, simContexts[i].getGeometry().getDimension() == 0);
                        simInfoHolderV.add(simInfoHolder);
                    }
                }
            } else if (vcDoc.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
                MathModel mathModel = (MathModel) vcDoc;
                // getDocumentManager().getMathModel(vcDoc.getVersion().getVersionKey());
                if (bIncludeSimulations) {
                    if (mathModel.getMathDescription() == null || mathModel.getMathDescription().getGeometry() == null) {
                        throw new DataAccessException("Error gathering document info (isCompartmental check failed):\nOpen MathModel document " + mathModel.getName() + " has either no MathDescription or no Geometry");
                    }
                    Simulation[] sims = mathModel.getSimulations();
                    for (int i = 0; i < sims.length; i += 1) {
                        for (int k = 0; k < sims[i].getScanCount(); k += 1) {
                            FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimMathModelInfo(sims[i].getName(), mathModel.getVersion(), mathModel.getMathDescription(), sims[i].getSimulationInfo(), k, // !sims[i].getSolverTaskDescription().getSolverDescription().hasVariableTimestep(),
                            mathModel.getMathDescription().getGeometry().getDimension() == 0);
                            simInfoHolderV.add(simInfoHolder);
                        }
                    }
                } else {
                    FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimMathModelInfo(null, mathModel.getVersion(), mathModel.getMathDescription(), null, -1, mathModel.getMathDescription().getGeometry().getDimension() == 0);
                    simInfoHolderV.add(simInfoHolder);
                }
            }
        // }
        }
    }
    OpenModelInfoHolder[] simInfoHolderArr = new OpenModelInfoHolder[simInfoHolderV.size()];
    simInfoHolderV.copyInto(simInfoHolderArr);
    return simInfoHolderArr;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) OpenModelInfoHolder(cbit.vcell.client.TopLevelWindowManager.OpenModelInfoHolder) SimulationContext(cbit.vcell.mapping.SimulationContext) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

VCDocument (org.vcell.util.document.VCDocument)38 BioModel (cbit.vcell.biomodel.BioModel)14 MathModel (cbit.vcell.mathmodel.MathModel)11 UserCancelException (org.vcell.util.UserCancelException)11 Simulation (cbit.vcell.solver.Simulation)10 DataAccessException (org.vcell.util.DataAccessException)10 DocumentWindowManager (cbit.vcell.client.DocumentWindowManager)9 IOException (java.io.IOException)9 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)8 PropertyVetoException (java.beans.PropertyVetoException)7 File (java.io.File)7 DocumentManager (cbit.vcell.clientdb.DocumentManager)6 Geometry (cbit.vcell.geometry.Geometry)6 SimulationContext (cbit.vcell.mapping.SimulationContext)6 UtilCancelException (org.vcell.util.UtilCancelException)6 ImageException (cbit.image.ImageException)5 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 GeometryException (cbit.vcell.geometry.GeometryException)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 Hashtable (java.util.Hashtable)5