Search in sources :

Example 1 with BoxableId

use of uk.ac.bbsrc.tgac.miso.core.data.BoxableId 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 2 with BoxableId

use of uk.ac.bbsrc.tgac.miso.core.data.BoxableId 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 3 with BoxableId

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

the class BoxPageIT method rearrangeMultipleTubes.

@Test
public void rearrangeMultipleTubes() {
    Sample sam1 = (Sample) getSession().get(SampleImpl.class, 4L);
    Sample sam2 = (Sample) getSession().get(SampleImpl.class, 7L);
    Sample sam3 = (Sample) getSession().get(SampleImpl.class, 8L);
    BoxPage page = getBoxPage(1L);
    BoxVisualization visualization = page.getVisualization();
    assertTrue(visualization.getPositionTitle("F06").contains(sam1.getAlias()));
    assertTrue(visualization.getPositionTitle("G07").contains(sam2.getAlias()));
    assertTrue(visualization.getPositionTitle("H08").contains(sam3.getAlias()));
    Map<String, String> updates = new HashMap<>();
    updates.put("G07", sam1.getIdentificationBarcode());
    updates.put("H08", sam2.getIdentificationBarcode());
    updates.put("F06", sam3.getIdentificationBarcode());
    visualization.updatePositions(updates, true);
    Box box = (Box) getSession().get(BoxImpl.class, 1L);
    assertTrue(visualization.getPositionTitle("G07").contains(sam1.getAlias()));
    assertEquals(new BoxableId(EntityType.SAMPLE, sam1.getId()), box.getBoxPositions().get("G07").getBoxableId());
    assertTrue(visualization.getPositionTitle("H08").contains(sam2.getAlias()));
    assertEquals(new BoxableId(EntityType.SAMPLE, sam2.getId()), box.getBoxPositions().get("H08").getBoxableId());
    assertTrue(visualization.getPositionTitle("F06").contains(sam3.getAlias()));
    assertEquals(new BoxableId(EntityType.SAMPLE, sam3.getId()), box.getBoxPositions().get("F06").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) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) BoxImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl) Box(uk.ac.bbsrc.tgac.miso.core.data.Box) BoxPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxPage) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Example 4 with BoxableId

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

the class BoxPageIT method replaceMultipleTubes.

@Test
public void replaceMultipleTubes() {
    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());
    assertFalse(visualization.isEmptyPosition("F06"));
    assertFalse(visualization.isEmptyPosition("G07"));
    assertFalse(visualization.isEmptyPosition("H08"));
    Map<String, String> updates = new HashMap<>();
    updates.put("F06", lib1.getName());
    updates.put("G07", lib2.getName());
    updates.put("H08", lib3.getName());
    visualization.updatePositions(updates, true);
    Box box = (Box) getSession().get(BoxImpl.class, 1L);
    assertTrue(visualization.getPositionTitle("F06").contains(lib1.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib1.getId()), box.getBoxPositions().get("F06").getBoxableId());
    assertTrue(visualization.getPositionTitle("G07").contains(lib2.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib2.getId()), box.getBoxPositions().get("G07").getBoxableId());
    assertTrue(visualization.getPositionTitle("H08").contains(lib3.getAlias()));
    assertEquals(new BoxableId(EntityType.LIBRARY, lib3.getId()), box.getBoxPositions().get("H08").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 5 with BoxableId

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

the class BoxRestController method recreateBoxFromPrefix.

@PostMapping("/{boxId}/positions/fill-by-pattern")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void recreateBoxFromPrefix(@PathVariable long boxId, @RequestParam(name = "prefix", required = true) String prefix, @RequestParam(name = "suffix", required = true) String suffix) throws IOException {
    Box box = getBox(boxId);
    if (!SUFFIXES.containsKey(suffix)) {
        throw new RestException("Invalid suffix", Status.BAD_REQUEST);
    }
    BiFunction<Integer, Integer, String> suffixGenerator = SUFFIXES.get(suffix).apply(box.getSize());
    Map<String, String> positionToBarcode = new HashMap<>();
    for (int row = 0; row < box.getSize().getRows(); row++) {
        for (int column = 0; column < box.getSize().getColumns(); column++) {
            positionToBarcode.put(BoxUtils.getPositionString(row, column), prefix + suffixGenerator.apply(row, column));
        }
    }
    Map<String, BoxableView> barcodesToBoxables = boxService.getViewsFromBarcodeList(positionToBarcode.values()).stream().collect(Collectors.toMap(BoxableView::getIdentificationBarcode, Function.identity()));
    box.setBoxPositions(positionToBarcode.entrySet().stream().filter(entry -> barcodesToBoxables.containsKey(entry.getValue())).collect(Collectors.toMap(Map.Entry::getKey, entry -> {
        BoxableView boxable = barcodesToBoxables.get(entry.getValue());
        BoxableId id = new BoxableId(boxable.getEntityType(), boxable.getId());
        return new BoxPosition(box, entry.getKey(), id);
    })));
    boxService.save(box);
}
Also used : HashMap(java.util.HashMap) Box(uk.ac.bbsrc.tgac.miso.core.data.Box) BoxableView(uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView) BoxableId(uk.ac.bbsrc.tgac.miso.core.data.BoxableId) Entry(java.util.Map.Entry) BoxPosition(uk.ac.bbsrc.tgac.miso.core.data.BoxPosition) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

BoxableId (uk.ac.bbsrc.tgac.miso.core.data.BoxableId)18 Box (uk.ac.bbsrc.tgac.miso.core.data.Box)13 Test (org.junit.Test)11 BoxPosition (uk.ac.bbsrc.tgac.miso.core.data.BoxPosition)9 BoxableView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.BoxableView)7 HashMap (java.util.HashMap)6 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)6 BoxImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl)5 Boxable (uk.ac.bbsrc.tgac.miso.core.data.Boxable)4 BoxPage (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxPage)4 BoxVisualization (uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.BoxVisualization)4 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)3 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)3 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)3 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)3 SampleBoxableView (uk.ac.bbsrc.tgac.miso.core.data.impl.view.box.SampleBoxableView)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 ValidationError (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)2 Functions (com.google.common.base.Functions)1