use of cbit.vcell.server.StateInfo in project vcell by virtualcell.
the class SimulationDatabaseDirect method getSimpleJobStatus.
@Override
public SimpleJobStatus[] getSimpleJobStatus(User user, SimpleJobStatusQuerySpec simStatusQuerySpec) throws ObjectNotFoundException, DataAccessException {
//
// create corresponding SimpleJobStatus[] from SimpleJobStatusPersistent[]
// 1) get SimpleJobStatusPersistent from database (with stored status, metadata, and documentLinks - but no stateInfo)
// 2) if already in cache, use SimulationJobStatus and stateInfo from cache.
// 3) if not in cache, use SimulationJobStatus from database and no stateInfo, populate cache.
//
List<SimpleJobStatusPersistent> simpleJobStatusPersistentList = databaseServerImpl.getSimpleJobStatus(simStatusQuerySpec);
ArrayList<SimpleJobStatus> simpleJobStatusList = new ArrayList<SimpleJobStatus>();
for (SimpleJobStatusPersistent simpleJobStatusPersistent : simpleJobStatusPersistentList) {
SimulationJobStatusPersistent simJobStatusDb = simpleJobStatusPersistent.jobStatus;
SimJobStatusKey key = new SimJobStatusKey(simpleJobStatusPersistent.simulationMetadata.vcSimID.getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
SimStatusCacheEntry simStatusCacheEntry = cache.get(key);
// TODO need to get this from memory cache.
StateInfo cachedStateInfo = null;
SimulationJobStatus latestSimulationJobStatus = null;
if (simStatusCacheEntry != null) {
cachedStateInfo = simStatusCacheEntry.stateInfo;
latestSimulationJobStatus = simStatusCacheEntry.jobStatus;
} else {
latestSimulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusDb);
cache.put(key, new SimStatusCacheEntry(latestSimulationJobStatus, null));
}
SimpleJobStatus bestSimpleJobStatus = translateToSimpleJobStatusTransient(simpleJobStatusPersistent, latestSimulationJobStatus, cachedStateInfo);
// uses latest SimulationJobStatus and StateInfo.
simpleJobStatusList.add(bestSimpleJobStatus);
}
return simpleJobStatusList.toArray(new SimpleJobStatus[simpleJobStatusList.size()]);
}
Aggregations