return JSONUtils.SimpleJSONError("Please enter a value for '" +k+ "'");
}
}
if (json.has("pcrId") && !json.get("pcrId").equals("")) {
Long pcrId = Long.parseLong(json.getString("pcrId"));
emPCR pcr = requestManager.getEmPcrById(pcrId);
emPCRDilution newDilution = dataObjectFactory.getEmPCRDilution();
newDilution.setSecurityProfile(pcr.getSecurityProfile());
newDilution.setDilutionCreator(json.getString("pcrDilutionCreator"));
newDilution.setCreationDate(new SimpleDateFormat("dd/MM/yyyy").parse(json.getString("pcrDilutionDate")));
newDilution.setConcentration(Double.parseDouble(json.getString("results")));
newDilution.setEmPCR(pcr);
requestManager.saveEmPCRDilution(newDilution);
StringBuilder sb = new StringBuilder();
sb.append("<tr>");
//sb.append("<th>ID</th><th>Done By</th><th>Date</th><th>Barcode</th><th>Results</th>");
sb.append("<th>ID</th><th>Done By</th><th>Date</th><th>Results</th><th>ID Barcode</th>");
sb.append("</tr>");
File temploc = new File(session.getServletContext().getRealPath("/")+"temp/");
for (emPCRDilution dil : requestManager.listAllEmPcrDilutionsByEmPcrId(pcrId)) {
sb.append("<tr>");
sb.append("<td>"+dil.getId()+"</td>");
sb.append("<td>"+dil.getDilutionCreator()+"</td>");
sb.append("<td>"+dil.getCreationDate()+"</td>");
sb.append("<td>"+dil.getConcentration()+" "+ dil.getUnits()+"</td>");
sb.append("<td>");
try {
barcodeFactory.setPointPixels(1.5f);
barcodeFactory.setBitmapResolution(600);
RenderedImage bi = barcodeFactory.generateSquareDataMatrix(dil, 400);
if (bi != null) {
File tempimage = misoFileManager.generateTemporaryFile("barcode-", ".png", temploc);
if (ImageIO.write(bi, "png", tempimage)) {
sb.append("<img style='border:0;' src='/temp/"+tempimage.getName()+"'/>");
}
}
}
catch (IOException e) {
e.printStackTrace();
}
sb.append("</td>");
//sb.append("<td><a href='/miso/pool/"+pcr.getLibraryDilution().getLibrary().getPlatformName().toLowerCase()+"/new/'>Construct New Pool</a></td>");
sb.append("<td><a href='/miso/poolwizard/new/"+pcr.getLibraryDilution().getLibrary().getSample().getProject().getProjectId()+"'>Construct New Pool</a></td>");
sb.append("</tr>");
}
return JSONUtils.SimpleJSONResponse(sb.toString());
}
}