@Override public String execute() throws Exception { TaskId taskId = new TaskId(TaskCategory.DATAMART, currentUserService.getCurrentUser()); notifier.clear(taskId); ScheduledTasks tasks = new ScheduledTasks(); // --------------------------------------------------------------------- // Analytics // --------------------------------------------------------------------- if (analytics) { analyticsTableTask.setTaskId(taskId); tasks.addTask(resourceTableTask); tasks.addTask(analyticsTableTask); } // --------------------------------------------------------------------- // Data mart // --------------------------------------------------------------------- if (dataMart) { Date start = DateUtils.getMediumDate(startDate); Date end = DateUtils.getMediumDate(endDate); List<Period> periods = new ArrayList<Period>(); for (String type : periodTypes) { CalendarPeriodType periodType = (CalendarPeriodType) PeriodType.getPeriodTypeByName(type); periods.addAll(periodType.generatePeriods(start, end)); } if (periods.size() > 0) { dataMartTask.setPeriods(periods); dataMartTask.setTaskId(taskId); tasks.addTask(dataMartTask); } } if (!tasks.isEmpty()) { scheduler.executeTask(tasks); } return SUCCESS; }
public String execute() throws Exception { String periodType = "Quarterly"; // periodType = periodType != null && !periodType.isEmpty() ? periodType : // MonthlyPeriodType.NAME; CalendarPeriodType _periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName(periodType); int thisYear = Calendar.getInstance().get(Calendar.YEAR); int currentYear = (Integer) SessionUtils.getSessionVar(SessionUtils.KEY_CURRENT_YEAR, thisYear); Calendar cal = PeriodType.createCalendarInstance(); // Cannot go to next year if current year equals this year if (!(currentYear == thisYear && year > 0)) { cal.set(Calendar.YEAR, currentYear); cal.add(Calendar.YEAR, year); SessionUtils.setSessionVar(SessionUtils.KEY_CURRENT_YEAR, cal.get(Calendar.YEAR)); } periods = _periodType.generatePeriods(cal.getTime()); FilterUtils.filter(periods, new PastAndCurrentPeriodFilter()); Collections.reverse(periods); for (Period period : periods) { period.setName(format.formatPeriod(period)); } return SUCCESS; }