Search in sources :

Example 1 with ContactDAO

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);
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) ContactInfo(com.autentia.tnt.businessobject.ContactInfo)

Example 2 with ContactDAO

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());
    }
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) AdvancedSearchContactSearch(com.autentia.tnt.dao.search.AdvancedSearchContactSearch) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) Position(com.autentia.tnt.businessobject.Position) EntityChange(com.autentia.tnt.tracking.EntityChange) ArrayList(java.util.ArrayList) EntityChangeDAO(com.autentia.tnt.tracking.hibernate.dao.EntityChangeDAO) Test(org.junit.Test)

Example 3 with ContactDAO

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());
    }
}
Also used : PositionDAO(com.autentia.tnt.dao.hibernate.PositionDAO) AdvancedSearchContactSearch(com.autentia.tnt.dao.search.AdvancedSearchContactSearch) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) Test(org.junit.Test)

Example 4 with ContactDAO

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);
}
Also used : UserCategory(com.autentia.tnt.businessobject.UserCategory) DepartmentDAO(com.autentia.tnt.dao.hibernate.DepartmentDAO) Date(java.util.Date) WorkingAgreementDAO(com.autentia.tnt.dao.hibernate.WorkingAgreementDAO) Role(com.autentia.tnt.businessobject.Role) OfferRole(com.autentia.tnt.businessobject.OfferRole) Department(com.autentia.tnt.businessobject.Department) UserCategoryDAO(com.autentia.tnt.dao.hibernate.UserCategoryDAO) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO) ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) RoleDAO(com.autentia.tnt.dao.hibernate.RoleDAO) OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) OrganizationDAO(com.autentia.tnt.dao.hibernate.OrganizationDAO) ProjectDAO(com.autentia.tnt.dao.hibernate.ProjectDAO) WorkingAgreement(com.autentia.tnt.businessobject.WorkingAgreement)

Example 5 with ContactDAO

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);
}
Also used : ContactDAO(com.autentia.tnt.dao.hibernate.ContactDAO) OfferDAO(com.autentia.tnt.dao.hibernate.OfferDAO) OrganizationDAO(com.autentia.tnt.dao.hibernate.OrganizationDAO) Date(java.util.Date) ProjectDAO(com.autentia.tnt.dao.hibernate.ProjectDAO)

Aggregations

ContactDAO (com.autentia.tnt.dao.hibernate.ContactDAO)9 PositionDAO (com.autentia.tnt.dao.hibernate.PositionDAO)6 AdvancedSearchContactSearch (com.autentia.tnt.dao.search.AdvancedSearchContactSearch)5 Test (org.junit.Test)5 Position (com.autentia.tnt.businessobject.Position)3 OfferDAO (com.autentia.tnt.dao.hibernate.OfferDAO)3 OrganizationDAO (com.autentia.tnt.dao.hibernate.OrganizationDAO)3 ProjectDAO (com.autentia.tnt.dao.hibernate.ProjectDAO)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 DepartmentDAO (com.autentia.tnt.dao.hibernate.DepartmentDAO)2 RoleDAO (com.autentia.tnt.dao.hibernate.RoleDAO)2 UserCategoryDAO (com.autentia.tnt.dao.hibernate.UserCategoryDAO)2 UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)2 WorkingAgreementDAO (com.autentia.tnt.dao.hibernate.WorkingAgreementDAO)2 EntityChange (com.autentia.tnt.tracking.EntityChange)2 EntityChangeDAO (com.autentia.tnt.tracking.hibernate.dao.EntityChangeDAO)2 ContactInfo (com.autentia.tnt.businessobject.ContactInfo)1 Department (com.autentia.tnt.businessobject.Department)1 OfferRole (com.autentia.tnt.businessobject.OfferRole)1