use of cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin in project vcell by virtualcell.
the class GeometryTable method getInfoSQL.
/**
* This method was created in VisualAge.
* @return java.lang.String
*/
public String getInfoSQL(User user, String extraConditions, String special, boolean bCheckPermission, DatabaseSyntax dbSyntax) {
UserTable userTable = UserTable.table;
GeometryTable gTable = this;
ExtentTable eTable = ExtentTable.table;
SoftwareVersionTable swvTable = SoftwareVersionTable.table;
String sql;
Field[] f = { userTable.userid, new cbit.sql.StarField(gTable), eTable.extentX, eTable.extentY, eTable.extentZ, swvTable.softwareVersion };
Table[] t = { gTable, userTable, eTable, swvTable };
switch(dbSyntax) {
case ORACLE:
{
String condition = // links in the extent table
eTable.id.getQualifiedColName() + " = " + gTable.extentRef.getQualifiedColName() + " AND " + userTable.id.getQualifiedColName() + " = " + // links in the userTable
gTable.ownerRef.getQualifiedColName() + " AND " + gTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName() + "(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, special, dbSyntax, bCheckPermission);
return sql;
}
case POSTGRES:
{
String condition = // links in the extent table
eTable.id.getQualifiedColName() + " = " + gTable.extentRef.getQualifiedColName() + " AND " + userTable.id.getQualifiedColName() + " = " + gTable.ownerRef.getQualifiedColName() + // links in the userTable
" ";
// " AND " + gTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName()+"(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
OuterJoin outerJoin = new OuterJoin(gTable, swvTable, JoinOp.LEFT_OUTER_JOIN, gTable.id, swvTable.versionableRef);
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, outerJoin, condition, special, dbSyntax, bCheckPermission);
return sql;
}
default:
{
throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
}
}
}
use of cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin in project vcell by virtualcell.
the class MathDescTable method getInfoSQL.
/**
* This method was created in VisualAge.
* @return java.lang.String
*/
public String getInfoSQL(User user, String extraConditions, String special, DatabaseSyntax dbSyntax) {
UserTable userTable = UserTable.table;
MathDescTable vTable = MathDescTable.table;
SoftwareVersionTable swvTable = SoftwareVersionTable.table;
String sql;
// Field[] f = {userTable.userid,new cbit.sql.StarField(vTable)};
Field[] f = new Field[] { vTable.id, userTable.userid, swvTable.softwareVersion };
f = (Field[]) org.vcell.util.BeanUtils.addElements(f, vTable.versionFields);
f = (Field[]) org.vcell.util.BeanUtils.addElement(f, vTable.geometryRef);
Table[] t = { vTable, userTable, swvTable };
switch(dbSyntax) {
case ORACLE:
{
String condition = // links in the userTable
userTable.id.getQualifiedColName() + " = " + vTable.ownerRef.getQualifiedColName() + " AND " + vTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName() + "(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, special, dbSyntax);
return sql;
}
case POSTGRES:
{
// links in the userTable
String condition = userTable.id.getQualifiedColName() + " = " + vTable.ownerRef.getQualifiedColName() + " ";
// " AND " + vTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName()+"(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
OuterJoin outerJoin = new OuterJoin(vTable, swvTable, JoinOp.LEFT_OUTER_JOIN, vTable.id, swvTable.versionableRef);
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, outerJoin, condition, special, dbSyntax);
return sql;
}
default:
{
throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
}
}
}
use of cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin 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 cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin in project vcell by virtualcell.
the class MathModelDbDriver method getMathModelMetaDatas.
/**
* getModel method comment.
*/
MathModelMetaData[] getMathModelMetaDatas(Connection con, User user, boolean bAll) throws SQLException, DataAccessException, ObjectNotFoundException {
if (user == null) {
throw new IllegalArgumentException("Improper parameters for getMathModelMetaDatas");
}
if (lg.isTraceEnabled())
lg.trace("MathModelDbDriver.getMathModelMetaData(user=" + user + ", bAll=" + bAll + ")");
//
// to construct a MathModelMetaData 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(mathModelTable), userTable.userid };
Table[] t = { mathModelTable, userTable };
String condition = userTable.id.getQualifiedColName() + " = " + mathModelTable.ownerRef.getQualifiedColName();
if (!bAll) {
condition += " AND " + userTable.id.getQualifiedColName() + " = " + user.getID();
}
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax, true);
//
StringBuffer newSQL = new StringBuffer(sql);
newSQL.insert(7, Table.SQL_GLOBAL_HINT);
sql = newSQL.toString();
//
Statement stmt = con.createStatement();
Vector<MathModelMetaData> mathModelMetaDataList = new Vector<MathModelMetaData>();
try {
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
MathModelMetaData mathModelMetaData = mathModelTable.getMathModelMetaData(rset, this, con, dbSyntax);
mathModelMetaDataList.addElement(mathModelMetaData);
}
} finally {
// Release resources include resultset
stmt.close();
}
MathModelMetaData[] mathModelMetaDataArray = new MathModelMetaData[mathModelMetaDataList.size()];
mathModelMetaDataList.copyInto(mathModelMetaDataArray);
return mathModelMetaDataArray;
}
use of cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin in project vcell by virtualcell.
the class MathModelTable method getInfoSQL.
/**
* This method was created in VisualAge.
* @return java.lang.String
*/
public String getInfoSQL(User user, String extraConditions, String special, DatabaseSyntax dbSyntax) {
UserTable userTable = UserTable.table;
MathModelTable vTable = MathModelTable.table;
SoftwareVersionTable swvTable = SoftwareVersionTable.table;
String sql;
Field[] f = { userTable.userid, new cbit.sql.StarField(vTable), swvTable.softwareVersion };
Table[] t = { vTable, userTable, swvTable };
switch(dbSyntax) {
case ORACLE:
{
String condition = // links in the userTable
userTable.id.getQualifiedColName() + " = " + vTable.ownerRef.getQualifiedColName() + " AND " + vTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName() + "(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, special, dbSyntax, true);
return sql;
}
case POSTGRES:
{
// links in the userTable
String condition = userTable.id.getQualifiedColName() + " = " + vTable.ownerRef.getQualifiedColName() + " ";
// " AND " + vTable.id.getQualifiedColName() + " = " + swvTable.versionableRef.getQualifiedColName()+"(+) ";
if (extraConditions != null && extraConditions.trim().length() > 0) {
condition += " AND " + extraConditions;
}
OuterJoin outerJoin = new OuterJoin(vTable, swvTable, JoinOp.LEFT_OUTER_JOIN, vTable.id, swvTable.versionableRef);
sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, outerJoin, condition, special, dbSyntax, true);
return sql;
}
default:
{
throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
}
}
}
Aggregations