List of usage examples for org.apache.commons.lang3 StringUtils upperCase
public static String upperCase(final String str)
Converts a String to upper case as per String#toUpperCase() .
A null input String returns null .
StringUtils.upperCase(null) = null StringUtils.upperCase("") = "" StringUtils.upperCase("aBc") = "ABC"
Note: As described in the documentation for String#toUpperCase() , the result of this method is affected by the current locale.
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void sendBpracticaSolicita(ActionEvent event) { try {/* w w w . ja v a 2s . c om*/ if (StringUtils.isBlank(this.getSelectedBpractica().getVmsjsolicita())) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Campo requerido. Ingrese el mensaje a enviar."); FacesContext.getCurrentInstance().addMessage(null, message); } else { //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.BUENAPRACTICA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedBpractica().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedBpractica() .setVtitulo(StringUtils.upperCase(this.getSelectedBpractica().getVtitulo().trim())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedBpractica().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedBpractica() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedBpractica() .setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedBpractica().setDfechamodificacion(new Date()); this.getSelectedBpractica().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedBpractica() .setVmsjsolicita(this.getSelectedBpractica().getVmsjsolicita().toUpperCase()); conocimientoService.saveOrUpdate(this.getSelectedBpractica()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedBpractica().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathbp.concat(this.getSelectedBpractica().getNconocimientoid().toString()) .concat("/").concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.BUENAPRACTICA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedBpractica().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedBpractica().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedBpractica().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedBpractica().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedBpractica().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedBpractica().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("9"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.BUENAPRACTICA); asignacion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); asignacion.setNusuarioid( serviceasig.getUserCreacionByContenido(this.getSelectedBpractica().getNtipoconocimientoid(), this.getSelectedBpractica().getNconocimientoid())); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); this.fSInfMod = "true"; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Solicitud de informacin adicional enviada."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void sendOmejoraSolicita(ActionEvent event) { try {/*from w w w . j av a2 s. co m*/ if (StringUtils.isBlank(this.getSelectedOmejora().getVmsjsolicita())) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Campo requerido. Ingrese el mensaje a enviar."); FacesContext.getCurrentInstance().addMessage(null, message); } else { //this.setContenidoHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.OPORTUNIDADMEJORA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedOmejora().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedOmejora().setVtitulo(StringUtils.upperCase(this.getSelectedOmejora().getVtitulo())); this.getSelectedOmejora() .setVdescripcion(StringUtils.upperCase(this.getSelectedOmejora().getVdescripcion())); if (this.getContenidoPlain().length() < 400) { this.getSelectedOmejora().setVcontenido(StringUtils.capitalize(this.getContenidoPlain())); } else { this.getSelectedOmejora() .setVcontenido(StringUtils.capitalize(this.getContenidoPlain().substring(0, 399))); } this.getSelectedOmejora().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedOmejora().setDfechamodificacion(new Date()); this.getSelectedOmejora().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedOmejora() .setVmsjsolicita(this.getSelectedOmejora().getVmsjsolicita().toUpperCase()); conocimientoService.saveOrUpdate(this.getSelectedOmejora()); this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "plain.txt", this.getContenidoPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedOmejora().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathom.concat(this.getSelectedOmejora().getNconocimientoid().toString()) .concat("/").concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedOmejora().getVtitulo()); historial.setVdescripcion(this.getSelectedOmejora().getVdescripcion()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedOmejora().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedOmejora().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedOmejora().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getContenidoPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedOmejora().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedOmejora().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("9"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); asignacion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); asignacion.setNusuarioid( serviceasig.getUserCreacionByContenido(this.getSelectedOmejora().getNtipoconocimientoid(), this.getSelectedOmejora().getNconocimientoid())); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); this.fSInfMod = "true"; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se envi la solicitud de informacin adicional."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void sendWikiRespuesta(ActionEvent event) { try {/*from www. java2 s .c o m*/ if (StringUtils.isBlank(this.getSelectedWiki().getVmsjrespuesta())) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Campo requerido. Ingrese el mensaje a enviar."); FacesContext.getCurrentInstance().addMessage(null, message); } else { //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.WIKI); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); this.getSelectedWiki().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedWiki().setVtitulo(StringUtils.upperCase(this.getSelectedWiki().getVtitulo())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedWiki().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedWiki() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedWiki().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedWiki().setDfechamodificacion(new Date()); this.getSelectedWiki().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedWiki().setVmsjrespuesta(this.getSelectedWiki().getVmsjrespuesta().toUpperCase()); conocimientoService.saveOrUpdate(this.getSelectedWiki()); GcmFileUtils.writeStringToFileServer(this.getSelectedWiki().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedWiki().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedWiki().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathwk.concat(this.getSelectedWiki().getNconocimientoid().toString()).concat("/") .concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.WIKI); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedWiki().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedWiki().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedWiki().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedWiki().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedWiki().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedWiki().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("10"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.WIKI); asignacion.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid(categoriaService.getCategoriaById(this.getSelectedWiki().getNcategoriaid()) .getNmoderador()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); this.fSInfMod = "true"; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Solicitud de informacin respondida."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void sendBpracticaRespuesta(ActionEvent event) { try {/*from w ww .j a v a 2 s . co m*/ if (StringUtils.isBlank(this.getSelectedBpractica().getVmsjrespuesta())) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Campo requerido. Ingrese el mensaje a enviar."); FacesContext.getCurrentInstance().addMessage(null, message); } else { //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.BUENAPRACTICA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedBpractica().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedBpractica() .setVtitulo(StringUtils.upperCase(this.getSelectedBpractica().getVtitulo().trim())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedBpractica().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedBpractica() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedBpractica() .setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedBpractica().setDfechamodificacion(new Date()); this.getSelectedBpractica().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedBpractica() .setVmsjrespuesta(this.getSelectedBpractica().getVmsjrespuesta().toUpperCase()); conocimientoService.saveOrUpdate(this.getSelectedBpractica()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedBpractica().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathbp.concat(this.getSelectedBpractica().getNconocimientoid().toString()) .concat("/").concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.BUENAPRACTICA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedBpractica().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedBpractica().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedBpractica().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedBpractica().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedBpractica().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedBpractica().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("10"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.BUENAPRACTICA); asignacion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid(categoriaService .getCategoriaById(this.getSelectedBpractica().getNcategoriaid()).getNmoderador()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); this.fSInfMod = "true"; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se respondi la solicitud de informacin."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void sendOmejoraRespuesta(ActionEvent event) { try {//w ww .j a v a2s. c o m if (StringUtils.isBlank(this.getSelectedOmejora().getVmsjrespuesta())) { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Campo requerido. Ingrese el mensaje a enviar."); FacesContext.getCurrentInstance().addMessage(null, message); } else { //this.setContenidoHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.OPORTUNIDADMEJORA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedOmejora().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedOmejora().setVtitulo(StringUtils.upperCase(this.getSelectedOmejora().getVtitulo())); this.getSelectedOmejora() .setVdescripcion(StringUtils.upperCase(this.getSelectedOmejora().getVdescripcion())); if (this.getContenidoPlain().length() < 400) { this.getSelectedOmejora().setVcontenido(StringUtils.capitalize(this.getContenidoPlain())); } else { this.getSelectedOmejora() .setVcontenido(StringUtils.capitalize(this.getContenidoPlain().substring(0, 399))); } this.getSelectedOmejora().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedOmejora().setDfechamodificacion(new Date()); this.getSelectedOmejora().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedOmejora() .setVmsjrespuesta(this.getSelectedOmejora().getVmsjrespuesta().toUpperCase()); conocimientoService.saveOrUpdate(this.getSelectedOmejora()); this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "plain.txt", this.getContenidoPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedOmejora().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathom.concat(this.getSelectedOmejora().getNconocimientoid().toString()) .concat("/").concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedOmejora().getVtitulo()); historial.setVdescripcion(this.getSelectedOmejora().getVdescripcion()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedOmejora().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedOmejora().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedOmejora().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getContenidoPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedOmejora().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedOmejora().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("10"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); asignacion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid(categoriaService .getCategoriaById(this.getSelectedOmejora().getNcategoriaid()).getNmoderador()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); this.fSInfMod = "true"; FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Respuesta de la solicitud de informacin enviada."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public String publicarWiki() { String pagina = null;/*from w w w.ja v a 2 s . co m*/ try { //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.WIKI); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return ""; } } LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); this.getSelectedWiki().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedWiki().setVtitulo(StringUtils.upperCase(this.getSelectedWiki().getVtitulo())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedWiki().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedWiki() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedWiki().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedWiki().setDfechamodificacion(new Date()); this.getSelectedWiki().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedWiki().setNsituacionid(BigDecimal.valueOf((long) 6)); this.getSelectedWiki().setDfechapublicacion(new Date()); conocimientoService.saveOrUpdate(this.getSelectedWiki()); GcmFileUtils.writeStringToFileServer(this.getSelectedWiki().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedWiki().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedWiki().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathwk.concat(this.getSelectedWiki().getNconocimientoid().toString()).concat("/") .concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.WIKI); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedWiki().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedWiki().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedWiki().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedWiki().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedWiki().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedWiki().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedWiki().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("8"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); loginMB.refreshNotifications(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se public el wiki."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } return pagina; }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void publicarBpractica(ActionEvent event) { try {// ww w. j ava2s . com //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.BUENAPRACTICA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedBpractica().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedBpractica() .setVtitulo(StringUtils.upperCase(this.getSelectedBpractica().getVtitulo().trim())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedBpractica().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedBpractica() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedBpractica().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedBpractica().setDfechamodificacion(new Date()); this.getSelectedBpractica().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedBpractica().setNsituacionid(BigDecimal.valueOf((long) 6)); this.getSelectedBpractica().setDfechapublicacion(new Date()); conocimientoService.saveOrUpdate(this.getSelectedBpractica()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedBpractica().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathbp.concat(this.getSelectedBpractica().getNconocimientoid().toString()).concat("/") .concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.BUENAPRACTICA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedBpractica().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedBpractica().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedBpractica().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedBpractica().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedBpractica().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedBpractica().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("8"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); loginMB.refreshNotifications(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se public la buena prctica."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void publicarOmejora(ActionEvent event) { try {/*from ww w .j av a 2 s. co m*/ //this.setContenidoHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.OPORTUNIDADMEJORA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedOmejora().setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); this.getSelectedOmejora().setVtitulo(StringUtils.upperCase(this.getSelectedOmejora().getVtitulo())); this.getSelectedOmejora() .setVdescripcion(StringUtils.upperCase(this.getSelectedOmejora().getVdescripcion())); if (this.getContenidoPlain().length() < 400) { this.getSelectedOmejora().setVcontenido(StringUtils.capitalize(this.getContenidoPlain())); } else { this.getSelectedOmejora() .setVcontenido(StringUtils.capitalize(this.getContenidoPlain().substring(0, 399))); } this.getSelectedOmejora().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedOmejora().setDfechamodificacion(new Date()); this.getSelectedOmejora().setVusuariomodificacion(usuario.getVlogin()); this.getSelectedOmejora() .setNsituacionid(BigDecimal.valueOf(Long.parseLong(Constante.SITUACION_VERIFICADO))); this.getSelectedOmejora().setDfechapublicacion(new Date()); conocimientoService.saveOrUpdate(this.getSelectedOmejora()); this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedOmejora().getVruta(), "plain.txt", this.getContenidoPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedOmejora().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathom.concat(this.getSelectedOmejora().getNconocimientoid().toString()).concat("/") .concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedOmejora().getVtitulo()); historial.setVdescripcion(this.getSelectedOmejora().getVdescripcion()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedOmejora().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedOmejora().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedOmejora().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getContenidoPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedOmejora().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedOmejora().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("8"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); asignacion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid(categoriaService.getCategoriaById(this.getSelectedOmejora().getNcategoriaid()) .getNespecialista()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se public la oportunidad de mejora."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void implementarOmejora(ActionEvent event) { try {/*from w w w . j a v a 2 s . co m*/ //this.setContenidoHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.OPORTUNIDADMEJORA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ImplementacionService implementacionService = (ImplementacionService) ServiceFinder .findBean("ImplementacionService"); Implementacion implementacion = new Implementacion(); implementacion.setNimplementacionid(implementacionService.getNextPK()); implementacion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); implementacion.setNtipoconocimientoid(this.getSelectedOmejora().getNtipoconocimientoid()); implementacion.setNcategoriaid(this.getSelectedOmejora().getNcategoriaid()); implementacion.setVtitulo(StringUtils.upperCase(this.getSelectedOmejora().getVtitulo())); implementacion.setVdescripcion(StringUtils.upperCase(this.getSelectedOmejora().getVdescripcion())); if (this.getContenidoPlain().length() < 400) { implementacion.setVcontenido(StringUtils.capitalize(this.getContenidoPlain())); } else { implementacion.setVcontenido(StringUtils.capitalize(this.getContenidoPlain().substring(0, 399))); } implementacion.setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); implementacion.setDfechacreacion(new Date()); implementacion.setVusuariocreacion(usuario.getVlogin()); implementacion.setNsituacionid(BigDecimal.valueOf((long) 11)); implementacionService.saveOrUpdate(implementacion); String np = this.pathom.concat(this.getSelectedOmejora().getNconocimientoid().toString()) .concat("/impl/"); this.setContenidoPlain(Jsoup.parse(this.getContenidoHtml()).text()); GcmFileUtils.writeStringToFileServer(np, "html.txt", this.getContenidoHtml()); GcmFileUtils.writeStringToFileServer(np, "plain.txt", this.getContenidoPlain()); this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoImplementacionService vinculoService = (VinculoImplementacionService) ServiceFinder .findBean("VinculoImplementacionService"); vinculoService.deleteByConocimiento(implementacion.getNimplementacionid()); for (Consulta consulta : this.getListaTargetVinculos()) { VinculoImplementacion vinculo = new VinculoImplementacion(); vinculo.setNimplvinculoid(vinculoService.getNextPK()); vinculo.setNimplementacionid(implementacion.getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); } } ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); this.getSelectedOmejora().setNsituacionid(BigDecimal.valueOf((long) 11)); conocimientoService.saveOrUpdate(this.getSelectedOmejora()); AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("15"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.OPORTUNIDADMEJORA); asignacion.setNconocimientoid(this.getSelectedOmejora().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid( categoriaService.getCategoriaById(this.getSelectedOmejora().getNcategoriaid()).getNmoderador()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); loginMB.refreshNotifications(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Se implement la oportunidad de mejora."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect("/gescon/index.xhtml"); } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java
public void saveBpracticaEdit(ActionEvent event) { String pagina = null;/* ww w . ja v a 2 s. c o m*/ try { //this.setDescripcionHtml(JSFUtils.getRequestParameter("descHtml")); if (this.getChkDestacado()) { ConsultaService consultaService = (ConsultaService) ServiceFinder.findBean("ConsultaService"); HashMap filter = new HashMap(); filter.put("ntipoconocimientoid", Constante.BUENAPRACTICA); BigDecimal cant = consultaService.countDestacadosByTipoConocimiento(filter); if (cant.intValue() >= 10) { this.setListaDestacados(consultaService.getDestacadosByTipoConocimiento(filter)); RequestContext.getCurrentInstance().execute("PF('destDialog').show();"); return; } } this.setDescripcionPlain(Jsoup.parse(this.getDescripcionHtml()).text()); LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User usuario = loginMB.getUser(); ConocimientoService conocimientoService = (ConocimientoService) ServiceFinder .findBean("ConocimientoService"); if (this.getSelectedCategoria() == null) { this.getSelectedBpractica().setNcategoriaid(this.getSelectedBpractica().getNcategoriaid()); cat_nueva = this.getSelectedBpractica().getNcategoriaid(); } else { this.getSelectedBpractica().setNcategoriaid(this.getSelectedBpractica().getNcategoriaid()); cat_nueva = this.getSelectedBpractica().getNcategoriaid(); } this.getSelectedBpractica() .setVtitulo(StringUtils.upperCase(this.getSelectedBpractica().getVtitulo().trim())); if (this.getDescripcionPlain().length() < 400) { this.getSelectedBpractica().setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain())); } else { this.getSelectedBpractica() .setVdescripcion(StringUtils.capitalize(this.getDescripcionPlain().substring(0, 399))); } this.getSelectedBpractica().setNdestacado(this.getChkDestacado() ? BigDecimal.ONE : BigDecimal.ZERO); this.getSelectedBpractica().setDfechamodificacion(new Date()); this.getSelectedBpractica().setVusuariomodificacion(usuario.getVlogin()); conocimientoService.saveOrUpdate(this.getSelectedBpractica()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(this.getSelectedBpractica().getVruta(), "plain.txt", this.getDescripcionPlain()); HistorialService historialService = (HistorialService) ServiceFinder.findBean("HistorialService"); Historial lastHistorial = historialService .getLastHistorialByConocimiento(this.getSelectedBpractica().getNconocimientoid()); int lastversion; if (lastHistorial != null) { lastversion = lastHistorial.getNnumversion().intValue(); } else { lastversion = 0; } String url = this.pathbp.concat(this.getSelectedBpractica().getNconocimientoid().toString()).concat("/") .concat(Integer.toString(lastversion + 1)).concat("/"); ThistorialId thistorialId = new ThistorialId(); thistorialId.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); thistorialId.setNhistorialid(historialService.getNextPK()); Historial historial = new Historial(); historial.setId(thistorialId); historial.setNtipoconocimientoid(Constante.BUENAPRACTICA); historial.setNcategoriaid(this.getSelectedCategoria().getNcategoriaid()); historial.setVtitulo(this.getSelectedBpractica().getVtitulo()); historial.setNactivo(BigDecimal.ONE); historial.setNsituacionid(this.getSelectedBpractica().getNsituacionid()); historial.setVruta(url); historial.setNnumversion(BigDecimal.valueOf(lastversion + 1)); historial.setDfechacreacion(new Date()); historial.setVusuariocreacion(usuario.getVlogin()); historial.setVmsjsolicita(this.getSelectedBpractica().getVmsjsolicita()); historial.setVmsjrespuesta(this.getSelectedBpractica().getVmsjrespuesta()); historialService.saveOrUpdate(historial); GcmFileUtils.writeStringToFileServer(url, "html.txt", this.getDescripcionHtml()); GcmFileUtils.writeStringToFileServer(url, "plain.txt", this.getDescripcionPlain()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaSeccion())) { String url0 = this.getSelectedBpractica().getVruta().concat("s"); String url1 = url.concat("s"); SeccionService seccionService = (SeccionService) ServiceFinder.findBean("SeccionService"); SeccionHistService seccionHistService = (SeccionHistService) ServiceFinder .findBean("SeccionHistService"); for (Seccion seccion : this.getListaSeccion()) { String ruta0 = url0.concat(seccion.getNorden().toString()).concat("/"); seccion.setVruta(ruta0); if (seccion.getNseccionid() != null) { seccion.setDfechamodificacion(new Date()); seccion.setVusuariomodificacion(usuario.getVlogin()); } else { seccion.setNseccionid(seccionService.getNextPK()); seccion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); seccion.setDfechacreacion(new Date()); seccion.setVusuariocreacion(usuario.getVlogin()); } seccionService.saveOrUpdate(seccion); seccion.setDetallePlain(Jsoup.parse(seccion.getDetalleHtml()).text()); GcmFileUtils.writeStringToFileServer(ruta0, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta0, "plain.txt", seccion.getDetallePlain()); String ruta1 = url1.concat(seccion.getNorden().toString()).concat("/"); TseccionHistId tseccionHistId = new TseccionHistId(); tseccionHistId.setNconocimientoid(thistorialId.getNconocimientoid()); tseccionHistId.setNhistorialid(thistorialId.getNhistorialid()); tseccionHistId.setNseccionhid(seccionHistService.getNextPK()); SeccionHist seccionHist = new SeccionHist(); seccionHist.setId(tseccionHistId); seccionHist.setNorden(seccion.getNorden()); seccionHist.setVruta(ruta1); seccionHist.setVtitulo(seccion.getVtitulo()); seccionHist.setVusuariocreacion(usuario.getVlogin()); seccionHist.setDfechacreacion(new Date()); seccionHistService.saveOrUpdate(seccionHist); GcmFileUtils.writeStringToFileServer(ruta1, "html.txt", seccion.getDetalleHtml()); GcmFileUtils.writeStringToFileServer(ruta1, "plain.txt", seccion.getDetallePlain()); } } this.setListaTargetVinculos(new ArrayList()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR()); this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK()); if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) { VinculoService vinculoService = (VinculoService) ServiceFinder.findBean("VinculoService"); VinculoHistService vinculoHistService = (VinculoHistService) ServiceFinder .findBean("VinculoHistService"); vinculoService.deleteByConocimiento(this.getSelectedBpractica().getNconocimientoid()); for (Consulta consulta : this.getListaTargetVinculos()) { Vinculo vinculo = new Vinculo(); vinculo.setNvinculoid(vinculoService.getNextPK()); vinculo.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); vinculo.setNconocimientovinc(consulta.getIdconocimiento()); vinculo.setNtipoconocimientovinc(consulta.getIdTipoConocimiento()); vinculo.setDfechacreacion(new Date()); vinculo.setVusuariocreacion(usuario.getVlogin()); vinculoService.saveOrUpdate(vinculo); TvinculoHistId vinculoHistId = new TvinculoHistId(); vinculoHistId.setNvinculohid(vinculoHistService.getNextPK()); vinculoHistId.setNconocimientoid(thistorialId.getNconocimientoid()); vinculoHistId.setNhistorialid(thistorialId.getNhistorialid()); VinculoHist vinculoHist = new VinculoHist(); vinculoHist.setId(vinculoHistId); vinculoHist.setNconocimientovinc(vinculo.getNconocimientovinc()); vinculoHist.setDfechacreacion(new Date()); vinculoHist.setVusuariocreacion(usuario.getVlogin()); vinculoHistService.saveOrUpdate(vinculoHist); } } if (cat_antigua != cat_nueva) { AsignacionService serviceasig = (AsignacionService) ServiceFinder.findBean("AsignacionService"); this.getSelectedAsignacion().setNestadoid(BigDecimal.valueOf(Long.parseLong("2"))); this.getSelectedAsignacion().setDfechaatencion(new Date()); this.getSelectedAsignacion().setNaccionid(BigDecimal.valueOf(Long.parseLong("12"))); serviceasig.saveOrUpdate(this.getSelectedAsignacion()); Asignacion asignacion = new Asignacion(); asignacion.setNasignacionid(serviceasig.getNextPK()); asignacion.setNtipoconocimientoid(Constante.BUENAPRACTICA); asignacion.setNconocimientoid(this.getSelectedBpractica().getNconocimientoid()); asignacion.setNestadoid(BigDecimal.valueOf(Long.parseLong("1"))); CategoriaService categoriaService = (CategoriaService) ServiceFinder.findBean("CategoriaService"); asignacion.setNusuarioid(categoriaService .getCategoriaById(this.getSelectedBpractica().getNcategoriaid()).getNmoderador()); asignacion.setDfechaasignacion(new Date()); asignacion.setDfechacreacion(new Date()); serviceasig.saveOrUpdate(asignacion); pagina = "/gescon/index.xhtml"; } else { pagina = ""; } loginMB.refreshNotifications(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "INFO.", "Actualizacin exitosa!."); FacesContext.getCurrentInstance().addMessage(null, message); FacesContext.getCurrentInstance().getExternalContext().redirect(pagina); } catch (Exception e) { e.getMessage(); e.printStackTrace(); } }