use of org.vcell.util.DependencyException in project vcell by virtualcell.
the class SimulationContextDbDriver method updateVersionable.
/**
* This method was created in VisualAge.
* @return cbit.image.VCImage
* @param user cbit.vcell.server.User
* @param image cbit.image.VCImage
*/
public KeyValue updateVersionable(InsertHashtable hash, Connection con, User user, SimulationContext simContext, KeyValue updatedMathDescKey, Model updatedModel, KeyValue updatedGeometryKey, boolean bVersion) throws DataAccessException, SQLException, RecordChangedException {
Version newVersion = null;
try {
newVersion = updateVersionableInit(hash, con, user, simContext, bVersion);
insertSimulationContext(hash, con, user, simContext, updatedMathDescKey, updatedModel, updatedGeometryKey, newVersion, bVersion);
} catch (DependencyException e) {
lg.error(e.getMessage(), e);
throw new DataAccessException("MathException: " + e.getMessage());
}
return newVersion.getVersionKey();
}
use of org.vcell.util.DependencyException in project vcell by virtualcell.
the class SimulationDbDriver method deleteSimulationSQL.
/**
* removeModel method comment.
*/
private void deleteSimulationSQL(Connection con, User user, KeyValue simKey) throws SQLException, DataAccessException, DependencyException {
//
// check for external references (from a BioModel or a MathModel)
//
failOnExternalRefs(con, MathModelSimulationLinkTable.table.simRef, MathModelSimulationLinkTable.table, simKey, SimulationTable.table);
failOnExternalRefs(con, BioModelSimulationLinkTable.table.simRef, BioModelSimulationLinkTable.table, simKey, SimulationTable.table);
//
// delete the Simulation (the ResultSetMetaData should be deleted by ON DELETE CASCADE)
//
String sql = DatabasePolicySQL.enforceOwnershipDelete(user, simTable, simTable.id.getQualifiedColName() + " = " + simKey);
updateCleanSQL(con, sql);
//
// try to delete the parentSimulation ... it's OK if it fails
//
KeyValue parentSimKey = getParentSimulation(con, user, simKey);
if (parentSimKey != null) {
try {
deleteVersionable(con, user, VersionableType.Simulation, parentSimKey);
} catch (Exception e) {
lg.error("failed to delete parent simulation, key=" + parentSimKey + ": " + e.getMessage(), e);
}
}
}
use of org.vcell.util.DependencyException in project vcell by virtualcell.
the class SimulationContextDbDriver method deleteSimContextSQL.
/**
* removeModel method comment.
*/
private void deleteSimContextSQL(Connection con, User user, KeyValue simContextKey) throws SQLException, PermissionException, DataAccessException, DependencyException {
// log.print("deleteSimContextSQL(user=" + user + ", simContextKey=" + simContextKey + ")");
//
// check for external references (from BioModel)
//
failOnExternalRefs(con, BioModelSimContextLinkTable.table.simContextRef, BioModelSimContextLinkTable.table, simContextKey, SimContextTable.table);
KeyValue mathKey = getDeletableMathKeyFromSimContext(con, user, simContextKey);
//
// delete SimulationContext (Model and Geometry link tables are ON DELETE CASCADE)
//
String sql;
sql = DatabasePolicySQL.enforceOwnershipDelete(user, simContextTable, simContextTable.id.getQualifiedColName() + " = " + simContextKey);
updateCleanSQL(con, sql);
//
try {
mathDescDB.deleteVersionable(con, user, VersionableType.MathDescription, mathKey);
if (lg.isTraceEnabled()) {
lg.trace("SimulationContextDbDriver.delete(" + simContextKey + ") deletion of MathDescription(" + mathKey + ") succeeded");
}
} catch (PermissionException | DependencyException e) {
if (lg.isWarnEnabled()) {
lg.warn("SimulationContextDbDriver.delete(" + simContextKey + ") deletion of MathDescription(" + mathKey + ") failed: " + e.getMessage());
}
}
}
use of org.vcell.util.DependencyException in project vcell by virtualcell.
the class DbDriver method deleteVersionableInit.
/**
* This method was created in VisualAge.
* @param user cbit.vcell.server.User
* @param vType int
* @param versionKey cbit.sql.KeyValue
*/
protected void deleteVersionableInit(Connection con, User user, VersionableType vType, KeyValue versionKey) throws DependencyException, ObjectNotFoundException, SQLException, DataAccessException, PermissionException {
Vector<VersionInfo> versionInfoVector = getVersionableInfos(con, user, vType, true, versionKey, true, dbSyntax);
if (versionInfoVector.size() == 0) {
throw new ObjectNotFoundException("DbDriver:deleteVersionableInit " + vType.getTypeName() + "(" + versionKey + ") not found for user=" + user);
} else if (versionInfoVector.size() > 1) {
throw new DataAccessException("DbDriver:deleteVersionableInit " + vType.getTypeName() + "(" + versionKey + ") found more than one entry DB ERROR,BAD!!!!!MUST CHECK");
}
VersionInfo versionInfo = versionInfoVector.firstElement();
//
if (versionInfo.getVersion().getFlag().compareEqual(VersionFlag.Archived) || versionInfo.getVersion().getFlag().compareEqual(VersionFlag.Published)) {
throw new DataAccessException("DbDriver:deleteVersionableInit " + vType.getTypeName() + "(" + versionKey + ") Cannot DELETE\n" + "because document " + versionInfo.getVersion().getName() + "(" + versionInfo.getVersion().getDate() + ") is " + (versionInfo.getVersion().getFlag().compareEqual(VersionFlag.Archived) ? "ARCHIVED" : "PUBLISHED"));
}
//
if (!versionInfo.getVersion().getOwner().compareEqual(user)) {
throw new PermissionException("deletion failed on " + vType.getTypeName() + " '" + versionInfo.getVersion().getName() + "' (" + versionKey + "), not owned by user " + user);
}
//
if (versionInfo.getVersion().getFlag().isArchived()) {
throw new PermissionException("deletion failed on archived " + vType.getTypeName() + " '" + versionInfo.getVersion().getName() + "' (" + versionKey + ")");
}
//
if (isBranchPointOrBaseSimulation(con, vType, versionKey)) {
throw new DependencyException(VersionTable.getVersionTable(vType) + ",id=" + versionKey + " can't be deleted, it is either a branch point or a base Simulation");
}
// if(VersionTable.hasExternalRef(con,user,vType,versionKey)){
// throw new DependencyException( vTable + ",id=" + versionKey + " has external references");
// }
updateCleanSQL(con, "DELETE FROM " + SoftwareVersionTable.table.getTableName() + " WHERE " + SoftwareVersionTable.table.versionableRef.toString() + " = " + versionKey.toString());
}
Aggregations