Search in sources :

Example 21 with ObjectNotFoundException

use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.

the class GeomDbDriver method getVCImage.

/**
 * getModel method comment.
 */
private VCImage getVCImage(QueryHashtable dbc, Connection con, User user, KeyValue imageKey, boolean bCheckPermission) throws SQLException, DataAccessException, ObjectNotFoundException {
    // log.print("GeomDbDriver.getImage(user="+user+", id="+imageKey+")");
    String sql;
    Field[] f = { new StarField(imageTable), userTable.userid, imageDataTable.data, new StarField(extentTable) };
    Table[] t = { imageTable, userTable, imageDataTable, extentTable };
    String condition = imageTable.id.getQualifiedColName() + " = " + imageKey + " AND " + imageTable.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName() + " AND " + imageTable.id.getQualifiedColName() + " = " + imageDataTable.imageRef.getQualifiedColName() + " AND " + imageTable.extentRef.getQualifiedColName() + " = " + extentTable.id.getQualifiedColName();
    sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax, bCheckPermission);
    // System.out.println(sql);
    // Connection con = conFact.getConnection();
    VCImage vcImage = null;
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            vcImage = imageTable.getImage(rset, con, imageDataTable, dbSyntax);
            getImageRegionsForVCImage(dbc, con, vcImage);
        } else {
            throw new ObjectNotFoundException("Image id=" + imageKey + " not found for user '" + user + "'");
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    return vcImage;
}
Also used : StarField(cbit.sql.StarField) StarField(cbit.sql.StarField) Field(cbit.sql.Field) Table(cbit.sql.Table) Statement(java.sql.Statement) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) OuterJoin(cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin) ResultSet(java.sql.ResultSet) VCImage(cbit.image.VCImage)

Example 22 with ObjectNotFoundException

use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.

the class ServerDocumentManager method getBioModelXML.

/**
 * Insert the method's description here.
 * Creation date: (3/29/2004 4:04:16 PM)
 * @return java.lang.String
 * @param vType cbit.sql.VersionableType
 * @param vKey cbit.sql.KeyValue
 */
public String getBioModelXML(QueryHashtable dbc, User user, KeyValue bioModelKey, boolean bRegenerateXML) throws DataAccessException {
    String bioModelXML = null;
    try {
        bioModelXML = dbServer.getDBTopLevel().getBioModelXML(user, bioModelKey, true);
        if (bioModelXML != null) {
            if (bRegenerateXML) {
                try {
                    BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML));
                    return cbit.vcell.xml.XmlHelper.bioModelToXML(bioModel);
                } catch (XmlParseException e) {
                    e.printStackTrace();
                    throw new DataAccessException(e.getMessage(), e);
                }
            } else {
                return bioModelXML;
            }
        }
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    } catch (ObjectNotFoundException e) {
    // 
    // not stored as XML currently, retrieve traditional way.
    // 
    }
    try {
        bioModelXML = getBioModelUnresolved(dbc, user, bioModelKey);
        dbServer.insertVersionableXML(user, VersionableType.BioModelMetaData, bioModelKey, bioModelXML);
        return bioModelXML;
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    } catch (cbit.vcell.xml.XmlParseException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) XmlParseException(cbit.vcell.xml.XmlParseException) XMLSource(cbit.vcell.xml.XMLSource) DataAccessException(org.vcell.util.DataAccessException)

Example 23 with ObjectNotFoundException

use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.

the class ServerDocumentManager method isChanged.

/**
 * Insert the method's description here.
 * Creation date: (2/5/01 4:58:40 PM)
 */
boolean isChanged(QueryHashtable dbc, User user, cbit.image.VCImage vcImage) throws org.vcell.util.DataAccessException {
    // 
    // identify versionable as it was last loaded from the database
    // 
    KeyValue key = (vcImage.getVersion() != null) ? (vcImage.getVersion().getVersionKey()) : null;
    if (key == null) {
        return true;
    }
    Versionable savedVersionable = null;
    // 
    try {
        savedVersionable = dbServer.getDBTopLevel().getVCImage(dbc, user, key, true);
    } catch (ObjectNotFoundException e) {
        // 
        return true;
    } catch (Throwable e) {
        // 
        // loaded version has been deleted
        // 
        e.printStackTrace(System.out);
        return true;
    }
    return isChanged0(user, vcImage, savedVersionable);
}
Also used : Versionable(org.vcell.util.document.Versionable) KeyValue(org.vcell.util.document.KeyValue) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException)

Example 24 with ObjectNotFoundException

use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.

the class SimulationContextDbDriver method getSimulationContextSQL.

/**
 * getModel method comment.
 */
private SimulationContext getSimulationContextSQL(QueryHashtable dbc, Connection con, User user, KeyValue simContextKey) throws /*, ReactStepDbDriver reactStepDB*/
SQLException, DataAccessException, IllegalMappingException, PropertyVetoException {
    SimulationContext simContext = null;
    String sql;
    Field[] f = { new cbit.sql.StarField(simContextTable), userTable.userid };
    Table[] t = { simContextTable, userTable };
    String condition = simContextTable.id.getQualifiedColName() + " = " + simContextKey + " AND " + simContextTable.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
    sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
    // System.out.println(sql);
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            simContext = simContextTable.getSimContext(dbc, con, user, rset, geomDB, modelDB, mathDescDB);
        } else {
            throw new ObjectNotFoundException("SimulationContext id=" + simContextKey + " not found for user '" + user + "'");
        }
    } finally {
        stmt.close();
    }
    DataSymbolTable.table.populateDataSymbols(con, simContextKey, simContext.getDataContext(), user, simContext.getModel().getUnitSystem());
    ArrayList<AnnotatedFunction> outputFunctionList = ApplicationMathTable.table.getOutputFunctionsSimcontext(con, simContextKey, dbSyntax);
    if (outputFunctionList != null) {
        OutputFunctionContext outputFnContext = simContext.getOutputFunctionContext();
        outputFnContext.setOutputFunctions(outputFunctionList);
    }
    SimContextTable.table.readAppComponents(con, simContext, dbSyntax);
    assignStimuliSQL(con, simContextKey, simContext);
    assignStructureMappingsSQL(dbc, con, simContextKey, simContext);
    assignSpeciesContextSpecsSQL(con, simContextKey, simContext);
    assignReactionSpecsSQL(con, simContextKey, simContext);
    for (GeometryClass gc : simContext.getGeometry().getGeometryClasses()) {
        try {
            StructureSizeSolver.updateUnitStructureSizes(simContext, gc);
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }
    simContext.getGeometryContext().enforceHierarchicalBoundaryConditions(simContext.getModel().getStructureTopology());
    simContext.getModel().refreshDependencies();
    assignAnalysisTasksSQL(con, simContextKey, simContext);
    // really needed to calculate MembraneMapping parameters that are not stored (inside/outside flux correction factors).
    simContext.refreshDependencies();
    return simContext;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) Table(cbit.sql.Table) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) DependencyException(org.vcell.util.DependencyException) RecordChangedException(cbit.sql.RecordChangedException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) IllegalMappingException(cbit.vcell.mapping.IllegalMappingException) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) Field(cbit.sql.Field) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) OuterJoin(cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin) ResultSet(java.sql.ResultSet) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 25 with ObjectNotFoundException

use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.

the class BioModelDbDriver method getBioModelMetaData.

/**
 * getModel method comment.
 */
private BioModelMetaData getBioModelMetaData(Connection con, User user, KeyValue bioModelKey, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException, ObjectNotFoundException {
    if (user == null || bioModelKey == null) {
        throw new IllegalArgumentException("Improper parameters for getBioModelMetaData");
    }
    // if (lg.isTraceEnabled()) lg.trace("BioModelDbDriver.getBioModelMetaData(user=" + user + ", id=" + bioModelKey + ")");
    // 
    // to construct a BioModelMetaData as an immutable object, lets collect all keys first
    // (even before authentication).  If the user doesn't authenticate, then throw away the
    // child keys (from link tables).
    // 
    // 
    // get Simulation Keys for bioModelKey
    // 
    KeyValue[] simKeys = getSimulationEntriesFromBioModel(con, bioModelKey);
    // 
    // get SimulationContext Keys for bioModelKey
    // 
    KeyValue[] simContextKeys = getSimContextEntriesFromBioModel(con, bioModelKey);
    // 
    // get BioModelMetaData object for bioModelKey
    // 
    String sql;
    VCMetaDataTable vcMetadataTable = VCMetaDataTable.table;
    Field[] f = { new StarField(bioModelTable), userTable.userid, new StarField(vcMetadataTable) };
    Table[] t = { bioModelTable, userTable, vcMetadataTable };
    switch(dbSyntax) {
        case ORACLE:
            {
                String condition = bioModelTable.id.getQualifiedColName() + " = " + bioModelKey + " AND " + userTable.id.getQualifiedColName() + " = " + bioModelTable.ownerRef.getQualifiedColName() + " AND " + vcMetadataTable.bioModelRef.getQualifiedColName() + "(+) = " + bioModelTable.id.getQualifiedColName();
                sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, null, condition, null, dbSyntax, true);
                break;
            }
        case POSTGRES:
            {
                String condition = bioModelTable.id.getQualifiedColName() + " = " + bioModelKey + " AND " + userTable.id.getQualifiedColName() + " = " + bioModelTable.ownerRef.getQualifiedColName() + " ";
                // " AND "+ VCMetaDataTable.table.bioModelRef.getQualifiedColName() + "(+) = " + bioModelTable.id.getQualifiedColName();
                OuterJoin outerJoin = new OuterJoin(vcMetadataTable, bioModelTable, JoinOp.RIGHT_OUTER_JOIN, vcMetadataTable.bioModelRef, bioModelTable.id);
                sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, outerJoin, condition, null, dbSyntax, true);
                break;
            }
        default:
            {
                throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
            }
    }
    Statement stmt = con.createStatement();
    BioModelMetaData bioModelMetaData = null;
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            bioModelMetaData = bioModelTable.getBioModelMetaData(rset, con, simContextKeys, simKeys, dbSyntax);
        } else {
            throw new ObjectNotFoundException("BioModel id=" + bioModelKey + " not found for user '" + user + "'");
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    return bioModelMetaData;
}
Also used : StarField(cbit.sql.StarField) KeyValue(org.vcell.util.document.KeyValue) Table(cbit.sql.Table) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BioModelMetaData(cbit.vcell.biomodel.BioModelMetaData) StarField(cbit.sql.StarField) Field(cbit.sql.Field) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) OuterJoin(cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin) ResultSet(java.sql.ResultSet)

Aggregations

ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)62 DataAccessException (org.vcell.util.DataAccessException)26 KeyValue (org.vcell.util.document.KeyValue)21 ResultSet (java.sql.ResultSet)18 Statement (java.sql.Statement)17 PermissionException (org.vcell.util.PermissionException)17 SQLException (java.sql.SQLException)13 User (org.vcell.util.document.User)12 BigString (org.vcell.util.BigString)11 XmlParseException (cbit.vcell.xml.XmlParseException)10 VersionInfo (org.vcell.util.document.VersionInfo)10 Field (cbit.sql.Field)9 SimulationRep (cbit.vcell.modeldb.SimulationRep)9 XMLSource (cbit.vcell.xml.XMLSource)9 Table (cbit.sql.Table)8 OuterJoin (cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin)8 PropertyVetoException (java.beans.PropertyVetoException)8 ResourceException (org.restlet.resource.ResourceException)8 VCellApiApplication (org.vcell.rest.VCellApiApplication)8 BioModel (cbit.vcell.biomodel.BioModel)7