Search in sources :

Example 1 with Instrument

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

the class ServiceRecordPageIT method testCreate.

@Test
public void testCreate() throws Exception {
    // goal: add one service record
    Instrument seq = (Instrument) getSession().get(InstrumentImpl.class, 200L);
    assertNotNull(seq);
    assertEquals(0, seq.getServiceRecords().size());
    InstrumentPage seqPage = InstrumentPage.get(getDriver(), getBaseUrl(), 200L);
    ServiceRecordPage page = seqPage.addServiceRecord();
    assertNotNull(page);
    assertEquals(seq.getName(), page.getField(Field.INSTRUMENT));
    Map<Field, String> fields = Maps.newLinkedHashMap();
    fields.put(Field.TITLE, "Test Service Record");
    fields.put(Field.DETAILS, "Many details, all of them important");
    fields.put(Field.SERVICED_BY, "Technician");
    fields.put(Field.REFERENCE_NUMBER, "123456");
    fields.put(Field.SERVICE_DATE, "2017-09-01");
    fields.put(Field.START_TIME, "2017-08-31 16:00:00");
    fields.put(Field.OUT_OF_SERVICE, "true");
    fields.put(Field.END_TIME, "2017-09-01 09:00:00");
    page.setFields(fields);
    assertFieldValues("pre-save", fields, page);
    ServiceRecordPage page2 = page.save();
    assertNotNull(page2);
    assertFieldValues("post-save", fields, page2);
    String newId = page2.getField(Field.ID);
    ServiceRecord sr = (ServiceRecord) getSession().get(ServiceRecord.class, Long.valueOf(newId));
    assertServiceRecordAttributes(fields, sr);
}
Also used : InstrumentPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.InstrumentPage) Field(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.ServiceRecordPage.Field) InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) ServiceRecordPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.ServiceRecordPage) ServiceRecord(uk.ac.bbsrc.tgac.miso.core.data.ServiceRecord) Test(org.junit.Test)

Example 2 with Instrument

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

the class DefaultLibraryService method validateChange.

private void validateChange(Library library, Library beforeChange, boolean libraryReceipt) throws IOException {
    updateDetailedQcStatusDetails(library, beforeChange, authorizationManager);
    List<ValidationError> errors = new ArrayList<>();
    if (!hasTemporaryAlias(library)) {
        NamingScheme namingScheme = getNamingScheme(library);
        boolean aliasChanged = isChanged(Library::getAlias, library, beforeChange);
        if (aliasChanged) {
            if (isInvalidDuplicate(library, namingScheme)) {
                errors.add(ValidationError.forDuplicate("library", "alias"));
            }
        }
        if (!isDetailedLibrary(library) || !((DetailedLibrary) library).hasNonStandardAlias()) {
            uk.ac.bbsrc.tgac.miso.core.service.naming.validation.ValidationResult aliasValidation = namingScheme.validateLibraryAlias(library.getAlias());
            if (!aliasValidation.isValid()) {
                if (!aliasChanged && isDetailedLibrary(library)) {
                    ((DetailedLibrary) library).setNonStandardAlias(true);
                } else {
                    throw new ValidationException(new ValidationError("alias", aliasValidation.getMessage()));
                }
            }
        }
        if (!isDetailedLibrary(library) || !((DetailedLibrary) library).hasNonStandardAlias()) {
            uk.ac.bbsrc.tgac.miso.core.service.naming.validation.ValidationResult aliasValidation = namingScheme.validateLibraryAlias(library.getAlias());
            if (!aliasValidation.isValid()) {
                throw new ValidationException(new ValidationError("alias", aliasValidation.getMessage()));
            }
        }
    }
    validateConcentrationUnits(library.getConcentration(), library.getConcentrationUnits(), errors);
    validateVolume(library.getInitialVolume(), library.getVolume(), errors);
    validateVolumeUnits(library.getVolume(), library.getVolumeUnits(), errors);
    validateBarcodeUniqueness(library, beforeChange, barcodableReferenceService, errors);
    validateUnboxableFields(library, errors);
    validateDetailedQcStatus(library, errors);
    if (isDetailedLibrary(library) && beforeChange != null) {
        validateTargetedSequencing(((DetailedLibrary) library).getLibraryDesignCode(), beforeChange.getLibraryAliquots(), errors);
        validateGroupDescription((DetailedLibrary) library, errors);
    }
    // 2. propagating (not library receipt), and options exist
    if (beforeChange != null) {
        if (beforeChange.getThermalCycler() != null && library.getThermalCycler() == null) {
            addRequiredError(errors, "thermalCyclerId");
        }
        if (beforeChange.getKitLot() != null && library.getKitLot() == null) {
            addRequiredError(errors, "kitLot");
        }
        if (beforeChange.getSop() != null && library.getSop() == null) {
            addRequiredError(errors, "sopId");
        }
    } else if (!libraryReceipt) {
        if (library.getThermalCycler() == null && instrumentService.listByType(InstrumentType.THERMAL_CYCLER).stream().anyMatch(Instrument::isActive)) {
            addRequiredError(errors, "thermalCyclerId");
        }
        if (library.getKitLot() == null) {
            addRequiredError(errors, "kitLot");
        }
        if (library.getSop() == null && sopService.listByCategory(SopCategory.LIBRARY).stream().anyMatch(sop -> !sop.isArchived())) {
            addRequiredError(errors, "sopId");
        }
    }
    if (library.getSpikeIn() != null) {
        if (library.getSpikeInDilutionFactor() == null) {
            errors.add(new ValidationError("spikeInDilutionFactor", "Spike-in dilution factor must be specified"));
        }
        if (library.getSpikeInVolume() == null) {
            errors.add(new ValidationError("spikeInVolume", "Spike-in volume must be specified"));
        }
    }
    validateIndices(library, errors);
    if (!errors.isEmpty()) {
        throw new ValidationException(errors);
    }
}
Also used : ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) NamingScheme(uk.ac.bbsrc.tgac.miso.core.service.naming.NamingScheme) ArrayList(java.util.ArrayList) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary)

Example 3 with Instrument

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

the class DefaultRunServiceTest method makeSequencer.

private static Instrument makeSequencer() {
    Instrument inst = new InstrumentImpl();
    inst.setId(1L);
    inst.setName(SEQUENCER_NAME);
    inst.setInstrumentModel(makeInstrumentModel());
    return inst;
}
Also used : InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument)

Example 4 with Instrument

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

the class Dtos method to.

public static Instrument to(@Nonnull InstrumentDto dto) {
    Instrument to = new InstrumentImpl();
    setLong(to::setId, dto.getId(), false);
    setDate(to::setDateCommissioned, dto.getDateCommissioned());
    setDate(to::setDateDecommissioned, dto.getDateDecommissioned());
    setString(to::setName, dto.getName());
    setObject(to::setInstrumentModel, InstrumentModel::new, dto.getInstrumentModelId());
    setString(to::setSerialNumber, dto.getSerialNumber());
    setObject(to::setUpgradedInstrument, InstrumentImpl::new, dto.getUpgradedInstrumentId());
    setObject(to::setDefaultRunPurpose, RunPurpose::new, dto.getDefaultRunPurposeId());
    setString(to::setIdentificationBarcode, dto.getIdentificationBarcode());
    setObject(to::setWorkstation, Workstation::new, dto.getWorkstationId());
    return to;
}
Also used : Workstation(uk.ac.bbsrc.tgac.miso.core.data.Workstation) RunPurpose(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPurpose) InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) 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)

Example 5 with Instrument

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

the class DefaultContainerService method validateChange.

private void validateChange(SequencerPartitionContainer container, SequencerPartitionContainer beforeChange) throws IOException {
    if (container.getModel().getPartitionCount() != container.getPartitions().size()) {
        // this is not user-correctable, so should not be reported as a validation error
        throw new IllegalArgumentException("Number of partitions does not match container model specifications");
    }
    List<ValidationError> errors = new ArrayList<>();
    if (LimsUtils.isStringBlankOrNull(container.getIdentificationBarcode())) {
        errors.add(new ValidationError("identificationBarcode", "Required"));
    }
    ValidationUtils.validateBarcodeUniqueness(container, beforeChange, barcodableReferenceService, errors);
    if (container.getClusteringKit() != null && container.getClusteringKit().getKitType() != KitType.CLUSTERING) {
        errors.add(new ValidationError("clusteringKitId", "Must be a clustering kit"));
    }
    if (container.getClusteringKitLot() != null && container.getClusteringKit() == null) {
        errors.add(new ValidationError("clusteringKitLot", "Clustering kit not specified"));
    }
    if (container.getMultiplexingKit() != null && container.getMultiplexingKit().getKitType() != KitType.MULTIPLEXING) {
        errors.add(new ValidationError("MultiplexingKitId", "Must be a multiplexing kit"));
    }
    if (container.getMultiplexingKitLot() != null && container.getMultiplexingKit() == null) {
        errors.add(new ValidationError("MultiplexingKitLot", "Multiplexing kit not specified"));
    }
    if (beforeChange != null && ValidationUtils.isSetAndChanged(SequencerPartitionContainer::getModel, container, beforeChange)) {
        SequencingContainerModel before = beforeChange.getModel();
        SequencingContainerModel after = container.getModel();
        if (after.getPlatformType() != before.getPlatformType()) {
            errors.add(new ValidationError("model.id", String.format("Can only be changed to a model of the same platform (%s)", before.getPlatformType().getKey())));
        } else if (after.getPartitionCount() != before.getPartitionCount()) {
            errors.add(new ValidationError("model.id", String.format("Can only be changed to a model with the same number of partitions (%d)", before.getPartitionCount())));
        }
        if (beforeChange.getRunPositions() != null) {
            Set<InstrumentModel> requiredInstrumentModels = beforeChange.getRunPositions().stream().map(RunPosition::getRun).map(Run::getSequencer).map(Instrument::getInstrumentModel).collect(Collectors.toSet());
            if (requiredInstrumentModels.stream().anyMatch(required -> after.getInstrumentModels().stream().map(InstrumentModel::getId).noneMatch(id -> id == required.getId()))) {
                errors.add(new ValidationError("model.id", String.format("Can only change to a model compatible with the linked runs' instrument models (%s)", LimsUtils.joinWithConjunction(requiredInstrumentModels.stream().map(InstrumentModel::getAlias).collect(Collectors.toSet()), "and"))));
            }
        }
    }
    if (!errors.isEmpty()) {
        throw new ValidationException(errors);
    }
}
Also used : SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) PoreVersion(uk.ac.bbsrc.tgac.miso.core.data.impl.PoreVersion) KitDescriptorService(uk.ac.bbsrc.tgac.miso.core.service.KitDescriptorService) Autowired(org.springframework.beans.factory.annotation.Autowired) SequencingContainerModelService(uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService) ArrayList(java.util.ArrayList) SequencerPartitionContainerStore(uk.ac.bbsrc.tgac.miso.persistence.SequencerPartitionContainerStore) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) KitType(uk.ac.bbsrc.tgac.miso.core.data.type.KitType) Service(org.springframework.stereotype.Service) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) LimsUtils(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils) SequencerPartitionContainerImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencerPartitionContainerImpl) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ValidationResult(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationResult) OxfordNanoporeContainer(uk.ac.bbsrc.tgac.miso.core.data.impl.OxfordNanoporeContainer) Collection(java.util.Collection) Set(java.util.Set) DeletionStore(uk.ac.bbsrc.tgac.miso.core.store.DeletionStore) IOException(java.io.IOException) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) AuthorizationException(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationException) Collectors(java.util.stream.Collectors) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) List(java.util.List) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) Transactional(org.springframework.transaction.annotation.Transactional) Pool(uk.ac.bbsrc.tgac.miso.core.data.Pool) BarcodableReferenceService(uk.ac.bbsrc.tgac.miso.core.service.BarcodableReferenceService) SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ArrayList(java.util.ArrayList) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)

Aggregations

Instrument (uk.ac.bbsrc.tgac.miso.core.data.Instrument)28 Test (org.junit.Test)14 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)12 InstrumentImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl)11 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)5 User (com.eaglegenomics.simlims.core.User)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 ServiceRecord (uk.ac.bbsrc.tgac.miso.core.data.ServiceRecord)4 NotFoundException (org.springframework.security.acls.model.NotFoundException)3 InstrumentModel (uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Date (java.util.Date)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2