Search in sources :

Example 1 with PositionSearch

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

the class ContactBean method getAllPositionsOfDepartment.

public List<SelectItem> getAllPositionsOfDepartment() {
    final PositionSearch positionSearch = new PositionSearch();
    positionSearch.setDepartmentId(this.getSelectedDepartment().getId());
    positionSearch.setDeleted(false);
    final List<Position> refs = PositionManager.getDefault().getAllEntities(positionSearch, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    ret.add(new SelectItem(null, FacesUtils.getMessage("contact.selectOnePosition")));
    for (Position ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : PositionSearch(com.autentia.tnt.dao.search.PositionSearch) SortCriteria(com.autentia.tnt.dao.SortCriteria) Position(com.autentia.tnt.businessobject.Position) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 2 with PositionSearch

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

the class TagBean method getAllPositions.

public List<SelectItem> getAllPositions() {
    final PositionSearch positionSearch = new PositionSearch();
    positionSearch.setDeleted(false);
    final List<Position> refs = PositionManager.getDefault().getAllEntities(positionSearch, new SortCriteria("name"));
    final List<SelectItem> ret = new ArrayList<SelectItem>();
    for (Position ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : PositionSearch(com.autentia.tnt.dao.search.PositionSearch) SortCriteria(com.autentia.tnt.dao.SortCriteria) Position(com.autentia.tnt.businessobject.Position) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 3 with PositionSearch

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

the class PositionBean method getAll.

/**
 * List positions. Order depends on Faces parameter sort.
 *
 * @return the list of all positions sorted by requested criterion
 */
public List<Position> getAll() {
    final PositionSearch allNotDeletedSearch = new PositionSearch();
    allNotDeletedSearch.setDeleted(false);
    return manager.getAllEntities(allNotDeletedSearch, new SortCriteria(sortColumn, sortAscending));
}
Also used : PositionSearch(com.autentia.tnt.dao.search.PositionSearch) SortCriteria(com.autentia.tnt.dao.SortCriteria)

Example 4 with PositionSearch

use of com.autentia.tnt.dao.search.PositionSearch 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)

Example 5 with PositionSearch

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

the class DepartmentBean method create.

/**
 * Go to create page
 * @return forward to CREATE page
 */
public String create() {
    department = new Department();
    // se inserta el puesto 'Indefinido' en caso de existir
    final PositionSearch positionSearch = new PositionSearch();
    positionSearch.setName("Indefinido");
    List<Position> positions = PositionManager.getDefault().getAllEntities(positionSearch, new SortCriteria("name", true));
    Set<Position> positionsSet = new HashSet<Position>();
    for (Position position : positions) {
        positionsSet.add(position);
    }
    department.setPositions(positionsSet);
    return NavigationResults.CREATE;
}
Also used : PositionSearch(com.autentia.tnt.dao.search.PositionSearch) SortCriteria(com.autentia.tnt.dao.SortCriteria) Department(com.autentia.tnt.businessobject.Department) Position(com.autentia.tnt.businessobject.Position) HashSet(java.util.HashSet)

Aggregations

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