use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class RestDatabaseService method getDataSetTimeSeries.
public DataSetTimeSeries getDataSetTimeSeries(SimDataValuesServerResource resource, User vcellUser) throws DataAccessException, ObjectNotFoundException, SQLException {
if (vcellUser == null) {
vcellUser = VCellApiApplication.DUMMY_USER;
}
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
// resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID);
String simId = resource.getAttribute(VCellApiApplication.SIMDATAID);
// resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID);
String jobIndexString = resource.getAttribute(VCellApiApplication.JOBINDEX);
KeyValue simKey = new KeyValue(simId);
SimulationRep simRep = getSimulationRep(simKey);
if (simRep == null) {
throw new ObjectNotFoundException("Simulation with key " + simKey + " not found");
}
int jobIndex = Integer.parseInt(jobIndexString);
// TODO: pass in variables names from the query parameters.
String[] variableNames = null;
User owner = simRep.getOwner();
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
RpcDataServerProxy rpcDataServerProxy = new RpcDataServerProxy(userLoginInfo, rpcSession);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
VCDataIdentifier vcdID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
DataSetTimeSeries dataSetTimeSeries = rpcDataServerProxy.getDataSetTimeSeries(vcdID, variableNames);
return dataSetTimeSeries;
} finally {
rpcSession.close();
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class RestDatabaseService method startSimulation.
public SimulationRep startSimulation(BiomodelSimulationStartServerResource resource, User vcellUser) throws PermissionException, ObjectNotFoundException, DataAccessException, SQLException {
// resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID);
String simId = resource.getAttribute(VCellApiApplication.SIMULATIONID);
KeyValue simKey = new KeyValue(simId);
SimulationRep simRep = getSimulationRep(simKey);
if (simRep == null) {
throw new ObjectNotFoundException("Simulation with key " + simKey + " not found");
}
User owner = simRep.getOwner();
if (!owner.compareEqual(vcellUser)) {
throw new PermissionException("not authorized to start simulation");
}
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
rpcSimServerProxy.startSimulation(vcellUser, vcSimID, simRep.getScanCount());
return simRep;
} finally {
rpcSession.close();
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class RestDatabaseService method stopSimulation.
public SimulationRep stopSimulation(BiomodelSimulationStopServerResource resource, User vcellUser) throws PermissionException, ObjectNotFoundException, DataAccessException, SQLException {
// resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID);
String simId = resource.getAttribute(VCellApiApplication.SIMULATIONID);
KeyValue simKey = new KeyValue(simId);
SimulationRep simRep = getSimulationRep(simKey);
if (simRep == null) {
throw new ObjectNotFoundException("Simulation with key " + simKey + " not found");
}
User owner = simRep.getOwner();
if (!owner.compareEqual(vcellUser)) {
throw new PermissionException("not authorized to stop simulation");
}
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
rpcSimServerProxy.stopSimulation(vcellUser, vcSimID);
return simRep;
} finally {
rpcSession.close();
}
}
use of cbit.vcell.solver.VCSimulationIdentifier 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.VCSimulationIdentifier in project vcell by virtualcell.
the class ClientRequestManager method getServerSimulationStatus.
/**
* Insert the method's description here.
* Creation date: (6/7/2004 1:27:25 PM)
* @return cbit.vcell.solver.ode.gui.SimulationStatus
* @param simulation cbit.vcell.solver.Simulation
*/
public SimulationStatus getServerSimulationStatus(SimulationInfo simInfo) {
SimulationStatus simStatus = null;
if (simInfo == null) {
// unsaved simulation ... won't have simulation status
return null;
}
try {
VCSimulationIdentifier vcSimulationIdentifier = simInfo.getAuthoritativeVCSimulationIdentifier();
simStatus = getClientServerManager().getJobManager().getServerSimulationStatus(vcSimulationIdentifier);
} catch (Throwable exc) {
exc.printStackTrace(System.out);
}
return simStatus;
}
Aggregations