r38 - in trunk/chorem-web/src/main: java/org/chorem/gepeto/action resources/i18n resources/org/chorem/gepeto/action
Author: vbriand Date: 2011-03-24 11:30:02 +0100 (Thu, 24 Mar 2011) New Revision: 38 Url: http://chorem.org/repositories/revision/chorem/38 Log: Implemented TaskAction's add method Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java trunk/chorem-web/src/main/java/org/chorem/gepeto/action/TaskAction.java trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/TaskAction-validation.xml Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java 2011-03-24 09:47:31 UTC (rev 37) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectAction.java 2011-03-24 10:30:02 UTC (rev 38) @@ -5,6 +5,7 @@ import org.chorem.ChoremProxy; import org.chorem.action.BaseAction; import org.chorem.entities.ProjectImpl; + import static org.nuiton.i18n.I18n.n_; /** @@ -17,39 +18,8 @@ private static final long serialVersionUID = 498267854350348906L; private static final Log log = LogFactory.getLog(ProjectAction.class); - - protected String name; - protected String description; /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name: the project name - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the project description - */ - public String getDescription() { - return description; - } - - /** - * @param description: the project description - */ - public void setDescription(String description) { - this.description = description; - } - - /** * Adds a new project * * @return INPUT if the mandatory fields haven't all been filled in @@ -79,8 +49,40 @@ * @return */ public String remove() { + //TODO: implement return SUCCESS; } + + protected String name; + protected String description; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name: the project name + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the project description + */ + public String getDescription() { + return description; + } + + /** + * @param description: the project description + */ + public void setDescription(String description) { + this.description = description; + } /** * Stores the new project through the proxy Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/TaskAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/TaskAction.java 2011-03-24 09:47:31 UTC (rev 37) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/TaskAction.java 2011-03-24 10:30:02 UTC (rev 38) @@ -3,10 +3,16 @@ */ package org.chorem.gepeto.action; +import java.util.Date; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.ChoremProxy; import org.chorem.action.BaseAction; +import org.chorem.entities.TaskImpl; +import static org.nuiton.i18n.I18n.n_; + /** * Task management class * @@ -18,14 +24,66 @@ private static final Log log = LogFactory.getLog(TaskAction.class); + /** + * Adds a new task + * + * @return INPUT if the mandatory fields haven't all been filled in + * @return SUCCESS if the task has been added successfully + * @return ERROR if an error occurred + */ + public String add() { + String result = INPUT; + + if (name != null && description != null && + beginDate != null && estimatedEndDate != null) { + if (!name.isEmpty() && !description.isEmpty()) { + //If the task has been added successfully + if (addTask()) { + result = SUCCESS; + } else { + result = ERROR; + } + } + } + return result; + } + protected String name; protected String description; protected String price; protected String estimatedDays; - protected String beginDate; - protected String estimatedEndDate; + protected Date beginDate; + protected Date estimatedEndDate; /** + * Stores the new task through the proxy + * + * @return true if the task has been stored properly + * @return false if a problem occurred + */ + protected boolean addTask() { + boolean result = true; + + try { + ChoremProxy proxy = getChoremProxy(); + TaskImpl newTask = new TaskImpl(); + + newTask.setDescription(description); + newTask.setName(name); + newTask.setBeginDate(beginDate); + newTask.setEndDate(estimatedEndDate); + newTask.setEstimatedDays(Integer.parseInt(estimatedDays)); + newTask.setPrice(Float.parseFloat(price)); + proxy.store(newTask); + } catch (Exception e) { + result = false; + addActionError(getText(n_("chorem.gepeto.task.create.error"))); + log.error("An error occured while creating a new task", e); + } + return result; + } + + /** * @return the name */ public String getName() { @@ -84,40 +142,28 @@ /** * @return the beginDate */ - public String getBeginDate() { + public Date getBeginDate() { return beginDate; } /** * @param beginDate the beginDate to set */ - public void setBeginDate(String beginDate) { + public void setBeginDate(Date beginDate) { this.beginDate = beginDate; } /** * @return the estimatedEndDate */ - public String getEstimatedEndDate() { + public Date getEstimatedEndDate() { return estimatedEndDate; } /** * @param estimatedEndDate the estimatedEndDate to set */ - public void setEstimatedEndDate(String estimatedEndDate) { + public void setEstimatedEndDate(Date estimatedEndDate) { this.estimatedEndDate = estimatedEndDate; } - - /** - * Adds a new task - * - * @return INPUT if the mandatory fields haven't all been filled in - * @return SUCCESS if the task has been added successfully - * @return ERROR if an error occurred - */ - public String add() { - //TODO: implement - return SUCCESS; - } } Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-03-24 09:47:31 UTC (rev 37) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-03-24 10:30:02 UTC (rev 38) @@ -36,6 +36,7 @@ chorem.gepeto.task.add=Add a new task chorem.gepeto.task.beginDate=Begin date chorem.gepeto.task.beginDate.required=You must enter the begin date for this task +chorem.gepeto.task.create.error=An error occurred while creating your new task, please try again. If the problem persists, please contact an administrator chorem.gepeto.task.date.wrongFormat=The date must be in the following format \: XX/YY/ZZZZ chorem.gepeto.task.description=Description chorem.gepeto.task.description.required=You must describe the task Modified: trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties =================================================================== --- trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-03-24 09:47:31 UTC (rev 37) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-03-24 10:30:02 UTC (rev 38) @@ -36,6 +36,7 @@ chorem.gepeto.task.add=Ajouter une nouvelle t\u00E2che chorem.gepeto.task.beginDate=Date de d\u00E9but chorem.gepeto.task.beginDate.required=Vous devez renseigner la date de d\u00E9but de la t\u00E2che +chorem.gepeto.task.create.error=Une erreur s''est produite lors de la cr\u00E9ation de votre nouvelle t\u00E2che, merci d''essayer \u00E0 nouveau. Si le probl\u00E8me se reproduit, merci de contacter un administrateur chorem.gepeto.task.date.wrongFormat=La date doit respecter le format suivant \: XX/YY/ZZZZ chorem.gepeto.task.description=Description chorem.gepeto.task.description.required=Vous devez d\u00E9crire la t\u00E2che Modified: trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/TaskAction-validation.xml =================================================================== --- trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/TaskAction-validation.xml 2011-03-24 09:47:31 UTC (rev 37) +++ trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/TaskAction-validation.xml 2011-03-24 10:30:02 UTC (rev 38) @@ -32,7 +32,7 @@ </field-validator> </field> <field name="beginDate"> - <field-validator type="requiredstring"> + <field-validator type="required"> <message key="chorem.gepeto.task.beginDate.required" /> </field-validator> <field-validator type="regex"> @@ -41,7 +41,7 @@ </field-validator> </field> <field name="estimatedEndDate"> - <field-validator type="requiredstring"> + <field-validator type="required"> <message key="chorem.gepeto.task.estimatedEndDate.required" /> </field-validator> <field-validator type="regex">
participants (1)
-
vbriand@users.chorem.org