diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningController.java index e5f38f61f..82133d1ac 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningController.java @@ -31,10 +31,16 @@ import java.util.Map; import org.apache.commons.lang.Validate; import org.libreplan.business.common.entities.ProgressType; +import org.libreplan.business.common.exceptions.InstanceNotFoundException; import org.libreplan.business.planner.entities.TaskElement; +import org.libreplan.business.users.daos.IUserDAO; +import org.libreplan.business.users.entities.User; import org.libreplan.business.users.entities.UserRole; import org.libreplan.web.common.components.bandboxsearch.BandboxMultipleSearch; import org.libreplan.web.common.components.finders.FilterPair; +import org.libreplan.web.common.components.finders.IFilterEnum; +import org.libreplan.web.common.components.finders.OrderFilterEnum; +import org.libreplan.web.common.components.finders.TaskGroupFilterEnum; import org.libreplan.web.planner.TaskGroupPredicate; import org.libreplan.web.planner.tabs.MultipleTabsPlannerController; import org.libreplan.web.security.SecurityUtils; @@ -76,6 +82,9 @@ public class CompanyPlanningController implements Composer { @Autowired private ICompanyPlanningModel model; + @Autowired + private IUserDAO userDAO; + private List> additional = new ArrayList>(); private Planner planner; @@ -136,6 +145,8 @@ public class CompanyPlanningController implements Composer { bdFilters = (BandboxMultipleSearch) filterComponent .getFellow("bdFilters"); bdFilters.setFinder("taskGroupsMultipleFiltersFinder"); + loadPredefinedBandboxFilter(); + checkIncludeOrderElements = (Checkbox) filterComponent .getFellow("checkIncludeOrderElements"); filterComponent.setVisible(true); @@ -144,6 +155,24 @@ public class CompanyPlanningController implements Composer { } + private void loadPredefinedBandboxFilter() { + User user; + try { + user = this.userDAO.findByLoginName(SecurityUtils + .getSessionUserLoginName()); + } catch (InstanceNotFoundException e) { + throw new RuntimeException(e); + } + + // Calculate filter based on user preferences + if ((user != null) && (user.getProjectsFilterLabel() != null)) { + bdFilters.addSelectedElement(new FilterPair( + TaskGroupFilterEnum.Label, user.getProjectsFilterLabel() + .getCompleteName(), user + .getProjectsFilterLabel())); + } + } + /** * Checks the creation permissions of the current user and enables/disables * the create buttons accordingly. @@ -305,6 +334,7 @@ public class CompanyPlanningController implements Composer { filterFinishDate.setValue(model.getFilterFinishDate(). toDateMidnight().toDate()); } + return predicate; } return new TaskGroupPredicate(listFilters, startDate, finishDate,