View Javadoc

1   /*
2    * Generated by MyEclipse Struts
3    * Template path: templates/java/JavaClass.vtl
4    */
5   package hu.elte.tribus.action;
6   
7   import hu.elte.tribus.interfaces.ConversationDao;
8   import hu.elte.tribus.interfaces.QaDao;
9   import hu.elte.tribus.interfaces.UserDao;
10  import hu.elte.tribus.model.Conversation;
11  import hu.elte.tribus.model.Topic;
12  import hu.elte.tribus.model.User;
13  import hu.elte.tribus.util.AuthUtil;
14  
15  import java.util.Date;
16  
17  import javax.servlet.http.HttpServletRequest;
18  import javax.servlet.http.HttpServletResponse;
19  
20  import org.apache.struts.action.ActionForm;
21  import org.apache.struts.action.ActionForward;
22  import org.apache.struts.action.ActionMapping;
23  import org.springframework.web.struts.ActionSupport;
24  
25  /*** 
26   * MyEclipse Struts
27   * Creation date: 11-10-2006
28   * 
29   * XDoclet definition:
30   * @struts.action validate="true"
31   */
32  public class StartConversationAction extends ActionSupport {
33  	/*
34  	 * Generated Methods
35  	 */
36  
37  	/*** 
38  	 * Method execute
39  	 * @param mapping
40  	 * @param form
41  	 * @param request
42  	 * @param response
43  	 * @return ActionForward
44  	 */
45  	public ActionForward execute(ActionMapping mapping, ActionForm form,
46  			HttpServletRequest request, HttpServletResponse response) {
47  		QaDao qaDao = (QaDao) getWebApplicationContext().getBean("qaDao");
48  		UserDao userDao = (UserDao) getWebApplicationContext().getBean("userDao");
49  		ConversationDao conversationDao = (ConversationDao) getWebApplicationContext().getBean("conversationDao");
50  		Topic topic = qaDao.getTopicById(Integer.parseInt(request.getParameter("tid")));
51  		Conversation conversation = new Conversation();
52  		conversation.setStartdate(new Date());
53  		conversation.setTopic(topic);
54  		User user = userDao.getUser(AuthUtil.getCurentUserName());
55  		conversation.setUser(user);
56  		request.setAttribute("topic", topic);
57  		conversationDao.saveConversation(conversation);
58  		request.getSession(true).setAttribute("conversation-id", conversation.getId());
59  		return mapping.findForward("ok");
60  	}
61  }