use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class DbDriver method setVersioned.
/**
* This method was created in VisualAge.
* @param vTable cbit.sql.VersionTable
* @param versionKey cbit.sql.KeyValue
*/
protected void setVersioned(Connection con, User user, Versionable versionable) throws ObjectNotFoundException, SQLException, DataAccessException {
String sql;
if (versionable instanceof SimulationContext) {
SimulationContext sc = (SimulationContext) versionable;
setVersioned(con, user, sc.getGeometryContext().getGeometry());
setVersioned(con, user, sc.getGeometryContext().getModel());
if (sc.getMathDescription() != null) {
setVersioned(con, user, sc.getMathDescription());
}
} else if (versionable instanceof MathDescription) {
MathDescription math = (MathDescription) versionable;
setVersioned(con, user, math.getGeometry());
} else if (versionable instanceof Geometry) {
Geometry geo = (Geometry) versionable;
if (geo.getGeometrySpec().getImage() != null) {
setVersioned(con, user, geo.getGeometrySpec().getImage());
}
}
//
if (versionable.getVersion().getOwner().compareEqual(user)) {
VersionTable vTable = VersionTable.getVersionTable(versionable);
sql = "UPDATE " + vTable.getTableName() + " SET " + vTable.versionFlag + " = " + VersionFlag.Archived.getIntValue() + " WHERE " + vTable.id + " = " + versionable.getVersion().getVersionKey() + // " AND " + vTable.versionFlag + " = " + VersionFlag.CURRENT +
" AND " + vTable.ownerRef + " = " + user.getID();
if (updateCleanSQL(con, sql) != 1) {
throw new DataAccessException("setVersioned failed for :" + versionable.getVersion());
}
}
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class ServerDocumentManager method getBioModelUnresolved.
/**
* Insert the method's description here.
* Creation date: (11/14/00 4:02:44 PM)
* @return cbit.vcell.biomodel.BioModel
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
//
// this returns a BioModel that contains multiple instances of objects.
//
public String getBioModelUnresolved(QueryHashtable dbc, User user, KeyValue bioModelKey) throws DataAccessException, XmlParseException, java.sql.SQLException {
//
// get meta data associated with BioModel
//
BioModelMetaData bioModelMetaData = dbServer.getDBTopLevel().getBioModelMetaData(dbc, user, bioModelKey);
//
// get list of appropriate child components
//
KeyValue modelKey = bioModelMetaData.getModelKey();
KeyValue[] simKeys = getKeyArrayFromEnumeration(bioModelMetaData.getSimulationKeys());
KeyValue[] scKeys = getKeyArrayFromEnumeration(bioModelMetaData.getSimulationContextKeys());
Model model = dbServer.getDBTopLevel().getModel(dbc, user, modelKey);
Simulation[] simArray = new Simulation[simKeys.length];
for (int i = 0; i < simKeys.length; i++) {
Simulation sim = dbServer.getDBTopLevel().getSimulation(dbc, user, simKeys[i]);
//
try {
simArray[i] = (Simulation) BeanUtils.cloneSerializable(sim);
} catch (Throwable e) {
e.printStackTrace(System.out);
throw new RuntimeException("exception cloning Simulation: " + e.getMessage());
}
}
SimulationContext[] scArray = new SimulationContext[scKeys.length];
for (int i = 0; i < scKeys.length; i++) {
SimulationContext sc = dbServer.getDBTopLevel().getSimulationContext(dbc, user, scKeys[i]);
//
try {
scArray[i] = (SimulationContext) BeanUtils.cloneSerializable(sc);
scArray[i].getModel().refreshDependencies();
scArray[i].refreshDependencies();
scArray[i].setModel(model);
} catch (Throwable e) {
e.printStackTrace(System.out);
throw new RuntimeException("exception cloning Application: " + e.getMessage());
}
if (!scArray[i].getModel().getKey().compareEqual(modelKey)) {
// throw new DataAccessException("simulationContext("+scKeys[i]+").model = "+scArray[i].getModel().getKey()+", BioModel.model = "+modelKey);
System.out.println("simulationContext(" + scKeys[i] + ").model = " + scArray[i].getModel().getKey() + ", BioModel.model = " + modelKey);
}
}
//
// create new BioModel according to loaded BioModelMetaData
//
BioModel newBioModel = new BioModel(bioModelMetaData.getVersion());
try {
// newBioModel.setMIRIAMAnnotation(bioModelMetaData.getMIRIAMAnnotation());
System.err.println("< < < < NEED TO GET VCMETADATA FROM METADATA TABLE ... METADATA IS EMPTY. > > > >");
newBioModel.setModel(model);
newBioModel.setSimulationContexts(scArray);
//
for (int i = 0; i < simArray.length; i++) {
boolean bMathFound = false;
for (int j = 0; j < scArray.length; j++) {
if (simArray[i].getMathDescription().getVersion().getVersionKey().compareEqual(scArray[j].getMathDescription().getVersion().getVersionKey())) {
simArray[i].setMathDescription(scArray[j].getMathDescription());
bMathFound = true;
break;
}
}
if (!bMathFound) {
System.out.println("<<<<WARNING>>>>> ClientDocumentManager.getBioModel(), Simulation " + simArray[i].getName() + " is orphaned, Math(" + simArray[i].getMathDescription().getName() + ") not found in Applications");
simArray = (Simulation[]) BeanUtils.removeElement(simArray, simArray[i]);
i--;
}
}
newBioModel.setSimulations(simArray);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new DataAccessException("PropertyVetoException caught " + e.getMessage());
}
//
// The BioModel is no longer cloned because the reference to this BioModel is no longer returned to the calling method.
// the only possible side effect is the "BioModel:refreshDependencies()" method call.
// this will reconnect internal listeners and other transient fields, and is not going to harm the cache integrity.
//
// //
// // clone BioModel (so that children can't be corrupted in the cache)
// //
// try {
// newBioModel = (BioModel)BeanUtils.cloneSerializable(newBioModel);
// }catch (Exception e){
// e.printStackTrace(System.out);
// throw new DataAccessException("BioModel clone failed: "+e.getMessage());
// }
newBioModel.refreshDependencies();
//
return cbit.vcell.xml.XmlHelper.bioModelToXML(newBioModel);
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class SimContextTable method getSimContext.
/**
* This method was created in VisualAge.
* @return cbit.vcell.mapping.SimulationContext
* @param rset java.sql.ResultSet
* @param log cbit.vcell.server.SessionLog
* @deprecated shouldn't do recursive query
*/
public SimulationContext getSimContext(QueryHashtable dbc, Connection con, User user, ResultSet rset, GeomDbDriver geomDB, ModelDbDriver modelDB, MathDescriptionDbDriver mathDB) throws SQLException, DataAccessException, java.beans.PropertyVetoException {
java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
KeyValue geomKey = new KeyValue(rset.getBigDecimal(SimContextTable.table.geometryRef.toString()));
Geometry geom = (Geometry) geomDB.getVersionable(dbc, con, user, VersionableType.Geometry, geomKey, false);
KeyValue modelKey = new KeyValue(rset.getBigDecimal(SimContextTable.table.modelRef.toString()));
Model model = (Model) modelDB.getVersionable(dbc, con, user, VersionableType.Model, modelKey);
//
// read characteristic size (may be null)
//
Double characteristicSize = null;
BigDecimal size = rset.getBigDecimal(charSize.toString());
if (!rset.wasNull() && size != null) {
characteristicSize = new Double(size.doubleValue());
}
//
// get mathKey (may be null)
//
MathDescription mathDesc = null;
BigDecimal mathKeyValue = rset.getBigDecimal(SimContextTable.table.mathRef.toString());
if (!rset.wasNull()) {
KeyValue mathKey = new KeyValue(mathKeyValue);
mathDesc = (MathDescription) mathDB.getVersionable(dbc, con, user, VersionableType.MathDescription, mathKey);
}
boolean bStochastic = mathDesc.isNonSpatialStoch() || mathDesc.isSpatialStoch() || mathDesc.isSpatialHybrid();
boolean bRuleBased = mathDesc.isRuleBased();
SimulationContext simContext = new SimulationContext(model, geom, mathDesc, version, bStochastic, bRuleBased);
if (characteristicSize != null) {
simContext.setCharacteristicSize(characteristicSize);
}
return simContext;
}
use of cbit.vcell.mapping.SimulationContext 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 cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class ElectricalStimulusPanel method setsimulationContext1.
/**
* Set the simulationContext1 to a new value.
* @param newValue cbit.vcell.mapping.SimulationContext
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setsimulationContext1(SimulationContext newValue) {
if (ivjsimulationContext1 != newValue) {
try {
SimulationContext oldValue = getsimulationContext1();
/* Stop listening for events from the current object */
if (ivjsimulationContext1 != null) {
ivjsimulationContext1.removePropertyChangeListener(ivjEventHandler);
}
ivjsimulationContext1 = newValue;
/* Listen for events from the new object */
if (ivjsimulationContext1 != null) {
ivjsimulationContext1.addPropertyChangeListener(ivjEventHandler);
}
connPtoP1SetSource();
connEtoM1(ivjsimulationContext1);
connEtoM3(ivjsimulationContext1);
connEtoM8(ivjsimulationContext1);
connEtoM11(ivjsimulationContext1);
connEtoC1(ivjsimulationContext1);
connEtoC7(ivjsimulationContext1);
setupElectrodeFeatureListProvider();
firePropertyChange("simulationContext", oldValue, newValue);
// user code begin {1}
// user code end
} catch (java.lang.Throwable ivjExc) {
// user code begin {2}
// user code end
handleException(ivjExc);
}
}
;
// user code begin {3}
// user code end
}
Aggregations