/** Update available report criteria */ public ReportCriteria syncUserReportCriteria( ReportCriteria reportCriteria, ReportCriteriaUpdateType updateType) { UserCriteria userCriteria = reportCriteria.getUserCriteria(); AvailableCriteria availCriteria = reportCriteria.getAvailableCriteria(); if (userCriteria.isSingleUser()) { syncCriteriaForSingleUser(reportCriteria); } else { if (updateType == ReportCriteriaUpdateType.UPDATE_CUSTOMERS || updateType == ReportCriteriaUpdateType.UPDATE_ALL) { availCriteria.setCustomers(getAvailableCustomers(userCriteria)); } if (updateType == ReportCriteriaUpdateType.UPDATE_PROJECTS || updateType == ReportCriteriaUpdateType.UPDATE_ALL) { availCriteria.setProjects(getAvailableProjects(userCriteria)); } if (updateType == ReportCriteriaUpdateType.UPDATE_ALL) { availCriteria.setUserDepartments(userDepartmentDAO.findAll()); availCriteria.setReportRange(reportAggregatedDAO.getMinMaxDateTimesheetEntry()); } if (updateType == ReportCriteriaUpdateType.UPDATE_USERS || updateType == ReportCriteriaUpdateType.UPDATE_ALL) { availCriteria.setUsers(getAvailableUsers(userCriteria)); } } return reportCriteria; }
@Test public void submit() { FormTester formTester = tester.newFormTester( "printSelectionFrame:printSelectionFrame_body:blueBorder:blueBorder_body:selectionForm:criteriaForm"); formTester.selectMultiple("billableProjectGroup", new int[] {0, 2}); formTester.setValue("signOff", "true"); formTester.submit("store"); tester.assertNoErrorMessage(); assertEquals( Boolean.TRUE, reportCriteria .getUserSelectedCriteria() .getCustomParameters() .get(TimesheetExportParameter.INCL_SIGN_OFF.name())); assertEquals(2, reportCriteria.getUserSelectedCriteria().getProjects().size()); Integer id = reportCriteria.getUserSelectedCriteria().getProjects().get(1).getProjectId(); // order is unknown if (id != 0 && id != 2) { fail("id should be 0 or 2"); } verifyMocks(); }
/* (non-Javadoc) * @see net.rrm.ehour.persistence.persistence.ui.common.report.AbstractReportModel#getReportData(net.rrm.ehour.persistence.persistence.report.criteria.ReportCriteria) */ @Override protected ReportData getReportData(ReportCriteria reportCriteria) { WebUtils.springInjection(this); UserSelectedCriteria userSelectedCriteria = reportCriteria.getUserSelectedCriteria(); List<Audit> audit = auditService.findAudits((AuditReportRequest) userSelectedCriteria); return new ReportData(convert(audit), reportCriteria.getReportRange(), userSelectedCriteria); }
private CompoundPropertyModel<ReportCriteria> createModelForMonth(Calendar forMonth) { ReportCriteria reportCriteria = getReportCriteria(); reportCriteria.getUserCriteria().setReportRange(DateUtil.getDateRangeForMonth(forMonth)); if (reportCriteria.getUserCriteria().getProjects() == null) { reportCriteria.getUserCriteria().setProjects(new ArrayList<Project>()); } return new CompoundPropertyModel<ReportCriteria>(reportCriteria); }
/** * Sync criteria for users, only customers & projects are displayed for users in this list * * @param reportCriteria */ private void syncCriteriaForSingleUser(ReportCriteria reportCriteria) { Set<Customer> customers = new HashSet<Customer>(); Set<Project> projects = new HashSet<Project>(); AvailableCriteria availCriteria = reportCriteria.getAvailableCriteria(); User user; user = reportCriteria.getUserCriteria().getUsers().get(0); List<ProjectAssignment> assignments = projectAssignmentDAO.findProjectAssignmentsForUser( user.getUserId(), reportCriteria.getUserCriteria().getReportRange()); for (ProjectAssignment assignment : assignments) { customers.add(assignment.getProject().getCustomer()); projects.add(assignment.getProject()); } availCriteria.setCustomers(new ArrayList<Customer>(customers)); availCriteria.setProjects(new ArrayList<Project>(projects)); availCriteria.setReportRange(reportAggregatedDAO.getMinMaxDateTimesheetEntry(user)); }