001 // Copyright 2008 Thiago H. de Paula Figueiredo
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package br.com.arsmachina.example.web.pages.project;
016
017 import java.util.List;
018
019 import org.apache.tapestry5.SelectModel;
020 import org.apache.tapestry5.annotations.Mixin;
021 import org.apache.tapestry5.ioc.annotations.Inject;
022 import org.springframework.security.annotation.Secured;
023
024 import br.com.arsmachina.authentication.controller.UserController;
025 import br.com.arsmachina.authentication.entity.User;
026 import br.com.arsmachina.example.entity.Manager;
027 import br.com.arsmachina.example.entity.Project;
028 import br.com.arsmachina.tapestrycrud.base.BaseEditPage;
029 import br.com.arsmachina.tapestrycrud.hibernatevalidator.mixins.HibernateValidatorMixin;
030
031 /**
032 * {@link Project} edit page.
033 *
034 * @author Thiago H. de Paula Figueiredo
035 */
036 @Secured("ROLE_MANAGER")
037 public class EditProject extends BaseEditPage<Project, Integer> {
038
039 @Mixin
040 @SuppressWarnings("unused")
041 private HibernateValidatorMixin hibernateValidatorMixin;
042
043 @Inject
044 private UserController userController;
045
046 /**
047 * Returns the {@link SelectModel} for the <code>manager</code> property.
048 *
049 * @return a {@link SelectModel}.
050 */
051 public SelectModel getManagerSM() {
052
053 final List<User> users = userController.findByRole(Manager.class);
054 return getSelectModelFactory().create(User.class, users);
055
056 }
057
058 }