Search in sources :

Example 1 with PlatformType

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

the class Dtos method to.

public static RunPartitionAliquot to(@Nonnull RunPartitionAliquotDto from) {
    RunPartitionAliquot to = new RunPartitionAliquot();
    PlatformType platform = PlatformType.valueOf(from.getPlatformType());
    setObject(to::setRun, platform::createRun, from.getRunId());
    setObject(to::setPartition, PartitionImpl::new, from.getPartitionId());
    setObject(to::setAliquot, LibraryAliquot::new, from.getAliquotId());
    setObject(to::setPurpose, RunPurpose::new, from.getRunPurposeId());
    setObject(to::setQcStatus, RunLibraryQcStatus::new, from.getQcStatusId());
    setString(to::setQcNote, from.getQcNote());
    setBoolean(to::setDataReview, from.getDataReview(), true);
    return to;
}
Also used : RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) RunPartitionAliquot(uk.ac.bbsrc.tgac.miso.core.data.RunPartitionAliquot) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) IonTorrentRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto) QcHierarchyNodeDto(uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto) RunPositionDto(uk.ac.bbsrc.tgac.miso.dto.run.RunPositionDto) PacBioRunDto(uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto) Ls454RunDto(uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto) IlluminaNotificationDto(ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto) OxfordNanoporeRunDto(uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto) IlluminaRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto) NotificationDto(ca.on.oicr.gsi.runscanner.dto.NotificationDto) OxfordNanoporeNotificationDto(ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SolidRunDto(uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto) OrderAliquotDto(uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto) TransferLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibraryAliquot) WorksetLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibraryAliquot) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) DetailedLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryAliquot) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) RunLibraryQcStatus(uk.ac.bbsrc.tgac.miso.core.data.RunLibraryQcStatus)

Example 2 with PlatformType

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

the class PoolRestController method getPoolsByPlatform.

@GetMapping(value = "platform/{platform}", produces = "application/json")
@ResponseBody
public List<PoolDto> getPoolsByPlatform(@PathVariable("platform") String platform, HttpServletRequest request, HttpServletResponse response, UriComponentsBuilder uriBuilder) throws IOException {
    if (PlatformType.getKeys().contains(platform)) {
        Collection<Pool> pools = new ArrayList<>();
        PlatformType platformType = PlatformType.get(platform);
        pools = poolService.list(0, 0, false, null, PaginationFilter.platformType(platformType));
        return serializePools(pools, uriBuilder);
    } else {
        throw new RestException("Request must specify a platform");
    }
}
Also used : ArrayList(java.util.ArrayList) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with PlatformType

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

the class HibernateSequencingContainerModelDaoIT method testGetByPlatformAndBarcode.

@Test
public void testGetByPlatformAndBarcode() throws Exception {
    PlatformType platform = PlatformType.ILLUMINA;
    String barcode = "12345678";
    SequencingContainerModel model = dao.getByPlatformAndBarcode(platform, barcode);
    assertNotNull(model);
    assertEquals(platform, model.getPlatformType());
    assertEquals(barcode, model.getIdentificationBarcode());
}
Also used : SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 4 with PlatformType

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

the class ConstantsController method rebuildConstants.

private void rebuildConstants() {
    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode node = mapper.createObjectNode();
        node.put("docsVersion", getDocsVersion());
        node.put("isDetailedSample", detailedSample);
        node.put("automaticBarcodes", autoGenerateIdBarcodes);
        node.put("boxScannerEnabled", boxScannerEnabled);
        node.put("newOptionSopUrl", newOptionSopUrl);
        final Collection<SampleValidRelationship> relationships = sampleValidRelationshipService.getAll();
        addJsonArray(mapper, node, "libraryDesigns", libraryDesignService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "libraryTypes", libraryTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "librarySelections", librarySelectionService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "libraryStrategies", libraryStrategyService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "libraryDesignCodes", libraryDesignCodeService.list(), Dtos::asDto);
        Set<Long> activePlatforms = sequencerService.list().stream().filter(Instrument::isActive).map(sequencer -> sequencer.getInstrumentModel().getId()).collect(Collectors.toSet());
        addJsonArray(mapper, node, "instrumentModels", instrumentModelService.list(), platform -> {
            InstrumentModelDto dto = Dtos.asDto(platform);
            dto.setActive(activePlatforms.contains(platform.getId()));
            return dto;
        });
        addJsonArray(mapper, node, "kitDescriptors", kitService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "sampleClasses", sampleClassService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "sampleValidRelationships", relationships, Dtos::asDto);
        addJsonArray(mapper, node, "detailedQcStatuses", detailedQcStatusService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "subprojects", subprojectService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "labs", labService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "tissueOrigins", tissueOriginService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "tissueTypes", tissueTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "tissueMaterials", tissueMaterialService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "tissuePieceTypes", tissuePieceTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "stains", stainService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "targetedSequencings", targetedSequencingService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "samplePurposes", samplePurposeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "sequencingParameters", sequencingParametersService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "printerBackends", Arrays.asList(Backend.values()), Dtos::asDto);
        addJsonArray(mapper, node, "printerDrivers", Arrays.asList(Driver.values()), Dtos::asDto);
        addJsonArray(mapper, node, "boxSizes", boxSizeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "boxUses", boxUseService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "studyTypes", studyTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "sampleCategories", SampleClass.CATEGORIES, Function.identity());
        createMap(mapper, node, "sampleSubcategories", SampleClass.SUBCATEGORIES);
        addJsonArray(mapper, node, "submissionAction", Arrays.asList(SubmissionActionType.values()), SubmissionActionType::name);
        addJsonArray(mapper, node, "containerModels", containerModelService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "poreVersions", containerService.listPoreVersions(), Dtos::asDto);
        addJsonArray(mapper, node, "spikeIns", librarySpikeInService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "attachmentCategories", attachmentCategoryService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "runPurposes", runPurposeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "sequencingControlTypes", sequencingControlTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "scientificNames", scientificNameService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "pipelines", pipelineService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "runLibraryQcStatuses", runLibraryQcStatusService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "worksetCategories", worksetCategoryService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "worksetStages", worksetStageService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "metrics", metricService.list(), MetricDto::from);
        addJsonArray(mapper, node, "metricSubcategories", metricSubcategoryService.list(), MetricSubcategoryDto::from);
        addJsonArray(mapper, node, "assays", assayService.list(), AssayDto::from);
        addJsonArray(mapper, node, "assayTests", assayTestService.list(), AssayTestDto::from);
        addJsonArray(mapper, node, "sampleSheetFormats", Arrays.asList(SampleSheet.values()), SampleSheet::name);
        Collection<IndexFamily> indexFamilies = indexFamilyService.list();
        addJsonArray(mapper, node, "indexFamilies", indexFamilies, Dtos::asDto);
        addJsonArray(mapper, node, "qcTypes", qcService.listQcTypes(), Dtos::asDto);
        addJsonArray(mapper, node, "qcTargets", Arrays.asList(QcTarget.values()), Dtos::asDto);
        addJsonArray(mapper, node, "concentrationUnits", Arrays.asList(ConcentrationUnit.values()), Dtos::asDto);
        addJsonArray(mapper, node, "volumeUnits", Arrays.asList(VolumeUnit.values()), Dtos::asDto);
        addJsonArray(mapper, node, "partitionQcTypes", partitionQcTypeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "referenceGenomes", referenceGenomeService.list(), Dtos::asDto);
        addJsonArray(mapper, node, "spreadsheetFormats", Arrays.asList(SpreadSheetFormat.values()), Dtos::asDto);
        addJsonArray(mapper, node, "sampleSpreadsheets", Arrays.asList(SampleSpreadSheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "librarySpreadsheets", Arrays.asList(LibrarySpreadSheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "libraryAliquotSpreadsheets", Arrays.asList(LibraryAliquotSpreadSheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "poolSpreadsheets", Arrays.asList(PoolSpreadSheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "partitionSpreadsheets", Arrays.asList(PartitionSpreadsheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "runLibrarySpreadsheets", Arrays.asList(RunLibrarySpreadsheets.values()), Dtos::asDto);
        addJsonArray(mapper, node, "workflows", Arrays.asList(WorkflowName.values()), Dtos::asDto);
        addJsonArray(mapper, node, "printableFields", Arrays.asList(PrintableField.values()), PrintableField::name);
        ArrayNode platformTypes = node.putArray("platformTypes");
        Collection<PlatformType> activePlatformTypes = instrumentModelService.listActivePlatformTypes();
        for (PlatformType platformType : PlatformType.values()) {
            ObjectNode dto = platformTypes.addObject();
            dto.put("name", platformType.name());
            dto.put("key", platformType.getKey());
            dto.put("containerName", platformType.getContainerName());
            dto.put("active", activePlatformTypes.contains(platformType));
            dto.put("partitionName", platformType.getPartitionName());
            dto.put("pluralPartitionName", platformType.getPluralPartitionName());
        }
        ArrayNode sampleTypes = node.putArray("sampleTypes");
        for (SampleType sampleType : sampleTypeService.list()) {
            if (!sampleType.isArchived()) {
                sampleTypes.add(sampleType.getName());
            }
        }
        ArrayNode donorSexes = node.putArray("donorSexes");
        for (String label : DonorSex.getLabels()) {
            donorSexes.add(label);
        }
        ArrayNode consentLevels = node.putArray("consentLevels");
        for (ConsentLevel level : ConsentLevel.values()) {
            consentLevels.add(level.getLabel());
        }
        ArrayNode strStatuses = node.putArray("strStatuses");
        for (String label : StrStatus.getLabels()) {
            strStatuses.add(label);
        }
        ArrayNode dilutionFactors = node.putArray("dilutionFactors");
        for (String label : DilutionFactor.getLabels()) {
            dilutionFactors.add(label);
        }
        ArrayNode illuminaChemistry = node.putArray("illuminaChemistry");
        for (IlluminaChemistry chemistry : IlluminaChemistry.values()) {
            illuminaChemistry.add(chemistry.name());
        }
        addIlluminaExperimentTypes(node);
        addHealthTypes(node);
        addIlluminaWorkflowTypes(node);
        addInstrumentTypes(node);
        addDataManglingPolicies(node);
        addMetricCategories(node);
        addThresholdTypes(node);
        ObjectNode warningsNode = mapper.createObjectNode();
        warningsNode.put("consentRevoked", "CONSENT REVOKED");
        warningsNode.put("duplicateIndices", indexChecker.getErrorMismatchesMessage());
        warningsNode.put("nearDuplicateIndices", indexChecker.getWarningMismatchesMessage());
        warningsNode.put("lowQualityLibraries", "Low Quality Libraries");
        warningsNode.put("missingIndex", "MISSING INDEX");
        warningsNode.put("negativeVolume", "Negative Volume");
        node.set("warningMessages", warningsNode);
        node.put("errorEditDistance", indexChecker.getErrorMismatches());
        node.put("warningEditDistance", indexChecker.getWarningMismatches());
        node.put("genomeFolder", genomeFolder);
        // Save the regenerated file in cache.
        constantsJs = "Constants = " + mapper.writeValueAsString(node) + ";";
        constantsTimestamp.set(System.currentTimeMillis() / 1000.0);
    } catch (IOException e) {
        throw new RestException(e);
    }
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Arrays(java.util.Arrays) LibraryAliquotSpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.LibraryAliquotSpreadSheets) ScheduledFuture(java.util.concurrent.ScheduledFuture) PoolSpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.PoolSpreadSheets) SampleSpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.SampleSpreadSheets) IlluminaWorkflowType(uk.ac.bbsrc.tgac.miso.core.data.type.IlluminaWorkflowType) Autowired(org.springframework.beans.factory.annotation.Autowired) SampleSheet(uk.ac.bbsrc.tgac.miso.core.util.SampleSheet) CacheControl(org.springframework.http.CacheControl) InstrumentType(uk.ac.bbsrc.tgac.miso.core.data.type.InstrumentType) Backend(uk.ac.bbsrc.tgac.miso.core.service.printing.Backend) MisoWebUtils.addJsonArray(uk.ac.bbsrc.tgac.miso.webapp.util.MisoWebUtils.addJsonArray) ThresholdType(uk.ac.bbsrc.tgac.miso.core.data.type.ThresholdType) Gauge(io.prometheus.client.Gauge) Map(java.util.Map) RestException(uk.ac.bbsrc.tgac.miso.webapp.controller.rest.RestException) uk.ac.bbsrc.tgac.miso.dto(uk.ac.bbsrc.tgac.miso.dto) SubmissionActionType(uk.ac.bbsrc.tgac.miso.core.data.type.SubmissionActionType) Collection(java.util.Collection) Resource(javax.annotation.Resource) Set(java.util.Set) Collectors(java.util.stream.Collectors) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) Executors(java.util.concurrent.Executors) RunLibrarySpreadsheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.RunLibrarySpreadsheets) ConsentLevel(uk.ac.bbsrc.tgac.miso.core.data.type.ConsentLevel) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) List(java.util.List) StrStatus(uk.ac.bbsrc.tgac.miso.core.data.type.StrStatus) DilutionFactor(uk.ac.bbsrc.tgac.miso.core.data.type.DilutionFactor) LibrarySpreadSheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.LibrarySpreadSheets) Driver(uk.ac.bbsrc.tgac.miso.core.service.printing.Driver) IlluminaChemistry(uk.ac.bbsrc.tgac.miso.core.data.IlluminaChemistry) SampleClass(uk.ac.bbsrc.tgac.miso.core.data.SampleClass) PartitionSpreadsheets(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.PartitionSpreadsheets) MetricCategory(uk.ac.bbsrc.tgac.miso.core.data.type.MetricCategory) SampleValidRelationship(uk.ac.bbsrc.tgac.miso.core.data.SampleValidRelationship) DonorSex(uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity.DonorSex) HealthType(uk.ac.bbsrc.tgac.miso.core.data.type.HealthType) Scheduled(org.springframework.scheduling.annotation.Scheduled) Controller(org.springframework.stereotype.Controller) InstrumentDataManglingPolicy(uk.ac.bbsrc.tgac.miso.core.data.InstrumentDataManglingPolicy) Function(java.util.function.Function) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Value(org.springframework.beans.factory.annotation.Value) Version(uk.ac.bbsrc.tgac.miso.Version) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) GetMapping(org.springframework.web.bind.annotation.GetMapping) VolumeUnit(uk.ac.bbsrc.tgac.miso.core.data.VolumeUnit) IndexFamily(uk.ac.bbsrc.tgac.miso.core.data.IndexFamily) ConcentrationUnit(uk.ac.bbsrc.tgac.miso.core.data.ConcentrationUnit) HttpServletResponse(javax.servlet.http.HttpServletResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) uk.ac.bbsrc.tgac.miso.core.service(uk.ac.bbsrc.tgac.miso.core.service) TimeUnit(java.util.concurrent.TimeUnit) SampleType(uk.ac.bbsrc.tgac.miso.core.data.SampleType) WorkflowName(uk.ac.bbsrc.tgac.miso.core.data.workflow.Workflow.WorkflowName) SpreadSheetFormat(uk.ac.bbsrc.tgac.miso.core.data.spreadsheet.SpreadSheetFormat) PrintableField(uk.ac.bbsrc.tgac.miso.core.service.printing.PrintableField) QcTarget(uk.ac.bbsrc.tgac.miso.core.data.qc.QcTarget) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) ServletContext(javax.servlet.ServletContext) ResponseEntity(org.springframework.http.ResponseEntity) IlluminaExperiment(uk.ac.bbsrc.tgac.miso.core.util.IlluminaExperiment) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) IlluminaChemistry(uk.ac.bbsrc.tgac.miso.core.data.IlluminaChemistry) SubmissionActionType(uk.ac.bbsrc.tgac.miso.core.data.type.SubmissionActionType) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConsentLevel(uk.ac.bbsrc.tgac.miso.core.data.type.ConsentLevel) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SampleSheet(uk.ac.bbsrc.tgac.miso.core.util.SampleSheet) RestException(uk.ac.bbsrc.tgac.miso.webapp.controller.rest.RestException) PrintableField(uk.ac.bbsrc.tgac.miso.core.service.printing.PrintableField) IOException(java.io.IOException) SampleValidRelationship(uk.ac.bbsrc.tgac.miso.core.data.SampleValidRelationship) IndexFamily(uk.ac.bbsrc.tgac.miso.core.data.IndexFamily) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) SampleType(uk.ac.bbsrc.tgac.miso.core.data.SampleType)

Example 5 with PlatformType

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

the class DefaultPoolOrderService method collectValidationErrors.

@Override
protected void collectValidationErrors(PoolOrder object, PoolOrder beforeChange, List<ValidationError> errors) throws IOException {
    if (object.getPool() != null || object.getSequencingOrder() != null) {
        // order should be fulfilled
        if (object.isDraft()) {
            errors.add(new ValidationError("draft", "Fulfilled order cannot be a draft"));
        }
        if (object.getPool() == null) {
            errors.add(new ValidationError("poolId", "Pool must be provided if a sequencing order is linked"));
        } else {
            for (OrderLibraryAliquot orderAli : object.getOrderLibraryAliquots()) {
                if (object.getPool().getPoolContents().stream().map(PoolElement::getAliquot).noneMatch(poolElement -> {
                    if (poolElement.getId() == orderAli.getAliquot().getId()) {
                        return true;
                    }
                    for (ParentAliquot parent = poolElement.getParentAliquot(); parent != null; parent = parent.getParentAliquot()) {
                        if (parent.getId() == orderAli.getAliquot().getId()) {
                            return true;
                        }
                    }
                    return false;
                })) {
                    errors.add(new ValidationError("Pool does not contain all of the required aliquots"));
                    break;
                }
            }
            if (object.getSequencingOrder() != null) {
                SequencingOrder seqOrder = object.getSequencingOrder();
                if (seqOrder.getPurpose().getId() != object.getPurpose().getId() || seqOrder.getSequencingParameter().getId() != object.getParameters().getId() || !seqOrder.getPartitions().equals(object.getPartitions()) || seqOrder.getPool().getId() != object.getPool().getId() || (object.getContainerModel() != null && (seqOrder.getContainerModel() == null || seqOrder.getContainerModel().getId() != object.getContainerModel().getId()))) {
                    errors.add(new ValidationError("Sequencing order does not match the pool order"));
                }
            }
        }
        preventFulfilledChange("partitions", PoolOrder::getPartitions, object, beforeChange, errors);
        preventFulfilledChange("parametersId", PoolOrder::getParameters, object, beforeChange, errors);
        preventFulfilledChange("containerModelId", PoolOrder::getContainerModel, object, beforeChange, errors);
        preventFulfilledChange("description", PoolOrder::getDescription, object, beforeChange, errors);
        preventFulfilledChange("alias", PoolOrder::getAlias, object, beforeChange, errors);
        preventFulfilledChange("purposeId", PoolOrder::getPurpose, object, beforeChange, errors);
        if (!allMatch(object.getOrderLibraryAliquots(), beforeChange.getOrderLibraryAliquots())) {
            errors.add(new ValidationError("Aliquots cannot be changed after the order is fulfilled"));
        }
    }
    // if any sequencing requirements are specified, all are required
    if (object.getContainerModel() != null || object.getParameters() != null || object.getPartitions() != null) {
        // exception: container model not required for legacy orders (from before container model was added to orders)
        if ((beforeChange == null || beforeChange.getContainerModel() != null) && object.getContainerModel() == null) {
            errors.add(ValidationUtils.makeNoNullError("containerModelId"));
        }
        if (object.getParameters() == null) {
            errors.add(ValidationUtils.makeNoNullError("parametersId"));
        }
        if (object.getPartitions() == null) {
            errors.add(ValidationUtils.makeNoNullError("partitions"));
        }
    }
    // Container model and seq params must be linked to same instrument model
    if (object.getContainerModel() != null && object.getParameters().getInstrumentModel().getContainerModels().stream().noneMatch(model -> model.getId() == object.getContainerModel().getId())) {
        errors.add(new ValidationError("containerModelId", "Not compatible with the selected sequencing parameters"));
    }
    PlatformType orderPlatform = object.getParameters() == null ? null : object.getParameters().getInstrumentModel().getPlatformType();
    for (OrderLibraryAliquot orderAli : object.getOrderLibraryAliquots()) {
        PlatformType libPlatform = orderAli.getAliquot().getLibrary().getPlatformType();
        if (orderPlatform == null) {
            orderPlatform = libPlatform;
        } else if (!libPlatform.equals(orderPlatform)) {
            errors.add(new ValidationError("Platform for all aliquots and sequencing parameters (if specified) must match"));
            break;
        }
    }
    if (!object.isDraft() && object.getOrderLibraryAliquots().isEmpty()) {
        errors.add(new ValidationError("Non-draft order must include at least one library aliquot"));
    }
    if (strictPools) {
        validateNoNewDuplicateIndices(object, beforeChange, errors);
    }
}
Also used : PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) RunPurposeService(uk.ac.bbsrc.tgac.miso.core.service.RunPurposeService) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) SequencingOrderService(uk.ac.bbsrc.tgac.miso.core.service.SequencingOrderService) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) Autowired(org.springframework.beans.factory.annotation.Autowired) Function(java.util.function.Function) SequencingContainerModelService(uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService) LibraryAliquotService(uk.ac.bbsrc.tgac.miso.core.service.LibraryAliquotService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Value(org.springframework.beans.factory.annotation.Value) Service(org.springframework.stereotype.Service) PoolOrder(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolOrder) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot) PoolElement(uk.ac.bbsrc.tgac.miso.core.data.impl.view.PoolElement) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) ValidationResult(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationResult) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) DeletionStore(uk.ac.bbsrc.tgac.miso.core.store.DeletionStore) PoolOrderDao(uk.ac.bbsrc.tgac.miso.persistence.PoolOrderDao) IOException(java.io.IOException) IndexChecker(uk.ac.bbsrc.tgac.miso.core.util.IndexChecker) Consumer(java.util.function.Consumer) List(java.util.List) SequencingParametersService(uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService) PoolOrderService(uk.ac.bbsrc.tgac.miso.service.PoolOrderService) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) ChangeLogService(uk.ac.bbsrc.tgac.miso.core.service.ChangeLogService) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) AbstractSaveService(uk.ac.bbsrc.tgac.miso.service.AbstractSaveService) SaveDao(uk.ac.bbsrc.tgac.miso.persistence.SaveDao) Transactional(org.springframework.transaction.annotation.Transactional) OrderLibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.OrderLibraryAliquot) SequencingOrder(uk.ac.bbsrc.tgac.miso.core.data.SequencingOrder) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) PlatformType(uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot)

Aggregations

PlatformType (uk.ac.bbsrc.tgac.miso.core.data.type.PlatformType)8 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)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 IOException (java.io.IOException)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 Function (java.util.function.Function)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Value (org.springframework.beans.factory.annotation.Value)2 IndexFamily (uk.ac.bbsrc.tgac.miso.core.data.IndexFamily)2 VolumeUnit (uk.ac.bbsrc.tgac.miso.core.data.VolumeUnit)2 LibraryType (uk.ac.bbsrc.tgac.miso.core.data.type.LibraryType)2 IndexChecker (uk.ac.bbsrc.tgac.miso.core.util.IndexChecker)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1