Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jeteam.bean.project.web
Class ProjectCRUDDispatchAction  view ProjectCRUDDispatchAction download ProjectCRUDDispatchAction.java

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.apache.struts.actions.DispatchAction
          extended byorg.jeteam.bean.common.web.AbstractCRUDDispatchAction
              extended byorg.jeteam.bean.project.web.ProjectCRUDDispatchAction

public class ProjectCRUDDispatchAction
extends org.jeteam.bean.common.web.AbstractCRUDDispatchAction

This class extends the AbstractCRUDDispatchAction class to provide a means to gather similar functionality for CRUD operations on a project.

All methods prefixed with "go" are used to pre-populate the form bean with data required by the accompanying CRUD method, for example goCreate(...) sets those values in the form bean that will be required for a user to effectively call create(...), one should always dispatch to the methods prefixed with "go" prior to dispatching to the actual method.


Field Summary
 
Fields inherited from class org.apache.struts.actions.DispatchAction
clazz, log, messages, methods, types
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
ProjectCRUDDispatchAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward create(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Reads the project name and description from the form bean, together with the users to whom this project will be assigned as well as the status.
private  org.jeteam.bean.project.ProjectDTO getProject(ProjectCRUDDispatchForm dataForm)
          Gets the project as a DTO from the form bean.
private  org.jeteam.bean.config.StatusDTO getStatus(ProjectCRUDDispatchForm dataForm)
          Gets the status as a DTO from the form bean.
private  org.jeteam.bean.user.UserDTO[] getUsers(ProjectCRUDDispatchForm dataForm)
          Retrieves the selected users from the form bean and returns the associated DTOs.
 org.apache.struts.action.ActionForward goCreate(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method should be called prior to an attempt to create a new project, this method sets the current list of active users and the list of statusses in the form bean and forwards to "create".
 org.apache.struts.action.ActionForward goRead(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method should be called prior to an attempt to read one of the projects, this method sets the current list of active projects in the form bean and forwards to "read".
 org.apache.struts.action.ActionForward goRemove(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Sets the current list of active projects in the form bean and forwards to "remove".
 org.apache.struts.action.ActionForward goUpdate(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This method is needed to populate the form bean prior to making an update to a project, in order to be able to do such an update the user needs to know the set of users statusses and projects.
 org.apache.struts.action.ActionForward populate(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Populates the form with the values of the project DTO instance corresponding with the current project name.
 org.apache.struts.action.ActionForward read(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Takes the project name from the form, retrieves the associated project from the data-source and populates the form bean with the users, status and tasks associated to this project.
 org.apache.struts.action.ActionForward remove(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Removes the project as specified by name in the form bean.
private  void setRequestParameterValue(javax.servlet.http.HttpServletRequest request, ProjectCRUDDispatchForm dataForm)
          Reads the request and looks for a parameter with key "item", if this value is found it will be set as the project name in the form bean.
 org.apache.struts.action.ActionForward unspecified(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This is the default executor for this dispatch action, it will simply return the "home" forward.
 org.apache.struts.action.ActionForward update(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Gets the users, status and project from the form bean and updates the project with the specified values.
 
Methods inherited from class org.apache.struts.actions.DispatchAction
cancelled, dispatchMethod, execute, getMethod, getMethodName, getParameter
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectCRUDDispatchAction

public ProjectCRUDDispatchAction()
Method Detail

unspecified

public org.apache.struts.action.ActionForward unspecified(org.apache.struts.action.ActionMapping mapping,
                                                          org.apache.struts.action.ActionForm form,
                                                          javax.servlet.http.HttpServletRequest request,
                                                          javax.servlet.http.HttpServletResponse response)
                                                   throws java.lang.Exception
This is the default executor for this dispatch action, it will simply return the "home" forward.


populate

public org.apache.struts.action.ActionForward populate(org.apache.struts.action.ActionMapping mapping,
                                                       org.apache.struts.action.ActionForm form,
                                                       javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response)
                                                throws java.lang.Exception
Populates the form with the values of the project DTO instance corresponding with the current project name.

More concretely get the specified project DTO instance from the existing list and sets the name and description into the form bean. Next the users assigned to this project are looked up, their names will also be set into the form bean, the same thing is done for the status.

If the request contains a parameter with key "name" the associated entity will override the default one in the form bean.

Forwards to "update".


goRead

public org.apache.struts.action.ActionForward goRead(org.apache.struts.action.ActionMapping mapping,
                                                     org.apache.struts.action.ActionForm form,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     javax.servlet.http.HttpServletResponse response)
                                              throws java.lang.Exception
This method should be called prior to an attempt to read one of the projects, this method sets the current list of active projects in the form bean and forwards to "read".

This list is required if users want to select a project to view.

If there is a request parameter with key "name" or the form bean has a non-null "projectName" property this method will execute a call to read(...) to populate the form bean with the properties of the project associated with the specified project name, prior to forwarding.


goCreate

public org.apache.struts.action.ActionForward goCreate(org.apache.struts.action.ActionMapping mapping,
                                                       org.apache.struts.action.ActionForm form,
                                                       javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response)
                                                throws java.lang.Exception
This method should be called prior to an attempt to create a new project, this method sets the current list of active users and the list of statusses in the form bean and forwards to "create".

Creating a project involves relations with users and a status, since these are seperate entities as opposed to the project properties we need the user to be able to select them.


goUpdate

public org.apache.struts.action.ActionForward goUpdate(org.apache.struts.action.ActionMapping mapping,
                                                       org.apache.struts.action.ActionForm form,
                                                       javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response)
                                                throws java.lang.Exception
This method is needed to populate the form bean prior to making an update to a project, in order to be able to do such an update the user needs to know the set of users statusses and projects. These values will persist between different requests (actually they persist during the session).

Sets the current list of active users and projects, and the list of statusses in the form bean and forwards to "update".

All these entities are required if the user decides to update the current state of the project.

If there is at least one active project the first one available will have its name set into the form bean by calling populate(...).


goRemove

public org.apache.struts.action.ActionForward goRemove(org.apache.struts.action.ActionMapping mapping,
                                                       org.apache.struts.action.ActionForm form,
                                                       javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response)
                                                throws java.lang.Exception
Sets the current list of active projects in the form bean and forwards to "remove".

This list is required if users want to select a project to remove.


read

public org.apache.struts.action.ActionForward read(org.apache.struts.action.ActionMapping mapping,
                                                   org.apache.struts.action.ActionForm form,
                                                   javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response)
                                            throws java.lang.Exception
Takes the project name from the form, retrieves the associated project from the data-source and populates the form bean with the users, status and tasks associated to this project.

Forwards to "read" in case of success or failure.

If the request contains a parameter with key "name" the associated entity will override the default one in the form bean.


create

public org.apache.struts.action.ActionForward create(org.apache.struts.action.ActionMapping mapping,
                                                     org.apache.struts.action.ActionForm form,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     javax.servlet.http.HttpServletResponse response)
                                              throws java.lang.Exception
Reads the project name and description from the form bean, together with the users to whom this project will be assigned as well as the status. Those values will be assigned to the project.

Any previously assigned users will be cleared from the project before associating the new users.

Forwards to "home" in case of success, to "failure" otherwise.


remove

public org.apache.struts.action.ActionForward remove(org.apache.struts.action.ActionMapping mapping,
                                                     org.apache.struts.action.ActionForm form,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     javax.servlet.http.HttpServletResponse response)
                                              throws java.lang.Exception
Removes the project as specified by name in the form bean.

Forwards to "home" in case of success, to "failure" otherwise.

If the request contains a parameter with key "name" the associated entity will override the default one in the form bean.


update

public org.apache.struts.action.ActionForward update(org.apache.struts.action.ActionMapping mapping,
                                                     org.apache.struts.action.ActionForm form,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     javax.servlet.http.HttpServletResponse response)
                                              throws java.lang.Exception
Gets the users, status and project from the form bean and updates the project with the specified values. Project relations are also updated (assigned users and status).

The name of a project cannot be changed after creation.

If the request contains a parameter with key "name" the associated entity will override the default one in the form bean.

Forwards to "home" in case of success, to "failure" otherwise.


getUsers

private final org.jeteam.bean.user.UserDTO[] getUsers(ProjectCRUDDispatchForm dataForm)
Retrieves the selected users from the form bean and returns the associated DTOs.

For all selected user names a lookup is performed to find the corresponding DTO instance. This method never returns null, in case no user is returned the array will be of size 0.


getStatus

private final org.jeteam.bean.config.StatusDTO getStatus(ProjectCRUDDispatchForm dataForm)
Gets the status as a DTO from the form bean.

The status name String value is used to lookup the corresponding DTO instance, this one is returned. In case none is found this method returns null.


getProject

private final org.jeteam.bean.project.ProjectDTO getProject(ProjectCRUDDispatchForm dataForm)
Gets the project as a DTO from the form bean.

The project name String value is used to lookup the corresponding DTO instance, this one is returned. In case none is found this method returns null.


setRequestParameterValue

private final void setRequestParameterValue(javax.servlet.http.HttpServletRequest request,
                                            ProjectCRUDDispatchForm dataForm)
Reads the request and looks for a parameter with key "item", if this value is found it will be set as the project name in the form bean.