use of com.autentia.tnt.businessobject.Activity in project TNTConcept by autentia.
the class ActivityManagerTest method shouldWorkedTime.
@Test
public void shouldWorkedTime() {
final Activity workingActivity1 = new Activity();
workingActivity1.setRole(workingRoleProject1);
workingActivity1.setDuration(100);
final Activity workingActivity2 = new Activity();
workingActivity2.setRole(workingRoleProject2);
workingActivity2.setDuration(150);
final Activity notWorkingActivity1 = new Activity();
notWorkingActivity1.setRole(notWorkingRoleProject1);
notWorkingActivity1.setDuration(11);
final Activity notWorkingActivity2 = new Activity();
notWorkingActivity2.setRole(notWorkingRoleProject2);
notWorkingActivity2.setDuration(12);
final List<Activity> activities = Arrays.asList(workingActivity1, notWorkingActivity1, workingActivity2, notWorkingActivity2);
Assert.assertEquals(250L, activityManager.workedTime(activities));
}
use of com.autentia.tnt.businessobject.Activity in project TNTConcept by autentia.
the class ActivityBean method fillActivities.
private void fillActivities(SimpleScheduleModel model) {
ActivitySearch searchMonth = new ActivitySearch();
Calendar calMin = Calendar.getInstance();
Calendar calMax = Calendar.getInstance();
calMin = getMinimumSearchTime(selectedDate);
calMax = getMaximumSearchTime(selectedDate);
searchMonth.setStartStartDate(calMin.getTime());
searchMonth.setEndStartDate(calMax.getTime());
searchMonth.setUser(authManager.getCurrentPrincipal().getUser());
/* search data in persistence layer */
List<Activity> activities = manager.getAllEntities(searchMonth, new SortCriteria(sortColumn, sortAscending));
List<Activity> activitiesWorkables = new ArrayList<>(activities.size());
/* load data in component */
for (Activity actualActivity : activities) {
calMin.setTime(actualActivity.getStartDate());
calMax.setTime(selectedDate);
if (calMin.get(Calendar.MONTH) == calMax.get(Calendar.MONTH)) {
activitiesWorkables.add(actualActivity);
}
ActivityScheduleEntry entry = new ActivityScheduleEntry(actualActivity);
scheduleModel.addEntry(entry);
}
monthPerformedHours = manager.workedTime(activitiesWorkables) / 60.0f;
}
use of com.autentia.tnt.businessobject.Activity in project TNTConcept by autentia.
the class GlobalHoursReportBean method getTotalHours.
public float getTotalHours() {
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());
if (billable)
search.setBillable(true);
// Search activities during indicated dates
List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name"));
// Search for projects in activities and create the global list.
float totalHours = 0.0f;
for (Activity act : activities) {
float horas = act.getDuration() / 60.0f;
totalHours = totalHours + horas;
}
return totalHours;
}
use of com.autentia.tnt.businessobject.Activity in project TNTConcept by autentia.
the class MenuBean method getMenu.
/**
* Get menu tree
* @return menu tree
*/
public TreeNode getMenu() {
// Create menu only the first time
if (menu == null) {
Principal creds = SpringUtils.getPrincipal();
Stack<TreeNode> path = new Stack<TreeNode>();
menu = new TreeNodeBase("menu", "Menu", false);
path.push(menu);
if (openNode(path, creds, null, "admin")) {
addLeaf(path, creds, Permission.Entity_Menu(User.class), "users");
addLeaf(path, creds, Permission.Entity_Menu(UserCategory.class), "userCategorys");
addLeaf(path, creds, null, "changePassword");
addLeaf(path, creds, Permission.Entity_Menu(Department.class), "departments");
// addLeaf( path, creds, Permission.Entity_Menu(Setting.class), "settings" );
closeNode(path);
}
if (openNode(path, creds, null, "masterTables")) {
addLeaf(path, creds, Permission.Entity_Menu(AccountEntryType.class), "accountEntryTypes");
addLeaf(path, creds, Permission.Entity_Menu(OrganizationType.class), "organizationTypes");
addLeaf(path, creds, Permission.Entity_Menu(InteractionType.class), "interactionTypes");
addLeaf(path, creds, Permission.Entity_Menu(OrganizationISOCategory.class), "organizationISOCategorys");
addLeaf(path, creds, Permission.Entity_Menu(ContractType.class), "contractTypes");
addLeaf(path, creds, Permission.Entity_Menu(Magazine.class), "magazines");
addLeaf(path, creds, Permission.Entity_Menu(OfferRejectReason.class), "offerRejectReasons");
closeNode(path);
}
if (openNode(path, creds, null, "billing")) {
addLeaf(path, creds, Permission.Entity_Menu(Bill.class), "bills");
addLeaf(path, creds, Permission.Entity_Menu(Account.class), "accounts");
addLeaf(path, creds, Permission.Entity_Menu(AccountEntry.class), "accountEntrys");
addLeaf(path, creds, Permission.Entity_Menu(PeriodicalAccountEntry.class), "periodicalAccountEntrys");
addLeaf(path, creds, Permission.Action_NOF, "nof");
addLeaf(path, creds, Permission.Entity_Menu(FinancialRatio.class), "financialRatios");
closeNode(path);
}
if (openNode(path, creds, null, "contacts")) {
addLeaf(path, creds, Permission.Entity_Menu(Organization.class), "organizations");
addLeaf(path, creds, Permission.Entity_Menu(Interaction.class), "interactions");
addLeaf(path, creds, Permission.Entity_Menu(Contact.class), "contacts");
addLeaf(path, creds, Permission.Entity_Menu(Offer.class), "offers");
addLeaf(path, creds, Permission.Entity_Menu(Project.class), "projects");
closeNode(path);
}
if (openNode(path, creds, null, "quality")) {
addLeaf(path, creds, Permission.Action_ListQualityDocuments, "qualityDocuments");
closeNode(path);
}
if (openNode(path, creds, null, "bulletin")) {
addLeaf(path, creds, Permission.Entity_Menu(BulletinBoard.class), "bulletinBoards");
addLeaf(path, creds, Permission.Entity_Menu(CompanyState.class), "companyStates");
addLeaf(path, creds, Permission.Entity_Menu(BulletinBoardCategory.class), "bulletinBoardCategorys");
addLeaf(path, creds, Permission.Entity_Menu(Idea.class), "ideas");
closeNode(path);
}
if (openNode(path, creds, null, "activity")) {
addLeaf(path, creds, Permission.Entity_Menu(Activity.class), "activitys");
addLeaf(path, creds, Permission.Entity_Menu(Objective.class), "objectives");
closeNode(path);
}
if (openNode(path, creds, null, "reports")) {
addLeaf(path, creds, Permission.Action_GeneralReports, "generalReports");
addLeaf(path, creds, Permission.Action_BitacoreReports, "bitacoreReports");
addLeaf(path, creds, Permission.Action_BillReports, "billReports");
addLeaf(path, creds, Permission.Action_ProjectReports, "projectReports");
addLeaf(path, creds, Permission.Action_InteractionReports, "interactionReports");
addLeaf(path, creds, Permission.Action_OrganizationReports, "organizationReports");
addLeaf(path, creds, Permission.Action_OfferReports, "offerReports");
addLeaf(path, creds, Permission.Action_OwnReports, "ownReports");
addLeaf(path, creds, Permission.Action_PersonalReports, "personalReports");
closeNode(path);
}
if (openNode(path, creds, null, "publish")) {
addLeaf(path, creds, Permission.Entity_Menu(Tutorial.class), "tutorials");
addLeaf(path, creds, Permission.Entity_Menu(Publication.class), "publications");
closeNode(path);
}
if (openNode(path, creds, null, "holiday")) {
addLeaf(path, creds, Permission.Entity_Menu(Holiday.class), "holidays");
addLeaf(path, creds, Permission.Entity_Menu(RequestHoliday.class), "requestHolidays");
addLeaf(path, creds, Permission.Entity_Menu(AdminHoliday.class), "adminHolidays");
closeNode(path);
}
if (openNode(path, creds, null, "utils")) {
addLeaf(path, creds, Permission.Entity_Menu(Book.class), "books");
addLeaf(path, creds, Permission.Entity_Menu(Inventary.class), "inventarys");
closeNode(path);
}
}
return menu;
}
use of com.autentia.tnt.businessobject.Activity in project TNTConcept by autentia.
the class GlobalHoursReportBean method getNextUserTotal.
public float getNextUserTotal() {
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());
if (billable)
search.setBillable(true);
if (iterator == null)
iterator = getUsers().iterator();
User user = null;
try {
user = iterator.next();
} catch (NoSuchElementException e) {
iterator = getUsers().iterator();
user = iterator.next();
}
search.setUser(user);
// Search activities during indicated dates
List<Activity> activities = manager.getAllEntities(search, new SortCriteria("role.project.client.name"));
// Search for projects in activities and create the global list.
float totalHours = 0.0f;
for (Activity act : activities) {
float horas = act.getDuration() / 60.0f;
totalHours = totalHours + horas;
}
return totalHours;
}
Aggregations