use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method getSimulationStatus.
@Override
public SimulationStatus[] getSimulationStatus(KeyValue[] simKeys) throws ObjectNotFoundException, DataAccessException {
SimulationStatusPersistent[] simStatusDbArray = databaseServerImpl.getSimulationStatus(simKeys);
ArrayList<SimulationStatus> simStatusList = new ArrayList<SimulationStatus>();
for (SimulationStatusPersistent simStatusDb : simStatusDbArray) {
if (simStatusDb != null) {
simStatusList.add(buildSimulationStatus(simStatusDb));
} else {
simStatusList.add(null);
}
}
return simStatusList.toArray(new SimulationStatus[0]);
}
use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method buildSimulationStatus.
private SimulationStatus buildSimulationStatus(SimulationStatusPersistent simStatusDB) throws ObjectNotFoundException, DataAccessException {
SimulationStatus simulationStatus = translateToSimulationStatusTransient(simStatusDB);
// replace SimulationJobStatus from cache when possible
ArrayList<SimulationJobStatus> simJobStatusList = new ArrayList<SimulationJobStatus>();
int index = 0;
while (simulationStatus.getJobStatus(index) != null) {
SimulationJobStatus simJobStatusDb = simulationStatus.getJobStatus(index);
SimJobStatusKey key = new SimJobStatusKey(simJobStatusDb.getVCSimulationIdentifier().getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
SimStatusCacheEntry entry = cache.get(key);
if (entry != null) {
// assume cache is more recent
simJobStatusList.add(entry.jobStatus);
} else {
simJobStatusList.add(simJobStatusDb);
cache.put(key, new SimStatusCacheEntry(simJobStatusDb, null));
}
index++;
}
SimulationStatus newSimStatus = new SimulationStatus(simJobStatusList.toArray(new SimulationJobStatus[simJobStatusList.size()]));
return newSimStatus;
}
use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method translateToSimulationStatusTransient.
private SimulationStatus translateToSimulationStatusTransient(SimulationStatusPersistent simStatusPersistent) {
SimulationJobStatus[] simJobStatusArray = new SimulationJobStatus[simStatusPersistent.getJobStatuses().length];
for (int i = 0; i < simJobStatusArray.length; i++) {
simJobStatusArray[i] = translateToSimulationJobStatusTransient(simStatusPersistent.getJobStatus(i));
}
SimulationStatus simStatus = new SimulationStatus(simJobStatusArray);
return simStatus;
}
use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.
the class ClientDocumentManager method getServerSimulationStatus.
/**
* Insert the method's description here.
* Creation date: (9/1/2004 10:48:52 AM)
* @return cbit.vcell.solver.ode.gui.SimulationStatus
* @param vcSimulationIdentifier cbit.vcell.solver.VCSimulationIdentifier
*/
public SimulationStatus getServerSimulationStatus(VCSimulationIdentifier vcSimulationIdentifier) throws DataAccessException {
if (simulationStatusHash.containsKey(vcSimulationIdentifier.getSimulationKey())) {
return (SimulationStatus) simulationStatusHash.get(vcSimulationIdentifier.getSimulationKey());
} else {
SimulationStatus simulationStatus = null;
try {
simulationStatus = sessionManager.getSimulationController().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
try {
simulationStatus = sessionManager.getSimulationController().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
} catch (RemoteProxyException e2) {
handleRemoteProxyException(e2);
throw new DataAccessException("SimulationStatus inquiry for '" + vcSimulationIdentifier + "' failed\n" + e2.getMessage());
}
}
simulationStatusHash.put(vcSimulationIdentifier.getSimulationKey(), simulationStatus);
return simulationStatus;
}
}
use of cbit.vcell.server.SimulationStatus in project vcell by virtualcell.
the class ClientDocumentManager method preloadSimulationStatus.
/**
* Insert the method's description here.
* Creation date: (9/1/2004 12:33:16 PM)
* @param simKeys cbit.sql.KeyValue[]
*/
private void preloadSimulationStatus(KeyValue[] simKeys) {
boolean bNeedRefreshStatus = false;
for (int i = 0; i < simKeys.length; i++) {
if (!simulationStatusHash.containsKey(simKeys[i])) {
bNeedRefreshStatus = true;
}
}
if (bNeedRefreshStatus) {
try {
SimulationStatus[] simulationStatusArray = null;
try {
simulationStatusArray = sessionManager.getSimulationController().getSimulationStatus(simKeys);
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
try {
simulationStatusArray = sessionManager.getSimulationController().getSimulationStatus(simKeys);
} catch (RemoteProxyException e2) {
handleRemoteProxyException(e2);
}
}
for (int i = 0; i < simKeys.length; i++) {
SimulationStatus simulationStatus = null;
for (int j = 0; simulationStatusArray != null && j < simulationStatusArray.length; j++) {
// these are server-supplied statuses, jobStatus array is not null
if (simulationStatusArray[j] != null && simulationStatusArray[j].getVCSimulationIdentifier().getSimulationKey().equals(simKeys[i])) {
simulationStatus = simulationStatusArray[j];
}
}
simulationStatusHash.put(simKeys[i], simulationStatus);
}
} catch (DataAccessException e) {
e.printStackTrace(System.out);
}
}
}
Aggregations