public byte[] gerarRelatorioHtml( List<Object> clAttrsRelatorio, String pathSistema, String pathReports, String pathImages, String nomeRelatorio) throws JRException { logger.entering(new Object[0]); Map<String, String> parametros = new HashMap<String, String>(); parametros.put(CAMINHO_RELATORIOS, pathReports); parametros.put(CAMINHO_IMAGENS, pathImages); try { JasperRunManager.runReportToHtmlFile( pathReports + nomeRelatorio, pathSistema + "relatorio.html", parametros, new JRBeanCollectionDataSource(clAttrsRelatorio)); logger.exiting(new Object[0]); return FileUtil.createByteArray(pathSistema + "relatorio.html"); } catch (JRException e) { logger.exception(e.getMessage(), e); throw e; } catch (IOException e) { logger.exception(e.getMessage(), e); throw new JRException(e.getMessage(), e); } }
public static void delete(ServidorRota servidorRota) throws VoxPersistenceException { try { logger.entering(new Object[0]); getDAO().remove(servidorRota); logger.exiting(new Object[0]); } catch (JPADeleteException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }
public static List<ServidorRota> listar() throws VoxPersistenceException { try { logger.entering(new Object[0]); List servidorRota = getDAO().listar(); logger.exiting(new Object[0]); return servidorRota; } catch (JPAUtilityException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }
public static ServidorRota consulta(Integer pk) throws VoxPersistenceException { try { logger.entering(new Object[0]); ServidorRota servidorRota = (ServidorRota) getDAO().get(pk); logger.exiting(new Object[0]); return servidorRota; } catch (JPAUtilityException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }
public byte[] gerarRelatorio( List<Object> clAttrsRelatorio, String pathReports, String pathImages, String nomeRelatorio) throws JRException { logger.entering(new Object[0]); Map<String, String> parametros = new HashMap<String, String>(); parametros.put(CAMINHO_RELATORIOS, pathReports); parametros.put(CAMINHO_IMAGENS, pathImages); try { JasperReport jasperReport = (JasperReport) JRLoader.loadObject(pathReports + nomeRelatorio); logger.exiting(new Object[0]); return JasperRunManager.runReportToPdf( jasperReport, parametros, new JRBeanCollectionDataSource(clAttrsRelatorio)); } catch (JRException e) { logger.exception(e.getMessage(), e); throw e; } }
public static void update(ServidorRota servidorRota) throws VoxPersistenceException, ObjetoJaCadastradoException { try { logger.entering(new Object[0]); if (!servidorExiste(servidorRota.getId(), servidorRota.getHost())) { getDAO().atualiza(servidorRota); } else { throw new ObjetoJaCadastradoException(); } logger.exiting(new Object[0]); } catch (JPAUpdateException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }
public static ServidorRota salvar(ServidorRota servidorRota) throws ObjetoJaCadastradoException, VoxPersistenceException, AsteriskManagerException { try { logger.entering(new Object[0]); if (!servidorExiste(servidorRota.getId(), servidorRota.getHost())) { servidorRota = (ServidorRota) getDAO().salva(servidorRota); } else { throw new ObjetoJaCadastradoException(); } logger.exiting(new Object[0]); return servidorRota; } catch (JPAInsertException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }
private static boolean servidorExiste(Integer id, String host) throws VoxPersistenceException { try { logger.entering(new Object[0]); Map map = new HashMap(); if (id != null) { map.put("id", id); } map.put("host", host); List servidoresRotas = getDAO().consultar(map); if (servidoresRotas.isEmpty()) { logger.exiting(new Object[0]); return false; } if (id != null) { if (id.equals(((ServidorRota) servidoresRotas.get(0)).getId())) { logger.exiting(new Object[0]); return false; } } else { logger.exiting(new Object[0]); return true; } logger.exiting(new Object[0]); return false; } catch (JPAUtilityException e) { logger.exception(e.getMessage(), e); throw e; } catch (VoxPersistenceException e) { logger.exception(e.getMessage(), e); throw e; } }