Author: vbriand Date: 2011-04-14 11:42:59 +0200 (Thu, 14 Apr 2011) New Revision: 82 Url: http://chorem.org/repositories/revision/chorem/82 Log: Added the list of existing companies on the page used to add a project order Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.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/ProjectOrderAction-addProjectOrder-validation.xml trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/addProjectOrder.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectOrderDetails.jsp Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java 2011-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java 2011-04-14 09:42:59 UTC (rev 82) @@ -1,18 +1,12 @@ package org.chorem.bonzoms.action; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.ChoremProxy; import org.chorem.ContactDetailsConstants; import org.chorem.action.BaseAction; -import org.chorem.entities.Company; import org.chorem.entities.CompanyImpl; import org.chorem.entities.ContactDetailsImpl; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.Search; - import com.opensymphony.xwork2.ActionContext; import static org.nuiton.i18n.I18n.n_; Modified: trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java 2011-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java 2011-04-14 09:42:59 UTC (rev 82) @@ -11,7 +11,6 @@ import org.chorem.ChoremProxy; import org.chorem.action.BaseAction; import org.chorem.entities.Company; -import org.chorem.entities.CompanyImpl; import org.chorem.entities.ProjectOrder; import org.chorem.entities.ProjectOrderImpl; import org.chorem.entities.Quotation; @@ -21,6 +20,7 @@ import org.nuiton.wikitty.search.Search; import com.opensymphony.xwork2.ActionContext; + import static org.nuiton.i18n.I18n.n_; /** @@ -64,8 +64,8 @@ } else { quotationReference = quotation.getReference(); if (type != null && description != null && - beginDate != null && estimatedEndDate != null && - companyName != null && companyType != null) { + beginDate != null && estimatedEndDate != null && + companyId != null) { //If the project order has been added successfully if (addProjectOrder()) { result = SUCCESS; @@ -106,12 +106,10 @@ if (projectOrder != null) { //If the projectOrderId exists setBeginDate(projectOrder.getBeginDate().toString()); - Company company; - - company = proxy.restore(Company.class, + Company company = proxy.restore(Company.class, projectOrder.getCompany()); - setCompanyName(company.getName()); - setCompanyType(company.getType()); + + setCompany(company); setDescription(projectOrder.getDescription()); setEstimatedEndDate(projectOrder.getEndDate().toString()); setStatus(projectOrder.getStatus()); @@ -141,8 +139,8 @@ protected String estimatedEndDate; protected String quotationId; protected String quotationReference; - protected String companyName; - protected String companyType; + protected String companyId; + protected Company company; protected String projectOrderId; /** @@ -187,7 +185,6 @@ try { ChoremProxy proxy = getChoremProxy(); ProjectOrderImpl newProjectOrder = new ProjectOrderImpl(); - CompanyImpl newCompany = new CompanyImpl(); SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); newProjectOrder.setType(type); @@ -195,11 +192,13 @@ newProjectOrder.setQuotation(quotationId); newProjectOrder.setStatus(status); - newCompany.setName(companyName); - newCompany.setType(companyType); - newProjectOrder.setCompany(newCompany.getWikittyId()); + if (proxy.restore(Company.class, companyId) != null) { + newProjectOrder.setCompany(companyId); + } else { //If the id doesn't exist or is invalid + addActionError(getText(n_("chorem.gepeto.projectOrder.invalidCompany"))); + result = false; + } - //Lenient mode disabled because results may be very odd formatter.setLenient(false); try { @@ -231,7 +230,6 @@ //If everything went smoothly if (result) { - proxy.store(newCompany); proxy.store(newProjectOrder); } } catch (Exception e) { @@ -358,44 +356,44 @@ } /** - * @return the companyName + * @return the projectOrderId */ - public String getCompanyName() { - return companyName; + public String getProjectOrderId() { + return projectOrderId; } /** - * @param companyName the companyName to set + * @param projectOrderId the projectOrderId to set */ - public void setCompanyName(String companyName) { - this.companyName = companyName; + public void setProjectOrderId(String projectOrderId) { + this.projectOrderId = projectOrderId; } /** - * @return the companyType + * @return the companyId */ - public String getCompanyType() { - return companyType; + public String getCompanyId() { + return companyId; } /** - * @param companyType the companyType to set + * @param companyId the companyId to set */ - public void setCompanyType(String companyType) { - this.companyType = companyType; + public void setCompanyId(String companyId) { + this.companyId = companyId; } /** - * @return the projectOrderId + * @return the company */ - public String getProjectOrderId() { - return projectOrderId; + public Company getCompany() { + return company; } /** - * @param projectOrderId the projectOrderId to set + * @param company the company to set */ - public void setProjectOrderId(String projectOrderId) { - this.projectOrderId = projectOrderId; + public void setCompany(Company company) { + this.company = company; } } \ No newline at end of file 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-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-04-14 09:42:59 UTC (rev 82) @@ -117,6 +117,7 @@ chorem.gepeto.projectOrder.description.required=You must describe the project order chorem.gepeto.projectOrder.estimatedEndDate=Estimated end date (dd/mm/yyyy) chorem.gepeto.projectOrder.estimatedEndDate.required=You must enter the estimated end date for this project order +chorem.gepeto.projectOrder.invalidCompany= chorem.gepeto.projectOrder.status= chorem.gepeto.projectOrder.type=Type chorem.gepeto.projectOrder.type.required=You must specify the project order''s type 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-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-04-14 09:42:59 UTC (rev 82) @@ -105,6 +105,7 @@ chorem.gepeto.projectOrder.backToQuotationDetails=Retourner sur le devis chorem.gepeto.projectOrder.beginDate=Date de d\u00E9but chorem.gepeto.projectOrder.beginDate.required=Vous devez renseigner une date de d\u00E9but pour le contrat +chorem.gepeto.projectOrder.company=Entreprise chorem.gepeto.projectOrder.company.name= chorem.gepeto.projectOrder.company.type= chorem.gepeto.projectOrder.create.error=Une erreur s''est produite lors de la cr\u00E9ation de votre nouveau contrat de projet, merci d''essayer \u00E0 nouveau. Si le probl\u00E8me se reproduit, merci de contacter un administrateur @@ -112,6 +113,7 @@ chorem.gepeto.projectOrder.description.required=Vous devez d\u00E9crire le contrat chorem.gepeto.projectOrder.estimatedEndDate=Date de fin estim\u00E9e chorem.gepeto.projectOrder.estimatedEndDate.required=Vous devez renseigner la date de fin estim\u00E9e du contrat +chorem.gepeto.projectOrder.invalidCompany= chorem.gepeto.projectOrder.status= chorem.gepeto.projectOrder.type=Type chorem.gepeto.projectOrder.type.required=Vous devez sp\u00E9cifier le type du contrat Modified: trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/ProjectOrderAction-addProjectOrder-validation.xml =================================================================== --- trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/ProjectOrderAction-addProjectOrder-validation.xml 2011-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/resources/org/chorem/gepeto/action/ProjectOrderAction-addProjectOrder-validation.xml 2011-04-14 09:42:59 UTC (rev 82) @@ -36,14 +36,4 @@ <message key="chorem.date.wrongFormat" /> </field-validator> </field> - <field name="companyName"> - <field-validator type="requiredstring"> - <message key="chorem.gepeto.projectOrder.companyName.required" /> - </field-validator> - </field> - <field name="companyType"> - <field-validator type="requiredstring"> - <message key="chorem.gepeto.projectOrder.companyType.required" /> - </field-validator> - </field> </validators> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/addProjectOrder.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/addProjectOrder.jsp 2011-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/addProjectOrder.jsp 2011-04-14 09:42:59 UTC (rev 82) @@ -1,4 +1,7 @@ <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@page import="java.util.List" %> +<%@page import="org.chorem.entities.Company" %> +<%@page import="org.chorem.bonzoms.action.CompanyAction" %> <%@page import="org.chorem.gepeto.action.ProjectOrderAction" %> <%@taglib prefix="s" uri="/struts-tags" %> @@ -33,10 +36,8 @@ <br /> <s:textfield key="chorem.gepeto.projectOrder.estimatedEndDate" name="estimatedEndDate" labelSeparator=": " /> <br /> - <s:textfield key="chorem.gepeto.projectOrder.company.name" name="companyName" labelSeparator=": " /> + <s:select label="%{getText('chorem.gepeto.projectOrder.company')}" list="allCompanies" name="companyId" listKey="wikittyId" listValue="name" /> <br /> - <s:textfield key="chorem.gepeto.projectOrder.company.type" name="companyType" labelSeparator=": " /> - <br /> <s:submit key="chorem.gepeto.projectOrder.add" name="submit" /> </fieldset> </form> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectOrderDetails.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectOrderDetails.jsp 2011-04-14 08:44:10 UTC (rev 81) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/projectOrderDetails.jsp 2011-04-14 09:42:59 UTC (rev 82) @@ -27,7 +27,7 @@ </s:text> <br /> <s:text name="chorem.gepeto.projectOrderDetails.companyName"> - <s:param><%= ProjectOrderAction.getAction().getCompanyName() %></s:param> + <s:param><%= ProjectOrderAction.getAction().getCompany().getName() %></s:param> </s:text> <br /> <s:text name="chorem.gepeto.projectOrderDetails.quotation">