Search in sources :

Example 1 with DepartmentSearch

use of com.autentia.tnt.dao.search.DepartmentSearch in project TNTConcept by autentia.

the class ContactBean method getAllDepartmentsOfCompany.

public List<SelectItem> getAllDepartmentsOfCompany() {
    final Set<Organization> organizations = new LinkedHashSet<Organization>();
    organizations.add(this.getSelectedOrganization());
    final DepartmentSearch departmentSearch = new DepartmentSearch();
    departmentSearch.setOrganization(this.getSelectedOrganization());
    final List<Department> refs = DepartmentManager.getDefault().getAllEntities(departmentSearch, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    ret.add(new SelectItem(null, FacesUtils.getMessage("contact.selectOneDepartment")));
    for (Department ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SortCriteria(com.autentia.tnt.dao.SortCriteria) Department(com.autentia.tnt.businessobject.Department) Organization(com.autentia.tnt.businessobject.Organization) SelectItem(javax.faces.model.SelectItem) DepartmentSearch(com.autentia.tnt.dao.search.DepartmentSearch) ArrayList(java.util.ArrayList)

Example 2 with DepartmentSearch

use of com.autentia.tnt.dao.search.DepartmentSearch in project TNTConcept by autentia.

the class OrganizationBean method create.

/**
 * Go to create page
 * @return forward to CREATE page
 */
public String create() {
    organization = new Organization();
    // se inserta el departamento 'Indefinido' en caso de existir
    final DepartmentSearch departmentSearch = new DepartmentSearch();
    departmentSearch.setName("Indefinido");
    List<Department> departments = DepartmentManager.getDefault().getAllEntities(departmentSearch, new SortCriteria("name", true));
    Set<Department> departmentsSet = new HashSet<Department>();
    for (Department department : departments) {
        departmentsSet.add(department);
    }
    organization.setDepartments(departmentsSet);
    return NavigationResults.CREATE;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) DepartmentSearch(com.autentia.tnt.dao.search.DepartmentSearch) HashSet(java.util.HashSet)

Example 3 with DepartmentSearch

use of com.autentia.tnt.dao.search.DepartmentSearch in project TNTConcept by autentia.

the class ContactManager method addOrganizationDepartmentOrPositionByDefault.

public Contact addOrganizationDepartmentOrPositionByDefault(final Contact contact, final Organization organization, final Department department, final Position position) {
    try {
        if (organization != null) {
            Department selectedDepartment = null;
            Position selectedPosition = null;
            if (department == null) {
                final DepartmentSearch departmentSearch = new DepartmentSearch();
                departmentSearch.setName("Indefinido");
                selectedDepartment = DepartmentDAO.getDefault().search(departmentSearch, new SortCriteria("id")).get(0);
            } else {
                selectedDepartment = department;
            }
            if (position == null) {
                final PositionSearch positionSearch = new PositionSearch();
                positionSearch.setName("Indefinido");
                selectedPosition = PositionDAO.getDefault().search(positionSearch, new SortCriteria("id")).get(0);
            } else {
                selectedPosition = position;
            }
            final ContactInfo contactInfo = new ContactInfo();
            contactInfo.setContact(contact);
            contactInfo.setOrganization(organization);
            contactInfo.setDepartment(selectedDepartment);
            contactInfo.setPosition(selectedPosition);
            contact.addContactInfo(contactInfo);
            this.updateEntity(contact);
        }
    } catch (Exception e) {
        log.error("addOrganizationDepartmentOrPositionByDefault - Error ", e);
    }
    return contact;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) PositionSearch(com.autentia.tnt.dao.search.PositionSearch) Department(com.autentia.tnt.businessobject.Department) ContactPosition(com.autentia.tnt.manager.contacts.advancedsearch.ContactPosition) Position(com.autentia.tnt.businessobject.Position) DepartmentSearch(com.autentia.tnt.dao.search.DepartmentSearch) ContactInfo(com.autentia.tnt.businessobject.ContactInfo)

Aggregations

SortCriteria (com.autentia.tnt.dao.SortCriteria)3 DepartmentSearch (com.autentia.tnt.dao.search.DepartmentSearch)3 Department (com.autentia.tnt.businessobject.Department)2 ContactInfo (com.autentia.tnt.businessobject.ContactInfo)1 Organization (com.autentia.tnt.businessobject.Organization)1 Position (com.autentia.tnt.businessobject.Position)1 PositionSearch (com.autentia.tnt.dao.search.PositionSearch)1 ContactPosition (com.autentia.tnt.manager.contacts.advancedsearch.ContactPosition)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 SelectItem (javax.faces.model.SelectItem)1