use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class GeomDbDriver method getImageRefKeyFromGeometry.
/**
* getModel method comment.
*/
private KeyValue getImageRefKeyFromGeometry(Connection con, KeyValue geomKey) throws SQLException, DataAccessException, ObjectNotFoundException {
if (geomKey == null) {
throw new IllegalArgumentException("Improper parameters for getImageRefKeyFromGeometry");
}
// log.print("GeomDbDriver.getImageRefKeyFromGeometry(id="+geomKey+")");
String sql;
sql = " SELECT " + geomTable.imageRef + " FROM " + geomTable.getTableName() + " WHERE " + geomTable.id + " = " + geomKey;
// System.out.println(sql);
// Connection con = conFact.getConnection();
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
java.math.BigDecimal iR = rset.getBigDecimal(geomTable.imageRef.toString());
if (rset.wasNull()) {
return null;
}
return new KeyValue(iR);
} else {
throw new ObjectNotFoundException("getSizeKeyFromGeometry for Image id=" + geomKey + " not found");
}
} finally {
// Release resources include resultset
stmt.close();
}
}
use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class GeomDbDriver method getExtentRefKeyFromImage.
/**
* getModel method comment.
*/
private KeyValue getExtentRefKeyFromImage(Connection con, KeyValue imageKey) throws SQLException, DataAccessException, ObjectNotFoundException {
if (imageKey == null) {
throw new IllegalArgumentException("Improper parameters for getSizeKeyFromImage");
}
// log.print("GeomDbDriver.getSizeRefKeyFromImage(id="+imageKey+")");
String sql;
sql = " SELECT " + imageTable.extentRef + " FROM " + imageTable.getTableName() + " WHERE " + imageTable.id + " = " + imageKey;
// System.out.println(sql);
// Connection con = conFact.getConnection();
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
return new KeyValue(rset.getBigDecimal(imageTable.extentRef.toString()));
} else {
throw new ObjectNotFoundException("getSizeKeyFromImage for Image id=" + imageKey + " not found");
}
} finally {
// Release resources include resultset
stmt.close();
}
}
use of org.vcell.util.ObjectNotFoundException 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;
}
use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class MathVerifier method testMathGeneration.
public MathGenerationResults testMathGeneration(KeyValue simContextKey) throws SQLException, ObjectNotFoundException, DataAccessException, XmlParseException, MappingException, MathException, MatrixException, ExpressionException, ModelException, PropertyVetoException {
User adminUser = new User(PropertyLoader.ADMINISTRATOR_ACCOUNT, new org.vcell.util.document.KeyValue(PropertyLoader.ADMINISTRATOR_ID));
if (lg.isTraceEnabled())
lg.trace("Testing SimContext with key '" + simContextKey + "'");
// get biomodel refs
java.sql.Connection con = null;
java.sql.Statement stmt = null;
con = conFactory.getConnection(new Object());
cbit.vcell.modeldb.BioModelSimContextLinkTable bmscTable = cbit.vcell.modeldb.BioModelSimContextLinkTable.table;
cbit.vcell.modeldb.BioModelTable bmTable = cbit.vcell.modeldb.BioModelTable.table;
cbit.vcell.modeldb.UserTable userTable = cbit.vcell.modeldb.UserTable.table;
String sql = "SELECT " + bmscTable.bioModelRef.getQualifiedColName() + "," + bmTable.ownerRef.getQualifiedColName() + "," + userTable.userid.getQualifiedColName() + " FROM " + bmscTable.getTableName() + "," + bmTable.getTableName() + "," + userTable.getTableName() + " WHERE " + bmscTable.simContextRef.getQualifiedColName() + " = " + simContextKey + " AND " + bmTable.id.getQualifiedColName() + " = " + bmscTable.bioModelRef.getQualifiedColName() + " AND " + bmTable.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
ArrayList<KeyValue> bioModelKeys = new ArrayList<KeyValue>();
stmt = con.createStatement();
User owner = null;
try {
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
KeyValue key = new KeyValue(rset.getBigDecimal(bmscTable.bioModelRef.getUnqualifiedColName()));
bioModelKeys.add(key);
KeyValue ownerRef = new KeyValue(rset.getBigDecimal(bmTable.ownerRef.getUnqualifiedColName()));
String userid = rset.getString(userTable.userid.getUnqualifiedColName());
owner = new User(userid, ownerRef);
}
} finally {
if (stmt != null) {
stmt.close();
}
con.close();
}
// use the first biomodel...
if (bioModelKeys.size() == 0) {
throw new RuntimeException("zombie simContext ... no biomodels");
}
BioModelInfo bioModelInfo = dbServerImpl.getBioModelInfo(owner, bioModelKeys.get(0));
//
// read in the BioModel from the database
//
BigString bioModelXML = dbServerImpl.getBioModelXML(owner, bioModelInfo.getVersion().getVersionKey());
BioModel bioModelFromDB = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
BioModel bioModelNewMath = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
bioModelFromDB.refreshDependencies();
bioModelNewMath.refreshDependencies();
//
// get all Simulations for this model
//
Simulation[] modelSimsFromDB = bioModelFromDB.getSimulations();
//
// ---> only for the SimContext we started with...
// recompute mathDescription, and verify it is equivalent
// then check each associated simulation to ensure math overrides are applied in an equivalent manner also.
//
SimulationContext[] simContextsFromDB = bioModelFromDB.getSimulationContexts();
SimulationContext[] simContextsNewMath = bioModelNewMath.getSimulationContexts();
SimulationContext simContextFromDB = null;
SimulationContext simContextNewMath = null;
for (int k = 0; k < simContextsFromDB.length; k++) {
// find it...
if (simContextsFromDB[k].getKey().equals(simContextKey)) {
simContextFromDB = simContextsFromDB[k];
simContextNewMath = simContextsNewMath[k];
break;
}
}
if (simContextFromDB == null) {
throw new RuntimeException("BioModel referred to by this SimContext does not contain this SimContext");
} else {
MathDescription origMathDesc = simContextFromDB.getMathDescription();
//
try {
if (simContextNewMath.getGeometry().getDimension() > 0 && simContextNewMath.getGeometry().getGeometrySurfaceDescription().getGeometricRegions() == null) {
simContextNewMath.getGeometry().getGeometrySurfaceDescription().updateAll();
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
//
// updated mathDescription loaded into copy of bioModel, then test for equivalence.
//
cbit.vcell.mapping.MathMapping mathMapping = simContextNewMath.createNewMathMapping();
MathDescription mathDesc_latest = mathMapping.getMathDescription();
MathMapping_4_8 mathMapping_4_8 = new MathMapping_4_8(simContextNewMath);
MathDescription mathDesc_4_8 = mathMapping_4_8.getMathDescription();
String issueString = null;
org.vcell.util.Issue[] issues = mathMapping.getIssues();
if (issues != null && issues.length > 0) {
StringBuffer buffer = new StringBuffer("Issues(" + issues.length + "):\n");
for (int l = 0; l < issues.length; l++) {
buffer.append(" <<" + issues[l].toString() + ">>\n");
}
issueString = buffer.toString();
}
simContextNewMath.setMathDescription(mathDesc_latest);
MathCompareResults mathCompareResults_latest = MathDescription.testEquivalency(SimulationSymbolTable.createMathSymbolTableFactory(), origMathDesc, mathDesc_latest);
MathCompareResults mathCompareResults_4_8 = null;
try {
mathCompareResults_4_8 = MathDescription.testEquivalency(SimulationSymbolTable.createMathSymbolTableFactory(), origMathDesc, mathDesc_4_8);
} catch (Exception e) {
e.printStackTrace(System.out);
mathCompareResults_4_8 = new MathCompareResults(Decision.MathDifferent_FAILURE_UNKNOWN, e.getMessage());
}
return new MathGenerationResults(bioModelFromDB, simContextFromDB, origMathDesc, mathDesc_latest, mathCompareResults_latest, mathDesc_4_8, mathCompareResults_4_8);
}
}
use of org.vcell.util.ObjectNotFoundException in project vcell by virtualcell.
the class ModelDbDriver method getModel.
/**
* getModel method comment.
*/
private cbit.vcell.model.Model getModel(QueryHashtable dbc, Connection con, User user, KeyValue modelKey) throws SQLException, DataAccessException, ObjectNotFoundException {
if (user == null || modelKey == null) {
throw new IllegalArgumentException("Improper parameters for getModel");
}
// log.print("ModelDbDriver.getModel(user=" + user + ", id=" + modelKey + ")");
String sql;
Field[] f = { new cbit.sql.StarField(modelTable), userTable.userid };
Table[] t = { modelTable, userTable };
String condition = modelTable.id.getQualifiedColName() + " = " + modelKey + " AND " + userTable.id.getQualifiedColName() + " = " + modelTable.ownerRef.getQualifiedColName();
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
Statement stmt = con.createStatement();
Model model = null;
try {
ResultSet rset = stmt.executeQuery(sql);
if (rset.next()) {
model = getModel(dbc, rset, con, user);
} else {
throw new org.vcell.util.ObjectNotFoundException("Model id=" + modelKey + " not found for user '" + user + "'");
}
} finally {
// Release resources include resultset
stmt.close();
}
// GlobalModelParameterTable.table.setModelParameters(con, model);
return model;
}
Aggregations