Search in sources :

Example 21 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo 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)

Example 22 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DbDriver method getVCInfoContainer.

/**
 * Insert the method's description here.
 * Creation date: (9/24/2003 12:54:32 PM)
 * @return cbit.vcell.modeldb.VCInfoContainer
 */
public static VCInfoContainer getVCInfoContainer(User user, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    VCInfoContainer results = null;
    // 
    VCImageInfo[] vcImageInfos = null;
    GeometryInfo[] geometryInfos = null;
    MathModelInfo[] mathModelInfos = null;
    BioModelInfo[] bioModelInfos = null;
    // 
    StringBuffer sql = null;
    String special = null;
    ResultSet rset = null;
    boolean enableSpecial = true;
    boolean enableDistinct = true;
    Statement stmt = con.createStatement();
    try {
        // 
        // BioModelInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + BioModelTable.table.name.getQualifiedColName() + "," + BioModelTable.table.versionBranchID.getQualifiedColName() + "," + BioModelTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(BioModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<BioModelInfo> tempInfos = new ArrayList<BioModelInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                BioModelInfo versionInfo = (BioModelInfo) BioModelTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                bioModelInfos = new BioModelInfo[tempInfos.size()];
                tempInfos.toArray(bioModelInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("BioModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // MathModelInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + MathModelTable.table.name.getQualifiedColName() + "," + MathModelTable.table.versionBranchID.getQualifiedColName() + "," + MathModelTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(MathModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<MathModelInfo> tempInfos = new ArrayList<MathModelInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                MathModelInfo versionInfo = (MathModelInfo) MathModelTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                mathModelInfos = new MathModelInfo[tempInfos.size()];
                tempInfos.toArray(mathModelInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("MathModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // VCImageInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + ImageTable.table.name.getQualifiedColName() + "," + ImageTable.table.versionBranchID.getQualifiedColName() + "," + ImageTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(ImageTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT);
            rset = stmt.executeQuery(sql.toString());
            ArrayList<VCImageInfo> tempInfos = new ArrayList<VCImageInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                VCImageInfo versionInfo = (VCImageInfo) ImageTable.table.getInfo(rset, con, dbSyntax);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                vcImageInfos = new VCImageInfo[tempInfos.size()];
                tempInfos.toArray(vcImageInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("ImageInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
        // 
        // GeometeryInfos
        // 
        {
            double beginTime = System.currentTimeMillis();
            special = " ORDER BY " + GeometryTable.table.name.getQualifiedColName() + "," + GeometryTable.table.versionBranchID.getQualifiedColName() + "," + GeometryTable.table.versionDate.getQualifiedColName();
            sql = new StringBuffer(GeometryTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
            sql.insert(7, Table.SQL_GLOBAL_HINT + (enableDistinct ? "DISTINCT " : ""));
            rset = stmt.executeQuery(sql.toString());
            ArrayList<GeometryInfo> tempInfos = new ArrayList<GeometryInfo>();
            Set<String> distinctV = new HashSet<String>();
            while (rset.next()) {
                GeometryInfo versionInfo = (GeometryInfo) GeometryTable.table.getInfo(rset, con);
                if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
                    tempInfos.add(versionInfo);
                    distinctV.add(versionInfo.getVersion().getVersionKey().toString());
                }
            }
            rset.close();
            if (tempInfos.size() > 0) {
                geometryInfos = new GeometryInfo[tempInfos.size()];
                tempInfos.toArray(geometryInfos);
            }
            if (lg.isInfoEnabled()) {
                lg.info("GeometryInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
            }
        }
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
    results = new VCInfoContainer(user, vcImageInfos, geometryInfos, mathModelInfos, bioModelInfos);
    return results;
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BioModelInfo(org.vcell.util.document.BioModelInfo) ArrayList(java.util.ArrayList) MathModelInfo(org.vcell.util.document.MathModelInfo) VCInfoContainer(org.vcell.util.document.VCInfoContainer) GeometryInfo(cbit.vcell.geometry.GeometryInfo) ResultSet(java.sql.ResultSet) VCImageInfo(cbit.image.VCImageInfo)

Example 23 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class StandaloneRuleBasedTest method main.

public static void main(String[] args) {
    try {
        PropertyLoader.loadProperties();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final int numTrials = 40;
    // 30 seconds
    final long bngTimeoutDurationMS = 30000;
    VCDatabaseVisitor vcDatabaseVisitor = new VCDatabaseVisitor() {

        @Override
        public void visitMathModel(MathModel mathModel, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitGeometry(Geometry geometry, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitBioModel(BioModel bioModel, PrintStream logFilePrintStream) {
            SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
            for (SimulationContext simContext : simulationContexts) {
                if ((simContext.getApplicationType() == Application.NETWORK_STOCHASTIC) && simContext.getGeometry().getDimension() == 0) {
                    File baseDirectory = createDirFile(simContext);
                    try {
                        checkNonspatialStochasticSimContext(simContext, baseDirectory, numTrials, bngTimeoutDurationMS);
                    } catch (Exception e) {
                        e.printStackTrace();
                        if (!e.getMessage().contains("Only Mass Action Kinetics supported ")) {
                            StochtestFileUtils.writeMessageTofile(baseDirectory, e.getMessage());
                        }
                    }
                }
            }
        }

        @Override
        public boolean filterMathModel(MathModelInfo mathModelInfo) {
            return false;
        }

        @Override
        public boolean filterGeometry(GeometryInfo geometryInfo) {
            return false;
        }

        @Override
        public boolean filterBioModel(BioModelInfo bioModelInfo) {
            return // bioModelInfo.getVersion().getName().equals("model");
            bioModelInfo.getVersion().getName().equals("simpleModel_Network_orig");
        }
    };
    String currentUserID = "schaff";
    String[] allUsers = new String[] { /*-all*/
    currentUserID, "-" };
    VCDatabaseScanner.scanBioModels(allUsers, vcDatabaseVisitor, false);
}
Also used : PrintStream(java.io.PrintStream) MathModel(cbit.vcell.mathmodel.MathModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) BioModel(cbit.vcell.biomodel.BioModel) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCDatabaseVisitor(cbit.vcell.modeldb.VCDatabaseVisitor) File(java.io.File)

Example 24 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo 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) MatrixException(cbit.vcell.matrix.MatrixException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) ModelException(cbit.vcell.model.ModelException) DataFormatException(java.util.zip.DataFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) 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)

Example 25 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DatabaseWindowManager method compareLatestEdition.

/**
 * Comment
 */
public void compareLatestEdition() {
    // 
    if (getPanelSelection() == null) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : No first document selected");
        return;
    }
    VCDocumentInfo thisDocumentInfo = getPanelSelection();
    // 
    // Get the latest version of the documentInfo
    // 
    VCDocumentInfo[] documentVersionsList = null;
    try {
        documentVersionsList = getDocumentVersionDates(thisDocumentInfo);
    } catch (DataAccessException e) {
        PopupGenerator.showErrorDialog(this, "Error accessing second document!");
    }
    if (documentVersionsList == null || documentVersionsList.length == 0) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : Not Enough Versions to Compare!");
        return;
    }
    // 
    // Obtaining the latest version of the current documentInfo
    // 
    VCDocumentInfo latestDocumentInfo = documentVersionsList[documentVersionsList.length - 1];
    for (int i = 0; i < documentVersionsList.length; i++) {
        if (documentVersionsList[i].getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
            latestDocumentInfo = documentVersionsList[i];
        }
    }
    if (thisDocumentInfo.getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
        PopupGenerator.showErrorDialog(this, "Current Version is the latest! Choose another Version or Model to compare!");
        return;
    }
    // Check if both document types are of the same kind. If not, throw an error.
    if (((thisDocumentInfo instanceof BioModelInfo) && !(latestDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(latestDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(latestDocumentInfo instanceof GeometryInfo))) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : The two documents are not of the same type!");
        return;
    }
    // 
    // Now that we have both the document versions to be compared, do the comparison and display the result
    // 
    compareWithOther(latestDocumentInfo, thisDocumentInfo);
}
Also used : VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

GeometryInfo (cbit.vcell.geometry.GeometryInfo)47 BioModelInfo (org.vcell.util.document.BioModelInfo)27 MathModelInfo (org.vcell.util.document.MathModelInfo)27 DataAccessException (org.vcell.util.DataAccessException)19 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)11 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 Hashtable (java.util.Hashtable)8 Geometry (cbit.vcell.geometry.Geometry)7 VCImageInfo (cbit.image.VCImageInfo)6 BioModel (cbit.vcell.biomodel.BioModel)6 User (org.vcell.util.document.User)6 VersionInfo (org.vcell.util.document.VersionInfo)6 CSGObject (cbit.vcell.geometry.CSGObject)5 SimulationContext (cbit.vcell.mapping.SimulationContext)5 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)5 Vector (java.util.Vector)5 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)5 ImageException (cbit.image.ImageException)4 DocumentManager (cbit.vcell.clientdb.DocumentManager)4 GeometryException (cbit.vcell.geometry.GeometryException)4