public void restore( DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { RegraEscalonamentoDTO regraEscalonamentoDTO = (RegraEscalonamentoDTO) document.getBean(); RegraEscalonamentoService service = (RegraEscalonamentoService) ServiceLocator.getInstance() .getService(RegraEscalonamentoService.class, WebUtil.getUsuarioSistema(request)); regraEscalonamentoDTO = (RegraEscalonamentoDTO) service.restore(regraEscalonamentoDTO); if ((regraEscalonamentoDTO != null) && (regraEscalonamentoDTO.getIdRegraEscalonamento() != null)) { EmpregadoService empregadoService = (EmpregadoService) ServiceLocator.getInstance() .getService(EmpregadoService.class, WebUtil.getUsuarioSistema(request)); if (regraEscalonamentoDTO.getIdSolicitante() != null) { EmpregadoDTO empregadoDTO = empregadoService.restoreByIdEmpregado(regraEscalonamentoDTO.getIdSolicitante()); regraEscalonamentoDTO.setNomeSolicitante( ((empregadoDTO == null) || (empregadoDTO.getNome() == null)) ? "" : empregadoDTO.getNome()); } ServicoService servicoService = (ServicoService) ServiceLocator.getInstance() .getService(ServicoService.class, WebUtil.getUsuarioSistema(request)); if (regraEscalonamentoDTO.getIdServico() != null) { ServicoDTO servicoDTO = servicoService.findById(regraEscalonamentoDTO.getIdServico()); regraEscalonamentoDTO.setServico( ((servicoDTO == null) || (servicoDTO.getNomeServico() == null)) ? "" : servicoDTO.getNomeServico()); } if (regraEscalonamentoDTO.getIdGrupo() != null) { GrupoService grupoService = (GrupoService) ServiceLocator.getInstance() .getService(GrupoService.class, WebUtil.getUsuarioSistema(request)); GrupoDTO grupoDTO = grupoService.listGrupoById(regraEscalonamentoDTO.getIdGrupo()); regraEscalonamentoDTO.setGrupo( ((grupoDTO == null) || (grupoDTO.getDescricao() == null)) ? "" : grupoDTO.getDescricao()); } } atualizaTblGrupoExecutor(document, request, response, regraEscalonamentoDTO); HTMLForm form = document.getForm("form"); form.clear(); if (regraEscalonamentoDTO != null) { form.setValues(regraEscalonamentoDTO); } }
public void atualizaTblGrupoExecutor( DocumentHTML document, HttpServletRequest request, HttpServletResponse response, RegraEscalonamentoDTO regraEscalonamentoDTO) throws Exception { // Restaurar tabela de escalonamento de grupos HTMLTable tblGrupoExecutor = document.getTableById("tblGrupoExecutor"); tblGrupoExecutor.deleteAllRows(); EscalonamentoService escalonamentoService = (EscalonamentoService) ServiceLocator.getInstance() .getService(EscalonamentoService.class, WebUtil.getUsuarioSistema(request)); Collection<EscalonamentoDTO> colEscalonamentoDTOs = escalonamentoService.findByRegraEscalonamento(regraEscalonamentoDTO); regraEscalonamentoDTO.setColEscalonamentoDTOs(colEscalonamentoDTOs); if ((tblGrupoExecutor != null) && (colEscalonamentoDTOs != null)) { tblGrupoExecutor.addRowsByCollection( colEscalonamentoDTOs, new String[] { "", "idGrupoExecutor", "descricao", "prazoExecucao", "idPrioridade", "descrPrioridade" }, null, "", new String[] {"gerarImgDelGrupoExecutor"}, null, null); } document.executeScript( "HTMLUtils.applyStyleClassInAllCells('tblGrupoExecutor', 'tblGrupoExecutor');"); }
@Override public void load(DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { 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; } HTMLForm form = document.getForm("form"); form.clear(); SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean(); SolicitacaoServicoService solicitacaoServicoService = (SolicitacaoServicoService) ServiceLocator.getInstance() .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request)); CalendarioService calendarioService = (CalendarioService) ServiceLocator.getInstance().getService(CalendarioService.class, null); JustificativaSolicitacaoService justificativaService = (JustificativaSolicitacaoService) ServiceLocator.getInstance().getService(JustificativaSolicitacaoService.class, null); solicitacaoServicoDto = solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico()); request.setAttribute("dataHoraSolicitacao", solicitacaoServicoDto.getDataHoraSolicitacaoStr()); HTMLSelect slaACombinar = (HTMLSelect) document.getSelectById("slaACombinar"); slaACombinar.addOption( "S", "-- " + UtilI18N.internacionaliza(request, "citcorpore.comum.acombinar") + " --"); slaACombinar.addOption( "N", UtilI18N.internacionaliza(request, "citcorpore.comum.definirtempo")); Collection colJustificativas = justificativaService.listAtivasParaSuspensao(); document.getSelectById("idJustificativa").removeAllOptions(); document .getSelectById("idJustificativa") .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione")); if (colJustificativas != null) { document .getSelectById("idJustificativa") .addOptions(colJustificativas, "idJustificativa", "descricaoJustificativa", null); } Collection colCalendarios = calendarioService.list(); document.getSelectById("idCalendario").removeAllOptions(); document .getSelectById("idCalendario") .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione")); if (colCalendarios != null) { document .getSelectById("idCalendario") .addOptions(colCalendarios, "idCalendario", "descricao", null); } form.setValues(solicitacaoServicoDto); document.executeScript("verificaMudarTipoSLA()"); }
/** * Salva a Mudança de SLA da Solicitação. * * @param document * @param request * @param response * @throws Exception * @author valdoilo.damasceno Data: 25/10/2013 - Horário: 16:03. Chamada * parent.pesquisarItensFiltro() */ public void save(DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { 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; } SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean(); SolicitacaoServicoService solicitacaoServicoService = (SolicitacaoServicoService) ServiceLocator.getInstance() .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request)); SolicitacaoServicoDTO solicitacaoServicoAux = solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico()); solicitacaoServicoDto.setIdSolicitante(solicitacaoServicoAux.getIdSolicitante()); solicitacaoServicoDto.setDataInicio(solicitacaoServicoAux.getDataInicio()); solicitacaoServicoDto.setDataHoraSolicitacao(solicitacaoServicoAux.getDataHoraSolicitacao()); solicitacaoServicoDto.setUsuarioDto(usuario); solicitacaoServicoDto.setRegistradoPor(usuario.getNomeUsuario()); solicitacaoServicoDto.setHouveMudanca("S"); solicitacaoServicoDto.setSituacao(solicitacaoServicoAux.getSituacao()); solicitacaoServicoDto.setPrazohhAnterior(solicitacaoServicoAux.getPrazoHH()); solicitacaoServicoDto.setPrazommAnterior(solicitacaoServicoAux.getPrazoMM()); solicitacaoServicoDto.setTempoDecorridoHH(solicitacaoServicoAux.getTempoDecorridoHH()); solicitacaoServicoDto.setTempoDecorridoMM(solicitacaoServicoAux.getTempoDecorridoMM()); if (solicitacaoServicoDto.getSlaACombinar().equalsIgnoreCase("S")) { solicitacaoServicoDto.setPrazoCapturaHH(0); solicitacaoServicoDto.setPrazoCapturaMM(0); solicitacaoServicoDto.setPrazoHH(0); solicitacaoServicoDto.setPrazoMM(0); } solicitacaoServicoService.updateSLA(solicitacaoServicoDto); document.executeScript("parent.refreshTelaGerenciamento();"); }
public ClienteEmailCentralServicoDTO getMessagesByLimitAndNoRequest( DocumentHTML document, HttpServletRequest request, HttpServletResponse response) throws Exception { EmailSolicitacaoServicoService emailSolicitacaoServicoService = (EmailSolicitacaoServicoService) ServiceLocator.getInstance() .getService( EmailSolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request)); ClienteEmailCentralServicoDTO clienteEmailCentralServicoDto = new ClienteEmailCentralServicoDTO(); clienteEmailCentralServicoDto.setResultSucess(true); try { if (CONEXAO_EMAIL_SERVIDOR.equals("") || CONEXAO_EMAIL_PROVIDER.equals("") || CONEXAO_EMAIL_CAIXA.equals("") || CONEXAO_EMAIL_SENHA.equals("") || CONEXAO_EMAIL_PASTA.equals("")) { clienteEmailCentralServicoDto.setResultSucess(false); clienteEmailCentralServicoDto.setResultMessage( UtilI18N.internacionaliza( request, "clienteEmailCentralServico.problemasRealizarleituraEmailsParametros")); } else { Properties props = new Properties(); props.setProperty("mail.store.protocol", CONEXAO_EMAIL_PROVIDER); props.setProperty("mail.imaps.auth.plain.disable", "true"); props.setProperty("mail.imaps.ssl.trust", "*"); // props.setProperty("mail.debug", "true"); if (!CONEXAO_EMAIL_PORTA.equals("")) props.setProperty("mail." + CONEXAO_EMAIL_PROVIDER + ".port", CONEXAO_EMAIL_PORTA); Session session = Session.getInstance(props, null); Store store = session.getStore(); store.connect(CONEXAO_EMAIL_SERVIDOR, CONEXAO_EMAIL_CAIXA, CONEXAO_EMAIL_SENHA); Folder inbox = store.getFolder(CONEXAO_EMAIL_PASTA); inbox.open(Folder.READ_WRITE); Message[] messages = inbox.getMessages(); if (messages != null && messages.length > 0) { ArrayUtils.reverse(messages); Integer limiteEmails = 10; try { limiteEmails = Integer.parseInt(CONEXAO_EMAIL_LIMITE); } catch (NumberFormatException e) { e.printStackTrace(); limiteEmails = 10; } ArrayList<ClienteEmailCentralServicoMessagesDTO> emailMessages = new ArrayList<ClienteEmailCentralServicoMessagesDTO>(); for (Message message : messages) { if (emailMessages.size() < limiteEmails) { MimeMessage m = (MimeMessage) inbox.getMessage(message.getMessageNumber()); EmailSolicitacaoServicoDTO colEmailDto = emailSolicitacaoServicoService.getEmailByIdMessage(m.getMessageID()); if (colEmailDto == null) { ClienteEmailCentralServicoMessagesDTO clienteEmailMessagesDto = new ClienteEmailCentralServicoMessagesDTO(); clienteEmailMessagesDto.setMessageId(m.getMessageID()); clienteEmailMessagesDto.setMessageNumber(message.getMessageNumber()); Address[] in = message.getFrom(); clienteEmailMessagesDto.setMessageEmail( (in == null ? null : ((InternetAddress) in[0]).getAddress())); clienteEmailMessagesDto.setMessageSubject(message.getSubject()); clienteEmailMessagesDto.setMessageReceivedDate(message.getReceivedDate()); // clienteEmailMessagesDto.setSeen(message.isSet(Flags.Flag.SEEN)); //Atrapalha a // performance clienteEmailMessagesDto.setSeen(true); emailMessages.add(clienteEmailMessagesDto); } } else { break; } } clienteEmailCentralServicoDto.setEmailMessages(emailMessages); } } } catch (Exception e) { e.printStackTrace(); clienteEmailCentralServicoDto.setResultSucess(false); clienteEmailCentralServicoDto.setResultMessage( UtilI18N.internacionaliza( request, "clienteEmailCentralServico.problemasRealizarleituraEmails")); } return clienteEmailCentralServicoDto; }