List of usage examples for org.apache.poi.xssf.usermodel XSSFCell getBooleanCellValue
@Override public boolean getBooleanCellValue()
From source file:org.finra.jtaf.core.utilities.ExcelFileParser.java
License:Apache License
public List<List<String>> parseExcelFile(boolean isXlsx) throws Exception { List<List<String>> parsedExcelFile = new ArrayList<List<String>>(); if (isXlsx) { for (int i = 0, numberOfRows = workBookSheetXlsx.getPhysicalNumberOfRows(); i < numberOfRows + 1; i++) { XSSFRow row = workBookSheetXlsx.getRow(i); if (row != null) { List<String> parsedExcelRow = new ArrayList<String>(); for (int j = 0, numberOfColumns = row.getLastCellNum(); j < numberOfColumns; j++) { XSSFCell cell = row.getCell(j); if (cell != null) { try { if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { parsedExcelRow.add(cell.getStringCellValue()); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_BLANK) { parsedExcelRow.add(""); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) { parsedExcelRow.add(String.valueOf(cell.getBooleanCellValue())); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) { parsedExcelRow.add(String.valueOf(cell.getNumericCellValue())); } else if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) { parsedExcelRow.add(""); } else { parsedExcelRow.add(cell.getStringCellValue()); }//from ww w . j a v a 2 s .c om } catch (Exception e) { logger.fatal("Oops! Can't read cell (row = " + i + ", column = " + j + ") in the excel file! Change cell format to 'Text', please!"); return null; } } else { parsedExcelRow.add(""); } } parsedExcelFile.add(parsedExcelRow); } } } else { for (int i = 0, numberOfRows = workBookSheetXls.getPhysicalNumberOfRows(); i < numberOfRows + 1; i++) { HSSFRow row = workBookSheetXls.getRow(i); if (row != null) { List<String> parsedExcelRow = new ArrayList<String>(); for (int j = 0, numberOfColumns = row.getLastCellNum(); j < numberOfColumns; j++) { HSSFCell cell = row.getCell(j); if (cell != null) { try { if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) { parsedExcelRow.add(cell.getStringCellValue()); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) { parsedExcelRow.add(""); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) { parsedExcelRow.add(String.valueOf(cell.getBooleanCellValue())); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { parsedExcelRow.add(String.valueOf(cell.getNumericCellValue())); } else if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) { parsedExcelRow.add(String.valueOf("")); } else { parsedExcelRow.add(cell.getStringCellValue()); } } catch (Exception e) { logger.fatal("Oops! Can't read cell (row = " + i + ", column = " + j + ") in the excel file! Change cell format to 'Text', please!"); return null; } } else { parsedExcelRow.add(""); } } parsedExcelFile.add(parsedExcelRow); } } } return parsedExcelFile; }
From source file:org.kuali.test.runner.output.PoiHelper.java
License:Educational Community License
private void copyCell(XSSFCell oldCell, XSSFCell newCell, Map<Integer, XSSFCellStyle> styleMap) { if (styleMap != null) { int stHashCode = oldCell.getCellStyle().hashCode(); XSSFCellStyle newCellStyle = styleMap.get(stHashCode); if (newCellStyle == null) { newCellStyle = newCell.getSheet().getWorkbook().createCellStyle(); newCellStyle.cloneStyleFrom(oldCell.getCellStyle()); newCellStyle.setFont(oldCell.getCellStyle().getFont()); styleMap.put(stHashCode, newCellStyle); }/* www . ja v a2 s . c o m*/ newCell.setCellStyle(newCellStyle); } switch (oldCell.getCellType()) { case XSSFCell.CELL_TYPE_STRING: newCell.setCellValue(oldCell.getStringCellValue()); break; case XSSFCell.CELL_TYPE_NUMERIC: newCell.setCellValue(oldCell.getNumericCellValue()); break; case XSSFCell.CELL_TYPE_BLANK: newCell.setCellType(HSSFCell.CELL_TYPE_BLANK); break; case XSSFCell.CELL_TYPE_BOOLEAN: newCell.setCellValue(oldCell.getBooleanCellValue()); break; case XSSFCell.CELL_TYPE_ERROR: newCell.setCellErrorValue(oldCell.getErrorCellValue()); break; case XSSFCell.CELL_TYPE_FORMULA: newCell.setCellFormula(oldCell.getCellFormula()); break; default: break; } }
From source file:org.talend.dataprep.qa.util.ExcelComparator.java
License:Open Source License
public static boolean compareTwoCells(XSSFCell cell1, XSSFCell cell2) { if ((cell1 == null) && (cell2 == null)) { return true; } else if ((cell1 == null) || (cell2 == null)) { return false; }//from w w w.j a v a2s . co m boolean equalCells = false; int type1 = cell1.getCellTypeEnum().getCode(); int type2 = cell2.getCellTypeEnum().getCode(); if (type1 == type2) { if (cell1.getCellStyle().equals(cell2.getCellStyle())) { // Compare cells based on its type switch (cell1.getCellTypeEnum().getCode()) { case HSSFCell.CELL_TYPE_FORMULA: if (cell1.getCellFormula().equals(cell2.getCellFormula())) { equalCells = true; } break; case HSSFCell.CELL_TYPE_NUMERIC: if (cell1.getNumericCellValue() == cell2.getNumericCellValue()) { equalCells = true; } break; case HSSFCell.CELL_TYPE_STRING: if (cell1.getStringCellValue().equals(cell2.getStringCellValue())) { equalCells = true; } break; case HSSFCell.CELL_TYPE_BLANK: if (cell2.getCellType() == HSSFCell.CELL_TYPE_BLANK) { equalCells = true; } break; case HSSFCell.CELL_TYPE_BOOLEAN: if (cell1.getBooleanCellValue() == cell2.getBooleanCellValue()) { equalCells = true; } break; case HSSFCell.CELL_TYPE_ERROR: if (cell1.getErrorCellValue() == cell2.getErrorCellValue()) { equalCells = true; } break; default: if (cell1.getStringCellValue().equals(cell2.getStringCellValue())) { equalCells = true; } break; } } else { return false; } } else { return false; } return equalCells; }
From source file:org.xframium.application.ExcelApplicationProvider.java
License:Open Source License
/** * Gets the cell value./*from ww w . ja v a 2 s. c om*/ * * @param cell the cell * @return the cell value */ private String getCellValue(XSSFCell cell) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf(cell.getBooleanCellValue()); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf(cell.getNumericCellValue()); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
From source file:org.xframium.device.data.ExcelDataProvider.java
License:Open Source License
/** * Gets the cell value.//from w w w . j a va 2 s . c om * * @param cell the cell * @return the cell value */ private String getCellValue(XSSFCell cell) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf(cell.getBooleanCellValue()); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf((int) cell.getNumericCellValue()); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); } } return null; }
From source file:org.xframium.page.keyWord.provider.ExcelKeyWordProvider.java
License:Open Source License
private String getCellValue(XSSFCell cell) { if (cell != null) { switch (cell.getCellType()) { case XSSFCell.CELL_TYPE_BLANK: return null; case XSSFCell.CELL_TYPE_BOOLEAN: return String.valueOf(cell.getBooleanCellValue()); case XSSFCell.CELL_TYPE_NUMERIC: return String.valueOf(cell.getNumericCellValue()); case XSSFCell.CELL_TYPE_STRING: return cell.getRichStringCellValue().toString(); }//from ww w . ja v a2 s . c om } return null; }
From source file:sv.com.mined.sieni.controller.GestionNotasController.java
public static void copyRow(XSSFSheet worksheetSource, XSSFSheet worksheetDestination, int sourceRowNum, int destinationRowNum) { // Get the source / new row XSSFRow origen = worksheetSource.getRow(sourceRowNum); XSSFRow destino = worksheetDestination.createRow(destinationRowNum); // Loop through source columns to add to new row for (int i = 0; i < origen.getLastCellNum(); i++) { // Grab a copy of the old/new cell XSSFCell oldCell = origen.getCell(i); XSSFCell newCell = destino.createCell(i); // If the old cell is null jump to next cell if (oldCell == null) { newCell = null;/*from www .j a va2 s. c om*/ continue; } //Ajustar tamaos columnas worksheetDestination.setColumnWidth(i, worksheetSource.getColumnWidth(i)); // Copy style from old cell and apply to new cell XSSFCellStyle newCellStyle = newCell.getSheet().getWorkbook().createCellStyle(); newCellStyle.cloneStyleFrom(oldCell.getCellStyle()); newCell.setCellStyle(newCellStyle); // If there is a cell comment, copy if (oldCell.getCellComment() != null) { newCell.setCellComment(oldCell.getCellComment()); } // If there is a cell hyperlink, copy if (oldCell.getHyperlink() != null) { newCell.setHyperlink(oldCell.getHyperlink()); } // Set the cell data type newCell.setCellType(oldCell.getCellType()); // Set the cell data value switch (oldCell.getCellType()) { case Cell.CELL_TYPE_BLANK: newCell.setCellValue(oldCell.getStringCellValue()); break; case Cell.CELL_TYPE_BOOLEAN: newCell.setCellValue(oldCell.getBooleanCellValue()); break; case Cell.CELL_TYPE_ERROR: newCell.setCellErrorValue(oldCell.getErrorCellValue()); break; case Cell.CELL_TYPE_FORMULA: newCell.setCellFormula(oldCell.getCellFormula()); break; case Cell.CELL_TYPE_NUMERIC: newCell.setCellValue(oldCell.getNumericCellValue()); break; case Cell.CELL_TYPE_STRING: newCell.setCellValue(oldCell.getRichStringCellValue()); break; } } }
From source file:tan.jam.jsf.Shifting.java
public static void InsertRow(XSSFWorkbook workbook, XSSFSheet worksheet, int sourceRowNum, int destinationRowNum) { worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1); XSSFRow newRow = worksheet.getRow(destinationRowNum); XSSFRow sourceRow = worksheet.getRow(sourceRowNum); if (newRow != null) { worksheet.shiftRows(destinationRowNum, worksheet.getLastRowNum(), 1); } else {/* w w w .j a v a 2 s. com*/ newRow = worksheet.createRow(destinationRowNum); } for (int i = 0; i < sourceRow.getLastCellNum(); i++) { // Grab a copy of the old/new cell XSSFCell oldCell = sourceRow.getCell(i); XSSFCell newCell = newRow.createCell(i); if (oldCell == null) { newCell = null; continue; } XSSFCellStyle newCellStyle = workbook.createCellStyle(); newCellStyle.cloneStyleFrom(oldCell.getCellStyle()); ; newCell.setCellStyle(newCellStyle); if (oldCell.getCellComment() != null) { newCell.setCellComment(oldCell.getCellComment()); } if (oldCell.getHyperlink() != null) { newCell.setHyperlink(oldCell.getHyperlink()); } newCell.setCellType(oldCell.getCellType()); switch (oldCell.getCellType()) { case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK: newCell.setCellValue(oldCell.getStringCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN: newCell.setCellValue(oldCell.getBooleanCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR: newCell.setCellErrorValue(oldCell.getErrorCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA: newCell.setCellFormula("+" + "F" + destinationRowNum + "*G" + destinationRowNum); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC: //newCell.setCellValue(oldCell.getNumericCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING: newCell.setCellValue(""); break; } } for (int i = 0; i < worksheet.getNumMergedRegions(); i++) { CellRangeAddress cellRangeAddress = worksheet.getMergedRegion(i); if (cellRangeAddress.getFirstRow() == sourceRow.getRowNum()) { CellRangeAddress newCellRangeAddress = new CellRangeAddress(newRow.getRowNum(), (newRow.getRowNum() + (cellRangeAddress.getLastRow() - cellRangeAddress.getFirstRow())), cellRangeAddress.getFirstColumn(), cellRangeAddress.getLastColumn()); worksheet.addMergedRegion(newCellRangeAddress); } } int inc = destinationRowNum + 1; worksheet.getRow(destinationRowNum).getCell(7).setCellFormula("+F" + inc + "*G" + inc); }
From source file:tan.jam.jsf.Shifting.java
private static void CopyData(XSSFWorkbook workbook, XSSFSheet worksheet, int sourceRowNum, int destinationRowNum, int Mov) { XSSFRow newRow = worksheet.getRow(destinationRowNum); XSSFRow sourceRow = worksheet.getRow(sourceRowNum); for (int i = sourceRow.getLastCellNum(); i > 8 + Mov; i--) { int d = i - 1; XSSFCell oldCell = sourceRow.getCell(d); XSSFCell newCell = newRow.createCell(i); if (oldCell == null) { newCell = null;/*from w w w.j a v a2 s . c om*/ continue; } XSSFCellStyle newCellStyle = workbook.createCellStyle(); newCellStyle.cloneStyleFrom(oldCell.getCellStyle()); ; newCell.setCellStyle(newCellStyle); if (oldCell.getCellComment() != null) { newCell.setCellComment(oldCell.getCellComment()); } if (oldCell.getHyperlink() != null) { newCell.setHyperlink(oldCell.getHyperlink()); } newCell.setCellType(oldCell.getCellType()); switch (oldCell.getCellType()) { case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BLANK: newCell.setCellValue(oldCell.getStringCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN: newCell.setCellValue(oldCell.getBooleanCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR: newCell.setCellErrorValue(oldCell.getErrorCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_FORMULA: newCell.setCellFormula(oldCell.getCellFormula()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_NUMERIC: newCell.setCellValue(oldCell.getNumericCellValue()); break; case org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING: newCell.setCellValue(oldCell.getRichStringCellValue()); break; } } }
From source file:uk.ac.bbsrc.tgac.miso.core.util.FormUtils.java
License:Open Source License
private static Map<String, PlatePool> process384PlateInputXLSX(XSSFWorkbook wb, User u, RequestManager manager, MisoNamingScheme<Library> libraryNamingScheme) throws Exception { ((RequestManagerAwareNamingScheme) libraryNamingScheme).setRequestManager(manager); List<Sample> samples = new ArrayList<Sample>(); XSSFSheet sheet = wb.getSheetAt(0);/*from w w w . j a v a 2 s . co m*/ int rows = sheet.getPhysicalNumberOfRows(); XSSFRow glrow = sheet.getRow(1); //process global headers XSSFCell pairedCell = glrow.getCell(0); boolean paired = pairedCell.getBooleanCellValue(); log.info("Got paired: " + paired); XSSFCell platformCell = glrow.getCell(1); PlatformType pt = null; if (getCellValueAsString(platformCell) != null) { pt = PlatformType.get(getCellValueAsString(platformCell)); } if (pt == null) { throw new InputFormException( "Cannot resolve Platform type from: '" + getCellValueAsString(platformCell) + "'"); } else { log.info("Got platform type: " + pt.getKey()); } XSSFCell typeCell = glrow.getCell(2); LibraryType lt = null; if (getCellValueAsString(typeCell) != null) { String[] split = getCellValueAsString(typeCell).split("-"); String plat = split[0]; String type = split[1]; if (getCellValueAsString(platformCell).equals(plat)) { lt = manager.getLibraryTypeByDescriptionAndPlatform(type, pt); } else { throw new InputFormException("Selected library type '" + getCellValueAsString(typeCell) + "' doesn't match platform type: '" + getCellValueAsString(platformCell) + "'"); } } if (lt == null) { throw new InputFormException( "Cannot resolve Library type from: '" + getCellValueAsString(typeCell) + "'"); } else { log.info("Got library type: " + lt.getDescription()); } XSSFCell selectionCell = glrow.getCell(3); LibrarySelectionType ls = null; if (getCellValueAsString(selectionCell) != null) { ls = manager.getLibrarySelectionTypeByName(getCellValueAsString(selectionCell)); } if (ls == null) { throw new InputFormException( "Cannot resolve Library Selection type from: '" + getCellValueAsString(selectionCell) + "'"); } else { log.info("Got library selection type: " + ls.getName()); } XSSFCell strategyCell = glrow.getCell(4); LibraryStrategyType lst = null; if (getCellValueAsString(strategyCell) != null) { lst = manager.getLibraryStrategyTypeByName(getCellValueAsString(strategyCell)); } if (lst == null) { throw new InputFormException( "Cannot resolve Library Strategy type from: '" + getCellValueAsString(strategyCell) + "'"); } else { log.info("Got library strategy type: " + lst.getName()); } XSSFCell plateBarcodeCell = glrow.getCell(5); String plateBarcode = null; if (getCellValueAsString(plateBarcodeCell) != null) { plateBarcode = getCellValueAsString(plateBarcodeCell); } if (plateBarcode == null) { throw new InputFormException( "Cannot resolve plate barcode from: '" + getCellValueAsString(plateBarcodeCell) + "'"); } else { log.info("Got plate barcode: " + plateBarcode); } //process entries Simple384WellPlate libraryPlate = null; //Map<String, Pool<Plate<LinkedList<Library>, Library>>> pools = new HashMap<String, Pool<Plate<LinkedList<Library>, Library>>>(); Map<String, PlatePool> pools = new HashMap<String, PlatePool>(); for (int ri = 4; ri < rows; ri++) { XSSFRow row = sheet.getRow(ri); // Ax - plate position XSSFCell platePosCell = row.getCell(0); String platePos = getCellValueAsString(platePosCell); if (platePos != null && libraryPlate == null) { //plated libraries - process as plate libraryPlate = new Simple384WellPlate(); libraryPlate.setIdentificationBarcode(plateBarcode); libraryPlate.setCreationDate(new Date()); } //cell defs XSSFCell sampleAliasCell = row.getCell(2); Sample s = null; if (getCellValueAsString(sampleAliasCell) != null) { String salias = getCellValueAsString(sampleAliasCell); Collection<Sample> ss = manager.listSamplesByAlias(salias); if (!ss.isEmpty()) { if (ss.size() == 1) { s = ss.iterator().next(); log.info("Got sample: " + s.getAlias()); } else { throw new InputFormException( "Multiple samples retrieved with this alias: '" + salias + "'. Cannot process."); } } else { throw new InputFormException("No such sample '" + salias + "'in database. Samples need to be created before using the form input functionality"); } } else { log.info("Blank sample row found. Ending import."); break; } //sample OK - good to go if (s != null) { XSSFCell entityIDCell = row.getCell(2); XSSFCell poolNumberCell = row.getCell(3); XSSFCell sampleQcCell = row.getCell(4); //XSSFCell sampleAmountCell = row.getCell(5); //XSSFCell sampleWaterAmountCell = row.getCell(6); XSSFCell libraryDescriptionCell = row.getCell(7); XSSFCell barcodeKitCell = row.getCell(8); XSSFCell barcodeTagsCell = row.getCell(9); XSSFCell libraryQcCell = row.getCell(10); XSSFCell libraryQcInsertSizeCell = row.getCell(11); XSSFCell libraryQcMolarityCell = row.getCell(12); XSSFCell libraryQcPassFailCell = row.getCell(13); //XSSFCell libraryAmountCell = row.getCell(14); //XSSFCell libraryWaterAmountCell = row.getCell(15); //XSSFCell dilutionQcCell = row.getCell(16); XSSFCell dilutionMolarityCell = row.getCell(17); //XSSFCell dilutionAmountCell = row.getCell(18); //XSSFCell dilutionWaterAmountCell = row.getCell(19); XSSFCell poolQcCell = row.getCell(20); //XSSFCell poolAverageInsertSizeCell = row.getCell(21); XSSFCell poolConvertedMolarityCell = row.getCell(22); //add pool, if any if (getCellValueAsString(poolNumberCell) != null) { String poolNum = getCellValueAsString(poolNumberCell); if (!pools.containsKey(poolNum)) { PlatePool pool = new PlatePool(); pool.setAlias(poolNum); pool.setPlatformType(pt); pool.setReadyToRun(true); pool.setCreationDate(new Date()); pools.put(poolNum, pool); log.info("Added pool: " + poolNum); manager.savePool(pool); } } //process sample QC if (getCellValueAsString(sampleQcCell) != null) { try { SampleQC sqc = new SampleQCImpl(); sqc.setSample(s); sqc.setResults(Double.valueOf(getCellValueAsString(sampleQcCell))); sqc.setQcCreator(u.getLoginName()); sqc.setQcDate(new Date()); if (manager.getSampleQcTypeByName("Picogreen") != null) { sqc.setQcType(manager.getSampleQcTypeByName("Picogreen")); } else { sqc.setQcType(manager.getSampleQcTypeByName("QuBit")); } if (!s.getSampleQCs().contains(sqc)) { s.addQc(sqc); manager.saveSampleQC(sqc); manager.saveSample(s); log.info("Added sample QC: " + sqc.toString()); } } catch (NumberFormatException nfe) { throw new InputFormException("Supplied Sample QC concentration for sample '" + getCellValueAsString(sampleAliasCell) + "' is invalid", nfe); } } //if (getCellValueAsString(libraryQcCell) != null) { if (getCellValueAsString(barcodeKitCell) != null && getCellValueAsString(barcodeTagsCell) != null) { //create library Library library = new LibraryImpl(); library.setSample(s); Matcher mat = samplePattern.matcher(s.getAlias()); if (mat.matches()) { String libAlias = plateBarcode + "_" + "L" + mat.group(2) + "-" + platePos + "_" + getCellValueAsString(entityIDCell); //String libAlias = libraryNamingScheme.generateNameFor("alias", library); //library.setAlias(libAlias); library.setAlias(libAlias); library.setSecurityProfile(s.getSecurityProfile()); library.setDescription(s.getDescription()); library.setCreationDate(new Date()); library.setPlatformName(pt.name()); library.setLibraryType(lt); library.setLibrarySelectionType(ls); library.setLibraryStrategyType(lst); library.setPaired(paired); if (getCellValueAsString(libraryQcMolarityCell) != null) { int insertSize = 0; try { String bp = getCellValueAsString(libraryQcInsertSizeCell); Matcher m = digitPattern.matcher(bp); if (m.matches()) { insertSize = Integer.valueOf(m.group(1)); } else { throw new InputFormException("Supplied Library insert size for library '" + libAlias + "' (" + s.getAlias() + ") is invalid"); } } catch (NumberFormatException nfe) { throw new InputFormException("Supplied Library insert size for library '" + libAlias + "' (" + s.getAlias() + ") is invalid", nfe); } try { LibraryQC lqc = new LibraryQCImpl(); lqc.setLibrary(library); lqc.setInsertSize(insertSize); lqc.setResults(Double.valueOf(getCellValueAsString(libraryQcMolarityCell))); lqc.setQcCreator(u.getLoginName()); lqc.setQcDate(new Date()); lqc.setQcType(manager.getLibraryQcTypeByName("Bioanalyzer")); if (!library.getLibraryQCs().contains(lqc)) { library.addQc(lqc); manager.saveLibraryQC(lqc); log.info("Added library QC: " + lqc.toString()); } if (insertSize == 0 && lqc.getResults() == 0) { library.setQcPassed(false); } else { //TODO check libraryQcPassFailCell? library.setQcPassed(true); } } catch (NumberFormatException nfe) { throw new InputFormException("Supplied Library QC concentration for library '" + libAlias + "' (" + s.getAlias() + ") is invalid", nfe); } } if (getCellValueAsString(barcodeKitCell) != null) { Collection<TagBarcode> bcs = manager .listAllTagBarcodesByStrategyName(getCellValueAsString(barcodeKitCell)); if (!bcs.isEmpty()) { String tags = getCellValueAsString(barcodeTagsCell); if (!"".equals(tags)) { HashMap<Integer, TagBarcode> tbs = new HashMap<Integer, TagBarcode>(); if (tags.contains("-")) { String[] splits = tags.split("-"); int count = 1; for (String tag : splits) { for (TagBarcode tb : bcs) { if (tb.getName().equals(tag)) { //set tag barcodes tbs.put(count, tb); count++; } } } } else { for (TagBarcode tb : bcs) { if (tb.getName().equals(tags) || tb.getSequence().equals(tags)) { //set tag barcode tbs.put(1, tb); log.info("Got tag barcode: " + tb.getName()); break; } } } library.setTagBarcodes(tbs); } else { throw new InputFormException( "Barcode Kit specified but no tag barcodes entered for: '" + s.getAlias() + "'."); } } else { throw new InputFormException("No tag barcodes associated with the kit definition '" + getCellValueAsString(barcodeKitCell) + "' for sample: '" + s.getAlias() + "'."); } } /* if (getCellValueAsString(dilutionMolarityCell) != null) { try { LibraryDilution ldi = new LibraryDilution(); ldi.setLibrary(library); ldi.setSecurityProfile(library.getSecurityProfile()); ldi.setConcentration(Double.valueOf(getCellValueAsString(dilutionMolarityCell))); ldi.setCreationDate(new Date()); ldi.setDilutionCreator(u.getLoginName()); if (!library.getLibraryDilutions().contains(ldi)) { library.addDilution(ldi); log.info("Added library dilution: " + ldi.toString()); } if (getCellValueAsString(poolNumberCell) != null) { String poolNum = String.valueOf(new Double(getCellValueAsString(poolNumberCell)).intValue()); Pool<Plate<LinkedList<Library>, Library>> p = pools.get(poolNum); if (p != null) { p.addPoolableElement(ldi); log.info("Added library dilution to pool: " + p.toString()); } } } catch (NumberFormatException nfe) { throw new InputFormException("Supplied LibraryDilution concentration for library '"+libAlias+"' ("+s.getAlias()+") is invalid", nfe); } } */ if (getCellValueAsString(poolConvertedMolarityCell) != null) { String poolNum = getCellValueAsString(poolNumberCell); Pool<Plate<LinkedList<Library>, Library>> p = pools.get(poolNum); if (p != null) { log.debug("Retrieved pool " + poolNum); try { p.setConcentration( Double.valueOf(getCellValueAsString(poolConvertedMolarityCell))); } catch (NumberFormatException nfe) { throw new InputFormException( "Supplied pool concentration for pool '" + poolNum + "' is invalid", nfe); } } } log.info("Added library: " + library.toString()); manager.saveLibrary(library); if (getCellValueAsString(platePosCell) != null && libraryPlate != null) { //libraryPlate.setElement(getCellValueAsString(platePosCell), library); libraryPlate.addElement(library); log.info("Added library " + library.getAlias() + " to " + getCellValueAsString(platePosCell)); } samples.add(s); Pool<Plate<LinkedList<Library>, Library>> p = pools .get(getCellValueAsString(poolNumberCell)); if (p != null && !p.getPoolableElements().contains(libraryPlate)) { p.addPoolableElement(libraryPlate); log.info("Added plate to pool: " + p.toString()); } } else { log.error( "Cannot generate library alias from specified parent sample alias. Does it match the required schema?"); } } } } log.info("Done"); return pools; }