use of org.vcell.util.document.VersionableTypeVersion in project vcell by virtualcell.
the class ClientRequestManager method createMathModelFromApplication.
/**
* Insert the method's description here.
* Creation date: (5/24/2004 12:22:11 PM)
* @param windowID java.lang.String
*/
public void createMathModelFromApplication(final BioModelWindowManager requester, final String name, final SimulationContext simContext) {
if (simContext == null) {
PopupGenerator.showErrorDialog(requester, "Selected Application is null, cannot generate corresponding math model");
return;
}
switch(simContext.getApplicationType()) {
case NETWORK_STOCHASTIC:
break;
case RULE_BASED_STOCHASTIC:
case NETWORK_DETERMINISTIC:
}
AsynchClientTask task1 = new AsynchClientTask("Creating MathModel from BioModel Application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathModel newMathModel = new MathModel(null);
// Get corresponding mathDesc to create new mathModel.
MathDescription mathDesc = simContext.getMathDescription();
MathDescription newMathDesc = null;
newMathDesc = new MathDescription(name + "_" + (new java.util.Random()).nextInt());
try {
if (mathDesc.getGeometry().getDimension() > 0 && mathDesc.getGeometry().getGeometrySurfaceDescription().getGeometricRegions() == null) {
mathDesc.getGeometry().getGeometrySurfaceDescription().updateAll();
}
} catch (ImageException e) {
e.printStackTrace(System.out);
throw new RuntimeException("Geometric surface generation error:\n" + e.getMessage());
} catch (GeometryException e) {
e.printStackTrace(System.out);
throw new RuntimeException("Geometric surface generation error:\n" + e.getMessage());
}
newMathDesc.setGeometry(mathDesc.getGeometry());
newMathDesc.read_database(new CommentStringTokenizer(mathDesc.getVCML_database()));
newMathDesc.isValid();
newMathModel.setName(name);
newMathModel.setMathDescription(newMathDesc);
hashTable.put("newMathModel", newMathModel);
}
};
AsynchClientTask task2 = new AsynchClientTask("Creating MathModel from BioModel Application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathModel newMathModel = (MathModel) hashTable.get("newMathModel");
DocumentWindowManager windowManager = createDocumentWindowManager(newMathModel);
if (simContext.getBioModel().getVersion() != null) {
((MathModelWindowManager) windowManager).setCopyFromBioModelAppVersionableTypeVersion(new VersionableTypeVersion(VersionableType.BioModelMetaData, simContext.getBioModel().getVersion()));
}
DocumentWindow dw = getMdiManager().createNewDocumentWindow(windowManager);
setFinalWindow(hashTable, dw);
}
};
ClientTaskDispatcher.dispatch(requester.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
use of org.vcell.util.document.VersionableTypeVersion in project vcell by virtualcell.
the class DbDriver method findAllChildren.
/**
* This method was created in VisualAge.
* @return java.util.Hashtable
*/
private static void findAllChildren(java.sql.Connection con, VersionableTypeVersion vtv, VersionableFamily refs) throws DataAccessException, SQLException {
// Get VersionableTypes(tables) which possibly are children of argument vType
Vector<VersionRef> possibleRefs = VersionTable.getChildVersionableTypes(vtv.getVType());
Enumeration<VersionRef> enum1 = possibleRefs.elements();
UserTable userTable = UserTable.table;
while (enum1.hasMoreElements()) {
VersionRef vr = enum1.nextElement();
// BEGIN check VersionableType for children of versionKey
String sql = null;
VersionTable table = VersionTable.getVersionTable(vr.getVType());
VersionTable vtvTable = VersionTable.getVersionTable(vtv.getVType());
if (vr.getLinkField() == null) {
//
// direct link between versionable types
//
sql = "SELECT " + table.id.getQualifiedColName() + "," + table.name.getQualifiedColName() + "," + table.ownerRef.getQualifiedColName() + "," + table.privacy.getQualifiedColName() + "," + table.versionBranchPointRef.getQualifiedColName() + "," + table.versionDate.getQualifiedColName() + "," + table.versionFlag.getQualifiedColName() + "," + table.versionAnnot.getQualifiedColName() + "," + table.versionBranchID.getQualifiedColName() + "," + userTable.userid.getQualifiedColName() + " FROM " + table.getTableName() + "," + userTable.getTableName() + "," + vtvTable.getTableName() + " WHERE " + vr.getRefField().getQualifiedColName() + " = " + table.id.getQualifiedColName() + " AND " + vtvTable.id.getQualifiedColName() + " = " + vtv.getVersion().getVersionKey() + " AND " + table.ownerRef.getQualifiedColName() + " = " + userTable.getTableName() + "." + userTable.id;
} else {
//
// indirect link between versionable types (Link Table ... e.g. BioModelSimulationLinkTable)
//
sql = "SELECT " + table.id.getQualifiedColName() + "," + table.name.getQualifiedColName() + "," + table.ownerRef.getQualifiedColName() + "," + table.privacy.getQualifiedColName() + "," + table.versionBranchPointRef.getQualifiedColName() + "," + table.versionDate.getQualifiedColName() + "," + table.versionFlag.getQualifiedColName() + "," + table.versionAnnot.getQualifiedColName() + "," + table.versionBranchID.getQualifiedColName() + "," + userTable.userid.getQualifiedColName() + " FROM " + table.getTableName() + "," + userTable.getTableName() + "," + vr.getLinkField().getTableName() + " WHERE " + vr.getRefField().getQualifiedColName() + " = " + table.id.getQualifiedColName() + " AND " + vr.getLinkField().getQualifiedColName() + " = " + vtv.getVersion().getVersionKey() + " AND " + table.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
}
java.sql.Statement stmt = con.createStatement();
Vector<VersionableTypeVersion> allChildrenVTV = new Vector<VersionableTypeVersion>();
try {
// Get KeyValues from statement and put into Vector, so we can close statement(good idea because we are recursive)
java.sql.ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
try {
BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = VersionTable.getVersion(rset, getGroupAccessFromGroupID(con, groupid));
VersionableTypeVersion childVTV = new VersionableTypeVersion(vr.getVType(), version);
allChildrenVTV.addElement(childVTV);
} catch (Throwable e) {
throw new DataAccessException(e.getMessage());
}
}
} finally {
stmt.close();
}
//
for (int c = 0; c < allChildrenVTV.size(); c += 1) {
VersionableTypeVersion childVTV = allChildrenVTV.elementAt(c);
//
// Add VersionableRelationship to children of refs
//
refs.addChildRelationship(new VersionableRelationship(vtv, childVTV));
//
// Check referencingVTV for children to it(Recursion)
//
findAllChildren(con, childVTV, refs);
}
}
}
use of org.vcell.util.document.VersionableTypeVersion in project vcell by virtualcell.
the class DbDriver method getAllReferences.
/**
* This method was created in VisualAge.
* @return java.util.Hashtable
*/
public static VersionableFamily getAllReferences(java.sql.Connection con, VersionableType vType, KeyValue keyValue) throws DataAccessException, SQLException {
VersionableTypeVersion vtv = new VersionableTypeVersion(vType, getVersionFromKeyValue(con, vType, keyValue));
VersionableFamily refs = new VersionableFamily(vtv);
findAllReferences(con, refs.getTarget(), refs);
findAllChildren(con, refs.getTarget(), refs);
return refs;
}
use of org.vcell.util.document.VersionableTypeVersion in project vcell by virtualcell.
the class DBTopLevel method findReferences.
/**
* Insert the method's description here.
* Creation date: (11/6/2005 10:16:41 AM)
* @return cbit.vcell.modeldb.ReferenceQueryResult
* @param user cbit.vcell.server.User
* @param rqs cbit.vcell.modeldb.ReferenceQuerySpec
*/
ReferenceQueryResult findReferences(User user, ReferenceQuerySpec rqs2, boolean bEnableRetry) throws DataAccessException, java.sql.SQLException {
Object lock = new Object();
Connection con = conFactory.getConnection(lock);
try {
// Use MathDescription for search if ExternalData
VersionableType rqsVType = null;
KeyValue[] vTypeKeys = null;
if (rqs2.isVersionableType()) {
rqsVType = rqs2.getVersionableType();
vTypeKeys = new KeyValue[] { rqs2.getKeyValue() };
} else if (rqs2.isExternalDataIdentiferType()) {
DbDriver.cleanupDeletedReferences(con, user, rqs2.getExternalDataIdentifier(), false);
con.commit();
rqsVType = VersionableType.MathDescription;
vTypeKeys = getMathDescKeysForExternalData(rqs2.getKeyValue(), user, true);
if (vTypeKeys == null || vTypeKeys.length == 0) {
return null;
}
}
if (rqsVType == null) {
throw new DataAccessException("findAllReferences error: Couldn't determine Query type");
}
VersionableFamily finalVersionalbeFamily = null;
for (int k = 0; k < vTypeKeys.length; k += 1) {
// Find references
VersionableFamily vf = getAllReferences(user, vTypeKeys[k], rqsVType, true);
// Check permission
if (vf.bDependants()) {
VersionableTypeVersion[] vtvArr = vf.getUniqueDependants();
for (int i = 0; i < vtvArr.length; i += 1) {
if (vtvArr[i].getVType().equals(VersionableType.BioModelMetaData)) {
Vector<VersionInfo> checkedVInfos = getVersionableInfos(user, vtvArr[i].getVersion().getVersionKey(), VersionableType.BioModelMetaData, false, true, true);
if (checkedVInfos == null || checkedVInfos.size() == 0) {
throw new DataAccessException("References Not Accessible");
}
} else if (vtvArr[i].getVType().equals(VersionableType.MathModelMetaData)) {
Vector<VersionInfo> checkedVInfos = getVersionableInfos(user, vtvArr[i].getVersion().getVersionKey(), VersionableType.MathModelMetaData, false, true, true);
if (checkedVInfos == null || checkedVInfos.size() == 0) {
throw new DataAccessException("References Not Accessible");
}
}
}
}
if (finalVersionalbeFamily == null) {
finalVersionalbeFamily = vf;
} else {
VersionableRelationship[] versRelArr = vf.getDependantRelationships();
for (int r = 0; r < versRelArr.length; r += 1) {
finalVersionalbeFamily.addDependantRelationship(versRelArr[r]);
}
}
}
return new ReferenceQueryResult(finalVersionalbeFamily);
} catch (Throwable e) {
lg.error(e.getMessage(), e);
if (bEnableRetry && isBadConnection(con)) {
conFactory.failed(con, lock);
return findReferences(user, rqs2, false);
} else {
handle_DataAccessException_SQLException(e);
// never gets here;
return null;
}
} finally {
conFactory.release(con, lock);
}
}
Aggregations