Search in sources :

Example 6 with Library

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

the class BoxPageIT method testMoveItemWithinBox.

@Test
public void testMoveItemWithinBox() {
    final String initialPosition = "F10";
    final String finalPosition = "F12";
    Library lib = (Library) getSession().get(LibraryImpl.class, 505L);
    assertNotNull(lib);
    BoxableId libBoxableId = new BoxableId(lib.getEntityType(), lib.getId());
    // confirm positions pre-move
    Box initial = (Box) getSession().get(BoxImpl.class, 500L);
    BoxPosition itemAtInitialPosition = initial.getBoxPositions().get(initialPosition);
    assertNotNull(itemAtInitialPosition);
    assertNull(initial.getBoxPositions().get(finalPosition));
    assertEquals(libBoxableId, itemAtInitialPosition.getBoxableId());
    BoxPage page = getBoxPage(500L);
    BoxVisualization visualization = page.getVisualization();
    assertFalse("checking that library is in position F10", visualization.isEmptyPosition(initialPosition));
    assertTrue("checking which library is in position F10", visualization.getPositionTitle(initialPosition).contains(lib.getAlias()));
    assertTrue("checking that no tube is in position F12", visualization.isEmptyPosition(finalPosition));
    visualization.selectPosition(finalPosition);
    visualization.searchBoxables(lib.getIdentificationBarcode());
    visualization.updatePosition(false);
    // confirm positions post-move
    Box updated = (Box) getSession().get(BoxImpl.class, 500L);
    assertNull(updated.getBoxPositions().get(initialPosition));
    BoxPosition updatedAtFinalPosition = updated.getBoxPositions().get(finalPosition);
    assertNotNull(updatedAtFinalPosition);
    assertEquals(libBoxableId, updatedAtFinalPosition.getBoxableId());
    BoxPage afterSave = getBoxPage(500L);
    BoxVisualization afterVisualization = afterSave.getVisualization();
    assertTrue("checking that no tube is in position F10", afterVisualization.isEmptyPosition(initialPosition));
    assertFalse("checking that library is in position F12", afterVisualization.isEmptyPosition(finalPosition));
    assertTrue("checking which library is in position F12", afterVisualization.getPositionTitle(finalPosition).contains(lib.getAlias()));
}
Also used : BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId) BoxVisualization(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxVisualization) LibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl) BoxImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl) Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) BoxPosition(uk.ac.bbsrc.tgac.miso.core.data.BoxPosition) BoxPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxPage) Test(org.junit.Test)

Example 7 with Library

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

the class BoxPageIT method testAddMultipleTubes.

@Test
public void testAddMultipleTubes() {
    Library lib1 = (Library) getSession().get(LibraryImpl.class, 100001L);
    Library lib2 = (Library) getSession().get(LibraryImpl.class, 100002L);
    Library lib3 = (Library) getSession().get(LibraryImpl.class, 100003L);
    BoxPage page = getBoxPage(1L);
    BoxVisualization visualization = page.getVisualization();
    assertNull(lib1.getBox());
    assertNull(lib2.getBox());
    assertNull(lib3.getBox());
    assertTrue(visualization.isEmptyPosition("H10"));
    assertTrue(visualization.isEmptyPosition("H11"));
    assertTrue(visualization.isEmptyPosition("H12"));
    Map<String, String> updates = new HashMap<>();
    updates.put("H10", lib1.getName());
    updates.put("H11", lib2.getName());
    updates.put("H12", lib3.getName());
    visualization.updatePositions(updates, false);
    Box box = (Box) getSession().get(BoxImpl.class, 1L);
    assertTrue(visualization.getPositionTitle("H10").contains(lib1.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib1.getId()), box.getBoxPositions().get("H10").getBoxableId());
    assertTrue(visualization.getPositionTitle("H11").contains(lib2.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib2.getId()), box.getBoxPositions().get("H11").getBoxableId());
    assertTrue(visualization.getPositionTitle("H12").contains(lib3.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib3.getId()), box.getBoxPositions().get("H12").getBoxableId());
}
Also used : BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId) BoxVisualization(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxVisualization) HashMap(java.util.HashMap) LibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl) BoxImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl) Box(uk.ac.bbsrc.tgac.miso.core.data.Box) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) BoxPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxPage) Test(org.junit.Test)

Example 8 with Library

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

the class DefaultLibraryService method deleteNote.

@Override
public void deleteNote(Library library, Long noteId) throws IOException {
    if (noteId == null) {
        throw new IllegalArgumentException("Cannot delete an unsaved Note");
    }
    Library managed = libraryDao.get(library.getId());
    Note deleteNote = null;
    for (Note note : managed.getNotes()) {
        if (note.getId() == noteId.longValue()) {
            deleteNote = note;
            break;
        }
    }
    if (deleteNote == null) {
        throw new IOException("Note " + noteId + " not found for Library  " + library.getId());
    }
    authorizationManager.throwIfNonAdminOrMatchingOwner(deleteNote.getOwner());
    managed.getNotes().remove(deleteNote);
    libraryDao.save(managed);
}
Also used : Note(com.eaglegenomics.simlims.core.Note) 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) IOException(java.io.IOException)

Example 9 with Library

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

the class DefaultLibraryService method addNote.

@Override
public void addNote(Library library, Note note) throws IOException {
    Library managed = libraryDao.get(library.getId());
    note.setCreationDate(new Date());
    note.setOwner(authorizationManager.getCurrentUser());
    managed.addNote(note);
    save(managed, false);
}
Also used : 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) Date(java.util.Date)

Example 10 with Library

use of uk.ac.bbsrc.tgac.miso.core.data.Library 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)

Aggregations

Library (uk.ac.bbsrc.tgac.miso.core.data.Library)56 Test (org.junit.Test)23 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)20 DetailedLibrary (uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary)14 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)13 TransferLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary)13 LibraryAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot)11 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)10 Pool (uk.ac.bbsrc.tgac.miso.core.data.Pool)8 ArrayList (java.util.ArrayList)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 IOException (java.io.IOException)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)6 RunDto (uk.ac.bbsrc.tgac.miso.dto.run.RunDto)6 Collection (java.util.Collection)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 WorksetLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary)5 Date (java.util.Date)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)4