Search in sources :

Example 31 with MathModelInfo

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

the class DatabaseServerImpl method getVersionInfos.

/**
 * This method was created in VisualAge.
 * @return GeometryInfo
 * @param key KeyValue
 * @exception org.vcell.util.DataAccessException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
private VersionInfo[] getVersionInfos(User user, KeyValue key, VersionableType vType, boolean bAll, boolean bCheckPermission) throws DataAccessException {
    try {
        if (lg.isTraceEnabled())
            lg.trace("DatabaseServerImpl.getVersionInfos(User=" + user + ",vType=" + vType + ",bAll=" + bAll + ")");
        Vector<VersionInfo> vector = dbTop.getVersionableInfos(user, key, vType, bAll, bCheckPermission, true);
        if (vType.equals(VersionableType.BioModelMetaData)) {
            BioModelInfo[] bioModelInfos = new BioModelInfo[vector.size()];
            vector.copyInto(bioModelInfos);
            return bioModelInfos;
        } else if (vType.equals(VersionableType.Geometry)) {
            GeometryInfo[] geoInfos = new GeometryInfo[vector.size()];
            vector.copyInto(geoInfos);
            return geoInfos;
        } else if (vType.equals(VersionableType.MathModelMetaData)) {
            MathModelInfo[] mathInfos = new MathModelInfo[vector.size()];
            vector.copyInto(mathInfos);
            return mathInfos;
        } else if (vType.equals(VersionableType.VCImage)) {
            VCImageInfo[] imgInfos = new VCImageInfo[vector.size()];
            vector.copyInto(imgInfos);
            return imgInfos;
        } else if (vType.equals(VersionableType.Simulation)) {
            SimulationInfo[] simInfos = new SimulationInfo[vector.size()];
            vector.copyInto(simInfos);
            return simInfos;
        } else {
            throw new IllegalArgumentException("Wrong VersinableType vType:" + vType);
        }
    } catch (SQLException e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    } catch (ObjectNotFoundException e) {
        lg.error(e.getMessage(), e);
        throw new ObjectNotFoundException(e.getMessage());
    } catch (Throwable e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : SQLException(java.sql.SQLException) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VersionInfo(org.vcell.util.document.VersionInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 32 with MathModelInfo

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

the class DbDriver method curate.

/**
 * Insert the method's description here.
 * Creation date: (5/23/2006 10:44:52 AM)
 */
public static VCDocumentInfo curate(CurateSpec curateSpec, Connection con, User user, DatabaseSyntax dbSyntax) throws DataAccessException, SQLException {
    VersionableType vType = null;
    if (curateSpec.getVCDocumentInfo() instanceof BioModelInfo) {
        vType = VersionableType.BioModelMetaData;
    } else if (curateSpec.getVCDocumentInfo() instanceof MathModelInfo) {
        vType = VersionableType.MathModelMetaData;
    } else {
        throw new DataAccessException("Expecting BioModelInfo or MathModelInfo but got type=" + curateSpec.getVCDocumentInfo().getClass().getName());
    }
    KeyValue vKey = curateSpec.getVCDocumentInfo().getVersion().getVersionKey();
    Version dbVersion = getVersionFromKeyValue(con, vType, vKey);
    // Must be owner to curate
    if (!dbVersion.getOwner().compareEqual(user)) {
        throw new PermissionException("Cannot curate " + vType.getTypeName() + " \"" + dbVersion.getName() + "\" (" + vKey + "), not owned by " + user.getName());
    }
    VersionFlag updatedVersionFlag = null;
    if (curateSpec.getCurateType() == CurateSpec.ARCHIVE) {
        if (!dbVersion.getFlag().compareEqual(VersionFlag.Current)) {
            throw new IllegalArgumentException("Only non-archived, non-published documents can be ARCHIVED");
        }
        updatedVersionFlag = VersionFlag.Archived;
    } else if (curateSpec.getCurateType() == CurateSpec.PUBLISH) {
        // Must have PUBLISH rights
        if (!dbVersion.getOwner().isPublisher()) {
            throw new PermissionException("Cannot curate " + vType.getTypeName() + " \"" + dbVersion.getName() + "\" (" + vKey + "), user " + user.getName() + " not granted PUBLISHING rights");
        }
        // Must be ARCHIVED and Public before PUBLISH is allowed
        if (!dbVersion.getFlag().compareEqual(VersionFlag.Archived) || !(dbVersion.getGroupAccess() instanceof GroupAccessAll)) {
            throw new IllegalArgumentException("Only ARCHIVED documents with PUBLIC permission can be PUBLISHED");
        }
        updatedVersionFlag = VersionFlag.Published;
    } else {
        throw new DataAccessException("Expecting CurateType " + CurateSpec.ARCHIVE + "(ARCHIVE) or " + CurateSpec.PUBLISH + "(PUBLISH) but got type=" + curateSpec.getCurateType());
    }
    VersionTable vTable = VersionTable.getVersionTable(vType);
    String set = vTable.versionFlag.getQualifiedColName() + " = " + updatedVersionFlag.getIntValue();
    String cond = vTable.id.getQualifiedColName() + " = " + vKey;
    String sql = DatabasePolicySQL.enforceOwnershipUpdate(user, vTable, set, cond);
    int numRowsProcessed = updateCleanSQL(con, sql);
    // Clear XML
    if (vType.equals(VersionableType.BioModelMetaData)) {
        updateCleanSQL(con, "DELETE FROM " + BioModelXMLTable.table.getTableName() + " WHERE " + BioModelXMLTable.table.bioModelRef.getQualifiedColName() + " = " + vKey.toString());
    } else if (vType.equals(VersionableType.MathModelMetaData)) {
        updateCleanSQL(con, "DELETE FROM " + MathModelXMLTable.table.getTableName() + " WHERE " + MathModelXMLTable.table.mathModelRef.getQualifiedColName() + " = " + vKey.toString());
    }
    VCDocumentInfo dbVCDocumentInfo = (VCDocumentInfo) getVersionableInfos(con, user, vType, false, vKey, false, dbSyntax).elementAt(0);
    return dbVCDocumentInfo;
}
Also used : PermissionException(org.vcell.util.PermissionException) KeyValue(org.vcell.util.document.KeyValue) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VersionableType(org.vcell.util.document.VersionableType) VersionFlag(org.vcell.util.document.VersionFlag) GroupAccessAll(org.vcell.util.document.GroupAccessAll) Version(org.vcell.util.document.Version) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 33 with MathModelInfo

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

the class VCComprehensiveStatistics method collectMathModelStats.

private void collectMathModelStats(long startDateInMs, long endDateInMs) throws DataAccessException {
    retrieveUsers();
    for (User user : userList) {
        if (!userConstraintList.contains(user.getName())) {
            continue;
        }
        if (!internalDeveloper.contains(user.getName())) {
            boolean bInternal = internalUsers.contains(user.getName());
            ModelStat modelStat = mathModelStats[bInternal ? 0 : 1];
            MathModelInfo[] mathModelInfos = dbServerImpl.getMathModelInfos(user, false);
            for (MathModelInfo mmi : mathModelInfos) {
                Date createDate = mmi.getVersion().getDate();
                long t = createDate.getTime();
                // }
                if (t < startDateInMs || t > endDateInMs) {
                    continue;
                }
                // modelStat.count_model ++;
                try {
                    BigString mathModelXML = dbServerImpl.getMathModelXML(user, mmi.getVersion().getVersionKey());
                    MathModel mathModel = (MathModel) waitForModel(mathModelXML, true);
                    if (mathModel == null) {
                        System.out.println("----------          Skipped MathModel " + mmi.getVersion() + "          ----------");
                        continue;
                    }
                    modelStat.count_model++;
                    boolean bHasCompletedSim = false;
                    for (Simulation sim : mathModel.getSimulations()) {
                        SimulationStatusPersistent ss = dbServerImpl.getSimulationStatus(sim.getKey());
                        for (int scan = 0; scan < sim.getScanCount(); scan++) {
                            SimulationJobStatusPersistent jobStatus = ss.getJobStatus(scan);
                            if (jobStatus != null) {
                                if (jobStatus.getSchedulerStatus() == SchedulerStatus.COMPLETED) {
                                    bHasCompletedSim = true;
                                    long elapsed = jobStatus.getEndDate().getTime() - jobStatus.getStartDate().getTime();
                                    if (elapsed < 2 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[0]++;
                                    } else if (elapsed < 5 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[1]++;
                                    } else if (elapsed < 20 * MINUTE_IN_MS) {
                                        modelStat.runningTimeHistogram[2]++;
                                    } else if (elapsed < HOUR_IN_MS) {
                                        modelStat.runningTimeHistogram[3]++;
                                    } else if (elapsed < DAY_IN_MS) {
                                        modelStat.runningTimeHistogram[4]++;
                                    } else {
                                        modelStat.runningTimeHistogram[5]++;
                                    }
                                }
                                int dimension = sim.getMathDescription().getGeometry().getDimension();
                                modelStat.count_geoDimSim[dimension]++;
                                if (sim.getMathDescription().isNonSpatialStoch()) {
                                    modelStat.count_sim_stochastic++;
                                } else {
                                    modelStat.count_sim_deterministic++;
                                }
                                if (dimension > 0) {
                                    if (sim.getSolverTaskDescription().getSolverDescription().isSemiImplicitPdeSolver()) {
                                        modelStat.count_semiSim++;
                                    } else {
                                        modelStat.count_fullySim++;
                                    }
                                }
                            }
                        }
                    }
                    if (bHasCompletedSim) {
                        modelStat.count_model_simcomplete++;
                    }
                } catch (Exception e2) {
                    e2.printStackTrace(System.out);
                }
            }
        }
    }
    itemCount++;
    statOutputPW.println(itemCount + ". MathModel Statistics ");
    statOutputPW.println("====================================================");
    for (ModelStat modelStat : mathModelStats) {
        statOutputPW.println("\t" + modelStat.title);
        statOutputPW.println("========================================");
        statOutputPW.println("number of mathmodels saved :\t" + modelStat.count_model);
        statOutputPW.println("number of mathmodels that has at least 1 completed simulation :\t" + modelStat.count_model_simcomplete);
        statOutputPW.println();
        statOutputPW.println("Simulation statistics (including all simulations (stopped, failed, completed) :");
        statOutputPW.println("number of run simulation ODE :\t" + modelStat.count_geoDimSim[0]);
        statOutputPW.println("number of run simulation 1D :\t" + modelStat.count_geoDimSim[1]);
        statOutputPW.println("number of run simulation 2D :\t" + modelStat.count_geoDimSim[2]);
        statOutputPW.println("number of run simulation 3D :\t" + modelStat.count_geoDimSim[3]);
        statOutputPW.println("number of run simulation Semi-Implicit :\t" + modelStat.count_semiSim);
        statOutputPW.println("number of run simulation Fully-Implicit :\t" + modelStat.count_fullySim);
        statOutputPW.println("number of run simulation stochastic :\t" + modelStat.count_sim_stochastic);
        statOutputPW.println("number of run simulation deterministic :\t" + modelStat.count_sim_deterministic);
        statOutputPW.println();
        statOutputPW.println("Running time histogram for completed simulations only:");
        statOutputPW.println("0 ~ 2min:\t" + modelStat.runningTimeHistogram[0]);
        statOutputPW.println("2 ~ 5min:\t" + modelStat.runningTimeHistogram[1]);
        statOutputPW.println("5 ~ 20min:\t" + modelStat.runningTimeHistogram[2]);
        statOutputPW.println("20min ~ 1hr:\t" + modelStat.runningTimeHistogram[3]);
        statOutputPW.println("1hr ~ 1day:\t" + modelStat.runningTimeHistogram[4]);
        statOutputPW.println(">1day:\t" + modelStat.runningTimeHistogram[5]);
        statOutputPW.println();
        statOutputPW.println();
        statOutputPW.flush();
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) BigString(org.vcell.util.BigString) Date(java.util.Date) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) Simulation(cbit.vcell.solver.Simulation)

Example 34 with MathModelInfo

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

the class VCDatabaseScanner method scanMathModels.

public void scanMathModels(VCDatabaseVisitor databaseVisitor, PrintStream logFilePrintStream, User[] users, KeyValue singleMathmodelKey, HashSet<KeyValue> includeHash, HashSet<KeyValue> excludeHash, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
    BadMathVisitor badMathVisitor = null;
    if (databaseVisitor instanceof BadMathVisitor) {
        badMathVisitor = (BadMathVisitor) databaseVisitor;
    }
    final boolean isBadMathVisitor = badMathVisitor != null;
    if (users == null) {
        users = getAllUsers();
    }
    try {
        // start visiting models and writing log
        logFilePrintStream.println("Start scanning mathmodels ......");
        logFilePrintStream.println("\n");
        for (int i = 0; i < users.length; i++) {
            User user = users[i];
            MathModelInfo[] mathInfos = dbServerImpl.getMathModelInfos(user, false);
            for (int j = 0; j < mathInfos.length; j++) {
                if (singleMathmodelKey != null && !mathInfos[j].getVersion().getVersionKey().compareEqual(singleMathmodelKey)) {
                    System.out.println("skipping geometry, not the single one that we wanted");
                    continue;
                }
                if (excludeHash != null && excludeHash.contains(mathInfos[j].getVersion().getVersionKey())) {
                    System.out.println("skipping geometry with key '" + mathInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (includeHash != null && !includeHash.contains(mathInfos[j].getVersion().getVersionKey())) {
                    System.out.println("not including geometry with key '" + mathInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (!databaseVisitor.filterMathModel(mathInfos[j])) {
                    continue;
                }
                KeyValue vk = null;
                try {
                    vk = mathInfos[j].getVersion().getVersionKey();
                    BigString mathModelXML = dbServerImpl.getMathModelXML(user, mathInfos[j].getVersion().getVersionKey());
                    MathModel mathModel = cbit.vcell.xml.XmlHelper.XMLToMathModel(new XMLSource(mathModelXML.toString()));
                    mathModel.refreshDependencies();
                    databaseVisitor.visitMathModel(mathModel, logFilePrintStream);
                } catch (Exception e2) {
                    if (isBadMathVisitor) {
                        badMathVisitor.unableToLoad(vk, e2);
                    }
                    lg.error(e2.getMessage(), e2);
                    if (bAbortOnDataAccessException) {
                        throw e2;
                    }
                }
            }
        }
        logFilePrintStream.close();
    } catch (Exception e) {
        System.err.println("error writing to log file.");
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) MathModelInfo(org.vcell.util.document.MathModelInfo) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) RemoteException(java.rmi.RemoteException)

Example 35 with MathModelInfo

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

the class EditTestCriteriaPanel method setReferenceMathModelInfo.

/**
 * Sets the referenceMathModelInfo property (cbit.vcell.mathmodel.MathModelInfo) value.
 * @param referenceMathModelInfo The new value for the property.
 * @see #getReferenceMathModelInfo
 */
public void setReferenceMathModelInfo(MathModelInfo referenceMathModelInfo) {
    MathModelInfo oldValue = fieldReferenceMathModelInfo;
    fieldReferenceMathModelInfo = referenceMathModelInfo;
    firePropertyChange("referenceMathModelInfo", oldValue, referenceMathModelInfo);
}
Also used : MathModelInfo(org.vcell.util.document.MathModelInfo)

Aggregations

MathModelInfo (org.vcell.util.document.MathModelInfo)67 BioModelInfo (org.vcell.util.document.BioModelInfo)37 DataAccessException (org.vcell.util.DataAccessException)32 GeometryInfo (cbit.vcell.geometry.GeometryInfo)22 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)14 MathModel (cbit.vcell.mathmodel.MathModel)12 Vector (java.util.Vector)11 BioModel (cbit.vcell.biomodel.BioModel)10 KeyValue (org.vcell.util.document.KeyValue)10 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)8 Hashtable (java.util.Hashtable)8 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)8 User (org.vcell.util.document.User)8 Simulation (cbit.vcell.solver.Simulation)7 UserCancelException (org.vcell.util.UserCancelException)7 Geometry (cbit.vcell.geometry.Geometry)6 SimulationContext (cbit.vcell.mapping.SimulationContext)6 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)6 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)6 SimulationInfo (cbit.vcell.solver.SimulationInfo)6