Author: acheype Date: 2013-02-18 01:07:41 +0100 (Mon, 18 Feb 2013) New Revision: 118 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/118 Log: change the package from nc.ird.module.utils to nc.ird.cantharella.utils and add a logger in the module utils to not fail the dependency:analyse mvn goal (for "mvn install -DperformRelease") Added: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/AssertTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanLookup.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CantharellaConfig.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CaptchaTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CollectionTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CoordTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenerateCsv.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenericsTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/IntuitiveStringComparator.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/NumberTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/Pair.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/PasswordTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTools.java trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTransformer.java Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Droits.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/FractionsOfPurificationComp.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/ResultatsOfTestBioComp.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/CompositeId.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/DbUniqueFieldValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeOrientationValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeOrientationValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeValidator.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/config/ServiceContext.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/CampagneServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ExtractionServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/LotServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MailServiceImpl.java 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/PersonneServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PurificationServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SpecimenServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/StationServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/TestBioServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/CampagneNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ConfigNameNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/EmailNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ErreurTestNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ExtractionNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/LotNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeExtractionNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodePurificationNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeTestBioNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PartieNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PersonneNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PurificationNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/SpecimenNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/StationNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TestBioNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TypeDocumentNormalizer.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/UniqueFieldNormalizer.java trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/ExcelColumnsReader.java trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/PopulateDB.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/AssertToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanLookupTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CaptchaToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CollectionToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CoordToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/GenericsToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/NumberToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PairTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PasswordToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringToolsTest.java trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringTransformerTest.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/ContactPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/HomePage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/LinkProduitPropertyColumn.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/campagne/ManageCampagnePage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/extraction/ManageExtractionPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/purification/ManagePurificationPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/specimen/ManageSpecimenPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/station/ManageStationPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/testBio/ManageTestBioPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/ManageUtilisateurPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/RegisterPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/ManageStationModel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/RegisterModel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/UpdateUtilisateurModel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/CallerPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/JSConfirmationBehavior.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/BigDecimalConverterImpl.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/DoubleConverterImpl.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/forms/AutoCompleteTextFieldString.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/GenericLoadableDetachableModel.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/LoadableDetachableSortableListDataProvider.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/resources/WebMessages.java Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java 2013-02-18 00:07:41 UTC (rev 118) @@ -40,7 +40,7 @@ import nc.ird.cantharella.data.exceptions.UnexpectedException; import nc.ird.cantharella.data.validation.utils.ModelValidator; import nc.ird.cantharella.data.validation.utils.ModelValidatorImpl; -import nc.ird.module.utils.CantharellaConfig; +import nc.ird.cantharella.utils.CantharellaConfig; import org.hibernate.SessionFactory; import org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java 2013-02-18 00:07:41 UTC (rev 118) @@ -29,8 +29,8 @@ import nc.ird.cantharella.data.dao.GenericDao; import nc.ird.cantharella.data.model.utils.AbstractModel; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.GenericsTools; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.GenericsTools; import org.hibernate.Criteria; import org.hibernate.Query; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Droits.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Droits.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Droits.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,8 +27,8 @@ import javax.persistence.Embeddable; import javax.validation.constraints.NotNull; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; /** * Modèles : droits Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-02-18 00:07:41 UTC (rev 118) @@ -47,7 +47,7 @@ import nc.ird.cantharella.data.model.comparators.FractionsOfPurificationComp; import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter; import nc.ird.cantharella.data.model.utils.AbstractModel; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.commons.beanutils.BeanComparator; import org.apache.commons.collections.comparators.ComparatorChain; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java 2013-02-18 00:07:41 UTC (rev 118) @@ -40,7 +40,7 @@ import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter; import nc.ird.cantharella.data.model.utils.AbstractModel; import nc.ird.cantharella.data.validation.CollectionUniqueField; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.commons.beanutils.BeanComparator; import org.apache.commons.collections.comparators.ComparatorChain; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java 2013-02-18 00:07:41 UTC (rev 118) @@ -35,7 +35,7 @@ import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; -import nc.ird.module.utils.PasswordTools; +import nc.ird.cantharella.utils.PasswordTools; import org.hibernate.annotations.Index; import org.hibernate.validator.constraints.Length; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/FractionsOfPurificationComp.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/FractionsOfPurificationComp.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/FractionsOfPurificationComp.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import java.util.Comparator; import nc.ird.cantharella.data.model.Fraction; -import nc.ird.module.utils.IntuitiveStringComparator; +import nc.ird.cantharella.utils.IntuitiveStringComparator; import org.apache.commons.beanutils.BeanComparator; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/ResultatsOfTestBioComp.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/ResultatsOfTestBioComp.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/comparators/ResultatsOfTestBioComp.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import java.util.Comparator; import nc.ird.cantharella.data.model.ResultatTestBio; -import nc.ird.module.utils.IntuitiveStringComparator; +import nc.ird.cantharella.utils.IntuitiveStringComparator; import org.apache.commons.beanutils.BeanComparator; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-02-18 00:07:41 UTC (rev 118) @@ -32,9 +32,9 @@ import javax.persistence.Id; import nc.ird.cantharella.data.exceptions.UnexpectedException; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/CompositeId.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/CompositeId.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/CompositeId.java 2013-02-18 00:07:41 UTC (rev 118) @@ -26,9 +26,9 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.GenericsTools; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.GenericsTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; /** * Composite-ID Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,10 +27,10 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; -import nc.ird.module.utils.GenericsTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; +import nc.ird.cantharella.utils.GenericsTools; /** * Field unique validator Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/DbUniqueFieldValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/DbUniqueFieldValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/DbUniqueFieldValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,9 +30,9 @@ import nc.ird.cantharella.data.dao.GenericDao; import nc.ird.cantharella.data.exceptions.DataNotFoundException; import nc.ird.cantharella.data.model.utils.AbstractModel; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; import org.springframework.beans.factory.annotation.Autowired; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeOrientationValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeOrientationValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeOrientationValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,7 +27,7 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; /** * Latitude validator Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LatitudeValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; /** * Latitude validator Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeOrientationValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeOrientationValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeOrientationValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,7 +27,7 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; /** * Latitude validator Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeValidator.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeValidator.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/LongitudeValidator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; /** * Longitude validator Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,7 +30,7 @@ import javax.validation.Validator; import javax.validation.ValidatorFactory; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorImpl.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -36,7 +36,7 @@ import javax.validation.metadata.ConstraintDescriptor; import nc.ird.cantharella.data.model.utils.AbstractModel; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/config/ServiceContext.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/config/ServiceContext.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/config/ServiceContext.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,8 +30,8 @@ import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.utils.normalizers.PersonneNormalizer; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.CantharellaConfig; -import nc.ird.module.utils.PasswordTools; +import nc.ird.cantharella.utils.CantharellaConfig; +import nc.ird.cantharella.utils.PasswordTools; import org.nuiton.util.ArgumentsParserException; import org.slf4j.Logger; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/CampagneServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/CampagneServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/CampagneServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -37,7 +37,7 @@ import nc.ird.cantharella.data.model.Utilisateur; import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.CampagneService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -32,7 +32,7 @@ import nc.ird.cantharella.data.model.TypeDocument; import nc.ird.cantharella.data.model.Utilisateur; import nc.ird.cantharella.service.services.DocumentService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ExtractionServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ExtractionServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ExtractionServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -41,7 +41,7 @@ import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.ExtractionService; import nc.ird.cantharella.service.services.LotService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/LotServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/LotServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/LotServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -37,7 +37,7 @@ import nc.ird.cantharella.data.model.Utilisateur; import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.LotService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MailServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MailServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MailServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,7 +30,7 @@ import nc.ird.cantharella.service.config.ServiceContext; import nc.ird.cantharella.service.exceptions.EmailException; import nc.ird.cantharella.service.services.MailService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; 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-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -45,7 +45,7 @@ import nc.ird.cantharella.service.model.MoleculeProvenanceBean; import nc.ird.cantharella.service.services.LotService; import nc.ird.cantharella.service.services.MoleculeService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PersonneServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PersonneServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PersonneServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -39,8 +39,8 @@ import nc.ird.cantharella.service.services.PersonneService; import nc.ird.cantharella.service.utils.normalizers.EmailNormalizer; import nc.ird.cantharella.service.utils.normalizers.utils.Normalize; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.PasswordTools; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.PasswordTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -40,7 +40,7 @@ import nc.ird.cantharella.service.services.ExtractionService; import nc.ird.cantharella.service.services.ProduitService; import nc.ird.cantharella.service.services.PurificationService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PurificationServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PurificationServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/PurificationServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -45,7 +45,7 @@ import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.ExtractionService; import nc.ird.cantharella.service.services.PurificationService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SpecimenServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SpecimenServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SpecimenServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -39,7 +39,7 @@ import nc.ird.cantharella.data.model.Utilisateur; import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.SpecimenService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/StationServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/StationServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/StationServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -38,7 +38,7 @@ import nc.ird.cantharella.data.model.Utilisateur; import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.StationService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/TestBioServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/TestBioServiceImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/TestBioServiceImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -41,7 +41,7 @@ import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; import nc.ird.cantharella.service.services.LotService; import nc.ird.cantharella.service.services.TestBioService; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/CampagneNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/CampagneNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/CampagneNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,8 +24,8 @@ import nc.ird.cantharella.data.model.Campagne; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * Campagne normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ConfigNameNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ConfigNameNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ConfigNameNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -23,7 +23,7 @@ package nc.ird.cantharella.service.utils.normalizers; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.StringTransformer; /** * Unique name normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.Document; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Document normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/EmailNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/EmailNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/EmailNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -23,7 +23,7 @@ package nc.ird.cantharella.service.utils.normalizers; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.StringTransformer; /** * E-mail normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ErreurTestNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ErreurTestNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ErreurTestNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.ErreurTestBio; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * ErreurTest normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ExtractionNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ExtractionNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/ExtractionNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import nc.ird.cantharella.data.model.Extraction; import nc.ird.cantharella.data.model.Extrait; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Extraction normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/LotNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/LotNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/LotNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.Lot; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Lot normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeExtractionNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeExtractionNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeExtractionNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import nc.ird.cantharella.data.model.MethodeExtraction; import nc.ird.cantharella.data.model.TypeExtrait; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * MethodeExtraction normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodePurificationNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodePurificationNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodePurificationNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import nc.ird.cantharella.data.model.MethodePurification; import nc.ird.cantharella.data.model.ParamMethoPuri; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * MethodePurification normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeTestBioNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeTestBioNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MethodeTestBioNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,8 +24,8 @@ import nc.ird.cantharella.data.model.MethodeTestBio; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * MethodeTest normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.Molecule; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Molecule normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PartieNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PartieNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PartieNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.Partie; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Partie normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PersonneNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PersonneNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PersonneNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,8 +24,8 @@ import nc.ird.cantharella.data.model.Personne; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * Personne normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PurificationNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PurificationNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/PurificationNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -26,8 +26,8 @@ import nc.ird.cantharella.data.model.ParamMethoPuriEffectif; import nc.ird.cantharella.data.model.Purification; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * Purification normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/SpecimenNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/SpecimenNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/SpecimenNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,8 +24,8 @@ import nc.ird.cantharella.data.model.Specimen; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * Spécimen normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/StationNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/StationNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/StationNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,8 +24,8 @@ import nc.ird.cantharella.data.model.Station; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * Station normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TestBioNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TestBioNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TestBioNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,8 +25,8 @@ import nc.ird.cantharella.data.model.ResultatTestBio; import nc.ird.cantharella.data.model.TestBio; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.StringTransformer; /** * TestBio normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TypeDocumentNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TypeDocumentNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/TypeDocumentNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import nc.ird.cantharella.data.model.TypeDocument; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Document type normalizer Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/UniqueFieldNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/UniqueFieldNormalizer.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/UniqueFieldNormalizer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -23,7 +23,7 @@ package nc.ird.cantharella.service.utils.normalizers; import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.StringTransformer; /** * Unique name normalizer Modified: trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/ExcelColumnsReader.java =================================================================== --- trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/ExcelColumnsReader.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/ExcelColumnsReader.java 2013-02-18 00:07:41 UTC (rev 118) @@ -32,7 +32,7 @@ import java.util.Map; import nc.ird.cantharella.service.exceptions.ExcelImportException; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; Modified: trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/PopulateDB.java =================================================================== --- trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/PopulateDB.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/utils/PopulateDB.java 2013-02-18 00:07:41 UTC (rev 118) @@ -60,7 +60,7 @@ import nc.ird.cantharella.service.services.SpecimenService; import nc.ird.cantharella.service.services.StationService; import nc.ird.cantharella.service.utils.ExcelColumnStructure.ExcelColumnType; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/AssertTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/AssertTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/AssertTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/AssertTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,251 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.util.Arrays; +import java.util.Collection; + +/** + * Assertion tools. You need to have -ea or -enableassertions in the JVM args. + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class AssertTools { + + /** Error message for wrong class argument */ + private static final String CLASS = "Argument must be of type %s"; + + /** Error message for not equals argument */ + private static final String EQUALS = "Argument must be equals to %s"; + + /** Error message for not greater argument */ + private static final String GREATER = "Argument must be greater than %s"; + + /** Error message for not greater or equals argument */ + private static final String GREATER_OR_EQUALS = "Argument must be greater than or equals to %s"; + + /** Error message for "not in" argument */ + private static final String IN = "Argument must be in %s"; + + /** Error message for not lower argument */ + private static final String LOWER = "Argument must be lower than %s"; + + /** Error message for not lower or equals argument */ + private static final String LOWER_OR_EQUALS = "Argument must be lower than or equals to %s"; + + /** Error message for empty argument */ + private static final String NOT_EMPTY = "Argument must not be empty"; + + /** Error message for equals argument */ + private static final String NOT_EQUALS = "Argument must not be equals to %s"; + + /** Error message for null argument */ + private static final String NOT_NULL = "Argument must not be null"; + + /** + * Assert that none of the string in an array is empty + * @param strings Strings array + */ + public static void assertArrayNotEmpty(String[] strings) { + assertNotNull(strings); + for (String string : strings) { + assertNotEmpty(string); + } + } + + /** + * Assert that none of the objects in an array is null + * @param objects Objects array + */ + public static void assertArrayNotNull(Object[] objects) { + assertNotNull(objects); + for (Object object : objects) { + assertNotNull(object); + } + } + + /** + * Assert that an object class/superclass/interface/superinterface + * @param object Object + * @param clazz Expected class/superclass/interface/superinterface + */ + public static void assertClassOrInterface(Object object, Class<?> clazz) { + assertNotNull(object); + assertNotNull(clazz); + assert clazz.isAssignableFrom(object.getClass()) : String.format(CLASS, clazz.getName()); + } + + /** + * Assert that none of the objects in a Collection is null + * @param objects Objects collection + */ + public static void assertCollectionNotNull(Collection<?> objects) { + assertNotNull(objects); + for (Object object : objects) { + assertNotNull(object); + } + } + + /** + * Assert that a value is equals to an expected value + * @param <N> Number type + * @param value Value + * @param expectedValue Expected value + */ + public static <N extends Number> void assertEquals(N value, N expectedValue) { + assert value.doubleValue() == expectedValue.doubleValue() : String.format(EQUALS, expectedValue); + } + + /** + * Assert that a value is greater than to a bound + * @param <N> Number type + * @param value Value + * @param bound Bound + */ + public static <N extends Number> void assertGreater(N value, N bound) { + assert value.doubleValue() > bound.doubleValue() : String.format(GREATER, bound); + } + + /** + * Assert that a value is greater than or equals to a bound + * @param <N> Number type + * @param value Value + * @param bound Bound + */ + public static <N extends Number> void assertGreaterOrEquals(N value, N bound) { + assert value.doubleValue() >= bound.doubleValue() : String.format(GREATER_OR_EQUALS, bound); + } + + /** + * Assert that an object is contains in a values array + * @param <O> Object type + * @param object Object + * @param values Values collection + */ + public static <O> void assertIn(O object, Collection<O> values) { + assertNotNull(object); + assertNotEmpty(values); + assert values.contains(object) : String.format(IN, object); + } + + /** + * Assert that an object is contains in a values array + * @param <O> Object type + * @param object Object + * @param values Values array + */ + public static <O> void assertIn(O object, O... values) { + assertNotEmpty(values); + assertIn(object, Arrays.asList(values)); + } + + /** + * Assert that a value is lower than to a bound + * @param <N> Number type + * @param value Value + * @param bound Bound + */ + public static <N extends Number> void assertLower(N value, N bound) { + assert value.doubleValue() < bound.doubleValue() : String.format(LOWER, bound); + } + + /** + * Assert that a value is lower than or equals to a bound + * @param <N> Number type + * @param value Value + * @param bound Bound + */ + public static <N extends Number> void assertLowerOrEquals(N value, N bound) { + assert value.doubleValue() <= bound.doubleValue() : String.format(LOWER_OR_EQUALS, bound); + } + + /** + * Assert that an array is not null or empty + * @param collection Collection + */ + public static void assertNotEmpty(Collection<?> collection) { + assertNotNull(collection); + assert !collection.isEmpty() : NOT_EMPTY; + } + + /** + * Assert that a collection is not null or empty + * @param array Array + */ + public static void assertNotEmpty(Object[] array) { + assertNotNull(array); + assert array.length > 0 : NOT_EMPTY; + } + + /** + * Assert that a string is not null or empty + * @param string String + */ + public static void assertNotEmpty(String string) { + assertNotNull(string); + assert !string.isEmpty() : NOT_EMPTY; + } + + /** + * Assert that a value is not equals to an unexpected value + * @param <N> Number type + * @param value Value + * @param unexpectedValue Unxpected value + */ + public static <N extends Number> void assertNotEquals(N value, N unexpectedValue) { + assert value.doubleValue() != unexpectedValue.doubleValue() : String.format(NOT_EQUALS, unexpectedValue); + } + + /** + * Assert that a value is not negative + * @param <N> Number type + * @param value Value + */ + public static <N extends Number> void assertNotNegative(N value) { + assertGreaterOrEquals(value, 0); + } + + /** + * Assert that an object is not null + * @param object Object + */ + public static void assertNotNull(Object object) { + assert object != null : NOT_NULL; + } + + /** + * Assert that a value is positive + * @param <N> Number type + * @param value Value + */ + public static <N extends Number> void assertPositive(N value) { + assertGreater(value, 0); + } + + /** + * Constructor (prevents instantiation) + */ + private AssertTools() { + // + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanLookup.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanLookup.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanLookup.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanLookup.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,67 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import nc.ird.cantharella.utils.BeanTools.AccessType; + +import org.apache.commons.lang3.text.StrLookup; + +/** + * Retrieve a bean field value from the bean field name + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class BeanLookup extends StrLookup { + + /** Access type */ + private final AccessType accessType; + + /** Bean */ + private final Object bean; + + /** + * Constructor + * @param bean Bean + * @param accessType Access type + */ + public BeanLookup(Object bean, AccessType accessType) { + super(); + AssertTools.assertNotNull(bean); + AssertTools.assertNotNull(accessType); + this.bean = bean; + this.accessType = accessType; + } + + /** {@inheritDoc} */ + @Override + public String lookup(String key) { + AssertTools.assertNotNull(key); + Object value; + try { + value = BeanTools.getValue(bean, accessType, key); + } catch (IllegalArgumentException e) { + value = null; + } + return value != null ? value.toString() : null; + } +} \ No newline at end of file Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/BeanTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,538 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.beans.PropertyDescriptor; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.beanutils.BeanComparator; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; + +/** + * Tools for beans + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class BeanTools { + + /** + * Access type + */ + public enum AccessType { + /** Access by (public) field */ + FIELD, + /** Access by (public) getter */ + GETTER; + } + + /** Error message for annotation not found in a class */ + private static final String ANNOTATION = "Argument of type %s must have a field annotated with %s"; + + /** Error message for field not found in a class */ + private static final String FIELD = "Argument of type %s must have an accessible %s property"; + + /** Parameters */ + private static final Object[] PARAMETERS = new Object[0]; + + /** + * Equals method + * @param thiz First object ("this", not null) + * @param obj Second object + * @param accessType Access type + * @param properties Properties (names) to check + * @return Equality + */ + public static boolean equals(Object thiz, Object obj, AccessType accessType, String... properties) { + AssertTools.assertNotNull(thiz); + AssertTools.assertNotEmpty(properties); + AssertTools.assertArrayNotNull(properties); + if (thiz == obj) { + return true; + } + if (obj != null + && thiz != null + && (thiz.getClass().isAssignableFrom(obj.getClass()) || obj.getClass() + .isAssignableFrom(thiz.getClass()))) { + EqualsBuilder builder = new EqualsBuilder(); + for (String property : properties) { + try { + Object val1 = getValue(thiz, accessType, property); + Object val2 = getValue(obj, accessType, property); + + // Test hashCodes first + if (val1 != null && val2 != null && !builder.append(val1.hashCode(), val2.hashCode()).isEquals()) { + return false; + } + + if (!builder.append(val1, val2).isEquals()) { + return false; + } + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(String.format(FIELD, thiz.getClass(), property), e); + } + + } + return builder.isEquals(); + } + return false; + } + + /** + * Equals method + * @param thiz First object ("this", not null) + * @param obj Second object + * @param fields Public fields to check + * @return Equality + */ + public static boolean equals(Object thiz, Object obj, Field... fields) { + AssertTools.assertNotNull(thiz); + AssertTools.assertNotEmpty(fields); + AssertTools.assertArrayNotNull(fields); + if (thiz == obj) { + return true; + } + if (obj != null + && thiz != null + && (thiz.getClass().isAssignableFrom(obj.getClass()) || obj.getClass() + .isAssignableFrom(thiz.getClass()))) { + EqualsBuilder builder = new EqualsBuilder(); + for (Field field : fields) { + try { + Object val1 = field.get(thiz); + Object val2 = field.get(obj); + + // Test hashCodes first + if (val1 != null && val2 != null && !builder.append(val1.hashCode(), val2.hashCode()).isEquals()) { + return false; + } + + if (!builder.append(val1, val2).isEquals()) { + return false; + } + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(String.format(FIELD, thiz.getClass(), field.getName()), e); + } + } + return builder.isEquals(); + } + return false; + } + + /** + * Retrieve an annotated public field or from inherited public field too + * @param thiz Object + * @param annotations Annotations to retrieve on a public field + * @return First annotated public field + * @throws NoSuchFieldException If an annotation cannot be found + */ + public static Field getAnnotatedPublicField(Object thiz, Class<? extends Annotation>... annotations) + throws NoSuchFieldException { + AssertTools.assertNotNull(thiz); + return getAnnotatedPublicField(thiz.getClass(), annotations); + } + + /** + * Retrieve an annotated from private field or from inherited private, protected or public field + * @param clazz The class which contains annotations (or inherited class) + * @param annotations Annotations to retrieve + * @return First annotated field finded + * @throws NoSuchFieldException If an annotation cannot be found + */ + public static Field getAnnotatedPrivateField(Class<?> clazz, Class<? extends Annotation>... annotations) + throws NoSuchFieldException { + AssertTools.assertNotNull(clazz); + AssertTools.assertNotEmpty(annotations); + AssertTools.assertArrayNotNull(annotations); + Field[] fields = clazz.getDeclaredFields(); + Field field = null; + int i = 0; + while (field == null && i < fields.length) { + int j = 0; + while (field == null && j < annotations.length) { + if (fields[i].isAnnotationPresent(annotations[j])) { + field = fields[i]; + } + ++j; + } + ++i; + } + if (field == null) { + // if not found + if (clazz.getSuperclass() == null) { + throw new NoSuchFieldException(String.format(ANNOTATION, clazz.getName(), Arrays.toString(annotations))); + } + // recursive search in the superclass + return getAnnotatedInheritedField(clazz, clazz.getSuperclass(), annotations); + } + return field; + } + + /** + * Retrieve an annotated from inherited private, protected or public field + * @param baseClazz The base clazz where the search began + * @param browsedClazz The + * @param annotations Annotations to retrieve + * @return First annotated field finded + * @throws NoSuchFieldException If an annotation cannot be found + */ + private static Field getAnnotatedInheritedField(Class<?> baseClazz, Class<?> browsedClazz, + Class<? extends Annotation>... annotations) throws NoSuchFieldException { + AssertTools.assertNotNull(baseClazz); + AssertTools.assertNotEmpty(annotations); + AssertTools.assertArrayNotNull(annotations); + + Field[] fields = browsedClazz.getDeclaredFields(); + Field field = null; + int i = 0; + while (field == null && i < fields.length) { + int j = 0; + while (field == null && j < annotations.length) { + if (fields[i].isAnnotationPresent(annotations[j]) + && (Modifier.isProtected(fields[i].getModifiers()) + || Modifier.isPublic(fields[i].getModifiers()) || Modifier.isPrivate(fields[i] + .getModifiers()))) { + field = fields[i]; + } + ++j; + } + ++i; + } + if (field == null) { + // if not found + if (browsedClazz.getSuperclass() == null) { + throw new NoSuchFieldException(String.format(ANNOTATION, baseClazz.getName(), Arrays + .toString(annotations))); + } + // recursive search in the superclass + getAnnotatedInheritedField(baseClazz, browsedClazz.getSuperclass(), annotations); + } + return field; + } + + /** + * Retrieve an annotated public field + * @param clazz The class which contains annotations + * @param annotations Annotations to retrieve on a public field + * @return First annotated public field + * @throws NoSuchFieldException If an annotation cannot be found + */ + public static Field getAnnotatedPublicField(Class<?> clazz, Class<? extends Annotation>... annotations) + throws NoSuchFieldException { + AssertTools.assertNotNull(clazz); + AssertTools.assertNotEmpty(annotations); + AssertTools.assertArrayNotNull(annotations); + Field[] fields = clazz.getFields(); + Field field = null; + int i = 0; + while (field == null && i < fields.length) { + int j = 0; + while (field == null && j < annotations.length) { + if (fields[i].isAnnotationPresent(annotations[j])) { + field = fields[i]; + } + ++j; + } + ++i; + } + if (field == null) { + throw new NoSuchFieldException(String.format(ANNOTATION, clazz.getName(), Arrays.toString(annotations))); + } + return field; + } + + /** + * Get an annotation on a bean property + * @param <A> Annotation class + * @param beanClass Bean class + * @param annotation Annotation + * @param property Property name + * @return The annotation + * @throws NoSuchFieldException If the property does not exist + */ + public static <A extends Annotation> A getAnnotationOnProperty(Class<?> beanClass, Class<A> annotation, + String property) throws NoSuchFieldException { + AssertTools.assertNotNull(beanClass); + AssertTools.assertNotNull(annotation); + return beanClass.getField(property).getAnnotation(annotation); + } + + /** + * Get a property value for a specified bean + * @param bean Bean + * @param accessType Access type + * @param property Property name + * @return Property value + */ + public static Object getValue(Object bean, AccessType accessType, String property) { + AssertTools.assertNotNull(bean); + AssertTools.assertNotNull(accessType); + AssertTools.assertNotEmpty(property); + Object value; + switch (accessType) { + case GETTER: + try { + value = new PropertyDescriptor(property, bean.getClass(), "is" + StringUtils.capitalize(property), + null).getReadMethod().invoke(bean, PARAMETERS); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + break; + case FIELD: + try { + value = bean.getClass().getField(property).get(bean); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(e); + } + break; + default: + throw new IllegalArgumentException(); + } + return value; + } + + /** + * Get a property value for a specified bean + * @param bean Bean + * @param accessType Access type + * @param pathToProperty properties path to access the property, example : beanX.beanY.propZ + * @return Property value + */ + public static Object getValueFromPath(Object bean, AccessType accessType, String pathToProperty) { + AssertTools.assertNotNull(bean); + AssertTools.assertNotNull(accessType); + AssertTools.assertNotEmpty(pathToProperty); + List<String> beanNames = createAccessBeanList(pathToProperty); + Object curBean = bean; + for (String beanName : beanNames) { + curBean = BeanTools.getValue(curBean, AccessType.GETTER, beanName); + } + return curBean; + } + + /** + * Extract from the given path, the differents beans name to access example : "X.Y.Z.F" will give the the array + * {"X", "Y", "Z", "F"} + * @param propertiesPath the properties path to browse + * @return an array of all the different bean names to access + */ + private static List<String> createAccessBeanList(final String propertiesPath) { + final Matcher matcher = Pattern.compile("\\w+").matcher(propertiesPath); + List<String> paramList = new ArrayList<String>(); + while (matcher.find()) { + paramList.add(propertiesPath.substring(matcher.start(), matcher.end())); + } + return paramList; + } + + /** + * HashCode method + * @param thiz Bean (not null) + * @param fields Public fields to considere + * @return HashCode + */ + public static int hashCode(Object thiz, Field... fields) { + AssertTools.assertNotNull(thiz); + AssertTools.assertNotEmpty(fields); + AssertTools.assertArrayNotNull(fields); + int seed = thiz.getClass().hashCode(); + int hashCode = seed; + for (Field field : fields) { + Object value; + try { + value = field.get(thiz); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(String.format(FIELD, thiz.getClass(), field.getName()), e); + } + hashCode += value != null ? seed ^ value.hashCode() : 0; + } + return hashCode; + } + + /** + * HashCode method + * @param thiz Bean (not null) + * @param ids Bean IDs + * @return HashCode + */ + public static int hashCode(Object thiz, Object... ids) { + AssertTools.assertNotNull(thiz); + AssertTools.assertNotEmpty(ids); + AssertTools.assertNotNull(ids); + int seed = thiz.getClass().hashCode(); + int hashCode = seed; + for (Object id : ids) { + hashCode += id != null ? seed ^ id.hashCode() : 0; + } + return hashCode; + } + + /** + * Is there an annotation on a bean property + * @param <A> Annotation class + * @param beanClass Bean class + * @param annotation Annotation + * @param property Property name + * @return TRUE if the annotation is on the bean property + * @throws NoSuchFieldException If the property does not exist + */ + public static <A extends Annotation> boolean isAnnotationOnProperty(Class<?> beanClass, Class<A> annotation, + String property) throws NoSuchFieldException { + return getAnnotationOnProperty(beanClass, annotation, property) != null; + } + + /** + * Display a bean by listing the specified properties + * @param bean Bean + * @param delimiter Delimiter between properties in the resulting string + * @param accessType Access type + * @param pathsToProperties Path of properties to display + * @return Bean display + */ + public static String toString(Object bean, String delimiter, AccessType accessType, String... pathsToProperties) { + AssertTools.assertNotNull(bean); + AssertTools.assertNotEmpty(delimiter); + AssertTools.assertArrayNotNull(pathsToProperties); + Class<?> clazz = bean.getClass(); + StringBuilder builder = new StringBuilder(clazz.getName()); + for (String pathToProperty : pathsToProperties) { + try { + Object value = getValueFromPath(bean, accessType, pathToProperty); + builder.append(delimiter + pathToProperty + ": " + (value != null ? value.toString() : "<null>")); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalArgumentException(String.format(FIELD, clazz, pathToProperty), e); + } + } + return builder.toString(); + } + + /** + * Display a bean by listing the specified properties (separated by "\n") + * @param bean Bean + * @param accessType Access type + * @param properties Properties to display + * @return Bean display + */ + public static String toString(Object bean, AccessType accessType, String... properties) { + return toString(bean, "\n- ", accessType, properties); + } + + /** + * Constructor (prevents instantiation) + */ + private BeanTools() { + // + } + + /** + * Display a list of beans by listing the specified properties (bean separated by "\n", properties by ", ") + * @param beansList The beans list to browsed + * @param accessType Access type + * @param pathsToProperties Paths to properties to display + * @return Bean display + */ + public static String beanListToString(List<? extends Object> beansList, AccessType accessType, + String... pathsToProperties) { + return BeanTools.beanListToString(beansList, "\n", ", ", accessType, pathsToProperties); + } + + /** + * Display a list of beans by listing the specified properties + * @param beansList The beans list to browsed + * @param delimiterBeans Delimiter between beans in the resulting string + * @param delimiterProperties Delimiter between properties in the resulting string + * @param accessType Access type + * @param pathsToProperties Paths to properties to display + * @return Bean display + */ + public static String beanListToString(List<? extends Object> beansList, String delimiterBeans, + String delimiterProperties, AccessType accessType, String... pathsToProperties) { + AssertTools.assertNotNull(beansList); + AssertTools.assertNotEmpty(delimiterProperties); + AssertTools.assertNotEmpty(delimiterBeans); + AssertTools.assertNotNull(accessType); + StringBuilder builder = new StringBuilder(); + Iterator<? extends Object> itBeans = beansList.iterator(); + while (itBeans.hasNext()) { + Object bean = itBeans.next(); + builder.append(toString(bean, delimiterProperties, accessType, pathsToProperties)); + if (itBeans.hasNext()) { + builder.append(delimiterBeans); + } + } + return builder.toString(); + } + + /** + * Wrapping of Apache communs BeanComparator. Create a comparator which compares two beans by the specified bean + * property. Property expression can use Apache's nested, indexed, combinated, mapped syntax. @see <a + * href="http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/BeanComparator.html">Apache's Bean + * Comparator</a> for more details. + * @param <T> generic type + * @param propertyExpression propertyExpression + * @return the comparator + */ + @SuppressWarnings("unchecked") + public static <T> Comparator<T> createPropertyComparator(final String propertyExpression) { + return new BeanComparator(propertyExpression); + } + + /** + * Wrapping of Apache communs BeanComparator to avoid "unchecked" tag in code. Create a comparator which compares + * two beans by the specified bean property. Property expression can use Apache's nested, indexed, combinated, + * mapped syntax. @see <a + * href="http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/BeanComparator.html">Apache's Bean + * Comparator</a> for more details. + * @param <T> generic type + * @param propertyExpression PropertyExpression + * @param comparator BeanComparator will pass the values of the specified bean property to this Comparator. If your + * bean property is not a comparable or contains null values, a suitable comparator may be supplied in this + * constructor + * @return the Comparator being used to compare beans + */ + @SuppressWarnings("unchecked") + public static <T> Comparator<T> createPropertyComparator(final String propertyExpression, Comparator<T> comparator) { + return new BeanComparator(propertyExpression, comparator); + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CantharellaConfig.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CantharellaConfig.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CantharellaConfig.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CantharellaConfig.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,66 @@ +package nc.ird.cantharella.utils; + +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import java.util.Properties; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; + + +/** + * Used as factory in spring configuration to get configuration file as properties + * this class use internaly {@link ApplicationConfig}. + * + * @author poussin + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +public class CantharellaConfig { + + /** + * force filename to cantharella.config + * @return + * @throws ArgumentsParserException + */ + static public Properties getProperties() throws ArgumentsParserException { + return getProperties("cantharella.conf"); + } + + /** + * This method take file name in argument, this permit to force filename for + * example for unit tests + * + * @param filename filename to used + * @return + * @throws ArgumentsParserException + */ + static public Properties getProperties(String filename) throws ArgumentsParserException { + ApplicationConfig config = new ApplicationConfig(filename); + config.parse(); + Properties result = config.getFlatOptions(); + return result; + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CaptchaTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CaptchaTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CaptchaTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CaptchaTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,54 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import org.apache.commons.lang3.RandomStringUtils; + +/** + * Tools for captchas + * @author Mickael Tricot + */ +public final class CaptchaTools { + + /** Captcha max length */ + public static final int CAPTCHA_LENGTH_MAX = 6; + + /** Captcha min length */ + public static final int CAPTCHA_LENGTH_MIN = 3; + + /** + * Generate a random numeric catpcha + * @return Captcha + */ + public static String random() { + return RandomStringUtils + .randomNumeric((int) (Math.random() * (CAPTCHA_LENGTH_MAX - CAPTCHA_LENGTH_MIN) + CAPTCHA_LENGTH_MIN)); + } + + /** + * Constructor (prevents from instantiation) + */ + private CaptchaTools() { + // + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CollectionTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CollectionTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CollectionTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CollectionTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,244 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import nc.ird.cantharella.utils.BeanTools.AccessType; + +import org.apache.commons.lang3.ObjectUtils; + +/** + * Tools for collections + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class CollectionTools { + + /** + * Test if all collection's values contain always the same value + * @param <T> Collection type + * @param collection Collection to parse + * @param value Value which is tested for the identity (may be null) + * @return The answer + */ + public static <T> boolean containsOnlySameValue(Collection<T> collection, T value) { + AssertTools.assertNotNull(collection); + + if (collection.isEmpty()) { + return false; + } + + boolean hasSame = true; + Iterator<T> itCol = collection.iterator(); + while (hasSame && itCol.hasNext()) { + T curVal = itCol.next(); + if (!ObjectUtils.equals(curVal, value)) { + hasSame = false; + } + } + return hasSame; + } + + /** + * Intersection of two sets + * @param <T> Set type + * @param s1 Set 1 + * @param s2 Set 2 + * @return Intersection + */ + public static <T> Set<T> intersect(Set<T> s1, Set<T> s2) { + Set<T> intersect = s1 == null ? new HashSet<T>() : new HashSet<T>(s1); + intersect.retainAll(s2); + return intersect; + } + + /** + * Setter for collections, preserving the instance + * @param <T> Collection type + * @param collectionToWrite Collection to write + * @param collectionToRead Collection to read + */ + public static <T> void setter(Collection<T> collectionToWrite, Collection<T> collectionToRead) { + AssertTools.assertNotNull(collectionToWrite); + collectionToWrite.clear(); + if (collectionToRead != null) { + collectionToWrite.addAll(collectionToRead); + } + } + + /** + * Check in a collection of beans if a property has a specific value + * @param collection The collection to parse + * @param pathToProperty The path to the tested bean property (for each bean in the collection), example : + * beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @param value The value to find + * @return true if the value is found, otherwise false + */ + public static boolean containsWithValue(Collection<? extends Object> collection, String pathToProperty, + AccessType accessType, Object value) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + for (Object curBean : collection) { + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + if (curVal.equals(value)) { + return true; + } + } + return false; + } + + /** + * Count in a collection of beans the number of beans which have a specific value + * @param collection The collection to parse + * @param pathToProperty The path to the tested bean property, example : beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @param value The value to find + * @return The count result + */ + public static int countWithValue(Collection<? extends Object> collection, String pathToProperty, + AccessType accessType, Object value) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + int count = 0; + for (Object curBean : collection) { + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + if (value.equals(curVal)) { + count++; + } + } + return count; + } + + /** + * Get from a beans collection the first bean which have a property with a specific value. If the value is not + * found, return null + * @param <T> The beans class in the collection + * @param collection The collection to parse + * @param pathToProperty The path to the tested bean property, example : beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @param value The value to find + * @return The bean with the specific value, null if not found + */ + public static <T extends Object> T findWithValue(List<T> collection, String pathToProperty, AccessType accessType, + Object value) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + for (T curBean : collection) { + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + if (value.equals(curVal)) { + return curBean; + } + } + return null; + } + + /** + * Remove in a collection of beans the beans which have a specific value. If the value is found, remove it and + * return true. + * @param collection The collection to parse + * @param pathToProperty The path to the tested bean property, example : beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @param value The value to find + * @return true if found, false otherwise + */ + public static boolean removeWithValue(Collection<? extends Object> collection, String pathToProperty, + AccessType accessType, Object value) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + boolean hasDeleted = false; + + Iterator<? extends Object> itList = collection.iterator(); + while (itList.hasNext()) { + Object curBean = itList.next(); + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + if (value.equals(curVal)) { + itList.remove(); + hasDeleted = true; + } + } + return hasDeleted; + } + + /** + * Remove in a collection of beans the beans which have a specifics values. If on these values are found, remove + * them and return true. + * @param collection The collection to parse + * @param pathToProperty The path to the tested bean property, example : beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @param values The values to find + * @return true if at least one value is found, false otherwise + */ + public static boolean removeAllWithValue(Collection<? extends Object> collection, String pathToProperty, + AccessType accessType, Collection<? extends Object> values) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + boolean hasDeleted = false; + + Iterator<? extends Object> itList = collection.iterator(); + while (itList.hasNext()) { + Object curBean = itList.next(); + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + if (curVal != null && values.contains(curVal)) { + itList.remove(); + hasDeleted = true; + } + } + return hasDeleted; + } + + /** + * Build a list from values properties of a bean list. Ex : From a beans list which contains the property "name", + * you can build the list of these names. + * @param collection The beans list to parse + * @param pathToProperty The path to the bean property, example : beanX.beanY.propZ + * @param accessType The access type to reach each property value + * @return These values + */ + public static List<Object> valuesFromList(Collection<? extends Object> collection, String pathToProperty, + AccessType accessType) { + AssertTools.assertNotNull(collection); + AssertTools.assertNotEmpty(pathToProperty); + + List<Object> values = new ArrayList<Object>(); + for (Object curBean : collection) { + Object curVal = BeanTools.getValueFromPath(curBean, accessType, pathToProperty); + values.add(curVal); + } + return values; + } + + /** + * Constructor (prevents instantiation) + */ + private CollectionTools() { + // + } + +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CoordTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CoordTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CoordTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/CoordTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,356 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.math.BigDecimal; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; + +/** + * Tools for coordonates + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class CoordTools { + + /** Degrees character */ + public static final char DEGREES = '°'; + + /** Latitude length */ + public static final int LATITUDE_LENGTH = 11; + + /** Latitude max degrees */ + public static final int LATITUDE_MAX_DEGREES = 90; + + /** Latitude max minutes */ + public static final String LATITUDE_MAX_MINUTES_STRING = "59.999"; + + /** Latitude max minutes */ + public static final BigDecimal LATITUDE_MAX_MINUTES = new BigDecimal(LATITUDE_MAX_MINUTES_STRING); + + /** Latitude min degrees */ + public static final int LATITUDE_MIN_DEGREES = 0; + + /** Latitude min minutes */ + public static final String LATITUDE_MIN_MINUTES_STRING = "00.000"; + + /** Latitude min minutes */ + public static final BigDecimal LATITUDE_MIN_MINUTES = new BigDecimal(LATITUDE_MIN_MINUTES_STRING); + + /** Latitude orientations */ + public static final Character[] LATITUDE_ORIENTATIONS = { 'N', 'S' }; + + /** Latitude pattern */ + private static final Pattern LATITUDE_PATTERN; + + /** Longitude length */ + public static final int LONGITUDE_LENGTH = 12; + + /** Longitude max degrees */ + public static final int LONGITUDE_MAX_DEGREES = 180; + + /** Longitude max minutes */ + public static final String LONGITUDE_MAX_MINUTES_STRING = "59.999"; + + /** Longitude max minutes */ + public static final BigDecimal LONGITUDE_MAX_MINUTES = new BigDecimal(LONGITUDE_MAX_MINUTES_STRING); + + /** Longitude min degrees */ + public static final int LONGITUDE_MIN_DEGREES = 0; + + /** Longitude min minutes */ + public static final String LONGITUDE_MIN_MINUTES_STRING = "00.000"; + + /** Longitude min minutes */ + public static final BigDecimal LONGITUDE_MIN_MINUTES = new BigDecimal(LONGITUDE_MIN_MINUTES_STRING); + + /** Longitude orientations */ + public static final Character[] LONGITUDE_ORIENTATIONS = { 'E', 'W' }; + + /** Longitude pattern */ + private static final Pattern LONGITUDE_PATTERN; + + /** Minutes character */ + public static final char MINUTES = '\''; + + /** Minutes blank */ + private static final char MINUTES_BLANK = '0'; + + /** Minutes decimal length */ + private static final int MINUTES_DECIMAL_LENGTH; + + /** Minutes integer length */ + private static final int MINUTES_INTEGER_LENGTH; + + /** Minutes separator */ + public static final char MINUTES_SEPARATOR = '.'; + + /** Minutes separator */ + private static final String MINUTES_SEPARATOR_PATTERN = "\\."; + + static { + String[] md = LONGITUDE_MAX_MINUTES_STRING.split(MINUTES_SEPARATOR_PATTERN); + + MINUTES_INTEGER_LENGTH = md[0].length(); + MINUTES_DECIMAL_LENGTH = md[1].length(); + + String patternMinutes = "[0-9]"; + String patternDegrees = "[ 0-9]"; + + StringBuilder pattern = new StringBuilder("^("); + for (int i = 0; i < String.valueOf(LATITUDE_MAX_DEGREES).length(); ++i) { + pattern.append(patternDegrees); + } + pattern.append(')'); + pattern.append(DEGREES); + pattern.append('('); + for (int i = 0; i < MINUTES_INTEGER_LENGTH; ++i) { + pattern.append(patternMinutes); + } + pattern.append(")"); + pattern.append(MINUTES_SEPARATOR_PATTERN); + pattern.append('('); + for (int i = 0; i < MINUTES_DECIMAL_LENGTH; ++i) { + pattern.append(patternMinutes); + } + pattern.append(')'); + pattern.append(MINUTES); + pattern.append("(["); + for (char o : LATITUDE_ORIENTATIONS) { + pattern.append(o); + } + pattern.append("])$"); + LATITUDE_PATTERN = Pattern.compile(pattern.toString()); + + pattern = new StringBuilder("^("); + for (int i = 0; i < String.valueOf(LONGITUDE_MAX_DEGREES).length(); ++i) { + pattern.append(patternDegrees); + } + pattern.append(')'); + pattern.append(DEGREES); + pattern.append('('); + for (int i = 0; i < MINUTES_INTEGER_LENGTH; ++i) { + pattern.append(patternMinutes); + } + pattern.append(")"); + pattern.append(MINUTES_SEPARATOR_PATTERN); + pattern.append('('); + for (int i = 0; i < MINUTES_DECIMAL_LENGTH; ++i) { + pattern.append(patternMinutes); + } + pattern.append(')'); + pattern.append(MINUTES); + pattern.append("(["); + for (char o : LONGITUDE_ORIENTATIONS) { + pattern.append(o); + } + pattern.append("])$"); + + LONGITUDE_PATTERN = Pattern.compile(pattern.toString()); + } + + /** + * Format a latitude (dd.mm.sss"o) + * @param d Degrees (0-90) + * @param m Minutes (00.000-59.999) + * @param o Orientation (N-S) + * @return Latitude + */ + public static String latitude(Integer d, BigDecimal m, Character o) { + // Check values + AssertTools.assertGreaterOrEquals(d, LATITUDE_MIN_DEGREES); + AssertTools.assertLowerOrEquals(d, LATITUDE_MAX_DEGREES); + AssertTools.assertGreaterOrEquals(m, LATITUDE_MIN_MINUTES); + AssertTools.assertLowerOrEquals(m, LATITUDE_MAX_MINUTES); + AssertTools.assertIn(Character.toUpperCase(o), LATITUDE_ORIENTATIONS); + // Format values + // LOG.debug(m); + // LOG.debug(NumberTools.doubleToString(m, Locale.ENGLISH, MINUTES_DECIMAL_LENGTH, MINUTES_DECIMAL_LENGTH)); + String[] md = NumberTools.bigDecimalToString(m, Locale.ENGLISH, MINUTES_DECIMAL_LENGTH, MINUTES_DECIMAL_LENGTH, + 2).split(MINUTES_SEPARATOR_PATTERN); + // LOG.debug(md); + return StringUtils.leftPad(String.valueOf(d), String.valueOf(LATITUDE_MAX_DEGREES).length()) + DEGREES + + StringUtils.leftPad(String.valueOf(md[0]), MINUTES_INTEGER_LENGTH, MINUTES_BLANK) + MINUTES_SEPARATOR + + StringUtils.rightPad(md[1], MINUTES_DECIMAL_LENGTH, MINUTES_BLANK) + MINUTES + + Character.toUpperCase(o); + } + + /** + * Retrieve the degrees from a complete latitude + * @param latitude Latitude + * @return Degrees + */ + public static Integer latitudeDegrees(String latitude) { + if (StringUtils.isEmpty(latitude)) { + return null; + } + Matcher matcher = LATITUDE_PATTERN.matcher(latitude); + matcher.lookingAt(); + return Integer.valueOf(matcher.group(1).trim()); + } + + /** + * Retrieve the minutes from a complete latitude + * @param latitude Latitude + * @return Minutes + */ + public static BigDecimal latitudeMinutes(String latitude) { + if (StringUtils.isEmpty(latitude)) { + return null; + } + Matcher matcher = LATITUDE_PATTERN.matcher(latitude); + matcher.lookingAt(); + return NumberTools.parseBigDecimal(matcher.group(2) + MINUTES_SEPARATOR + matcher.group(3), Locale.ENGLISH, + MINUTES_DECIMAL_LENGTH, 2); + } + + /** + * Retrieve the orientation from a complete latitude + * @param latitude Latitude + * @return Orientation + */ + public static Character latitudeOrientation(String latitude) { + if (StringUtils.isEmpty(latitude)) { + return null; + } + Matcher matcher = LATITUDE_PATTERN.matcher(latitude); + matcher.lookingAt(); + return Character.valueOf(matcher.group(4).charAt(0)); + } + + /** + * Format a longitude (ddd.mm'ss"o) + * @param d Degrees (0-180) + * @param m Minutes (00.000-59.999) + * @param o Orientation (E-W) + * @return Longitude + */ + public static String longitude(Integer d, BigDecimal m, Character o) { + // Check values + AssertTools.assertGreaterOrEquals(d, LONGITUDE_MIN_DEGREES); + AssertTools.assertLowerOrEquals(d, LONGITUDE_MAX_DEGREES); + AssertTools.assertGreaterOrEquals(m, LONGITUDE_MIN_MINUTES); + AssertTools.assertLowerOrEquals(m, LONGITUDE_MAX_MINUTES); + AssertTools.assertIn(Character.toUpperCase(o), LONGITUDE_ORIENTATIONS); + // Format values + String[] md = NumberTools.bigDecimalToString(m, Locale.ENGLISH, MINUTES_DECIMAL_LENGTH, MINUTES_DECIMAL_LENGTH, + 3).split(MINUTES_SEPARATOR_PATTERN); + return StringUtils.leftPad(String.valueOf(d), String.valueOf(LONGITUDE_MAX_DEGREES).length()) + DEGREES + + StringUtils.leftPad(String.valueOf(md[0]), MINUTES_INTEGER_LENGTH, MINUTES_BLANK) + MINUTES_SEPARATOR + + StringUtils.rightPad(md[1], MINUTES_DECIMAL_LENGTH, MINUTES_BLANK) + MINUTES + + Character.toUpperCase(o); + } + + /** + * Retrieve the degrees from a complete longitude + * @param longitude Longitude + * @return Degrees + */ + public static Integer longitudeDegrees(String longitude) { + if (StringUtils.isEmpty(longitude)) { + return null; + } + Matcher matcher = LONGITUDE_PATTERN.matcher(longitude); + matcher.lookingAt(); + return Integer.valueOf(matcher.group(1).trim()); + } + + /** + * Retrieve the minutes from a complete longitude + * @param longitude Longitude + * @return Minutes + */ + public static BigDecimal longitudeMinutes(String longitude) { + if (StringUtils.isEmpty(longitude)) { + return null; + } + Matcher matcher = LONGITUDE_PATTERN.matcher(longitude); + matcher.lookingAt(); + return NumberTools.parseBigDecimal(matcher.group(2) + MINUTES_SEPARATOR + matcher.group(3), Locale.ENGLISH, + MINUTES_DECIMAL_LENGTH, 3); + } + + /** + * Retrieve the orientation from a complete longitude + * @param longitude Longitude + * @return Orientation + */ + public static Character longitudeOrientation(String longitude) { + if (StringUtils.isEmpty(longitude)) { + return null; + } + Matcher matcher = LONGITUDE_PATTERN.matcher(longitude); + matcher.lookingAt(); + return Character.valueOf(matcher.group(4).charAt(0)); + } + + /** + * Validate a latitude (ddd.mm.sss"o) + * @param latitude Latitude + * @return TRUE if the latitude is valid + */ + public static boolean validateLatitude(String latitude) { + AssertTools.assertNotEmpty(latitude); + + Matcher matcher = LATITUDE_PATTERN.matcher(latitude); + if (matcher.lookingAt()) { + int d = Integer.valueOf(matcher.group(1).trim()); + BigDecimal m = NumberTools.parseBigDecimal(matcher.group(2) + MINUTES_SEPARATOR + matcher.group(3), + Locale.ENGLISH, MINUTES_DECIMAL_LENGTH, 2); + // if the latitude is 90 with others minutes, return false + return d >= LATITUDE_MIN_DEGREES && d <= LATITUDE_MAX_DEGREES && LATITUDE_MIN_MINUTES.compareTo(m) <= 0 + && LATITUDE_MAX_MINUTES.compareTo(m) >= 0 && (d != 90 || new BigDecimal("0.000").compareTo(m) == 0); + } + return false; + } + + /** + * Validate a longitude (dd.mm.sss"o) + * @param longitude Longitude + * @return TRUE if the longitude is valid + */ + public static boolean validateLongitude(String longitude) { + AssertTools.assertNotEmpty(longitude); + Matcher matcher = LONGITUDE_PATTERN.matcher(longitude); + if (matcher.lookingAt()) { + int d = Integer.valueOf(matcher.group(1).trim()); + BigDecimal m = NumberTools.parseBigDecimal(matcher.group(2) + MINUTES_SEPARATOR + matcher.group(3), + Locale.ENGLISH, MINUTES_DECIMAL_LENGTH, 3); + // if the longitude is 180 with others minutes, return false + return d >= LONGITUDE_MIN_DEGREES && d <= LONGITUDE_MAX_DEGREES && LONGITUDE_MIN_MINUTES.compareTo(m) <= 0 + && LATITUDE_MAX_MINUTES.compareTo(m) >= 0 + && (d != 180 || new BigDecimal("0.000").compareTo(m) == 0); + } + return false; + } + + /** + * Constructor + */ + private CoordTools() { + // + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenerateCsv.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/GenerateCsv.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenerateCsv.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenerateCsv.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,164 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.List; + +import au.com.bytecode.opencsv.CSVWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Classe permettant de générer un fichier csv + * @author Adrien Cheype + */ +public class GenerateCsv { + + /** + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(GenerateCsv.class); + + /** delimiter de colonne */ + private char columnsSeparator; + /** Copyright, pour Ird par défaut */ + private String copyright; + /** Encoding utilisé pour le CSV */ + private String encoding; + + /** Copyright utilisé par défaut, pour l'IRD en français */ + private final static String DEFAULT_COPYRIGHT = "©IRD tous droits réservés"; + + /** static varable for UTF-8 encoding */ + public static final String CHARSET_UTF_8 ="UTF-8"; + + /** static varable for ISO_8859_1 encoding */ + public static final String CHARSET_ISO_8859_1 ="ISO-8859-1"; + + /** + * Constructeur par défaut + */ + public GenerateCsv(){ + this(';',CHARSET_UTF_8); + } + + /** + * Constructeur + * @param encoding utilisé pour le CSV + */ + public GenerateCsv(String encoding){ + this(';',encoding); + } + + /** + * Constructeur + * + * @param columnsSeparator caractère utilisé comme délimiteur de colonne + * @param encoding utilisé pour le CSV + */ + public GenerateCsv(char columnsSeparator, String encoding){ + setColumnsSeparator(columnsSeparator); + setEncoding(encoding); + setCopyright(DEFAULT_COPYRIGHT); + } + + /** + * Rend un flux qui décrit un ensemble de données en respectant le format CSV + * + * @param data données à écrire + * @param withCopyright si vrai, un copyright est ajouté à la dernière ligne + * @return le flux de donnée en sortie + * @throws IOException exception parvenue dans les traitements entrée/sortie du fichier + */ + public ByteArrayOutputStream writeCSV(List<String[]> data, boolean withCopyright) throws IOException{ + + ByteArrayOutputStream csvStream = new ByteArrayOutputStream(); + OutputStreamWriter outWriter = new OutputStreamWriter(csvStream, encoding); + + CSVWriter csvWriter = new CSVWriter(outWriter, this.getColumnsSeparator()); + // paramétrage de l'écriture du CSV + + //écriture des données + csvWriter.writeAll(data); + if (withCopyright){ + //écriture du copyright + csvWriter.writeNext(new String[]{getCopyright()}); + } + csvWriter.close(); + LOG.debug("data written in the CSV stream"); + + return csvStream; + } + + /** + * copyright getter + * @return copyright + */ + public String getCopyright() { + return copyright; + } + + /** + * copyright setter + * @param copyright copyright + */ + public void setCopyright(String copyright) { + this.copyright = copyright; + } + + /** + * columnsSeparator getter + * @return columnsSeparator + */ + public char getColumnsSeparator() { + return columnsSeparator; + } + + /** + * columnsSeparator setter + * @param columnsSeparator columnsSeparator + */ + public void setColumnsSeparator(char columnsSeparator) { + this.columnsSeparator = columnsSeparator; + } + + /** + * encoding getter + * @return encoding + */ + public String getEncoding() { + return encoding; + } + + /** + * encoding setter + * @param encoding encoding + */ + public void setEncoding(String encoding) { + this.encoding = encoding; + } + +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenericsTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/GenericsTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenericsTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/GenericsTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,50 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +/** + * Tools for generics classes + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class GenericsTools { + + /** + * Object cast + * @param <I> Input type + * @param <O> Output type + * @param i Input object + * @return Output object + */ + @SuppressWarnings("unchecked") + public static <I, O extends I> O cast(I i) { + return (O) i; + } + + /** + * Constructor (prevents instantiation) + */ + private GenericsTools() { + // + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/IntuitiveStringComparator.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/IntuitiveStringComparator.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/IntuitiveStringComparator.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/IntuitiveStringComparator.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,170 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.util.Comparator; + +/** + * <p> + * A comparator that emulates the "intuitive" sorting used by Windows Explorer. The rules are as follows: + * </p> + * <ul> + * <li>Any sequence of one or more digits is treated as an atomic unit, a number. When these number units are matched + * up, they're compared according to their respective numeric values. If they're numerically equal, but one has more + * leading zeroes than the other, the longer sequence is considered larger.</li> + * <li>Numbers always sort before any other kind of character.</li> + * <li>Spaces and all punctuation characters always sort before letters.</li> + * <li>Letters are sorted case-insensitively.</li> + * </ul> + * <p> + * Explorer's sort order for punctuation characters is not quite the same as their ASCII order. Also, some characters + * aren't allowed in file names, so I don't know how they would be sorted. This class just sorts them all according to + * their ASCII values. + * </p> + * <p> + * This comparator is only guaranteed to work with 7-bit ASCII strings. + * </p> + * @author Alan Moore + * @param <T> generic type + */ +public class IntuitiveStringComparator<T extends CharSequence> implements Comparator<T> { + + /** string 1 */ + private T str1; + + /** string 2 */ + private T str2; + + /** posistion 1 */ + private int pos1; + + /** position 2 */ + private int pos2; + + /** lenght 1 */ + private int len1; + + /** length 2 */ + private int len2; + + /** {@inheritDoc} */ + @Override + public int compare(T s1, T s2) { + str1 = s1; + str2 = s2; + len1 = str1.length(); + len2 = str2.length(); + pos1 = pos2 = 0; + + if (len1 == 0) { + return len2 == 0 ? 0 : -1; + } else if (len2 == 0) { + return 1; + } + + while (pos1 < len1 && pos2 < len2) { + char ch1 = str1.charAt(pos1); + char ch2 = str2.charAt(pos2); + int result = 0; + + if (Character.isDigit(ch1)) { + result = Character.isDigit(ch2) ? compareNumbers() : -1; + } else if (Character.isLetter(ch1)) { + result = Character.isLetter(ch2) ? compareOther(true) : 1; + } else { + result = Character.isDigit(ch2) ? 1 : Character.isLetter(ch2) ? -1 : compareOther(false); + } + + if (result != 0) { + return result; + } + } + + return len1 - len2; + } + + /** + * Compare numbers + * @return the integer response + */ + private int compareNumbers() { + int delta = 0; + int zeroes1 = 0, zeroes2 = 0; + char ch1 = (char) 0, ch2 = (char) 0; + + // Skip leading zeroes, but keep a count of them. + while (pos1 < len1 && (ch1 = str1.charAt(pos1++)) == '0') { + zeroes1++; + } + while (pos2 < len2 && (ch2 = str2.charAt(pos2++)) == '0') { + zeroes2++; + } + + // If one sequence contains more significant digits than the + // other, it's a larger number. In case they turn out to have + // equal lengths, we compare digits at each position; the first + // unequal pair determines which is the bigger number. + while (true) { + boolean noMoreDigits1 = (ch1 == 0) || !Character.isDigit(ch1); + boolean noMoreDigits2 = (ch2 == 0) || !Character.isDigit(ch2); + + if (noMoreDigits1 && noMoreDigits2) { + return delta != 0 ? delta : zeroes1 - zeroes2; + } else if (noMoreDigits1) { + return -1; + } else if (noMoreDigits2) { + return 1; + } else if (delta == 0 && ch1 != ch2) { + delta = ch1 - ch2; + } + + ch1 = pos1 < len1 ? str1.charAt(pos1++) : (char) 0; + ch2 = pos2 < len2 ? str2.charAt(pos2++) : (char) 0; + } + } + + /** + * Compare other characters + * @param isLetters true if characters are letters + * @return the integer response + */ + private int compareOther(boolean isLetters) { + char ch1 = str1.charAt(pos1++); + char ch2 = str2.charAt(pos2++); + + if (ch1 == ch2) { + return 0; + } + + if (isLetters) { + ch1 = Character.toUpperCase(ch1); + ch2 = Character.toUpperCase(ch2); + if (ch1 != ch2) { + ch1 = Character.toLowerCase(ch1); + ch2 = Character.toLowerCase(ch2); + } + } + + return ch1 - ch2; + } +} \ No newline at end of file Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/NumberTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/NumberTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/NumberTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/NumberTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,188 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.Locale; + +/** + * Tools for numbers + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class NumberTools { + + /** + * Constructor (prevents instantiation) + */ + private NumberTools() { + // + } + + /** + * Returns null if the value if zero + * @param <N> Number type + * @param n Number value + * @return The value or null if zero + */ + public static <N extends Number> N nullIfZero(N n) { + return n == null || n.doubleValue() == 0D ? null : n; + } + + /** + * Parse a double from a String. If the number is not recognize with locale separator, try with '.' decimal + * separator. + * @param value String value to parse + * @param locale The locale which define the decimal separator + * @param maxFractionDigit The maximum number of digits allowed in the fraction portion + * @return The double rounded according to maxFractionDigit (HALF_UP rounding mode) + */ + public static Double parseDouble(final String value, final Locale locale, final int maxFractionDigit) { + AssertTools.assertNotEmpty(value); + AssertTools.assertNotNull(locale); + + DecimalFormat fmt = (DecimalFormat) DecimalFormat.getNumberInstance(locale); + fmt.setMaximumFractionDigits(maxFractionDigit); + fmt.setRoundingMode(RoundingMode.HALF_UP); + + ParsePosition position = new ParsePosition(0); + Number nb = (Number) fmt.parseObject(value, position); + + if (position.getIndex() != value.length()) { + // second try with '.' for decimal separator + if (value.charAt(position.getIndex()) == '.') { + DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); + symbols.setDecimalSeparator('.'); + fmt.setDecimalFormatSymbols(symbols); + + position = new ParsePosition(0); + nb = (Number) fmt.parseObject(value, position); + if (position.getIndex() != value.length()) { + throw new NumberFormatException("Cannot convert '" + value + + "' to Double. Parse failed at position " + position.getIndex() + "."); + } + } else { + throw new NumberFormatException("Cannot convert '" + value + "' to Double. Parse failed at position " + + position.getIndex() + "."); + } + } + return nb.doubleValue(); + } + + /** + * Parse a big decimal from a String. If the number is not recognize with locale separator, try with '.' decimal + * separator + * @param value String value to parse + * @param locale The locale which define the decimal separator + * @param maxFractionDigit The maximum number of digits allowed in the fraction portion + * @param maxIntegerDigit The maximum number of digits allowed in the integer portion + * @return The big decimal with a specified precision + */ + public static BigDecimal parseBigDecimal(final String value, final Locale locale, final int maxFractionDigit, + final int maxIntegerDigit) { + AssertTools.assertNotEmpty(value); + AssertTools.assertNotNull(locale); + + DecimalFormat fmt = (DecimalFormat) NumberFormat.getNumberInstance(locale); + fmt.setMaximumFractionDigits(maxFractionDigit); + fmt.setMaximumIntegerDigits(maxIntegerDigit); + fmt.setParseBigDecimal(true); + + ParsePosition position = new ParsePosition(0); + BigDecimal bd = (BigDecimal) fmt.parseObject(value, position); + + if (position.getIndex() != value.length()) { + // second try with '.' for decimal separator + if (value.charAt(position.getIndex()) == '.') { + DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); + symbols.setDecimalSeparator('.'); + fmt.setDecimalFormatSymbols(symbols); + + position = new ParsePosition(0); + bd = (BigDecimal) fmt.parseObject(value, position); + if (position.getIndex() != value.length()) { + throw new NumberFormatException("Cannot convert '" + value + + "' to BigDecimal. Parse failed at position " + position.getIndex() + "."); + } + } else { + throw new NumberFormatException("Cannot convert '" + value + + "' to BigDecimal. Parse failed at position " + position.getIndex() + "."); + } + } + + return bd; + } + + /** + * Give the string representation of a double + * @param value The double + * @param locale The locale which define the decimal separator + * @param minFractionDigit the minimum number of digits allowed in the fraction portion + * @param maxFractionDigit The maximum number of digits allowed in the fraction portion + * @return The double rounded according to maxFractionDigit (HALF_UP rounding mode) + */ + public static String doubleToString(final Double value, final Locale locale, final int minFractionDigit, + final int maxFractionDigit) { + AssertTools.assertNotNull(value); + AssertTools.assertNotNull(locale); + + NumberFormat fmt = NumberFormat.getInstance(locale); + if (fmt != null) { + fmt.setMinimumFractionDigits(minFractionDigit); + fmt.setMaximumFractionDigits(maxFractionDigit); + fmt.setRoundingMode(RoundingMode.HALF_UP); + return fmt.format(value); + } + return value.toString(); + } + + /** + * Give the string representation of a big decimal + * @param value The big decimal + * @param locale The locale which define the decimal separator + * @param minFractionDigit the minimum number of digits allowed in the fraction portion + * @param maxFractionDigit The maximum number of digits allowed in the fraction portion + * @param maxIntegerDigit The maximum number of digits allowed in the integer portion + * @return The big decimal with a specified precision + */ + public static String bigDecimalToString(final BigDecimal value, final Locale locale, final int minFractionDigit, + final int maxFractionDigit, final int maxIntegerDigit) { + AssertTools.assertNotNull(value); + AssertTools.assertNotNull(locale); + + NumberFormat fmt = NumberFormat.getInstance(locale); + if (fmt != null) { + fmt.setMinimumFractionDigits(minFractionDigit); + fmt.setMaximumFractionDigits(maxFractionDigit); + fmt.setMaximumIntegerDigits(maxIntegerDigit); + fmt.setRoundingMode(RoundingMode.HALF_UP); + return fmt.format(value); + } + return value.toString(); + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/Pair.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/Pair.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/Pair.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/Pair.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,101 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.io.Serializable; +import java.util.Map.Entry; + +import nc.ird.cantharella.utils.BeanTools.AccessType; + +/** + * Pair of objects + * @author Mickael Tricot + * @param <K> First element type + * @param <V> Second element type + */ +public final class Pair<K, V> implements Entry<K, V>, Serializable { + + /** First element */ + private K key; + + /** Second element */ + private V value; + + /** + * Constructor + */ + public Pair() { + // + } + + /** + * Constructor + * @param key First element + * @param value Second element + */ + public Pair(K key, V value) { + this(); + this.key = key; + this.value = value; + } + + /** @see java.lang.Object#equals(java.lang.Object) */ + @Override + public boolean equals(Object obj) { + return BeanTools.equals(this, obj, AccessType.GETTER, "key", "value"); + } + + /** {@inheritDoc} */ + @Override + public K getKey() { + return key; + } + + /** {@inheritDoc} */ + @Override + public V getValue() { + return value; + } + + /** @see java.lang.Object#hashCode() **/ + @Override + public int hashCode() { + return BeanTools.hashCode(this, getKey(), getValue()); + } + + /** + * key setter + * @param key key + */ + public void setKey(K key) { + this.key = key; + } + + /** {@inheritDoc} */ + @Override + public V setValue(V value) { + V oldValue = this.value; + this.value = value; + return oldValue; + } +} \ No newline at end of file Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/PasswordTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/PasswordTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/PasswordTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/PasswordTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,81 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.RandomStringUtils; + +/** + * Tools for passwords + * @author Mickael Tricot + */ +public final class PasswordTools { + + /** Password MD5 length */ + public static final int MD5_LENGTH = 32; + + /** Password max length */ + public static final int PASSWORD_LENGTH_MAX = 12; + + /** Password min length */ + public static final int PASSWORD_LENGTH_MIN = 5; + + /** Password SHA1 length */ + public static final int SHA1_LENGTH = 40; + + /** + * Hash a password with the MD5 algorithm + * @param password Password + * @return Hashed password + */ + public static String md5(String password) { + AssertTools.assertNotNull(password); + return DigestUtils.md5Hex(password); + } + + /** + * Generate a random password + * @return Password + */ + public static String random() { + return RandomStringUtils + .randomAlphanumeric((int) (Math.random() * (PASSWORD_LENGTH_MAX - PASSWORD_LENGTH_MIN) + PASSWORD_LENGTH_MIN)); + } + + /** + * Hash a password with the SHA-1 algorithm + * @param password Password + * @return Hashed password + */ + public static String sha1(String password) { + AssertTools.assertNotNull(password); + return DigestUtils.sha1Hex(password); + } + + /** + * Constructor (prevents from instantiation) + */ + private PasswordTools() { + // + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTools.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTools.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTools.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTools.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,208 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.io.LineIterator; +import org.apache.commons.lang3.StringUtils; + +/** + * Tools for strings + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class StringTools { + + /** + * Create a string representing a list of couples (key + value) + * @param <O1> Keys type + * @param <O2> Values type + * @param couples Couples (key + value) + * @param separatorKeysValues Separator between keys and values + * @param separatorCouples Separator between couples + * @return String representing the list of couples, or null if empty + */ + public static <O1, O2> String couplesToString(Map<O1, O2> couples, String separatorKeysValues, + String separatorCouples) { + AssertTools.assertNotNull(couples); + AssertTools.assertNotNull(separatorKeysValues); + AssertTools.assertNotNull(separatorCouples); + StringBuilder builder = new StringBuilder(); + for (Entry<O1, O2> entry : couples.entrySet()) { + builder.append(entry.getKey() + separatorKeysValues + entry.getValue() + separatorCouples); + } + return StringUtils.stripToNull(truncate(builder, separatorCouples)); + } + + /** + * Display a list of objects + * @param list The list to browsed + * @param delimiter The delimiter between each object + * @return List display + */ + public static String listToString(List<? extends Object> list, String delimiter) { + AssertTools.assertNotNull(list); + AssertTools.assertNotEmpty(delimiter); + StringBuilder builder = new StringBuilder(); + Iterator<? extends Object> itBeans = list.iterator(); + while (itBeans.hasNext()) { + Object bean = itBeans.next(); + builder.append(bean.toString()); + if (itBeans.hasNext()) { + builder.append(delimiter); + } + } + return builder.toString(); + } + + /** + * Null-safe string length + * @param string String + * @return String length or -1 if null + */ + public static int length(String string) { + return string == null ? -1 : string.length(); + } + + /** + * Create a line iterator, without null or empty lines + * @param string String + * @return Iterator + */ + public static Iterator<String> lineIterator(String string) { + AssertTools.assertNotNull(string); + List<String> lines = new ArrayList<String>(); + for (LineIterator i = new LineIterator(new StringReader(string)); i.hasNext();) { + String line = StringUtils.trimToNull(i.nextLine()); + if (line != null) { + lines.add(line); + } + } + return lines.iterator(); + } + + /** + * Create a line iterator, without null or empty lines + * @param stringBuilder String + * @return Iterator + */ + public static Iterator<String> lineIterator(StringBuilder stringBuilder) { + AssertTools.assertNotNull(stringBuilder); + return lineIterator(stringBuilder.toString()); + } + + /** + * Replace accented characters by their corresponding non-accented characters + * @param string Accented string + * @return Non-accented string + */ + public static String replaceAccents(String string) { + return StringUtils.stripAccents(string); + } + + /** + * Replace consecutive whitespaces by a single whitespace + * @param string String to transform + * @return String transformed + */ + public static String replaceConsecutiveWhitespaces(String string) { + return StringUtils.isEmpty(string) ? string : string.replaceAll("\\p{Space}+", " "); + } + + /** + * Replace consecutive whitespaces by an underscore + * @param string String to transform + * @return String transformed + */ + public static String replaceConsecutiveWhitespacesByUnderscore(String string) { + return StringUtils.isEmpty(string) ? string : string.replaceAll("\\p{Space}+", "_"); + } + + /** + * Replace non alpha characters by a whitespace (accentuated characters are considered as non alpha characters) + * @param string String to transform + * @return String transformed + */ + public static String replaceNonAlpha(String string) { + return StringUtils.isEmpty(string) ? string : string.replaceAll("[^\\p{Alpha}]", " "); + } + + /** + * Truncate a string by the end + * @param toTruncate String to truncate + * @param truncation String to delete + * @return Truncated string (empty if empty, null if null) + */ + public static String truncate(String toTruncate, String truncation) { + AssertTools.assertNotNull(truncation); + String result = toTruncate; + if (!StringUtils.isEmpty(toTruncate) + && toTruncate.length() >= truncation.length() + && truncation.equals(toTruncate.substring(toTruncate.length() - truncation.length(), toTruncate + .length()))) { + result = toTruncate.substring(0, toTruncate.length() - truncation.length()); + } + return result; + } + + /** + * Truncate a string by the end + * @param toTruncate String to truncate + * @param truncation String to delete + * @return Truncated string (empty if empty, null if null) + */ + public static String truncate(StringBuilder toTruncate, String truncation) { + return toTruncate != null ? truncate(toTruncate.toString(), truncation) : null; + } + + /** + * Constructor (prevents from instantiation) + */ + private StringTools() { + // + } + + /** + * Create a comparator according to the toString method + * @param <T> Type + * @return Comparator + */ + public static <T> Comparator<T> createStringComparator() { + return new Comparator<T>() { + @Override + public int compare(T t1, T t2) { + String t1String = t1 == null ? "" : t1.toString(); + String t2String = t2 == null ? "" : t2.toString(); + + return t1String.compareTo(t2String); + } + }; + } +} Copied: trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTransformer.java (from rev 116, trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTransformer.java) =================================================================== --- trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTransformer.java (rev 0) +++ trunk/cantharella.utils/src/main/java/nc/ird/cantharella/utils/StringTransformer.java 2013-02-18 00:07:41 UTC (rev 118) @@ -0,0 +1,150 @@ +/* + * #%L + * Cantharella :: Utils + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.utils; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.WordUtils; + +/** + * String transformer, chained, null-safe + * @author Mickael Tricot + */ +public final class StringTransformer { + + /** String to transform */ + private String string; + + /** + * Constructor + * @param string String to transform + */ + public StringTransformer(String string) { + this.string = string; + } + + /** + * Capitalize + * @return this + * @see WordUtils + */ + public StringTransformer capitalize() { + string = StringUtils.isEmpty(string) ? string : WordUtils.capitalize(string); + return this; + } + + /** + * Capitalize fully + * @return this + * @see WordUtils + */ + public StringTransformer capitalizeFully() { + string = StringUtils.isEmpty(string) ? string : WordUtils.capitalizeFully(string); + return this; + } + + /** + * Replace accents + * @return this + * @see StringTools + */ + public StringTransformer replaceAccents() { + string = StringUtils.isEmpty(string) ? string : StringTools.replaceAccents(string); + return this; + } + + /** + * Replace consecutive whitespaces + * @return this + * @see StringTools + */ + public StringTransformer replaceConsecutiveWhitespaces() { + string = StringUtils.isEmpty(string) ? string : StringTools.replaceConsecutiveWhitespaces(string); + return this; + } + + /** + * Replace consecutive whitespaces by an underscore + * @return this + * @see StringTools + */ + public StringTransformer replaceConsecutiveWhitespacesByUnderscore() { + string = StringUtils.isEmpty(string) ? string : StringTools.replaceConsecutiveWhitespacesByUnderscore(string); + return this; + } + + /** + * Replace non alpha + * @return this + * @see StringTools + */ + public StringTransformer replaceNonAlpha() { + string = StringUtils.isEmpty(string) ? string : StringTools.replaceNonAlpha(string); + return this; + } + + /** + * To lower case + * @return this + * @see String + */ + public StringTransformer toLowerCase() { + string = StringUtils.isEmpty(string) ? string : string.toLowerCase(); + return this; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return string; + } + + /** + * To upper case + * @return this + * @see String + */ + public StringTransformer toUpperCase() { + string = StringUtils.isEmpty(string) ? string : string.toUpperCase(); + return this; + } + + /** + * Trim + * @return this + * @see String + */ + public StringTransformer trim() { + string = StringUtils.isEmpty(string) ? string : string.trim(); + return this; + } + + /** + * Trim to null + * @return this + * @see StringUtils + */ + public StringTransformer trimToNull() { + string = string == null ? null : StringUtils.trimToNull(string); + return this; + } +} Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/AssertToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/AssertToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/AssertToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.AssertTools; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanLookupTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanLookupTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanLookupTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,7 +22,8 @@ */ package nc.ird.module.utils; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanLookup; +import nc.ird.cantharella.utils.BeanTools.AccessType; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/BeanToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,11 +22,12 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.BeanTools; import java.lang.reflect.Field; import javax.annotation.Resource; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanTools.AccessType; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CaptchaToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CaptchaToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CaptchaToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.CaptchaTools; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CollectionToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CollectionToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CollectionToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,8 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.StringTools; +import nc.ird.cantharella.utils.CollectionTools; import java.util.AbstractList; import java.util.ArrayList; import java.util.Arrays; @@ -31,7 +33,7 @@ import java.util.List; import java.util.Set; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanTools.AccessType; import nc.ird.module.utils.BeanToolsTest.Bean1; import nc.ird.module.utils.BeanToolsTest.Bean2; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CoordToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CoordToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/CoordToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.CoordTools; import java.math.BigDecimal; import org.junit.Assert; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/GenericsToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/GenericsToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/GenericsToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.GenericsTools; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/NumberToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/NumberToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/NumberToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.NumberTools; import java.math.BigDecimal; import java.math.BigInteger; import java.util.concurrent.atomic.AtomicInteger; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PairTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PairTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PairTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.Pair; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PasswordToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PasswordToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/PasswordToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.PasswordTools; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringToolsTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringToolsTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringToolsTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.StringTools; import java.util.HashMap; import java.util.Iterator; import java.util.Map; Modified: trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringTransformerTest.java =================================================================== --- trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringTransformerTest.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.utils/src/test/java/nc/ird/module/utils/StringTransformerTest.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,6 +22,7 @@ */ package nc.ird.module.utils; +import nc.ird.cantharella.utils.StringTransformer; import org.junit.Assert; import org.junit.Test; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -21,7 +21,7 @@ * #L% */ package nc.ird.cantharella.web.config; - + import java.math.BigDecimal; import nc.ird.cantharella.data.config.DataContext; @@ -72,7 +72,7 @@ import nc.ird.cantharella.web.utils.converters.DoubleConverterImpl; import nc.ird.cantharella.web.utils.security.AuthSession; import nc.ird.cantharella.web.utils.security.AuthStrategy; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.wicket.ConverterLocator; import org.apache.wicket.IConverterLocator; @@ -99,293 +99,293 @@ import org.apache.wicket.util.time.Duration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -/** - * Web application - * @author Mickael Tricot - * @author Adrien Cheype - */ -public final class WebApplicationImpl extends WebApplication { - - /** Logger */ + +/** + * Web application + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class WebApplicationImpl extends WebApplication { + + /** Logger */ private static final Logger LOG = LoggerFactory.getLogger(WebApplicationImpl.class); - - /** - * SpringBeans injector (some objects such as Pages are automatically injected, by not all of them) - * @param object Object to be injected - */ - public static void injectSpringBeans(Object object) { - Injector.get().inject(object); - } - - /** Debug mode */ - private final boolean debug; - - /** Internationalization messages */ - private final IStringResourceLoader[] messages; - - /** Optimize mode */ - private final boolean optimize; - - /** Service: personne */ - @SpringBean - private PersonneService personneService; - - /** Wicket configuration (Application.DEVELOPMENT or Application.DEPLOYMENT) */ - private final RuntimeConfigurationType wicketConfiguration; - - /** - * Constructor - * @param debug Debug mode - * @param optimize Optimize mode - * @param wicketConfiguration Wicket configuration (DEVELOPMENT or DEPLOYMENT) - * @param messages Internationalization messages - */ - public WebApplicationImpl(boolean debug, boolean optimize, RuntimeConfigurationType wicketConfiguration, - IStringResourceLoader... messages) { - AssertTools.assertArrayNotNull(messages); - this.debug = debug; - this.optimize = optimize; - this.wicketConfiguration = wicketConfiguration; - this.messages = messages; - } - - /** {@inheritDoc} */ - @Override - public RuntimeConfigurationType getConfigurationType() { - return wicketConfiguration; - } - - /** {@inheritDoc} */ - @Override - public Class<HomePage> getHomePage() { - return HomePage.class; - } - - /** {@inheritDoc} */ - @Override - protected void init() { - super.init(); - getComponentInstantiationListeners().add(new SpringComponentInjector(this)); - injectSpringBeans(this); - try { - personneService.checkOrCreateAdmin(); - } catch (DataConstraintException e) { - LOG.error(e.getMessage(), e); - throw new UnexpectedException(e); - } - setApplicationSettings(); - setDebugSettings(); - setExceptionSettings(); - setFrameworkSettings(); - setMarkupSettings(); - setPageSettings(); - setRequestCycleSettings(); - setRequestLoggerSettings(); - setResourceSettings(); - setSecuritySettings(); - mountUrls(); - } - - /** {@inheritDoc} */ - @Override - protected IConverterLocator newConverterLocator() { - ConverterLocator converterLocator = (ConverterLocator) super.newConverterLocator(); - converterLocator.set(Double.class, DoubleConverterImpl.INSTANCE); - converterLocator.set(BigDecimal.class, BigDecimalConverterImpl.INSTANCE); - return converterLocator; - } - - /** {@inheritDoc} */ - @Override - public Session newSession(Request request, Response response) { - return new AuthSession(request); - } - - /** - * Application settings - */ - private void setApplicationSettings() { - getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class); - getApplicationSettings().setDefaultMaximumUploadSize(WebContext.HTTP_MAXIMUM_UPLOAD); - getApplicationSettings().setInternalErrorPage(InternalErrorPage.class); - getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class); - } - - /** - * Debug settings - */ - private void setDebugSettings() { - getDebugSettings().setAjaxDebugModeEnabled(debug); - getDebugSettings().setComponentUseCheck(debug); - getDebugSettings().setDevelopmentUtilitiesEnabled(debug); - getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(debug); - getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(debug); - getDebugSettings().setOutputComponentPath(debug); - getDebugSettings().setOutputMarkupContainerClassName(debug); - } - - /** - * Exception settings - */ - private void setExceptionSettings() { - getExceptionSettings().setUnexpectedExceptionDisplay( - debug ? IExceptionSettings.SHOW_EXCEPTION_PAGE : IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); - } - - /** - * Framework settings - */ - private void setFrameworkSettings() { - getFrameworkSettings().setDetachListener(null); - } - - /** - * Markup settings - */ - private void setMarkupSettings() { - getMarkupSettings().setAutomaticLinking(false); - getMarkupSettings().setCompressWhitespace(optimize); - getMarkupSettings().setDefaultAfterDisabledLink("</strike"); - getMarkupSettings().setDefaultBeforeDisabledLink("<strike>"); - getMarkupSettings().setDefaultMarkupEncoding(DataContext.ENCODING); - // getMarkupSettings().setMarkupCache(???); - // getMarkupSettings().setMarkupParserFactory(???); - getMarkupSettings().setStripComments(optimize); - getMarkupSettings().setStripWicketTags(true); - - getMarkupSettings().setThrowExceptionOnMissingXmlDeclaration(false); - } - - /** - * Page settings - */ - private void setPageSettings() { - // getPageSettings().addComponentResolver(???); - getPageSettings().setVersionPagesByDefault(true); - } - - /** - * Request cycle settings - */ - private void setRequestCycleSettings() { - // getRequestCycleSettings().addResponseFilter(???); - getRequestCycleSettings().setBufferResponse(true); - getRequestCycleSettings().setGatherExtendedBrowserInfo(false); - getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_BUFFER); - getRequestCycleSettings().setResponseRequestEncoding(DataContext.ENCODING); - getRequestCycleSettings().setTimeout(WebContext.HTTP_TIME_OUT); - } - - /** - * Request logger settings - */ - private void setRequestLoggerSettings() { - getRequestLoggerSettings().setRecordSessionSize(debug); - getRequestLoggerSettings().setRequestLoggerEnabled(debug); - getRequestLoggerSettings().setRequestsWindowSize(WebContext.HTTP_REQUEST_LOGGER_WINDOW_SIZE); - } - - /** - * Resource settings - */ - private void setResourceSettings() { - for (IStringResourceLoader message : messages) { - getResourceSettings().getStringResourceLoaders().add(message); - } - getResourceSettings().setDefaultCacheDuration(optimize ? WebContext.HTTP_CACHE_DURATION : Duration.NONE); - - getResourceSettings().setJavaScriptCompressor(optimize ? new DefaultJavaScriptCompressor() : null); - - getResourceSettings().setCssCompressor(optimize ? new NoOpTextCompressor() : null); - - getResourceSettings().setParentFolderPlaceholder(null); - getResourceSettings().setResourcePollFrequency(null); - - getResourceSettings().setThrowExceptionOnMissingResource(true); - getResourceSettings().setUseDefaultOnMissingResource(!debug); - } - - /** - * Security settings - */ - private void setSecuritySettings() { - getSecuritySettings().setAuthorizationStrategy(new AuthStrategy()); - - // Customize the cookie age for the authentification stategy - IAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(WebContext.AUTH_COOKIE_KEY) { - - /** Cookie utils with custom settings */ - private CookieUtils cookieUtils; - - protected CookieUtils getCookieUtils() { - if (cookieUtils == null) { - cookieUtils = new CookieUtils(); - cookieUtils.getSettings().setMaxAge(WebContext.AUTH_COOKIE_MAX_AGE); - } - return cookieUtils; - } - }; - getSecuritySettings().setAuthenticationStrategy(authStrategy); - - getSecuritySettings().setEnforceMounts(false); - } - - /** - * Configure the mapping of urls - */ - private void mountUrls() { - - getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/list", ListCampagnesPage.class)); - mountPage("/campagne/list", ListCampagnesPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/edit", ManageCampagnePage.class)); - mountPage("/campagne/edit", ManageCampagnePage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/view", ReadCampagnePage.class)); - mountPage("/campagne/view", ReadCampagnePage.class); - - getRootRequestMapperAsCompound().add( - new MountMapper("/config", new PackageMapper(PackageName.forClass(ListConfigurationPage.class)))); - - getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/list", ListExtractionsPage.class)); - mountPage("/extraction/list", ListExtractionsPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/edit", ManageExtractionPage.class)); - mountPage("/extraction/edit", ManageExtractionPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/view", ReadExtractionPage.class)); - mountPage("/extraction/view", ReadExtractionPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/lot/list", ListLotsPage.class)); - mountPage("/lot/list", ListLotsPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/lot/edit", ManageLotPage.class)); - mountPage("/lot/edit", ManageLotPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/lot/view", ReadLotPage.class)); - mountPage("/lot/view", ReadLotPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/personne/list", ListPersonnesPage.class)); - mountPage("/personne/list", ListPersonnesPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/personne/edit", ManagePersonnePage.class)); - mountPage("/personne/edit", ManagePersonnePage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/personne/view", ReadPersonnePage.class)); - mountPage("/personne/view", ReadPersonnePage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/purification/list", ListPurificationsPage.class)); - mountPage("/purification/list", ListPurificationsPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/purification/edit", ManagePurificationPage.class)); - mountPage("/purification/edit", ManagePurificationPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/purification/view", ReadPurificationPage.class)); - mountPage("/purification/view", ReadPurificationPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/list", ListSpecimensPage.class)); - mountPage("/specimen/list", ListSpecimensPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/edit", ManageSpecimenPage.class)); - mountPage("/specimen/edit", ManageSpecimenPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/view", ReadSpecimenPage.class)); - mountPage("/specimen/view", ReadSpecimenPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/station/list", ListStationsPage.class)); - mountPage("/station/list", ListStationsPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/station/edit", ManageStationPage.class)); - mountPage("/station/edit", ManageStationPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/station/view", ReadStationPage.class)); + + /** + * SpringBeans injector (some objects such as Pages are automatically injected, by not all of them) + * @param object Object to be injected + */ + public static void injectSpringBeans(Object object) { + Injector.get().inject(object); + } + + /** Debug mode */ + private final boolean debug; + + /** Internationalization messages */ + private final IStringResourceLoader[] messages; + + /** Optimize mode */ + private final boolean optimize; + + /** Service: personne */ + @SpringBean + private PersonneService personneService; + + /** Wicket configuration (Application.DEVELOPMENT or Application.DEPLOYMENT) */ + private final RuntimeConfigurationType wicketConfiguration; + + /** + * Constructor + * @param debug Debug mode + * @param optimize Optimize mode + * @param wicketConfiguration Wicket configuration (DEVELOPMENT or DEPLOYMENT) + * @param messages Internationalization messages + */ + public WebApplicationImpl(boolean debug, boolean optimize, RuntimeConfigurationType wicketConfiguration, + IStringResourceLoader... messages) { + AssertTools.assertArrayNotNull(messages); + this.debug = debug; + this.optimize = optimize; + this.wicketConfiguration = wicketConfiguration; + this.messages = messages; + } + + /** {@inheritDoc} */ + @Override + public RuntimeConfigurationType getConfigurationType() { + return wicketConfiguration; + } + + /** {@inheritDoc} */ + @Override + public Class<HomePage> getHomePage() { + return HomePage.class; + } + + /** {@inheritDoc} */ + @Override + protected void init() { + super.init(); + getComponentInstantiationListeners().add(new SpringComponentInjector(this)); + injectSpringBeans(this); + try { + personneService.checkOrCreateAdmin(); + } catch (DataConstraintException e) { + LOG.error(e.getMessage(), e); + throw new UnexpectedException(e); + } + setApplicationSettings(); + setDebugSettings(); + setExceptionSettings(); + setFrameworkSettings(); + setMarkupSettings(); + setPageSettings(); + setRequestCycleSettings(); + setRequestLoggerSettings(); + setResourceSettings(); + setSecuritySettings(); + mountUrls(); + } + + /** {@inheritDoc} */ + @Override + protected IConverterLocator newConverterLocator() { + ConverterLocator converterLocator = (ConverterLocator) super.newConverterLocator(); + converterLocator.set(Double.class, DoubleConverterImpl.INSTANCE); + converterLocator.set(BigDecimal.class, BigDecimalConverterImpl.INSTANCE); + return converterLocator; + } + + /** {@inheritDoc} */ + @Override + public Session newSession(Request request, Response response) { + return new AuthSession(request); + } + + /** + * Application settings + */ + private void setApplicationSettings() { + getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class); + getApplicationSettings().setDefaultMaximumUploadSize(WebContext.HTTP_MAXIMUM_UPLOAD); + getApplicationSettings().setInternalErrorPage(InternalErrorPage.class); + getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class); + } + + /** + * Debug settings + */ + private void setDebugSettings() { + getDebugSettings().setAjaxDebugModeEnabled(debug); + getDebugSettings().setComponentUseCheck(debug); + getDebugSettings().setDevelopmentUtilitiesEnabled(debug); + getDebugSettings().setLinePreciseReportingOnAddComponentEnabled(debug); + getDebugSettings().setLinePreciseReportingOnNewComponentEnabled(debug); + getDebugSettings().setOutputComponentPath(debug); + getDebugSettings().setOutputMarkupContainerClassName(debug); + } + + /** + * Exception settings + */ + private void setExceptionSettings() { + getExceptionSettings().setUnexpectedExceptionDisplay( + debug ? IExceptionSettings.SHOW_EXCEPTION_PAGE : IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); + } + + /** + * Framework settings + */ + private void setFrameworkSettings() { + getFrameworkSettings().setDetachListener(null); + } + + /** + * Markup settings + */ + private void setMarkupSettings() { + getMarkupSettings().setAutomaticLinking(false); + getMarkupSettings().setCompressWhitespace(optimize); + getMarkupSettings().setDefaultAfterDisabledLink("</strike"); + getMarkupSettings().setDefaultBeforeDisabledLink("<strike>"); + getMarkupSettings().setDefaultMarkupEncoding(DataContext.ENCODING); + // getMarkupSettings().setMarkupCache(???); + // getMarkupSettings().setMarkupParserFactory(???); + getMarkupSettings().setStripComments(optimize); + getMarkupSettings().setStripWicketTags(true); + + getMarkupSettings().setThrowExceptionOnMissingXmlDeclaration(false); + } + + /** + * Page settings + */ + private void setPageSettings() { + // getPageSettings().addComponentResolver(???); + getPageSettings().setVersionPagesByDefault(true); + } + + /** + * Request cycle settings + */ + private void setRequestCycleSettings() { + // getRequestCycleSettings().addResponseFilter(???); + getRequestCycleSettings().setBufferResponse(true); + getRequestCycleSettings().setGatherExtendedBrowserInfo(false); + getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_BUFFER); + getRequestCycleSettings().setResponseRequestEncoding(DataContext.ENCODING); + getRequestCycleSettings().setTimeout(WebContext.HTTP_TIME_OUT); + } + + /** + * Request logger settings + */ + private void setRequestLoggerSettings() { + getRequestLoggerSettings().setRecordSessionSize(debug); + getRequestLoggerSettings().setRequestLoggerEnabled(debug); + getRequestLoggerSettings().setRequestsWindowSize(WebContext.HTTP_REQUEST_LOGGER_WINDOW_SIZE); + } + + /** + * Resource settings + */ + private void setResourceSettings() { + for (IStringResourceLoader message : messages) { + getResourceSettings().getStringResourceLoaders().add(message); + } + getResourceSettings().setDefaultCacheDuration(optimize ? WebContext.HTTP_CACHE_DURATION : Duration.NONE); + + getResourceSettings().setJavaScriptCompressor(optimize ? new DefaultJavaScriptCompressor() : null); + + getResourceSettings().setCssCompressor(optimize ? new NoOpTextCompressor() : null); + + getResourceSettings().setParentFolderPlaceholder(null); + getResourceSettings().setResourcePollFrequency(null); + + getResourceSettings().setThrowExceptionOnMissingResource(true); + getResourceSettings().setUseDefaultOnMissingResource(!debug); + } + + /** + * Security settings + */ + private void setSecuritySettings() { + getSecuritySettings().setAuthorizationStrategy(new AuthStrategy()); + + // Customize the cookie age for the authentification stategy + IAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(WebContext.AUTH_COOKIE_KEY) { + + /** Cookie utils with custom settings */ + private CookieUtils cookieUtils; + + protected CookieUtils getCookieUtils() { + if (cookieUtils == null) { + cookieUtils = new CookieUtils(); + cookieUtils.getSettings().setMaxAge(WebContext.AUTH_COOKIE_MAX_AGE); + } + return cookieUtils; + } + }; + getSecuritySettings().setAuthenticationStrategy(authStrategy); + + getSecuritySettings().setEnforceMounts(false); + } + + /** + * Configure the mapping of urls + */ + private void mountUrls() { + + getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/list", ListCampagnesPage.class)); + mountPage("/campagne/list", ListCampagnesPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/edit", ManageCampagnePage.class)); + mountPage("/campagne/edit", ManageCampagnePage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/campagne/view", ReadCampagnePage.class)); + mountPage("/campagne/view", ReadCampagnePage.class); + + getRootRequestMapperAsCompound().add( + new MountMapper("/config", new PackageMapper(PackageName.forClass(ListConfigurationPage.class)))); + + getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/list", ListExtractionsPage.class)); + mountPage("/extraction/list", ListExtractionsPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/edit", ManageExtractionPage.class)); + mountPage("/extraction/edit", ManageExtractionPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/extraction/view", ReadExtractionPage.class)); + mountPage("/extraction/view", ReadExtractionPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/lot/list", ListLotsPage.class)); + mountPage("/lot/list", ListLotsPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/lot/edit", ManageLotPage.class)); + mountPage("/lot/edit", ManageLotPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/lot/view", ReadLotPage.class)); + mountPage("/lot/view", ReadLotPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/personne/list", ListPersonnesPage.class)); + mountPage("/personne/list", ListPersonnesPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/personne/edit", ManagePersonnePage.class)); + mountPage("/personne/edit", ManagePersonnePage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/personne/view", ReadPersonnePage.class)); + mountPage("/personne/view", ReadPersonnePage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/purification/list", ListPurificationsPage.class)); + mountPage("/purification/list", ListPurificationsPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/purification/edit", ManagePurificationPage.class)); + mountPage("/purification/edit", ManagePurificationPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/purification/view", ReadPurificationPage.class)); + mountPage("/purification/view", ReadPurificationPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/list", ListSpecimensPage.class)); + mountPage("/specimen/list", ListSpecimensPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/edit", ManageSpecimenPage.class)); + mountPage("/specimen/edit", ManageSpecimenPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/specimen/view", ReadSpecimenPage.class)); + mountPage("/specimen/view", ReadSpecimenPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/station/list", ListStationsPage.class)); + mountPage("/station/list", ListStationsPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/station/edit", ManageStationPage.class)); + mountPage("/station/edit", ManageStationPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/station/view", ReadStationPage.class)); mountPage("/station/view", ReadStationPage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/list", ListMoleculesPage.class)); @@ -393,34 +393,34 @@ getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/edit", ManageMoleculePage.class)); mountPage("/molecule/edit", ManageMoleculePage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/view", ReadMoleculePage.class)); - mountPage("/molecule/view", ReadMoleculePage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/list", ListTestsBioPage.class)); - mountPage("/testBio/list", ListTestsBioPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/edit", ManageTestBioPage.class)); - mountPage("/testBio/edit", ManageTestBioPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/view", ReadTestBioPage.class)); + mountPage("/molecule/view", ReadMoleculePage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/list", ListTestsBioPage.class)); + mountPage("/testBio/list", ListTestsBioPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/edit", ManageTestBioPage.class)); + mountPage("/testBio/edit", ManageTestBioPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/view", ReadTestBioPage.class)); mountPage("/testBio/view", ReadTestBioPage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/document/edit", ManageDocumentPage.class)); mountPage("/document/edit", ManageDocumentPage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/document/view", ReadDocumentPage.class)); - mountPage("/document/view", ReadDocumentPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/utilisateur/edit", ManageUtilisateurPage.class)); - mountPage("/utilisateur/edit", ManageUtilisateurPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/utilisateur/update", UpdateUtilisateurPage.class)); - mountPage("/utilisateur/update", UpdateUtilisateurPage.class); - - getRootRequestMapperAsCompound().add(new MountedMapper("/contact", ContactPage.class)); - mountPage("/contact", ContactPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/register", RegisterPage.class)); - mountPage("/register", RegisterPage.class); - getRootRequestMapperAsCompound().add(new MountedMapper("/passwordLost", ResetPasswordPage.class)); + mountPage("/document/view", ReadDocumentPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/utilisateur/edit", ManageUtilisateurPage.class)); + mountPage("/utilisateur/edit", ManageUtilisateurPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/utilisateur/update", UpdateUtilisateurPage.class)); + mountPage("/utilisateur/update", UpdateUtilisateurPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/contact", ContactPage.class)); + mountPage("/contact", ContactPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/register", RegisterPage.class)); + mountPage("/register", RegisterPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/passwordLost", ResetPasswordPage.class)); mountPage("/passwordLost", ResetPasswordPage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/search", SearchPage.class)); - mountPage("/search", SearchPage.class); - } - + mountPage("/search", SearchPage.class); + } + } \ No newline at end of file Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebContext.java 2013-02-18 00:07:41 UTC (rev 118) @@ -42,9 +42,9 @@ import nc.ird.cantharella.data.validation.utils.ModelValidatorImpl; import nc.ird.cantharella.service.config.ServiceContext; import nc.ird.cantharella.web.utils.resources.WebMessages; -import nc.ird.module.utils.CantharellaConfig; -import nc.ird.module.utils.Pair; -import nc.ird.module.utils.StringTools; +import nc.ird.cantharella.utils.CantharellaConfig; +import nc.ird.cantharella.utils.Pair; +import nc.ird.cantharella.utils.StringTools; import org.apache.wicket.RuntimeConfigurationType; import org.apache.wicket.protocol.http.WebApplication; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/ContactPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/ContactPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/ContactPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,7 +30,7 @@ import nc.ird.cantharella.web.utils.forms.SubmittableButton; import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; import nc.ird.cantharella.web.utils.security.AuthRole; -import nc.ird.module.utils.CaptchaTools; +import nc.ird.cantharella.utils.CaptchaTools; import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/HomePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/HomePage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/HomePage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -21,342 +21,342 @@ * #L% */ package nc.ird.cantharella.web.pages; - -import java.text.MessageFormat; -import java.util.List; - -import nc.ird.cantharella.data.exceptions.DataConstraintException; -import nc.ird.cantharella.data.exceptions.DataNotFoundException; -import nc.ird.cantharella.data.model.Utilisateur; -import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; -import nc.ird.cantharella.data.validation.utils.ModelValidator; -import nc.ird.cantharella.service.services.CampagneService; -import nc.ird.cantharella.service.services.ExtractionService; -import nc.ird.cantharella.service.services.LotService; -import nc.ird.cantharella.service.services.PersonneService; -import nc.ird.cantharella.service.services.PurificationService; -import nc.ird.cantharella.service.services.SpecimenService; -import nc.ird.cantharella.service.services.StationService; -import nc.ird.cantharella.service.services.TestBioService; -import nc.ird.cantharella.web.pages.domain.utilisateur.ManageUtilisateurPage; -import nc.ird.cantharella.web.pages.domain.utilisateur.ReadUtilisateurPage; -import nc.ird.cantharella.web.pages.domain.utilisateur.RegisterPage; -import nc.ird.cantharella.web.pages.domain.utilisateur.ResetPasswordPage; -import nc.ird.cantharella.web.pages.model.LoginModel; -import nc.ird.cantharella.web.utils.CallerPage; -import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior; -import nc.ird.cantharella.web.utils.forms.SubmittableButton; -import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; -import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider; -import nc.ird.cantharella.web.utils.security.AuthContainer; -import nc.ird.cantharella.web.utils.security.AuthRole; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; - + +import java.text.MessageFormat; +import java.util.List; + +import nc.ird.cantharella.data.exceptions.DataConstraintException; +import nc.ird.cantharella.data.exceptions.DataNotFoundException; +import nc.ird.cantharella.data.model.Utilisateur; +import nc.ird.cantharella.data.model.Utilisateur.TypeDroit; +import nc.ird.cantharella.data.validation.utils.ModelValidator; +import nc.ird.cantharella.service.services.CampagneService; +import nc.ird.cantharella.service.services.ExtractionService; +import nc.ird.cantharella.service.services.LotService; +import nc.ird.cantharella.service.services.PersonneService; +import nc.ird.cantharella.service.services.PurificationService; +import nc.ird.cantharella.service.services.SpecimenService; +import nc.ird.cantharella.service.services.StationService; +import nc.ird.cantharella.service.services.TestBioService; +import nc.ird.cantharella.web.pages.domain.utilisateur.ManageUtilisateurPage; +import nc.ird.cantharella.web.pages.domain.utilisateur.ReadUtilisateurPage; +import nc.ird.cantharella.web.pages.domain.utilisateur.RegisterPage; +import nc.ird.cantharella.web.pages.domain.utilisateur.ResetPasswordPage; +import nc.ird.cantharella.web.pages.model.LoginModel; +import nc.ird.cantharella.web.utils.CallerPage; +import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior; +import nc.ird.cantharella.web.utils.forms.SubmittableButton; +import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; +import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider; +import nc.ird.cantharella.web.utils.security.AuthContainer; +import nc.ird.cantharella.web.utils.security.AuthRole; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; + import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.wicket.MarkupContainer; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.CheckBox; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.markup.html.link.Link; -import org.apache.wicket.markup.html.panel.EmptyPanel; -import org.apache.wicket.markup.repeater.Item; -import org.apache.wicket.markup.repeater.data.DataView; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -/** - * Home page - * @author Mickael Tricot - * @author Adrien Cheype - */ -public final class HomePage extends TemplatePage { - - /** Logger */ +import org.slf4j.LoggerFactory; +import org.apache.wicket.MarkupContainer; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.PasswordTextField; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.markup.html.panel.EmptyPanel; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.markup.repeater.data.DataView; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.spring.injection.annot.SpringBean; + +/** + * Home page + * @author Mickael Tricot + * @author Adrien Cheype + */ +public final class HomePage extends TemplatePage { + + /** Logger */ private static final Logger LOG = LoggerFactory.getLogger(HomePage.class); - - /** Action : login */ - private static final String ACTION_LOGIN = "Login"; - - /** Service : personne */ - @SpringBean - private PersonneService personneService; - - /** Service : campagne */ - @SpringBean - private CampagneService campagneService; - - /** Service : station */ - @SpringBean - private StationService stationService; - - /** Service : specimen */ - @SpringBean - private SpecimenService specimenService; - - /** Service : lots */ - @SpringBean - private LotService lotService; - - /** Service : extraction */ - @SpringBean - private ExtractionService extractionService; - - /** Service : purification */ - @SpringBean - private PurificationService purificationService; - - /** Service : test biologique */ - @SpringBean - private TestBioService testBioService; - - /** Validateur modèle */ - @SpringBean(name = "webModelValidator") - private ModelValidator validator; - - /** - * Constructeur - */ - public HomePage() { - super(HomePage.class); - addVisitorContent(); - addUserContent(); - addAdminContent(); - } - - /** - * Ajour du contenu administrateur - */ - private void addAdminContent() { - final AuthContainer adminContent = new AuthContainer("Content.ADMIN", AuthRole.ADMIN); - if (adminContent.isAuthorized()) { - - // Affiche les utilisateurs à valider sur la page d'accueil ADMIN - final MarkupContainer invalidUtilisateursView = new WebMarkupContainer("InvalidUtilisateurs.List"); - invalidUtilisateursView.setOutputMarkupId(true); - - final List<Utilisateur> utilisateursInvalid = personneService.listUtilisateursInvalid(); - invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); - if (invalidUtilisateursView.isVisibilityAllowed()) { - invalidUtilisateursView.add(new DataView<Utilisateur>("InvalidUtilisateurs.List.Utilisateur", - new LoadableDetachableSortableListDataProvider<Utilisateur>(utilisateursInvalid, getSession() - .getLocale())) { - @Override - protected void populateItem(Item<Utilisateur> item) { - Utilisateur utilisateur = item.getModelObject(); - item.add(new Label("InvalidUtilisateurs.List.Utilisateur.Label", utilisateur.toString())); - - // Action : valider l'utilisateur - item.add(new AjaxFallbackLink<Utilisateur>("InvalidUtilisateurs.List.Utilisateur.Valid", - new Model<Utilisateur>(utilisateur)) { - @Override - public void onClick(AjaxRequestTarget target) { - try { - // Validation - personneService.validAndUpdateUtilisateur(getModelObject()); - successCurrentPage(ManageUtilisateurPage.class, "Update"); - - // Mise à jour de la liste - CollectionTools.setter(utilisateursInvalid, - personneService.listUtilisateursInvalid()); - invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); - if (target != null) { - target.add(invalidUtilisateursView); - } - } catch (DataConstraintException e) { - errorCurrentPage(ManageUtilisateurPage.class, "Update", e); - } - refreshFeedbackPage(target); - } - }); - - // Action : mettre à jour l'utilisateur (redirection vers le formulaire) - item.add(new Link<Utilisateur>("InvalidUtilisateurs.List.Utilisateur.Update", - new Model<Utilisateur>(utilisateur)) { - @Override - public void onClick() { - setResponsePage(new ManageUtilisateurPage(getModelObject().getIdPersonne(), - new CallerPage(HomePage.class))); - } - }); - - // Action : supprimer l'utilisateur - Link<Utilisateur> deleteLink = new AjaxFallbackLink<Utilisateur>( - "InvalidUtilisateurs.List.Utilisateur.Reject", new Model<Utilisateur>(utilisateur)) { - @Override - public void onClick(AjaxRequestTarget target) { - // Suppression - personneService.rejectUtilisateur(getModelObject()); - successCurrentPage(ManageUtilisateurPage.class, "Reject"); - - // Mise à jour de la liste - CollectionTools.setter(utilisateursInvalid, personneService.listUtilisateursInvalid()); - invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); - if (target != null) { - target.add(invalidUtilisateursView); - } - refreshFeedbackPage(target); - } - }; - deleteLink.add(new JSConfirmationBehavior(getString("Confirm"))); - item.add(deleteLink); - } - }); - - } - - adminContent.add(invalidUtilisateursView); - - } - add(adminContent); - } - - /** - * Ajour du contenu utilisateur (s'affiche également pour l'admin) - */ - private void addUserContent() { - AuthContainer userContent = new AuthContainer("Content.USER", AuthRole.USER, AuthRole.ADMIN); - if (userContent.isAuthorized()) { - userContent.add(new Label(getResource() + ".Statistics.Personnes", String.valueOf(personneService - .countPersonnes()))); - userContent.add(new Label(getResource() + ".Statistics.Campagnes", String.valueOf(campagneService - .countCampagnes()))); - userContent.add(new Label(getResource() + ".Statistics.Stations", String.valueOf(stationService - .countStations()))); - userContent.add(new Label(getResource() + ".Statistics.Specimens", String.valueOf(specimenService - .countSpecimens()))); - userContent.add(new Label(getResource() + ".Statistics.Lots", String.valueOf(lotService.countLots()))); - userContent.add(new Label(getResource() + ".Statistics.Extractions", String.valueOf(extractionService - .countExtractions()))); - userContent.add(new Label(getResource() + ".Statistics.Purifications", String.valueOf(purificationService - .countPurifications()))); - userContent.add(new Label(getResource() + ".Statistics.TestsBio", String.valueOf(testBioService - .countResultatsTestsBio()))); - - // affichage du volet droits - Link<Utilisateur> detailsRight = new Link<Utilisateur>("HomePage.Rights.User.Details", - new Model<Utilisateur>(getSession().getUtilisateur())) { - @Override - public void onClick() { - setResponsePage(new ReadUtilisateurPage(getModelObject().getIdPersonne(), new CallerPage( - HomePage.this))); - } - - /** {@inheritDoc} */ - @Override - protected CharSequence getURL() { - return super.getURL() + "#rights"; - } - - }; - userContent.add(detailsRight); - - if (getSession().getUtilisateur().getTypeDroit() == TypeDroit.ADMINISTRATEUR) { - userContent.add(new Label("HomePage.Rights.User1", getString("HomePage.Rights.Admin"))); - // pas d'affichage du lien de détails - detailsRight.setVisibilityAllowed(false); - EmptyPanel rights2 = new EmptyPanel("HomePage.Rights.User2"); - rights2.setVisibilityAllowed(false); - userContent.add(rights2); - } else { - // pour l'utilisateur simple, nb de campagnes et de lots accessibles affichés - Integer nbCampagnesDroits = getSession().getUtilisateur().getCampagnesDroits().size(); - Integer nbLotsDroits = getSession().getUtilisateur().getLotsDroits().size(); - String msgRights = MessageFormat.format(getString("HomePage.Rights.User"), nbCampagnesDroits, - nbLotsDroits); - userContent.add(new Label("HomePage.Rights.User1", msgRights)); - - Integer nbCampagnesCrees = getSession().getUtilisateur().getCampagnesCreees().size(); - String msgRights2 = MessageFormat.format(getString("HomePage.Rights.User2"), nbCampagnesCrees); - Label rights2 = new Label("HomePage.Rights.User2", msgRights2); - rights2.setVisibilityAllowed(nbCampagnesCrees != 0); - userContent.add(rights2); - } - } - add(userContent); - } - - /** - * Ajout du contenu visiteur - */ - private void addVisitorContent() { - AuthContainer visitorContent = new AuthContainer("Content.VISITOR", AuthRole.VISITOR); - if (visitorContent.isAuthorized()) { - - // Initialisation des modèles pour la connexion - final IModel<LoginModel> loginModel = new Model<LoginModel>(new LoginModel()); - final IModel<Utilisateur> utilisateurModel = new Model<Utilisateur>(new Utilisateur()); - - // Formulaire de connexion - final Form<Void> formView = new Form<Void>("Form"); - - // Champs du formulaire - formView.add(new TextField<String>("Personne.courriel", new PropertyModel<String>(utilisateurModel, - "courriel"))); - formView.add(new PasswordTextField("LoginModel.password", new PropertyModel<String>(loginModel, "password")) - .setRequired(false)); - formView.add(new CheckBox("LoginModel.rememberMe", new PropertyModel<Boolean>(loginModel, "rememberMe"))); - - // Action : connexion - formView.add(new SubmittableButton(ACTION_LOGIN, new SubmittableButtonEvents() { - - @Override - public void onProcess() throws DataNotFoundException, DataConstraintException { - if (getSession().authenticate(utilisateurModel.getObject().getCourriel(), - personneService.hashPassword(loginModel.getObject().getPassword()))) { - Utilisateur user = personneService.loadUtilisateur(utilisateurModel.getObject().getCourriel()); - getSession().connectUser(user, loginModel.getObject().getRememberMe()); - LOG.info("connexion de l'utilisateur : " + user.getPrenom() + " " + user.getNom()); - } else { - // si échec dans l'authentification - if (CollectionTools.containsWithValue(personneService.listUtilisateursInvalid(), "courriel", - AccessType.GETTER, utilisateurModel.getObject().getCourriel())) { - // si le courriel est celui d'un utilisateur non validé, message d'erreur approprié - error(getString("HomePage.Login.NotYetValid")); - } else { - error(getString("HomePage.Login.KO")); - } - // Ràz du mot de passe - loginModel.getObject().setPassword(null); - } - } - - @Override - public void onSuccess() { - successNextPage(ACTION_LOGIN); - setResponsePage(getApplication().getHomePage()); - } - - @Override - public void onValidate() { - // Validate Utilisateur - addValidationErrors(validator.validate(utilisateurModel.getObject(), getSession().getLocale(), - "courriel")); - // Validate LoginModel - addValidationErrors(validator.validate(loginModel.getObject(), getSession().getLocale(), - "password", "rememberMe")); - } - })); - - // Lien pour regénérer le mot de passe - formView.add(new BookmarkablePageLink<Void>(ResetPasswordPage.class.getSimpleName(), - ResetPasswordPage.class)); - - // Lien pour s'enregistrer - visitorContent.add(new BookmarkablePageLink<Void>(RegisterPage.class.getSimpleName(), RegisterPage.class)); - - visitorContent.add(formView); - - } - add(visitorContent); - } + + /** Action : login */ + private static final String ACTION_LOGIN = "Login"; + + /** Service : personne */ + @SpringBean + private PersonneService personneService; + + /** Service : campagne */ + @SpringBean + private CampagneService campagneService; + + /** Service : station */ + @SpringBean + private StationService stationService; + + /** Service : specimen */ + @SpringBean + private SpecimenService specimenService; + + /** Service : lots */ + @SpringBean + private LotService lotService; + + /** Service : extraction */ + @SpringBean + private ExtractionService extractionService; + + /** Service : purification */ + @SpringBean + private PurificationService purificationService; + + /** Service : test biologique */ + @SpringBean + private TestBioService testBioService; + + /** Validateur modèle */ + @SpringBean(name = "webModelValidator") + private ModelValidator validator; + + /** + * Constructeur + */ + public HomePage() { + super(HomePage.class); + addVisitorContent(); + addUserContent(); + addAdminContent(); + } + + /** + * Ajour du contenu administrateur + */ + private void addAdminContent() { + final AuthContainer adminContent = new AuthContainer("Content.ADMIN", AuthRole.ADMIN); + if (adminContent.isAuthorized()) { + + // Affiche les utilisateurs à valider sur la page d'accueil ADMIN + final MarkupContainer invalidUtilisateursView = new WebMarkupContainer("InvalidUtilisateurs.List"); + invalidUtilisateursView.setOutputMarkupId(true); + + final List<Utilisateur> utilisateursInvalid = personneService.listUtilisateursInvalid(); + invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); + if (invalidUtilisateursView.isVisibilityAllowed()) { + invalidUtilisateursView.add(new DataView<Utilisateur>("InvalidUtilisateurs.List.Utilisateur", + new LoadableDetachableSortableListDataProvider<Utilisateur>(utilisateursInvalid, getSession() + .getLocale())) { + @Override + protected void populateItem(Item<Utilisateur> item) { + Utilisateur utilisateur = item.getModelObject(); + item.add(new Label("InvalidUtilisateurs.List.Utilisateur.Label", utilisateur.toString())); + + // Action : valider l'utilisateur + item.add(new AjaxFallbackLink<Utilisateur>("InvalidUtilisateurs.List.Utilisateur.Valid", + new Model<Utilisateur>(utilisateur)) { + @Override + public void onClick(AjaxRequestTarget target) { + try { + // Validation + personneService.validAndUpdateUtilisateur(getModelObject()); + successCurrentPage(ManageUtilisateurPage.class, "Update"); + + // Mise à jour de la liste + CollectionTools.setter(utilisateursInvalid, + personneService.listUtilisateursInvalid()); + invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); + if (target != null) { + target.add(invalidUtilisateursView); + } + } catch (DataConstraintException e) { + errorCurrentPage(ManageUtilisateurPage.class, "Update", e); + } + refreshFeedbackPage(target); + } + }); + + // Action : mettre à jour l'utilisateur (redirection vers le formulaire) + item.add(new Link<Utilisateur>("InvalidUtilisateurs.List.Utilisateur.Update", + new Model<Utilisateur>(utilisateur)) { + @Override + public void onClick() { + setResponsePage(new ManageUtilisateurPage(getModelObject().getIdPersonne(), + new CallerPage(HomePage.class))); + } + }); + + // Action : supprimer l'utilisateur + Link<Utilisateur> deleteLink = new AjaxFallbackLink<Utilisateur>( + "InvalidUtilisateurs.List.Utilisateur.Reject", new Model<Utilisateur>(utilisateur)) { + @Override + public void onClick(AjaxRequestTarget target) { + // Suppression + personneService.rejectUtilisateur(getModelObject()); + successCurrentPage(ManageUtilisateurPage.class, "Reject"); + + // Mise à jour de la liste + CollectionTools.setter(utilisateursInvalid, personneService.listUtilisateursInvalid()); + invalidUtilisateursView.setVisibilityAllowed(!utilisateursInvalid.isEmpty()); + if (target != null) { + target.add(invalidUtilisateursView); + } + refreshFeedbackPage(target); + } + }; + deleteLink.add(new JSConfirmationBehavior(getString("Confirm"))); + item.add(deleteLink); + } + }); + + } + + adminContent.add(invalidUtilisateursView); + + } + add(adminContent); + } + + /** + * Ajour du contenu utilisateur (s'affiche également pour l'admin) + */ + private void addUserContent() { + AuthContainer userContent = new AuthContainer("Content.USER", AuthRole.USER, AuthRole.ADMIN); + if (userContent.isAuthorized()) { + userContent.add(new Label(getResource() + ".Statistics.Personnes", String.valueOf(personneService + .countPersonnes()))); + userContent.add(new Label(getResource() + ".Statistics.Campagnes", String.valueOf(campagneService + .countCampagnes()))); + userContent.add(new Label(getResource() + ".Statistics.Stations", String.valueOf(stationService + .countStations()))); + userContent.add(new Label(getResource() + ".Statistics.Specimens", String.valueOf(specimenService + .countSpecimens()))); + userContent.add(new Label(getResource() + ".Statistics.Lots", String.valueOf(lotService.countLots()))); + userContent.add(new Label(getResource() + ".Statistics.Extractions", String.valueOf(extractionService + .countExtractions()))); + userContent.add(new Label(getResource() + ".Statistics.Purifications", String.valueOf(purificationService + .countPurifications()))); + userContent.add(new Label(getResource() + ".Statistics.TestsBio", String.valueOf(testBioService + .countResultatsTestsBio()))); + + // affichage du volet droits + Link<Utilisateur> detailsRight = new Link<Utilisateur>("HomePage.Rights.User.Details", + new Model<Utilisateur>(getSession().getUtilisateur())) { + @Override + public void onClick() { + setResponsePage(new ReadUtilisateurPage(getModelObject().getIdPersonne(), new CallerPage( + HomePage.this))); + } + + /** {@inheritDoc} */ + @Override + protected CharSequence getURL() { + return super.getURL() + "#rights"; + } + + }; + userContent.add(detailsRight); + + if (getSession().getUtilisateur().getTypeDroit() == TypeDroit.ADMINISTRATEUR) { + userContent.add(new Label("HomePage.Rights.User1", getString("HomePage.Rights.Admin"))); + // pas d'affichage du lien de détails + detailsRight.setVisibilityAllowed(false); + EmptyPanel rights2 = new EmptyPanel("HomePage.Rights.User2"); + rights2.setVisibilityAllowed(false); + userContent.add(rights2); + } else { + // pour l'utilisateur simple, nb de campagnes et de lots accessibles affichés + Integer nbCampagnesDroits = getSession().getUtilisateur().getCampagnesDroits().size(); + Integer nbLotsDroits = getSession().getUtilisateur().getLotsDroits().size(); + String msgRights = MessageFormat.format(getString("HomePage.Rights.User"), nbCampagnesDroits, + nbLotsDroits); + userContent.add(new Label("HomePage.Rights.User1", msgRights)); + + Integer nbCampagnesCrees = getSession().getUtilisateur().getCampagnesCreees().size(); + String msgRights2 = MessageFormat.format(getString("HomePage.Rights.User2"), nbCampagnesCrees); + Label rights2 = new Label("HomePage.Rights.User2", msgRights2); + rights2.setVisibilityAllowed(nbCampagnesCrees != 0); + userContent.add(rights2); + } + } + add(userContent); + } + + /** + * Ajout du contenu visiteur + */ + private void addVisitorContent() { + AuthContainer visitorContent = new AuthContainer("Content.VISITOR", AuthRole.VISITOR); + if (visitorContent.isAuthorized()) { + + // Initialisation des modèles pour la connexion + final IModel<LoginModel> loginModel = new Model<LoginModel>(new LoginModel()); + final IModel<Utilisateur> utilisateurModel = new Model<Utilisateur>(new Utilisateur()); + + // Formulaire de connexion + final Form<Void> formView = new Form<Void>("Form"); + + // Champs du formulaire + formView.add(new TextField<String>("Personne.courriel", new PropertyModel<String>(utilisateurModel, + "courriel"))); + formView.add(new PasswordTextField("LoginModel.password", new PropertyModel<String>(loginModel, "password")) + .setRequired(false)); + formView.add(new CheckBox("LoginModel.rememberMe", new PropertyModel<Boolean>(loginModel, "rememberMe"))); + + // Action : connexion + formView.add(new SubmittableButton(ACTION_LOGIN, new SubmittableButtonEvents() { + + @Override + public void onProcess() throws DataNotFoundException, DataConstraintException { + if (getSession().authenticate(utilisateurModel.getObject().getCourriel(), + personneService.hashPassword(loginModel.getObject().getPassword()))) { + Utilisateur user = personneService.loadUtilisateur(utilisateurModel.getObject().getCourriel()); + getSession().connectUser(user, loginModel.getObject().getRememberMe()); + LOG.info("connexion de l'utilisateur : " + user.getPrenom() + " " + user.getNom()); + } else { + // si échec dans l'authentification + if (CollectionTools.containsWithValue(personneService.listUtilisateursInvalid(), "courriel", + AccessType.GETTER, utilisateurModel.getObject().getCourriel())) { + // si le courriel est celui d'un utilisateur non validé, message d'erreur approprié + error(getString("HomePage.Login.NotYetValid")); + } else { + error(getString("HomePage.Login.KO")); + } + // Ràz du mot de passe + loginModel.getObject().setPassword(null); + } + } + + @Override + public void onSuccess() { + successNextPage(ACTION_LOGIN); + setResponsePage(getApplication().getHomePage()); + } + + @Override + public void onValidate() { + // Validate Utilisateur + addValidationErrors(validator.validate(utilisateurModel.getObject(), getSession().getLocale(), + "courriel")); + // Validate LoginModel + addValidationErrors(validator.validate(loginModel.getObject(), getSession().getLocale(), + "password", "rememberMe")); + } + })); + + // Lien pour regénérer le mot de passe + formView.add(new BookmarkablePageLink<Void>(ResetPasswordPage.class.getSimpleName(), + ResetPasswordPage.class)); + + // Lien pour s'enregistrer + visitorContent.add(new BookmarkablePageLink<Void>(RegisterPage.class.getSimpleName(), RegisterPage.class)); + + visitorContent.add(formView); + + } + add(visitorContent); + } } \ No newline at end of file Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -43,8 +43,8 @@ import nc.ird.cantharella.web.utils.security.AuthContainer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthSession; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.Pair; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.Pair; import org.apache.wicket.Component; import org.apache.wicket.MarkupContainer; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/LinkProduitPropertyColumn.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/LinkProduitPropertyColumn.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/LinkProduitPropertyColumn.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,8 +27,8 @@ import nc.ird.cantharella.data.model.Produit; import nc.ird.cantharella.web.pages.TemplatePage; import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; import org.apache.wicket.markup.repeater.Item; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/campagne/ManageCampagnePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/campagne/ManageCampagnePage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/campagne/ManageCampagnePage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -54,7 +54,7 @@ import nc.ird.cantharella.web.utils.renderers.MapChoiceRenderer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.CollectionTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/extraction/ManageExtractionPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/extraction/ManageExtractionPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/extraction/ManageExtractionPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -57,8 +57,8 @@ import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -49,8 +49,8 @@ import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/purification/ManagePurificationPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/purification/ManagePurificationPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/purification/ManagePurificationPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -56,8 +56,8 @@ import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/specimen/ManageSpecimenPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/specimen/ManageSpecimenPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/specimen/ManageSpecimenPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -50,8 +50,8 @@ import nc.ird.cantharella.web.utils.renderers.EnumChoiceRenderer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/station/ManageStationPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/station/ManageStationPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/station/ManageStationPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -45,7 +45,7 @@ import nc.ird.cantharella.web.utils.renderers.MapChoiceRenderer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/testBio/ManageTestBioPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/testBio/ManageTestBioPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/testBio/ManageTestBioPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -66,8 +66,8 @@ import nc.ird.cantharella.web.utils.renderers.EnumChoiceRenderer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/ManageUtilisateurPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/ManageUtilisateurPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/ManageUtilisateurPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -50,9 +50,9 @@ import nc.ird.cantharella.web.utils.renderers.EnumChoiceRenderer; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.CollectionTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.CollectionTools; import org.apache.commons.collections.comparators.ComparatorChain; import org.slf4j.Logger; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/RegisterPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/RegisterPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/utilisateur/RegisterPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -37,7 +37,7 @@ import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import nc.ird.module.utils.CaptchaTools; +import nc.ird.cantharella.utils.CaptchaTools; import org.apache.wicket.Component; import org.apache.wicket.extensions.markup.html.captcha.CaptchaImageResource; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/ManageStationModel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/ManageStationModel.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/ManageStationModel.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,7 +30,7 @@ import nc.ird.cantharella.data.validation.LatitudeOrientation; import nc.ird.cantharella.data.validation.LongitudeOrientation; -import nc.ird.module.utils.CoordTools; +import nc.ird.cantharella.utils.CoordTools; import org.hibernate.validator.constraints.Range; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/RegisterModel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/RegisterModel.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/RegisterModel.java 2013-02-18 00:07:41 UTC (rev 118) @@ -26,7 +26,7 @@ import javax.validation.constraints.NotNull; -import nc.ird.module.utils.PasswordTools; +import nc.ird.cantharella.utils.PasswordTools; import org.hibernate.validator.constraints.Length; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/UpdateUtilisateurModel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/UpdateUtilisateurModel.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/model/UpdateUtilisateurModel.java 2013-02-18 00:07:41 UTC (rev 118) @@ -26,7 +26,7 @@ import javax.validation.constraints.NotNull; -import nc.ird.module.utils.PasswordTools; +import nc.ird.cantharella.utils.PasswordTools; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/CallerPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/CallerPage.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/CallerPage.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import java.io.Serializable; import nc.ird.cantharella.web.pages.TemplatePage; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; /** * Caller page, to make easy redirections between pages. Works either with a page class or instance. Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/JSConfirmationBehavior.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/JSConfirmationBehavior.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/JSConfirmationBehavior.java 2013-02-18 00:07:41 UTC (rev 118) @@ -22,7 +22,7 @@ */ package nc.ird.cantharella.web.utils.behaviors; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.wicket.Component; import org.apache.wicket.behavior.Behavior; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/BigDecimalConverterImpl.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/BigDecimalConverterImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/BigDecimalConverterImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -26,7 +26,7 @@ import java.util.Locale; import nc.ird.cantharella.data.config.DataContext; -import nc.ird.module.utils.NumberTools; +import nc.ird.cantharella.utils.NumberTools; import org.apache.wicket.util.convert.ConversionException; import org.apache.wicket.util.convert.IConverter; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/DoubleConverterImpl.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/DoubleConverterImpl.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/converters/DoubleConverterImpl.java 2013-02-18 00:07:41 UTC (rev 118) @@ -25,7 +25,7 @@ import java.util.Locale; import nc.ird.cantharella.web.config.WebContext; -import nc.ird.module.utils.NumberTools; +import nc.ird.cantharella.utils.NumberTools; import org.apache.wicket.util.convert.ConversionException; import org.apache.wicket.util.convert.IConverter; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/forms/AutoCompleteTextFieldString.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/forms/AutoCompleteTextFieldString.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/forms/AutoCompleteTextFieldString.java 2013-02-18 00:07:41 UTC (rev 118) @@ -27,10 +27,10 @@ import java.util.List; import java.util.TreeSet; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.Pair; -import nc.ird.module.utils.StringTools; -import nc.ird.module.utils.StringTransformer; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.Pair; +import nc.ird.cantharella.utils.StringTools; +import nc.ird.cantharella.utils.StringTransformer; import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField; import org.apache.wicket.extensions.ajax.markup.html.autocomplete.StringAutoCompleteRenderer; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/GenericLoadableDetachableModel.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/GenericLoadableDetachableModel.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/GenericLoadableDetachableModel.java 2013-02-18 00:07:41 UTC (rev 118) @@ -28,7 +28,7 @@ import nc.ird.cantharella.data.exceptions.UnexpectedException; import nc.ird.cantharella.data.model.utils.AbstractModel; import nc.ird.cantharella.web.config.WebApplicationImpl; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/LoadableDetachableSortableListDataProvider.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/LoadableDetachableSortableListDataProvider.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/LoadableDetachableSortableListDataProvider.java 2013-02-18 00:07:41 UTC (rev 118) @@ -32,10 +32,10 @@ import nc.ird.cantharella.data.exceptions.UnexpectedException; import nc.ird.cantharella.data.model.utils.AbstractModel; import nc.ird.cantharella.web.config.WebContext; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.GenericsTools; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.GenericsTools; import org.apache.commons.collections.comparators.NullComparator; import org.apache.commons.lang3.StringUtils; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java 2013-02-18 00:07:41 UTC (rev 118) @@ -30,10 +30,10 @@ import nc.ird.cantharella.data.config.DataContext; import nc.ird.cantharella.data.exceptions.UnexpectedException; import nc.ird.cantharella.web.config.WebContext; -import nc.ird.module.utils.AssertTools; -import nc.ird.module.utils.BeanTools; -import nc.ird.module.utils.BeanTools.AccessType; -import nc.ird.module.utils.GenericsTools; +import nc.ird.cantharella.utils.AssertTools; +import nc.ird.cantharella.utils.BeanTools; +import nc.ird.cantharella.utils.BeanTools.AccessType; +import nc.ird.cantharella.utils.GenericsTools; import org.apache.commons.collections.comparators.NullComparator; import org.apache.commons.lang3.StringUtils; import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/resources/WebMessages.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/resources/WebMessages.java 2013-02-18 00:05:44 UTC (rev 117) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/resources/WebMessages.java 2013-02-18 00:07:41 UTC (rev 118) @@ -24,7 +24,7 @@ import java.util.Locale; -import nc.ird.module.utils.AssertTools; +import nc.ird.cantharella.utils.AssertTools; import org.apache.wicket.Component; import org.apache.wicket.resource.loader.IStringResourceLoader;