public JSONObject plateElementsDataTable(HttpSession session, JSONObject json) { if (json.has("plateId")) { try { JSONObject j = new JSONObject(); JSONArray jsonArray = new JSONArray(); long plateId = json.getLong("plateId"); Plate<? extends List<? extends Plateable>, ? extends Plateable> plate = requestManager.getPlateById(plateId); if (plate != null) { for (Plateable p : plate.getElements()) { if (p instanceof Library) { Library l = (Library) p; String strategyName = "No barcode"; StringBuilder seqbuilder = new StringBuilder(); if (!l.getTagBarcodes().isEmpty()) { int count = 1; Collection<TagBarcode> barcodes = l.getTagBarcodes().values(); for (TagBarcode tb : barcodes) { strategyName = tb.getStrategyName(); seqbuilder.append(tb.getSequence()); if (l.getTagBarcodes().values().size() > 1 && count < l.getTagBarcodes().values().size()) { seqbuilder.append("-"); } count++; } } else { log.info("No tag barcodes!"); } jsonArray.add( "['" + l.getName() + "','" + l.getAlias() + "','" + strategyName + "','" + seqbuilder.toString() + "','" + "<a href=\"/miso/library/" + l.getId() + "\"><span class=\"ui-icon ui-icon-pencil\"></span></a>" + "']"); } } } j.put("elementsArray", jsonArray); return j; } catch (IOException e) { log.debug("Failed", e); return JSONUtils.SimpleJSONError("Failed: " + e.getMessage()); } } else { return JSONUtils.SimpleJSONError("No plates to show"); } }
@Test public void testLibraries() { try { // get row count of experiments in the dataset int expected = getDataSet().getTable("Library").getRowCount(); // get number of experiments from the DAO int actual = getLibraryDAO().count(); // test data contains 2 experiments, check size of returned list TestCase.assertEquals("Wrong number of Library", expected, actual); System.out.println("Expected number of Library: " + expected + ", actual: " + actual); for (Library d : random(getLibraryDAO(), actual, 5)) { TestCase.assertNotNull(d); TestCase.assertNotNull(d.getId()); } } catch (Exception e) { e.printStackTrace(); TestCase.fail(); } }