public void preencherComboContrato( DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws ServiceException, Exception { RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean(); ContratoService contratoService = (ContratoService) ServiceLocator.getInstance().getService(ContratoService.class, null); ClienteService clienteService = (ClienteService) ServiceLocator.getInstance().getService(ClienteService.class, null); FornecedorService fornecedorService = (FornecedorService) ServiceLocator.getInstance().getService(FornecedorService.class, null); ContratosGruposService contratosGruposService = (ContratosGruposService) ServiceLocator.getInstance().getService(ContratosGruposService.class, null); Collection colContratos = contratoService.list(); ContratoDTO contratoDtoAux = new ContratoDTO(); UsuarioDTO usuario = WebUtil.getUsuario(request); if (usuario == null) { document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada")); document.executeScript( "window.location = '" + Constantes.getValue("SERVER_ADDRESS") + request.getContextPath() + "'"); return; } String COLABORADORES_VINC_CONTRATOS = ParametroUtil.getValorParametroCitSmartHashMap( br.com.centralit.citcorpore.util.Enumerados.ParametroSistema .COLABORADORES_VINC_CONTRATOS, "N"); if (COLABORADORES_VINC_CONTRATOS == null) { COLABORADORES_VINC_CONTRATOS = "N"; } Collection colContratosColab = null; if (COLABORADORES_VINC_CONTRATOS.equalsIgnoreCase("S")) { colContratosColab = contratosGruposService.findByIdEmpregado(usuario.getIdEmpregado()); } Collection<ContratoDTO> listaContratos = new ArrayList<ContratoDTO>(); ((HTMLSelect) document.getSelectById("idContrato")).removeAllOptions(); if (colContratos != null) { if (colContratos.size() > 1) { ((HTMLSelect) document.getSelectById("idContrato")) .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione")); } for (Iterator it = colContratos.iterator(); it.hasNext(); ) { ContratoDTO contratoDto = (ContratoDTO) it.next(); if (contratoDto.getDeleted() == null || !contratoDto.getDeleted().equalsIgnoreCase("y")) { if (COLABORADORES_VINC_CONTRATOS.equalsIgnoreCase( "S")) { // Se parametro de colaboradores por contrato ativo, entao filtra. if (colContratosColab == null) { continue; } if (!isContratoInList(contratoDto.getIdContrato(), colContratosColab)) { continue; } } if (regraEscalonamentoDTO != null && regraEscalonamentoDTO.getIdRegraEscalonamento() != null) { this.restore(document, request, response); } String nomeCliente = ""; String nomeForn = ""; ClienteDTO clienteDto = new ClienteDTO(); clienteDto.setIdCliente(contratoDto.getIdCliente()); clienteDto = (ClienteDTO) clienteService.restore(clienteDto); if (clienteDto != null) { nomeCliente = clienteDto.getNomeRazaoSocial(); } FornecedorDTO fornecedorDto = new FornecedorDTO(); fornecedorDto.setIdFornecedor(contratoDto.getIdFornecedor()); fornecedorDto = (FornecedorDTO) fornecedorService.restore(fornecedorDto); if (fornecedorDto != null) { nomeForn = fornecedorDto.getRazaoSocial(); } contratoDtoAux.setIdContrato(contratoDto.getIdContrato()); if (contratoDto.getSituacao().equalsIgnoreCase("A")) { String nomeContrato = "" + contratoDto.getNumero() + " de " + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, contratoDto.getDataContrato(), WebUtil.getLanguage(request)) + " (" + nomeCliente + " - " + nomeForn + ")"; ((HTMLSelect) document.getSelectById("idContrato")) .addOption("" + contratoDto.getIdContrato(), nomeContrato); contratoDto.setNome(nomeContrato); listaContratos.add(contratoDto); } } } } }
/** * Este metodo trata do motor do sistema dinamico de gravacao de dados de visoes (montadas * dinamicamente) */ @Override public void save( final UsuarioDTO usuarioDto, final DinamicViewsDTO dinamicViewDto, final Map map, final HttpServletRequest request) throws Exception { final VisaoRelacionadaDao visaoRelacionadaDao = new VisaoRelacionadaDao(); final GrupoVisaoDao grupoVisaoDao = new GrupoVisaoDao(); final GrupoVisaoCamposNegocioDao grupoVisaoCamposNegocioDao = new GrupoVisaoCamposNegocioDao(); final CamposObjetoNegocioDao camposObjetoNegocioDao = new CamposObjetoNegocioDao(); final VinculoVisaoDao vinculoVisaoDao = new VinculoVisaoDao(); final ScriptsVisaoDao scriptsVisaoDao = new ScriptsVisaoDao(); final MatrizVisaoDao matrizVisaoDao = new MatrizVisaoDao(); final VisaoDao visaoDao = this.getDao(); final TransactionControler tc = this.getDao().getTransactionControler(); visaoRelacionadaDao.setTransactionControler(tc); grupoVisaoDao.setTransactionControler(tc); grupoVisaoCamposNegocioDao.setTransactionControler(tc); camposObjetoNegocioDao.setTransactionControler(tc); vinculoVisaoDao.setTransactionControler(tc); scriptsVisaoDao.setTransactionControler(tc); matrizVisaoDao.setTransactionControler(tc); final Integer idVisao = dinamicViewDto.getDinamicViewsIdVisao(); final Collection colScripts = scriptsVisaoDao.findByIdVisao(idVisao); final HashMap mapScritps = new HashMap<>(); if (colScripts != null) { for (final Iterator it = colScripts.iterator(); it.hasNext(); ) { final ScriptsVisaoDTO scriptsVisaoDTO = (ScriptsVisaoDTO) it.next(); mapScritps.put( scriptsVisaoDTO.getTypeExecute() + "#" + scriptsVisaoDTO.getScryptType().trim(), scriptsVisaoDTO.getScript()); } } final Collection colCamposPKPrincipal = new ArrayList<>(); final Collection colCamposTodosPrincipal = new ArrayList<>(); Collection colCamposTodosVinc = null; CamposObjetoNegocioDTO camposObjetoNegocioChaveMatriz = new CamposObjetoNegocioDTO(); this.setInfoSave(idVisao, colCamposPKPrincipal, colCamposTodosPrincipal); final Collection colVisoesRelacionadas = visaoRelacionadaDao.findByIdVisaoPaiAtivos(idVisao); try { tc.start(); if (this.isPKExists(colCamposPKPrincipal, map)) { String strScript = (String) mapScritps.get( ScriptsVisaoDTO.SCRIPT_EXECUTE_SERVER + "#" + ScriptsVisaoDTO.SCRIPT_ONUPDATE.getName()); if (strScript != null && !strScript.trim().equalsIgnoreCase("")) { final ScriptRhinoJSExecute scriptExecute = new ScriptRhinoJSExecute(); final RuntimeScript runtimeScript = new RuntimeScript(); final Context cx = Context.enter(); final Scriptable scope = cx.initStandardObjects(); scope.put("mapFields", scope, map); final String action = "UPDATE"; scope.put("ACTION", scope, action); scope.put("userLogged", scope, usuarioDto); scope.put("transactionControler", scope, tc); scope.put("dinamicViewDto", scope, dinamicViewDto); scope.put("RuntimeScript", scope, runtimeScript); scope.put("language", scope, WebUtil.getLanguage(request)); scriptExecute.processScript( cx, scope, strScript, VisaoServiceEjb.class.getName() + "_" + ScriptsVisaoDTO.SCRIPT_ONUPDATE.getName()); } if (!dinamicViewDto.isAbortFuncaoPrincipal()) { this.updateFromMap(map, colCamposTodosPrincipal, usuarioDto, visaoDao, request); strScript = (String) mapScritps.get( ScriptsVisaoDTO.SCRIPT_EXECUTE_SERVER + "#" + ScriptsVisaoDTO.SCRIPT_AFTERUPDATE.getName()); if (strScript != null && !strScript.trim().equalsIgnoreCase("")) { final ScriptRhinoJSExecute scriptExecute = new ScriptRhinoJSExecute(); final RuntimeScript runtimeScript = new RuntimeScript(); final Context cx = Context.enter(); final Scriptable scope = cx.initStandardObjects(); scope.put("mapFields", scope, map); final String action = "UPDATE"; scope.put("ACTION", scope, action); scope.put("userLogged", scope, usuarioDto); scope.put("transactionControler", scope, tc); scope.put("dinamicViewDto", scope, dinamicViewDto); scope.put("RuntimeScript", scope, runtimeScript); scope.put("language", scope, WebUtil.getLanguage(request)); scriptExecute.processScript( cx, scope, strScript, VisaoServiceEjb.class.getName() + "_" + ScriptsVisaoDTO.SCRIPT_AFTERUPDATE.getName()); } } } else { String strScript = (String) mapScritps.get( ScriptsVisaoDTO.SCRIPT_EXECUTE_SERVER + "#" + ScriptsVisaoDTO.SCRIPT_ONCREATE.getName()); if (strScript != null && !strScript.trim().equalsIgnoreCase("")) { final ScriptRhinoJSExecute scriptExecute = new ScriptRhinoJSExecute(); final RuntimeScript runtimeScript = new RuntimeScript(); final Context cx = Context.enter(); final Scriptable scope = cx.initStandardObjects(); scope.put("mapFields", scope, map); final String action = "CREATE"; scope.put("ACTION", scope, action); scope.put("userLogged", scope, usuarioDto); scope.put("transactionControler", scope, tc); scope.put("dinamicViewDto", scope, dinamicViewDto); scope.put("RuntimeScript", scope, runtimeScript); scope.put("language", scope, WebUtil.getLanguage(request)); scriptExecute.processScript( cx, scope, strScript, VisaoServiceEjb.class.getName() + "_" + ScriptsVisaoDTO.SCRIPT_ONCREATE.getName()); } if (!dinamicViewDto.isAbortFuncaoPrincipal()) { this.createFromMap(map, colCamposTodosPrincipal, usuarioDto, visaoDao, request); strScript = (String) mapScritps.get( ScriptsVisaoDTO.SCRIPT_EXECUTE_SERVER + "#" + ScriptsVisaoDTO.SCRIPT_AFTERCREATE.getName()); if (strScript != null && !strScript.trim().equalsIgnoreCase("")) { final ScriptRhinoJSExecute scriptExecute = new ScriptRhinoJSExecute(); final RuntimeScript runtimeScript = new RuntimeScript(); final Context cx = Context.enter(); final Scriptable scope = cx.initStandardObjects(); scope.put("mapFields", scope, map); final String action = "CREATE"; scope.put("ACTION", scope, action); scope.put("userLogged", scope, usuarioDto); scope.put("transactionControler", scope, tc); scope.put("dinamicViewDto", scope, dinamicViewDto); scope.put("RuntimeScript", scope, runtimeScript); scope.put("language", scope, WebUtil.getLanguage(request)); scriptExecute.processScript( cx, scope, strScript, VisaoServiceEjb.class.getName() + "_" + ScriptsVisaoDTO.SCRIPT_AFTERCREATE.getName()); } } } if (colVisoesRelacionadas != null) { for (final Iterator it = colVisoesRelacionadas.iterator(); it.hasNext(); ) { final VisaoRelacionadaDTO visaoRelacionadaDto = (VisaoRelacionadaDTO) it.next(); final Collection colVinculos = vinculoVisaoDao.findByIdVisaoRelacionada(visaoRelacionadaDto.getIdVisaoRelacionada()); final Object objFromHash = map.get( VisaoRelacionadaDTO.PREFIXO_SISTEMA_TABELA_VINCULADA + visaoRelacionadaDto.getIdVisaoFilha()); VisaoDTO visaoDtoAux = new VisaoDTO(); visaoDtoAux.setIdVisao(visaoRelacionadaDto.getIdVisaoFilha()); visaoDtoAux = (VisaoDTO) visaoDao.restore(visaoDtoAux); MatrizVisaoDTO matrizVisaoDTO = new MatrizVisaoDTO(); boolean ehMatriz = false; if (visaoDtoAux != null) { if (visaoDtoAux.getTipoVisao().equalsIgnoreCase(VisaoDTO.MATRIZ)) { ehMatriz = true; matrizVisaoDTO.setIdVisao(visaoDtoAux.getIdVisao()); final Collection colMatriz = matrizVisaoDao.findByIdVisao(visaoDtoAux.getIdVisao()); if (colMatriz != null && colMatriz.size() > 0) { matrizVisaoDTO = (MatrizVisaoDTO) colMatriz.iterator().next(); camposObjetoNegocioChaveMatriz.setIdCamposObjetoNegocio( matrizVisaoDTO.getIdCamposObjetoNegocio1()); camposObjetoNegocioChaveMatriz.setIdObjetoNegocio( matrizVisaoDTO.getIdObjetoNegocio()); camposObjetoNegocioChaveMatriz = (CamposObjetoNegocioDTO) camposObjetoNegocioDao.restore(camposObjetoNegocioChaveMatriz); } } } if (HashMap.class.isInstance(objFromHash)) { final HashMap mapVinc = (HashMap) objFromHash; if (mapVinc != null) { // Se existir dados recebidos. final Collection colCamposPKVinc = new ArrayList<>(); colCamposTodosVinc = new ArrayList<>(); this.setInfoSave( visaoRelacionadaDto.getIdVisaoFilha(), colCamposPKVinc, colCamposTodosVinc); // Grava os dados de informacoes vinculadas. if (this.isPKExists(colCamposPKVinc, mapVinc)) { this.updateFromMap(mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } else { this.createFromMap(mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } } } else if (Collection.class.isInstance(objFromHash)) { final Collection colVinc = (Collection) objFromHash; if (colVinc != null) { for (final Iterator it2 = colVinc.iterator(); it2.hasNext(); ) { Map mapVinc = (Map) it2.next(); if (mapVinc != null) { // Se existir dados recebidos. final Collection colCamposPKVinc = new ArrayList<>(); colCamposTodosVinc = new ArrayList<>(); this.setInfoSave( visaoRelacionadaDto.getIdVisaoFilha(), colCamposPKVinc, colCamposTodosVinc); // ***** String tipoVinc = ""; if (colVinculos != null && colVinculos.size() > 0) { final VinculoVisaoDTO vinculoVisaoDTO = (VinculoVisaoDTO) ((List) colVinculos).get(0); tipoVinc = vinculoVisaoDTO.getTipoVinculo(); } if (ehMatriz) { if (camposObjetoNegocioChaveMatriz != null) { mapVinc.put(camposObjetoNegocioChaveMatriz.getNomeDB(), mapVinc.get("FLD_0")); } CamposObjetoNegocioDTO camposObjetoNegocioDTO = null; if (colCamposPKVinc != null && colCamposPKVinc.size() > 0) { for (final Iterator itVinc = colCamposPKVinc.iterator(); itVinc.hasNext(); ) { camposObjetoNegocioDTO = (CamposObjetoNegocioDTO) itVinc.next(); if (!camposObjetoNegocioDTO .getNomeDB() .trim() .equalsIgnoreCase(camposObjetoNegocioChaveMatriz.getNomeDB().trim())) { mapVinc.put( camposObjetoNegocioDTO.getNomeDB(), map.get(camposObjetoNegocioDTO.getNomeDB())); } } } if (tipoVinc == null || tipoVinc.equalsIgnoreCase("")) { tipoVinc = VinculoVisaoDTO.VINCULO_1_TO_N; } } if (tipoVinc.equalsIgnoreCase(VinculoVisaoDTO.VINCULO_N_TO_N)) { // Grava os dados de informacoes vinculadas. if (this.isPKExists(colCamposPKVinc, mapVinc)) { this.updateFromMap( mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } else { this.createFromMap( mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } this.processCreateVinc( visaoRelacionadaDto, colVinculos, map, mapVinc, usuarioDto, request); } if (tipoVinc.equalsIgnoreCase(VinculoVisaoDTO.VINCULO_1_TO_N)) { mapVinc = this.createUniqueMap(map, mapVinc); // ****** // Grava os dados de informacoes vinculadas. if (this.isPKExists(colCamposPKVinc, mapVinc)) { this.updateFromMap( mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } else { this.createFromMap( mapVinc, colCamposTodosVinc, usuarioDto, visaoDao, request); } } } } } } } } if (dinamicViewDto.getIdFluxo() != null || dinamicViewDto.getIdTarefa() != null) { new ExecucaoSolicitacaoServiceEjb() .executa( usuarioDto, tc, dinamicViewDto.getIdFluxo(), dinamicViewDto.getIdTarefa(), dinamicViewDto.getAcaoFluxo(), map, colCamposTodosPrincipal, colCamposTodosVinc); } tc.commit(); tc.close(); } catch (final Exception e) { this.rollbackTransaction(tc, e); } }
@Override public void onEndPage(final PdfWriter writer, final Document document) { try { /* Adicionado o header */ final Rectangle page = document.getPageSize(); final PdfPTable header = new PdfPTable(1); header.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); header.setLockedWidth(true); header.getDefaultCell().setFixedHeight(55); header.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); final PdfPCell cellC = new PdfPCell(); cellC.setBorder(1); final PdfPTable tableContent = new PdfPTable(3); /* Adicionando a LogoMarca */ URL url = null; String caminho = ""; String urlInicial = ""; Image image = null; caminho = ParametroUtil.getValorParametroCitSmartHashMap( Enumerados.ParametroSistema.URL_LOGO_PADRAO_RELATORIO, ""); if ("".equals(caminho.trim()) || !UtilImagem.verificaSeImagemExiste(caminho)) { urlInicial = ParametroUtil.getValorParametroCitSmartHashMap( Enumerados.ParametroSistema.URL_Sistema, ""); caminho = urlInicial + "/imagens/logo/logo.png"; } try { url = new URL(caminho); final URLConnection conn = url.openConnection(); conn.connect(); } catch (final MalformedURLException e) { // the URL is not in a valid form e.printStackTrace(); url = null; } catch (final IOException e) { e.printStackTrace(); url = null; } if (url == null) { if (Constantes.getValue("CAMINHO_LOGO_CITGERENCIAL") != null) { try { url = new URL(Constantes.getValue("CAMINHO_LOGO_CITGERENCIAL")); } catch (final Exception e) { e.printStackTrace(); } } } if (url == null) { caminho = Constantes.getValue("SERVER_ADDRESS") + Constantes.getValue("CONTEXTO_APLICACAO") + "/imagens/logoPadraoRelatorio.png"; try { url = new URL(caminho); } catch (final Exception e) { e.printStackTrace(); } } if (url != null) { try { image = Image.getInstance(url); } catch (final BadElementException e) { e.printStackTrace(); } } if (image != null) { image.scaleAbsolute(150, 50); image.setAlignment(Image.RIGHT); final Chunk ck = new Chunk(image, -3, -25); final PdfPCell cell = new PdfPCell(); cell.addElement(ck); cell.setBorderWidth(0); cell.setRowspan(2); tableContent.addCell(cell); } else { tableContent.addCell("Citsmart"); } final String strCab = Constantes.getValue("TEXTO_1a_LINHA_CABECALHO_CITGERENCIAL"); if (strCab != null && !strCab.equalsIgnoreCase("")) { final PdfPCell cAux = new PdfPCell( new Phrase(strCab, new Font(Font.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cAux.setColspan(2); cAux.setBorderWidth(1); cAux.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tableContent.addCell(cAux); } /* Adicionado o Titulo do relatório */ final PdfPCell titulo = new PdfPCell( new Phrase(titleReport, new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0)))); titulo.setColspan(2); titulo.setRowspan(1); titulo.setBorderWidth(0); titulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tableContent.addCell(titulo); /* Adicionado o filtro */ String strFiltro = this.trataParameters(hshParameters, colParmsUtilizadosNoSQL, colDefinicaoParametros); if (strFiltro == null) { strFiltro = ""; } final PdfPCell cFiltro = new PdfPCell( new Phrase(strFiltro, new Font(Font.HELVETICA, 8, Font.NORMAL, new Color(0, 0, 0)))); cFiltro.setBorderWidth(0); cFiltro.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cFiltro.setColspan(2); tableContent.addCell(cFiltro); cellC.addElement(tableContent); header.addCell(tableContent); // Fim - Trata parametros if (!existeAgrupador) { if (listRetorno != null && listRetorno.size() > 0) { final Object[] row = (Object[]) listRetorno.get(0); this.geraCabecalhoPDF(row.length, gerencialItemDto, header, writer, document, page); } } if (page.getWidth() > 600) { if (!existeAgrupador) { header.writeSelectedRows(0, -1, 20, 565, writer.getDirectContent()); } else { header.writeSelectedRows(0, -1, 20, 585, writer.getDirectContent()); } } else { if (!existeAgrupador) { header.writeSelectedRows( 0, -1, 20, page.getHeight() - document.topMargin() + header.getTotalHeight(), writer.getDirectContent()); } else { header.writeSelectedRows(0, -1, 20, 805, writer.getDirectContent()); } } /* Adicionado o footer */ final PdfPTable footer = new PdfPTable(2); final String emissao = (String) hshParameters.get("citcorpore.comum.emissao"); final String pagina = (String) hshParameters.get("citcorpore.comum.pagina"); PdfPCell cAuxPageNumber = new PdfPCell( new Phrase( emissao + ": " + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, UtilDatas.getDataAtual(), WebUtil.getLanguage(request)) + " " + UtilDatas.formatHoraFormatadaStr(UtilDatas.getHoraAtual()), new Font(Font.HELVETICA, 8, Font.NORMAL, new Color(0, 0, 0)))); cAuxPageNumber.setBorder(0); footer.addCell(cAuxPageNumber); cAuxPageNumber = new PdfPCell( new Phrase( pagina + ": " + writer.getPageNumber(), new Font(Font.HELVETICA, 8, Font.NORMAL, new Color(0, 0, 0)))); cAuxPageNumber.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); cAuxPageNumber.setBorder(0); footer.addCell(cAuxPageNumber); footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); footer.writeSelectedRows( 0, -1, document.leftMargin(), document.bottomMargin(), writer.getDirectContent()); } catch (final Exception e) { throw new ExceptionConverter(e); } }
public void listarRegistrosQuestionario( DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { final ChecklistQuestionarioDTO checklistQuestionarioDTO = (ChecklistQuestionarioDTO) document.getBean(); final UsuarioDTO usuario = WebUtil.getUsuario(request); if (usuario == null) { document.alert("Sessão expirada! Favor efetuar logon novamente!"); return; } String PRONTUARIO_FORMA_EDICAO = "PRONTUARIO_FORMA_EDICAO"; if (PRONTUARIO_FORMA_EDICAO == null || PRONTUARIO_FORMA_EDICAO.trim().equalsIgnoreCase("")) { PRONTUARIO_FORMA_EDICAO = "P"; } QuestionarioDTO questionarioDTO = new QuestionarioDTO(); final QuestionarioService questionarioService = (QuestionarioService) ServiceLocator.getInstance().getService(QuestionarioService.class, null); if (checklistQuestionarioDTO.getIdQuestionario() != null) { questionarioDTO.setIdQuestionario(checklistQuestionarioDTO.getIdQuestionario()); questionarioDTO = (QuestionarioDTO) questionarioService.restore(questionarioDTO); checklistQuestionarioDTO.setIdQuestionarioOrigem(questionarioDTO.getIdQuestionarioOrigem()); } final RequisicaoQuestionarioService requisicaoQuestionariosService = (RequisicaoQuestionarioService) ServiceLocator.getInstance().getService(RequisicaoQuestionarioService.class, null); final Collection colQuestHist = requisicaoQuestionariosService.listByIdTipoAbaAndTipoRequisicaoAndQuestionario( checklistQuestionarioDTO); Integer seqGeral = new Integer(0); String abrir = ""; String abrirUltimo = ""; String geralData = ""; final StringBuilder strTable = new StringBuilder(); strTable.append(""); final StringBuilder hist_Pront = new StringBuilder(); if (colQuestHist != null && colQuestHist.size() > 0) { strTable.append("<table width=\"100%\" class=\"tableLess\">"); strTable.append("<thead>"); strTable.append("<tr>"); strTable.append("<th width=\"7%\" >"); strTable.append(" "); strTable.append("</th>"); strTable.append("<th>"); strTable.append(UtilI18N.internacionaliza(request, "itemConfiguracaoTree.versao")); strTable.append("</th>"); strTable.append("<th>"); strTable.append(UtilI18N.internacionaliza(request, "questionario.dataHora")); strTable.append("</th>"); strTable.append("<th>"); strTable.append(UtilI18N.internacionaliza(request, "menu.nome.questionario")); strTable.append("</th>"); strTable.append("<th >"); strTable.append(UtilI18N.internacionaliza(request, "citcorpore.comum.concluida")); strTable.append("</th>"); strTable.append("</tr>"); strTable.append("</thead>"); hist_Pront.append("geral_hist_Pront_Quest_Seq = new Array();"); hist_Pront.append("geral_hist_Pront_Quest = new Array();"); hist_Pront.append("geral_hist_Pront_Quest = new Array();"); seqGeral = colQuestHist.size(); Integer seq = colQuestHist.size(); int i = colQuestHist.size() - 1; for (final Iterator it = colQuestHist.iterator(); it.hasNext(); ) { final RequisicaoQuestionarioDTO reqQuestQuestDTO = (RequisicaoQuestionarioDTO) it.next(); hist_Pront.append("geral_hist_Pront_Quest_Seq[" + i + "] = '" + seq.toString() + "';"); hist_Pront.append( "geral_hist_Pront_Quest_Data[" + i + "] = '" + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, reqQuestQuestDTO.getDataQuestionario(), WebUtil.getLanguage(request)) + "';"); final String descricao = ""; final Collection col = null; strTable.append("<tr>"); strTable.append("<td >"); abrir = "titulo_Selecionado = '" + descricao.replaceAll("'", "") + "';"; abrir += "try{cit$('divTituloPOPUPQUEST').innerHTML = titulo_Selecionado;}catch(e){};"; if ("F".equalsIgnoreCase(reqQuestQuestDTO.getSituacao())) { abrir += "abaSelecionada = '" + reqQuestQuestDTO.getAba() + "'; chamaEdicaoQuestionario(" + reqQuestQuestDTO.getIdRequisicao() + "," + reqQuestQuestDTO.getIdQuestionario() + ",0, " + reqQuestQuestDTO.getIdRequisicaoQuestionario() + ", true, 'N', '" + reqQuestQuestDTO.getAba() + "," + reqQuestQuestDTO.getNomeQuestionario() + "')"; strTable.append( "<img title=\"" + UtilI18N.internacionaliza(request, "Questionario.questionarioPreenchido") + "\" src=\"" + CitCorporeConstantes.CAMINHO_SERVIDOR + request.getContextPath() + "/template_new/images/icons/large/grey/archive.png\" border=\"0\" onclick=\"try{cit$('div_PQ_Indicador').innerHTML = '--';}catch(e){};try{cit$('div_PQ_Data').innerHTML = '" + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, reqQuestQuestDTO.getDataQuestionario(), WebUtil.getLanguage(request)) + "';}catch(e){};" + abrir + "\" style=\"cursor:pointer\" >"); } else { abrir += "abaSelecionada = '" + reqQuestQuestDTO.getAba() + "'; chamaEdicaoQuestionario(" + reqQuestQuestDTO.getIdRequisicao() + "," + reqQuestQuestDTO.getIdQuestionario() + ",0, " + reqQuestQuestDTO.getIdRequisicaoQuestionario() + ", false, 'N', '" + reqQuestQuestDTO.getAba() + "," + reqQuestQuestDTO.getNomeQuestionario() + "')"; strTable.append( "<img title='" + UtilI18N.internacionaliza(request, "Questionario.questionarioPreenchido") + "' src=\"" + CitCorporeConstantes.CAMINHO_SERVIDOR + request.getContextPath() + "/template_new/images/icons/large/grey/archive.png\" border=\"0\" onclick=\"try{cit$('div_PQ_Indicador').innerHTML = '--';}catch(e){};try{cit$('div_PQ_Data').innerHTML = '" + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, reqQuestQuestDTO.getDataQuestionario(), WebUtil.getLanguage(request)) + "';}catch(e){};" + abrir + "\" style=\"cursor:pointer\" >"); } strTable.append("</td>"); strTable.append( "<td class='tdPontilhada' style=\"text-align:center\">" + seq.toString() + "</td>"); strTable.append("<td class='tdPontilhada'>"); strTable.append( UtilDatas.convertDateToString( TipoDate.TIMESTAMP_WITH_SECONDS, reqQuestQuestDTO.getDataHoraGrav(), WebUtil.getLanguage(request))); strTable.append("</td>"); strTable.append("<td class='tdPontilhada'>"); strTable.append(UtilStrings.nullToVazio(reqQuestQuestDTO.getNomeQuestionario()) + " "); strTable.append("</td>"); strTable.append("<td class='tdPontilhada' style='text-align: center'>"); if (reqQuestQuestDTO.getConfirmacao() != null && reqQuestQuestDTO.getConfirmacao().equalsIgnoreCase("S")) { strTable.append( "<label style='cursor:pointer'><input type='checkbox' value='S' id='confirma' name='confirma' checked onclick='gravaConfirmacao(" + reqQuestQuestDTO.getIdRequisicaoQuestionario() + ", \"S\");'/></label><br>"); } else { strTable.append( "<label style='cursor:pointer'><input type='checkbox' value='N' id='confirma' name='confirma' onclick='gravaConfirmacao(" + reqQuestQuestDTO.getIdRequisicaoQuestionario() + ", \"N\");'/></label><br>"); } strTable.append("</td>"); strTable.append("</tr>"); seq = seq - 1; hist_Pront.append("geral_hist_Pront_Quest_Comando[" + i + "] = \"" + abrir + "\";"); i--; if (abrirUltimo.equalsIgnoreCase("")) { abrirUltimo = abrir; } if (geralData.equalsIgnoreCase("")) { if (checklistQuestionarioDTO.getTipoApresResumo() == null) { checklistQuestionarioDTO.setTipoApresResumo(""); } if (!checklistQuestionarioDTO.getTipoApresResumo().equalsIgnoreCase("E")) { hist_Pront.append( "geral_data = '" + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, reqQuestQuestDTO.getDataQuestionario(), WebUtil.getLanguage(request)) + "';"); geralData = "geral_data = '" + UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, reqQuestQuestDTO.getDataQuestionario(), WebUtil.getLanguage(request)) + "';"; } } } strTable.append("</table>"); if (PRONTUARIO_FORMA_EDICAO.equalsIgnoreCase("A")) { document.executeScript(hist_Pront.toString()); if (checklistQuestionarioDTO.getTipoApresResumo() == null) { checklistQuestionarioDTO.setTipoApresResumo(""); } if (!checklistQuestionarioDTO.getTipoApresResumo().equalsIgnoreCase("E")) { document.executeScript("geral_seq_Pront_Questionario = " + seqGeral.toString()); document.executeScript( "geral_seq_Sel_Pront_Questionario = (" + seqGeral.toString() + " - 1)"); } if (!abrir.equalsIgnoreCase("")) { checklistQuestionarioDTO.setUltimoComando(abrirUltimo); } } if (checklistQuestionarioDTO.getTipoApresResumo() == null || checklistQuestionarioDTO.getTipoApresResumo().equalsIgnoreCase("J")) { document.getElementById("divRegistros").setInnerHTML(strTable.toString()); } else { if (!checklistQuestionarioDTO .getTipoApresResumo() .equalsIgnoreCase("*")) { // O * indica para nao apresentar nada document.getElementById("divHistRes_Conteudo").setInnerHTML(strTable.toString()); final HTMLForm form = document.getForm("form"); form.setValues(checklistQuestionarioDTO); } } } }
public void informacao( DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { this.setInformacaoItemConfiguracao((InformacaoItemConfiguracaoDTO) document.getBean()); this.getItemConfiguracao().setIdItemConfiguracao(Integer.parseInt(request.getParameter("id"))); this.setItemConfiguracao( (ItemConfiguracaoDTO) this.getItemConfiguracaoService().restore(this.getItemConfiguracao())); this.setInformacaoItemConfiguracao( this.getInformacaoItemConfiguracaoService().listByInformacao(this.getItemConfiguracao())); this.getInformacaoItemConfiguracao() .setIdentificacaoItemConfiguracao(this.getItemConfiguracao().getIdentificacao()); GrupoItemConfiguracaoService grupoItemConfiguracaoService = (GrupoItemConfiguracaoService) ServiceLocator.getInstance().getService(GrupoItemConfiguracaoService.class, null); GrupoItemConfiguracaoDTO grupoItemConfiguracaoDTO = new GrupoItemConfiguracaoDTO(); if (this.getItemConfiguracao().getIdGrupoItemConfiguracao() != null) { grupoItemConfiguracaoDTO.setIdGrupoItemConfiguracao( this.getItemConfiguracao().getIdGrupoItemConfiguracao()); grupoItemConfiguracaoDTO = (GrupoItemConfiguracaoDTO) grupoItemConfiguracaoService.restore(grupoItemConfiguracaoDTO); this.getInformacaoItemConfiguracao() .setNomeGrupoItemConfiguracao(grupoItemConfiguracaoDTO.getNomeGrupoItemConfiguracao()); } else { if (!ParametroUtil.getValorParametroCitSmartHashMap( Enumerados.ParametroSistema.NOME_GRUPO_ITEM_CONFIG_NOVOS, " ") .trim() .equalsIgnoreCase("")) this.getInformacaoItemConfiguracao() .setNomeGrupoItemConfiguracao( ParametroUtil.getValorParametroCitSmartHashMap( Enumerados.ParametroSistema.NOME_GRUPO_ITEM_CONFIG_NOVOS, " ")); } /* Desenvolvedor: Pedro Lino - Data: 23/10/2013 - Horário: 10:54 - ID Citsmart: 120948 - * Motivo/Comentário: Grupo estavaparecendo NULL/ Utilizado nullToVazio para aparesentar vazio na tela * Obs.: Tratado tbm para identificação - Linha(s): 90 e 93 */ StringBuilder subDiv = new StringBuilder(); /* Cabeçalho */ subDiv.append("<div id='cabecalhoInf'>"); subDiv.append( "<h2>" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.descricaoAtivosMaquina") + "</h2><hr />"); subDiv.append("<label>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "citcorpore.comum.identificacao") + ": " + UtilStrings.nullToVazio( this.getInformacaoItemConfiguracao().getIdentificacaoItemConfiguracao())); subDiv.append("</label>"); subDiv.append("<label>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "grupo.grupo") + ": " + UtilStrings.nullToVazio( this.getInformacaoItemConfiguracao().getNomeGrupoItemConfiguracao())); subDiv.append("</label>"); subDiv.append("<hr />"); subDiv.append("</div>"); // subDiv.append("<div id='divImpactos'>"); // subDiv.append("</div>"); /* Treeview */ subDiv.append("<div id='corpoInf'>"); subDiv.append("<ul id='browser' class='filetree treeview'>"); subDiv.append("<li class='closed' >"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder'>"); subDiv.append("BIOS"); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.dataUltimoIventario") + ""); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<li>"); subDiv.append("<span class='file'>"); subDiv.append( UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, this.getItemConfiguracao().getDataInicio(), WebUtil.getLanguage(request))); subDiv.append("</span>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea' onclick='restaurarValoresBios();'>"); subDiv.append("</div>"); subDiv.append("<span class='folder' onclick='restaurarValoresBios();'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.caracteristicas") + ""); subDiv.append("</span>"); subDiv.append("<ul id='subBios'>"); // subDiv.append("<div id='subBios'></div>"); // aqui sera incluso via InnerHTML quando o ator clicar em BIOS. subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder' >"); subDiv.append("Hardware"); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.dataUltimoIventario") + ""); subDiv.append("</span>"); subDiv.append("<ul >"); subDiv.append("<li>"); subDiv.append("<span class='file'>"); subDiv.append( UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, this.getItemConfiguracao().getDataInicio(), WebUtil.getLanguage(request))); subDiv.append("</span>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("<li class='closed' >"); subDiv.append( "<div class='hitarea closed-hitarea collapsable-hitarea' onclick='restaurarValoresHardware();'>"); subDiv.append("</div>"); subDiv.append("<span class='folder' onclick='restaurarValoresHardware();'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.caracteristicas") + ""); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<div id='subHardware'></div>"); // aqui sera incluso via InnerHTML quando o ator clicar em HARDWARE. subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder' name='bios' >"); subDiv.append("Software"); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<li class='closed'>"); subDiv.append("<div class='hitarea closed-hitarea collapsable-hitarea'>"); subDiv.append("</div>"); subDiv.append("<span class='folder'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.dataUltimoIventario") + ""); subDiv.append("</span>"); subDiv.append("<ul >"); subDiv.append("<li>"); subDiv.append("<span class='file'>"); subDiv.append( UtilDatas.convertDateToString( TipoDate.DATE_DEFAULT, this.getItemConfiguracao().getDataInicio(), WebUtil.getLanguage(request))); subDiv.append("</span>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("<li class='closed'>"); subDiv.append( "<div class='hitarea closed-hitarea collapsable-hitarea' onclick='restaurarValoresSoftware();'>"); subDiv.append("</div>"); subDiv.append("<span class='folder' onclick='restaurarValoresSoftware();'>"); subDiv.append( "" + UtilI18N.internacionaliza(request, "pesquisaItemConfiguracao.caracteristicas") + ""); subDiv.append("</span>"); subDiv.append("<ul>"); subDiv.append("<div id='subSoftware'></div>"); // aqui sera incluso via InnerHTML quando o ator clicar em SOFTWARE. subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</li>"); subDiv.append("</ul>"); subDiv.append("</div>"); subDiv.append("<div id='divImpactos'></div>"); HTMLElement divPrincipal = document.getElementById("principalInf"); divPrincipal.setInnerHTML(subDiv.toString()); if (request.getParameter("mostraItensVinculados") == null || request.getParameter("mostraItensVinculados").equals("true")) verificaImpactos( this.getInformacaoItemConfiguracao().getIdItemConfiguracao(), document, request, response); document.executeScript("tree('#browser'); $('#loading_overlay').hide();"); HTMLForm form = CITCorporeUtil.limparFormulario(document); form.setValues(this.getInformacaoItemConfiguracao()); }