Search in sources :

Example 1 with DataSetMetadata

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

the class RestDatabaseService method getDataSetMetadata.

public DataSetMetadata getDataSetMetadata(SimDataServerResource resource, User vcellUser) throws ObjectNotFoundException, DataAccessException, 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);
    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();
    int jobIndex = 0;
    VCMessageSession rpcSession = vcMessagingService.createProducerSession();
    try {
        RpcDataServerProxy rpcDataServerProxy = new RpcDataServerProxy(userLoginInfo, rpcSession);
        VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
        VCDataIdentifier vcdID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
        DataSetMetadata dataSetMetadata = rpcDataServerProxy.getDataSetMetadata(vcdID);
        return dataSetMetadata;
    } 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) DataSetMetadata(cbit.vcell.simdata.DataSetMetadata) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) UserLoginInfo(org.vcell.util.document.UserLoginInfo) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) SimulationRep(cbit.vcell.modeldb.SimulationRep)

Example 2 with DataSetMetadata

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

the class SimDataServerResource method getSimDataRepresentation.

private SimDataRepresentation getSimDataRepresentation(User vcellUser) {
    // if (!application.authenticate(getRequest(), getResponse())){
    // // not authenticated
    // return new SimulationTaskRepresentation[0];
    // }else{
    RestDatabaseService restDatabaseService = ((VCellApiApplication) getApplication()).getRestDatabaseService();
    try {
        DataSetMetadata dataSetMetadata = restDatabaseService.getDataSetMetadata(this, vcellUser);
        SimulationRep simRep = restDatabaseService.getSimulationRep(dataSetMetadata.getSimKey());
        SimDataRepresentation simDataRepresentation = new SimDataRepresentation(dataSetMetadata, simRep.getScanCount());
        return simDataRepresentation;
    } catch (PermissionException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_UNAUTHORIZED, "not authorized");
    } catch (ObjectNotFoundException e) {
        e.printStackTrace();
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "simulation metadata 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) SimDataRepresentation(org.vcell.rest.common.SimDataRepresentation) ResourceException(org.restlet.resource.ResourceException) DataSetMetadata(cbit.vcell.simdata.DataSetMetadata) SimulationRep(cbit.vcell.modeldb.SimulationRep) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) ResourceException(org.restlet.resource.ResourceException)

Aggregations

SimulationRep (cbit.vcell.modeldb.SimulationRep)2 DataSetMetadata (cbit.vcell.simdata.DataSetMetadata)2 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)2 VCMessageSession (cbit.vcell.message.VCMessageSession)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 SimDataRepresentation (org.vcell.rest.common.SimDataRepresentation)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