Search in sources :

Example 1 with DataSetTimeSeries

use of cbit.vcell.simdata.DataSetTimeSeries in project vcell by virtualcell.

the class SimDataValuesServerResource method getSimDataValuesRepresentation.

private SimDataValuesRepresentation getSimDataValuesRepresentation(User vcellUser) {
    // if (!application.authenticate(getRequest(), getResponse())){
    // // not authenticated
    // return new SimulationTaskRepresentation[0];
    // }else{
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        DataSetTimeSeries dataSetTimeSeries = restDatabaseService.getDataSetTimeSeries(this, vcellUser);
        SimDataValuesRepresentation simDataRepresentation = new SimDataValuesRepresentation(dataSetTimeSeries);
        return simDataRepresentation;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized to stop simulation");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "simulation not found");
    } catch (Exception e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage());
    }
// }
}
Also used : PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) VCellApiApplication(org.vcell.rest.VCellApiApplication) ResourceException(org.restlet.resource.ResourceException) DataSetTimeSeries(cbit.vcell.simdata.DataSetTimeSeries) SimDataValuesRepresentation(org.vcell.rest.common.SimDataValuesRepresentation) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Example 2 with DataSetTimeSeries

use of cbit.vcell.simdata.DataSetTimeSeries 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();
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) VCMessageSession(cbit.vcell.message.VCMessageSession) BigString(org.vcell.util.BigString) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) RpcDataServerProxy(org.vcell.rest.rpc.RpcDataServerProxy) DataSetTimeSeries(cbit.vcell.simdata.DataSetTimeSeries) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) UserLoginInfo(org.vcell.util.document.UserLoginInfo) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) SimulationRep(cbit.vcell.modeldb.SimulationRep)

Aggregations

DataSetTimeSeries (cbit.vcell.simdata.DataSetTimeSeries)2 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)2 VCMessageSession (cbit.vcell.message.VCMessageSession)1 SimulationRep (cbit.vcell.modeldb.SimulationRep)1 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)1 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)1 ResourceException (org.restlet.resource.ResourceException)1 VCellApiApplication (org.vcell.rest.VCellApiApplication)1 SimDataValuesRepresentation (org.vcell.rest.common.SimDataValuesRepresentation)1 RpcDataServerProxy (org.vcell.rest.rpc.RpcDataServerProxy)1 BigString (org.vcell.util.BigString)1 PermissionException (org.vcell.util.PermissionException)1 KeyValue (org.vcell.util.document.KeyValue)1 User (org.vcell.util.document.User)1 UserLoginInfo (org.vcell.util.document.UserLoginInfo)1 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)1