Search in sources :

Example 1 with Study

use of org.jbei.ice.lib.experiment.Study in project ice by JBEI.

the class PartResource method createPartExperiment.

@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/experiments")
public Response createPartExperiment(@PathParam("id") final String partId, final Study study) {
    try {
        final String userId = requireUserId();
        log(userId, "adding experiment " + study.toString() + " to " + partId);
        Experiments experiments = new Experiments(userId, partId);
        final Study created = experiments.createOrUpdateStudy(study);
        return respond(Response.Status.OK, created);
    } catch (PermissionException e) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    } catch (IllegalArgumentException ile) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Study(org.jbei.ice.lib.experiment.Study) Experiments(org.jbei.ice.lib.experiment.Experiments)

Example 2 with Study

use of org.jbei.ice.lib.experiment.Study in project ice by JBEI.

the class PartResource method getPartExperiments.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/experiments")
public Response getPartExperiments(@PathParam("id") final String partId) {
    final String userId = requireUserId();
    try {
        Experiments experiments = new Experiments(userId, partId);
        final List<Study> studies = experiments.getPartStudies();
        return respond(Response.Status.OK, studies);
    } catch (PermissionException e) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    } catch (IllegalArgumentException ile) {
        throw new WebApplicationException(Response.Status.BAD_REQUEST);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Study(org.jbei.ice.lib.experiment.Study) Experiments(org.jbei.ice.lib.experiment.Experiments)

Example 3 with Study

use of org.jbei.ice.lib.experiment.Study in project ice by JBEI.

the class Experiment method toDataTransferObject.

public Study toDataTransferObject() {
    Study study = new Study();
    study.setId(id);
    study.setCreated(creationTime.getTime());
    study.setLabel(label);
    study.setOwnerEmail(this.ownerEmail);
    study.setUrl(url);
    return study;
}
Also used : Study(org.jbei.ice.lib.experiment.Study)

Aggregations

Study (org.jbei.ice.lib.experiment.Study)3 PermissionException (org.jbei.ice.lib.access.PermissionException)2 Experiments (org.jbei.ice.lib.experiment.Experiments)2