Search in sources :

Example 6 with RunPartition

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

the class DefaultRunService method createRunPartitions.

private void createRunPartitions(Run run) throws IOException {
    for (SequencerPartitionContainer container : run.getSequencerPartitionContainers()) {
        for (Partition partition : container.getPartitions()) {
            RunPartition runPartition = runPartitionService.get(run, partition);
            if (runPartition == null) {
                runPartition = new RunPartition();
                runPartition.setRunId(run.getId());
                runPartition.setPartitionId(partition.getId());
                runPartition.setPurpose(run.getSequencer().getDefaultRunPurpose());
                runPartitionService.save(runPartition);
            }
        }
    }
}
Also used : SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) 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)

Example 7 with RunPartition

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

the class DefaultQcStatusService method update.

@Override
public void update(QcStatusUpdate update) throws IOException {
    // to detect changes and set QC users
    switch(update.getEntityType()) {
        case SAMPLE:
            {
                Sample sample = sampleService.get(update.getId());
                updateDetailedStatus(EntityType.SAMPLE.getLabel(), sample, update);
                sampleService.update(sample);
                break;
            }
        case LIBRARY:
            {
                Library library = libraryService.get(update.getId());
                updateDetailedStatus(EntityType.LIBRARY.getLabel(), library, update);
                libraryService.update(library);
                break;
            }
        case LIBRARY_ALIQUOT:
            {
                LibraryAliquot aliquot = libraryAliquotService.get(update.getId());
                updateDetailedStatus(EntityType.LIBRARY_ALIQUOT.getLabel(), aliquot, update);
                libraryAliquotService.update(aliquot);
                break;
            }
        case POOL:
            {
                Pool pool = poolService.get(update.getId());
                throwIfNull(EntityType.POOL.getLabel(), pool);
                pool.setQcPassed(update.getQcPassed());
                poolService.update(pool);
                break;
            }
        case RUN:
            {
                Run run = runService.get(update.getId());
                throwIfNull("Run", run);
                if (update.getQcPassed() == null) {
                    // QC Passed not set
                    run.setQcPassed(null);
                    run.setQcUser(null);
                    run.setQcDate(null);
                    clearDataReview(run);
                } else if (!update.getQcPassed().equals(run.getQcPassed())) {
                    // QC Passed set and changed
                    run.setQcPassed(update.getQcPassed());
                    run.setQcUser(authorizationManager.getCurrentUser());
                    run.setQcDate(new Date());
                    clearDataReview(run);
                } else if (update.getDataReview() == null) {
                    // QC Passed set and not changed, data review not set
                    clearDataReview(run);
                } else {
                    // QC Passed set and not changed, data review set and changed
                    run.setDataReview(update.getDataReview());
                    run.setDataReviewer(authorizationManager.getCurrentUser());
                    run.setDataReviewDate(new Date());
                }
                runService.update(run);
                break;
            }
        case RUN_PARTITION:
            {
                if (update.getIds() == null || update.getIds().length != 2) {
                    throw new ValidationException("Invalid ID for run-partition");
                }
                Run run = runService.get(update.getIds()[0]);
                throwIfNull("Run", run);
                Partition partition = findPartitionInRun(run, update.getIds()[1]);
                RunPartition runPartition = runPartitionService.get(run, partition);
                if (update.getQcStatusId() == null) {
                    runPartition.setQcType(null);
                } else {
                    PartitionQCType status = partitionQcTypeService.get(update.getQcStatusId());
                    throwIfNull("Partition QC type", status);
                    runPartition.setQcType(status);
                }
                runPartition.setNotes(update.getQcNote());
                runPartition.setLastModifier(authorizationManager.getCurrentUser());
                runPartitionService.save(runPartition);
                break;
            }
        case RUN_LIBRARY:
            {
                if (update.getIds() == null || update.getIds().length != 3) {
                    throw new ValidationException("Invalid ID for run-partition");
                }
                Run run = runService.get(update.getIds()[0]);
                throwIfNull("Run", run);
                Partition partition = findPartitionInRun(run, update.getIds()[1]);
                ListLibraryAliquotView aliquotView = partition.getPool().getPoolContents().stream().map(PoolElement::getAliquot).filter(x -> x.getId() == update.getIds()[2]).findFirst().orElse(null);
                throwIfNull("Run-library", aliquotView);
                LibraryAliquot aliquot = libraryAliquotService.get(update.getIds()[2]);
                RunPartitionAliquot runLib = runPartitionAliquotService.get(run, partition, aliquot);
                if (update.getQcStatusId() == null) {
                    // QC status not set
                    runLib.setQcStatus(null);
                    runLib.setQcUser(null);
                    runLib.setQcDate(null);
                    clearDataReview(runLib);
                } else if (runLib.getQcStatus() == null || runLib.getQcStatus().getId() != update.getQcStatusId().longValue()) {
                    // QC status set and changed
                    RunLibraryQcStatus status = runLibraryQcStatusService.get(update.getQcStatusId());
                    throwIfNull("Run-library QC status", status);
                    runLib.setQcStatus(status);
                    runLib.setQcUser(authorizationManager.getCurrentUser());
                    runLib.setQcDate(new Date());
                    clearDataReview(runLib);
                } else if (update.getDataReview() == null) {
                    // QC status set and not changed, data review not set
                    clearDataReview(runLib);
                } else if (update.getDataReview() != runLib.getDataReview()) {
                    // QC status set and not changed, data review set and changed
                    runLib.setDataReview(update.getDataReview());
                    runLib.setDataReviewer(authorizationManager.getCurrentUser());
                    runLib.setDataReviewDate(new Date());
                }
                runLib.setQcNote(update.getQcNote());
                runPartitionAliquotService.save(runLib);
                break;
            }
        default:
            throw new ValidationException("Unsupported entity type");
    }
}
Also used : AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) Date(java.util.Date) DetailedQcStatus(uk.ac.bbsrc.tgac.miso.core.data.DetailedQcStatus) Autowired(org.springframework.beans.factory.annotation.Autowired) DetailedQcItem(uk.ac.bbsrc.tgac.miso.core.data.qc.DetailedQcItem) RunLibraryQcStatusService(uk.ac.bbsrc.tgac.miso.core.service.RunLibraryQcStatusService) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) DetailedQcStatusService(uk.ac.bbsrc.tgac.miso.core.service.DetailedQcStatusService) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Service(org.springframework.stereotype.Service) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) PartitionQCType(uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) QcStatusService(uk.ac.bbsrc.tgac.miso.core.service.QcStatusService) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) QcStatusUpdate(uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) Collection(java.util.Collection) IOException(java.io.IOException) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PartitionQcTypeService(uk.ac.bbsrc.tgac.miso.core.service.PartitionQcTypeService) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) Transactional(org.springframework.transaction.annotation.Transactional) EntityType(uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ListLibraryAliquotView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ListLibraryAliquotView) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) 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) PartitionQCType(uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) Library(uk.ac.bbsrc.tgac.miso.core.data.Library)

Example 8 with RunPartition

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

the class RunRestController method setQc.

@PostMapping(value = "/{runId}/qc", produces = "application/json")
@ResponseStatus(code = HttpStatus.NO_CONTENT)
public void setQc(@PathVariable Long runId, @RequestBody RunPartitionQCRequest request) throws IOException {
    Run run = RestUtils.retrieve("Run", runId, runService);
    PartitionQCType qcType = partitionQcTypeService.list().stream().filter(qt -> qt.getId() == request.getQcTypeId().longValue()).findAny().orElseThrow(() -> new RestException(String.format("No partition QC type found with ID: %d", request.getQcTypeId()), Status.BAD_REQUEST));
    // 
    run.getSequencerPartitionContainers().stream().flatMap(// 
    container -> container.getPartitions().stream()).filter(// 
    partition -> request.partitionIds.contains(partition.getId())).map(WhineyFunction.rethrow(partition -> {
        RunPartition runPartition = runPartitionService.get(run, partition);
        if (runPartition == null) {
            runPartition = new RunPartition();
            runPartition.setRunId(run.getId());
            runPartition.setPartitionId(partition.getId());
        }
        runPartition.setQcType(qcType);
        runPartition.setNotes(request.notes);
        return runPartition;
    })).forEach(WhineyConsumer.rethrow(runPartitionService::save));
}
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) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) PartitionQCType(uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 9 with RunPartition

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

the class EditRunController method setupForm.

public ModelAndView setupForm(Run run, ModelMap model) throws IOException {
    if (run.getId() == Run.UNSAVED_ID) {
        model.put("title", "New Run");
        model.put("multiplexed", false);
        model.put("metrics", "[]");
        model.put("partitionNames", "[]");
    } else {
        model.put("title", "Run " + run.getId());
        model.put("metrics", getSources().filter(Objects::nonNull).map(source -> source.fetchMetrics(run)).filter(metrics -> !isStringBlankOrNull(metrics)).collect(new JsonArrayCollector()));
        if (run.getSequencerPartitionContainers().size() == 1) {
            ObjectMapper mapper = new ObjectMapper();
            model.put("partitionNames", mapper.writeValueAsString(run.getSequencerPartitionContainers().get(0).getPartitions().stream().sorted(Comparator.comparing(Partition::getPartitionNumber)).map(partition -> partition.getPool() == null ? "N/A" : partition.getPool().getAlias()).collect(Collectors.toList())));
        } else {
            model.put("partitionNames", "[]");
        }
        model.put("runReportLinks", externalUriBuilder.getUris(run));
    }
    model.put("runPositions", run.getRunPositions().stream().map(Dtos::asDto).collect(Collectors.toList()));
    model.put("runPartitions", run.getSequencerPartitionContainers().stream().flatMap(container -> container.getPartitions().stream()).map(WhineyFunction.rethrow(partition -> {
        PartitionDto dto = Dtos.asDto(partition, false, indexChecker);
        RunPartition runPartition = runPartitionService.get(run, partition);
        if (runPartition != null) {
            if (runPartition.getQcType() != null) {
                dto.setQcType(runPartition.getQcType().getId());
                dto.setQcNotes(runPartition.getNotes());
            }
            if (runPartition.getPurpose() != null) {
                dto.setRunPurposeId(runPartition.getPurpose().getId());
            }
        } else {
            dto.setQcNotes("");
        }
        return dto;
    })).collect(Collectors.toList()));
    model.put("runAliquots", getRunAliquots(run));
    MisoWebUtils.addIssues(issueTrackerManager, () -> issueTrackerManager.searchIssues(run.getAlias()), model);
    model.put("run", run);
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode partitionConfig = mapper.createObjectNode();
    partitionConfig.put("platformType", run.getPlatformType().name());
    partitionConfig.put("instrumentModelId", run.getSequencer().getInstrumentModel().getId());
    partitionConfig.put("runId", run.getId());
    partitionConfig.put("isFull", run.isFull());
    partitionConfig.put("showContainer", true);
    partitionConfig.put("sequencingParametersId", run.getSequencingParameters() == null ? 0 : run.getSequencingParameters().getId());
    partitionConfig.put("showPool", true);
    model.put("partitionConfig", mapper.writeValueAsString(partitionConfig));
    model.put("experiments", experimentService.listAllByRunId(run.getId()).stream().map(expt -> Dtos.asDto(expt)).collect(Collectors.toList()));
    ObjectNode experimentConfig = mapper.createObjectNode();
    experimentConfig.put("runId", run.getId());
    model.put("experimentConfiguration", mapper.writeValueAsString(experimentConfig));
    model.put("runDto", mapper.writeValueAsString(Dtos.asDto(run)));
    ObjectNode formConfig = mapper.createObjectNode();
    User user = authorizationManager.getCurrentUser();
    formConfig.put("isAdmin", user.isAdmin());
    formConfig.put("isRunReviewer", user.isRunReviewer() || user.isAdmin());
    MisoWebUtils.addJsonArray(mapper, formConfig, "sops", sopService.listByCategory(SopCategory.RUN), Dtos::asDto);
    model.put("formConfig", mapper.writeValueAsString(formConfig));
    return new ModelAndView("/WEB-INF/pages/editRun.jsp", model);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) ClientErrorException(uk.ac.bbsrc.tgac.miso.webapp.controller.component.ClientErrorException) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelMap(org.springframework.ui.ModelMap) IssueTrackerManager(uk.ac.bbsrc.tgac.miso.core.manager.IssueTrackerManager) InstrumentType(uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) JsonArrayCollector(uk.ac.bbsrc.tgac.miso.webapp.util.JsonArrayCollector) SopCategory(uk.ac.bbsrc.tgac.miso.core.data.impl.Sop.SopCategory) ServiceLoader(java.util.ServiceLoader) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) Objects(java.util.Objects) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) MisoWebUtils(uk.ac.bbsrc.tgac.miso.webapp.util.MisoWebUtils) Stream(java.util.stream.Stream) InstrumentService(uk.ac.bbsrc.tgac.miso.core.service.InstrumentService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) User(com.eaglegenomics.simlims.core.User) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) RunMetricsSource(uk.ac.bbsrc.tgac.miso.webapp.util.RunMetricsSource) NotFoundException(org.springframework.security.acls.model.NotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) LimsUtils.isStringBlankOrNull(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils.isStringBlankOrNull) 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) GetMapping(org.springframework.web.bind.annotation.GetMapping) StreamSupport(java.util.stream.StreamSupport) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) ExternalUriBuilder(uk.ac.bbsrc.tgac.miso.webapp.context.ExternalUriBuilder) Logger(org.slf4j.Logger) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) ExperimentService(uk.ac.bbsrc.tgac.miso.core.service.ExperimentService) Comparator(java.util.Comparator) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) PartitionDto(uk.ac.bbsrc.tgac.miso.dto.PartitionDto) SopService(uk.ac.bbsrc.tgac.miso.core.service.SopService) User(com.eaglegenomics.simlims.core.User) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonArrayCollector(uk.ac.bbsrc.tgac.miso.webapp.util.JsonArrayCollector) Objects(java.util.Objects) ModelAndView(org.springframework.web.servlet.ModelAndView) PartitionDto(uk.ac.bbsrc.tgac.miso.dto.PartitionDto) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with RunPartition

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

the class DefaultRunServiceTest method setup.

@Before
public void setup() throws IOException {
    MockitoAnnotations.initMocks(this);
    User notificationUser = makeUser(2L, "notification");
    Mockito.when(authorizationManager.getCurrentUser()).thenReturn(notificationUser);
    Mockito.when(userService.getByLoginName("notification")).thenReturn(notificationUser);
    Mockito.when(instrumentService.getByName(SEQUENCER_NAME)).thenReturn(makeSequencer());
    Mockito.when(containerModelService.find(Mockito.any(), Mockito.eq(CONTAINER_MODEL_BARCODE), Mockito.eq(1))).thenReturn(makeContainerModel());
    Mockito.when(runStore.getByAlias(RUN_ALIAS)).thenReturn(makeSavedRun());
    Mockito.when(sequencingParametersService.listByInstrumentModelId(1L)).thenReturn(Arrays.asList(makeSequencingParameters()));
    Mockito.when(runPartitionService.get(Mockito.any(Run.class), Mockito.any(Partition.class))).thenAnswer((invocation) -> {
        Run run = (Run) invocation.getArguments()[0];
        if (!RUN_ALIAS.equals(run.getAlias())) {
            return null;
        }
        Partition part = (Partition) invocation.getArguments()[1];
        RunPartition runPart = new RunPartition();
        runPart.setRunId(run.getId());
        runPart.setPartitionId(part.getId());
        return runPart;
    });
    Mockito.when(containerService.listByBarcode(CONTAINER_SERIAL_NO)).thenReturn(Arrays.asList(makeContainer()));
}
Also used : RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) User(com.eaglegenomics.simlims.core.User) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) IlluminaRun(uk.ac.bbsrc.tgac.miso.core.data.IlluminaRun) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Before(org.junit.Before)

Aggregations

RunPartition (uk.ac.bbsrc.tgac.miso.core.data.RunPartition)13 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)9 Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)8 User (com.eaglegenomics.simlims.core.User)6 Test (org.junit.Test)5 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)5 SequencerPartitionContainer (uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer)5 IOException (java.io.IOException)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 PartitionQCType (uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Stream (java.util.stream.Stream)3 Controller (org.springframework.stereotype.Controller)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 PathVariable (org.springframework.web.bind.annotation.PathVariable)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3