Author: echatellier Date: 2013-02-15 15:39:31 +0100 (Fri, 15 Feb 2013) New Revision: 116 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/116 Log: Display both mol?\195?\169cule and personne organisms Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeEditorBehavior.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java trunk/cantharella.web/src/main/webapp/js/moleditor.js Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-15 11:49:11 UTC (rev 115) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-15 14:39:31 UTC (rev 116) @@ -23,6 +23,7 @@ package nc.ird.cantharella.data.model; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; import javax.persistence.Column; @@ -148,6 +149,14 @@ private List<Document> documents; /** + * Constructor. + */ + public Molecule() { + provenances = new ArrayList<MoleculeProvenance>(); + documents = new ArrayList<Document>(); + } + + /** * Id molecule getter. * * @return the idMolecule Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-02-15 11:49:11 UTC (rev 115) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-02-15 14:39:31 UTC (rev 116) @@ -23,10 +23,14 @@ package nc.ird.cantharella.service.services.impl; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import nc.ird.cantharella.data.dao.GenericDao; import nc.ird.cantharella.data.dao.impl.MoleculeDao; +import nc.ird.cantharella.data.dao.impl.PersonneDao; import nc.ird.cantharella.data.exceptions.DataConstraintException; import nc.ird.cantharella.data.exceptions.DataNotFoundException; import nc.ird.cantharella.data.exceptions.UnexpectedException; @@ -129,7 +133,7 @@ result.add(new MoleculeProvenanceBean(molecule)); } } - + return result; } @@ -163,7 +167,13 @@ @SuppressWarnings("unchecked") @Override public List<String> listMoleculeOrganisme() { - return (List<String>) dao.list(MoleculeDao.CRITERIA_DISTINCT_MOLECULE_ORGANISMES); + Set<String> organismes = new HashSet<String>(); + organismes.addAll((List<String>)dao.list(MoleculeDao.CRITERIA_DISTINCT_MOLECULE_ORGANISMES)); + organismes.addAll((List<String>)dao.list(PersonneDao.CRITERIA_DISTINCT_PERSONNE_ORGANISMES)); + List<String> result = new ArrayList<String>(organismes); + result.remove(null); // fix NPE on sort + Collections.sort(result); + return result; } /** {@inheritDoc} */ Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeEditorBehavior.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeEditorBehavior.java 2013-02-15 11:49:11 UTC (rev 115) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeEditorBehavior.java 2013-02-15 14:39:31 UTC (rev 116) @@ -57,7 +57,11 @@ protected String newValue(String currentValue, String replacementValue) { // on ajoute toujours un premier caractere pour oblige l'existance de // l'attribut car sinon si formula est vide l'attribut n'est pas ajoute - return "." + replacementValue; + String result = "."; + if (replacementValue != null) { + result += replacementValue; + } + return result; } /** {@inheritDoc} */ Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java 2013-02-15 11:49:11 UTC (rev 115) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java 2013-02-15 14:39:31 UTC (rev 116) @@ -76,7 +76,11 @@ protected String newValue(String currentValue, String replacementValue) { // on ajoute toujours un premier caractere pour oblige l'existance de // l'attribut car sinon si formula est vide le l'attribut n'est pas ajoute - return "." + replacementValue; + String result = "."; + if (replacementValue != null) { + result += replacementValue; + } + return result; } /** {@inheritDoc} */ Modified: trunk/cantharella.web/src/main/webapp/js/moleditor.js =================================================================== --- trunk/cantharella.web/src/main/webapp/js/moleditor.js 2013-02-15 11:49:11 UTC (rev 115) +++ trunk/cantharella.web/src/main/webapp/js/moleditor.js 2013-02-15 14:39:31 UTC (rev 116) @@ -21,7 +21,7 @@ * #L% */ function addEditorMolecule(tagId) { - if (tagId) { + if (tagId) { tagId = '#' + tagId.replace( /(:|\.)/g, "\\$1" ); } else { tagId = '[formula]';