use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class VCellBasicCellRenderer method getTreeCellRendererComponent.
/**
* Insert the method's description here.
* Creation date: (7/27/2000 6:41:57 PM)
* @return java.awt.Component
*/
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
//
if (!leaf && expanded) {
setIcon(fieldFolderOpenIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedIcon);
}
try {
if (value instanceof BioModelNode) {
BioModelNode node = (BioModelNode) value;
boolean bLoaded = false;
//
// Check if node is a SolverResultSetInfo
//
Object userObject = node.getUserObject();
if (userObject instanceof SimulationInfo) {
//
// Check if node is a SimulationInfo
//
setComponentProperties(component, (SimulationInfo) userObject);
int maxErrorLevel = getMaxErrorLevel(node);
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
setIcon(fieldSimulationWarningIcon);
component.setToolTipText("Simulation contains possibly invalid results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
setIcon(fieldSimulationErrorIcon);
component.setToolTipText("Simulation contains invalid results");
}
} else if (userObject instanceof String && node.getChildCount() == 0) {
component.setToolTipText(null);
component.setText((String) userObject);
} else if (userObject instanceof BioModelInfo) {
//
// Check if node is a BioModelInfo
//
setComponentProperties(component, (BioModelInfo) userObject);
bLoaded = isLoaded((BioModelInfo) userObject);
int maxErrorLevel = getMaxErrorLevel(node);
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
setIcon(fieldBioModelWarningIcon);
component.setToolTipText("BioModel version: Has possibly invalid simulation results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
setIcon(fieldBioModelErrorIcon);
component.setToolTipText("BioModel version: Has invalid simulation results");
}
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
//
// Check if node is a BioModelName (String), with children (at least one version of biomodel), and if the child is a
// BioModelInfo node
//
String label = (String) userObject;
component.setToolTipText("BioModel");
component.setText(label);
//
// check if child is loaded
//
int maxErrorLevel = BioModelNode.ERROR_NONE;
for (int i = 0; i < node.getChildCount(); i++) {
maxErrorLevel = Math.max(maxErrorLevel, getMaxErrorLevel((BioModelNode) node.getChildAt(i)));
}
if (maxErrorLevel == BioModelNode.ERROR_POSSIBLE) {
if (!leaf && expanded) {
setIcon(fieldFolderOpenWarningIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedWarningIcon);
}
component.setToolTipText("BioModel: one or more versions may have invalid simulation results");
} else if (maxErrorLevel == BioModelNode.ERROR_CONFIRMED) {
if (!leaf && expanded) {
setIcon(fieldFolderOpenErrorIcon);
} else if (!leaf && !expanded) {
setIcon(fieldFolderClosedErrorIcon);
}
component.setToolTipText("BioModel: one or more versions have invalid simulation results");
}
//
for (int i = 0; i < node.getChildCount(); i++) {
BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(bioModelInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof BioModelInfo) {
//
// Check if node is a User, with at least one child which is a string (BioModel name)
// and if the child's child is a BioModelInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof MathModelInfo) {
//
// Check if node is a MathModelInfo node
//
setComponentProperties(component, (MathModelInfo) userObject);
bLoaded = isLoaded((MathModelInfo) userObject);
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof MathModelInfo) {
//
// Check if node is a MathModel name (String), with children (at least one version of mathmodel), and
// if the child is a MathModelInfo node
//
String label = (String) userObject;
component.setToolTipText("Mathematical Model");
component.setText(label);
//
for (int i = 0; i < node.getChildCount(); i++) {
MathModelInfo mathModelInfo = (MathModelInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(mathModelInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof MathModelInfo) {
//
// Check if node is a User, with at least one child which is a string (Mathmodel name)
// and if the child's child is a MathModelInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof cbit.vcell.geometry.GeometryInfo) {
//
// Check if node is a GeometryInfo
//
setComponentProperties(component, (GeometryInfo) userObject);
bLoaded = isLoaded((GeometryInfo) userObject);
} else if (userObject instanceof String && node.getChildCount() > 0 && ((BioModelNode) node.getChildAt(0)).getUserObject() instanceof GeometryInfo) {
//
// Check if node is a Geometry name (String), with children (at least one version of Geometry), and
// if the child is a GeometryInfo node
//
String label = (String) userObject;
component.setToolTipText("Geometry");
component.setText(label);
//
for (int i = 0; i < node.getChildCount(); i++) {
GeometryInfo geometryInfo = (GeometryInfo) ((BioModelNode) node.getChildAt(i)).getUserObject();
if (isLoaded(geometryInfo)) {
bLoaded = true;
}
}
} else if (userObject instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof GeometryInfo) {
//
// Check if node is a User, with at least one child which is a string (Geometry name)
// and if the child's child is a GeometryInfo node
//
String label = ((User) userObject).getName();
component.setToolTipText("User Name");
component.setText(label);
if (isLoaded((User) userObject)) {
bLoaded = true;
}
} else if (userObject instanceof String && node.getChildCount() > 0) {
component.setToolTipText(null);
component.setText((String) userObject);
// }else if (node.getUserObject() instanceof MathInfo) {
// setComponentProperties(component,(MathInfo)node.getUserObject());
} else if (userObject instanceof VCImageInfo) {
setComponentProperties(component, (VCImageInfo) userObject);
} else if (userObject instanceof Extent) {
setComponentProperties(component, (Extent) userObject);
} else if (userObject instanceof Annotation) {
setComponentProperties(component, (Annotation) userObject);
} else if (userObject instanceof MathModel) {
setComponentProperties(component, (MathModel) userObject);
} else if (userObject instanceof BioModel) {
setComponentProperties(component, (BioModel) userObject);
} else if (userObject instanceof SimulationContext) {
setComponentProperties(component, (SimulationContext) userObject);
bLoaded = isLoaded((SimulationContext) userObject);
} else if (userObject instanceof Simulation) {
setComponentProperties(component, (Simulation) userObject);
} else if (userObject instanceof MathDescription) {
setComponentProperties(component, (MathDescription) userObject);
} else if (userObject instanceof Geometry) {
setComponentProperties(component, (Geometry) userObject);
} else if (userObject instanceof User) {
setComponentProperties(component, (User) userObject);
} else {
setComponentProperties(component, userObject);
}
if (selectedFont == null && component.getFont() != null) {
selectedFont = component.getFont().deriveFont(Font.BOLD);
}
if (unselectedFont == null && component.getFont() != null) {
unselectedFont = component.getFont().deriveFont(Font.PLAIN);
}
if (bLoaded) {
component.setFont(selectedFont);
} else {
component.setFont(unselectedFont);
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
}
//
return component;
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class BioModelWindowManager method updateSimulationDataViewers.
/**
* Insert the method's description here.
* Creation date: (7/20/2004 1:13:06 PM)
*/
private void updateSimulationDataViewers(ApplicationComponents appComponents, SimulationContext found) {
SimulationWindow[] simWindows = appComponents.getSimulationWindows();
Simulation[] sims = found.getSimulations();
Hashtable<VCSimulationIdentifier, Simulation> hash = new Hashtable<VCSimulationIdentifier, Simulation>();
for (int i = 0; i < sims.length; i++) {
SimulationInfo simInfo = sims[i].getSimulationInfo();
if (simInfo != null) {
VCSimulationIdentifier vcSimulationIdentifier = simInfo.getAuthoritativeVCSimulationIdentifier();
hash.put(vcSimulationIdentifier, sims[i]);
}
}
for (int i = 0; i < simWindows.length; i++) {
SimulationWindow sw = simWindows[i];
if (hash.containsKey(simWindows[i].getVcSimulationIdentifier())) {
sw.resetSimulation((Simulation) hash.get(sw.getVcSimulationIdentifier()));
} else if (sw.isShowingLocalSimulation()) {
sw.setLocalState(LocalState.LOCAL_SIMMODFIED);
} else {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getJPanel());
ChildWindow childWindow = childWindowManager.getChildWindowFromContext(sw);
if (childWindow != null) {
childWindowManager.closeChildWindow(childWindow);
}
}
}
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class SimulationDispatcherEngine method onStartRequest.
/**
* @param vcMessage
* @param session
* @throws VCMessagingException
* @throws SQLException
* @throws DataAccessException
*/
public void onStartRequest(VCSimulationIdentifier vcSimID, User user, int simulationScanCount, SimulationDatabase simulationDatabase, VCMessageSession session, VCMessageSession dispatcherQueueSession) throws VCMessagingException, DataAccessException, SQLException {
KeyValue simKey = vcSimID.getSimulationKey();
SimulationInfo simulationInfo = null;
try {
simulationInfo = simulationDatabase.getSimulationInfo(user, simKey);
} catch (DataAccessException ex) {
if (lg.isWarnEnabled())
lg.warn("Bad simulation " + vcSimID);
StatusMessage message = new StatusMessage(new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, -1, null, SchedulerStatus.FAILED, 0, SimulationMessage.workerFailure("Failed to dispatch simulation: " + ex.getMessage()), null, null), user.getName(), null, null);
message.sendToClient(session);
return;
}
if (simulationInfo == null) {
if (lg.isWarnEnabled())
lg.warn("Can't start, simulation [" + vcSimID + "] doesn't exist in database");
StatusMessage message = new StatusMessage(new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, -1, null, SchedulerStatus.FAILED, 0, SimulationMessage.workerFailure("Can't start, simulation [" + vcSimID + "] doesn't exist"), null, null), user.getName(), null, null);
message.sendToClient(session);
return;
}
if (simulationScanCount > Integer.parseInt(cbit.vcell.resource.PropertyLoader.getRequiredProperty(cbit.vcell.resource.PropertyLoader.maxJobsPerScan))) {
if (lg.isWarnEnabled())
lg.warn("Too many simulations (" + simulationScanCount + ") for parameter scan." + vcSimID);
StatusMessage message = new StatusMessage(new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, -1, null, SchedulerStatus.FAILED, 0, SimulationMessage.workerFailure("Too many simulations (" + simulationScanCount + ") for parameter scan."), null, null), user.getName(), null, null);
message.sendToClient(session);
return;
}
for (int jobIndex = 0; jobIndex < simulationScanCount; jobIndex++) {
SimulationStateMachine simStateMachine = getSimulationStateMachine(simKey, jobIndex);
try {
simStateMachine.onStartRequest(user, vcSimID, simulationDatabase, session);
} catch (UpdateSynchronizationException e) {
simStateMachine.onStartRequest(user, vcSimID, simulationDatabase, session);
}
}
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class DbDriver method testSuiteGet.
/**
* Insert the method's description here.
* Creation date: (10/16/2004 2:39:49 PM)
* @return cbit.vcell.numericstest.TestSuiteInfoNew[]
*/
public static TestSuiteNew testSuiteGet(BigDecimal getThisTS, Connection con, User user, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
if (!user.isTestAccount()) {
throw new PermissionException("User=" + user.getName() + " not allowed TestSuiteInfo");
}
// if(testSuiteHash.containsKey(getThisTS)){
// return (cbit.vcell.numericstest.TestSuiteNew)testSuiteHash.get(getThisTS);
// }
Hashtable simulationInfoH = new Hashtable();
Hashtable mathModelInfoH = new Hashtable();
Hashtable bioModelInfoH = new Hashtable();
Statement stmt = null;
ResultSet rset = null;
String sql = null;
Level origLogLevel = DatabasePolicySQL.lg.getLevel();
try {
DatabasePolicySQL.lg.setLevel(Level.WARN);
// double begTime=System.currentTimeMillis();
// int counter = 0;
stmt = con.createStatement();
// Get VariableComparisonSummaries
Hashtable vcsH = new Hashtable();
{
sql = "SELECT " + TFTestResultTable.table.getTableName() + ".*" + " FROM " + TFTestResultTable.table.getTableName() + "," + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.id.getQualifiedColName() + "=" + TFTestResultTable.table.testCriteriaRef.getQualifiedColName() + " ORDER BY UPPER(" + TFTestResultTable.table.varName.getQualifiedColName() + ")";
rset = stmt.executeQuery(sql);
while (rset.next()) {
BigDecimal tcritRef = rset.getBigDecimal(TFTestResultTable.table.testCriteriaRef.getUnqualifiedColName());
String varName = rset.getString(TFTestResultTable.table.varName.getUnqualifiedColName());
double absError = rset.getDouble(TFTestResultTable.table.absError.getUnqualifiedColName());
double relError = rset.getDouble(TFTestResultTable.table.relError.getUnqualifiedColName());
double maxRef = rset.getDouble(TFTestResultTable.table.maxRef.getUnqualifiedColName());
double minRef = rset.getDouble(TFTestResultTable.table.minRef.getUnqualifiedColName());
double mse = rset.getDouble(TFTestResultTable.table.meanSqrError.getUnqualifiedColName());
double timeAbsError = rset.getDouble(TFTestResultTable.table.timeAbsError.getUnqualifiedColName());
int indexAbsError = rset.getInt(TFTestResultTable.table.indexAbsError.getUnqualifiedColName());
double timeRelError = rset.getDouble(TFTestResultTable.table.timeRelError.getUnqualifiedColName());
int indexRelError = rset.getInt(TFTestResultTable.table.indexRelError.getUnqualifiedColName());
Vector v = (Vector) vcsH.get(tcritRef);
if (v == null) {
v = new Vector();
vcsH.put(tcritRef, v);
}
v.add(new VariableComparisonSummary(varName, minRef, maxRef, absError, relError, mse, timeAbsError, indexAbsError, timeRelError, indexRelError));
// counter+= 1;
}
// System.out.println("VCS count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
rset.close();
}
// begTime=System.currentTimeMillis();
// counter = 0;
// Get TestCriteria for mathModel based TestCases
Hashtable tcritH = new Hashtable();
{
sql = "SELECT " + TFTestCriteriaTable.table.getTableName() + ".*" + "," + MathModelSimulationLinkTable.table.getTableName() + ".*" + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + MathModelSimulationLinkTable.table.getTableName() + "," + SimulationTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " IS NOT NULL " + " AND " + TFTestCriteriaTable.table.simulationRef.getQualifiedColName() + "=" + SimulationTable.table.id.getQualifiedColName() + " AND " + TFTestCriteriaTable.table.regressionMMSimRef.getQualifiedColName() + "=" + MathModelSimulationLinkTable.table.id.getQualifiedColName() + "(+)" + " ORDER BY UPPER(" + SimulationTable.table.name.getQualifiedColName() + ")";
// System.out.println(sql);
rset = stmt.executeQuery(sql);
while (rset.next()) {
BigDecimal tcritKey = rset.getBigDecimal(TFTestCriteriaTable.table.id.getUnqualifiedColName());
BigDecimal tcaseRef = rset.getBigDecimal(TFTestCriteriaTable.table.testCaseRef.getUnqualifiedColName());
BigDecimal simRef = rset.getBigDecimal(TFTestCriteriaTable.table.simulationRef.getUnqualifiedColName());
BigDecimal simRegrRef = rset.getBigDecimal(MathModelSimulationLinkTable.table.simRef.getUnqualifiedColName());
if (rset.wasNull()) {
simRegrRef = null;
}
BigDecimal mathRegrRef = rset.getBigDecimal(MathModelSimulationLinkTable.table.mathModelRef.getUnqualifiedColName());
if (rset.wasNull()) {
mathRegrRef = null;
}
Double maxRelError = null;
double dtemp = rset.getDouble(TFTestCriteriaTable.table.maxRelError.getUnqualifiedColName());
if (rset.wasNull()) {
maxRelError = null;
} else {
maxRelError = new Double(dtemp);
}
Double maxAbsError = null;
dtemp = rset.getDouble(TFTestCriteriaTable.table.maxAbsError.getUnqualifiedColName());
if (rset.wasNull()) {
maxAbsError = null;
} else {
maxAbsError = new Double(dtemp);
}
String reportStatus = rset.getString(TFTestCriteriaTable.table.reportStatus.getUnqualifiedColName());
if (rset.wasNull()) {
reportStatus = TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT;
}
String reportStatusMessage = rset.getString(TFTestCriteriaTable.table.reportMessage.getUnqualifiedColName());
if (rset.wasNull()) {
reportStatusMessage = null;
}
if (reportStatusMessage != null && reportStatusMessage.length() > 0) {
reportStatusMessage = TokenMangler.getSQLRestoredString(reportStatusMessage);
}
Vector v = (Vector) tcritH.get(tcaseRef);
if (v == null) {
v = new Vector();
tcritH.put(tcaseRef, v);
}
SimulationInfo simInfo = (SimulationInfo) simulationInfoH.get(simRef);
if (simInfo == null) {
Vector<VersionInfo> simVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(simRef), false, dbSyntax);
if (simVector != null && simVector.size() > 0) {
simInfo = (SimulationInfo) simVector.firstElement();
simulationInfoH.put(simRef, simInfo);
}
}
SimulationInfo regrSimInfo = null;
MathModelInfo regrMathModelInfo = null;
if (simRegrRef != null) {
regrSimInfo = (SimulationInfo) simulationInfoH.get(simRegrRef);
if (regrSimInfo == null) {
Vector<VersionInfo> regSimVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(simRegrRef), false, dbSyntax);
if (regSimVector != null && regSimVector.size() > 0) {
regrSimInfo = (SimulationInfo) regSimVector.firstElement();
simulationInfoH.put(simRegrRef, regrSimInfo);
}
}
regrMathModelInfo = (MathModelInfo) mathModelInfoH.get(mathRegrRef);
if (regrMathModelInfo == null) {
Vector<VersionInfo> regMathVector = getVersionableInfos(con, user, VersionableType.MathModelMetaData, false, new KeyValue(mathRegrRef), false, dbSyntax);
if (regMathVector != null && regMathVector.size() > 0) {
regrMathModelInfo = (MathModelInfo) regMathVector.firstElement();
mathModelInfoH.put(mathRegrRef, regrMathModelInfo);
}
}
}
//
VariableComparisonSummary[] neededVCSArr = null;
Vector vcsV = (Vector) vcsH.get(tcritKey);
if (vcsV != null) {
neededVCSArr = new VariableComparisonSummary[vcsV.size()];
vcsV.copyInto(neededVCSArr);
}
//
TestCriteriaNew tcn = null;
if (simInfo != null) {
tcn = new TestCriteriaNewMathModel(tcritKey, simInfo, regrMathModelInfo, regrSimInfo, maxRelError, maxAbsError, neededVCSArr, reportStatus, reportStatusMessage);
v.add(tcn);
}
// counter+= 1;
}
// System.out.println("TCrit count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
rset.close();
}
// Get TestCriteria for bioModel based TestCases
// Hashtable tcritH = new Hashtable();
{
final String REGRSIMREF = "REGRSIMREF";
final String SCNAME = "SCNAME";
sql = "SELECT " + TFTestCriteriaTable.table.getTableName() + ".*" + "," + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "," + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + " " + REGRSIMREF + "," + SimContextTable.table.name.getQualifiedColName() + " " + SCNAME + " FROM " + TFTestCriteriaTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + BioModelSimulationLinkTable.table.getTableName() + // SimulationTable.table.getTableName()+
" WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.id.getQualifiedColName() + "=" + TFTestCriteriaTable.table.testCaseRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " IS NOT NULL " + " AND " + TFTestCriteriaTable.table.regressionBMAPPRef.getQualifiedColName() + "=" + BioModelSimContextLinkTable.table.id.getQualifiedColName() + "(+)" + " AND " + BioModelSimContextLinkTable.table.simContextRef + " = " + SimContextTable.table.id.getQualifiedColName() + "(+)" + // SimContextTable.table.mathRef.getQualifiedColName()+" = "+SimulationTable.table.mathRef.getQualifiedColName()+"(+)" +
" AND " + TFTestCriteriaTable.table.regressionBMSimRef.getQualifiedColName() + " = " + BioModelSimulationLinkTable.table.id.getQualifiedColName() + "(+)";
// System.out.println(sql);
rset = stmt.executeQuery(sql);
while (rset.next()) {
BigDecimal tcritKey = rset.getBigDecimal(TFTestCriteriaTable.table.id.getUnqualifiedColName());
BigDecimal tcaseRef = rset.getBigDecimal(TFTestCriteriaTable.table.testCaseRef.getUnqualifiedColName());
BigDecimal tcSimRef = rset.getBigDecimal(TFTestCriteriaTable.table.simulationRef.getUnqualifiedColName());
BigDecimal regrSimRef = rset.getBigDecimal(REGRSIMREF);
// BigDecimal regrSimRef = rset.getBigDecimal(SimulationTable.table.id.getUnqualifiedColName());
if (rset.wasNull()) {
regrSimRef = null;
}
BigDecimal regrBioModelRef = rset.getBigDecimal(BioModelSimContextLinkTable.table.bioModelRef.getUnqualifiedColName());
if (rset.wasNull()) {
regrBioModelRef = null;
}
String regrSCName = rset.getString(SCNAME);
if (rset.wasNull()) {
regrSCName = null;
}
Double maxRelError = null;
double dtemp = rset.getDouble(TFTestCriteriaTable.table.maxRelError.getUnqualifiedColName());
if (rset.wasNull()) {
maxRelError = null;
} else {
maxRelError = new Double(dtemp);
}
Double maxAbsError = null;
dtemp = rset.getDouble(TFTestCriteriaTable.table.maxAbsError.getUnqualifiedColName());
if (rset.wasNull()) {
maxAbsError = null;
} else {
maxAbsError = new Double(dtemp);
}
String reportStatus = rset.getString(TFTestCriteriaTable.table.reportStatus.getUnqualifiedColName());
if (rset.wasNull()) {
reportStatus = TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT;
}
String reportStatusMessage = rset.getString(TFTestCriteriaTable.table.reportMessage.getUnqualifiedColName());
if (rset.wasNull()) {
reportStatusMessage = null;
}
if (reportStatusMessage != null && reportStatusMessage.length() > 0) {
reportStatusMessage = TokenMangler.getSQLRestoredString(reportStatusMessage);
}
Vector v = (Vector) tcritH.get(tcaseRef);
if (v == null) {
v = new Vector();
tcritH.put(tcaseRef, v);
}
SimulationInfo simInfo = (SimulationInfo) simulationInfoH.get(tcSimRef);
if (simInfo == null) {
Vector<VersionInfo> simVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(tcSimRef), false, dbSyntax);
if (simVector != null && simVector.size() == 1) {
simInfo = (SimulationInfo) simVector.firstElement();
simulationInfoH.put(tcSimRef, simInfo);
} else {
throw new DataAccessException("Found more than 1 versionable for tcsimRef=" + tcSimRef);
}
}
SimulationInfo regrSimInfo = null;
BioModelInfo regrBioModelInfo = null;
if (regrSimRef != null) {
regrSimInfo = (SimulationInfo) simulationInfoH.get(regrSimRef);
if (regrSimInfo == null) {
Vector<VersionInfo> regSimVector = getVersionableInfos(con, user, VersionableType.Simulation, false, new KeyValue(regrSimRef), false, dbSyntax);
if (regSimVector != null && regSimVector.size() == 1) {
regrSimInfo = (SimulationInfo) regSimVector.firstElement();
simulationInfoH.put(regrSimRef, regrSimInfo);
} else {
throw new DataAccessException("Found more than 1 versionable for simregRef=" + regrSimRef);
}
}
regrBioModelInfo = (BioModelInfo) mathModelInfoH.get(regrBioModelRef);
if (regrBioModelInfo == null) {
Vector<VersionInfo> regBioModelVector = getVersionableInfos(con, user, VersionableType.BioModelMetaData, false, new KeyValue(regrBioModelRef), false, dbSyntax);
if (regBioModelVector != null && regBioModelVector.size() == 1) {
regrBioModelInfo = (BioModelInfo) regBioModelVector.firstElement();
mathModelInfoH.put(regrBioModelRef, regrBioModelInfo);
} else {
throw new DataAccessException("Found more than 1 versionable for reegrbiomodelRef=" + regrBioModelRef);
}
}
}
//
VariableComparisonSummary[] neededVCSArr = null;
Vector vcsV = (Vector) vcsH.get(tcritKey);
if (vcsV != null) {
neededVCSArr = new VariableComparisonSummary[vcsV.size()];
vcsV.copyInto(neededVCSArr);
}
//
TestCriteriaNew tcn = null;
if (simInfo != null) {
tcn = new TestCriteriaNewBioModel(tcritKey, simInfo, regrBioModelInfo, regrSCName, regrSimInfo, maxRelError, maxAbsError, neededVCSArr, reportStatus, reportStatusMessage);
v.add(tcn);
}
// counter+= 1;
}
// System.out.println("TCrit count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
rset.close();
}
// Get TestCases
Vector tcV = new Vector();
// begTime=System.currentTimeMillis();
// counter = 0;
{
// final String BMSCL = "bmscl";
final String OBTCTYPECOLUMN = "OBTCTYPECOLUMN";
final String OBNAMECOLUMN = "OBNAMECOLUMN";
final String BMSCBMRNAME = "BMSCBMRNAME";
final String BMSCSCRNAME = "BMSCSCRNAME";
final String SCNAME = "SCNAME";
final String SORTHELP1 = "SORTHELP1";
final String SORTHELP2 = "SORTHELP2";
sql = "SELECT " + "UPPER(" + MathModelTable.table.name.getQualifiedColName() + ") " + SORTHELP1 + "," + "TO_CHAR(NULL) " + SORTHELP2 + "," + TFTestCaseTable.table.getTableName() + ".*" + "," + "TO_NUMBER(NULL) " + BMSCBMRNAME + "," + "TO_NUMBER(NULL) " + BMSCSCRNAME + "," + "TO_CHAR(NULL) " + SCNAME + "," + "'MM' " + OBTCTYPECOLUMN + "," + MathModelTable.table.name.getQualifiedColName() + " " + OBNAMECOLUMN + " FROM " + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + MathModelTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " IS NOT NULL" + " AND " + TFTestCaseTable.table.mathModelRef.getQualifiedColName() + " = " + MathModelTable.table.id.getQualifiedColName() + " UNION " + "SELECT " + "UPPER(" + BioModelTable.table.name.getQualifiedColName() + ") " + SORTHELP1 + ",UPPER(" + SimContextTable.table.name.getQualifiedColName() + ") " + SORTHELP2 + "," + TFTestCaseTable.table.getTableName() + ".*" + "," + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + " " + BMSCBMRNAME + "," + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " " + BMSCSCRNAME + "," + SimContextTable.table.name.getQualifiedColName() + " " + SCNAME + "," + "'BM' " + OBTCTYPECOLUMN + "," + BioModelTable.table.name.getQualifiedColName() + " " + OBNAMECOLUMN + " FROM " + BioModelSimContextLinkTable.table.getTableName() + "," + SimContextTable.table.getTableName() + "," + TFTestCaseTable.table.getTableName() + "," + TFTestSuiteTable.table.getTableName() + "," + BioModelTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " AND " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + TFTestCaseTable.table.testSuiteRef.getQualifiedColName() + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " IS NOT NULL" + " AND " + TFTestCaseTable.table.bmAppRef.getQualifiedColName() + " = " + BioModelSimContextLinkTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " = " + SimContextTable.table.id.getQualifiedColName() + " AND " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "=" + BioModelTable.table.id.getQualifiedColName() + // " ORDER BY 11,"+"UPPER(12)"+","+"UPPER(10)";
" ORDER BY 13,1,2";
rset = stmt.executeQuery(sql);
while (rset.next()) {
BigDecimal tcaseKey = rset.getBigDecimal(TFTestCaseTable.table.id.getUnqualifiedColName());
BigDecimal mmRef = rset.getBigDecimal(TFTestCaseTable.table.mathModelRef.getUnqualifiedColName());
if (rset.wasNull()) {
mmRef = null;
}
BigDecimal simContextRef = rset.getBigDecimal(BMSCSCRNAME);
if (rset.wasNull()) {
simContextRef = null;
}
BigDecimal bioModelRef = rset.getBigDecimal(BMSCBMRNAME);
if (rset.wasNull()) {
bioModelRef = null;
}
String simContextName = rset.getString(SCNAME);
if (rset.wasNull()) {
simContextName = null;
}
String tcType = rset.getString(TFTestCaseTable.table.tcSolutionType.getUnqualifiedColName());
String tcAnnot = rset.getString(TFTestCaseTable.table.tcAnnotation.getUnqualifiedColName());
if (rset.wasNull()) {
tcAnnot = "";
} else {
tcAnnot = TokenMangler.getSQLRestoredString(tcAnnot);
}
java.util.Date tcDate = VersionTable.getDate(rset, TFTestCaseTable.table.creationDate.getUnqualifiedColName());
MathModelInfo mmInfo = null;
BioModelInfo bmInfo = null;
if (mmRef != null) {
mmInfo = (MathModelInfo) mathModelInfoH.get(mmRef);
if (mmInfo == null) {
Vector<VersionInfo> mathVector = getVersionableInfos(con, user, VersionableType.MathModelMetaData, false, new KeyValue(mmRef), false, dbSyntax);
if (mathVector != null && mathVector.size() > 0) {
mmInfo = (MathModelInfo) mathVector.firstElement();
mathModelInfoH.put(mmRef, mmInfo);
}
}
} else if (bioModelRef != null) {
bmInfo = (BioModelInfo) bioModelInfoH.get(bioModelRef);
if (bmInfo == null) {
Vector<VersionInfo> bmAppVector = getVersionableInfos(con, user, VersionableType.BioModelMetaData, false, new KeyValue(bioModelRef), false, dbSyntax);
if (bmAppVector != null && bmAppVector.size() > 0) {
bmInfo = (BioModelInfo) bmAppVector.firstElement();
bioModelInfoH.put(bioModelRef, bmInfo);
}
}
} else {
throw new RuntimeException("Test case in DB does not have MathmodelRef or BioModelAppRef");
}
TestCriteriaNew[] neededTcritArr = null;
Vector needTcritV = (Vector) tcritH.get(tcaseKey);
if (needTcritV != null) {
neededTcritArr = new TestCriteriaNew[needTcritV.size()];
needTcritV.copyInto(neededTcritArr);
}
TestCaseNew tcn = null;
if (mmInfo != null) {
tcn = new TestCaseNewMathModel(tcaseKey, mmInfo, tcType, tcAnnot, neededTcritArr);
tcV.add(tcn);
} else if (bmInfo != null) {
tcn = new TestCaseNewBioModel(tcaseKey, bmInfo, simContextName, new KeyValue(simContextRef), tcType, tcAnnot, neededTcritArr);
tcV.add(tcn);
} else {
// throw new RuntimeException("Expected testCase MathModelInfo or BioModelInfo to be not null");
}
// counter+= 1;
}
// System.out.println("TCase count="+counter+" time="+((System.currentTimeMillis()-begTime)/1000));
rset.close();
}
// Get TestSuite
{
TestCaseNew[] tcnArr = null;
if (tcV.size() > 0) {
tcnArr = new TestCaseNew[tcV.size()];
tcV.copyInto(tcnArr);
}
sql = "SELECT " + TFTestSuiteTable.table.getTableName() + ".*" + " FROM " + TFTestSuiteTable.table.getTableName() + " WHERE " + TFTestSuiteTable.table.id.getQualifiedColName() + "=" + getThisTS + " ORDER BY UPPER(" + TFTestSuiteTable.table.tsVersion.getQualifiedColName() + ")";
rset = stmt.executeQuery(sql);
BigDecimal tsKey = null;
String tsVersion = null;
String tsVCBuild = null;
String tsNumericsBuild = null;
java.util.Date tsDate = null;
String tsAnnot = null;
boolean islocked = true;
if (rset.next()) {
tsKey = rset.getBigDecimal(TFTestSuiteTable.table.id.getUnqualifiedColName());
tsVersion = rset.getString(TFTestSuiteTable.table.tsVersion.getUnqualifiedColName());
tsVCBuild = rset.getString(TFTestSuiteTable.table.vcBuildVersion.getUnqualifiedColName());
tsNumericsBuild = rset.getString(TFTestSuiteTable.table.vcNumericsVersion.getUnqualifiedColName());
tsDate = VersionTable.getDate(rset, TFTestSuiteTable.table.creationDate.getUnqualifiedColName());
tsAnnot = rset.getString(TFTestSuiteTable.table.tsAnnotation.getUnqualifiedColName());
islocked = rset.getBoolean(TFTestSuiteTable.table.isLocked.getUnqualifiedColName());
} else {
throw new ObjectNotFoundException("TestSuite with key=" + getThisTS + " not found");
}
rset.close();
TestSuiteInfoNew tsiNew = new TestSuiteInfoNew(tsKey, tsVersion, tsVCBuild, tsNumericsBuild, tsDate, tsAnnot, islocked);
TestSuiteNew tsn = new TestSuiteNew(tsiNew, tcnArr);
// testSuiteHash.put(tsKey,tsn);
return tsn;
}
} catch (SQLException e) {
lg.error("failed: (" + sql + "): " + e.getMessage(), e);
throw e;
} finally {
DatabasePolicySQL.lg.setLevel(origLogLevel);
if (stmt != null) {
stmt.close();
}
}
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class SimulationTable method getInfo.
/**
* This method was created in VisualAge.
* @return cbit.vcell.geometry.GeometryInfo
* @param rset java.sql.ResultSet
* @param log cbit.vcell.server.SessionLog
*/
public VersionInfo getInfo(ResultSet rset, Connection con) throws SQLException, DataAccessException {
KeyValue mathRef = new KeyValue(rset.getBigDecimal(SimulationTable.table.mathRef.toString()));
java.math.BigDecimal groupid = rset.getBigDecimal(VersionTable.privacy_ColumnName);
Version version = getVersion(rset, DbDriver.getGroupAccessFromGroupID(con, groupid));
SimulationVersion simulationVersion = (SimulationVersion) version;
String softwareVersion = rset.getString(SoftwareVersionTable.table.softwareVersion.toString());
return new SimulationInfo(mathRef, simulationVersion, VCellSoftwareVersion.fromString(softwareVersion));
}
Aggregations