// Path: src/main/java/org/cejug/hurraa/model/User.java
// @Entity
// public class User implements Serializable {
// 
//     private static final long serialVersionUID = 1L;
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private Long id;
// 
//     @NotNull
//     private String name;
// 
//     @NotNull
//     private String email;
// 
//     //TODO: Now the passoword will be open. Later in the project we will hash it.
//     @NotNull
//     private String password;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     @Override
//     public String toString() {
//         return "User [id=" + id + ", name=" + name + ", mail=" + email + "]";
//     }
// }
// 
// Path: src/main/java/org/cejug/hurraa/model/bean/UserBean.java
// @Stateless
// public class UserBean extends AbstractBean<User> {
// 
// 	@PersistenceContext
// 	private EntityManager manager;
// 	
// 	public UserBean() {
// 		super(User.class);
// 	}
// 
// 	@Override
// 	protected EntityManager getEntityManager() {
// 		return this.manager;
// 	}
// }


import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.validator.SimpleMessage;
import br.com.caelum.vraptor.validator.Validator;
import java.util.ResourceBundle;
import javax.inject.Inject;
import javax.validation.Valid;
import org.cejug.hurraa.model.User;
import org.cejug.hurraa.model.bean.UserBean;
import org.cejug.hurraa.producer.ValidationMessages;
import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Get;
/*
* Hurraa is a web application conceived to manage resources
* in companies that need manage IT resources. Create issues
* and purchase IT materials. Copyright (C) 2014 CEJUG.
*
* Hurraa is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hurraa 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Hurraa. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
*
*/
package org.cejug.hurraa.controller;





@Path("user")
@Controller
public class UserController {

    @Inject
    private Result result;
    @Inject
    private UserBean userBean;
    @Inject
    private ResourceBundle messagesBundle;
    @Inject
    @ValidationMessages
    private ResourceBundle validationBundle;

    @Path(value = {"", "/"})
    public void index() {
        result.forwardTo(UserController.class).list();
    }

    @Path("form")
    public void form() {

    }

    @Path("form/{id}")
    public void form(Long id) {
        User user = userBean.findById(id);
        result.include(user);
    }

    @Post
    @Path("insert")
// Path: src/main/java/org/cejug/hurraa/model/User.java
// @Entity
// public class User implements Serializable {
// 
//     private static final long serialVersionUID = 1L;
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     private Long id;
// 
//     @NotNull
//     private String name;
// 
//     @NotNull
//     private String email;
// 
//     //TODO: Now the passoword will be open. Later in the project we will hash it.
//     @NotNull
//     private String password;
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     @Override
//     public String toString() {
//         return "User [id=" + id + ", name=" + name + ", mail=" + email + "]";
//     }
// }
// 
// Path: src/main/java/org/cejug/hurraa/model/bean/UserBean.java
// @Stateless
// public class UserBean extends AbstractBean<User> {
// 
// 	@PersistenceContext
// 	private EntityManager manager;
// 	
// 	public UserBean() {
// 		super(User.class);
// 	}
// 
// 	@Override
// 	protected EntityManager getEntityManager() {
// 		return this.manager;
// 	}
// }


// Path: src/main/java/org/cejug/hurraa/controller/UserController.java
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Post;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.validator.SimpleMessage;
import br.com.caelum.vraptor.validator.Validator;
import java.util.ResourceBundle;
import javax.inject.Inject;
import javax.validation.Valid;
import org.cejug.hurraa.model.User;
import org.cejug.hurraa.model.bean.UserBean;
import org.cejug.hurraa.producer.ValidationMessages;
import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Get;

/*
* Hurraa is a web application conceived to manage resources
* in companies that need manage IT resources. Create issues
* and purchase IT materials. Copyright (C) 2014 CEJUG.
*
* Hurraa is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hurraa 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Hurraa. If not, see http://www.gnu.org/licenses/gpl-3.0.html.
*
*/
package org.cejug.hurraa.controller;





@Path("user")
@Controller
public class UserController {

    @Inject
    private Result result;
    @Inject
    private UserBean userBean;
    @Inject
    private ResourceBundle messagesBundle;
    @Inject
    @ValidationMessages
    private ResourceBundle validationBundle;

    @Path(value = {"", "/"})
    public void index() {
        result.forwardTo(UserController.class).list();
    }

    @Path("form")
    public void form() {

    }

    @Path("form/{id}")
    public void form(Long id) {
        User user = userBean.findById(id);
        result.include(user);
    }

    @Post
    @Path("insert")
    public void insert(@Valid User user, String passwordConfirmation, Validator validator) {