use of com.autentia.tnt.businessobject.Project 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;
}
use of com.autentia.tnt.businessobject.Project 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;
}
use of com.autentia.tnt.businessobject.Project in project TNTConcept by autentia.
the class ActivityBean method getProjectsVisiblesBySelectedOrganization.
/**
* Get the list of all projects
*
* @return the list of all projects
*/
public List<SelectItem> getProjectsVisiblesBySelectedOrganization() {
Organization companySelected = this.getSelectedOrganization();
List<Project> openProjects = ProjectManager.getDefault().getOpenProjectsByOrganization(companySelected);
ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
if (selectedProject != null && selectedProject.isFinished()) {
ret.add(new SelectItem(selectedProject, selectedProject.getName() + " (*)"));
}
if (openProjects == null || openProjects.size() == 0) {
projects.clear();
return ret;
}
Project proj = null;
for (Object ref : openProjects) {
proj = (Project) ref;
projects.add(proj);
if (!proj.isFinished() && !proj.getRoles().isEmpty()) {
ret.add(new SelectItem(proj, proj.getName()));
}
}
return ret;
}
use of com.autentia.tnt.businessobject.Project in project TNTConcept by autentia.
the class ActivityBean method getProjects.
/**
* Get the list of all projects
*
* @return the list of all projects
*/
public List<SelectItem> getProjects() {
ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
List<Project> refs = projectManager.getAllEntities(null, new SortCriteria("name"));
for (Project ref : refs) {
ret.add(new SelectItem(ref, ref.getClient().getName() + " - " + ref.getName()));
}
return ret;
}
use of com.autentia.tnt.businessobject.Project in project TNTConcept by autentia.
the class ActivityBean method create.
/**
* Go to create page
*
* @return forward to CREATE page
*/
public String create() {
activity = new Activity();
externalActivity = new ExternalActivity();
selectedOrganization = null;
selectedProject = null;
organizations.clear();
projects.clear();
cal.setTime(scheduleModel.getSelectedDate());
if (scheduleModel.getMode() == ScheduleModel.MONTH || scheduleModel.getMode() == ScheduleModel.WEEK) {
cal.set(Calendar.HOUR_OF_DAY, ((SettingBean) FacesUtils.getBean("settingBean")).getMySettings().getWorkingDayHourStarts());
}
activity.setStartDate(cal.getTime());
activity.setDescription(FacesUtils.getMessage("activity.description"));
activity.setUser(authManager.getCurrentPrincipal().getUser());
externalActivity.setStartDate(cal.getTime());
// it is going to end in the same day
externalActivity.setEndDate(cal.getTime());
externalActivity.setComments(FacesUtils.getMessage("offer.observations"));
externalActivity.setOwnerId(authManager.getCurrentPrincipal().getUser().getId());
externalActivity.setDepartmentId(authManager.getCurrentPrincipal().getUser().getDepartmentId());
DocumentCategory padre = dcManager.getDocumentCategoryParent();
// User category
DocumentCategory extActDocCategory = new DocumentCategory();
extActDocCategory.setName(externalActivity.getName());
extActDocCategory.setDescription(externalActivity.getName());
extActDocCategory.setPadre(padre);
externalActivity.setDocumentCategory(extActDocCategory);
// Preselect last selected options
Setting val = settings.get(SettingPath.BITACORE_LAST_ROLEID, false);
int projectRoleId = SettingManager.getInt(val, -1);
Project pr = null;
if (projectRoleId != -1) {
ProjectRole projectRole;
try {
projectRole = projectRoleMgr.getEntityById(projectRoleId);
if (!projectRole.getProject().isFinished()) {
setRole(projectRole);
setSelectedProject(projectRole.getProject());
setSelectedOrganization(getSelectedProject().getClient());
pr = projectRole.getProject();
}
} catch (ObjectNotFoundException onfex) {
// Caso especial. Si no se localiza el anterior rol, continuamos con la
// ejecucion.
}
}
if (pr != null) {
setBillable(pr.getBillable());
setDefaultBillable(pr.getBillable());
} else {
val = settings.get(SettingPath.BITACORE_LAST_BILLABLE, false);
setBillable(SettingManager.getBoolean(val, false));
}
if (scheduleModel.getMode() == ScheduleModel.MONTH || scheduleModel.getMode() == ScheduleModel.WEEK) {
ActivitySearch searchToday = new ActivitySearch();
ExternalActivitySearch extActivitySearchToday = new ExternalActivitySearch();
Calendar initToday = Calendar.getInstance();
initToday.setTime(DateUtils.minHourInDate(scheduleModel.getSelectedDate()));
Calendar lastToday = Calendar.getInstance();
lastToday.setTime(DateUtils.maxHourInDate(scheduleModel.getSelectedDate()));
searchToday.setStartStartDate(initToday.getTime());
searchToday.setEndStartDate(lastToday.getTime());
extActivitySearchToday.setStartStartDate(initToday.getTime());
extActivitySearchToday.setEndStartDate(lastToday.getTime());
// Try to obtain the last hour in day.
searchToday.setUser(authManager.getCurrentPrincipal().getUser());
extActivitySearchToday.setOwner(authManager.getCurrentPrincipal().getUser());
List<Activity> activities = manager.getAllEntities(searchToday, new SortCriteria(sortColumn, sortAscending));
List<ExternalActivity> extActivities = externalActivityManager.getAllEntities(extActivitySearchToday, new SortCriteria(sortColumn, sortAscending));
if (activities.size() > 0 && extActivities.size() <= 0) {
// No externalActivities
// sort is descendent
Collections.sort(activities, new compareActivitiesByStartAndDuration());
activity.setStartDate(activities.get(0).getEndDate());
externalActivity.setStartDate(activities.get(0).getEndDate());
externalActivity.setEndDate(activities.get(0).getEndDate());
} else if (activities.size() <= 0 && extActivities.size() > 0) {
// No activities
Collections.sort(extActivities, new compareExternalActivitiesActivitiesByStartAndDuration());
activity.setStartDate(extActivities.get(0).getEndDate());
externalActivity.setStartDate(extActivities.get(0).getEndDate());
externalActivity.setEndDate(extActivities.get(0).getEndDate());
} else if (activities.size() > 0 && extActivities.size() > 0) {
Collections.sort(activities, new compareActivitiesByStartAndDuration());
Collections.sort(extActivities, new compareExternalActivitiesActivitiesByStartAndDuration());
Date lastActivityEndDate = activities.get(0).getEndDate();
Date lastExtActivityEndDate = extActivities.get(0).getEndDate();
Date startDate = (lastActivityEndDate.compareTo(lastExtActivityEndDate) > 0) ? lastActivityEndDate : lastExtActivityEndDate;
activity.setStartDate(startDate);
externalActivity.setStartDate(startDate);
externalActivity.setEndDate(startDate);
}
}
tabsRendered = NO_EDIT_SELECTED;
return NavigationResults.CREATE;
}
Aggregations