List of usage examples for java.text NumberFormat setGroupingUsed
public void setGroupingUsed(boolean newValue)
From source file:org.glom.app.libglom.Document.java
private String getStringForDecimal(final double value) { final NumberFormat format = NumberFormat.getInstance(Locale.US); format.setGroupingUsed(false); // TODO: Does this change it system-wide? return format.format(value); }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
private String getFolio(Empresa empresa) { Query query = currentSession().createQuery( "select f from FolioActivo f where f.nombre = :nombre and f.organizacion.id = :organizacionId"); query.setString("nombre", "ACTIVOS"); query.setLong("organizacionId", empresa.getOrganizacion().getId()); query.setLockOptions(LockOptions.UPGRADE); FolioActivo folio = (FolioActivo) query.uniqueResult(); if (folio == null) { folio = new FolioActivo("ACTIVOS"); folio.setOrganizacion(empresa.getOrganizacion()); currentSession().save(folio);//from w w w.j av a 2 s. c om return getFolio(empresa); } folio.setValor(folio.getValor() + 1); java.text.NumberFormat nf = java.text.DecimalFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(7); nf.setMaximumIntegerDigits(7); nf.setMaximumFractionDigits(0); StringBuilder sb = new StringBuilder(); sb.append("A-"); sb.append(empresa.getOrganizacion().getCodigo()); sb.append(empresa.getCodigo()); sb.append(nf.format(folio.getValor())); return sb.toString(); }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override//from w w w . ja va2 s . co m public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java
private void saveSecurity(Security security, Document document, Element root) { Element element = document.createElement("security"); //$NON-NLS-1$ element.setAttribute("id", String.valueOf(security.getId())); //$NON-NLS-1$ root.appendChild(element);//from w ww .j ava2s. com Element node = document.createElement("code"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getCode())); element.appendChild(node); node = document.createElement("description"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getDescription())); element.appendChild(node); if (security.getCurrency() != null) { node = document.createElement("currency"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getCurrency().getCurrencyCode())); element.appendChild(node); } NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMinimumIntegerDigits(2); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); Element collectorNode = document.createElement("dataCollector"); //$NON-NLS-1$ collectorNode.setAttribute("enable", String.valueOf(security.isEnableDataCollector())); //$NON-NLS-1$ element.appendChild(collectorNode); node = document.createElement("begin"); //$NON-NLS-1$ node.appendChild(document.createTextNode( nf.format(security.getBeginTime() / 60) + ":" + nf.format(security.getBeginTime() % 60))); //$NON-NLS-1$ collectorNode.appendChild(node); node = document.createElement("end"); //$NON-NLS-1$ node.appendChild(document.createTextNode( nf.format(security.getEndTime() / 60) + ":" + nf.format(security.getEndTime() % 60))); //$NON-NLS-1$ collectorNode.appendChild(node); node = document.createElement("weekdays"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getWeekDays()))); collectorNode.appendChild(node); node = document.createElement("keepdays"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getKeepDays()))); collectorNode.appendChild(node); if (security.getQuoteFeed() != null || security.getLevel2Feed() != null || security.getHistoryFeed() != null) { Node feedsNode = document.createElement("feeds"); //$NON-NLS-1$ element.appendChild(feedsNode); if (security.getQuoteFeed() != null) { node = document.createElement("quote"); //$NON-NLS-1$ node.setAttribute("id", security.getQuoteFeed().getId()); //$NON-NLS-1$ if (security.getQuoteFeed().getExchange() != null) node.setAttribute("exchange", security.getQuoteFeed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getQuoteFeed().getSymbol())); feedsNode.appendChild(node); } if (security.getLevel2Feed() != null) { node = document.createElement("level2"); //$NON-NLS-1$ node.setAttribute("id", security.getLevel2Feed().getId()); //$NON-NLS-1$ if (security.getLevel2Feed().getExchange() != null) node.setAttribute("exchange", security.getLevel2Feed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getLevel2Feed().getSymbol())); feedsNode.appendChild(node); } if (security.getHistoryFeed() != null) { node = document.createElement("history"); //$NON-NLS-1$ node.setAttribute("id", security.getHistoryFeed().getId()); //$NON-NLS-1$ if (security.getHistoryFeed().getExchange() != null) node.setAttribute("exchange", security.getHistoryFeed().getExchange()); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getHistoryFeed().getSymbol())); feedsNode.appendChild(node); } } if (security.getTradeSource() != null) { TradeSource source = security.getTradeSource(); Element feedsNode = document.createElement("tradeSource"); //$NON-NLS-1$ feedsNode.setAttribute("id", source.getTradingProviderId()); //$NON-NLS-1$ if (source.getExchange() != null) feedsNode.setAttribute("exchange", source.getExchange()); //$NON-NLS-1$ element.appendChild(feedsNode); if (!source.getSymbol().equals("")) //$NON-NLS-1$ { node = document.createElement("symbol"); //$NON-NLS-1$ node.appendChild(document.createTextNode(source.getSymbol())); feedsNode.appendChild(node); } if (source.getAccountId() != null) { node = document.createElement("account"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(source.getAccountId()))); feedsNode.appendChild(node); } node = document.createElement("quantity"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(source.getQuantity()))); feedsNode.appendChild(node); } if (security.getQuote() != null) { Quote quote = security.getQuote(); Node quoteNode = document.createElement("quote"); //$NON-NLS-1$ if (quote.getDate() != null) { node = document.createElement("date"); //$NON-NLS-1$ node.appendChild(document.createTextNode(dateTimeFormat.format(quote.getDate()))); quoteNode.appendChild(node); } node = document.createElement("last"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getLast()))); quoteNode.appendChild(node); node = document.createElement("bid"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getBid()))); quoteNode.appendChild(node); node = document.createElement("ask"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getAsk()))); quoteNode.appendChild(node); node = document.createElement("bidSize"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getBidSize()))); quoteNode.appendChild(node); node = document.createElement("askSize"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getAskSize()))); quoteNode.appendChild(node); node = document.createElement("volume"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(quote.getVolume()))); quoteNode.appendChild(node); element.appendChild(quoteNode); } Node dataNode = document.createElement("data"); //$NON-NLS-1$ element.appendChild(dataNode); if (security.getOpen() != null) { node = document.createElement("open"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getOpen()))); dataNode.appendChild(node); } if (security.getHigh() != null) { node = document.createElement("high"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getHigh()))); dataNode.appendChild(node); } if (security.getLow() != null) { node = document.createElement("low"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getLow()))); dataNode.appendChild(node); } if (security.getClose() != null) { node = document.createElement("close"); //$NON-NLS-1$ node.appendChild(document.createTextNode(String.valueOf(security.getClose()))); dataNode.appendChild(node); } node = document.createElement("comment"); //$NON-NLS-1$ node.appendChild(document.createTextNode(security.getComment())); element.appendChild(node); for (Iterator iter = security.getSplits().iterator(); iter.hasNext();) { Split split = (Split) iter.next(); node = document.createElement("split"); //$NON-NLS-1$ node.setAttribute("date", dateTimeFormat.format(split.getDate())); //$NON-NLS-1$ node.setAttribute("fromQuantity", String.valueOf(split.getFromQuantity())); //$NON-NLS-1$ node.setAttribute("toQuantity", String.valueOf(split.getToQuantity())); //$NON-NLS-1$ element.appendChild(node); } for (Iterator iter = security.getDividends().iterator(); iter.hasNext();) { Dividend dividend = (Dividend) iter.next(); node = document.createElement("dividend"); //$NON-NLS-1$ node.setAttribute("date", dateTimeFormat.format(dividend.getDate())); //$NON-NLS-1$ node.setAttribute("value", String.valueOf(dividend.getValue())); //$NON-NLS-1$ element.appendChild(node); } }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
@Override @SuppressWarnings("unchecked") public void sube(byte[] datos, Usuario usuario, OutputStream out, Integer codigoInicial) { Date inicio = new Date(); int idx = 5;/* w ww .j av a2s .c om*/ int i = 0; SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yy"); SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yy"); MathContext mc = new MathContext(16, RoundingMode.HALF_UP); NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMaximumFractionDigits(0); nf.setMinimumIntegerDigits(5); Transaction tx = null; try { String ejercicioId = "001-2012"; Map<String, CentroCosto> centrosDeCosto = new HashMap<>(); Map<String, TipoActivo> tipos = new HashMap<>(); Query tipoActivoQuery = currentSession() .createQuery("select ta from TipoActivo ta " + "where ta.empresa.id = :empresaId " + "and ta.cuenta.id.ejercicio.id.idEjercicio = :ejercicioId " + "and ta.cuenta.id.ejercicio.id.organizacion.id = :organizacionId"); log.debug("empresaId: {}", usuario.getEmpresa().getId()); log.debug("ejercicioId: {}", ejercicioId); log.debug("organizacionId: {}", usuario.getEmpresa().getOrganizacion().getId()); tipoActivoQuery.setLong("empresaId", usuario.getEmpresa().getId()); tipoActivoQuery.setString("ejercicioId", ejercicioId); tipoActivoQuery.setLong("organizacionId", usuario.getEmpresa().getOrganizacion().getId()); List<TipoActivo> listaTipos = tipoActivoQuery.list(); for (TipoActivo tipoActivo : listaTipos) { tipos.put(tipoActivo.getCuenta().getId().getIdCtaMayor(), tipoActivo); } log.debug("TIPOS: {}", tipos); Query proveedorQuery = currentSession().createQuery( "select p from Proveedor p where p.empresa.id = :empresaId and p.nombre = :nombreEmpresa"); proveedorQuery.setLong("empresaId", usuario.getEmpresa().getId()); proveedorQuery.setString("nombreEmpresa", usuario.getEmpresa().getNombre()); Proveedor proveedor = (Proveedor) proveedorQuery.uniqueResult(); Query codigoDuplicadoQuery = currentSession() .createQuery("select a from Activo a where a.empresa.id = :empresaId and a.codigo = :codigo"); XSSFWorkbook workbook = new XSSFWorkbook(new ByteArrayInputStream(datos)); FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet ccostoFantasma = wb.createSheet("CCOSTO-FANTASMAS"); int ccostoFantasmaRow = 0; XSSFSheet sinCCosto = wb.createSheet("SIN-CCOSTO"); int sinCCostoRow = 0; XSSFSheet codigoAsignado = wb.createSheet("CODIGO-ASIGNADO"); int codigoAsignadoRow = 0; XSSFSheet fechaInvalida = wb.createSheet("FECHA-INVALIDA"); int fechaInvalidaRow = 0; XSSFSheet sinCosto = wb.createSheet("SIN-COSTO"); int sinCostoRow = 0; tx = currentSession().beginTransaction(); for (idx = 0; idx <= 5; idx++) { XSSFSheet sheet = workbook.getSheetAt(idx); int rows = sheet.getPhysicalNumberOfRows(); for (i = 2; i < rows; i++) { log.debug("Leyendo pagina {} renglon {}", idx, i); XSSFRow row = sheet.getRow(i); if (row.getCell(0) == null) { break; } String nombreGrupo = row.getCell(0).getStringCellValue().trim(); TipoActivo tipoActivo = tipos.get(nombreGrupo); if (tipoActivo != null) { String cuentaCCosto = row.getCell(2).toString().trim(); if (StringUtils.isNotBlank(cuentaCCosto)) { CentroCosto centroCosto = centrosDeCosto.get(cuentaCCosto); if (centroCosto == null) { Query ccostoQuery = currentSession().createQuery("select cc from CentroCosto cc " + "where cc.id.ejercicio.id.idEjercicio = :ejercicioId " + "and cc.id.ejercicio.id.organizacion.id = :organizacionId " + "and cc.id.idCosto like :idCosto"); ccostoQuery.setString("ejercicioId", ejercicioId); ccostoQuery.setLong("organizacionId", usuario.getEmpresa().getOrganizacion().getId()); ccostoQuery.setString("idCosto", "1.01." + cuentaCCosto); ccostoQuery.setMaxResults(1); List<CentroCosto> listaCCosto = ccostoQuery.list(); if (listaCCosto != null && listaCCosto.size() > 0) { centroCosto = listaCCosto.get(0); } if (centroCosto == null) { XSSFRow renglon = ccostoFantasma.createRow(ccostoFantasmaRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(row.getCell(8).toString()); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); continue; } centrosDeCosto.put(cuentaCCosto, centroCosto); } String poliza = null; switch (row.getCell(4).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: poliza = row.getCell(4).toString(); poliza = StringUtils.removeEnd(poliza, ".0"); log.debug("POLIZA-N: {}", poliza); break; case XSSFCell.CELL_TYPE_STRING: poliza = row.getCell(4).getStringCellValue().trim(); log.debug("POLIZA-S: {}", poliza); break; } Boolean seguro = false; if (row.getCell(5) != null && StringUtils.isNotBlank(row.getCell(5).toString())) { seguro = true; } Boolean garantia = false; if (row.getCell(6) != null && StringUtils.isNotBlank(row.getCell(6).toString())) { garantia = true; } Date fechaCompra = null; if (row.getCell(7) != null) { log.debug("VALIDANDO FECHA"); XSSFCell cell = row.getCell(7); switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: log.debug("ES NUMERIC"); if (DateUtil.isCellDateFormatted(cell)) { log.debug("ES FECHA"); fechaCompra = cell.getDateCellValue(); } else if (DateUtil.isCellInternalDateFormatted(cell)) { log.debug("ES FECHA INTERNAL"); fechaCompra = cell.getDateCellValue(); } else { BigDecimal bd = new BigDecimal(cell.getNumericCellValue()); bd = stripTrailingZeros(bd); log.debug("CONVIRTIENDO DOUBLE {} - {}", DateUtil.isValidExcelDate(bd.doubleValue()), bd); fechaCompra = HSSFDateUtil.getJavaDate(bd.longValue(), true); log.debug("Cal: {}", fechaCompra); } break; case Cell.CELL_TYPE_FORMULA: log.debug("ES FORMULA"); CellValue cellValue = evaluator.evaluate(cell); switch (cellValue.getCellType()) { case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { fechaCompra = DateUtil.getJavaDate(cellValue.getNumberValue(), true); } } } } if (row.getCell(7) != null && fechaCompra == null) { String fechaCompraString; if (row.getCell(7).getCellType() == Cell.CELL_TYPE_STRING) { fechaCompraString = row.getCell(7).getStringCellValue(); } else { fechaCompraString = row.getCell(7).toString().trim(); } try { fechaCompra = sdf.parse(fechaCompraString); } catch (ParseException e) { try { fechaCompra = sdf2.parse(fechaCompraString); } catch (ParseException e2) { try { fechaCompra = sdf3.parse(fechaCompraString); } catch (ParseException e3) { // no se pudo convertir } } } } if (fechaCompra == null) { XSSFRow renglon = fechaInvalida.createRow(fechaInvalidaRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(row.getCell(8).toString()); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); continue; } String codigo = null; switch (row.getCell(8).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: codigo = row.getCell(8).toString(); break; case XSSFCell.CELL_TYPE_STRING: codigo = row.getCell(8).getStringCellValue().trim(); break; } if (StringUtils.isBlank(codigo)) { codigo = nf.format(codigoInicial); XSSFRow renglon = codigoAsignado.createRow(codigoAsignadoRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(codigoInicial); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); codigoInicial++; } else { // busca codigo duplicado if (codigo.contains(".")) { codigo = codigo.substring(0, codigo.lastIndexOf(".")); log.debug("CODIGO: {}", codigo); } codigoDuplicadoQuery.setLong("empresaId", usuario.getEmpresa().getId()); codigoDuplicadoQuery.setString("codigo", codigo); Activo activo = (Activo) codigoDuplicadoQuery.uniqueResult(); if (activo != null) { XSSFRow renglon = codigoAsignado.createRow(codigoAsignadoRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(codigo + "-" + nf.format(codigoInicial)); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); codigo = nf.format(codigoInicial); codigoInicial++; } } String descripcion = null; if (row.getCell(9) != null) { switch (row.getCell(9).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: descripcion = row.getCell(9).toString(); descripcion = StringUtils.removeEnd(descripcion, ".0"); break; case XSSFCell.CELL_TYPE_STRING: descripcion = row.getCell(9).getStringCellValue().trim(); break; default: descripcion = row.getCell(9).toString().trim(); } } String marca = null; if (row.getCell(10) != null) { switch (row.getCell(10).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: marca = row.getCell(10).toString(); marca = StringUtils.removeEnd(marca, ".0"); break; case XSSFCell.CELL_TYPE_STRING: marca = row.getCell(10).getStringCellValue().trim(); break; default: marca = row.getCell(10).toString().trim(); } } String modelo = null; if (row.getCell(11) != null) { switch (row.getCell(11).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: modelo = row.getCell(11).toString(); modelo = StringUtils.removeEnd(modelo, ".0"); break; case XSSFCell.CELL_TYPE_STRING: modelo = row.getCell(11).getStringCellValue().trim(); break; default: modelo = row.getCell(11).toString().trim(); } } String serie = null; if (row.getCell(12) != null) { switch (row.getCell(12).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: serie = row.getCell(12).toString(); serie = StringUtils.removeEnd(serie, ".0"); break; case XSSFCell.CELL_TYPE_STRING: serie = row.getCell(12).getStringCellValue().trim(); break; default: serie = row.getCell(12).toString().trim(); } } String responsable = null; if (row.getCell(13) != null) { switch (row.getCell(13).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: responsable = row.getCell(13).toString(); responsable = StringUtils.removeEnd(responsable, ".0"); break; case XSSFCell.CELL_TYPE_STRING: responsable = row.getCell(13).getStringCellValue().trim(); break; default: responsable = row.getCell(13).toString().trim(); } } String ubicacion = null; if (row.getCell(14) != null) { switch (row.getCell(14).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: ubicacion = row.getCell(14).toString(); ubicacion = StringUtils.removeEnd(ubicacion, ".0"); break; case XSSFCell.CELL_TYPE_STRING: ubicacion = row.getCell(14).getStringCellValue().trim(); break; default: ubicacion = row.getCell(14).toString().trim(); } } BigDecimal costo = null; switch (row.getCell(15).getCellType()) { case XSSFCell.CELL_TYPE_NUMERIC: costo = new BigDecimal(row.getCell(15).getNumericCellValue(), mc); log.debug("COSTO-N: {} - {}", costo, row.getCell(15).getNumericCellValue()); break; case XSSFCell.CELL_TYPE_STRING: costo = new BigDecimal(row.getCell(15).toString(), mc); log.debug("COSTO-S: {} - {}", costo, row.getCell(15).toString()); break; case XSSFCell.CELL_TYPE_FORMULA: costo = new BigDecimal( evaluator.evaluateInCell(row.getCell(15)).getNumericCellValue(), mc); log.debug("COSTO-F: {}", costo); } if (costo == null) { XSSFRow renglon = sinCosto.createRow(sinCostoRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(row.getCell(8).toString()); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); continue; } Activo activo = new Activo(fechaCompra, seguro, garantia, poliza, codigo, descripcion, marca, modelo, serie, responsable, ubicacion, costo, tipoActivo, centroCosto, proveedor, usuario.getEmpresa()); this.crea(activo, usuario); } else { XSSFRow renglon = sinCCosto.createRow(sinCCostoRow++); renglon.createCell(0).setCellValue(sheet.getSheetName() + ":" + (i + 1)); renglon.createCell(1).setCellValue(row.getCell(0).toString()); renglon.createCell(2).setCellValue(row.getCell(1).toString()); renglon.createCell(3).setCellValue(row.getCell(2).toString()); renglon.createCell(4).setCellValue(row.getCell(3).toString()); renglon.createCell(5).setCellValue(row.getCell(4).toString()); renglon.createCell(6).setCellValue(row.getCell(5).toString()); renglon.createCell(7).setCellValue(row.getCell(6).toString()); renglon.createCell(8).setCellValue(row.getCell(7).toString()); renglon.createCell(9).setCellValue(row.getCell(8).toString()); renglon.createCell(10).setCellValue(row.getCell(9).toString()); renglon.createCell(11).setCellValue(row.getCell(10).toString()); renglon.createCell(12).setCellValue(row.getCell(11).toString()); renglon.createCell(13).setCellValue(row.getCell(12).toString()); renglon.createCell(14).setCellValue(row.getCell(13).toString()); renglon.createCell(15).setCellValue(row.getCell(14).toString()); renglon.createCell(16).setCellValue(row.getCell(15).toString()); continue; } } else { throw new RuntimeException( "(" + idx + ":" + i + ") No se encontro el tipo de activo " + nombreGrupo); } } } tx.commit(); log.debug("################################################"); log.debug("################################################"); log.debug("TERMINO EN {} MINS", (new Date().getTime() - inicio.getTime()) / (1000 * 60)); log.debug("################################################"); log.debug("################################################"); wb.write(out); } catch (IOException | RuntimeException e) { if (tx != null && tx.isActive()) { tx.rollback(); } log.error("Hubo problemas al intentar pasar datos de archivo excel a BD (" + idx + ":" + i + ")", e); throw new RuntimeException( "Hubo problemas al intentar pasar datos de archivo excel a BD (" + idx + ":" + i + ")", e); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemAMin_actionPerformed(ActionEvent event) { try {// w ww . j av a 2s .c o m NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); nf.setGroupingUsed(false); String answer = nf.format(_minAreaCutoff); String newAnswer = JOptionPane.showInputDialog("New value for min AUC cutoff:", answer); if (newAnswer == null) return; float newCutoff = Float.parseFloat(newAnswer); if (newCutoff > 0.0f) { for (MRMTransition mrt : _mrmTransitions) { for (MRMDaughter curd : mrt.getDaughters().values()) { if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getAUC() < newCutoff) { ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false), curd.getElutionDataTableRow(), peaksData.Accept.colno); } } } } _minAreaCutoff = newCutoff; } catch (Exception e) { ApplicationContext.infoMessage("Failed to change min acceptable AUC: " + e); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
public void menuItemPMin_actionPerformed(ActionEvent event) { try {// w w w. ja v a2 s .co m NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); nf.setGroupingUsed(false); String answer = nf.format(_minPeakCutoff); String newAnswer = JOptionPane.showInputDialog("New value for min peak cutoff:", answer); if (newAnswer == null) return; float newCutoff = Float.parseFloat(newAnswer); if (newCutoff > 0.0f) { for (MRMTransition mrt : _mrmTransitions) { for (MRMDaughter curd : mrt.getDaughters().values()) { if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getHighestPointY() < newCutoff) { ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false), curd.getElutionDataTableRow(), peaksData.Accept.colno); } } } } _minPeakCutoff = newCutoff; } catch (Exception e) { ApplicationContext.infoMessage("Failed to change min acceptable peak height: " + e); } }
From source file:com.aol.framework.helper.report.CustomizedReporter.java
synchronized private void generateTestExecutionStatus(boolean emailable, List<ISuite> suites, PrintWriter f_out) {/* w w w . j a va 2 s . c o m*/ String testName = ""; int totalPassedMethods = 0; int totalFailedMethods = 0; int totalSkippedMethods = 0; int totalSkippedConfigurationMethods = 0; int totalFailedConfigurationMethods = 0; int totalAutomationErrors = 0; int totalMethods = 0; int suite_totalPassedMethods = 0; int suite_totalFailedMethods = 0; int suite_totalSkippedMethods = 0; int suite_totalAutomationErrors = 0; String suite_passPercentage = ""; String suiteName = ""; ITestContext overview = null; HashMap<String, String> dashboardReportMap = new HashMap<String, String>(); String dashboardAppGroup = ""; for (ISuite suite : suites) { suiteName = suite.getName(); TestHelper.logger.info(">> " + suiteName + " <<"); Map<String, ISuiteResult> tests = suite.getResults(); NumberFormat nf = NumberFormat.getInstance(); for (ISuiteResult r : tests.values()) { overview = r.getTestContext(); testName = overview.getName(); totalPassedMethods = overview.getPassedTests().getAllMethods().size(); totalFailedMethods = overview.getFailedTests().getAllMethods().size(); totalAutomationErrors = overview.getFailedButWithinSuccessPercentageTests().getAllMethods().size(); totalSkippedMethods = overview.getSkippedTests().getAllMethods().size(); totalFailedConfigurationMethods = overview.getFailedConfigurations().getAllMethods().size(); // this should be 0 as redirected to automation error // totalMethods = overview.getAllTestMethods().length; totalMethods = totalPassedMethods + totalFailedMethods; nf.setMaximumFractionDigits(2); nf.setGroupingUsed(true); String includedModule = ""; String includedGroup = ""; ITestNGMethod[] allTestMethods = overview.getAllTestMethods(); for (ITestNGMethod testngMethod : allTestMethods) { String[] modules = testngMethod.getGroups(); for (String module : modules) { for (String moduleName : TestHelper.MODULES) { if (module.equalsIgnoreCase(moduleName)) { if (!(includedModule.contains(module))) { includedModule = includedModule + " " + module; } } } for (String groupName : TestHelper.TEST_GROUPS) { if (module.equalsIgnoreCase(groupName)) { if (!(includedGroup.contains(module))) { includedGroup = includedGroup + " " + module; } } } } } String[] nodeInfo = getNodeInfo(overview, testName); String browser = nodeInfo[1]; String browser_version = nodeInfo[2]; String platform = nodeInfo[0]; //String nodeIp = nodeInfo[3]; if (platform == null || platform.trim().length() == 0) { platform = "N/A"; } if (browser_version == null || browser_version.trim().length() == 0) { browser_version = "N/A"; } if (browser == null || browser.trim().length() == 0) { browser = "N/A"; } if (!(dashboardReportMap.containsKey(includedModule))) { if (browser_version.equalsIgnoreCase("N/A")) { browser_version = ""; } dashboardReportMap.put(includedModule, "os1~" + platform + "|browser1~" + browser + browser_version + "|testcase_count_1~" + totalMethods + "|pass_count_1~" + totalPassedMethods + "|fail_count_1~" + totalFailedMethods + "|skip_count_1~" + totalSkippedMethods + "|skip_conf_count_1~" + totalSkippedConfigurationMethods + "|fail_conf_count_1~" + totalFailedConfigurationMethods + "|fail_automation_count_1~" + totalAutomationErrors); } else { for (String key : dashboardReportMap.keySet()) { if (key.equalsIgnoreCase(includedModule)) { if (browser_version.equalsIgnoreCase("N/A")) { browser_version = ""; } String value = dashboardReportMap.get(key); int index = StringUtils.countMatches(value, "#") + 1; index += 1; value = value + "#" + "os" + index + "~" + platform + "|browser" + index + "~" + browser + browser_version + "|testcase_count_" + index + "~" + totalMethods + "|pass_count_" + index + "~" + totalPassedMethods + "|fail_count_" + index + "~" + totalFailedMethods + "|skip_count_" + index + "~" + totalSkippedMethods + "|skip_conf_count_" + index + "~" + totalSkippedConfigurationMethods + "|fail_conf_count_" + index + "~" + totalFailedConfigurationMethods + "|fail_automation_count_~" + totalAutomationErrors; dashboardReportMap.put(key, value); } } } dashboardAppGroup = includedGroup; suite_totalPassedMethods += totalPassedMethods; suite_totalFailedMethods += totalFailedMethods; suite_totalAutomationErrors += totalAutomationErrors; suite_totalSkippedMethods += totalSkippedMethods; suite_passPercentage = getPercentage(nf, suite_totalPassedMethods, suite_totalPassedMethods + suite_totalFailedMethods); } } if (!doneOutputToConsole) { //**************************** report to console as status ****************** int suite_totalTestedMethods = suite_totalPassedMethods + suite_totalFailedMethods; System.out.println("[TOTAL_METHODS]: " + (suite_totalTestedMethods)); System.out.println("[PASSED_METHODS]: " + suite_totalPassedMethods); if (suite_totalFailedMethods > 0 || suite_totalPassedMethods == 0) System.out.println("[FAILED_METHODS]: " + suite_totalFailedMethods); if (suite_totalAutomationErrors > 0) System.out.println("[AUTOMATION_ERRORS]: " + suite_totalAutomationErrors); if (suite_totalSkippedMethods > 0) System.out.println("[SKIPPED_METHODS]: " + suite_totalSkippedMethods); System.out.println("[PASSED%]: " + suite_passPercentage); TestHelper.setReportProperties(suite_totalTestedMethods, suite_totalPassedMethods, suite_totalFailedMethods, suite_totalSkippedMethods, suite_passPercentage, suite_totalAutomationErrors); //******************************************************************************** } StringBuilder dashboardResults = new StringBuilder(); if (!emailable) { dashboardResults.append( "<table id=\"myTable\" width=\"100%\" cellspacing=0 cellpadding=0 class=\"tablesorter\">"); } else { dashboardResults.append("<table " + classParam + " cellspacing=\"0\" cellpadding=\"0\" width=\"91%\">"); } dashboardResults // .append("<thead><tr> <th>Test Name</th><th>" .append("<thead><tr> <th>Module Name</th><th>" + " # Unique TestCases</th><th>" + " # Combinations</th><th>" + " # Passed</th><th>" + " # Failed</th><th>" + " # Warning</th><th>" + " # Skipped</th><th>" + "# Total</th><th>" + "Success Rate</th> </tr> </thead> <tbody>"); int total_browser_combinations = 0; int total_unique_testcases = 0; for (String key : dashboardReportMap.keySet()) { String fileName = key.trim() + "-Overall" + "-customized-report.html"; if (!emailable) { try { generateModuleOverallTestReport(testName, key, suites, fileName); } catch (Exception e) { e.printStackTrace(); } } String value = dashboardReportMap.get(key); String[] values = value.split("#"); int testcase_count = 0; //******************************************* int pass_count = 0; int fail_count = 0; int fail_automation_count = 0; int skip_count = 0; int skip_conf_count = 0; int fail_conf_count = 0; String appKey = "TEST_APP"; String appName = TestHelper.getTestConfig(appKey); if (dashboardAppGroup.contains("Smoke") && !appName.equalsIgnoreCase("webmail")) { appName = appName + "_" + "Smoke"; } else if (dashboardAppGroup.contains("Regression")) { appName = appName + "_" + "Regression"; } String dashboardModule = key; // // if (dashboardModule.contains("Compose")) // { // dashboardModule = dashboardModule.replace("Compose", "ComposeMail"); // } else if (dashboardModule.contains("Read")) // { // dashboardModule = dashboardModule.replace("Read", "ReadMail"); // } // int countMatches = StringUtils.countMatches(value, "#") + 1; for (String val : values) { String[] tokens = val.split("\\|"); for (String token : tokens) { if (token.contains("testcase_count")) { testcase_count = testcase_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("pass_count")) { pass_count = pass_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("fail_count")) { fail_count = fail_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("fail_automation_count")) { fail_automation_count = fail_automation_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("skip_count")) { skip_count = skip_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("skip_conf_count")) { skip_conf_count = skip_conf_count + Integer.parseInt(token.split("~")[1]); } if (token.contains("fail_conf_count")) { fail_conf_count = fail_conf_count + Integer.parseInt(token.split("~")[1]); } } testcase_count -= skip_count + skip_conf_count + fail_conf_count; } NumberFormat nformat = NumberFormat.getInstance(); nformat.setMaximumFractionDigits(2); nformat.setGroupingUsed(true); String passPercent = getPercentage(nformat, pass_count, pass_count + fail_count); String finalStr = "["; String[] val = dashboardReportMap.get(key).split("#"); int unique_testcase = 0; int limit = val.length - 1; for (int i = 0; i < val.length; i++) {//TODO - unique_testcase is the max num cases among tests, not the total for the module across tests - Steven String testCaseCount = (val[i].split("\\|")[2]).split("~")[1]; int next = Integer.parseInt(testCaseCount); if (next > unique_testcase) { unique_testcase = next; } finalStr = finalStr + testCaseCount + " T * 1 B]"; if (i != limit) { finalStr += " + ["; } } //unique_testcase = String finalString = ""; // if ((unique_testcase * values.length) != (pass_count + fail_count + skip_count)) // { // finalString = "<a href=\"#\" title=\"" + finalStr + "\">" + (pass_count + fail_count + skip_count) // + "</a>"; // // } else { finalString = String.valueOf((pass_count + fail_count + fail_automation_count + skip_count)); } String passCount = ""; String failCount = ""; String automationErrorCount = ""; String skipCount = ""; if (pass_count > 0) { passCount = "<td bgcolor=\"" + passColor + "\"><font color=\"white\"><b>" + pass_count + "</b></font></td>"; } else { passCount = "<td>" + pass_count + "</td>"; } if (fail_count > 0) { failCount = "<td bgcolor=\"" + failColor + "\"><font color=\"white\"><b>" + fail_count + "</b></font></td>"; } else { failCount = "<td>" + fail_count + "</td>"; } if (fail_automation_count > 0) { automationErrorCount = "<td bgcolor=\"" + warnColor + "\"><font color=\"white\"><b>" + fail_automation_count + "</b></font></td>"; } else { automationErrorCount = "<td>" + fail_automation_count + "</td>"; } if (skip_count > 0) { skipCount = "<td bgcolor=\"" + skipColor + "\"><font color=\"white\"><b>" + skip_count + "</b></font></td>"; } else { skipCount = "<td>" + skip_count + "</td>"; } if (!emailable || !disableCss) { dashboardResults.append("<tr><td><b><a href='" + TestHelper.jenkinsBuildUrl + TestHelper.jenkinsCustomReportTitle + TestHelper.customReportDirLink + fileName + "'>" + dashboardModule + "</b></td><td>" // + testName + "</b></td><td>" + unique_testcase + "</td><td>" + values.length + "</td>" + passCount + failCount + automationErrorCount + skipCount + "<td>" + finalString + "</td><td><font color=\"" + passPercentageColor + "\"><b>" + passPercent + " %" + "</b></font></td></tr>"); } else { dashboardResults.append("<tr><td><b>" + dashboardModule + "</b></td><td>" //+ testName + "</b></td><td>" + unique_testcase + "</td><td>" + values.length + "</td><td>" + pass_count + "</td><td>" + fail_count + "</td><td>" + fail_automation_count + "</td><td>" + skip_count + "</td><td>" + finalString + "</td><td><b>" + passPercent + " %" + "</td></tr>"); } if (total_browser_combinations < values.length) { total_browser_combinations = values.length; } total_unique_testcases += unique_testcase; } dashboardResults.append("</tbody></table>"); if (!emailable || !disableCss) { String suite_pass = ""; String suite_fail = ""; String suite_automation_error = ""; String suite_skip = ""; if (suite_totalPassedMethods > 0) { suite_pass = "<td bgcolor=\"" + passColor + "\"><font color=\"white\"><b>" + suite_totalPassedMethods + "</b></font></td>"; } else { suite_pass = "<td>" + suite_totalPassedMethods + "</td>"; } if (suite_totalFailedMethods > 0) { suite_fail = "<td bgcolor=\"" + failColor + "\"><font color=\"white\"><b>" + suite_totalFailedMethods + "</b></font></td>"; } else { suite_fail = "<td>" + suite_totalFailedMethods + "</td>"; } if (suite_totalAutomationErrors > 0) { suite_automation_error = "<td bgcolor=\"" + warnColor + "\"><font color=\"white\"><b>" + suite_totalAutomationErrors + "</b></font></td>"; } else { suite_automation_error = "<td>" + suite_totalAutomationErrors + "</td>"; } if (suite_totalSkippedMethods > 0) { suite_skip = "<td bgcolor=\"" + skipColor + "\"><font color=\"white\"><b>" + suite_totalSkippedMethods + "</b></font></td>"; } else { suite_skip = "<td>" + suite_totalSkippedMethods + "</td>"; } // Summary Table f_out.println("<p><b>Overall Execution Summary</b></p>"); if (!emailable) { f_out.println("<table class=\"tablesorter\" width=\"100%\">"); } else { f_out.println("<table " + classParam + " cellspacing=\"0\" cellpadding=\"0\" width=\"91%\">"); } f_out.println(//"<table class=\"param\" width=\"100%\">"+ "<thead><tr><th>Test Suite Name</th><th>" + "# Unique TestCases</th><th>" + "# Combinations</th> <th>" + "# Passed</th> <th>" + "# Failed</th> <th>" + "# Warning</th> <th>" + "# Skipped</th><th>" + "# Total</th> <th>" + "Success Rate</th> </tr> </thead>" + " <tbody> <tr><td><b>" + suiteName + "</b></td><td>" + total_unique_testcases + "</td><td>" + total_browser_combinations + "</td>" + suite_pass + suite_fail + suite_automation_error + suite_skip + "<td>" + (suite_totalPassedMethods + suite_totalFailedMethods + suite_totalSkippedMethods + suite_totalAutomationErrors) + "</td><td><font color=\"" + passPercentageColor + "\"><b>" + suite_passPercentage + " %" + "</b></font></td></tr></tbody></table>"); } else { f_out.println("<b><font color=\"" + titleColor + "\">Overall Execution Summary</font></b><br/><br/>"); f_out.println("<table " + classParam + " cellspacing=\"0\" cellpadding=\"0\" width=\"91%\">" + "<thead><tr><th>Test Suite Name</th><th>" + "# Unique TestCases</th><th>" + "# Combinations</th> <th>" + "# Passed</th> <th>" + "# Failed</th> <th>" + "# Warning</th> <th>" + "# Skipped</th><th>" + "# Total</th> <th>" + "Success Rate</th> </tr> </thead>" + " <tbody> <tr><td><b>" + suiteName + "</b></td><td>" + total_unique_testcases + "</td><td>" + total_browser_combinations + "</td><td>" + suite_totalPassedMethods + "</td><td>" + suite_totalFailedMethods + "</td><td>" + suite_totalAutomationErrors + "</td><td>" + suite_totalSkippedMethods + "</td><td>" + (suite_totalPassedMethods + suite_totalFailedMethods + suite_totalSkippedMethods + suite_totalAutomationErrors) + "</td><td>" + suite_passPercentage + " %" + "</td></tr></tbody></table>"); } f_out.flush(); f_out.println("<br/>"); f_out.println("<p><b>Modulewise Execution Summary</b></p>"); f_out.println(dashboardResults); // if(!emailable){ // f_out.println("<br/><h4>Legend:</h4>"); // f_out.print("<ul>"); // f_out.println("<li>T: Unique Testcase</li>"); // f_out.println("<li>B: Unique Browser Combination</li>"); // f_out.print("</ul>"); // }else{ f_out.println("<br/><br/><br/><br/>"); // } f_out.flush(); }
From source file:com.brick.sms.email.MailTest.java
public void sendAllSupplierGrantPriceExpireeList() throws MessagingException { try {/* w w w .j a v a2s. c o m*/ Map tempMap = new HashMap(); List<Map<String, Object>> supplierGrantPriceExpireeList = null; supplierGrantPriceExpireeList = (List<Map<String, Object>>) DataAccessor .query("applyCompanyManage.getSupplierGrantPriceExpire", tempMap, DataAccessor.RS_TYPE.LIST); //?????Mail if (supplierGrantPriceExpireeList == null || supplierGrantPriceExpireeList.size() == 0) { return; } NumberFormat nfFSNum = new DecimalFormat("#,###,###,##0.00"); nfFSNum.setGroupingUsed(true); nfFSNum.setMaximumFractionDigits(2); StringBuffer mailContent = new StringBuffer(); mailContent.append("<html><head></head>"); mailContent.append("<body>"); mailContent.append("<font size='3'><b>??:<b><br></font>" + "<font size='2'>???List?~</font><br><br>"); mailContent.append( "<table cellspacing='1' width='1050px;' cellpadding='2' style=\"background-color: black;\">" + "<tr>" + "<th style=\"background-color: #FFFFFF; width:30px;\">??</th>" + "<th style=\"background-color: #FFFFFF; width:100px;\">()</th>" + "<th align='center' style=\"background-color: #FFFF99\">?</th>" + "<th align='center' style=\"background-color: #FFFF99\">??</th>" + "<th align='center' style=\"background-color: #FFFF99\">??</th>" + "<th align='center' style=\"background-color: #99CCFF\"></th>" + "<th align='center' style=\"background-color: #99CCFF\">?</th>" + "<th align='center' style=\"background-color: #99CCFF\">?</th>" + "<th align='center' style=\"background-color: #33CCCC\">?</th>" + "<th align='center' style=\"background-color: #33CCCC\">??</th>" + "<th align='center' style=\"background-color: #33CCCC\">??</th>" + "<th align='center' style=\"background-color: #8080C0\">?</th>" + "<th align='center' style=\"background-color: #8080C0\">??</th>" + "<th align='center' style=\"background-color: #8080C0\">??</th>" + "</tr>"); for (int i = 0; i < supplierGrantPriceExpireeList.size(); i++) { tempMap = (Map) supplierGrantPriceExpireeList.get(i); mailContent.append("<tr>" + "<td style=\"background-color: #FFFFFF\">" + (i + 1) + "</td>" + "<td style=\"background-color: #FFFFFF\">" + supplierGrantPriceExpireeList.get(i).get("NAME") + "(" + supplierGrantPriceExpireeList.get(i).get("SUPP_LEVEL") + ")" + "</td>" + "<td style=\"background-color: #FFFF99\">" + supplierGrantPriceExpireeList.get(i).get("LIEN_START_DATE") + "</td>" + "<td style=\"background-color: #FFFF99\">" + supplierGrantPriceExpireeList.get(i).get("LIEN_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #FFFF99\">" + updateMoney( DataUtil.doubleUtil(supplierGrantPriceExpireeList.get(i).get("LIEN_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #99CCFF\">" + supplierGrantPriceExpireeList.get(i).get("REPURCH_START_DATE") + "</td>" + "<td style=\"background-color: #99CCFF\">" + supplierGrantPriceExpireeList.get(i).get("REPURCH_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #99CCFF\">" + updateMoney(DataUtil.doubleUtil( supplierGrantPriceExpireeList.get(i).get("REPURCH_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #33CCCC\">" + supplierGrantPriceExpireeList.get(i).get("ADVANCE_START_DATE") + "</td>" + "<td style=\"background-color: #33CCCC\">" + supplierGrantPriceExpireeList.get(i).get("ADVANCE_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #33CCCC\">" + updateMoney( DataUtil.doubleUtil( supplierGrantPriceExpireeList.get(i).get("ADVANCEMACHINE_GRANT_PRICE")), nfFSNum) + "</td>" + "<td style=\"background-color: #8080C0\">" + supplierGrantPriceExpireeList.get(i).get("VOICE_START_DATE") + "</td>" + "<td style=\"background-color: #8080C0\">" + supplierGrantPriceExpireeList.get(i).get("VOICE_END_DATE") + "</td>" + "<td align='right' style=\"background-color: #8080C0\">" + updateMoney(DataUtil.doubleUtil(supplierGrantPriceExpireeList.get(i).get("VOICE_CREDIT")), nfFSNum) + "</td>" + "</tr>"); } mailContent.append("</table>"); mailContent.append("</body></html>"); MailSettingTo mailSettingTo = new MailSettingTo(); mailSettingTo.setEmailContent(mailContent.toString()); mailUtilService.sendMail(226, mailSettingTo); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.brick.sms.email.MailTest.java
public void findAllApplyCompany() { Map context = new HashMap(); Map outputMap = new HashMap(); List dw = null;/*from www .j av a 2 s .co m*/ // ? //Add by Michael 2012 02/07 ?? ? double lianbao = 0d; double huigou = 0d; Map tempSuplTrue = null; int guihutype = 0; context.put("C", ""); NumberFormat nfFSNum = new DecimalFormat("###,###,###,##0.00"); nfFSNum.setGroupingUsed(true); nfFSNum.setMaximumFractionDigits(2); try { //??????sql, if (guihutype == 0) { dw = (List) DataAccessor.query("applyCompanyManage.findAllApplyCompany", context, DataAccessor.RS_TYPE.LIST); if (dw != null) { for (int i = 0; i < dw.size(); i++) { Map temp = (Map) dw.get(i); //Modify by Michael 2012 08-06 //??? // Double lienLastPrice =(Double) (SelectReportInfo.selectApplyLienLastPrice(Integer.parseInt(temp.get("ID").toString()))==null ? 0.0 :SelectReportInfo.selectApplyLienLastPrice(Integer.parseInt(temp.get("ID").toString()))); // Double repurchLastPrice=(Double) (SelectReportInfo.selectApplyRepurchLastPrice(Integer.parseInt(temp.get("ID").toString()))==null ? 0.0 :SelectReportInfo.selectApplyRepurchLastPrice(Integer.parseInt(temp.get("ID").toString()))); //??? if (temp.get("GRANT_PRICE") != null) { //temp.put("LAST_PRICE",(lienLastPrice>0?lienLastPrice:0.0)+(repurchLastPrice>0?repurchLastPrice:0.0)); temp.put("LAST_PRICE", SelectReportInfo.selectApplyLastPrice( Integer.parseInt(temp.get("ID").toString())) == null ? 0.0 : SelectReportInfo.selectApplyLastPrice( Integer.parseInt(temp.get("ID").toString()))); } Map LastPrice = (Map) DataAccessor.query( "beforeMakeContract.selectApplySumIrrMonthAndLastPrice", temp, DataAccessor.RS_TYPE.MAP); if (LastPrice != null) { temp.put("SUMLASTPRICE", LastPrice.get("SHENGYUBENJIN")); } //Add by Michael 2012 02/07 ?? ?-------------- Map allLastPriceMap = SelectReportInfo .selectApplyAllLastPrice(Integer.parseInt(temp.get("ID").toString())); if (allLastPriceMap != null) { lianbao = DataUtil.doubleUtil(allLastPriceMap.get("shouxinjianshaoe_lien")); temp.put("LIANBAO", lianbao); huigou = DataUtil.doubleUtil(allLastPriceMap.get("shouxinjianshaoe_repurch")); temp.put("HUIGOU", huigou); } //------------------------------------------------------------------- } } } if (dw.size() > 0) { StringBuffer mailContent = new StringBuffer(); mailContent.append("<html><head></head>"); mailContent.append("<style>.rhead { background-color: #006699}" + ".Body2 { font-family: Arial, Helvetica, sans-serif; font-weight: normal; color: #000000; font-size: 9pt; text-decoration: none}" + ".Body2BoldWhite2 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 11pt; text-decoration: none }" + ".Body2Bold { font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #000000; font-size: 8pt; text-decoration: none }" + ".r11 { background-color: #C4E2EC}" + ".r12 { background-color: #D2EFF0}</style><body>"); mailContent.append("<font size='3'><b>??:<b><br></font>" + "<font size='2'>????~</font><br><br>"); mailContent.append( "<table border='1' cellspacing='0' width='1050px;' cellpadding='0'>" + "<tr class='rhead'>" + "<td class='Body2BoldWhite2' style='width:40px;' align='center'>??</td>" + "<td class='Body2BoldWhite2' style='width:100px;' align='center'></td>" + "<td class='Body2BoldWhite2' align='center'>??</td>" + "<td class='Body2BoldWhite2' align='center'>?</td>" + "<td class='Body2BoldWhite2' align='center'>??</td>" + "<td class='Body2BoldWhite2' align='center'>?</td></tr>"); int num = 0; for (int i = 0; i < dw.size(); i++) { num++; mailContent.append("<tr class='r12'>" + "<td class=body2 >" + num + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("NAME") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("LIEN_GRANT_PRICE") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("REPURCH_GRANT_PRICE") + "</td>" + "<td class=body2 >" + ((Map) dw.get(i)).get("LIANBAO") + "</td>" + "<td class=body2>" + ((Map) dw.get(i)).get("HUIGOU") + "</td></tr>"); } mailContent.append("</table>"); mailContent.append("</body></html>"); MailSettingTo mailSettingTo = new MailSettingTo(); mailSettingTo.setEmailTo("michael@tacleasing.cn"); mailSettingTo.setEmailSubject(""); mailSettingTo.setEmailContent(mailContent.toString()); mailUtilService.sendMail(mailSettingTo); } } catch (Exception e) { // TODO: handle exception } }