Search in sources :

Example 1 with SortCriteria

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

the class GlobalHoursReportBean method getAll.

public List<GlobalHourReport> getAll() {
    // Retrieve activities for every User during that period of time
    ActivitySearch search = new ActivitySearch();
    Calendar init = Calendar.getInstance();
    init.setTime(startDate);
    Calendar last = Calendar.getInstance();
    last.setTime(endDate);
    init.set(Calendar.HOUR_OF_DAY, init.getMinimum(Calendar.HOUR_OF_DAY));
    init.set(Calendar.MINUTE, init.getMinimum(Calendar.MINUTE));
    init.set(Calendar.SECOND, init.getMinimum(Calendar.SECOND));
    init.set(Calendar.MILLISECOND, init.getMinimum(Calendar.MILLISECOND));
    last.set(Calendar.HOUR_OF_DAY, last.getMaximum(Calendar.HOUR_OF_DAY));
    last.set(Calendar.MINUTE, last.getMaximum(Calendar.MINUTE));
    last.set(Calendar.SECOND, last.getMaximum(Calendar.SECOND));
    last.set(Calendar.MILLISECOND, last.getMaximum(Calendar.MILLISECOND));
    search.setStartStartDate(init.getTime());
    search.setEndStartDate(last.getTime());
    List<GlobalHourReport> listGlobal = new ArrayList<GlobalHourReport>();
    if (billable)
        search.setBillable(true);
    // Search activities during indicated dates
    List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name"));
    for (Activity act : activities) {
        Project proj = act.getRole().getProject();
        GlobalHourReport unit = new GlobalHourReport();
        unit.setProject(proj);
        // an entry in the list represents a project
        if (!listGlobal.contains(unit))
            listGlobal.add(unit);
        // Retrieve the stored unit and save hours
        GlobalHourReport storedUnit = listGlobal.get(listGlobal.indexOf(unit));
        float horas = act.getDuration() / 60.0f;
        storedUnit.setUserHours(act.getUser(), horas);
        storedUnit.setIterator(usuarios.iterator());
    }
    return listGlobal;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) Project(com.autentia.tnt.businessobject.Project) GlobalHourReport(com.autentia.tnt.businessobject.GlobalHourReport) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Activity(com.autentia.tnt.businessobject.Activity) ActivitySearch(com.autentia.tnt.dao.search.ActivitySearch)

Example 2 with SortCriteria

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

the class OccupationBean method getOrganizations.

/**
 * Get the list of all organizations
 * @return the list of all organizations
 */
public List<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, 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 3 with SortCriteria

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

the class OccupationBean method getProjects.

/**
 * Get the list of all projects
 * @return the list of all projects
 */
public List<SelectItem> getProjects() {
    List<Project> refs = ProjectManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (Project ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) Project(com.autentia.tnt.businessobject.Project) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 4 with SortCriteria

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

the class ActivityBean method fillExternalActivities.

private void fillExternalActivities(SimpleScheduleModel model) {
    Calendar calMin = Calendar.getInstance();
    Calendar calMax = Calendar.getInstance();
    calMin = getMinimumSearchTime(selectedDate);
    calMax = getMaximumSearchTime(selectedDate);
    ExternalActivitySearch search = new ExternalActivitySearch();
    search.setStartStartDate(calMin.getTime());
    search.setEndStartDate(calMax.getTime());
    search.setStartEndDate(calMin.getTime());
    search.setEndEndDate(calMax.getTime());
    search.setOwner(authManager.getCurrentPrincipal().getUser());
    List<ExternalActivity> extActivities = externalActivityManager.getAllEntities(search, new SortCriteria(sortColumn, sortAscending));
    for (ExternalActivity extActivity : extActivities) {
        ExternalActivityScheduleEntry entry = new ExternalActivityScheduleEntry(extActivity);
        model.addEntry(entry);
    }
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) ExternalActivitySearch(com.autentia.tnt.dao.search.ExternalActivitySearch) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) ExternalActivity(com.autentia.tnt.businessobject.ExternalActivity)

Example 5 with SortCriteria

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

the class ActivityBean 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() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<User> refs = userDAO.search(new SortCriteria("name"));
    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