Search in sources :

Example 6 with Partition

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

the class RunRestController method setPartitionPurposes.

@PutMapping("/{runId}/partition-purposes")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setPartitionPurposes(@PathVariable long runId, @RequestBody RunPartitionPurposeRequest request) throws IOException {
    Run run = RestUtils.retrieve("Run", runId, runService);
    RunPurpose purpose = RestUtils.retrieve("Run purpose", request.getRunPurposeId(), runPurposeService);
    List<Partition> partitions = run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).filter(partition -> request.getPartitionIds().contains(partition.getId())).collect(Collectors.toList());
    for (Partition partition : partitions) {
        RunPartition runPartition = runPartitionService.get(run, partition);
        if (runPartition == null) {
            runPartition = new RunPartition();
            runPartition.setRunId(run.getId());
            runPartition.setPartitionId(partition.getId());
        }
        runPartition.setPurpose(purpose);
        runPartitionService.save(runPartition);
    }
}
Also used : RunPurposeService(uk.ac.bbsrc.tgac.miso.core.service.RunPurposeService) PathVariable(org.springframework.web.bind.annotation.PathVariable) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) RequestParam(org.springframework.web.bind.annotation.RequestParam) SampleTissueProcessing(uk.ac.bbsrc.tgac.miso.core.data.SampleTissueProcessing) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) DataTablesResponseDto(uk.ac.bbsrc.tgac.miso.dto.DataTablesResponseDto) Autowired(org.springframework.beans.factory.annotation.Autowired) SampleSheet(uk.ac.bbsrc.tgac.miso.core.util.SampleSheet) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) RunPartitionDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto.RunPartitionDto) PutMapping(org.springframework.web.bind.annotation.PutMapping) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Map(java.util.Map) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) PartitionQCType(uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) PostMapping(org.springframework.web.bind.annotation.PostMapping) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) PoolDto(uk.ac.bbsrc.tgac.miso.dto.PoolDto) AdvancedSearchParser(uk.ac.bbsrc.tgac.miso.webapp.controller.component.AdvancedSearchParser) HttpHeaders(org.springframework.http.HttpHeaders) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) Collection(java.util.Collection) MediaType(org.springframework.http.MediaType) ExperimentDto(uk.ac.bbsrc.tgac.miso.dto.ExperimentDto) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) RunLibrarySpreadsheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.RunLibrarySpreadsheets) Objects(java.util.Objects) LibraryDto(uk.ac.bbsrc.tgac.miso.dto.LibraryDto) List(java.util.List) HttpEntity(org.springframework.http.HttpEntity) MisoWebUtils(uk.ac.bbsrc.tgac.miso.webapp.util.MisoWebUtils) Stream(java.util.stream.Stream) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) Pair(uk.ac.bbsrc.tgac.miso.core.data.Pair) LibraryAliquotDto(uk.ac.bbsrc.tgac.miso.dto.LibraryAliquotDto) InstrumentModelDto(uk.ac.bbsrc.tgac.miso.dto.InstrumentModelDto) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) SampleIdentity(uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity) StudyDto(uk.ac.bbsrc.tgac.miso.dto.StudyDto) User(com.eaglegenomics.simlims.core.User) RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) ArrayList(java.util.ArrayList) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) HttpServletRequest(javax.servlet.http.HttpServletRequest) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) RunPartitionAliquotDto(uk.ac.bbsrc.tgac.miso.dto.RunPartitionAliquotDto) LimsUtils(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) Status(javax.ws.rs.core.Response.Status) SampleAliquot(uk.ac.bbsrc.tgac.miso.core.data.SampleAliquot) SampleTissue(uk.ac.bbsrc.tgac.miso.core.data.SampleTissue) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) HttpServletResponse(javax.servlet.http.HttpServletResponse) SpreadsheetRequest(uk.ac.bbsrc.tgac.miso.dto.SpreadsheetRequest) IOException(java.io.IOException) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) WhineyConsumer(uk.ac.bbsrc.tgac.miso.core.util.WhineyConsumer) ContainerDto(uk.ac.bbsrc.tgac.miso.dto.ContainerDto) Consumer(java.util.function.Consumer) HttpStatus(org.springframework.http.HttpStatus) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) PartitionQcTypeService(uk.ac.bbsrc.tgac.miso.core.service.PartitionQcTypeService) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) PaginatedDataSource(uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource) PartitionDto(uk.ac.bbsrc.tgac.miso.dto.PartitionDto) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 7 with Partition

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

the class HibernateSequencerPartitionContainerDao method listAllPartitionsByPoolId.

@Override
public List<Partition> listAllPartitionsByPoolId(long poolId) throws IOException {
    Criteria criteria = currentSession().createCriteria(PartitionImpl.class);
    criteria.createAlias("pool", "pool");
    criteria.add(Restrictions.eq("pool.id", poolId));
    @SuppressWarnings("unchecked") List<Partition> records = criteria.list();
    return records;
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Criteria(org.hibernate.Criteria)

Example 8 with Partition

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

the class HibernateRunPartitionAliquotDaoIT method testSaveCreate.

@Test
public void testSaveCreate() throws Exception {
    Run run = (Run) currentSession().get(Run.class, 1L);
    Partition partition = (Partition) currentSession().get(PartitionImpl.class, 2L);
    LibraryAliquot aliquot = (LibraryAliquot) currentSession().get(LibraryAliquot.class, 3L);
    RunPartitionAliquotId id = new RunPartitionAliquotId(run, partition, aliquot);
    assertNull(currentSession().get(RunPartitionAliquot.class, id));
    RunPartitionAliquot rpa = new RunPartitionAliquot(run, partition, aliquot);
    User user = (User) currentSession().get(UserImpl.class, 1L);
    rpa.setLastModifier(user);
    RunLibraryQcStatus qc = (RunLibraryQcStatus) currentSession().get(RunLibraryQcStatus.class, 1L);
    rpa.setQcStatus(qc);
    rpa.setQcUser(user);
    rpa.setQcDate(new Date());
    sut.save(rpa);
    clearSession();
    RunPartitionAliquot saved = (RunPartitionAliquot) currentSession().get(RunPartitionAliquot.class, id);
    assertNotNull(saved);
    assertEquals(1L, saved.getRun().getId());
    assertEquals(2L, saved.getPartition().getId());
    assertEquals(3L, saved.getAliquot().getId());
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPartitionAliquotId(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot.RunPartitionAliquotId) User(com.eaglegenomics.simlims.core.User) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus) Date(java.util.Date) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 9 with Partition

use of uk.ac.bbsrc.tgac.miso.core.data.Partition 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 Partition

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

the class SequencerPartitionContainerImpl method setPartitions.

@Override
public void setPartitions(List<Partition> partitions) {
    this.partitions = partitions;
    for (Partition p : partitions) {
        p.setSequencerPartitionContainer(this);
    }
    Collections.sort(partitions, partitionNumberComparator);
}
Also used : Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition)

Aggregations

Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)27 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)21 RunPartitionAliquot (uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot)14 LibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot)13 RunPartition (uk.ac.bbsrc.tgac.miso.core.data.RunPartition)12 Test (org.junit.Test)10 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)10 IOException (java.io.IOException)9 List (java.util.List)9 PartitionImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl)9 User (com.eaglegenomics.simlims.core.User)8 Collectors (java.util.stream.Collectors)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 PoolElement (uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement)8 RunService (uk.ac.bbsrc.tgac.miso.core.service.RunService)8 Collection (java.util.Collection)7 Map (java.util.Map)7 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)7 AuthorizationManager (uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager)7 RunPartitionAliquotService (uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService)7