use of cbit.vcell.biomodel.BioModelMetaData in project vcell by virtualcell.
the class LocalUserMetaDbServerMessaging method getBioModelMetaDatas.
/**
* getVersionInfo method comment.
* @throws RemoteException
*/
public BioModelMetaData[] getBioModelMetaDatas(boolean bAll) throws DataAccessException {
try {
log.print("LocalUserMetaDbServerMessaging.getBioModelMetaDatas(bAll=" + bAll + ")");
BioModelMetaData[] bioModelMetaDataArray = dbServerProxy.getBioModelMetaDatas(bAll);
return bioModelMetaDataArray;
} catch (DataAccessException e) {
log.exception(e);
throw e;
} catch (Throwable e) {
log.exception(e);
throw new DataAccessException(e.getMessage());
}
}
use of cbit.vcell.biomodel.BioModelMetaData in project vcell by virtualcell.
the class BioModelDbDriver method getBioModelMetaDatas.
/**
* getModel method comment.
*/
BioModelMetaData[] getBioModelMetaDatas(Connection con, User user, boolean bAll, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException, ObjectNotFoundException {
if (user == null) {
throw new IllegalArgumentException("Improper parameters for getBioModelMetaDatas");
}
if (lg.isTraceEnabled())
lg.trace("BioModelDbDriver.getBioModelMetaDatas(user=" + user + ", bAll=" + bAll + ")");
//
// 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 BioModelMetaData object for bioModelKey
//
String sql;
Field[] f = { new cbit.sql.StarField(bioModelTable), userTable.userid };
Table[] t = { bioModelTable, userTable };
String condition = userTable.id.getQualifiedColName() + " = " + bioModelTable.ownerRef.getQualifiedColName();
if (!bAll) {
condition += " AND " + userTable.id.getQualifiedColName() + " = " + user.getID();
}
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
//
StringBuffer newSQL = new StringBuffer(sql);
newSQL.insert(7, Table.SQL_GLOBAL_HINT);
sql = newSQL.toString();
//
Statement stmt = con.createStatement();
Vector<BioModelMetaData> bioModelMetaDataList = new Vector<BioModelMetaData>();
try {
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
BioModelMetaData bioModelMetaData = bioModelTable.getBioModelMetaData(rset, this, con, dbSyntax);
bioModelMetaDataList.addElement(bioModelMetaData);
}
} finally {
// Release resources include resultset
stmt.close();
}
BioModelMetaData[] bioModelMetaDataArray = new BioModelMetaData[bioModelMetaDataList.size()];
bioModelMetaDataList.copyInto(bioModelMetaDataArray);
return bioModelMetaDataArray;
}
use of cbit.vcell.biomodel.BioModelMetaData 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;
}
use of cbit.vcell.biomodel.BioModelMetaData in project vcell by virtualcell.
the class BioModelTable method getBioModelMetaData.
/**
* This method was created in VisualAge.
* @return cbit.vcell.math.MathDescription
* @param user cbit.vcell.server.User
* @param rset java.sql.ResultSet
*/
public BioModelMetaData getBioModelMetaData(ResultSet rset, BioModelDbDriver bioModelDbDriver, Connection con, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
//
// Get Version
//
BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
KeyValue bioModelKey = version.getVersionKey();
KeyValue modelRef = new KeyValue(rset.getBigDecimal(table.modelRef.toString()));
//
// get Simulation Keys for bioModelKey
//
KeyValue[] simKeys = bioModelDbDriver.getSimulationEntriesFromBioModel(con, bioModelKey);
//
// get SimulationContext Keys for bioModelKey
//
KeyValue[] simContextKeys = bioModelDbDriver.getSimContextEntriesFromBioModel(con, bioModelKey);
//
// Get VCMetaData XML
//
String vcMetaDataXML = VCMetaDataTable.getVCMetaDataXML(rset, dbSyntax);
BioModelMetaData bioModelMetaData = new BioModelMetaData(version, modelRef, simContextKeys, simKeys, vcMetaDataXML);
return bioModelMetaData;
}
use of cbit.vcell.biomodel.BioModelMetaData 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) {
lg.error(e.getLocalizedMessage(), e);
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) {
lg.error(e.getLocalizedMessage(), e);
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);
if (lg.isWarnEnabled())
lg.warn("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());
if (lg.isWarnEnabled())
lg.warn("< < < < 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) {
if (lg.isWarnEnabled())
lg.warn("<<<<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) {
lg.error(e.getLocalizedMessage(), e);
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){
// lg.error(e.getLocalizedMessage(),e);
// throw new DataAccessException("BioModel clone failed: "+e.getMessage());
// }
newBioModel.refreshDependencies();
//
return cbit.vcell.xml.XmlHelper.bioModelToXML(newBioModel);
}
Aggregations