r94 - in trunk/chorem-web/src/main: java/org/chorem/bonzoms/action java/org/chorem/gepeto/action resources resources/i18n webapp/WEB-INF/jsp/bonzoms
Author: vbriand Date: 2011-04-15 17:06:56 +0200 (Fri, 15 Apr 2011) New Revision: 94 Url: http://chorem.org/repositories/revision/chorem/94 Log: Added the choice of the employee's company on the person's page Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.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/struts.xml trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addPerson.jsp Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.java 2011-04-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.java 2011-04-15 15:06:56 UTC (rev 94) @@ -2,16 +2,21 @@ import java.text.ParseException; import java.text.SimpleDateFormat; +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.ContactDetailsImpl; import org.chorem.entities.EmployeeImpl; import org.chorem.entities.EmploymentContractImpl; import org.chorem.entities.PersonImpl; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; import static org.nuiton.i18n.I18n.n_; @@ -67,6 +72,7 @@ protected String contractWorkingTime; protected String contractBeginDate; protected String contractEndDate; + protected String companyId; /** * Stores the new person through the proxy @@ -122,9 +128,11 @@ proxy.store(newContactDetails); } - result = storeEmployee(newPerson, result, proxy); if (result) { - proxy.store(newPerson); + result = storeEmployee(newPerson, result, proxy); + if (result) { + proxy.store(newPerson); + } } } } catch (Exception e) { @@ -177,9 +185,18 @@ n_("chorem.bonzoms.employee.rtt.wrongFormat"))); } - result = storeEmploymentContract(newEmployee, result, proxy); + if (proxy.restore(Company.class, companyId) != null) { + newEmployee.setCompany(companyId); + } else { //If the id doesn't exist or is invalid + addActionError(getText(n_("chorem.bonzoms.employee.invalidCompany"))); + result = false; + } + if (result) { - proxy.store(newEmployee); + result = storeEmploymentContract(newEmployee, result, proxy); + if (result) { + proxy.store(newEmployee); + } } } else { @@ -249,6 +266,20 @@ return result; } + /** + * Gets the list of all companies + * + * @return a list containing all companies + */ + public List<Company> getAllCompanies() { + ChoremProxy proxy = getChoremProxy(); + Search search = Search.query().exteq(Company.EXT_COMPANY); + Criteria criteria = search.criteria(); + PagedResult<Company> result = proxy.findAllByCriteria(Company.class, criteria); + List<Company> companies = result.getAll(); + return companies; + } + /** * @return the firstName */ @@ -514,4 +545,18 @@ public void setContractEndDate(String contractEndDate) { this.contractEndDate = contractEndDate; } + + /** + * @return the companyId + */ + public String getCompanyId() { + return companyId; + } + + /** + * @param companyId the companyId to set + */ + public void setCompanyId(String companyId) { + this.companyId = companyId; + } } 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-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/action/ProjectOrderAction.java 2011-04-15 15:06:56 UTC (rev 94) @@ -197,7 +197,7 @@ } 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); 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-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-04-15 15:06:56 UTC (rev 94) @@ -52,6 +52,7 @@ chorem.bonzoms.contactDetails.value.required=You must enter the contact details'' value chorem.bonzoms.employee= chorem.bonzoms.employee.diploma= +chorem.bonzoms.employee.invalidCompany= chorem.bonzoms.employee.paidLeave= chorem.bonzoms.employee.paidLeave.wrongFormat= chorem.bonzoms.employee.required= 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-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-04-15 15:06:56 UTC (rev 94) @@ -51,6 +51,7 @@ chorem.bonzoms.contactDetails.value.required=Vous devez entrer la valeur de la m\u00E9thode de contact chorem.bonzoms.employee=Employ\u00E9 chorem.bonzoms.employee.diploma=Dipl\u00F4me (opt.) +chorem.bonzoms.employee.invalidCompany= chorem.bonzoms.employee.paidLeave=Cong\u00E9s pay\u00E9s chorem.bonzoms.employee.paidLeave.wrongFormat=Les cong\u00E9s pay\u00E9s doivent \u00EAtre \u00EAtre un entier positif ou un nombre \u00E0 virgule flottante positif chorem.bonzoms.employee.required=Vous devez remplir le nombre de cong\u00E9s pay\u00E9s et les RTT Modified: trunk/chorem-web/src/main/resources/struts.xml =================================================================== --- trunk/chorem-web/src/main/resources/struts.xml 2011-04-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/resources/struts.xml 2011-04-15 15:06:56 UTC (rev 94) @@ -33,7 +33,7 @@ <action name="companies" class="org.chorem.bonzoms.action.CompanyAction"> <result>/WEB-INF/jsp/bonzoms/companies.jsp</result> </action> - <action name="addPersonInput"> + <action name="addPersonInput" class="org.chorem.bonzoms.action.PersonAction"> <result>/WEB-INF/jsp/bonzoms/addPerson.jsp</result> </action> <action name="addPerson" class="org.chorem.bonzoms.action.PersonAction" method="add"> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addPerson.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addPerson.jsp 2011-04-15 14:39:32 UTC (rev 93) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addPerson.jsp 2011-04-15 15:06:56 UTC (rev 94) @@ -1,4 +1,5 @@ <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@page import="org.chorem.bonzoms.action.PersonAction" %> <%@taglib prefix="s" uri="/struts-tags" %> <html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" @@ -44,6 +45,7 @@ <br /> <s:textfield key="chorem.bonzoms.employee.rtt" name="employeeRtt" labelSeparator=": " /> <br /> + <s:select label="%{getText('chorem.gepeto.projectOrder.company')}" list="allCompanies" name="companyId" listKey="wikittyId" listValue="name" /> <br /> <fieldset> <legend><s:text name="chorem.bonzoms.employmentContract" /></legend>
participants (1)
-
vbriand@users.chorem.org