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);
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations