Author: bpoussin Date: 2011-11-19 18:17:08 +0100 (Sat, 19 Nov 2011) New Revision: 130 Url: http://chorem.org/repositories/revision/chorem/130 Log: work in progress Added: trunk/chorem-entities/src/site/rst/chorem-entities-base.png trunk/chorem-entities/src/site/rst/chorem-entities-billy.png trunk/chorem-entities/src/site/rst/chorem-entities-bonzoms.png trunk/chorem-entities/src/site/rst/chorem-entities-gepeto.png Removed: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmploymentContractAction.java trunk/chorem-web/src/main/java/org/chorem/gepeto/EmploymentContractFull.java Modified: trunk/chorem-entities/pom.xml trunk/chorem-entities/src/main/xmi/chorem.properties trunk/chorem-entities/src/main/xmi/chorem.zargo trunk/chorem-entities/src/site/rst/dataModel.rst trunk/chorem-web/src/main/java/org/chorem/ContactDetailsConstants.java trunk/chorem-web/src/main/java/org/chorem/action/EntitySearchJsonAction.java trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmployeeAction.java trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.java trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companies.jsp trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/personDetails.jsp trunk/pom.xml Modified: trunk/chorem-entities/pom.xml =================================================================== --- trunk/chorem-entities/pom.xml 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-entities/pom.xml 2011-11-19 17:17:08 UTC (rev 130) @@ -57,18 +57,6 @@ </dependency> <dependency> - <groupId>org.nuiton.wikitty</groupId> - <artifactId>wikitty-jdbc-impl</artifactId> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.nuiton.wikitty</groupId> - <artifactId>wikitty-solr-impl</artifactId> - <scope>runtime</scope> - </dependency> - - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <scope>runtime</scope> Modified: trunk/chorem-entities/src/main/xmi/chorem.properties =================================================================== --- trunk/chorem-entities/src/main/xmi/chorem.properties 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-entities/src/main/xmi/chorem.properties 2011-11-19 17:17:08 UTC (rev 130) @@ -2,13 +2,12 @@ org.chorem.entities.ProjectOrder.class.tagvalue.version=1.0 org.chorem.entities.Task.class.tagvalue.version=1.0 org.chorem.entities.Worker.class.tagvalue.version=1.0 -org.chorem.entities.Person.class.tagvalue.version=1.0 +org.chorem.entities.Person.class.tagvalue.version=2.0 org.chorem.entities.Interval.class.tagvalue.version=1.0 org.chorem.entities.Company.class.tagvalue.version=1.0 org.chorem.entities.ContactDetails.class.tagvalue.version=1.0 org.chorem.entities.Time.class.tagvalue.version=1.0 -org.chorem.entities.EmploymentContract.class.tagvalue.version=1.0 -org.chorem.entities.Employee.class.tagvalue.version=1.0 +org.chorem.entities.Employee.class.tagvalue.version=2.0 org.chorem.entities.Goal.class.tagvalue.version=1.0 org.chorem.entities.PersonSkill.class.tagvalue.version=1.0 org.chorem.entities.Skill.class.tagvalue.version=1.0 Modified: trunk/chorem-entities/src/main/xmi/chorem.zargo =================================================================== (Binary files differ) Added: trunk/chorem-entities/src/site/rst/chorem-entities-base.png =================================================================== (Binary files differ) Property changes on: trunk/chorem-entities/src/site/rst/chorem-entities-base.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/chorem-entities/src/site/rst/chorem-entities-billy.png =================================================================== (Binary files differ) Property changes on: trunk/chorem-entities/src/site/rst/chorem-entities-billy.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/chorem-entities/src/site/rst/chorem-entities-bonzoms.png =================================================================== (Binary files differ) Property changes on: trunk/chorem-entities/src/site/rst/chorem-entities-bonzoms.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/chorem-entities/src/site/rst/chorem-entities-gepeto.png =================================================================== (Binary files differ) Property changes on: trunk/chorem-entities/src/site/rst/chorem-entities-gepeto.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/chorem-entities/src/site/rst/dataModel.rst =================================================================== --- trunk/chorem-entities/src/site/rst/dataModel.rst 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-entities/src/site/rst/dataModel.rst 2011-11-19 17:17:08 UTC (rev 130) @@ -66,7 +66,12 @@ Billy ===== -- Quotation: devis envoyé à un client en rapport avec un projet +- Quotation: devis envoyé à un client en rapport avec un projet, un devis a + un type (dev, admin, formation, ...), et un beginDate, endDate qui + détermine approximativement le moment ou la réalisation devra être faite. + Tant que le devis n'a pas de date d'envoi, il s'agit d'un brouillon. + L'espoire de conversion (conversionHope) indique si l'on pense convertir + facilement en contrat ce devis (0 = non, 10 = quasi sur) - Invoiceable: indique les conditions de facturation. Chaque facture a emettre doit avoir une condition et une valeur associee. La condition et la valeur associee sont evaluees en fonction du type mime indique. De meme il Modified: trunk/chorem-web/src/main/java/org/chorem/ContactDetailsConstants.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/ContactDetailsConstants.java 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/ContactDetailsConstants.java 2011-11-19 17:17:08 UTC (rev 130) @@ -9,4 +9,5 @@ public static final String CONTACT_DETAILS_POSTAL_ADDRESS = "Postal address"; public static final String CONTACT_DETAILS_PHONE = "Phone number"; public static final String CONTACT_DETAILS_WEBSITE = "Website"; + public static final String CONTACT_DETAILS_EMAIL = "Email"; } Modified: trunk/chorem-web/src/main/java/org/chorem/action/EntitySearchJsonAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/action/EntitySearchJsonAction.java 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/action/EntitySearchJsonAction.java 2011-11-19 17:17:08 UTC (rev 130) @@ -6,7 +6,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -21,16 +20,48 @@ import org.nuiton.wikitty.entities.FieldType; import org.nuiton.wikitty.entities.Wikitty; import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyImpl; import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.PagedResult; import org.nuiton.wikitty.search.Search; /** - * Action qui recherche n'importe qu'elle type d'extension de wikitty. - * L'extension doit etre passee via le parametre 'wikittyExtension' - * Il est possible d'ajouter une condition de recherche via le parametre - * 'fulltextSearch'. + * Action qui d'interagir avec les jqgrid pour n'importe qu'elle type d'extension + * de wikitty. + * La grille doit être configuree en json et le model se nome 'gridModel' * + * <h3>Recherche</h3> + * + * <li> id: si non vide l'id de ligne de la grille mere pour une sous grille + * <li> wikittyExtension: les extensions que doivent avoir les wikitties + * recherches (master) + * <li> wikittyLinkToLoad: listes des champs du wikitty master, qui represente + * des wikitties a charger en plus pour permettre un affichage plus + * lisible pour l'utilisateur + * <li> filters: la valeur du filtre de la grille + * <li> fulltextSearch: une contrainte de recherche des wikitties affiches + * + * si filters et fulltextSearch sont non vide, seul filters est utilise. + * + * <h3>Ajout</h3> + * + * <li> wikittyExtension: la liste des extensions a mettre sur le nouveau wikitty + * <li> rowid: l'id de la derniere ligne ouverte lorsqu'on est en sous grille + * <li> wikittyLinkFieldForRowId: le champs qui doit etre value avec rowid dans + * le nouvel objet wikitty + * + * <h3>Edition</h3> + * + * <li> id: l'id de l'objet a modifier + * + * L'ensemble des champs a mettre dans le wikitty sont passes dans les paramatres + * + * <h3>Suppression</h3> + * + * <li> id: l'id de l'objet a supprimer + * <li> deleteAllLink: indique de supprimer tous les objets qui contiennent cet + * identifiant + * * @author poussin * @version $Revision$ * @@ -84,181 +115,225 @@ /** action faite via le grid ['add', 'edit', 'del'], si vide alors une simple recherche */ protected String oper; - /** id ou list d'id sur lequel l'action est faite, le separateur est la ','*/ + + protected boolean deleteAllLink = false; + /** + * id ou list d'id sur lequel l'action est faite, le separateur est la ',' + * id est aussi utilise pour les subgrid comme valeur de l'id du pere + */ protected String id; - protected Map<String, String[]> parameters; + /** id de la derniere ligne ouverte (pour les tableaux ayant un sous tableau) */ + protected String rowid; - public void setWikittyLinkToLoad(String wikittyLinkToLoad) { - this.wikittyLinkToLoad = wikittyLinkToLoad; - } + /** champs wikitty dans lequel on doit stocker rowid si non vide */ + protected String wikittyLinkFieldForRowId; - public void setParameters(Map<String, String[]> parameters) { - this.parameters = parameters; - } - public void setFilters(String filters) { - this.filters = filters; - } + protected Map<String, String[]> parameters; - public void setWikittyExtension(String wikittyExtension) { - this.wikittyExtension = wikittyExtension; - } + public String execute() { + try { + if (log.isDebugEnabled()) { + for (String param : parameters.keySet()) { + log.debug("param:" + param + "=" + Arrays.toString(parameters.get(param))); + } + } - public void setFulltextSearch(String fulltextSearch) { - this.fulltextSearch = fulltextSearch; + if ("del".equalsIgnoreCase(oper)) { + doDelete(); + } else if ("add".equalsIgnoreCase(oper)) { + doAdd(); + } else if ("edit".equalsIgnoreCase(oper)) { + doEdit(); + } else { + doSearch(); + } + return SUCCESS; + } catch (Exception eee) { + log.error(String.format("Can't find wikitty '%s'", wikittyExtension), eee); + throw new UnhandledException(eee); + } } - public void setPage(Integer page) { - this.page = page; - } + protected void doDelete() { + Collection<String> ids = toCollection(id); - public void setSord(String sord) { - this.sord = sord; + // si l'utilisateur demande de supprimer aussi tous les objets qui ont + // ces ids comme reference, on les recherche + if (isDeleteAllLink()) { + Search search = Search.query().or(); + for(String id:ids) { + search.keyword(id); + } + Criteria criteria = search.criteria(); + PagedResult<String> result = getChoremProxy().findAllIdByCriteria(criteria); + ids = result.getAll(); + } + getChoremProxy().delete(ids); } - public void setSidx(String sidx) { - this.sidx = sidx; + protected void doAdd() { + Wikitty w = new WikittyImpl(); + Collection<String> extNames = toCollection(wikittyExtension); + List<WikittyExtension> exts = getChoremProxy().restoreExtensionAndDependenciesLastVesion(extNames); + w.addExtension(exts); + if (StringUtils.isNotBlank(wikittyLinkFieldForRowId) + && StringUtils.isNotBlank(rowid)) { + w.setFqField(wikittyLinkFieldForRowId, rowid); + } + populateWikitty(w, parameters); + getChoremProxy().store(w); } - public void setRows(Integer rows) { - this.rows = rows; + protected void doEdit() { + Wikitty w = getChoremProxy().restore(id); + populateWikitty(w, parameters); + getChoremProxy().store(w); } - public void setRecords(Integer records) { - this.records = records; + /** + * Recherche dans parameters toutes les champs du wikitty pour mettre a jour + * le wikitty + * + * @param w le wikitty a mettre a jour + * @param parameters la map contenant les nouvelles valeurs pour les champs + */ + protected void populateWikitty(Wikitty w, Map<String, String[]> parameters) { + if (w != null) { + for (String param : parameters.keySet()) { + if(w.hasField(param)) { + FieldType type = w.getFieldType(param); + String[] val = parameters.get(param); + if (type.isCollection()) { + w.setFqField(param, val); + } else { + w.setFqField(param, val[0]); + } + } + } + } } - public void setTotal(Integer total) { - this.total = total; - } + protected void doSearch() { - public List getWikitties() { - return wikitties; - } - public String execute() { - try { - if (log.isDebugEnabled()) { - for (String param : parameters.keySet()) { - log.debug("param:" + param + "=" + Arrays.toString(parameters.get(param))); - } - } - - Search search = Search.query(); + Search search = Search.query(); - if (StringUtils.isNotBlank(wikittyExtension)) { - Collection<String> col = toCollection(wikittyExtension); - search.exteq(col); - } + if (StringUtils.isNotBlank(wikittyExtension)) { + Collection<String> col = toCollection(wikittyExtension); + search.exteq(col); + } - if (StringUtils.isNotBlank(filters)) { - JSONObject jsonFilter = (JSONObject) JSONSerializer.toJSON( filters ); - String groupOp = jsonFilter.getString("groupOp"); - log.debug("groupOp: " + groupOp); - Search filter; - if ("or".equalsIgnoreCase(groupOp)) { - filter = search.or(); - } else { - filter = search.and(); - } - JSONArray rules = jsonFilter.getJSONArray("rules"); - int rulesCount = JSONArray.getDimensions(rules)[0]; - for (int i = 0; i < rulesCount; i++) { - JSONObject rule = rules.getJSONObject(i); - String field = rule.getString("field"); - String op = rule.getString("op"); - String data = rule.getString("data"); - addCondition(filter, field, op, data); - } + // on restraint la recherche pour les sous grilles a l'id du wikitty + // pere dans la grille principale + if (StringUtils.isNotBlank(id)) { + search.keyword(id); + } - } else if (StringUtils.isNotBlank(fulltextSearch)) { - // TODO poussin 20111106: ca ne serait pas au like d'ajouter les * ? - String s = "*" + fulltextSearch + "*"; - // TODO poussin 20111106: voir pourquoi like fontion comme on souhaite et pas Keyword :( - // keyword ne fonctionne pas avec les * - Search or = search.or(); - or = or.like("#fulltext", s); - log.debug("link: " + getWikittyLinkToLoadCache()); - for (String link:getWikittyLinkToLoadCache()) { - or.associated(link).like("#fulltext", s); - } + if (StringUtils.isNotBlank(filters)) { + JSONObject jsonFilter = (JSONObject) JSONSerializer.toJSON( filters ); + String groupOp = jsonFilter.getString("groupOp"); + log.debug("groupOp: " + groupOp); + Search filter; + if ("or".equalsIgnoreCase(groupOp)) { + filter = search.or(); } else { - // si pas de filtre on recherche tout - search.rTrue(); + filter = search.and(); } - + JSONArray rules = jsonFilter.getJSONArray("rules"); + int rulesCount = JSONArray.getDimensions(rules)[0]; + for (int i = 0; i < rulesCount; i++) { + JSONObject rule = rules.getJSONObject(i); + String field = rule.getString("field"); + String op = rule.getString("op"); + String data = rule.getString("data"); + addCondition(filter, field, op, data); + } - int first = rows * (page - 1); - int last = rows * page - 1; - - Criteria criteria = search.criteria(); - criteria.setFirstIndex(first); - criteria.setEndIndex(last); - - if (StringUtils.isNotBlank(sidx)) { - if ("asc".equalsIgnoreCase(sord)) { - criteria.setSortAscending(sidx); - } else { - criteria.setSortDescending(sidx); - } + } else if (StringUtils.isNotBlank(fulltextSearch)) { + // TODO poussin 20111106: ca ne serait pas au like d'ajouter les * ? + String s = "*" + fulltextSearch + "*"; + // TODO poussin 20111106: voir pourquoi like fontion comme on souhaite et pas Keyword :( + // keyword ne fonctionne pas avec les * + Search or = search.or(); + or = or.like("#fulltext", s); + log.debug("link: " + getWikittyLinkToLoadCache()); + for (String link:getWikittyLinkToLoadCache()) { + or.associated(link).like("#fulltext", s); } + } else { + // si pas de filtre on recherche tout + search.rTrue(); + } - if (log.isDebugEnabled()) { - log.debug("rows:" + rows); - log.debug("page:" + page); - log.debug("first:" + first); - log.debug("last:" + last); + int first = rows * (page - 1); + int last = rows * page - 1; - log.debug("sord:" + sord); - log.debug("sidx:" + sidx); + Criteria criteria = search.criteria(); + criteria.setFirstIndex(first); + criteria.setEndIndex(last); - log.debug("wikittyExtension:" + wikittyExtension); - log.debug("searchString: " + fulltextSearch); - log.debug("filters: " + filters); - log.debug("criteria: " + criteria); + if (StringUtils.isNotBlank(sidx)) { + if ("asc".equalsIgnoreCase(sord)) { + criteria.setSortAscending(sidx); + } else { + criteria.setSortDescending(sidx); } + } - PagedResult<Wikitty> result = getChoremProxy().findAllByCriteria(criteria); + if (log.isDebugEnabled()) { + log.debug("rows:" + rows); + log.debug("page:" + page); - setWikitties(result.getAll()); + log.debug("first:" + first); + log.debug("last:" + last); - if (log.isTraceEnabled()) { - log.trace("result: " + getWikitties()); - } + log.debug("sord:" + sord); + log.debug("sidx:" + sidx); - setRecords(result.getNumFound()); - setTotal((int) Math.ceil((double) getRecords() / (double) getRows())); + log.debug("wikittyExtension:" + wikittyExtension); + log.debug("searchString: " + fulltextSearch); + log.debug("filters: " + filters); + log.debug("criteria: " + criteria); + } - gridModel = new ArrayList<Map<String, Object>>(); - for (Wikitty w:wikitties) { - Map<String, Object> map = wikittyToMap(w); - gridModel.add(map); - } + PagedResult<Wikitty> result = getChoremProxy().findAllByCriteria(criteria); - return SUCCESS; - } catch (Exception eee) { - log.error(String.format("Can't find wikitty '%s'", wikittyExtension), eee); - throw new UnhandledException(eee); + setWikitties(result.getAll()); + + if (log.isTraceEnabled()) { + log.trace("result: " + getWikitties()); } + + setRecords(result.getNumFound()); + setTotal((int) Math.ceil((double) getRecords() / (double) getRows())); + + gridModel = new ArrayList<Map<String, Object>>(); + for (Wikitty w:wikitties) { + Map<String, Object> map = wikittyToMap(w); + gridModel.add(map); + } } protected Map<String, Object> wikittyToMap(Wikitty w) { Map<String, Object> result = new HashMap<String, Object>(); - String wid = w.getId(); + if (w != null) { + String wid = w.getId(); - result.put("id", wid); - result.putAll(w.getFieldValue()); - for (String fieldToLoad:getWikittyLinkToLoadCache()) { - String linkId = (String)w.getFqField(fieldToLoad); - if (linkId != null) { - // TODO poussin 20111107 pas tres optimal de faire une requete a chaque besoin - // il faudrait collecter les ids, pour faire une seule demande pour tous - // mais tant que pour le deploiement, tout est sur le meme serveur - // si un peu moins genant - Wikitty wlink = getChoremProxy().restore(linkId); - Map<String, Object> map = wikittyToMap(wlink); - map.remove("id"); - result.putAll(map); + result.put("id", wid); + result.putAll(w.getFieldValue()); + for (String fieldToLoad:getWikittyLinkToLoadCache()) { + String linkId = (String)w.getFqField(fieldToLoad); + if (linkId != null) { + // TODO poussin 20111107 pas tres optimal de faire une requete a chaque besoin + // il faudrait collecter les ids, pour faire une seule demande pour tous + // mais tant que pour le deploiement, tout est sur le meme serveur + // si un peu moins genant + Wikitty wlink = getChoremProxy().restore(linkId); + Map<String, Object> map = wikittyToMap(wlink); + map.remove("id"); + result.putAll(map); + } } } return result; @@ -281,6 +356,85 @@ return wikittyLinkToLoadCache; } + public String getRowid() { + return rowid; + } + + public void setRowid(String rowid) { + this.rowid = rowid; + } + + public String getWikittyLinkFieldForRowId() { + return wikittyLinkFieldForRowId; + } + + public void setWikittyLinkFieldForRowId(String wikittyLinkFieldForRowId) { + this.wikittyLinkFieldForRowId = wikittyLinkFieldForRowId; + } + + public boolean isDeleteAllLink() { + return deleteAllLink; + } + + public void setDeleteAllLink(boolean deleteAllLink) { + this.deleteAllLink = deleteAllLink; + } + + public void setWikittyLinkToLoad(String wikittyLinkToLoad) { + this.wikittyLinkToLoad = wikittyLinkToLoad; + } + + public void setParameters(Map<String, String[]> parameters) { + this.parameters = parameters; + } + public void setFilters(String filters) { + this.filters = filters; + } + + public void setWikittyExtension(String wikittyExtension) { + this.wikittyExtension = wikittyExtension; + } + + public void setFulltextSearch(String fulltextSearch) { + this.fulltextSearch = fulltextSearch; + } + + public void setOper(String oper) { + this.oper = oper; + } + + public void setId(String id) { + this.id = id; + } + + public void setPage(Integer page) { + this.page = page; + } + + public void setSord(String sord) { + this.sord = sord; + } + + public void setSidx(String sidx) { + this.sidx = sidx; + } + + public void setRows(Integer rows) { + this.rows = rows; + } + + public void setRecords(Integer records) { + this.records = records; + } + + public void setTotal(Integer total) { + this.total = total; + } + + public List getWikitties() { + return wikitties; + } + public void setWikitties(List<Wikitty> wikitties) { this.wikitties = wikitties; } Modified: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmployeeAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmployeeAction.java 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmployeeAction.java 2011-11-19 17:17:08 UTC (rev 130) @@ -11,6 +11,8 @@ import org.nuiton.wikitty.search.Search; import com.opensymphony.xwork2.ActionContext; +import java.text.ParseException; +import java.text.SimpleDateFormat; import static org.nuiton.i18n.I18n.n_; @@ -43,9 +45,12 @@ person = proxy.restore(Person.class, personId); employee = proxy.restore(Employee.class, employeeId); - if (person != null && employee != null) { + if (person != null) { + if (employee == null) { + employee = new EmployeeImpl(); + } //If the user wants to update the employee's details - employee.setDiploma(diploma); +// employee.setDiploma(diploma); try { employee.setPaidLeave(Float.parseFloat(paidLeave)); if (employee.getPaidLeave() < 0) { @@ -66,33 +71,53 @@ addActionError( getText(n_("chorem.bonzoms.employee.rtt.wrongFormat"))); } - proxy.store(employee); - } else if (person != null && employee == null) { - //If the user wants to enter the employee's details - employee = new EmployeeImpl(); - - employee.setPerson(personId); - employee.setDiploma(diploma); + + employee.setType(type); + employee.setDescription(description); try { - employee.setPaidLeave(Float.parseFloat(paidLeave)); - if (employee.getPaidLeave() < 0) { - throw new NumberFormatException(); - } + //Replaces the (possible) comma by a dot, so the string can be + //parsed successfully as a float + salary = salary.replace(',', '.'); + employee.setSalary(Float.parseFloat(salary)); } catch (NumberFormatException e) { result = INPUT; addActionError( - getText(n_("chorem.bonzoms.employee.paidLeave.wrongFormat"))); + getText(n_("chorem.bonzoms.employmentContract.salary.wrongFormat"))); } try { - employee.setRtt(Float.parseFloat(rtt)); - if (employee.getRtt() < 0) { - throw new NumberFormatException(); - } + //Replaces the (possible) comma by a dot, so the string can be + //parsed successfully as a float + workingTime = workingTime.replace(',', '.'); + employee.setWorkingTime(Float.parseFloat(workingTime)); } catch (NumberFormatException e) { result = INPUT; addActionError( - getText(n_("chorem.bonzoms.employee.rtt.wrongFormat"))); + getText(n_("chorem.bonzoms.employmentContract.workingTime.wrongFormat"))); } + + + SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); + + //Lenient mode disabled because results may be very odd + formatter.setLenient(false); + try { + + employee.setBeginDate(formatter.parse(beginDate)); + + if (!endDate.isEmpty()) { //If the contract is not permanent + employee.setEndDate(formatter.parse(endDate)); + //If the end date is anterior to the begin date (...) + if (employee.getEndDate().before(employee.getBeginDate())) { + result = ERROR; + addActionError(getText(n_("chorem.endDate.afterBegin"))); + } + } + } catch (ParseException e) { + //If the date doesn't match the format above + result = ERROR; + addActionError(getText(n_("chorem.date.wrongFormat"))); + } + proxy.store(employee); } else { result = ERROR; @@ -102,9 +127,15 @@ protected String personId; protected String employeeId; - protected String diploma; +// protected String diploma; protected String paidLeave; protected String rtt; + protected String type; + protected String description; + protected String salary; + protected String workingTime; + protected String beginDate; + protected String endDate; /** * Gets the employee's information @@ -149,21 +180,21 @@ this.employeeId = employeeId; } - /** - * @return the diploma - */ - public String getDiploma() { - return diploma; - } +// /** +// * @return the diploma +// */ +// public String getDiploma() { +// return diploma; +// } +// +// /** +// * @param diploma the diploma to set +// */ +// public void setDiploma(String diploma) { +// this.diploma = diploma; +// } /** - * @param diploma the diploma to set - */ - public void setDiploma(String diploma) { - this.diploma = diploma; - } - - /** * @return the paidLeave */ public String getPaidLeave() { @@ -190,4 +221,53 @@ public void setRtt(String rtt) { this.rtt = rtt; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSalary() { + return salary; + } + + public void setSalary(String salary) { + this.salary = salary; + } + + public String getWorkingTime() { + return workingTime; + } + + public void setWorkingTime(String workingTime) { + this.workingTime = workingTime; + } + + public String getBeginDate() { + return beginDate; + } + + public void setBeginDate(String beginDate) { + this.beginDate = beginDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + } Deleted: trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmploymentContractAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmploymentContractAction.java 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/EmploymentContractAction.java 2011-11-19 17:17:08 UTC (rev 130) @@ -1,354 +0,0 @@ -package org.chorem.bonzoms.action; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.ChoremProxy; -import org.chorem.action.ChoremBaseAction; -import org.chorem.bonzoms.EmployeeFull; -import org.chorem.entities.Employee; -import org.chorem.entities.EmploymentContract; -import org.chorem.entities.EmploymentContractImpl; -import org.chorem.gepeto.EmploymentContractFull; -import org.nuiton.wikitty.search.Criteria; -import org.nuiton.wikitty.search.PagedResult; -import org.nuiton.wikitty.search.Search; - -import com.opensymphony.xwork2.ActionContext; - -import static org.nuiton.i18n.I18n.n_; - -/** - * Employment contract management class - * - * @author vbriand - */ -public class EmploymentContractAction extends ChoremBaseAction { - - private static final long serialVersionUID = -5841507190565206548L; - - private static final Log log = LogFactory.getLog(EmploymentContractAction.class); - - static public EmploymentContractAction getAction() { - return (EmploymentContractAction)ActionContext.getContext().get(CONTEXT_ACTION_KEY); - } - - /** - * Adds a new employment contract - * - * @return INPUT if the mandatory fields haven't all been filled in, - * SUCCESS if the employment contract has been added successfully, - * ERROR if an error occurred - */ - public String add() { - String result = INPUT; - - if (type != null && description != null && salary != null && - workingTime != null && beginDate != null && endDate != null) { - if (!type.isEmpty() && !description.isEmpty() && - !salary.isEmpty() && !workingTime.isEmpty() && - !beginDate.isEmpty()) { - //If the employment contract has been added successfully - if (addEmploymentContract()) { - result = SUCCESS; - } else { - result = ERROR; - } - } - } - return result; - } - - /** - * Modifies the employment contract's information - * - * @return SUCCESS if the employment contract has been successfully modified, - * ERROR if the id is invalid - */ - public String modify() { - String result = SUCCESS; - EmploymentContract employmentContract; - ChoremProxy proxy = getChoremProxy(); - - employmentContract = proxy.restore(EmploymentContract.class, - employmentContractId); - if (employmentContract != null) { //If the id exists - employmentContract.setType(type); - employmentContract.setDescription(description); - try { - //Replaces the (possible) comma by a dot, so the string can be - //parsed successfully as a float - salary = salary.replace(',', '.'); - employmentContract.setSalary(Float.parseFloat(salary)); - } catch (NumberFormatException e) { - result = INPUT; - addActionError( - getText(n_("chorem.bonzoms.employmentContract.salary.wrongFormat"))); - } - try { - employmentContract.setWorkingTime(Integer.parseInt(workingTime)); - } catch (NumberFormatException e) { - result = INPUT; - addActionError( - getText(n_("chorem.bonzoms.employmentContract.workingTime.wrongFormat"))); - } - proxy.store(employmentContract); - } else { - result = ERROR; - } - return result; - } - - protected String type; - protected String description; - protected String salary; - protected String workingTime; - protected String beginDate; - protected String endDate; - protected String personId; - protected String employeeId; - protected String employmentContractId; - - /** - * Gets the employments contracts of the employee - * - * @return a list containing all employment contracts - */ - public List<EmploymentContractFull> getEmploymentContracts() { - ChoremProxy proxy = getChoremProxy(); - Search search = Search.query(); - Criteria criteria = search.exteq(EmploymentContract.EXT_EMPLOYMENTCONTRACT). - associated(EmploymentContract.FQ_FIELD_EMPLOYMENTCONTRACT_EMPLOYEE). - eq(Employee.FQ_FIELD_EMPLOYEE_PERSON, personId).criteria(); - PagedResult<EmploymentContract> result = proxy.findAllByCriteria( - EmploymentContract.class, criteria); - List<EmploymentContract> employmentContracts = result.getAll(); - List<EmploymentContractFull> employmentContractsFull = new ArrayList<EmploymentContractFull>(); - EmploymentContractFull employeeTmp; - EmployeeFull employee; - - for (EmploymentContract employmentContract : employmentContracts) { - employeeTmp = new EmploymentContractFull(); - - employeeTmp.setEmploymentContract(employmentContract); - employee = EmployeeFull.initEmployee(employmentContract.getEmployee(), - proxy); - employeeTmp.setEmployee(employee); - employmentContractsFull.add(employeeTmp); - } - return employmentContractsFull; - } - - /** - * Retrieves the employment contract linked with the id - * - * @return the employment contract - */ - public EmploymentContractFull getEmploymentContract() { - EmployeeFull employee; - ChoremProxy proxy = getChoremProxy(); - EmploymentContract employmentContract; - EmploymentContractFull employmentContractFull = new EmploymentContractFull(); - - employmentContract = proxy.restore(EmploymentContract.class, - employmentContractId); - employmentContractFull.setEmploymentContract(employmentContract); - employee = EmployeeFull.initEmployee(employmentContract.getEmployee(), - proxy); - employmentContractFull.setEmployee(employee); - return employmentContractFull; - } - - /** - * Stores the new employment contract through the proxy - * - * @return true if the employment contract has been stored properly, - * false if a problem occurred - */ - protected boolean addEmploymentContract() { - boolean result = true; - - try { - ChoremProxy proxy = getChoremProxy(); - EmploymentContractImpl newEmploymentContract = new EmploymentContractImpl(); - SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); - - //Lenient mode disabled because results may be very odd - formatter.setLenient(false); - try { - Calendar cal = Calendar.getInstance(); - - newEmploymentContract.setBeginDate(formatter.parse(beginDate)); - - //Subtracts 1 day to the current time so the next test willn't - //fail if the begin date is today's date, as the before() method - //is exclusive - cal.add(Calendar.DAY_OF_MONTH, -1); - //If the begin date is set before the current date - if (newEmploymentContract.getBeginDate().before(cal.getTime())) { - result = false; - addFieldError("beginDate", getText(n_("chorem.beginDate.beforeToday"))); - } - - if (!endDate.isEmpty()) { //If the contract is not permanent - newEmploymentContract.setEndDate(formatter.parse(endDate)); - //If the end date is anterior to the begin date (...) - if (newEmploymentContract.getEndDate().before(newEmploymentContract.getBeginDate())) { - result = false; - addActionError(getText(n_("chorem.endDate.afterBegin"))); - } - } - } catch (ParseException e) { - //If the date doesn't match the format above - result = false; - addActionError(getText(n_("chorem.date.wrongFormat"))); - } - newEmploymentContract.setDescription(description); - newEmploymentContract.setSalary(Float.parseFloat(salary)); - newEmploymentContract.setType(type); - newEmploymentContract.setWorkingTime(Integer.parseInt(workingTime)); - newEmploymentContract.setEmployee(employeeId); - - //If everything went smoothly - if (result) { - proxy.store(newEmploymentContract); - } - } catch (Exception e) { - result = false; - addActionError(getText(n_("chorem.create.error"))); - log.error("An error occurred while creating a new employment contract", e); - } - return result; - } - - /** - * @return the type - */ - public String getType() { - return type; - } - - /** - * @param type the type to set - */ - public void setType(String type) { - this.type = type; - } - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * @return the salary - */ - public String getSalary() { - return salary; - } - - /** - * @param salary the salary to set - */ - public void setSalary(String salary) { - this.salary = salary; - } - - /** - * @return the workingTime - */ - public String getWorkingTime() { - return workingTime; - } - - /** - * @param workingTime the workingTime to set - */ - public void setWorkingTime(String workingTime) { - this.workingTime = workingTime; - } - - /** - * @return the beginDate - */ - public String getBeginDate() { - return beginDate; - } - - /** - * @param beginDate the beginDate to set - */ - public void setBeginDate(String beginDate) { - this.beginDate = beginDate; - } - - /** - * @return the endDate - */ - public String getEndDate() { - return endDate; - } - - /** - * @param endDate the endDate to set - */ - public void setEndDate(String endDate) { - this.endDate = endDate; - } - - /** - * @return the personId - */ - public String getPersonId() { - return personId; - } - - /** - * @param personId the personId to set - */ - public void setPersonId(String personId) { - this.personId = personId; - } - - /** - * @return the employmentContractId - */ - public String getEmploymentContractId() { - return employmentContractId; - } - - /** - * @param employmentContractId the employmentContractId to set - */ - public void setEmploymentContractId(String employmentContractId) { - this.employmentContractId = employmentContractId; - } - - /** - * @return the employeeId - */ - public String getEmployeeId() { - return employeeId; - } - - /** - * @param employeeId the employeeId to set - */ - public void setEmployeeId(String employeeId) { - this.employeeId = employeeId; - } -} 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-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/bonzoms/action/PersonAction.java 2011-11-19 17:17:08 UTC (rev 130) @@ -2,7 +2,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -11,16 +10,12 @@ import org.chorem.ChoremProxy; import org.chorem.ContactDetailsConstants; import org.chorem.action.ChoremBaseAction; -import org.chorem.bonzoms.EmployeeFull; import org.chorem.entities.Company; import org.chorem.entities.ContactDetailsImpl; import org.chorem.entities.Employee; import org.chorem.entities.EmployeeImpl; -import org.chorem.entities.EmploymentContract; -import org.chorem.entities.EmploymentContractImpl; import org.chorem.entities.Person; import org.chorem.entities.PersonImpl; -import org.chorem.gepeto.EmploymentContractFull; import org.nuiton.wikitty.search.Criteria; import org.nuiton.wikitty.search.PagedResult; import org.nuiton.wikitty.search.Search; @@ -90,7 +85,8 @@ setFirstName(person.getFirstName()); setLastName(person.getLastName()); - setEmail(person.getEmail()); + setDiploma(person.getDiploma()); +// setEmail(person.getEmail()); if (person.getBirthDate() != null) { setBirthDate(formatter.format(person.getBirthDate())); } @@ -118,7 +114,8 @@ person = proxy.restore(Person.class, personId); if (person != null) { - person.setEmail(email); + person.setDiploma(diploma); +// person.setEmail(email); proxy.store(person); } else { result = ERROR; @@ -128,6 +125,7 @@ protected String firstName; protected String lastName; + protected String diploma; protected String email; protected String birthDate; protected String addressLine1; @@ -164,10 +162,6 @@ newPerson.setFirstName(firstName); newPerson.setLastName(lastName); - if (StringUtils.isNotBlank(email)) { - newPerson.setEmail(email); - } - if (StringUtils.isNotBlank(birthDate)) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); //Lenient mode disabled because results may be very odd @@ -208,14 +202,25 @@ proxy.store(newContactDetails); } - if (result) { - result = storeEmployee(newPerson, result, proxy); - if (result) { - //Useful to redirect the user directly to the person's page - setPersonId(newPerson.getWikittyId()); - proxy.store(newPerson); - } + if (StringUtils.isNotBlank(email)) { +// newPerson.setEmail(email); + newContactDetails = new ContactDetailsImpl(); + newContactDetails.setName(CONTACT_DETAILS_EMAIL + + " of person \"" + firstName + " " + lastName + "\""); + newContactDetails.setType(CONTACT_DETAILS_EMAIL); + newContactDetails.setValue(email); + newContactDetails.setTarget(newPerson.getWikittyId()); + proxy.store(newContactDetails); } + +// if (result) { +// result = storeEmployee(newPerson, result, proxy); +// if (result) { +// //Useful to redirect the user directly to the person's page +// setPersonId(newPerson.getWikittyId()); +// proxy.store(newPerson); +// } +// } } } catch (Exception e) { result = false; @@ -225,132 +230,132 @@ return result; } - /** - * Stores the employee details and links them to the person - * - * @param newPerson the person to link the employee details with - * @param result whether or not the previous operations went smoothly - * @param proxy the wikitty proxy - * @return true if no errors occurred, false otherwise - */ - protected boolean storeEmployee(PersonImpl newPerson, boolean result, - ChoremProxy proxy) { - EmployeeImpl newEmployee = new EmployeeImpl(); - - newEmployee.setPerson(newPerson.getWikittyId()); - newEmployee.setDiploma(employeeDiploma); - - if (StringUtils.isNotBlank(employeePaidLeave)) { - try { - newEmployee.setPaidLeave( - Float.parseFloat(employeePaidLeave)); - if (newEmployee.getPaidLeave() < 0) { - throw new NumberFormatException(); - } - } catch (NumberFormatException e) { - result = false; - addFieldError("employeePaidLeave", getText( - n_("chorem.bonzoms.employee.paidLeave.wrongFormat"))); - } - } - - if (StringUtils.isNotBlank(employeeRtt)) { - try { - newEmployee.setRtt(Float.parseFloat(employeeRtt)); - if (newEmployee.getRtt() < 0) { - throw new NumberFormatException(); - } - } catch (NumberFormatException e) { - result = false; - addFieldError("employeeRtt", getText( - n_("chorem.bonzoms.employee.rtt.wrongFormat"))); - } - } - - if (StringUtils.isNotBlank(companyId)) { - 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) { - result = storeEmploymentContract(newEmployee, result, proxy); - if (result) { - proxy.store(newEmployee); - } - } - return result; - } +// /** +// * Stores the employee details and links them to the person +// * +// * @param newPerson the person to link the employee details with +// * @param result whether or not the previous operations went smoothly +// * @param proxy the wikitty proxy +// * @return true if no errors occurred, false otherwise +// */ +// protected boolean storeEmployee(PersonImpl newPerson, boolean result, +// ChoremProxy proxy) { +// EmployeeImpl newEmployee = new EmployeeImpl(); +// +// newEmployee.setPerson(newPerson.getWikittyId()); +// newEmployee.setDiploma(employeeDiploma); +// +// if (StringUtils.isNotBlank(employeePaidLeave)) { +// try { +// newEmployee.setPaidLeave( +// Float.parseFloat(employeePaidLeave)); +// if (newEmployee.getPaidLeave() < 0) { +// throw new NumberFormatException(); +// } +// } catch (NumberFormatException e) { +// result = false; +// addFieldError("employeePaidLeave", getText( +// n_("chorem.bonzoms.employee.paidLeave.wrongFormat"))); +// } +// } +// +// if (StringUtils.isNotBlank(employeeRtt)) { +// try { +// newEmployee.setRtt(Float.parseFloat(employeeRtt)); +// if (newEmployee.getRtt() < 0) { +// throw new NumberFormatException(); +// } +// } catch (NumberFormatException e) { +// result = false; +// addFieldError("employeeRtt", getText( +// n_("chorem.bonzoms.employee.rtt.wrongFormat"))); +// } +// } +// +// if (StringUtils.isNotBlank(companyId)) { +// 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) { +// result = storeEmploymentContract(newEmployee, result, proxy); +// if (result) { +// proxy.store(newEmployee); +// } +// } +// return result; +// } +// +// /** +// * Stores an employment contract and links it with the person +// * +// * @param employee the employee to link the contract with +// * @param result whether or not the previous operations went smoothly +// * @param proxy the wikitty proxy +// * @return true if no errors occurred, false otherwise +// */ +// protected boolean storeEmploymentContract(EmployeeImpl employee, +// boolean result, ChoremProxy proxy) { +// +// EmploymentContractImpl newEmploymentContract = +// new EmploymentContractImpl(); +// +// newEmploymentContract.setEmployee(employee.getWikittyId()); +// newEmploymentContract.setType(contractType); +// newEmploymentContract.setDescription(contractDescription); +// +// SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); +// if (StringUtils.isNotBlank(contractBeginDate)) { +// try { +// newEmploymentContract.setBeginDate( +// formatter.parse(contractBeginDate)); +// } catch (ParseException e) { +// addActionError(getText(n_("chorem.date.wrongFormat.contractBegin"))); +// result = false; +// } +// } +// +// if (StringUtils.isNotBlank(contractEndDate)) { +// try { +// newEmploymentContract.setEndDate( +// formatter.parse(contractEndDate)); +// } catch (ParseException e) { +// addActionError(getText(n_("chorem.date.wrongFormat.contractEnd"))); +// result = false; +// } +// } +// +// if (StringUtils.isNotBlank(contractSalary)) { +// try { +// newEmploymentContract.setSalary(Float.parseFloat(contractSalary)); +// } catch (NumberFormatException e) { +// addFieldError("contractSalary", +// getText(n_("chorem.bonzoms.employmentContract.salary.wrongFormat"))); +// result = false; +// } +// } +// +// if (StringUtils.isNotBlank(contractWorkingTime)) { +// try { +// newEmploymentContract.setWorkingTime( +// Integer.parseInt(contractWorkingTime)); +// } catch (NumberFormatException e) { +// addFieldError("contractWorkingTime", +// getText(n_("chorem.bonzoms.employmentContract.workingTime.wrongFormat"))); +// result = false; +// } +// } +// +// if (result) { +// proxy.store(newEmploymentContract); +// } +// return result; +// } - /** - * Stores an employment contract and links it with the person - * - * @param employee the employee to link the contract with - * @param result whether or not the previous operations went smoothly - * @param proxy the wikitty proxy - * @return true if no errors occurred, false otherwise - */ - protected boolean storeEmploymentContract(EmployeeImpl employee, - boolean result, ChoremProxy proxy) { - - EmploymentContractImpl newEmploymentContract = - new EmploymentContractImpl(); - - newEmploymentContract.setEmployee(employee.getWikittyId()); - newEmploymentContract.setType(contractType); - newEmploymentContract.setDescription(contractDescription); - - SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); - if (StringUtils.isNotBlank(contractBeginDate)) { - try { - newEmploymentContract.setBeginDate( - formatter.parse(contractBeginDate)); - } catch (ParseException e) { - addActionError(getText(n_("chorem.date.wrongFormat.contractBegin"))); - result = false; - } - } - - if (StringUtils.isNotBlank(contractEndDate)) { - try { - newEmploymentContract.setEndDate( - formatter.parse(contractEndDate)); - } catch (ParseException e) { - addActionError(getText(n_("chorem.date.wrongFormat.contractEnd"))); - result = false; - } - } - - if (StringUtils.isNotBlank(contractSalary)) { - try { - newEmploymentContract.setSalary(Float.parseFloat(contractSalary)); - } catch (NumberFormatException e) { - addFieldError("contractSalary", - getText(n_("chorem.bonzoms.employmentContract.salary.wrongFormat"))); - result = false; - } - } - - if (StringUtils.isNotBlank(contractWorkingTime)) { - try { - newEmploymentContract.setWorkingTime( - Integer.parseInt(contractWorkingTime)); - } catch (NumberFormatException e) { - addFieldError("contractWorkingTime", - getText(n_("chorem.bonzoms.employmentContract.workingTime.wrongFormat"))); - result = false; - } - } - - if (result) { - proxy.store(newEmploymentContract); - } - return result; - } - /** * Gets the list of all companies * @@ -365,35 +370,35 @@ return companies; } - /** - * Gets the employee's employments contracts - * - * @return a list containing all employment contracts - */ - public List<EmploymentContractFull> getEmploymentContracts() { - ChoremProxy proxy = getChoremProxy(); - Search search = Search.query(); - Criteria criteria = search.exteq(EmploymentContract.EXT_EMPLOYMENTCONTRACT). - associated(EmploymentContract.FQ_FIELD_EMPLOYMENTCONTRACT_EMPLOYEE). - eq(Employee.FQ_FIELD_EMPLOYEE_PERSON, personId).criteria(); - PagedResult<EmploymentContract> result = proxy.findAllByCriteria( - EmploymentContract.class, criteria); - List<EmploymentContract> employmentContracts = result.getAll(); - List<EmploymentContractFull> employmentContractsFull = new ArrayList<EmploymentContractFull>(); - EmploymentContractFull employeeTmp; - EmployeeFull employee; - - for (EmploymentContract employmentContract : employmentContracts) { - employeeTmp = new EmploymentContractFull(); - - employeeTmp.setEmploymentContract(employmentContract); - employee = EmployeeFull.initEmployee(employmentContract.getEmployee(), - proxy); - employeeTmp.setEmployee(employee); - employmentContractsFull.add(employeeTmp); - } - return employmentContractsFull; - } +// /** +// * Gets the employee's employments contracts +// * +// * @return a list containing all employment contracts +// */ +// public List<EmploymentContractFull> getEmploymentContracts() { +// ChoremProxy proxy = getChoremProxy(); +// Search search = Search.query(); +// Criteria criteria = search.exteq(EmploymentContract.EXT_EMPLOYMENTCONTRACT). +// associated(EmploymentContract.FQ_FIELD_EMPLOYMENTCONTRACT_EMPLOYEE). +// eq(Employee.FQ_FIELD_EMPLOYEE_PERSON, personId).criteria(); +// PagedResult<EmploymentContract> result = proxy.findAllByCriteria( +// EmploymentContract.class, criteria); +// List<EmploymentContract> employmentContracts = result.getAll(); +// List<EmploymentContractFull> employmentContractsFull = new ArrayList<EmploymentContractFull>(); +// EmploymentContractFull employeeTmp; +// EmployeeFull employee; +// +// for (EmploymentContract employmentContract : employmentContracts) { +// employeeTmp = new EmploymentContractFull(); +// +// employeeTmp.setEmploymentContract(employmentContract); +// employee = EmployeeFull.initEmployee(employmentContract.getEmployee(), +// proxy); +// employeeTmp.setEmployee(employee); +// employmentContractsFull.add(employeeTmp); +// } +// return employmentContractsFull; +// } /** * Gets the list of all persons @@ -453,6 +458,14 @@ public void setLastName(String lastName) { this.lastName = lastName; } + + public String getDiploma() { + return diploma; + } + + public void setDiploma(String diploma) { + this.diploma = diploma; + } /** * @return the email Deleted: trunk/chorem-web/src/main/java/org/chorem/gepeto/EmploymentContractFull.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/gepeto/EmploymentContractFull.java 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/java/org/chorem/gepeto/EmploymentContractFull.java 2011-11-19 17:17:08 UTC (rev 130) @@ -1,40 +0,0 @@ -package org.chorem.gepeto; - -import org.chorem.bonzoms.EmployeeFull; -import org.chorem.entities.EmploymentContract; - -/** - * @author vbriand - */ -public class EmploymentContractFull { - protected EmployeeFull employee; - protected EmploymentContract employmentContract; - - /** - * @return the employmentContract - */ - public EmploymentContract getEmploymentContract() { - return employmentContract; - } - - /** - * @param employmentContract the employmentContract to set - */ - public void setEmploymentContract(EmploymentContract employmentContract) { - this.employmentContract = employmentContract; - } - - /** - * @return the employee - */ - public EmployeeFull getEmployee() { - return employee; - } - - /** - * @param employee the employee to set - */ - public void setEmployee(EmployeeFull employee) { - this.employee = employee; - } -} Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companies.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companies.jsp 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/companies.jsp 2011-11-19 17:17:08 UTC (rev 130) @@ -17,59 +17,156 @@ <s:url id="companyDetails" namespace="/bonzoms" action="companyDetails"/> <script type="text/javascript"> - function formatCompanyNameLink(cellvalue, options, rowObject) { - return "<a href='<s:property value="companyDetails"/>?companyId="+rowObject['Employee.company']+"'>" + cellvalue + "</a>"; + function formatCompanyIdLink(cellvalue, options, rowObject) { + return "<a href='<s:property value="companyDetails"/>?companyId="+rowObject['id']+"'>voir</a>"; } + function formatCompanyLink(cellvalue, options, rowObject) { + return "<a href='<s:property value="companyDetails"/>?companyId="+rowObject['id']+"'>" + cellvalue + "</a>"; + } </script> <s:url id="personDetails" namespace="/bonzoms" action="personDetails"/> <script type="text/javascript"> function formatPersonNameLink(cellvalue, options, rowObject) { - return "<a href='<s:property value="personDetails"/>?personId="+rowObject['Employee.person']+"'>" + cellvalue + "</a>"; + return "<a href='<s:property value="personDetails"/>?personId="+rowObject['id']+"'>" + cellvalue + "</a>"; } </script> <%-- Partie generique (ou presque, ce ne sont que des variables qui change) --%> - <s:url id="remoteurlFulltextSearch" namespace="/" action="EntitySearchJson" escapeAmp="false"> + <s:url id="listCompanyUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> + <s:param name="wikittyExtension">Company</s:param> + </s:url> + + <s:url id="listContactDetailsUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> + <s:param name="wikittyExtension">ContactDetails</s:param> + </s:url> + + <s:url id="listEmployeeUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> <s:param name="wikittyExtension">Employee</s:param> <s:param name="wikittyLinkToLoad">Employee.person,Employee.company</s:param> </s:url> - <s:url id="remoteurl" namespace="/" action="EntitySearchJson" escapeAmp="false"> - <s:param name="fulltextSearch"><%=StringUtils.defaultString(request.getParameter("fulltextSearch"))%></s:param> + <s:url id="editCompanyUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> + <s:param name="wikittyExtension">Company</s:param> + </s:url> + + <s:url id="editEmployeeUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> <s:param name="wikittyExtension">Employee</s:param> - <s:param name="wikittyLinkToLoad">Employee.person,Employee.company</s:param> </s:url> + <s:url id="editContactDetailsUrl" namespace="/" action="EntitySearchJson" escapeAmp="false"> + <s:param name="wikittyExtension">ContactDetails</s:param> + <s:param name="wikittyLinkFieldForRowId">ContactDetails.target</s:param> + </s:url> + <script type="text/javascript"> var timeoutHnd; - function doSearch() { + function doSearchCompany() { if(timeoutHnd) { clearTimeout(timeoutHnd) } - timeoutHnd = setTimeout(gridReload, 500) + timeoutHnd = setTimeout(gridReloadCompany, 500) } - function gridReload() { - var filter = jQuery("#fulltextSearch").val(); - var gridUrl = "<s:property value="remoteurlFulltextSearch" escapeHtml="false"/>&fulltextSearch="+filter; - jQuery("#gridtable").jqGrid('setGridParam',{url:gridUrl,page:1}).trigger("reloadGrid"); + function gridReloadCompany() { + var filter = jQuery("#fulltextSearchCompany").val(); + var gridUrl = "<s:property value="listCompanyUrl" escapeHtml="false"/>&fulltextSearch="+filter; + jQuery("#gridCompany").jqGrid('setGridParam',{url:gridUrl,page:1}).trigger("reloadGrid"); } + + $.subscribe('rowselect', function(event, data) { + // alert('Selected Row : ' + event.originalEvent.id + ' data: ' + event.originalEvent.status); + var gridUrl = "<s:property value="listEmployeeUrl" escapeHtml="false"/>&fulltextSearch=" + event.originalEvent.id; + jQuery("#gridEmployee").jqGrid('setGridParam',{url:gridUrl,page:1}) + .trigger('reloadGrid'); + }); </script> <s:form> - <s:textfield id="fulltextSearch" name="fulltextSearch" onkeydown="doSearch()"></s:textfield> - <s:submit></s:submit> + <s:textfield id="fulltextSearchCompany" name="fulltextSearchCompany" onkeydown="doSearchCompany()"></s:textfield> </s:form> - <s:url id="editurl" namespace="/" action="EntitySearchJson" escapeAmp="false"> - </s:url> + <sjg:grid + id="gridCompany" + dataType="json" + href="%{listCompanyUrl}" + gridModel="gridModel" + rowList="10,20,50,100" + rowNum="20" + rownumbers="true" + autowidth="true" + sortname="Company.name" + sortorder="asc" + pager="true" + viewrecords="true" + multiselect="false" + + editurl="%{editCompanyUrl}" + editinline="false" + + onSelectRowTopics="rowselect" + + navigator="true" + navigatorAdd="true" + navigatorEdit="true" + navigatorDelete="true" + navigatorView="true" + navigatorSearch="true" + navigatorAddOptions="{height:280,reloadAfterSubmit:true}" + navigatorEditOptions="{height:280,reloadAfterSubmit:true}" + navigatorDeleteOptions="{height:280,reloadAfterSubmit:true}" + navigatorSearchOptions="{multipleGroup:true,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}" + > + + <sjg:gridColumn name="id" hidden="true" key="true" title="Action" formatter="formatCompanyIdLink" editable="false" sortable="false"/> + <sjg:gridColumn name="Company.name" index="Company.name" title="Société" editable="true" sortable="true"/> + <sjg:gridColumn name="Company.type" index="Company.type" title="type" editable="true" sortable="true"/> + + <sjg:grid + id="gridCompanyContact" + dataType="json" + href="%{listContactDetailsUrl}" + gridModel="gridModel" + rowList="10,20,50,100" + rowNum="20" + rownumbers="true" + autowidth="true" + sortname="ContactDetails.type" + sortorder="asc" + pager="true" + viewrecords="true" + + multiselect="false" + + editurl="%{editContactDetailsUrl}" + editinline="false" + + navigator="true" + navigatorAdd="true" + navigatorEdit="true" + navigatorDelete="true" + navigatorView="true" + navigatorSearch="true" + navigatorAddOptions="{height:280,reloadAfterSubmit:true}" + navigatorEditOptions="{height:280,reloadAfterSubmit:true}" + navigatorDeleteOptions="{height:280,reloadAfterSubmit:true}" + navigatorSearchOptions="{multipleGroup:true,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}" + > + + <sjg:gridColumn name="id" hidden="true" key="true" title="id"/> + <sjg:gridColumn name="ContactDetails.type" index="ContactDetails.type" title="Type" editable="true" sortable="true"/> + <sjg:gridColumn name="ContactDetails.name" index="ContactDetails.name" title="Name" editable="true" sortable="true"/> + <sjg:gridColumn name="ContactDetails.value" index="ContactDetails.value" title="Value" editable="true" sortable="true"/> + </sjg:grid> + + </sjg:grid> + <sjg:grid - id="gridtable" + id="gridEmployee" dataType="json" - href="%{remoteurl}" + href="%{listEmployeeUrl}" gridModel="gridModel" rowList="10,20,50,100" rowNum="20" @@ -80,9 +177,9 @@ pager="true" viewrecords="true" - multiselect="true" + multiselect="false" - editurl="%{editurl}" + editurl="%{editEmployeeUrl}" editinline="false" navigator="true" @@ -98,10 +195,56 @@ > <sjg:gridColumn name="id" hidden="true" key="true" title="id"/> - <sjg:gridColumn name="Company.name" index="Company.name" title="Société" formatter="formatCompanyNameLink"/> - <sjg:gridColumn name="Person.lastName" index="Person.lastName" title="Nom" editable="true" formatter="formatPersonNameLink"/> - <sjg:gridColumn name="Person.firstName" index="Person.firstName" title="Prénom" editable="true"/> - <sjg:gridColumn name="Employee.diploma" index="Employee.diploma" title="Diplôme"/> + <sjg:gridColumn name="Company.name" index="Company.name" title="Société" sortable="false" formatter="formatCompanyLink" editable="false"/> + <sjg:gridColumn name="Person.lastName" index="Person.lastName" title="Nom" sortable="false" formatter="formatPersonNameLink" editable="false"/> + <sjg:gridColumn name="Person.firstName" index="Person.firstName" title="Prénom" sortable="false" editable="false"/> + <sjg:gridColumn name="Person.diploma" index="Person.diploma" title="Diplôme" sortable="false" editable="false"/> + <sjg:gridColumn name="Employee.type" index="Employee.type" title="Type" edittype="select" editoptions="{value:'CDI:CDI;CDD:CDD;Stage:Stage;TNS:TNS'}" editable="true"/> + <sjg:gridColumn name="Employee.paidLeave" index="Employee.paidLeave" title="Congé" editrules="{number:true}" editable="true"/> + <sjg:gridColumn name="Employee.rtt" index="Employee.rtt" title="RTT" editrules="{number:true}" editable="true"/> + <sjg:gridColumn name="Employee.salary" index="Employee.salary" title="Salaire" editrules="{number:true}" editable="true"/> + <sjg:gridColumn name="Employee.workingTime" index="Employee.workingTime" title="Temps de travail" editrules="{number:true}" editable="true"/> + <sjg:gridColumn name="Employee.description" index="Employee.description" title="Description" edittype="textarea" editable="true"/> + <sjg:gridColumn name="Employee.person" index="Employee.person" title="Personne" editable="true" edittype="select" editoptions="{value:'%{selectOption}'}" editrules="{edithidden:true}"/> + <sjg:gridColumn name="Employee.company" index="Employee.company" title="Société" hidden="true" editable="true" editrules="{edithidden:true}"/> + + <sjg:grid + id="gridEmployeeContact" + dataType="json" + href="%{listContactDetailsUrl}" + gridModel="gridModel" + rowList="10,20,50,100" + rowNum="20" + rownumbers="true" + autowidth="true" + sortname="ContactDetails.type" + sortorder="asc" + pager="true" + viewrecords="true" + + multiselect="false" + + editurl="%{editContactDetailsUrl}" + editinline="false" + + navigator="true" + navigatorAdd="true" + navigatorEdit="true" + navigatorDelete="true" + navigatorView="true" + navigatorSearch="true" + navigatorAddOptions="{height:280,reloadAfterSubmit:true}" + navigatorEditOptions="{height:280,reloadAfterSubmit:true}" + navigatorDeleteOptions="{height:280,reloadAfterSubmit:true}" + navigatorSearchOptions="{multipleGroup:true,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}" + > + + <sjg:gridColumn name="id" hidden="true" key="true" title="id"/> + <sjg:gridColumn name="ContactDetails.type" index="ContactDetails.type" title="Type" editable="true" sortable="true"/> + <sjg:gridColumn name="ContactDetails.name" index="ContactDetails.name" title="Name" editable="true" sortable="true"/> + <sjg:gridColumn name="ContactDetails.value" index="ContactDetails.value" title="Value" editable="true" sortable="true"/> + </sjg:grid> + </sjg:grid> </body> Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/personDetails.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/personDetails.jsp 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/bonzoms/personDetails.jsp 2011-11-19 17:17:08 UTC (rev 130) @@ -3,7 +3,7 @@ <%@page import="org.chorem.gepeto.EmploymentContractFull" %> <%@page import="org.chorem.entities.EmploymentContract" %> <%@page import="org.chorem.entities.Employee" %> -<%@page import="java.util.List" %> +<%@page import="java.util.List" %>dip <%@taglib prefix="s" uri="/struts-tags" %> <html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" @@ -27,7 +27,12 @@ <p> <s:text name="chorem.bonzoms.person.birthDate" />: <%= person.getBirthDate() %> <br /> - <s:textfield key="chorem.bonzoms.person.email" name="email" labelSeparator=": " /> + <label for="diploma"><s:text name="chorem.bonzoms.employee.diploma" /></label>: + <% if (person != null) { %> + <input type="text" name="diploma" id="diploma" value="<%= person.getDiploma() %>" /> + <% } else { %> + <input type="text" name="diploma" id="diploma" /> + <% } %> <br /> <s:submit key="chorem.misc.modify" name="submit" /> </p> @@ -44,13 +49,6 @@ <% } %> </s:url> <form action="${modifyEmployee}" method="post"> - <label for="diploma"><s:text name="chorem.bonzoms.employee.diploma" /></label>: - <% if (employee != null) { %> - <input type="text" name="diploma" id="diploma" value="<%= employee.getDiploma() %>" /> - <% } else { %> - <input type="text" name="diploma" id="diploma" /> - <% } %> - <br /> <label for="paidLeave"><s:text name="chorem.bonzoms.employee.paidLeave" /></label>: <% if (employee != null) { %> <input type="text" name="paidLeave" id="paidLeave" value="<%= employee.getPaidLeave() %>" /> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-11-08 17:46:52 UTC (rev 129) +++ trunk/pom.xml 2011-11-19 17:17:08 UTC (rev 130) @@ -63,7 +63,7 @@ <wikittyVersion>3.3-SNAPSHOT</wikittyVersion> <slf4jVersion>1.6.1</slf4jVersion> <struts2Version>2.2.3</struts2Version> - <struts2jqueryVersion>3.1.0</struts2jqueryVersion> + <struts2jqueryVersion>3.2.0</struts2jqueryVersion> <xWorkCoreVersion>2.1.6</xWorkCoreVersion> <javaxMailVersion>1.4.3</javaxMailVersion> <servletApiVersion>2.5</servletApiVersion>