Search in sources :

Example 1 with QcStatusUpdate

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

the class Dtos method to.

public static QcStatusUpdate to(@Nonnull QcNodeDto from) {
    QcStatusUpdate to = new QcStatusUpdate();
    setLong(to::setId, from.getId(), true);
    to.setIds(from.getIds());
    setObject(to::setEntityType, from.getEntityType(), QcNodeType::lookup);
    setBoolean(to::setQcPassed, from.getQcPassed(), true);
    setLong(to::setQcStatusId, from.getQcStatusId(), true);
    setString(to::setQcNote, from.getQcNote());
    setBoolean(to::setDataReview, from.getDataReview(), true);
    return to;
}
Also used : QcNodeType(uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcNodeType) 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) QcStatusUpdate(uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate)

Example 2 with QcStatusUpdate

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

the class QcStatusRestController method update.

@PutMapping
@ResponseStatus(HttpStatus.NO_CONTENT)
@ResponseBody
public void update(@RequestBody QcNodeDto dto) throws IOException {
    QcStatusUpdate update = Dtos.to(dto);
    qcStatusService.update(update);
}
Also used : QcStatusUpdate(uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PutMapping(org.springframework.web.bind.annotation.PutMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with QcStatusUpdate

use of uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate 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)

Aggregations

QcStatusUpdate (uk.ac.bbsrc.tgac.miso.core.data.impl.view.qc.QcStatusUpdate)3 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)1 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)1 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1 PutMapping (org.springframework.web.bind.annotation.PutMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1 EntityType (uk.ac.bbsrc.tgac.miso.core.data.Boxable.EntityType)1 DetailedQcStatus (uk.ac.bbsrc.tgac.miso.core.data.DetailedQcStatus)1 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)1 Partition (uk.ac.bbsrc.tgac.miso.core.data.Partition)1 PartitionQCType (uk.ac.bbsrc.tgac.miso.core.data.PartitionQCType)1 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)1 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)1