use of com.autentia.tnt.dao.hibernate.ContactDAO in project TNTConcept by autentia.
the class ContactPositionManagerTest method insertContactData.
/**
* Metodo encargado de insertar los datos de los propios contactos
*/
private void insertContactData() {
final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
// puestos
becario.setName("becario");
becario.setDescription("becario");
becario.setEmail("becario@dominio.com");
becario.setPhone("+344343");
becario.setFax("+341212");
becario.setCountry("España");
becario.setProvince(province);
becario.setCity("barbate");
becario.setPostalCode("10111");
becario.setAddress("C/ Becario");
positionDAO.insert(becario);
responsableDireccion.setName("Responsable de Dirección");
responsableDireccion.setDescription("Responsable de Dirección");
responsableDireccion.setEmail("responsableDireccion@dominio.com");
responsableDireccion.setPhone("+344343");
responsableDireccion.setFax("+341212");
responsableDireccion.setCountry("España");
responsableDireccion.setProvince(province);
responsableDireccion.setCity("barbate");
responsableDireccion.setPostalCode("10111");
responsableDireccion.setAddress("C/ Becario");
positionDAO.insert(responsableDireccion);
responsableFacturacion.setName("Responsable de Facturación");
responsableFacturacion.setDescription("Responsable de Facturación");
responsableFacturacion.setEmail("responsableFacturacion@dominio.com");
responsableFacturacion.setPhone("+344343");
responsableFacturacion.setFax("+341212");
responsableFacturacion.setCountry("España");
responsableFacturacion.setProvince(province);
responsableFacturacion.setCity("barbate");
responsableFacturacion.setPostalCode("10111");
responsableFacturacion.setAddress("C/ Becario");
positionDAO.insert(responsableFacturacion);
analista.setName("Analista");
analista.setDescription("Analista");
analista.setEmail("analista@dominio.com");
analista.setPhone("+344343");
analista.setFax("+341212");
analista.setCountry("España");
analista.setProvince(province);
analista.setCity("barbate");
analista.setPostalCode("10111");
analista.setAddress("C/ Becario");
positionDAO.insert(analista);
// contactos
antonioRuiz.setName("Antonio Ruiz");
antonioRuiz.setEmail("antonio@dominio.com");
antonioRuiz.setPhone("+341234");
antonioRuiz.setFax("+349876");
antonioRuiz.setCountry("España");
antonioRuiz.setProvince(province);
antonioRuiz.setCity("Casarrubuelos de arriba");
antonioRuiz.setPostalCode("90666");
antonioRuiz.setAddress("C/ Antonio Ruiz");
contactDAO.insert(antonioRuiz);
pilarSancho.setName("Pilar M. de Sancho");
pilarSancho.setEmail("pilar@dominio.com");
pilarSancho.setPhone("+342468");
pilarSancho.setFax("+348642");
pilarSancho.setCountry("España");
pilarSancho.setProvince(province);
pilarSancho.setCity("Casarrubuelos de abajo");
pilarSancho.setPostalCode("90123");
pilarSancho.setAddress("C/ Pilar Sancho");
contactDAO.insert(pilarSancho);
// relacion entre contactos y puestos
final ContactInfo contactInfoAntonio = new ContactInfo();
contactInfoAntonio.setContact(antonioRuiz);
contactInfoAntonio.setDepartment(department);
contactInfoAntonio.setOrganization(organization);
contactInfoAntonio.setPosition(becario);
antonioRuiz.addContactInfo(contactInfoAntonio);
contactDAO.update(antonioRuiz);
final ContactInfo contactInfoPilar = new ContactInfo();
contactInfoPilar.setContact(pilarSancho);
contactInfoPilar.setDepartment(department);
contactInfoPilar.setOrganization(organization);
contactInfoPilar.setPosition(analista);
pilarSancho.addContactInfo(contactInfoPilar);
contactDAO.update(pilarSancho);
}
use of com.autentia.tnt.dao.hibernate.ContactDAO in project TNTConcept by autentia.
the class ContactPositionManagerTest method testDoAdvancedSearchHistorical.
/**
* Buscar por en historico y en activo
*/
@Test
public void testDoAdvancedSearchHistorical() {
final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
final EntityChangeDAO entityChangeDAO = (EntityChangeDAO) SpringUtilsForTesting.getSpringBean("daoEntityChange");
final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
this.insertInitialData();
this.insertContactData();
// añadimos que Pilar Sancho fue becaria
final EntityChange changePosition = new EntityChange();
changePosition.setField(Contact.FIELD_POSITION);
changePosition.setNewValue("");
changePosition.setOldValue("becario");
changePosition.setEntityId(pilarSancho.getId());
changePosition.setEntityName("com.autentia.tnt.businessobject.Contact");
entityChangeDAO.insert(changePosition);
final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
final List<Position> positions = new ArrayList<Position>();
positions.add(becario);
advancedSearch.setPositions(positions);
final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, ACTIVE_AND_HISTORICAL);
// debe salir dos resultados, ya que hay uno que es becario actualmente y otro que lo fue
if (contactPositions.size() != 2) {
fail("Deberian haber salido 2 resultados, pero han salido " + contactPositions.size());
}
}
use of com.autentia.tnt.dao.hibernate.ContactDAO in project TNTConcept by autentia.
the class ContactPositionManagerTest method testDoAdvancedSearchWithoutCriteria.
/**
* Busqueda sin filtrado
*/
@Test
public void testDoAdvancedSearchWithoutCriteria() {
final PositionDAO positionDAO = (PositionDAO) SpringUtilsForTesting.getSpringBean("daoPosition");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
final ContactPositionManager contactPositionManager = new ContactPositionManager(contactDAO, positionDAO);
this.insertInitialData();
this.insertContactData();
final AdvancedSearchContactSearch advancedSearch = new AdvancedSearchContactSearch();
final List<ContactPosition> contactPositions = contactPositionManager.doAdvancedSearch(advancedSearch, JUST_ACTIVE);
// deben salir 4 resultados, puesto que hay 2 contactos con puesto y 2 puestos sin asignar
if (contactPositions.size() != 4) {
fail("Deberian haber salido 4 resultados, pero han salido " + contactPositions.size());
}
}
use of com.autentia.tnt.dao.hibernate.ContactDAO in project TNTConcept by autentia.
the class DuplicateOfferTest method insertInitialData.
/**
* Metodo encargado de insertar datos muy generales pero que son necesarios
* para generar facturas en base a ofertas
*/
private void insertInitialData() {
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
final ProjectDAO projectDAO = (ProjectDAO) SpringUtilsForTesting.getSpringBean("daoProject");
final OrganizationDAO organizationDAO = (OrganizationDAO) SpringUtilsForTesting.getSpringBean("daoOrganization");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
final UserDAO userDAO = (UserDAO) SpringUtilsForTesting.getSpringBean("daoUser");
final RoleDAO roleDAO = (RoleDAO) SpringUtilsForTesting.getSpringBean("daoRole");
final UserCategoryDAO categoryDAO = (UserCategoryDAO) SpringUtilsForTesting.getSpringBean("daoUserCategory");
final DepartmentDAO departmentDAO = (DepartmentDAO) SpringUtilsForTesting.getSpringBean("daoDepartment");
final WorkingAgreementDAO workingAgreementDAO = (WorkingAgreementDAO) SpringUtilsForTesting.getSpringBean("daoWorkingAgreement");
final Role role = new Role();
roleDAO.insert(role);
final Department department = new Department();
department.setName("departamento");
departmentDAO.insert(department);
final UserCategory category = new UserCategory();
categoryDAO.insert(category);
final WorkingAgreement workingAgreement = new WorkingAgreement();
workingAgreementDAO.insert(workingAgreement);
contact.setName("Sergio Hermida");
contactDAO.insert(contact);
projectDAO.insert(project);
organizationDAO.insert(organization);
user.setRole(role);
user.setCategory(category);
user.setDepartment(department);
user.setAgreement(workingAgreement);
userDAO.insert(user);
offer.setNumber(OFFER_NUMBER);
offer.setOrganization(organization);
offer.setContact(contact);
offer.setTitle(OFFER_TITLE);
offer.setDescription(OFFER_DESCRIPTION);
offer.setOfferPotential(OfferPotential.MEDIUM);
offer.setOfferState(OfferState.OPEN);
offer.setCreationDate(new Date());
offer.setMaturityDate(new Date());
offerDAO.insert(offer);
}
use of com.autentia.tnt.dao.hibernate.ContactDAO in project TNTConcept by autentia.
the class FromOfferToBillTest method insertInitialData.
/**
* Metodo encargado de insertar datos muy generales pero que son necesarios
* para generar facturas en base a ofertas
*/
private void insertInitialData() {
final OfferDAO offerDAO = (OfferDAO) SpringUtilsForTesting.getSpringBean("daoOffer");
final ProjectDAO projectDAO = (ProjectDAO) SpringUtilsForTesting.getSpringBean("daoProject");
final OrganizationDAO organizationDAO = (OrganizationDAO) SpringUtilsForTesting.getSpringBean("daoOrganization");
final ContactDAO contactDAO = (ContactDAO) SpringUtilsForTesting.getSpringBean("daoContact");
contact.setName("Sergio Hermida");
contactDAO.insert(contact);
projectDAO.insert(project);
organizationDAO.insert(organization);
offer.setNumber(OFFER_NUMBER);
offer.setOrganization(organization);
offer.setContact(contact);
offer.setTitle(OFFER_TITLE);
offer.setDescription(OFFER_DESCRIPTION);
offer.setOfferPotential(OfferPotential.MEDIUM);
offer.setOfferState(OfferState.OPEN);
offer.setCreationDate(new Date());
offerDAO.insert(offer);
}
Aggregations