Search in sources :

Example 66 with BioModelInfo

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

the class BioModelDbTreePanel method treeSelection.

/**
 * Comment
 */
protected void treeSelection() {
    TreePath treePath = getJTree1().getSelectionPath();
    if (treePath == null) {
        setSelectedVersionInfo(null);
        return;
    }
    BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
    Object object = bioModelNode.getUserObject();
    if (object instanceof BioModelInfo) {
        setSelectedVersionInfo((VersionInfo) object);
    } else if (object instanceof VCDocumentInfoNode && bioModelNode.getChildCount() > 0 && ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
        BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject();
        setSelectedVersionInfo(bioModelInfo);
    } else if (object instanceof BioModelMetaData) {
        BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) bioModelNode.getParent()).getUserObject();
        setSelectedVersionInfo(bioModelInfo);
    } else {
        setSelectedVersionInfo(null);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) BioModelInfo(org.vcell.util.document.BioModelInfo) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) BioModelMetaData(cbit.vcell.biomodel.BioModelMetaData)

Example 67 with BioModelInfo

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

the class BioModelInfoTreeModel 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) {
    if (bioModelInfo == fieldBioModelInfo) {
        return;
    }
    BioModelInfo oldValue = fieldBioModelInfo;
    fieldBioModelInfo = bioModelInfo;
    firePropertyChange("bioModelInfo", oldValue, bioModelInfo);
    refreshTree();
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo)

Example 68 with BioModelInfo

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

the class ClientRequestManager method createNewDocument.

/**
 * Insert the method's description here.
 * Creation date: (5/10/2004 3:48:16 PM)
 */
public AsynchClientTask[] createNewDocument(final TopLevelWindowManager requester, final VCDocument.DocumentCreationInfo documentCreationInfo) {
    // throws UserCancelException, Exception {
    /* asynchronous and not blocking any window */
    AsynchClientTask[] taskArray = null;
    final int createOption = documentCreationInfo.getOption();
    switch(documentCreationInfo.getDocumentType()) {
        case BIOMODEL_DOC:
            {
                AsynchClientTask task1 = new AsynchClientTask("creating biomodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                    @Override
                    public void run(Hashtable<String, Object> hashTable) throws Exception {
                        BioModel bioModel = createDefaultBioModelDocument(null);
                        hashTable.put("doc", bioModel);
                    }
                };
                taskArray = new AsynchClientTask[] { task1 };
                break;
            }
        case MATHMODEL_DOC:
            {
                if ((createOption == VCDocument.MATH_OPTION_NONSPATIAL) || (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS)) {
                    AsynchClientTask task2 = new AsynchClientTask("creating mathmodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = null;
                            if (createOption == VCDocument.MATH_OPTION_NONSPATIAL) {
                                geometry = new Geometry("Untitled", 0);
                            } else {
                                geometry = (Geometry) hashTable.get(GEOMETRY_KEY);
                            }
                            MathModel mathModel = createMathModel("Untitled", geometry);
                            mathModel.setName("MathModel" + (getMdiManager().getNumCreatedDocumentWindows() + 1));
                            hashTable.put("doc", mathModel);
                        }
                    };
                    if (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS) {
                        AsynchClientTask task1 = createSelectDocTask(requester);
                        AsynchClientTask task1b = createSelectLoadGeomTask(requester);
                        taskArray = new AsynchClientTask[] { task1, task1b, task2 };
                    } else {
                        taskArray = new AsynchClientTask[] { task2 };
                    }
                    break;
                } else if (createOption == VCDocument.MATH_OPTION_FROMBIOMODELAPP) {
                    AsynchClientTask task1 = new AsynchClientTask("select biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            // spatial or non-spatial
                            BioModelInfo bioModelInfo = (BioModelInfo) DialogUtils.getDBTreePanelSelection(requester.getComponent(), getMdiManager().getDatabaseWindowManager().getBioModelDbTreePanel(), "Open", "Select BioModel");
                            if (bioModelInfo != null) {
                                // may throw UserCancelException
                                hashTable.put("bioModelInfo", bioModelInfo);
                            }
                        }
                    };
                    AsynchClientTask task2 = new AsynchClientTask("find sim contexts in biomodel application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            // spatial or non-spatial
                            // Get the simContexts in the corresponding BioModel
                            BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
                            SimulationContext[] simContexts = getDocumentManager().getBioModel(bioModelInfo).getSimulationContexts();
                            if (simContexts != null) {
                                // may throw UserCancelException
                                hashTable.put("simContexts", simContexts);
                            }
                        }
                    };
                    AsynchClientTask task3 = new AsynchClientTask("create math model from biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            SimulationContext[] simContexts = (SimulationContext[]) hashTable.get("simContexts");
                            String[] simContextNames = new String[simContexts.length];
                            if (simContextNames.length == 0) {
                                throw new RuntimeException("no application is available");
                            } else {
                                for (int i = 0; i < simContexts.length; i++) {
                                    simContextNames[i] = simContexts[i].getName();
                                }
                                Component component = requester.getComponent();
                                // Get the simContext names, so that user can choose which simContext math to import
                                String simContextChoice = (String) PopupGenerator.showListDialog(component, simContextNames, "Please select Application");
                                if (simContextChoice == null) {
                                    throw UserCancelException.CANCEL_DB_SELECTION;
                                }
                                SimulationContext chosenSimContext = null;
                                for (int i = 0; i < simContexts.length; i++) {
                                    if (simContexts[i].getName().equals(simContextChoice)) {
                                        chosenSimContext = simContexts[i];
                                        break;
                                    }
                                }
                                Objects.requireNonNull(chosenSimContext);
                                BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
                                // Get corresponding mathDesc to create new mathModel and return.
                                String newName = bioModelInfo.getVersion().getName() + "_" + chosenSimContext.getName();
                                MathDescription bioMathDesc = chosenSimContext.getMathDescription();
                                MathDescription newMathDesc = null;
                                newMathDesc = new MathDescription(newName + "_" + (new Random()).nextInt());
                                newMathDesc.setGeometry(bioMathDesc.getGeometry());
                                newMathDesc.read_database(new CommentStringTokenizer(bioMathDesc.getVCML_database()));
                                newMathDesc.isValid();
                                MathModel newMathModel = new MathModel(null);
                                newMathModel.setName(newName);
                                newMathModel.setMathDescription(newMathDesc);
                                hashTable.put("doc", newMathModel);
                            }
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1, task2, task3 };
                    break;
                } else {
                    throw new RuntimeException("Unknown MathModel Document creation option value=" + documentCreationInfo.getOption());
                }
            }
        case GEOMETRY_DOC:
            {
                if (createOption == VCDocument.GEOM_OPTION_1D || createOption == VCDocument.GEOM_OPTION_2D || createOption == VCDocument.GEOM_OPTION_3D) {
                    // analytic
                    AsynchClientTask task1 = new AsynchClientTask("creating analytic geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), documentCreationInfo.getOption());
                            geometry.getGeometrySpec().addSubVolume(new AnalyticSubVolume("subdomain0", new Expression(1.0)));
                            geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
                            hashTable.put("doc", geometry);
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1 };
                    break;
                }
                if (createOption == VCDocument.GEOM_OPTION_CSGEOMETRY_3D) {
                    // constructed solid geometry
                    AsynchClientTask task1 = new AsynchClientTask("creating constructed solid geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                        @Override
                        public void run(Hashtable<String, Object> hashTable) throws Exception {
                            Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), 3);
                            Extent extent = geometry.getExtent();
                            if (extent != null) {
                                // create a CSGPrimitive of type cube and scale it to the 'extent' components. Use this as the default or background CSGObject (subdomain).
                                // This can be considered as the equivalent of subdomain (with expression) 1.0 for analyticSubvolume.
                                // basic cube
                                CSGPrimitive cube = new CSGPrimitive("cube", CSGPrimitive.PrimitiveType.CUBE);
                                // scaled cube
                                double x = extent.getX();
                                double y = extent.getY();
                                double z = extent.getZ();
                                CSGScale scaledCube = new CSGScale("scale", new Vect3d(x / 2.0, y / 2.0, z / 2.0));
                                scaledCube.setChild(cube);
                                // translated scaled cube
                                CSGTranslation translatedScaledCube = new CSGTranslation("translation", new Vect3d(x / 2, y / 2, z / 2));
                                translatedScaledCube.setChild(scaledCube);
                                CSGObject csgObject = new CSGObject(null, "subdomain0", 0);
                                csgObject.setRoot(translatedScaledCube);
                                geometry.getGeometrySpec().addSubVolume(csgObject, false);
                                geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
                                hashTable.put("doc", geometry);
                            }
                        }
                    };
                    taskArray = new AsynchClientTask[] { task1 };
                    break;
                } else {
                    throw new RuntimeException("Unknown Geometry Document creation option value=" + documentCreationInfo.getOption());
                }
            }
        default:
            {
                throw new RuntimeException("Unknown default document type: " + documentCreationInfo.getDocumentType());
            }
    }
    return taskArray;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) MathModel(cbit.vcell.mathmodel.MathModel) SetMathDescription(cbit.vcell.client.task.SetMathDescription) MathDescription(cbit.vcell.math.MathDescription) Extent(org.vcell.util.Extent) CSGPrimitive(cbit.vcell.geometry.CSGPrimitive) CSGScale(cbit.vcell.geometry.CSGScale) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) Random(java.util.Random) Component(java.awt.Component) CSGObject(cbit.vcell.geometry.CSGObject) CSGTranslation(cbit.vcell.geometry.CSGTranslation) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) 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) Vect3d(cbit.vcell.render.Vect3d) Geometry(cbit.vcell.geometry.Geometry) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) CommentStringTokenizer(org.vcell.util.CommentStringTokenizer) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 69 with BioModelInfo

use of org.vcell.util.document.BioModelInfo 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 70 with BioModelInfo

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

the class ClientRequestManager method getGeometryFromDocumentSelection.

public Geometry getGeometryFromDocumentSelection(Component parentComponent, VCDocumentInfo vcDocumentInfo, boolean bClearVersion) throws Exception, UserCancelException {
    Geometry geom = null;
    if (vcDocumentInfo.getVersionType().equals(VersionableType.BioModelMetaData)) /*documentType == VCDocument.BIOMODEL_DOC*/
    {
        BioModelInfo bioModelInfo = getDocumentManager().getBioModelInfo(vcDocumentInfo.getVersion().getVersionKey());
        BioModelChildSummary bioModelChildSummary = bioModelInfo.getBioModelChildSummary();
        if (bioModelChildSummary != null && bioModelChildSummary.getSimulationContextNames() != null) {
            Vector<Integer> spatialV = new Vector<Integer>();
            for (int i = 0; i < bioModelChildSummary.getSimulationContextNames().length; i++) {
                if (bioModelChildSummary.getGeometryDimensions()[i] > 0) {
                    spatialV.add(i);
                }
            }
            if (spatialV.size() > 0) {
                String[] columnNames = new String[] { "Application", "Geometry", "Dimension" };
                String[][] rowData = new String[spatialV.size()][3];
                for (int i = 0; i < spatialV.size(); i++) {
                    rowData[i][0] = bioModelChildSummary.getSimulationContextNames()[spatialV.elementAt(i)];
                    rowData[i][1] = bioModelChildSummary.getGeometryNames()[spatialV.elementAt(i)];
                    rowData[i][2] = bioModelChildSummary.getGeometryDimensions()[spatialV.elementAt(i)] + "";
                }
                int[] selection = DialogUtils.showComponentOKCancelTableList(JOptionPane.getFrameForComponent(parentComponent), "Select Geometry", columnNames, rowData, ListSelectionModel.SINGLE_SELECTION);
                ModelGeometryOPResults modelGeometryOPResults = (ModelGeometryOPResults) getDocumentManager().getSessionManager().getUserMetaDbServer().doTestSuiteOP(new ModelGeometryOP((BioModelInfo) vcDocumentInfo, rowData[selection[0]][0]));
                geom = getDocumentManager().getGeometry(modelGeometryOPResults.getGeometryKey());
            // BioModel bioModel = getDocumentManager().getBioModel((BioModelInfo)vcDocumentInfo);
            // for (int i = 0; i < bioModel.getSimulationContexts().length; i++) {
            // if(bioModel.getSimulationContexts()[i].getName().equals(rowData[selection[0]][0])){
            // geom = bioModel.getSimulationContexts()[i].getGeometry();
            // break;
            // }
            // }
            } else {
                throw new Exception("BioModel '" + bioModelInfo.getVersion().getName() + "' contains no spatial geometries.");
            }
        } else {
            throw new Exception("BioModel '" + bioModelInfo.getVersion().getName() + "' contains no spatial geometries.");
        }
    } else if (vcDocumentInfo.getVersionType().equals(VersionableType.MathModelMetaData)) /*documentType == VCDocument.MATHMODEL_DOC*/
    {
        MathModelInfo mathModelInfo = getDocumentManager().getMathModelInfo(vcDocumentInfo.getVersion().getVersionKey());
        MathModelChildSummary mathModelChildSummary = mathModelInfo.getMathModelChildSummary();
        if (mathModelChildSummary != null) {
            if (mathModelChildSummary.getGeometryDimension() > 0) {
                ModelGeometryOPResults modelGeometryOPResults = (ModelGeometryOPResults) getDocumentManager().getSessionManager().getUserMetaDbServer().doTestSuiteOP(new ModelGeometryOP((MathModelInfo) vcDocumentInfo));
                geom = getDocumentManager().getGeometry(modelGeometryOPResults.getGeometryKey());
            // MathModel mathModel = getDocumentManager().getMathModel(mathModelInfo);
            // geom = mathModel.getMathDescription().getGeometry();
            } else {
                throw new Exception("MathModel '" + mathModelInfo.getVersion().getName() + "' contains no spatial geometry.");
            }
        } else {
            throw new Exception("MathModel '" + mathModelInfo.getVersion().getName() + "' contains no spatial geometry.");
        }
    } else if (vcDocumentInfo.getVersionType().equals(VersionableType.Geometry)) {
        geom = getDocumentManager().getGeometry((GeometryInfo) vcDocumentInfo);
        if (geom.getDimension() == 0) {
            throw new Exception("Error, Only spatial geometries allowed (dimension > 0).");
        }
    } else {
        throw new IllegalArgumentException("Error selecting geometry from document type " + vcDocumentInfo.getVersionType() + ". Must be BioModel,MathModel or Geometry.");
    }
    if (geom == null) {
        throw new Exception("error selecting geometry");
    }
    if (bClearVersion) {
        geom.clearVersion();
    }
    return geom;
}
Also used : BioModelChildSummary(org.vcell.util.document.BioModelChildSummary) BioModelInfo(org.vcell.util.document.BioModelInfo) 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) Geometry(cbit.vcell.geometry.Geometry) MathModelChildSummary(org.vcell.util.document.MathModelChildSummary) GeometryInfo(cbit.vcell.geometry.GeometryInfo) ModelGeometryOPResults(cbit.vcell.numericstest.ModelGeometryOPResults) Vector(java.util.Vector) ModelGeometryOP(cbit.vcell.numericstest.ModelGeometryOP)

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