Search in sources :

Example 6 with Experiment

use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.

the class HibernateExperimentDao method listByStudyId.

@Override
public List<Experiment> listByStudyId(long studyId) {
    Criteria criteria = currentSession().createCriteria(Experiment.class);
    criteria.createAlias("study", "study");
    criteria.add(Restrictions.eq("study.id", studyId));
    @SuppressWarnings("unchecked") List<Experiment> results = criteria.list();
    return results;
}
Also used : Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) Criteria(org.hibernate.Criteria)

Example 7 with Experiment

use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.

the class EditExperimentController method setupForm.

@GetMapping(value = "/{experimentId}")
public ModelAndView setupForm(@PathVariable Long experimentId, ModelMap model) throws IOException {
    Experiment experiment = experimentService.get(experimentId);
    if (experiment == null)
        throw new NotFoundException("No experiment found for ID " + experimentId.toString());
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode consumableConfig = mapper.createObjectNode();
    consumableConfig.put("experimentId", experiment.getId());
    Stream.<// 
    KitDescriptor>concat(// 
    Stream.of(experiment.getLibrary().getKitDescriptor()), // 
    experiment.getRunPartitions().stream().map(// 
    RunPartition::getPartition).flatMap(partition -> Stream.of(partition.getSequencerPartitionContainer().getClusteringKit(), // 
    partition.getSequencerPartitionContainer().getMultiplexingKit()))).filter(// 
    Objects::nonNull).distinct().map(// 
    Dtos::asDto).forEach(consumableConfig.putArray("allowedDescriptors")::addPOJO);
    model.put("experiment", experiment);
    model.put("experimentDto", mapper.writeValueAsString(Dtos.asDto(experiment)));
    model.put("consumables", experiment.getKits().stream().map(Dtos::asDto).collect(Collectors.toList()));
    model.put("consumableConfig", mapper.writeValueAsString(consumableConfig));
    model.put("runPartitions", experiment.getRunPartitions().stream().map(entry -> new ExperimentDto.RunPartitionDto(Dtos.asDto(entry.getRun()), Dtos.asDto(entry.getPartition(), indexChecker))).collect(Collectors.toList()));
    model.put("title", "Edit Experiment");
    return new ModelAndView("/WEB-INF/pages/editExperiment.jsp", model);
}
Also used : KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) PathVariable(org.springframework.web.bind.annotation.PathVariable) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) NotFoundException(org.springframework.security.acls.model.NotFoundException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) IOException(java.io.IOException) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Controller(org.springframework.stereotype.Controller) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) ModelMap(org.springframework.ui.ModelMap) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Objects(java.util.Objects) ModelAndView(org.springframework.web.servlet.ModelAndView) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) Stream(java.util.stream.Stream) GetMapping(org.springframework.web.bind.annotation.GetMapping) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) ModelAndView(org.springframework.web.servlet.ModelAndView) NotFoundException(org.springframework.security.acls.model.NotFoundException) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 8 with Experiment

use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.

the class HibernateExperimentDaoIT method testGet.

/**
 * Test method for {@link uk.ac.bbsrc.tgac.miso.persistence.impl.HibernateExperimentDao#get(long)}.
 *
 * @throws IOException
 */
@Test
public void testGet() throws IOException {
    Experiment experiment = dao.get(1L);
    assertNotNull(experiment);
    assertEquals("EXP1", experiment.getName());
    assertEquals("TEST", experiment.getDescription());
    assertEquals("PRO1 Illumina Other experiment (Auto-gen)", experiment.getTitle());
}
Also used : Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 9 with Experiment

use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.

the class ExperimentRestController method addPartition.

@PostMapping(value = "/{experimentId}/add", produces = "application/json")
@ResponseBody
public ExperimentDto addPartition(@PathVariable Long experimentId, @RequestParam("runId") Long runId, @RequestParam("partitionId") Long partitionId) throws IOException {
    Experiment experiment = experimentService.get(experimentId);
    if (experiment == null) {
        throw new RestException("No such experiment.", Status.NOT_FOUND);
    }
    Run run = runService.get(runId);
    if (run == null) {
        throw new RestException("No such run.", Status.NOT_FOUND);
    }
    Partition partition = containerService.getPartition(partitionId);
    if (partition == null) {
        throw new RestException("No such partition.", Status.NOT_FOUND);
    }
    if (run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).noneMatch(p -> p.getId() == partitionId)) {
        throw new RestException("Partition not in run.", Status.BAD_REQUEST);
    }
    if (experiment.getRunPartitions().stream().noneMatch(rp -> rp.getPartition().getId() == partition.getId() && rp.getRun().getId() == run.getId())) {
        RunPartition rp = new RunPartition();
        rp.setExperiment(experiment);
        rp.setPartition(partition);
        rp.setRun(run);
        experiment.getRunPartitions().add(rp);
        experimentService.update(experiment);
    }
    return get(experimentId);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) Controller(org.springframework.stereotype.Controller) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) KitConsumableDto(uk.ac.bbsrc.tgac.miso.dto.KitConsumableDto) RequestBody(org.springframework.web.bind.annotation.RequestBody) PutMapping(org.springframework.web.bind.annotation.PutMapping) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) KitService(uk.ac.bbsrc.tgac.miso.core.service.KitService) Status(javax.ws.rs.core.Response.Status) PostMapping(org.springframework.web.bind.annotation.PostMapping) Collection(java.util.Collection) IOException(java.io.IOException) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Kit(uk.ac.bbsrc.tgac.miso.core.data.Kit) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Collectors(java.util.stream.Collectors) HttpStatus(org.springframework.http.HttpStatus) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) List(java.util.List) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with Experiment

use of uk.ac.bbsrc.tgac.miso.core.data.Experiment in project miso-lims by miso-lims.

the class DefaultExperimentService method update.

@Override
public long update(Experiment experiment) throws IOException {
    loadRunPartitions(experiment);
    ValidationResult nameValidation = namingSchemeHolder.getPrimary().validateName(experiment.getName());
    if (!nameValidation.isValid()) {
        throw new IOException("Cannot save Experiment - invalid name:" + nameValidation.getMessage());
    }
    Experiment original = experimentStore.get(experiment.getId());
    original.setAccession(experiment.getAccession());
    original.setAlias(experiment.getAlias());
    original.setDescription(experiment.getDescription());
    original.setName(experiment.getName());
    original.setInstrumentModel(instrumentModelService.get(experiment.getInstrumentModel().getId()));
    original.setLibrary(libraryService.get(experiment.getLibrary().getId()));
    original.setStudy(studyService.get(experiment.getStudy().getId()));
    original.setTitle(experiment.getTitle());
    // These have been already reloaded.
    original.setRunPartitions(experiment.getRunPartitions());
    original.getRunPartitions().forEach(rp -> rp.setExperiment(original));
    Set<Kit> kits = new HashSet<>();
    for (Kit k : experiment.getKits()) {
        kits.add(kitService.get(k.getId()));
    }
    original.setKits(kits);
    original.setChangeDetails(authorizationManager.getCurrentUser());
    return experimentStore.save(original);
}
Also used : Experiment(uk.ac.bbsrc.tgac.miso.core.data.Experiment) Kit(uk.ac.bbsrc.tgac.miso.core.data.Kit) IOException(java.io.IOException) ValidationResult(uk.ac.bbsrc.tgac.miso.core.service.naming.validation.ValidationResult) HashSet(java.util.HashSet)

Aggregations

Experiment (uk.ac.bbsrc.tgac.miso.core.data.Experiment)17 IOException (java.io.IOException)5 Criteria (org.hibernate.Criteria)5 RunPartition (uk.ac.bbsrc.tgac.miso.core.data.Experiment.RunPartition)5 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 Test (org.junit.Test)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Controller (org.springframework.stereotype.Controller)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 PathVariable (org.springframework.web.bind.annotation.PathVariable)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)3 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)2 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)2 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)2 User (com.eaglegenomics.simlims.core.User)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2