use of cbit.vcell.server.MathModelLink in project vcell by virtualcell.
the class SimulationJobsTableModel method getValueAt.
@Override
public Object getValueAt(int iRow, int iCol) {
SimpleJobStatus sjs = getValueAt(iRow);
if (sjs == null) {
return null;
}
switch(iCol) {
case iColModelApp:
if (sjs.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
return "(BM) " + bml.bioModelName + ", (App) " + bml.simContextName;
} else if (sjs.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
return "(MM) " + mml.mathModelName;
} else {
return null;
}
case iColSimulation:
return sjs.simulationMetadata.simname;
case iColSimId:
return sjs.simulationMetadata.vcSimID.getSimulationKey().toString() + " / " + sjs.jobStatus.getJobIndex() + " / " + sjs.jobStatus.getTaskID();
case iColSolver:
String str = "";
if (sjs.simulationMetadata.solverTaskDesc != null) {
str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription() == null ? "" : sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
return str;
case iColSubmitDate:
DateFormat df = new SimpleDateFormat("MM.dd.yyyy");
Date date = sjs.jobStatus.getStartDate();
return df.format(date);
case iColHasData:
return sjs.jobStatus.hasData() == true ? "Yes" : "No";
case iColStatus:
return sjs.jobStatus.getSchedulerStatus().getDescription();
case iColMessage:
return sjs.jobStatus.getSimulationMessage().getDisplayMessage();
case iColSite:
return sjs.jobStatus.getServerID().toString();
// return sjs.jobStatus.getComputeHost();
default:
return null;
}
}
use of cbit.vcell.server.MathModelLink in project vcell by virtualcell.
the class SimulationJobsTableModel method getComparator.
public Comparator<SimpleJobStatus> getComparator(final int col, final boolean ascending) {
final int scale = ascending ? 1 : -1;
return new Comparator<SimpleJobStatus>() {
public int compare(SimpleJobStatus o1, SimpleJobStatus o2) {
String s1 = "";
String s2 = "";
switch(col) {
case iColModelApp:
if (o1.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) o1.simulationDocumentLink;
s1 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (o1.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) o1.simulationDocumentLink;
s1 = "(MM) " + mml.mathModelName;
}
if (o2.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) o2.simulationDocumentLink;
s2 = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (o2.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) o2.simulationDocumentLink;
s2 = "(MM) " + mml.mathModelName;
}
return scale * s1.compareToIgnoreCase(s2);
case iColSimulation:
s1 = o1.simulationMetadata.simname;
s2 = o2.simulationMetadata.simname;
if (!s1.equalsIgnoreCase(s2)) {
return scale * s1.compareToIgnoreCase(s2);
} else {
// if same simulation, sort by date
Date d1 = o1.jobStatus.getStartDate();
Date d2 = o2.jobStatus.getStartDate();
return scale * d1.compareTo(d2);
}
case iColSimId:
s1 = o1.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o1.jobStatus.getJobIndex() + "," + o1.jobStatus.getTaskID();
s2 = o2.simulationMetadata.vcSimID.getSimulationKey().toString() + "," + o2.jobStatus.getJobIndex() + "," + o2.jobStatus.getTaskID();
return scale * s1.compareToIgnoreCase(s2);
case iColSolver:
if (o1.simulationMetadata.solverTaskDesc != null && o1.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
s1 = o1.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
if (o2.simulationMetadata.solverTaskDesc != null && o2.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
s2 = o2.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
}
return scale * s1.compareToIgnoreCase(s2);
case iColSubmitDate:
Date d1 = o1.jobStatus.getSubmitDate();
Date d2 = o2.jobStatus.getSubmitDate();
return scale * d1.compareTo(d2);
case iColHasData:
Boolean b1 = o1.jobStatus.hasData();
Boolean b2 = o2.jobStatus.hasData();
return scale * b1.compareTo(b2);
case iColStatus:
SchedulerStatus ss1 = o1.jobStatus.getSchedulerStatus();
SchedulerStatus ss2 = o2.jobStatus.getSchedulerStatus();
return scale * ss1.compareTo(ss2);
case iColMessage:
if (o1.jobStatus != null && o1.jobStatus.getSimulationMessage() != null) {
s1 = o1.jobStatus.getSimulationMessage().getDisplayMessage();
}
if (o2.jobStatus != null && o2.jobStatus.getSimulationMessage() != null) {
s2 = o2.jobStatus.getSimulationMessage().getDisplayMessage();
}
return scale * s1.compareToIgnoreCase(s2);
case iColSite:
s1 = o1.jobStatus.getServerID().toString();
s2 = o2.jobStatus.getServerID().toString();
return scale * s1.compareToIgnoreCase(s2);
default:
return 0;
}
}
};
}
use of cbit.vcell.server.MathModelLink in project vcell by virtualcell.
the class SimulationJobsTableModel method refreshData.
public void refreshData() {
List<SimpleJobStatus> allJobStatusList = new ArrayList<>();
for (SimpleJobStatus sjj : jobStatusArray) {
allJobStatusList.add(sjj);
}
// ----- apply filters that are not applied by running the query -----------------
List<SimpleJobStatus> filteredJobStatusList = new ArrayList<>();
if (owner.getOrphanedButton().isSelected()) {
// if checked, hide orphans
for (SimpleJobStatus sjj : allJobStatusList) {
if (sjj.simulationDocumentLink != null) {
filteredJobStatusList.add(sjj);
}
}
} else {
filteredJobStatusList = allJobStatusList;
}
// ------- apply search --------------------------------------------------------------------
List<SimpleJobStatus> jobStatusList = new ArrayList<>();
if (searchText == null || searchText.length() == 0) {
jobStatusList.addAll(filteredJobStatusList);
} else {
String lowerCaseSearchText = searchText.toLowerCase();
for (SimpleJobStatus sjs : filteredJobStatusList) {
// search in Solver column
if (sjs.simulationMetadata.solverTaskDesc != null && sjs.simulationMetadata.solverTaskDesc.getSolverDescription() != null) {
String str = sjs.simulationMetadata.solverTaskDesc.getSolverDescription().getDisplayLabel();
if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
// search in Message column
if (sjs.jobStatus != null && sjs.jobStatus.getSimulationMessage() != null) {
String str = sjs.jobStatus.getSimulationMessage().getDisplayMessage();
if (str != null && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
// search in Model name, Application name (if available)
String str = null;
if (sjs.simulationDocumentLink instanceof BioModelLink) {
BioModelLink bml = (BioModelLink) sjs.simulationDocumentLink;
str = "(BM) " + bml.bioModelName + ",(App) " + bml.simContextName;
} else if (sjs.simulationDocumentLink instanceof MathModelLink) {
MathModelLink mml = (MathModelLink) sjs.simulationDocumentLink;
str = "(MM) " + mml.mathModelName;
}
if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
// Search in Simulation name
str = sjs.simulationMetadata.simname;
if (str != null && !str.isEmpty() && str.toLowerCase().contains(lowerCaseSearchText)) {
jobStatusList.add(sjs);
continue;
}
}
}
setData(jobStatusList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
use of cbit.vcell.server.MathModelLink in project vcell by virtualcell.
the class SimulationJobDbDriver method getSimpleJobStatus.
/**
* Insert the method's description here.
* Creation date: (9/3/2003 8:59:46 AM)
* @return java.util.List of SimpleJobStatus for managementGUI
* @param conditions java.lang.String
*
* for the subqueries, here is a prototype query which returns the
*
* select
*vc_simulation_1.id as simid,
*(select max('{"bmid":"' || lpad(vc_biomodel.id,14,0) || '","scid":"' || lpad(vc_simcontext.id,14,0) || '","bmbranch":"' || lpad(vc_biomodel.versionbranchid,14,0) || '","scbranch":"' || lpad(vc_simcontext.versionbranchid,14,0) || '","bmname":"' || vc_biomodel.name || '","scname":"' || vc_simcontext.name || '"}')
*from vc_biomodel, vc_biomodelsimcontext, VC_BIOMODELSIM, vc_simcontext
*where vc_simulation_1.mathref = vc_simcontext.mathref
*and VC_BIOMODELSIMCONTEXT.SIMCONTEXTREF = VC_SIMCONTEXT.id
*and VC_BIOMODELSIMCONTEXT.BIOMODELREF = vc_biomodel.id
*and VC_BIOMODELSIM.SIMREF = VC_SIMULATION_1.id
*and VC_BIOMODELSIM.BIOMODELREF = vc_biomodel.id
*) as bmLink,
*(select max('{"mmid":"' || lpad(vc_mathmodel.id,14,0) || '","mmbranch":"' || lpad(vc_mathmodel.versionbranchid,14,0) || '","mmname":"' || vc_mathmodel.name || '"}')
*from vc_mathmodel, VC_MATHMODELSIM
*where vc_simulation_1.id = vc_mathmodelsim.SIMREF
*and vc_mathmodelsim.MATHMODELREF = vc_mathmodel.id
*) as mmLink
*from vc_simulation vc_simulation_1
*where rownum <= 10;
*
*which returns the biomodel link (bmlink) and the math model link (mmlink) as JSON strings to be interpreted as needed.
*
*simid bmlink mmlink
*2,006,065 <null> {"mmid":"00000002001619","mmbranch":"00000001008286","mmname":"Terasaki1"}
*2,006,075 <null> {"mmid":"00000002001626","mmbranch":"00000001008286","mmname":"Terasaki1"}
*2,006,085 <null> {"mmid":"00000002001636","mmbranch":"00000001008286","mmname":"Terasaki1"}
*2,637,970 {"bmid":"00000002669821","scid":"00000002637934","bmbranch":"00000002622407","scbranch":"00000002637935","bmname":"aggregation","scname":"diagonal gradient"} <null>
*2,006,427 <null> {"mmid":"00000002002108","mmbranch":"00000001002871","mmname":"DiffusionfromChannel"}
*2,006,437 <null> {"mmid":"00000002002110","mmbranch":"00000001002871","mmname":"DiffusionfromChannel"}
*2,006,646 <null> {"mmid":"00000002002254","mmbranch":"00000001118506","mmname":"AliciaProblem1"}
*10,067,537 {"bmid":"00000010067543","scid":"00000010067469","bmbranch":"00000010033822","scbranch":"00000010067470","bmname":"BMTest_biphasicStatModule1","scname":"figure5"} <null>
*10,369,972 {"bmid":"00000010369990","scid":"00000010369900","bmbranch":"00000010009521","scbranch":"00000010369901","bmname":"MemBinding_1","scname":"comp"} <null>
*2,007,278 <null> {"mmid":"00000002001884","mmbranch":"00000001036088","mmname":"Wave_no_nucl5"}
*/
public List<SimpleJobStatusPersistent> getSimpleJobStatus(Connection con, String conditions, int startRow, int maxNumRows) throws java.sql.SQLException, DataAccessException {
BioModelSimulationLinkTable bioSimLinkTable = BioModelSimulationLinkTable.table;
MathModelSimulationLinkTable mathSimLinkTable = MathModelSimulationLinkTable.table;
final String BMLINK = "bmlink";
final String MMLINK = "mmlink";
String subquery = "SELECT " + "current_timestamp as " + DatabaseConstants.SYSDATE_COLUMN_NAME + "," + jobTable.getTableName() + ".*," + userTable.userid.getQualifiedColName() + "," + userTable.id.getQualifiedColName() + " as ownerkey" + "," + "vc_sim_1." + simTable.ownerRef.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.name.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.taskDescription.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.meshSpecX.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.meshSpecY.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.meshSpecZ.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.mathOverridesLarge.getUnqualifiedColName() + " as " + simTable.mathOverridesLarge.getUnqualifiedColName() + "," + "vc_sim_1." + simTable.mathOverridesSmall.getUnqualifiedColName() + " as " + simTable.mathOverridesSmall.getUnqualifiedColName() + "," + "(SELECT max('{\"" + BioModelLink.bmid + "\":\"' || lpad(vc_biomodel.id,14,0)" + " || '\",\"" + BioModelLink.scid + "\":\"' || lpad(vc_simcontext.id,14,0)" + " || '\",\"" + BioModelLink.bmbranch + "\":\"' || lpad(vc_biomodel.versionbranchid,14,0)" + " || '\",\"" + BioModelLink.scbranch + "\":\"' || lpad(vc_simcontext.versionbranchid,14,0)" + " || '\",\"" + BioModelLink.bmname + "\":\"' || vc_biomodel.name" + " || '\",\"" + BioModelLink.scname + "\":\"' || vc_simcontext.name || '\"}')" + " FROM vc_biomodel" + ", vc_biomodelsimcontext" + ", VC_BIOMODELSIM" + ", vc_simcontext" + " WHERE vc_sim_1.mathref = vc_simcontext.mathref" + " AND VC_BIOMODELSIMCONTEXT.SIMCONTEXTREF = VC_SIMCONTEXT.id" + " AND VC_BIOMODELSIMCONTEXT.BIOMODELREF = vc_biomodel.id" + " AND VC_BIOMODELSIM.SIMREF = vc_sim_1.id" + " AND VC_BIOMODELSIM.BIOMODELREF = vc_biomodel.id" + ") as " + BMLINK + "," + "(SELECT max('{\"" + MathModelLink.mmid + "\":\"' || lpad(vc_mathmodel.id,14,0)" + " || '\",\"" + MathModelLink.mmbranch + "\":\"' || lpad(vc_mathmodel.versionbranchid,14,0)" + " || '\",\"" + MathModelLink.mmname + "\":\"' || vc_mathmodel.name || '\"}')" + " FROM vc_mathmodel" + ", vc_mathmodelsim" + " WHERE vc_sim_1.id = vc_mathmodelsim.SIMREF" + " AND vc_mathmodelsim.MATHMODELREF = vc_mathmodel.id" + ") as " + MMLINK + " FROM " + jobTable.getTableName() + "," + simTable.getTableName() + " vc_sim_1" + "," + userTable.getTableName() + "," + bioSimLinkTable.getTableName() + "," + mathSimLinkTable.getTableName() + " WHERE " + "vc_sim_1." + simTable.id.getUnqualifiedColName() + "=" + jobTable.simRef.getQualifiedColName() + " AND " + "vc_sim_1." + simTable.ownerRef.getUnqualifiedColName() + "=" + userTable.id.getQualifiedColName() + " AND " + bioSimLinkTable.simRef.getQualifiedColName() + " (+) " + "=" + "vc_sim_1." + simTable.id.getUnqualifiedColName() + " AND " + mathSimLinkTable.simRef.getQualifiedColName() + " (+) " + "=" + "vc_sim_1." + simTable.id.getUnqualifiedColName();
String additionalConditionsClause = "";
if (conditions != null && conditions.length() > 0) {
additionalConditionsClause = " AND (" + conditions + ")";
}
// most recent records first
String orderByClause = " order by " + jobTable.submitDate.getQualifiedColName() + " DESC ";
String sql = null;
if (maxNumRows > 0) {
if (startRow <= 1) {
// simpler query, only limit rows, not starting row
sql = "select * from " + "(" + subquery + " " + additionalConditionsClause + " " + orderByClause + ") " + "where rownum <= " + maxNumRows;
} else {
// full query, limit start and limit
sql = "select * from " + "(select a.*, ROWNUM rnum from " + "(" + subquery + " " + additionalConditionsClause + " " + orderByClause + ") a " + " where rownum <= " + (startRow + maxNumRows - 1) + ") " + "where rnum >= " + startRow;
}
} else {
sql = subquery + " " + additionalConditionsClause + " " + orderByClause;
}
if (lg.isTraceEnabled()) {
lg.trace(sql);
}
List<SimpleJobStatusPersistent> resultList = new ArrayList<SimpleJobStatusPersistent>();
Statement stmt = con.createStatement();
SimulationJobStatusPersistent simJobStatus = null;
cbit.vcell.solver.SolverTaskDescription std = null;
String username = null;
try {
ResultSet rset = stmt.executeQuery(sql.toString());
while (rset.next()) {
simJobStatus = jobTable.getSimulationJobStatus(rset);
username = rset.getString(userTable.userid.getUnqualifiedColName());
BigDecimal ownerKeyDecimal = rset.getBigDecimal("ownerkey");
User owner = new User(username, new KeyValue(ownerKeyDecimal));
std = null;
try {
String taskDesc = rset.getString(SimulationTable.table.taskDescription.getUnqualifiedColName());
if (taskDesc != null) {
std = new cbit.vcell.solver.SolverTaskDescription(new org.vcell.util.CommentStringTokenizer(org.vcell.util.TokenMangler.getSQLRestoredString(taskDesc)));
}
} catch (DataAccessException ex) {
ex.printStackTrace();
lg.error("failed to parse SolverTaskDescription", ex);
}
Integer meshSizeX = rset.getInt(SimulationTable.table.meshSpecX.getUnqualifiedColName());
if (rset.wasNull()) {
meshSizeX = null;
}
Integer meshSizeY = rset.getInt(SimulationTable.table.meshSpecY.getUnqualifiedColName());
if (rset.wasNull()) {
meshSizeY = null;
}
Integer meshSizeZ = rset.getInt(SimulationTable.table.meshSpecZ.getUnqualifiedColName());
if (rset.wasNull()) {
meshSizeZ = null;
}
String simname = rset.getString(SimulationTable.table.name.getUnqualifiedColName());
SimulationDocumentLink simulationDocumentLink = null;
String latestBioModelLinkJSON = rset.getString(BMLINK);
if (latestBioModelLinkJSON != null) {
try {
Gson gson = new Gson();
BioModelLink bioModelLink = gson.fromJson(latestBioModelLinkJSON, BioModelLink.class);
bioModelLink.clearZeroPadding();
simulationDocumentLink = bioModelLink;
} catch (Exception e) {
e.printStackTrace();
lg.error("failed to parse BioModelLink", e);
}
}
String latestMathModelLinkJSON = rset.getString(MMLINK);
if (latestMathModelLinkJSON != null) {
Gson gson = new Gson();
try {
MathModelLink mathModelLink = gson.fromJson(latestMathModelLinkJSON, MathModelLink.class);
mathModelLink.clearZeroPadding();
simulationDocumentLink = mathModelLink;
} catch (Exception e) {
e.printStackTrace();
lg.error("failed to parse MathModelLink", e);
}
}
CommentStringTokenizer mathOverridesTokens = SimulationTable.getMathOverridesTokenizer(rset, dbSyntax);
List<MathOverrides.Element> mathOverrideElements = MathOverrides.parseOverrideElementsFromVCML(mathOverridesTokens);
int scanCount = 1;
for (MathOverrides.Element element : mathOverrideElements) {
if (element.getSpec() != null) {
scanCount *= element.getSpec().getNumValues();
}
}
SimulationMetadata simulationMetadata = new SimulationMetadata(simJobStatus.getVCSimulationIdentifier(), simname, owner, std, meshSizeX, meshSizeY, meshSizeZ, new Integer(scanCount));
resultList.add(new SimpleJobStatusPersistent(simulationMetadata, simulationDocumentLink, simJobStatus));
}
} finally {
stmt.close();
}
return resultList;
}
Aggregations