1021 lines
34 KiB
Plaintext
Executable File
1021 lines
34 KiB
Plaintext
Executable File
package com.fp.frontend.controller.pcustomer;
|
||
|
||
import java.awt.image.BufferedImage;
|
||
import java.io.ByteArrayInputStream;
|
||
import java.io.File;
|
||
import java.io.IOException;
|
||
import java.io.InputStream;
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.UUID;
|
||
|
||
import javax.annotation.PostConstruct;
|
||
import javax.faces.bean.ManagedBean;
|
||
import javax.faces.bean.ManagedProperty;
|
||
import javax.faces.bean.ViewScoped;
|
||
import javax.faces.context.ExternalContext;
|
||
import javax.faces.context.FacesContext;
|
||
import javax.imageio.ImageIO;
|
||
import javax.servlet.ServletContext;
|
||
|
||
import org.primefaces.event.FileUploadEvent;
|
||
import org.primefaces.event.SelectEvent;
|
||
import org.primefaces.model.DefaultStreamedContent;
|
||
import org.primefaces.model.StreamedContent;
|
||
import org.primefaces.model.UploadedFile;
|
||
|
||
import com.fp.dto.AbstractDataTransport;
|
||
import com.fp.dto.Request;
|
||
import com.fp.dto.Response;
|
||
import com.fp.dto.helper.FileHelper;
|
||
import com.fp.dto.save.DtoSave;
|
||
import com.fp.frontend.controller.AbstractController;
|
||
import com.fp.frontend.controller.pcustomer.lov.PersonLovController;
|
||
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
||
import com.fp.frontend.controller.pgeneral.lov.ActivityLovController;
|
||
import com.fp.frontend.helper.MessageHelper;
|
||
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
||
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
||
import com.fp.persistence.pcustomer.gene.TcustPersonPhone;
|
||
import com.fp.persistence.pcustomer.gene.TgeneActivity;
|
||
import com.fp.persistence.pcustomer.people.TcustPeople;
|
||
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
||
import com.fp.persistence.pgeneral.image.TgeneFilesDetail;
|
||
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
||
|
||
/**
|
||
* Clase controladora del bean TsafeUserDetail.
|
||
*
|
||
* @author Jorge Vaca.
|
||
* @version 2.1
|
||
*/
|
||
@ManagedBean
|
||
@ViewScoped
|
||
public class PeopleFastController extends AbstractController<AbstractDataTransport> {
|
||
|
||
private static final long serialVersionUID = 1L;
|
||
|
||
@ManagedProperty(value = "#{personDetailController}")
|
||
private PersonDetailController persondetail;
|
||
|
||
@ManagedProperty(value = "#{peopleController}")
|
||
private PeopleController people;
|
||
|
||
@ManagedProperty(value = "#{personAddressController}")
|
||
private PersonAddressController address;
|
||
|
||
@ManagedProperty(value = "#{personPhoneController}")
|
||
private PersonPhoneController phones;
|
||
|
||
@ManagedProperty(value = "#{fileDetailController}")
|
||
private FileDetailController fileDetail;
|
||
|
||
private List<TcustPersonAddress> direccionesEliminadas=new ArrayList<TcustPersonAddress>();
|
||
private List<TcustPersonPhone> telefonosEliminados=new ArrayList<TcustPersonPhone>();
|
||
private List<TgeneCatalogDetail> profesionList = new ArrayList<TgeneCatalogDetail>();
|
||
private List<TgeneCatalogDetail> estadocivilList = new ArrayList<TgeneCatalogDetail>();
|
||
private List<TgeneCatalogDetail> militarygrades;
|
||
|
||
/**
|
||
* Id de profesion
|
||
*/
|
||
private String idProfesion;
|
||
|
||
/**
|
||
* Estado civil
|
||
*/
|
||
private String idEstadoCivil;
|
||
|
||
private String imageUrl;
|
||
|
||
|
||
|
||
public PeopleFastController() throws Exception {
|
||
super(AbstractDataTransport.class);
|
||
}
|
||
|
||
/**
|
||
* Atributo para la lista de objetos TgeneCatalogDetail de identificacion
|
||
*/
|
||
private List<TgeneCatalogDetail> lidentification;
|
||
|
||
/**
|
||
* Atributo para la lista de objetos TgeneCatalogDetail de tipo de cliente
|
||
*/
|
||
private List<TgeneCatalogDetail> ltypeclient;
|
||
|
||
/**
|
||
* Atributo para la lista de objetos TgeneCatalogDetail de sector económico
|
||
*/
|
||
private List<TgeneCatalogDetail> leconomicsector;
|
||
|
||
/**
|
||
* Atributo para la lista de objetos TgeneCatalogDetail de actividad no económica
|
||
*/
|
||
private List<TgeneCatalogDetail> lnotactivity;
|
||
|
||
/**
|
||
* Atributo para el listado de géneros
|
||
*/
|
||
private List<String[]> lgender;
|
||
|
||
/**
|
||
* Atributo para activar el keyFilter
|
||
*/
|
||
private boolean activeRegEx;
|
||
|
||
/**
|
||
* Atributo para la longitud de la identificación
|
||
*/
|
||
private String lengthId;
|
||
|
||
/**
|
||
* atributo para el código de persona
|
||
*/
|
||
private String personcode;
|
||
|
||
private boolean flagHabilita;
|
||
|
||
/**
|
||
* Atributo para la firma digital
|
||
*/
|
||
UploadedFile selectedSign;
|
||
Boolean firmaCargada=false;
|
||
StreamedContent firma;
|
||
String rutaFirma;
|
||
TsafeUserDetail usuario;
|
||
|
||
UploadedFile selectedPicture;
|
||
Boolean fotoCargada=false;
|
||
StreamedContent foto;
|
||
String rutaFoto;
|
||
String extensionFoto = "jpg";
|
||
String extensionFirma = "jpg";
|
||
List<FileHelper> fileH = new ArrayList<FileHelper>();
|
||
|
||
@PostConstruct
|
||
private void postconstruct() {
|
||
|
||
this.lengthId = "10";
|
||
this.init();
|
||
// Inicializa autoconsulta
|
||
super.startQuery();
|
||
|
||
// LLenamos Listas
|
||
this.lidentification = CatalogDetailController.find("IDENTIFICATION", "1");
|
||
this.leconomicsector = CatalogDetailController.find("ECONOMICSECTOR");
|
||
this.ltypeclient = CatalogDetailController.find("PERSONTYPE");
|
||
this.lnotactivity = CatalogDetailController.find("NOTACTIVITY");
|
||
this.estadocivilList = CatalogDetailController.find("MARITALSTATUS");
|
||
this.profesionList = CatalogDetailController.find("PROFESSION");
|
||
this.militarygrades=CatalogDetailController.find("MILITARYGRADE");
|
||
this.lgender = CatalogDetailController.getListGender();
|
||
}
|
||
|
||
/**
|
||
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
||
*/
|
||
private void init() {
|
||
try {
|
||
this.personcode = null;
|
||
this.lrecord = new ArrayList<>();
|
||
this.beanalias = "PEOPLEFAST";
|
||
|
||
//Obteniendo los datos del usuario logueado
|
||
this.usuario=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
||
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
@SuppressWarnings("static-access")
|
||
@Override
|
||
protected void querydatabase() {
|
||
try {
|
||
|
||
if ((super.getFieldvalue("pk.personcode") == null) || super.getFieldvalue("pk.personcode").equals("")) {
|
||
MessageHelper.setMessageError("msg_filterrequird");
|
||
return;
|
||
}
|
||
this.personcode = String.valueOf(super.getFieldvalue("pk.personcode"));
|
||
|
||
//Request request = this.callerhelper.getRequest();
|
||
|
||
this.persondetail.addPersoncodeFilter(this.personcode);
|
||
this.persondetail.query();
|
||
|
||
this.people.addPersoncodeFilter(this.personcode);
|
||
this.people.query();
|
||
|
||
//Cargando la firma y la foto
|
||
if(people.getRecord()!=null){
|
||
if(super.getFieldvalue("personname")!=null){
|
||
people.getRecord().setFirstname(super.getFieldvalue("personname").toString());
|
||
}
|
||
//Firma
|
||
if(people.getRecord().getSignaturecode()!=null){
|
||
TgeneFilesDetail fileDetalle = fileDetail.find(String.valueOf(people.getRecord().getSignaturecode()));
|
||
extensionFirma = fileDetalle!=null?fileDetalle.getExtension():extensionFirma;
|
||
|
||
if(fileDetalle!= null && fileDetalle.getImage()!=null){
|
||
InputStream input=new ByteArrayInputStream(fileDetalle.getImage());
|
||
this.firma=new DefaultStreamedContent(input);
|
||
this.firmaCargada=true;
|
||
|
||
//Almacenando la imagen temporalmente
|
||
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
|
||
ServletContext servletContext = (ServletContext) externalContext.getContext();
|
||
|
||
String tempUrl = servletContext.getRealPath("/");;
|
||
String imageName=UUID.randomUUID().toString();
|
||
imageUrl=tempUrl + "resources/images/" + imageName +"."+extensionFirma;
|
||
imageUrl = imageUrl.replace("\\", "/");
|
||
File outputfile = new File(imageUrl);
|
||
BufferedImage image=ImageIO.read(input);
|
||
ImageIO.write(image, extensionFirma, outputfile);
|
||
|
||
this.rutaFirma="/resources/images/"+imageName+"."+extensionFirma;
|
||
}else{
|
||
this.firma=null;
|
||
imageUrl=null;
|
||
this.rutaFirma=null;
|
||
this.firmaCargada=false;
|
||
}
|
||
}else{
|
||
this.firma=null;
|
||
imageUrl=null;
|
||
this.rutaFirma=null;
|
||
this.firmaCargada=false;
|
||
}
|
||
//Foto
|
||
if(people.getRecord().getPhotocode()!=null){
|
||
TgeneFilesDetail fileDetalle = fileDetail.find(String.valueOf(people.getRecord().getPhotocode()));
|
||
extensionFoto = fileDetalle!=null?fileDetalle.getExtension():extensionFoto;
|
||
|
||
if(fileDetalle!=null && fileDetalle.getImage()!=null){
|
||
InputStream input=new ByteArrayInputStream(fileDetalle.getImage());
|
||
this.foto=new DefaultStreamedContent(input);
|
||
this.fotoCargada=true;
|
||
|
||
//Almacenando la imagen temporalmente
|
||
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
|
||
ServletContext servletContext = (ServletContext) externalContext.getContext();
|
||
|
||
String tempUrl = servletContext.getRealPath("/");;
|
||
String imageName=UUID.randomUUID().toString();
|
||
imageUrl=tempUrl + "resources/images/" + imageName +"."+extensionFoto;
|
||
imageUrl = imageUrl.replace("\\", "/");
|
||
File outputfile = new File(imageUrl);
|
||
BufferedImage image=ImageIO.read(input);
|
||
ImageIO.write(image, extensionFoto, outputfile);
|
||
this.rutaFoto="/resources/images/"+imageName+"."+extensionFoto;
|
||
}else{
|
||
this.foto=null;
|
||
imageUrl=null;
|
||
this.rutaFoto=null;
|
||
this.fotoCargada=false;
|
||
}
|
||
}else{
|
||
this.foto=null;
|
||
imageUrl=null;
|
||
this.rutaFoto=null;
|
||
this.fotoCargada=false;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
this.address.addPersoncodeFilter(this.personcode);
|
||
this.address.addFilterDateto();
|
||
this.address.query();
|
||
|
||
this.phones.addPersoncodeFilter(this.personcode);
|
||
this.phones.addFilterDateto();
|
||
this.phones.query();
|
||
} catch (Throwable e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void save() {
|
||
try {
|
||
Request request = this.callerhelper.getRequest();
|
||
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
||
if(this.persondetail.getRecord().getPk() == null || this.persondetail.getRecord().getPk().getPersoncode() == null){
|
||
TcustPersonDetail per=PersonDetailController.findByIdentification(this.persondetail.getRecord().getIdentification());
|
||
if(per != null && per.getIdentification()!=null){
|
||
MessageHelper.setMessageError("C<>DULA YA REGISTRADA");
|
||
return;
|
||
}
|
||
}
|
||
if ((this.personcode != null) && !this.personcode.equals("")) {
|
||
request.put("personcode", this.personcode);
|
||
request.put("identification", this.persondetail.getRecord().getIdentification());
|
||
// this.reqAddressPhone();
|
||
} else {
|
||
if (this.address.getLrecord().size() == 0) {
|
||
MessageHelper.setMessageError("msg_requireAddress");
|
||
return;
|
||
}
|
||
if (this.phones.getLrecord().size() == 0) {
|
||
MessageHelper.setMessageError("msg_requirePhones");
|
||
return;
|
||
}
|
||
}
|
||
|
||
//Asignando la foto
|
||
if(this.selectedPicture!=null){
|
||
this.persondetail.getRecord().setPicture(this.selectedPicture.getContents());
|
||
request.getModifiedData().put("EXTENSION", this.extensionFoto);
|
||
request.getModifiedData().put("NAME", this.selectedPicture.getFileName());
|
||
}
|
||
|
||
if(this.persondetail.getRecord().getMilitarygrade()!=null){
|
||
this.persondetail.getRecord().setMilitarygradecode("MILITARYGRADE");
|
||
}
|
||
|
||
//Asignando la firma
|
||
if(this.selectedSign!=null){
|
||
this.persondetail.getRecord().setSign(this.selectedSign.getContents());
|
||
}
|
||
|
||
// Preparamos los objetos a ser enviados
|
||
this.persondetail.update();
|
||
this.people.update();
|
||
|
||
// Definimos los formularios
|
||
DtoSave dtoSavePerson = this.persondetail.getDtoSave(true);
|
||
DtoSave dtoSavePeople = this.people.getDtoSave(true);
|
||
DtoSave dtoSaveAddress = this.address.getDtoSave(true);
|
||
DtoSave dtoSavePhone = this.phones.getDtoSave(true);
|
||
|
||
// Verificamos y agregamos al request
|
||
if (dtoSavePeople.pendingProcess()) {
|
||
this.persondetail.getRecord().setName(this.people.getRecord().getFirstname());
|
||
// this.people.getRecord().getLastname());
|
||
//+ " " + this.people.getRecord().getSurename() + " "
|
||
// + this.people.getRecord().getFirstname() + " " + this.people.getRecord().getMiddlename()
|
||
dtoSavePerson = this.persondetail.getDtoSave(true);
|
||
msave.put(this.people.getBeanalias(), dtoSavePeople);
|
||
}
|
||
if (dtoSavePerson.pendingProcess()) {
|
||
msave.put(this.persondetail.getBeanalias(), dtoSavePerson);
|
||
}
|
||
if (dtoSaveAddress.pendingProcess()) {
|
||
msave.put(this.address.getBeanalias(), dtoSaveAddress);
|
||
}
|
||
if (dtoSavePhone.pendingProcess()) {
|
||
msave.put(this.phones.getBeanalias(), dtoSavePhone);
|
||
}
|
||
|
||
request.setSaveTables(msave);
|
||
|
||
request.getModifiedData().put("DETALLESPERSONA", persondetail.getRecord());
|
||
request.getModifiedData().put("DIRECCIONESELIMINADAS",this.direccionesEliminadas);
|
||
request.getModifiedData().put("TELEFONOSELIMINADOS", this.telefonosEliminados);
|
||
|
||
|
||
request.getModifiedData().put("USUARIO", this.usuario);
|
||
|
||
guardarInformacionImagenes();
|
||
|
||
request.getModifiedData().put("file", fileH);
|
||
request.getModifiedData().put("photocode",people.getRecord()!=null?people.getRecord().getPhotocode():null);
|
||
request.getModifiedData().put("signaturecode", people.getRecord()!=null?people.getRecord().getSignaturecode():null);
|
||
request.getModifiedData().put("pk_personcode", people.getRecord()!=null?people.getRecord().getPk().getPersoncode():null);
|
||
|
||
Response resp = this.callerhelper.executeSave(request);
|
||
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
||
this.postCommit(resp);
|
||
this.people.postCommit(resp);
|
||
this.persondetail.postCommit(resp);
|
||
this.address.postCommit(resp);
|
||
this.phones.postCommit(resp);
|
||
MessageHelper.setMessageInfo(resp);
|
||
} else {
|
||
MessageHelper.setMessageError(resp);
|
||
}
|
||
|
||
} catch (Throwable e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Metodo para guardar informacion de las imagenes en la base de datos
|
||
* @throws IOException
|
||
*/
|
||
private void guardarInformacionImagenes() throws IOException{
|
||
FileHelper archivoPicture = new FileHelper();
|
||
archivoPicture.setName("");
|
||
|
||
fileH = new ArrayList<FileHelper>();
|
||
|
||
if(selectedPicture!=null){
|
||
long size = selectedPicture.getSize();
|
||
InputStream stream = selectedPicture.getInputstream();
|
||
byte[] buffer = new byte[(int) size];
|
||
stream.read(buffer, 0, (int) size);
|
||
stream.close();
|
||
archivoPicture.setContentType(selectedPicture.getContentType());
|
||
archivoPicture.setExtension(extensionFoto);
|
||
archivoPicture.setImage(buffer);
|
||
archivoPicture.setName(selectedPicture.getFileName());
|
||
archivoPicture.setSize(selectedPicture.getFileName().length());
|
||
}
|
||
fileH.add(archivoPicture);
|
||
|
||
|
||
FileHelper archivoFirma = new FileHelper();
|
||
archivoFirma.setName("");
|
||
|
||
if(selectedSign!=null){
|
||
long sizeFirma = selectedSign.getSize();
|
||
InputStream streamFirma = selectedSign.getInputstream();
|
||
byte[] bufferFirma = new byte[(int) sizeFirma];
|
||
streamFirma.read(bufferFirma, 0, (int) sizeFirma);
|
||
streamFirma.close();
|
||
archivoFirma.setContentType(selectedSign.getContentType());
|
||
archivoFirma.setExtension(extensionFirma);
|
||
archivoFirma.setImage(bufferFirma);
|
||
archivoFirma.setName(selectedSign.getFileName());
|
||
archivoFirma.setSize(selectedSign.getFileName().length());
|
||
}
|
||
fileH.add(archivoFirma);
|
||
}
|
||
|
||
|
||
@Override
|
||
public void postCommit(Response response) throws Exception {
|
||
this.persondetail.postCommit(response);
|
||
}
|
||
|
||
/**
|
||
* Elimina una direccion
|
||
*/
|
||
public void removeAddress(TcustPersonAddress direccion){
|
||
try {
|
||
this.direccionesEliminadas.add(direccion);
|
||
//this.address.setRecord(direccion);
|
||
//this.address.getRecord().getPk().setDateto(new Timestamp(Calendar.getInstance().getTimeInMillis()));
|
||
//this.address.update();
|
||
this.address.remove();
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Elimina una telefono
|
||
*/
|
||
public void removePhone(TcustPersonPhone telefono){
|
||
try {
|
||
this.telefonosEliminados.add(telefono);
|
||
this.phones.remove();
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Verifica los valores requeridos
|
||
*
|
||
* @throws Exception
|
||
*/
|
||
public void reqAddressPhone() throws Exception {
|
||
if (this.activity(this.persondetail.getRecord(), this.people.getRecord())) {
|
||
MessageHelper.setMessageError("msg_requireActivity");
|
||
return;
|
||
}
|
||
if (!this.address.getDtoSave().pendingProcess()) {
|
||
MessageHelper.setMessageError("msg_requireAddress");
|
||
return;
|
||
}
|
||
if (!this.phones.getDtoSave().pendingProcess()) {
|
||
MessageHelper.setMessageError("msg_requirePhones");
|
||
return;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Verifica el ingreso de una actividad económica
|
||
*
|
||
* @param person Objeto TcustPersonDetail
|
||
* @param people Objeto TcustPeople
|
||
* @return result V/F
|
||
*/
|
||
private boolean activity(TcustPersonDetail person, TcustPeople people) {
|
||
boolean result = false;
|
||
if (((person.getActivitycode() == null) || person.getActivitycode().equals(""))
|
||
&& ((people.getNotactivitycatalog() == null) || people.getNotactivitycatalog().equals(""))) {
|
||
result = true;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* Ejecuta el evento change del combo actividad no económica
|
||
*/
|
||
public void onChangeNotactivity() {
|
||
this.people.getRecord().setNotactivitycatalogcode("NOTACTIVITY");
|
||
this.persondetail.getRecord().setActivitycode(null);
|
||
this.persondetail.getRecord().put("activitydesc", null);
|
||
this.persondetail.getRecord().put("segmenttypecatalog", null);
|
||
this.persondetail.getRecord().put("segmentdesc", null);
|
||
}
|
||
|
||
public String getImageUrl() {
|
||
return imageUrl;
|
||
}
|
||
|
||
public void setImageUrl(String imageUrl) {
|
||
this.imageUrl = imageUrl;
|
||
}
|
||
|
||
public String getIdProfesion() {
|
||
return idProfesion;
|
||
}
|
||
|
||
public void setIdProfesion(String idProfesion) {
|
||
this.idProfesion = idProfesion;
|
||
}
|
||
|
||
/**
|
||
* Método para abrir el lov de personas
|
||
*/
|
||
public void openPersonLov() {
|
||
Map<String, List<String>> params = new HashMap<>();
|
||
List<String> natural = new ArrayList<String>();
|
||
natural.add("CED");
|
||
params.put("natural", natural);
|
||
PersonLovController.openLov(params);
|
||
}
|
||
|
||
/**
|
||
* Retorna los valores del lov
|
||
*
|
||
* @param event Evento ajax
|
||
* @throws Exception
|
||
*/
|
||
public void onReturnPersonLov(SelectEvent event) throws Exception {
|
||
TcustPersonDetail t = (TcustPersonDetail) event.getObject();
|
||
super.addField("pk.personcode", t.getPk().getPersoncode().toString());
|
||
super.addField("personname", t.getName());
|
||
super.query();
|
||
}
|
||
|
||
/**
|
||
* Método que abre el lov de activudad económica
|
||
*/
|
||
public void openActivityLov() {
|
||
Map<String, List<String>> params = new HashMap<>();
|
||
ActivityLovController.openLov(params);
|
||
}
|
||
|
||
/**
|
||
* Controla la respuesta del lov de activudad económica
|
||
*
|
||
* @param event
|
||
* @throws Exception
|
||
*/
|
||
public void onReturnActivityLov(SelectEvent event) throws Exception {
|
||
TgeneActivity t = (TgeneActivity) event.getObject();
|
||
this.people.getRecord().setNotactivitycatalog(null);
|
||
this.people.getRecord().setNotactivitycatalogcode(null);
|
||
this.persondetail.getRecord().setActivitycode(t.getPk());
|
||
this.persondetail.getRecord().modifiedData.put("activitydesc", t.getDescription());
|
||
this.persondetail.getRecord().modifiedData.put("segmenttypecatalog", t.getSegmenttypecatalog());
|
||
this.persondetail.getRecord().modifiedData.put("segmentdesc", t.get("segmentdesc"));
|
||
}
|
||
|
||
public void onChangeId() {
|
||
if (this.persondetail.getRecord().getIdentificationcatalog().compareTo("CED") == 0) {
|
||
this.lengthId = "10";
|
||
this.activeRegEx = false;
|
||
} else if (this.persondetail.getRecord().getIdentificationcatalog().compareTo("RUC") == 0) {
|
||
this.lengthId = "13";
|
||
this.activeRegEx = false;
|
||
} else if (this.persondetail.getRecord().getIdentificationcatalog().compareTo("PAS") == 0) {
|
||
this.lengthId = "13";
|
||
this.activeRegEx = true;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Metodo que carga la firma digital
|
||
*/
|
||
public void uploadSign(FileUploadEvent event){
|
||
try {
|
||
selectedSign = event.getFile();
|
||
|
||
InputStream is=new ByteArrayInputStream(selectedSign.getContents());
|
||
this.firma=new DefaultStreamedContent(is, selectedSign.getContentType(), selectedSign.getFileName());
|
||
this.firmaCargada=true;
|
||
|
||
|
||
|
||
//Obteniendo la extension de la imagen
|
||
extensionFirma="";
|
||
int pos=-1;
|
||
for (int i = selectedSign.getFileName().length()-1; i>=0; i--) {
|
||
if(selectedSign.getFileName().toCharArray()[i]=='.'){
|
||
pos=i;
|
||
break;
|
||
}
|
||
}
|
||
if(pos!=-1){
|
||
extensionFirma=selectedSign.getFileName().substring(pos+1, selectedSign.getFileName().length());
|
||
}
|
||
|
||
//Almacenando la imagen temporalmente
|
||
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
|
||
ServletContext servletContext = (ServletContext) externalContext.getContext();
|
||
String tempUrl = servletContext.getRealPath("/");
|
||
String imageName=UUID.randomUUID().toString();
|
||
//String imageUrl=servletContext.getRealPath(tempUrl)+File.separator+imageName+"."+extension;
|
||
imageUrl=tempUrl + "resources/images/" + imageName +"."+extensionFirma;
|
||
imageUrl = imageUrl.replace("\\", "/");
|
||
File outputfile = new File(imageUrl);
|
||
InputStream input=new ByteArrayInputStream(selectedSign.getContents());
|
||
BufferedImage image=ImageIO.read(input);
|
||
ImageIO.write(image, extensionFirma, outputfile);
|
||
|
||
this.rutaFirma="/resources/images/"+imageName+"."+extensionFirma;
|
||
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Metodo que carga la foto
|
||
*/
|
||
@SuppressWarnings("unused")
|
||
public void uploadPicture(FileUploadEvent event){
|
||
try {
|
||
selectedPicture = event.getFile();
|
||
|
||
InputStream is=new ByteArrayInputStream(selectedPicture.getContents());
|
||
this.foto=new DefaultStreamedContent(is, selectedPicture.getContentType(), selectedPicture.getFileName());
|
||
this.fotoCargada=true;
|
||
|
||
|
||
/* long size = selectedPicture.getSize();
|
||
InputStream stream = selectedPicture.getInputstream();
|
||
byte[] buffer = new byte[(int) size];
|
||
stream.read(buffer, 0, (int) size);
|
||
stream.close();*/
|
||
|
||
//Obteniendo la extension de la imagen
|
||
this.extensionFoto="";
|
||
int pos=-1;
|
||
for (int i = selectedPicture.getFileName().length()-1; i>=0; i--) {
|
||
if(selectedPicture.getFileName().toCharArray()[i]=='.'){
|
||
pos=i;
|
||
break;
|
||
}
|
||
}
|
||
if(pos!=-1){
|
||
extensionFoto=selectedPicture.getFileName().substring(pos+1, selectedPicture.getFileName().length());
|
||
}
|
||
|
||
//Almacenando la imagen temporalmente
|
||
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
|
||
ServletContext servletContext = (ServletContext) externalContext.getContext();
|
||
|
||
String tempUrl = servletContext.getRealPath("/");;
|
||
String imageName=UUID.randomUUID().toString();
|
||
imageUrl=tempUrl + "resources/images/" + imageName +"."+extensionFoto;
|
||
imageUrl = imageUrl.replace("\\", "/");
|
||
File outputfile = new File(imageUrl);
|
||
InputStream input=new ByteArrayInputStream(selectedPicture.getContents());
|
||
BufferedImage image=ImageIO.read(input);
|
||
Boolean saved=ImageIO.write(image, extensionFoto, outputfile);
|
||
|
||
this.rutaFoto="/resources/images/"+imageName+"."+extensionFoto;
|
||
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Entrega el valor de: persondetail
|
||
*
|
||
* @return PersonDetailController
|
||
*/
|
||
public PersonDetailController getPersondetail() {
|
||
return this.persondetail;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de: persondetail
|
||
*
|
||
* @param persondetail Valor a fijar en el atributo.
|
||
*/
|
||
public void setPersondetail(PersonDetailController persondetail) {
|
||
this.persondetail = persondetail;
|
||
}
|
||
|
||
/**
|
||
* Entrega el valor de: persondetail
|
||
*
|
||
* @return PersonDetailController
|
||
*/
|
||
public PeopleController getPeople() {
|
||
return this.people;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de: persondetail
|
||
*
|
||
* @param people Valor a fijar en el atributo.
|
||
*/
|
||
public void setPeople(PeopleController people) {
|
||
this.people = people;
|
||
}
|
||
|
||
/**
|
||
* Entrega el valor de: address
|
||
*
|
||
* @return PersonAddressController
|
||
*/
|
||
public PersonAddressController getAddress() {
|
||
return this.address;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de: address
|
||
*
|
||
* @param PersonAddressController
|
||
*/
|
||
public void setAddress(PersonAddressController address) {
|
||
this.address = address;
|
||
}
|
||
|
||
/**
|
||
* Entrega el valor de: phones
|
||
*
|
||
* @return PersonPhoneController
|
||
*/
|
||
public PersonPhoneController getPhones() {
|
||
return this.phones;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de: phones
|
||
*
|
||
* @param PersonPhoneController
|
||
*/
|
||
public void setPhones(PersonPhoneController phones) {
|
||
this.phones = phones;
|
||
}
|
||
|
||
/**
|
||
* Entrega lista de objetos TgeneCatalogDetail tipo de identificación
|
||
*
|
||
* @return lidentification Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public List<TgeneCatalogDetail> getLidentification() {
|
||
return this.lidentification;
|
||
}
|
||
|
||
/**
|
||
* Fija lista de objetos TgeneCatalogDetail tipo de identificación
|
||
*
|
||
* @param lidentification Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public void setLidentification(List<TgeneCatalogDetail> lidentification) {
|
||
this.lidentification = lidentification;
|
||
}
|
||
|
||
/**
|
||
* Entrega Verdadero/Falso
|
||
*
|
||
* @return activeNotEconomic V/F
|
||
*/
|
||
public boolean isActiveRegEx() {
|
||
return this.activeRegEx;
|
||
}
|
||
|
||
/**
|
||
* Fija Verdadero/Falso
|
||
*
|
||
* @param activeNotEconomic V/F
|
||
*/
|
||
public void setActiveRegEx(boolean activeRegEx) {
|
||
this.activeRegEx = activeRegEx;
|
||
}
|
||
|
||
/**
|
||
* Entrega el número de digitos para el tipo de identificaci&oacuye;n
|
||
*
|
||
* @return lengthId Número de digitos
|
||
*/
|
||
public String getLengthId() {
|
||
return this.lengthId;
|
||
}
|
||
|
||
/**
|
||
* Fija el número de digitos para el tipo de identificaci&oacuye;n
|
||
*
|
||
* @param lengthId Número de digitos
|
||
*/
|
||
public void setLengthId(String lengthId) {
|
||
this.lengthId = lengthId;
|
||
}
|
||
|
||
/**
|
||
* Entrega lista de objetos TgeneCatalogDetail de sector económico
|
||
*
|
||
* @return leconomicsector Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public List<TgeneCatalogDetail> getLeconomicsector() {
|
||
return this.leconomicsector;
|
||
}
|
||
|
||
/**
|
||
* Fija lista de objetos TgeneCatalogDetail de sector económico
|
||
*
|
||
* @param leconomicsector Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public void setLeconomicsector(List<TgeneCatalogDetail> leconomicsector) {
|
||
this.leconomicsector = leconomicsector;
|
||
}
|
||
|
||
/**
|
||
* Entrega lista de objetos TgeneCatalogDetail de tipo cliente
|
||
*
|
||
* @return ltypeclient Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public List<TgeneCatalogDetail> getLtypeclient() {
|
||
return this.ltypeclient;
|
||
}
|
||
|
||
/**
|
||
* Fija lista de objetos TgeneCatalogDetail de tipo cliente
|
||
*
|
||
* @param ltypeclient Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public void setLtypeclient(List<TgeneCatalogDetail> ltypeclient) {
|
||
this.ltypeclient = ltypeclient;
|
||
}
|
||
|
||
/**
|
||
* Entrega lista de objetos TgeneCatalogDetail
|
||
*
|
||
* @return lnotactivity Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public List<TgeneCatalogDetail> getLnotactivity() {
|
||
return this.lnotactivity;
|
||
}
|
||
|
||
/**
|
||
* Fija lista de objetos TgeneCatalogDetail
|
||
*
|
||
* @param lnotactivity Lista de objetos TgeneCatalogDetail
|
||
*/
|
||
public void setLnotactivity(List<TgeneCatalogDetail> lnotactivity) {
|
||
this.lnotactivity = lnotactivity;
|
||
}
|
||
|
||
/**
|
||
* Entrega la lista de géneros
|
||
*
|
||
* @return lgender Lista de géneros
|
||
*/
|
||
public List<String[]> getLgender() {
|
||
return this.lgender;
|
||
}
|
||
|
||
/**
|
||
* Fija la lista de géneros
|
||
*
|
||
* @param lgender Lista de géneros
|
||
*/
|
||
public void setLgender(List<String[]> lgender) {
|
||
this.lgender = lgender;
|
||
}
|
||
|
||
public Boolean getFirmaCargada() {
|
||
return firmaCargada;
|
||
}
|
||
|
||
public void setFirmaCargada(Boolean firmaCargada) {
|
||
this.firmaCargada = firmaCargada;
|
||
}
|
||
|
||
public UploadedFile getSelectedSign() {
|
||
return selectedSign;
|
||
}
|
||
|
||
public void setSelectedSign(UploadedFile selectedSign) {
|
||
this.selectedSign = selectedSign;
|
||
}
|
||
|
||
public UploadedFile getSelectedPicture() {
|
||
return selectedPicture;
|
||
}
|
||
|
||
public void setSelectedPicture(UploadedFile selectedPicture) {
|
||
this.selectedPicture = selectedPicture;
|
||
}
|
||
|
||
public Boolean getFotoCargada() {
|
||
return fotoCargada;
|
||
}
|
||
|
||
public void setFotoCargada(Boolean fotoCargada) {
|
||
this.fotoCargada = fotoCargada;
|
||
}
|
||
|
||
public StreamedContent getFirma() throws IOException {
|
||
if(selectedSign!=null){
|
||
FacesContext.getCurrentInstance().getExternalContext().getMimeType(selectedSign.getContentType());
|
||
return new DefaultStreamedContent(selectedSign.getInputstream(), "image/png");
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public void setFirma(StreamedContent firma) {
|
||
this.firma = firma;
|
||
}
|
||
|
||
public StreamedContent getFoto() throws IOException {
|
||
if(selectedPicture!=null){
|
||
FacesContext.getCurrentInstance().getExternalContext().getMimeType(selectedPicture.getContentType());
|
||
return new DefaultStreamedContent(selectedPicture.getInputstream(), "image/png");
|
||
}
|
||
return null;
|
||
|
||
}
|
||
|
||
public void setFoto(StreamedContent foto) {
|
||
this.foto = foto;
|
||
}
|
||
|
||
public String getRutaFoto() {
|
||
return rutaFoto;
|
||
}
|
||
|
||
public void setRutaFoto(String rutaFoto) {
|
||
this.rutaFoto = rutaFoto;
|
||
}
|
||
|
||
public String getRutaFirma() {
|
||
return rutaFirma;
|
||
}
|
||
|
||
public void setRutaFirma(String rutaFirma) {
|
||
this.rutaFirma = rutaFirma;
|
||
}
|
||
|
||
public List<TgeneCatalogDetail> getProfesionList() {
|
||
return profesionList;
|
||
}
|
||
|
||
public void setProfesionList(List<TgeneCatalogDetail> profesionList) {
|
||
this.profesionList = profesionList;
|
||
}
|
||
|
||
public List<TgeneCatalogDetail> getEstadocivilList() {
|
||
return estadocivilList;
|
||
}
|
||
|
||
public String getIdEstadoCivil() {
|
||
return idEstadoCivil;
|
||
}
|
||
|
||
public void setIdEstadoCivil(String idEstadoCivil) {
|
||
this.idEstadoCivil = idEstadoCivil;
|
||
}
|
||
|
||
|
||
|
||
public void setEstadocivilList(List<TgeneCatalogDetail> estadocivilList) {
|
||
this.estadocivilList = estadocivilList;
|
||
}
|
||
|
||
public FileDetailController getFileDetail() {
|
||
return fileDetail;
|
||
}
|
||
|
||
public void setFileDetail(FileDetailController fileDetail) {
|
||
this.fileDetail = fileDetail;
|
||
}
|
||
|
||
public List<TgeneCatalogDetail> getMilitarygrades() {
|
||
return militarygrades;
|
||
}
|
||
|
||
public void setMilitarygrades(List<TgeneCatalogDetail> militarygrades) {
|
||
this.militarygrades = militarygrades;
|
||
}
|
||
|
||
}
|