Search in sources :

Example 86 with KeyValue

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

the class GeomDbDriver method getGeometry.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.model.Model
 * @param rset java.sql.ResultSet
 */
private Geometry getGeometry(QueryHashtable dbc, Connection con, User user, ResultSet rset) throws SQLException, DataAccessException {
    // 
    // get Image reference
    // 
    java.math.BigDecimal bigD = rset.getBigDecimal(geomTable.imageRef.toString());
    KeyValue imageRef = null;
    if (!rset.wasNull()) {
        imageRef = new KeyValue(bigD);
    }
    // 
    // get geometry object
    // 
    Geometry tempGeometry = null;
    try {
        tempGeometry = geomTable.getGeometry(rset, con);
    } catch (PropertyVetoException e) {
        throw new DataAccessException(e.getMessage());
    }
    Geometry geom = null;
    // 
    // get image for this geometry
    // 
    VCImage vcImage = null;
    if (imageRef != null) {
        // permission checking for the image is disabled because it is a child of this geometry
        vcImage = getVCImage(dbc, con, user, imageRef, false);
    }
    if (vcImage != null) {
        geom = new Geometry(tempGeometry, vcImage);
    } else {
        geom = tempGeometry;
    }
    // 
    // get SubVolumes for this geometry
    // 
    SubVolume[] subVolumes = getSubVolumesFromGeometry(dbc, con, geom.getVersion().getVersionKey());
    if (subVolumes != null) {
        try {
            geom.getGeometrySpec().setSubVolumes(subVolumes);
        } catch (java.beans.PropertyVetoException e) {
            lg.error(e.getMessage(), e);
            throw new DataAccessException(e.getMessage());
        }
    }
    // 
    if (geom.getDimension() > 0) {
        getSurfaceDescription(con, geom);
    }
    // 
    if (geom.getDimension() > 0) {
        getFilaments(con, geom);
    }
    // 
    // get SurfaceClasses for this geometry
    // 
    SurfaceClass[] surfaceClasses = getSurfaceClassesFromGeometry(dbc, con, geom.getVersion().getVersionKey());
    if (surfaceClasses != null) {
        try {
            geom.getGeometrySurfaceDescription().setSurfaceClasses(surfaceClasses);
        } catch (java.beans.PropertyVetoException e) {
            lg.error(e.getMessage(), e);
            throw new DataAccessException(e.getMessage());
        }
    }
    return geom;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) SurfaceClass(cbit.vcell.geometry.SurfaceClass) VCImage(cbit.image.VCImage) Geometry(cbit.vcell.geometry.Geometry) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException) BigDecimal(java.math.BigDecimal) SubVolume(cbit.vcell.geometry.SubVolume) DataAccessException(org.vcell.util.DataAccessException)

Example 87 with KeyValue

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

the class MathDescriptionDbDriver method getMathDescriptionSQL.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.math.MathDescription
 * @param user cbit.vcell.server.User
 * @param mathDescKey cbit.sql.KeyValue
 */
private MathDescription getMathDescriptionSQL(QueryHashtable dbc, Connection con, User user, KeyValue mathDescKey) throws SQLException, DataAccessException, ObjectNotFoundException {
    String sql;
    Field[] f = { userTable.userid, new cbit.sql.StarField(mathDescTable) };
    Table[] t = { mathDescTable, userTable };
    String condition = mathDescTable.id.getQualifiedColName() + " = " + mathDescKey + " AND " + userTable.id.getQualifiedColName() + " = " + mathDescTable.ownerRef.getQualifiedColName();
    sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
    // System.out.println(sql);
    MathDescription mathDescription = null;
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            // 
            // note: must call mathDescTable.getMathDescription() first (rset.getBytes(language) must be called first)
            // 
            mathDescription = mathDescTable.getMathDescription(rset, con, dbSyntax);
            // 
            // get Geometry reference and assign to mathDescription
            // 
            java.math.BigDecimal bigD = rset.getBigDecimal(MathDescTable.table.geometryRef.toString());
            KeyValue geomRef = null;
            if (!rset.wasNull()) {
                geomRef = new KeyValue(bigD);
            } else {
                throw new DataAccessException("Error:  Geometry Reference Cannot be Null for MathDescription");
            }
            Geometry geom = (Geometry) geomDB.getVersionable(dbc, con, user, VersionableType.Geometry, geomRef, false);
            try {
                mathDescription.setGeometry(geom);
            } catch (java.beans.PropertyVetoException e) {
                e.printStackTrace(System.out);
                throw new DataAccessException("DataAccess Exception: " + e.getMessage());
            }
        } else {
            throw new ObjectNotFoundException("MathDescription id=" + mathDescKey + " not found for user '" + user + "'");
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    return mathDescription;
}
Also used : Table(cbit.sql.Table) KeyValue(org.vcell.util.document.KeyValue) MathDescription(cbit.vcell.math.MathDescription) Statement(java.sql.Statement) Geometry(cbit.vcell.geometry.Geometry) Field(cbit.sql.Field) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) OuterJoin(cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin) ResultSet(java.sql.ResultSet) DataAccessException(org.vcell.util.DataAccessException)

Example 88 with KeyValue

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

the class MathModelDbDriver method getSimulationEntriesFromMathModel.

/**
 * getModels method comment.
 */
KeyValue[] getSimulationEntriesFromMathModel(Connection con, KeyValue mathModelKey) throws SQLException, DataAccessException {
    // if (lg.isTraceEnabled()) lg.trace("MathModelDbDriver.getSimulationEntriesFromMathModel(mathModelKey=" + mathModelKey + ")");
    String sql;
    sql = " SELECT " + mathModelSimLinkTable.simRef + " FROM " + mathModelSimLinkTable.getTableName() + " WHERE " + mathModelSimLinkTable.mathModelRef + " = " + mathModelKey + " ORDER BY " + mathModelSimLinkTable.id;
    Statement stmt = con.createStatement();
    java.util.Vector<KeyValue> keyList = new Vector<KeyValue>();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        // 
        while (rset.next()) {
            KeyValue key = mathModelSimLinkTable.getSimulationKey(rset);
            keyList.addElement(key);
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    // 
    // put results in an array
    // 
    KeyValue[] keyArray = new KeyValue[keyList.size()];
    keyList.copyInto(keyArray);
    return keyArray;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Vector(java.util.Vector)

Example 89 with KeyValue

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

the class MathModelTable method getMathModelMetaData.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.math.MathDescription
 * @param user cbit.vcell.server.User
 * @param rset java.sql.ResultSet
 */
public MathModelMetaData getMathModelMetaData(ResultSet rset, Connection con, KeyValue[] simulationKeys, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    // 
    // Get Version
    // 
    java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
    Version mathModelVersion = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
    KeyValue mathDescrRef = new KeyValue(rset.getBigDecimal(table.mathRef.toString()));
    // MathModelMetaData mathModelMetaData = new MathModelMetaData(version,mathRef,simulationKeys);
    MathModelMetaData mathModelMetaData = populateOutputFunctions(con, mathDescrRef, mathModelVersion, simulationKeys, dbSyntax);
    return mathModelMetaData;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) Version(org.vcell.util.document.Version) MathModelMetaData(cbit.vcell.mathmodel.MathModelMetaData)

Example 90 with KeyValue

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

the class MathModelTable method getInfo.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.geometry.GeometryInfo
 * @param rset java.sql.ResultSet
 * @param log cbit.vcell.server.SessionLog
 */
public VersionInfo getInfo(ResultSet rset, Connection con, DatabaseSyntax dbSyntax) throws SQLException, org.vcell.util.DataAccessException {
    KeyValue mathRef = new KeyValue(rset.getBigDecimal(table.mathRef.toString()));
    java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
    Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
    String serialDbChildSummary = DbDriver.varchar2_CLOB_get(rset, MathModelTable.table.childSummarySmall, MathModelTable.table.childSummaryLarge, dbSyntax);
    String softwareVersion = rset.getString(SoftwareVersionTable.table.softwareVersion.toString());
    return new MathModelInfo(version, mathRef, serialDbChildSummary, VCellSoftwareVersion.fromString(softwareVersion));
}
Also used : KeyValue(org.vcell.util.document.KeyValue) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) Version(org.vcell.util.document.Version) MathModelInfo(org.vcell.util.document.MathModelInfo)

Aggregations

KeyValue (org.vcell.util.document.KeyValue)325 DataAccessException (org.vcell.util.DataAccessException)92 User (org.vcell.util.document.User)68 ResultSet (java.sql.ResultSet)57 Statement (java.sql.Statement)52 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)44 SQLException (java.sql.SQLException)43 BigString (org.vcell.util.BigString)40 BigDecimal (java.math.BigDecimal)38 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)37 BioModel (cbit.vcell.biomodel.BioModel)36 Simulation (cbit.vcell.solver.Simulation)33 XmlParseException (cbit.vcell.xml.XmlParseException)33 PropertyVetoException (java.beans.PropertyVetoException)33 Vector (java.util.Vector)33 Connection (java.sql.Connection)32 ArrayList (java.util.ArrayList)31 File (java.io.File)29 SimulationContext (cbit.vcell.mapping.SimulationContext)28 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)24