Search in sources :

Example 36 with SortCriteria

use of com.autentia.tnt.dao.SortCriteria in project TNTConcept by autentia.

the class ReportBean method getOrganizations.

public ArrayList<SelectItem> getOrganizations() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Organization> refs = organizationDAO.search(new SortCriteria("name"));
    for (Organization ref : refs) {
        ret.add(new SelectItem(ref.getId().toString(), ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) Organization(com.autentia.tnt.businessobject.Organization) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 37 with SortCriteria

use of com.autentia.tnt.dao.SortCriteria in project TNTConcept by autentia.

the class BillManager method getAllBitacoreBreakDowns.

public List<BillBreakDown> getAllBitacoreBreakDowns(Date start, Date end, Project project) {
    final List<BillBreakDown> desgloses = new ArrayList<BillBreakDown>();
    ActivityDAO activityDAO = ActivityDAO.getDefault();
    ActivitySearch actSearch = new ActivitySearch();
    actSearch.setBillable(new Boolean(true));
    actSearch.setStartStartDate(start);
    actSearch.setEndStartDate(end);
    List<Activity> actividadesTotal = new ArrayList<Activity>();
    Hashtable user_roles = new Hashtable();
    ProjectRoleDAO projectRoleDAO = ProjectRoleDAO.getDefault();
    ProjectRoleSearch prjRolSearch = new ProjectRoleSearch();
    prjRolSearch.setProject(project);
    List<ProjectRole> roles = projectRoleDAO.search(prjRolSearch, new SortCriteria("id", false));
    for (ProjectRole proyRole : roles) {
        actSearch.setRole(proyRole);
        List<Activity> actividades = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        actividadesTotal.addAll(actividades);
    }
    for (Activity act : actividadesTotal) {
        String key = act.getRole().getId().toString() + act.getUser().getId().toString();
        if (!user_roles.containsKey(key)) {
            Hashtable value = new Hashtable();
            value.put("ROLE", act.getRole());
            value.put("USER", act.getUser());
            user_roles.put(key, value);
        }
    }
    Enumeration en = user_roles.keys();
    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        Hashtable pair = (Hashtable) user_roles.get(key);
        actSearch.setBillable(new Boolean(true));
        actSearch.setStartStartDate(start);
        actSearch.setEndStartDate(end);
        ProjectRole pR = (ProjectRole) pair.get("ROLE");
        User u = (User) pair.get("USER");
        actSearch.setRole(pR);
        actSearch.setUser(u);
        List<Activity> actividadesUsuarioRol = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Imputaciones (usuario - rol): " + u.getName() + " - " + pR.getName());
        brd.setAmount(pR.getCostPerHour());
        IvaApplicator.applyIvaToTaxableObject(start, brd);
        BigDecimal unitsTotal = new BigDecimal(0);
        for (Activity act : actividadesUsuarioRol) {
            BigDecimal unitsActual = new BigDecimal(act.getDuration());
            unitsActual = unitsActual.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
            unitsTotal = unitsTotal.add(unitsActual);
        }
        brd.setUnits(unitsTotal);
        brd.setSelected(true);
        desgloses.add(brd);
    }
    ProjectCostDAO prjCostDAO = ProjectCostDAO.getDefault();
    ProjectCostSearch prjCostSearch = new ProjectCostSearch();
    prjCostSearch.setProject(project);
    List<ProjectCost> costes = prjCostDAO.search(prjCostSearch, new SortCriteria("id", false));
    for (ProjectCost proyCost : costes) {
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Coste: " + proyCost.getName());
        brd.setUnits(new BigDecimal(1));
        brd.setAmount(proyCost.getCost());
        IvaApplicator.applyIvaToTaxableObject(start, brd);
        brd.setSelected(true);
        desgloses.add(brd);
    }
    return desgloses;
}
Also used : ProjectRoleDAO(com.autentia.tnt.dao.hibernate.ProjectRoleDAO) Enumeration(java.util.Enumeration) User(com.autentia.tnt.businessobject.User) ProjectCostDAO(com.autentia.tnt.dao.hibernate.ProjectCostDAO) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) ProjectCostSearch(com.autentia.tnt.dao.search.ProjectCostSearch) Activity(com.autentia.tnt.businessobject.Activity) ProjectRole(com.autentia.tnt.businessobject.ProjectRole) BigDecimal(java.math.BigDecimal) SortCriteria(com.autentia.tnt.dao.SortCriteria) ProjectRoleSearch(com.autentia.tnt.dao.search.ProjectRoleSearch) ActivitySearch(com.autentia.tnt.dao.search.ActivitySearch) ProjectCost(com.autentia.tnt.businessobject.ProjectCost) BillBreakDown(com.autentia.tnt.businessobject.BillBreakDown) ActivityDAO(com.autentia.tnt.dao.hibernate.ActivityDAO)

Example 38 with SortCriteria

use of com.autentia.tnt.dao.SortCriteria in project TNTConcept by autentia.

the class ReportUtil method getRoles.

public static ArrayList<SelectItem> getRoles(ArrayList<SelectItem> projs) {
    final RoleDAO roleDAO = new RoleDAO();
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<Role> roles = roleDAO.search(new SortCriteria("name"));
    for (Role role : roles) {
        ret.add(new SelectItem(role.getId().toString(), role.getName()));
    }
    return ret;
}
Also used : Role(com.autentia.tnt.businessobject.Role) ProjectRole(com.autentia.tnt.businessobject.ProjectRole) SortCriteria(com.autentia.tnt.dao.SortCriteria) RoleDAO(com.autentia.tnt.dao.hibernate.RoleDAO) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 39 with SortCriteria

use of com.autentia.tnt.dao.SortCriteria in project TNTConcept by autentia.

the class CollaboratorBean method doBeforeSave.

public String doBeforeSave() {
    // comprobacion de que solo se ha seleccionado o un usuario, o un contacto o una organizacion
    int numRefs = 0;
    if (collaborator.getUser() != null) {
        numRefs++;
        CollaboratorSearch collaboratorSearch = new CollaboratorSearch();
        collaboratorSearch.setUser(this.getUser());
        if (!CollaboratorManager.getDefault().getAllEntities(collaboratorSearch, new SortCriteria("id")).isEmpty()) {
            FacesUtils.addErrorMessage(null, "collaborator.error.duplicateUserCollaborator");
            return "Fail";
        }
    }
    if (collaborator.getContact() != null) {
        numRefs++;
        CollaboratorSearch collaboratorSearch = new CollaboratorSearch();
        collaboratorSearch.setContact(this.getContact());
        if (!CollaboratorManager.getDefault().getAllEntities(collaboratorSearch, new SortCriteria("id")).isEmpty()) {
            FacesUtils.addErrorMessage(null, "collaborator.error.duplicateContactCollaborator");
            return "Fail";
        }
    }
    if (collaborator.getOrganization() != null) {
        numRefs++;
        CollaboratorSearch collaboratorSearch = new CollaboratorSearch();
        collaboratorSearch.setOrganization(this.getOrganization());
        if (!CollaboratorManager.getDefault().getAllEntities(collaboratorSearch, new SortCriteria("id")).isEmpty()) {
            FacesUtils.addErrorMessage(null, "collaborator.error.duplicateOrganizationCollaborator");
            return "Fail";
        }
    }
    if (numRefs != 1) {
        FacesUtils.addErrorMessage(null, "collaborator.error.justOne");
        return "Fail";
    }
    return null;
}
Also used : CollaboratorSearch(com.autentia.tnt.dao.search.CollaboratorSearch) SortCriteria(com.autentia.tnt.dao.SortCriteria)

Example 40 with SortCriteria

use of com.autentia.tnt.dao.SortCriteria in project TNTConcept by autentia.

the class CollaboratorBean method getUsers.

// Getters to list possible values of related entities
/**
 * Get the list of all users
 * @return the list of all users
 */
public List<SelectItem> getUsers() {
    List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    ret.add(new SelectItem(null, ""));
    for (User ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Aggregations

SortCriteria (com.autentia.tnt.dao.SortCriteria)136 ArrayList (java.util.ArrayList)114 SelectItem (javax.faces.model.SelectItem)107 Organization (com.autentia.tnt.businessobject.Organization)15 User (com.autentia.tnt.businessobject.User)15 Department (com.autentia.tnt.businessobject.Department)9 Project (com.autentia.tnt.businessobject.Project)9 Position (com.autentia.tnt.businessobject.Position)7 Calendar (java.util.Calendar)7 GregorianCalendar (java.util.GregorianCalendar)7 Activity (com.autentia.tnt.businessobject.Activity)6 ProjectRole (com.autentia.tnt.businessobject.ProjectRole)6 ActivitySearch (com.autentia.tnt.dao.search.ActivitySearch)6 PositionSearch (com.autentia.tnt.dao.search.PositionSearch)6 Account (com.autentia.tnt.businessobject.Account)5 Contact (com.autentia.tnt.businessobject.Contact)5 Bill (com.autentia.tnt.businessobject.Bill)4 Inventary (com.autentia.tnt.businessobject.Inventary)4 AccountEntryType (com.autentia.tnt.businessobject.AccountEntryType)3 ExternalActivity (com.autentia.tnt.businessobject.ExternalActivity)3