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;
}
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());
}
}
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);
}
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;
}
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;
}
Aggregations