150 lines
5.8 KiB
Plaintext
Executable File
150 lines
5.8 KiB
Plaintext
Executable File
package com.fp.person.db;
|
|
|
|
import com.fp.persistence.commondb.PersistenceHelper;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCanton;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCantonKey;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCity;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCityKey;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCountry;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParroquia;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParroquiaKey;
|
|
import com.fp.persistence.pgeneral.gene.TgeneProvince;
|
|
import com.fp.persistence.pgeneral.gene.TgeneProvinceKey;
|
|
|
|
/**
|
|
* Clase utilitaria que maneje sql y hql utiliada en el proyecto person.
|
|
* @author Jorge Vaca
|
|
* @version 2.1
|
|
*/
|
|
public class DataHelper {
|
|
|
|
/**Almacena una instancia de DataHelper.*/
|
|
private static DataHelper cache;
|
|
|
|
/**
|
|
* Entrega una instancia de DataHelper.
|
|
* @return DataHelper
|
|
*/
|
|
public static DataHelper getInstance() {
|
|
if (cache != null) {
|
|
return cache;
|
|
}
|
|
synchronized (DataHelper.class) {
|
|
if (cache == null) {
|
|
cache = new DataHelper();
|
|
}
|
|
}
|
|
return cache;
|
|
}
|
|
|
|
/**
|
|
* Metodo que entrega datos de una sucursal definidos en TgeneBranch.
|
|
* @param pBranch Codigo de sucursal.
|
|
* @param pCompany Compania a la que pertenece la cuenta.
|
|
* @return TgeneBranch
|
|
* @throws Exception
|
|
*/
|
|
public TcustPersonDetail getTcustPersonDetail(Integer pPersonCode) throws Exception {
|
|
return TcustPersonDetail.find(PersistenceHelper.getEntityManager(), pPersonCode);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que entrega datos de una Direccion definida en TcustPersonAddress.
|
|
* @param personcode Codigo de la persona a quien pertenece la Direccion.
|
|
* @param addressnumber Numero de la direccion.
|
|
* @return tcustPersonAddress
|
|
* @throws Exception
|
|
*/
|
|
public TcustPersonAddress getTcustPersonAddress(Integer personcode, Integer addressnumber) throws Exception {
|
|
return TcustPersonAddress.findByPersonCode(PersistenceHelper.getEntityManager(), personcode, addressnumber);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que entrega datos de un Pais definido en TgeneCountry.
|
|
* @param countrycode Codigo que identfica el Pais.
|
|
* @return tgeneCountry
|
|
* @throws Exception
|
|
*/
|
|
public TgeneCountry getTgeneCountry(String countrycode) throws Exception {
|
|
TgeneCountry tgeneCountry = null;
|
|
tgeneCountry = (TgeneCountry) PersistenceHelper.getSession().get(TgeneCountry.class, countrycode);
|
|
return tgeneCountry;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que entrega datos de una Provincia definida en TgeneProvince.
|
|
* @param countrycode Codigo del pais al cual pertenece la Provincia.
|
|
* @param provincecode Codigo que identfica la Provincia.
|
|
* @return tgeneProvince
|
|
* @throws Exception
|
|
*/
|
|
public TgeneProvince getTgeneProvince(String countrycode, String provincecode) throws Exception {
|
|
TgeneProvinceKey tgeneProvinceKey = new TgeneProvinceKey(countrycode, provincecode);
|
|
TgeneProvince tgeneProvince = null;
|
|
tgeneProvince = (TgeneProvince) PersistenceHelper.getSession().get(TgeneProvince.class, tgeneProvinceKey);
|
|
return tgeneProvince;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que devuelve un objeto de tipo TgeneCanton
|
|
* @param countrycode Codigo de pais
|
|
* @param provincecode Codigo provincia
|
|
* @param cantoncode Codigo canton
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
public TgeneCanton getTgeneCanton(String countrycode, String provincecode, String cantoncode) throws Exception {
|
|
TgeneCantonKey tgeneCantonKey = new TgeneCantonKey(countrycode, provincecode, cantoncode);
|
|
TgeneCanton tgeneCanton = null;
|
|
tgeneCanton = (TgeneCanton) PersistenceHelper.getSession().get(TgeneCanton.class, tgeneCantonKey);
|
|
return tgeneCanton;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que entrega datos de una Ciudad definida en TgeneCity.
|
|
* @param countrycode Codigo del pais al cual perteneces la Ciudad.
|
|
* @param provincecode Codigo de la provincia al cual pertenece la Ciudad.
|
|
* @param cantoncode Codigo del canton de la ciudad
|
|
* @param citycode Codigo que identfica la Ciudad.
|
|
* @return tgeneCity
|
|
* @throws Exception
|
|
*/
|
|
public TgeneCity getTgeneCity(String countrycode, String provincecode, String cantoncode, String citycode) throws Exception {
|
|
TgeneCityKey tgeneCityKey = new TgeneCityKey(countrycode, provincecode, cantoncode, citycode);
|
|
TgeneCity tgeneCity = null;
|
|
tgeneCity = (TgeneCity) PersistenceHelper.getSession().get(TgeneCity.class, tgeneCityKey);
|
|
return tgeneCity;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo que entrega datos de una Parroquia definida en TgeneParroquia.
|
|
* @param countrycode Codigo del pais al cual perteneces la Ciudad.
|
|
* @param provincecode Codigo de la provincia al cual pertenece la Ciudad.
|
|
* @param cantoncode Codigo del canton de la ciudad
|
|
* @param parroquiacode Codigo que identfica a la parroquia.
|
|
* @return tgeneCity
|
|
* @throws Exception
|
|
*/
|
|
public TgeneParroquia getTgeneParroquia(String countrycode, String provincecode, String cantoncode, String parroquiacode) throws Exception {
|
|
TgeneParroquiaKey tgeneParroquiaKey = new TgeneParroquiaKey(countrycode, provincecode, cantoncode, parroquiacode);
|
|
TgeneParroquia tgeneParroquia = null;
|
|
tgeneParroquia = (TgeneParroquia) PersistenceHelper.getSession().get(TgeneParroquia.class, tgeneParroquiaKey);
|
|
return tgeneParroquia;
|
|
}
|
|
|
|
}
|