Search in sources :

Example 1 with Requisition

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

the class RequisitionRestController method addSamples.

@PostMapping("/{requisitionId}/samples")
@ResponseBody
public ObjectNode addSamples(@PathVariable long requisitionId, @RequestBody List<Long> ids) throws IOException {
    Requisition requisition = RestUtils.retrieve(TYPE_LABEL, requisitionId, requisitionService, Status.NOT_FOUND);
    List<Sample> samples = new ArrayList<>();
    for (Long id : ids) {
        Sample sample = RestUtils.retrieve("Sample", id, sampleService, Status.BAD_REQUEST);
        sample.setRequisition(requisition);
        samples.add(sample);
    }
    return asyncOperationManager.startAsyncBulkUpdate("Sample", samples, sampleService);
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) ArrayList(java.util.ArrayList) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Requisition

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

the class DefaultRequisitionService method addNote.

@Override
public void addNote(Requisition entity, Note note) throws IOException {
    Requisition managed = requisitionDao.get(entity.getId());
    note.setCreationDate(new Date());
    note.setOwner(authorizationManager.getCurrentUser());
    managed.addNote(note);
    managed.setLastModifier(authorizationManager.getCurrentUser());
    requisitionDao.update(managed);
}
Also used : Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) Date(java.util.Date)

Example 3 with Requisition

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

the class Dtos method asDto.

public static LibraryAliquotDto asDto(@Nonnull LibraryAliquot from, boolean includeBoxPositions) {
    LibraryAliquotDto dto = null;
    Library library = from.getLibrary();
    Sample sample = library == null ? null : library.getSample();
    if (isDetailedLibraryAliquot(from)) {
        DetailedLibraryAliquotDto detailedDto = asDetailedDto((DetailedLibraryAliquot) from);
        DetailedSample detailed = (DetailedSample) sample;
        if (detailed.getSubproject() != null) {
            detailedDto.setSubprojectAlias(detailed.getSubproject().getAlias());
            detailedDto.setSubprojectPriority(detailed.getSubproject().getPriority());
        }
        if (detailed.getIdentityAttributes() != null) {
            ParentIdentityAttributes identity = detailed.getIdentityAttributes();
            setString(detailedDto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
            setString(detailedDto::setEffectiveExternalNames, identity.getExternalName());
        }
        if (detailed.getTissueAttributes() != null) {
            ParentTissueAttributes tissue = detailed.getTissueAttributes();
            setString(detailedDto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
            setString(detailedDto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
            setString(detailedDto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
            setString(detailedDto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
        }
        dto = detailedDto;
    } else {
        dto = new LibraryAliquotDto();
    }
    if (library != null) {
        setLong(dto::setLibraryId, library.getId(), true);
        setString(dto::setLibraryName, library.getName());
        setString(dto::setLibraryAlias, library.getAlias());
        setBoolean(dto::setLibraryLowQuality, library.isLowQuality(), false);
        setString(dto::setLibraryPlatformType, library.getPlatformType().getKey());
        if (library.getIndex1() != null) {
            List<Index> indices = Stream.of(library.getIndex1(), library.getIndex2()).filter(Objects::nonNull).collect(Collectors.toList());
            dto.setIndexIds(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getId).collect(Collectors.toList()));
            dto.setIndexLabels(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getLabel).collect(Collectors.toList()));
        }
        if (sample != null) {
            setLong(dto::setSampleId, sample.getId(), true);
            setString(dto::setSampleName, sample.getName());
            setString(dto::setSampleAlias, sample.getAlias());
        }
    }
    if (from.getParentAliquot() != null) {
        setLong(dto::setParentAliquotId, from.getParentAliquot().getId(), true);
        setString(dto::setParentAliquotAlias, from.getParentAliquot().getAlias());
    }
    setString(dto::setParentName, maybeGetProperty(from.getParent(), HierarchyEntity::getName));
    setString(dto::setParentVolume, maybeGetProperty(from.getParent(), HierarchyEntity::getVolume));
    dto.setId(from.getId());
    dto.setName(from.getName());
    setString(dto::setAlias, from.getAlias());
    setString(dto::setDescription, from.getDescription());
    dto.setCreatorName(from.getCreator().getFullName());
    setString(dto::setConcentration, from.getConcentration());
    dto.setConcentrationUnits(from.getConcentrationUnits());
    setString(dto::setVolume, from.getVolume());
    dto.setVolumeUnits(from.getVolumeUnits());
    setString(dto::setNgUsed, from.getNgUsed());
    setString(dto::setVolumeUsed, from.getVolumeUsed());
    setInteger(dto::setDnaSize, from.getDnaSize(), true);
    if (from.getCreationDate() != null) {
        dto.setCreationDate(formatDate(from.getCreationDate()));
    }
    dto.setIdentificationBarcode(from.getIdentificationBarcode());
    dto.setLocationLabel(BoxUtils.makeLocationLabel(from));
    if (from.getTargetedSequencing() != null) {
        dto.setTargetedSequencingId(from.getTargetedSequencing().getId());
    }
    if (from.getBox() != null) {
        dto.setBox(asDto(from.getBox(), includeBoxPositions));
        dto.setBoxPosition(from.getBoxPosition());
    }
    dto.setDiscarded(from.isDiscarded());
    setDateTimeString(dto::setLastModified, from.getLastModified());
    setId(dto::setDetailedQcStatusId, from.getDetailedQcStatus());
    setString(dto::setDetailedQcStatusNote, from.getDetailedQcStatusNote());
    setString(dto::setQcUserName, maybeGetProperty(from.getQcUser(), User::getFullName));
    setDateString(dto::setQcDate, from.getQcDate());
    setEffectiveQcFailure(from, dto);
    setId(dto::setKitDescriptorId, from.getKitDescriptor());
    setString(dto::setKitLot, from.getKitLot());
    Requisition requisition = from.getLibrary().getSample().getRequisition();
    if (requisition == null) {
        requisition = getParentRequisition(from.getLibrary().getSample());
    }
    setId(dto::setRequisitionId, requisition);
    setString(dto::setRequisitionAlias, maybeGetProperty(requisition, Requisition::getAlias));
    return dto;
}
Also used : ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) ParentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentSample) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) WorksetSample(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample) GrandparentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.GrandparentSample) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Index(uk.ac.bbsrc.tgac.miso.core.data.Index) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) ParentLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary) WorksetLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition)

Example 4 with Requisition

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

the class Dtos method to.

public static QC to(@Nonnull QcDto dto) {
    QC to;
    switch(dto.getQcTarget()) {
        case "Library":
            LibraryQC newLibraryQc = new LibraryQC();
            Library ownerLibrary = new LibraryImpl();
            ownerLibrary.setId(dto.getEntityId());
            newLibraryQc.setLibrary(ownerLibrary);
            to = newLibraryQc;
            break;
        case "Sample":
            SampleQC newSampleQc = new SampleQC();
            Sample ownerSample = new SampleImpl();
            ownerSample.setId(dto.getEntityId());
            newSampleQc.setSample(ownerSample);
            to = newSampleQc;
            break;
        case "Pool":
            PoolQC newPoolQc = new PoolQC();
            Pool ownerPool = new PoolImpl();
            ownerPool.setId(dto.getEntityId());
            newPoolQc.setPool(ownerPool);
            to = newPoolQc;
            break;
        case "Container":
            ContainerQC newContainerQc = new ContainerQC();
            SequencerPartitionContainer ownerContainer = new SequencerPartitionContainerImpl();
            ownerContainer.setId(dto.getEntityId());
            newContainerQc.setContainer(ownerContainer);
            to = newContainerQc;
            break;
        case "Requisition":
            RequisitionQC newRequisitionQc = new RequisitionQC();
            Requisition ownerRequisition = new Requisition();
            ownerRequisition.setId(dto.getEntityId());
            newRequisitionQc.setRequisition(ownerRequisition);
            to = newRequisitionQc;
            break;
        default:
            throw new IllegalArgumentException("No such QC target: " + dto.getQcTarget());
    }
    if (dto.getId() != null) {
        to.setId(dto.getId());
    }
    to.setDate(parseDate(dto.getDate()));
    setBigDecimal(to::setResults, dto.getResults());
    setObject(to::setType, QcType::new, dto.getQcTypeId());
    to.setDescription(dto.getDescription());
    setObject(to::setInstrument, InstrumentImpl::new, dto.getInstrumentId());
    setObject(to::setKit, KitDescriptor::new, dto.getKitDescriptorId());
    setString(to::setKitLot, dto.getKitLot());
    addQcControlRuns(dto.getControls(), to, QcTarget.valueOf(dto.getQcTarget()));
    return to;
}
Also used : SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) ParentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentSample) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) WorksetSample(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample) GrandparentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.GrandparentSample) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) SampleQC(uk.ac.bbsrc.tgac.miso.core.data.qc.SampleQC) RequisitionQC(uk.ac.bbsrc.tgac.miso.core.data.qc.RequisitionQC) LibraryQC(uk.ac.bbsrc.tgac.miso.core.data.qc.LibraryQC) PoolImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl) LibraryQC(uk.ac.bbsrc.tgac.miso.core.data.qc.LibraryQC) PoolQC(uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC) QC(uk.ac.bbsrc.tgac.miso.core.data.qc.QC) SampleQC(uk.ac.bbsrc.tgac.miso.core.data.qc.SampleQC) ContainerQC(uk.ac.bbsrc.tgac.miso.core.data.qc.ContainerQC) RequisitionQC(uk.ac.bbsrc.tgac.miso.core.data.qc.RequisitionQC) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) LibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl) DetailedLibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedLibraryImpl) SequencerPartitionContainerImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencerPartitionContainerImpl) TransferPool(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferPool) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) InstrumentStatusPositionRunPool(uk.ac.bbsrc.tgac.miso.core.data.impl.view.instrumentstatus.InstrumentStatusPositionRunPool) ContainerQC(uk.ac.bbsrc.tgac.miso.core.data.qc.ContainerQC) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) ParentLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary) WorksetLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) 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) PoolQC(uk.ac.bbsrc.tgac.miso.core.data.qc.PoolQC) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) DetailedSampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedSampleImpl) QcType(uk.ac.bbsrc.tgac.miso.core.data.type.QcType)

Example 5 with Requisition

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

the class RequisitionRestController method moveSamples.

@PostMapping("/{requisitionId}/samples/move")
@ResponseBody
public RequisitionDto moveSamples(@PathVariable long requisitionId, @RequestBody MoveSamplesRequest request) throws IOException {
    List<Sample> samples = new ArrayList<>();
    for (Long id : request.sampleIds) {
        Sample sample = RestUtils.retrieve("Sample", id, sampleService, Status.BAD_REQUEST);
        samples.add(sample);
    }
    Requisition requisition = null;
    if (request.requisitionId != null) {
        requisition = RestUtils.retrieve("Requisition", request.requisitionId, requisitionService, Status.BAD_REQUEST);
    } else {
        requisition = new Requisition();
        requisition.setAlias(request.requisitionAlias);
        Assay assay = new Assay();
        assay.setId(request.assayId);
        requisition.setAssay(assay);
        requisition.setStopped(request.stopped);
    }
    Requisition saved = requisitionService.moveToRequisition(requisition, samples);
    return RequisitionDto.from(saved);
}
Also used : Assay(uk.ac.bbsrc.tgac.miso.core.data.impl.Assay) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) ArrayList(java.util.ArrayList) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Requisition (uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition)18 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)7 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)6 Assay (uk.ac.bbsrc.tgac.miso.core.data.impl.Assay)4 DetailedLibrary (uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary)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 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)2 SampleStock (uk.ac.bbsrc.tgac.miso.core.data.SampleStock)2 DetailedSampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.DetailedSampleImpl)2 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)2 TransferLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary)2 TransferSample (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample)2