From ed24855836fd1f306aeb164aaac5abab2160d99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Tilve=20=C3=81lvaro?= Date: Wed, 6 Feb 2013 12:40:17 +0100 Subject: [PATCH] Refactored to external class methods to handle filters session parameters FEA: ItEr77S15FilteringEnhancements --- .../org/libreplan/web/common/FilterUtils.java | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 libreplan-webapp/src/main/java/org/libreplan/web/common/FilterUtils.java diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/FilterUtils.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/FilterUtils.java new file mode 100644 index 000000000..2985c1574 --- /dev/null +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/FilterUtils.java @@ -0,0 +1,140 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2013 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.web.common; + +import java.util.Date; +import java.util.List; + +import org.joda.time.LocalDate; +import org.libreplan.web.common.components.finders.FilterPair; +import org.zkoss.zk.ui.Sessions; + +/** + * Manages operations to read and write filter parameters from the session
+ * + * @author Lorenzo Tilve Álvaro + */ +public class FilterUtils { + + // Company view and Project list session variables + + public static Date readProjectsStartDate() { + return (Date) Sessions.getCurrent().getAttribute( + "companyFilterStartDate"); + } + + public static Date readProjectsEndDate() { + return (Date) Sessions.getCurrent() + .getAttribute("companyFilterEndDate"); + } + + public static List readProjectsParameters() { + return (List) Sessions.getCurrent().getAttribute( + "companyFilterLabel"); + } + + public static void writeProjectsStartDate(Date date) { + Sessions.getCurrent().setAttribute("companyFilterStartDate", date); + } + + public static void writeProjectsEndDate(Date date) { + Sessions.getCurrent().setAttribute("companyFilterEndDate", date); + } + + public static void writeProjectsParameters(List parameters) { + Sessions.getCurrent().getAttribute("companyFilterLabel"); + } + + public static void writeProjectsFilter(Date startDate, Date endDate, + List parameters) { + writeProjectsStartDate(startDate); + writeProjectsEndDate(endDate); + writeProjectsParameters(parameters); + } + + // Resources load filter + + public static LocalDate readResourceLoadsStartDate() { + return (LocalDate) Sessions.getCurrent().getAttribute( + "resourceLoadStartDate"); + } + + public static LocalDate readResourceLoadsEndDate() { + return (LocalDate) Sessions.getCurrent().getAttribute( + "resourceLoadEndDate"); + } + + public static List readResourceLoadsBandbox() { + return (List) Sessions.getCurrent().getAttribute( + "resourceLoadFilterWorkerOrCriterion"); + } + + public static void writeResourceLoadsStartDate(LocalDate date) { + Sessions.getCurrent().setAttribute("resourceLoadStartDate", date); + } + + public static void writeResourceLoadsEndDate(LocalDate date) { + Sessions.getCurrent().setAttribute("resourceLoadEndDate", date); + } + + public static void writeResourceLoadsParameters(List parameters) { + Sessions.getCurrent().getAttribute( + "resourceLoadFilterWorkerOrCriterion"); + } + + // Project gantt and WBS filter parameters + + public static Date readOrderStartDate(String orderCode) { + return (Date) Sessions.getCurrent().getAttribute( + orderCode + "-startDateFilter"); + } + + public static Date readOrderEndDate(String orderCode) { + return (Date) Sessions.getCurrent().getAttribute( + orderCode + "-endDateFilter"); + } + + public static String readOrderTaskName(String orderCode) { + return (String) Sessions.getCurrent().getAttribute( + orderCode + "-tasknameFilter"); + } + + public static List readOrderParameters(String orderCode) { + return (List) Sessions.getCurrent().getAttribute( + orderCode + "-labelsandcriteriaFilter"); + } + + public static Boolean readOrderInheritance(String orderCode) { + return (Boolean) Sessions.getCurrent().getAttribute( + orderCode + "-inheritanceFilter"); + } + + public static void writeOrderStartDate(String orderCode, Date date) { + Sessions.getCurrent() + .setAttribute(orderCode + "-startDateFilter", date); + } + public static void writeOrderEndDate(String orderCode, Date date) { + Sessions.getCurrent().setAttribute(orderCode + "-endDateFilter", date); + } + public static void writeOrderTaskName(String orderCode, String name) { + Sessions.getCurrent().setAttribute(orderCode + "-tasknameFilter", name); + } + +}