r45 - in trunk/chorem-web/src/main: java/org/chorem java/org/chorem/bonzoms/action resources/i18n resources/org/chorem/bonzoms/action webapp/WEB-INF/jsp/bonzoms webapp/WEB-INF/jsp/gepeto
Author: vbriand Date: 2011-03-25 17:31:08 +0100 (Fri, 25 Mar 2011) New Revision: 45 Url: http://chorem.org/repositories/revision/chorem/45 Log: Added contact details for the company (postal address and telephone) Implemented methods in proxy to fetch attachments and contact details linked with a wikittyId Modified: trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.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/bonzoms/action/CompanyAction-validation.xml trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addCompany.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/home.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/home.jsp Modified: trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java 2011-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/java/org/chorem/ChoremProxy.java 2011-03-25 16:31:08 UTC (rev 45) @@ -9,6 +9,9 @@ import org.nuiton.wikitty.WikittyProxy; import org.nuiton.wikitty.WikittyService; import org.nuiton.wikitty.WikittyServiceFactory; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; /** * Proxy pour l'application. Certaines methodes specifiques pour l'application @@ -61,8 +64,12 @@ * @return the list of attachments */ static public List<Attachment> getAttachments(String wikittyId) { - //TODO: implement - return null; + Criteria criteria = Search.query(). + eq(Attachment.FQ_FIELD_ATTACHMENT_TARGET, wikittyId).criteria(); + PagedResult<Attachment> result = getInstance(null). + findAllByCriteria(Attachment.class, criteria); + List<Attachment> attachments = result.getAll(); + return attachments; } /** @@ -72,7 +79,11 @@ * @return the list of contact details */ static public List<ContactDetails> getContactDetails(String wikittyId) { - //TODO: implement - return null; + Criteria criteria = Search.query(). + eq(ContactDetails.FQ_FIELD_CONTACTDETAILS_TARGET, wikittyId).criteria(); + PagedResult<ContactDetails> result = getInstance(null). + findAllByCriteria(ContactDetails.class, criteria); + List<ContactDetails> contactDetails = result.getAll(); + return contactDetails; } } 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-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/CompanyAction.java 2011-03-25 16:31:08 UTC (rev 45) @@ -5,6 +5,7 @@ import org.chorem.ChoremProxy; import org.chorem.action.BaseAction; import org.chorem.entities.CompanyImpl; +import org.chorem.entities.ContactDetailsImpl; import static org.nuiton.i18n.I18n.n_; @@ -18,12 +19,20 @@ private static final long serialVersionUID = 2266576941588474102L; private static final Log log = LogFactory.getLog(CompanyAction.class); + + private static final String CONTACT_DETAILS_POSTAL_ADDRESS = "Postal address"; + + private static final String CONTACT_DETAILS_PHONE = "Phone number"; public String add() { String result = INPUT; - if (name != null && type != null) { - if (!name.isEmpty() && !type.isEmpty()) { + if (name != null && type != null && addressLine1 != null && + postcode != null && city != null && country != null && + phoneNb != null) { + if (!name.isEmpty() && !type.isEmpty() && !addressLine1.isEmpty() && + !postcode.isEmpty() && !city.isEmpty() && + !country.isEmpty()) { //If the company has been added successfully if (addCompany()) { result = SUCCESS; @@ -37,6 +46,12 @@ protected String name; protected String type; + protected String addressLine1; + protected String addressLine2; + protected String postcode; + protected String city; + protected String country; + protected String phoneNb; /** * Stores the new company through the proxy @@ -50,10 +65,31 @@ try { ChoremProxy proxy = getChoremProxy(); CompanyImpl newCompany = new CompanyImpl(); + ContactDetailsImpl newContactDetails = new ContactDetailsImpl(); + String address = addressLine1; + if (!addressLine2.isEmpty()) { + address += "\n" + addressLine2; + } + address += "\n" + postcode + "\n" + city + "\n" + country; + newCompany.setName(name); newCompany.setType(type); + newContactDetails.setName(CONTACT_DETAILS_POSTAL_ADDRESS + + " of company \"" + name + "\""); + newContactDetails.setType(CONTACT_DETAILS_POSTAL_ADDRESS); + newContactDetails.setValue(address); + newContactDetails.setTarget(newCompany.getWikittyId()); proxy.store(newCompany); + proxy.store(newContactDetails); + + newContactDetails = new ContactDetailsImpl(); + newContactDetails.setName(CONTACT_DETAILS_PHONE + " of company \"" + + name + "\""); + newContactDetails.setType(CONTACT_DETAILS_PHONE); + newContactDetails.setValue(phoneNb); + newContactDetails.setTarget(newCompany.getWikittyId()); + proxy.store(newContactDetails); } catch (Exception e) { result = false; addActionError(getText(n_("chorem.bonzoms.company.create.error"))); @@ -89,4 +125,88 @@ public void setType(String type) { this.type = type; } + + /** + * @return the addressLine1 + */ + public String getAddressLine1() { + return addressLine1; + } + + /** + * @param addressLine1 the addressLine1 to set + */ + public void setAddressLine1(String addressLine1) { + this.addressLine1 = addressLine1; + } + + /** + * @return the addressLine2 + */ + public String getAddressLine2() { + return addressLine2; + } + + /** + * @param addressLine2 the addressLine2 to set + */ + public void setAddressLine2(String addressLine2) { + this.addressLine2 = addressLine2; + } + + /** + * @return the postcode + */ + public String getPostcode() { + return postcode; + } + + /** + * @param postcode the postcode to set + */ + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + /** + * @return the city + */ + public String getCity() { + return city; + } + + /** + * @param city the city to set + */ + public void setCity(String city) { + this.city = city; + } + + /** + * @return the country + */ + public String getCountry() { + return country; + } + + /** + * @param country the country to set + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * @return the phoneNb + */ + public String getPhoneNb() { + return phoneNb; + } + + /** + * @param phoneNb the phoneNb to set + */ + public void setPhoneNb(String phoneNb) { + this.phoneNb = phoneNb; + } } 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-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_en_GB.properties 2011-03-25 16:31:08 UTC (rev 45) @@ -1,9 +1,19 @@ chorem.beginDate.beforeToday=The date cannot be set before today''s date chorem.bonzoms.company=Company {0} chorem.bonzoms.company.add=Add a new company +chorem.bonzoms.company.addressLine1=Address line 1 +chorem.bonzoms.company.addressLine1.required=You must enter the first address line +chorem.bonzoms.company.addressLine2=Address line 2 +chorem.bonzoms.company.city=City +chorem.bonzoms.company.city.required=You must enter the city +chorem.bonzoms.company.country=Country +chorem.bonzoms.company.country.required=You must enter the country chorem.bonzoms.company.create.error=An error occurred while creating your new company, please try again. If the problem persists, please contact an administrator chorem.bonzoms.company.name=Company''s name chorem.bonzoms.company.name.required=You must enter the company''s name +chorem.bonzoms.company.phoneNb=Phone number +chorem.bonzoms.company.postcode=Postcode +chorem.bonzoms.company.postcode.required=You must enter the postcode chorem.bonzoms.company.type=Company''s type chorem.bonzoms.company.type.required=You must enter the company''s type chorem.bonzoms.contactDetails=Contact details 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-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/resources/i18n/chorem-web_fr_FR.properties 2011-03-25 16:31:08 UTC (rev 45) @@ -1,20 +1,30 @@ chorem.beginDate.beforeToday=La date entr\u00E9e ne peut \u00EAtre ant\u00E9rieure \u00E0 la date du jour chorem.bonzoms.company=Soci\u00E9t\u00E9 chorem.bonzoms.company.add=Ajouter une nouvelle soci\u00E9t\u00E9 +chorem.bonzoms.company.addressLine1=Adresse +chorem.bonzoms.company.addressLine1.required=Vous devez donner l'adresse de l''entreprise +chorem.bonzoms.company.addressLine2=Adresse (ligne 2) +chorem.bonzoms.company.city=Ville +chorem.bonzoms.company.city.required=Vous devez renseigner la ville +chorem.bonzoms.company.country=Pays +chorem.bonzoms.company.country.required=Vous devez indiquer le pays chorem.bonzoms.company.create.error=Une erreur s''est produite lors de la cr\u00E9ation de votre nouvelle soci\u00E9t\u00E9, merci d''essayer \u00E0 nouveau. Si le probl\u00E8me se reproduit, merci de contacter un administrateur chorem.bonzoms.company.name=Nom de la soci\u00E9t\u00E9 chorem.bonzoms.company.name.required=Vous devez entrer le nom de la soci\u00E9t\u00E9 +chorem.bonzoms.company.phoneNb=Num\u00E9ro de t\u00E9l\u00E9phone +chorem.bonzoms.company.postcode=Code postal +chorem.bonzoms.company.postcode.required=Vous devez renseigner le code postal de la soci\u00E9t\u00E9 chorem.bonzoms.company.type=Type de la soci\u00E9t\u00E9 chorem.bonzoms.company.type.required=Vous devez entrer le type de la soci\u00E9t\u00E9 chorem.bonzoms.contactDetails=M\u00E9thode de contact chorem.bonzoms.contactDetails.add=Ajouter une nouvelle m\u00E9thode de contact chorem.bonzoms.contactDetails.create.error=Une erreur s''est produite lors de la cr\u00E9ation de votre nouvelle m\u00E9thode de contact, merci d''essayer \u00E0 nouveau. Si le probl\u00E8me se reproduit, merci de contacter un administrateur chorem.bonzoms.contactDetails.name=Nom de la m\u00E9thode de contact -chorem.bonzoms.contactDetails.name.required=Vous devez indiquer le nom de la méthode de contact +chorem.bonzoms.contactDetails.name.required=Vous devez indiquer le nom de la m\u00E9thode de contact chorem.bonzoms.contactDetails.type=Type de la m\u00E9thode de contact -chorem.bonzoms.contactDetails.type.required=Vous devez saisir le type de la méthode de contact +chorem.bonzoms.contactDetails.type.required=Vous devez saisir le type de la m\u00E9thode de contact chorem.bonzoms.contactDetails.value=Valeur de la m\u00E9thode de contact -chorem.bonzoms.contactDetails.value.required=Vous devez entrer la valeur de la méthode de contact +chorem.bonzoms.contactDetails.value.required=Vous devez entrer la valeur de la m\u00E9thode de contact chorem.bonzoms.employmentContract=Contrat de travail chorem.bonzoms.employmentContract.add=Ajouter un nouveau contrat de travail chorem.bonzoms.employmentContract.beginDate=Date de d\u00E9but Modified: trunk/chorem-web/src/main/resources/org/chorem/bonzoms/action/CompanyAction-validation.xml =================================================================== --- trunk/chorem-web/src/main/resources/org/chorem/bonzoms/action/CompanyAction-validation.xml 2011-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/resources/org/chorem/bonzoms/action/CompanyAction-validation.xml 2011-03-25 16:31:08 UTC (rev 45) @@ -13,4 +13,24 @@ <message key="chorem.bonzoms.company.type.required" /> </field-validator> </field> + <field name="addressLine1"> + <field-validator type="requiredstring"> + <message key="chorem.bonzoms.company.addressLine1.required" /> + </field-validator> + </field> + <field name="postcode"> + <field-validator type="requiredstring"> + <message key="chorem.bonzoms.company.postcode.required" /> + </field-validator> + </field> + <field name="city"> + <field-validator type="requiredstring"> + <message key="chorem.bonzoms.company.city.required" /> + </field-validator> + </field> + <field name="country"> + <field-validator type="requiredstring"> + <message key="chorem.bonzoms.company.country.required" /> + </field-validator> + </field> </validators> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addCompany.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addCompany.jsp 2011-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/addCompany.jsp 2011-03-25 16:31:08 UTC (rev 45) @@ -21,6 +21,20 @@ <br /> <s:textfield key="chorem.bonzoms.company.type" name="type" labelSeparator=": " /> <br /> + <br /> + <s:textfield key="chorem.bonzoms.company.addressLine1" name="addressLine1" labelSeparator=": " /> + <br /> + <s:textfield key="chorem.bonzoms.company.addressLine2" name="addressLine2" labelSeparator=": " /> + <br /> + <s:textfield key="chorem.bonzoms.company.postcode" name="postcode" labelSeparator=": " /> + <br /> + <s:textfield key="chorem.bonzoms.company.city" name="city" labelSeparator=": " /> + <br /> + <s:textfield key="chorem.bonzoms.company.country" name="country" labelSeparator=": " /> + <br /> + <br /> + <s:textfield key="chorem.bonzoms.company.phoneNb" name="phoneNb" labelSeparator=": " /> + <br /> <s:submit key="chorem.bonzoms.company.add" name="submit" /> </fieldset> </s:form> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/home.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/home.jsp 2011-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/home.jsp 2011-03-25 16:31:08 UTC (rev 45) @@ -8,5 +8,7 @@ <s:head /> </head> <body> + <s:a action="addCompany_input"><s:text name="chorem.bonzoms.company.add" /></s:a><br /> + <s:a action=""></s:a> </body> </html> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/home.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/home.jsp 2011-03-25 13:22:02 UTC (rev 44) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/gepeto/home.jsp 2011-03-25 16:31:08 UTC (rev 45) @@ -8,5 +8,8 @@ <s:head /> </head> <body> + <s:a action="addProject_input"><s:text name="chorem.gepeto.project.add" /></s:a><br /> + <s:a action="addProjectOrder_input"><s:text name="chorem.gepeto.projectOrder.add" /></s:a><br /> + <s:a action="addTask_input"><s:text name="chorem.gepeto.task.add" /></s:a> </body> </html>
participants (1)
-
vbriand@users.chorem.org