branch feature/2263 updated (a182c8a -> 44b8232)
This is an automated email from the git hooks/post-receive script. New change to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git from a182c8a Impact des données de test suite à changement de modèle CSV new 1a11c49 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) new 44b8232 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 44b82321eb517d338f8e5d1faa327e6523b60bb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 14:58:17 2014 +0100 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation commit 1a11c491eb88690a423def59c6a278948ad0a43b Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 12:04:50 2014 +0100 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) Summary of changes: .../fr/ifremer/wao/entity/SampleRowLogImpl.java | 2 +- .../ifremer/wao/services/AuthenticatedWaoUser.java | 5 +++ .../wao/services/service/SamplingPlanService.java | 37 ++++++++++++++-------- .../services/service/UpdateSampleRowCommand.java | 28 ++++++++-------- .../wao/services/service/ObsMerFixtures.java | 4 +-- .../services/service/SclerochronologyFixtures.java | 10 +++++- .../SclerochronologySamplingPlanServiceTest.java | 11 +++++++ .../ifremer/wao/services/service/WaoFixtures.java | 27 ++++++++++++++-- .../main/resources/i18n/wao-web_en_GB.properties | 1 + .../main/resources/i18n/wao-web_fr_FR.properties | 1 + .../WEB-INF/content/edit-sample-row-input.jsp | 8 ++--- 11 files changed, 96 insertions(+), 38 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit 1a11c491eb88690a423def59c6a278948ad0a43b Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 12:04:50 2014 +0100 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) --- .../src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java index bd39c1b..f0fad49 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java @@ -199,7 +199,7 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { if (oldOrganisation != null) { String msg = "La ligne n'est plus associée à " + oldOrganisation.getFullName(); if (newOrganisation != null && !newOrganisation.equals(oldOrganisation)) { - addChange(msg + " mais à la société " + newOrganisation.getName()); + addChange(msg + " mais à " + newOrganisation.getFullName()); } else if (newOrganisation == null) { addChange(msg); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit 44b82321eb517d338f8e5d1faa327e6523b60bb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 14:58:17 2014 +0100 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation --- .../ifremer/wao/services/AuthenticatedWaoUser.java | 5 +++ .../wao/services/service/SamplingPlanService.java | 37 ++++++++++++++-------- .../services/service/UpdateSampleRowCommand.java | 28 ++++++++-------- .../wao/services/service/ObsMerFixtures.java | 4 +-- .../services/service/SclerochronologyFixtures.java | 10 +++++- .../SclerochronologySamplingPlanServiceTest.java | 11 +++++++ .../ifremer/wao/services/service/WaoFixtures.java | 27 ++++++++++++++-- .../main/resources/i18n/wao-web_en_GB.properties | 1 + .../main/resources/i18n/wao-web_fr_FR.properties | 1 + .../WEB-INF/content/edit-sample-row-input.jsp | 8 ++--- 10 files changed, 95 insertions(+), 37 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java index a3fab0b..214d21a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java @@ -27,6 +27,7 @@ import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.News; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.UserProfile; import fr.ifremer.wao.entity.UserRole; import fr.ifremer.wao.entity.WaoUser; @@ -103,6 +104,10 @@ public class AuthenticatedWaoUser implements Serializable{ return waoUser.getCompany(); } + public Organisation getOrganisation() { + return waoUser.getOrganisation(); + } + public boolean isAuthorizedToChangeUserRights() { boolean authorizedToChangeUserRights = isAuthorizedToSetAdmin() || isAuthorizedToSetCoordinator() diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index f2c72a1..2376fb1 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -35,7 +35,6 @@ import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Boats; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.Dcf5Code; @@ -154,9 +153,11 @@ public class SamplingPlanService extends WaoServiceSupport { public SampleRowsFilter newSampleRowsFilter(AuthenticatedWaoUser authenticatedWaoUser) { + ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); + // all users can see only rows for the program they are logged for SampleRowsFilter newFilter = new SampleRowsFilter(); - newFilter.setObsProgram(authenticatedWaoUser.getObsProgram()); + newFilter.setObsProgram(obsProgram); // We don't want to see all rows but the ones important for today Date fromDate = serviceContext.getNow(); @@ -164,11 +165,7 @@ public class SamplingPlanService extends WaoServiceSupport { // Dans ObsMer et ObsVente, le plan est mensualisé fromDate = DateUtils.truncate(fromDate, Calendar.MONTH); - if (authenticatedWaoUser.getObsProgram().isSclerochronology()) { - // on est sur un plan de janvier à décembre - fromDate = DateUtils.setMonths(fromDate, 0); - - } else { + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { // la période initiale doit toujours aller d'avril à mars (contractuel). // on prend la période dans laquelle on se trouve actuellement @@ -185,6 +182,12 @@ public class SamplingPlanService extends WaoServiceSupport { // l'année prochaine fromDate = DateUtils.setMonths(fromDate, 3); } + } else if (obsProgram.isSclerochronology()) { + // on est sur un plan de janvier à décembre + fromDate = DateUtils.setMonths(fromDate, 0); + + } else { + throw new UnsupportedOperationException("program " + obsProgram); } // on a fromDate sur le premier avril de la bonne année, on va @@ -194,10 +197,17 @@ public class SamplingPlanService extends WaoServiceSupport { newFilter.setPeriodFrom(fromDate); newFilter.setPeriodTo(toDate); - // Very very important to do that at beginning - // Evo #2227 : Guest user has no default company filter + // ATTENTION, il s'agit de sécu if (authenticatedWaoUser.isCoordinatorOrObserver()) { - newFilter.setOrganisationIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); + // quand on appartient à une organisation (société ou labo), par défaut on ne peut voir + // que les lignes de cette même organisation + Organisation organisationToFilterOn = authenticatedWaoUser.getOrganisation(); + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + // dans ce cas, on est plus souple : si on appartient à des labos différents mais à + // la même société, on peut voir tout ce qui concerne la société tous labos confondus + organisationToFilterOn = authenticatedWaoUser.getOrganisation().getCompany(); + } + newFilter.setOrganisationIds(ImmutableSet.of(organisationToFilterOn.getTopiaId())); } return newFilter; @@ -351,13 +361,12 @@ public class SamplingPlanService extends WaoServiceSupport { ); updateSampleRowCommand.setAllFishingZones(allFishingZones); - ImmutableMap<String, Company> allCompanies = + ImmutableMap<String, Organisation> allOrganisations = Maps.uniqueIndex( - // TODO brendan 15/12/14 getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram); - getCompaniesService().getAllCompanies(), + getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram), TopiaEntities.getTopiaIdFunction() ); - updateSampleRowCommand.setAllCompanies(allCompanies); + updateSampleRowCommand.setAllOrganisations(allOrganisations); ImmutableMap<String, Dcf5Code> allDcf5Codes = Maps.uniqueIndex( diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java index cf233e9..3641d36 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java @@ -28,10 +28,10 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import fr.ifremer.wao.WaoUtils; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.IndividualMeasurementStrategy; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; @@ -72,7 +72,7 @@ public class UpdateSampleRowCommand implements Serializable{ protected ImmutableMap<String, FishingZone> allFishingZones; - protected ImmutableMap<String, Company> allCompanies; + protected ImmutableMap<String, Organisation> allOrganisations; protected ImmutableMap<String, Dcf5Code> allDcf5Codes; @@ -112,20 +112,20 @@ public class UpdateSampleRowCommand implements Serializable{ this.expectedObservationsByMonths = expectedObservationsByMonths; } - public String getCompanyId() { - String companyId = null; + public String getOrganisationId() { + String organisationId = null; if (sampleRow.getCompany() != null) { - companyId = sampleRow.getCompany().getTopiaId(); + organisationId = sampleRow.getOrganisation().getTopiaId(); } - return companyId; + return organisationId; } - public void setCompanyId(String companyId) { - Company company = null; + public void setOrganisationId(String companyId) { + Organisation organisation = null; if (StringUtils.isNotBlank(companyId)) { - company = allCompanies.get(companyId); + organisation = allOrganisations.get(companyId); } - sampleRow.setCompany(company); + sampleRow.setOrganisation(organisation); } public Set<String> getDcf5CodesIds() { @@ -216,12 +216,12 @@ public class UpdateSampleRowCommand implements Serializable{ this.allFishingZones = allFishingZones; } - public ImmutableMap<String, Company> getAllCompanies() { - return allCompanies; + public ImmutableMap<String, Organisation> getAllOrganisations() { + return allOrganisations; } - public void setAllCompanies(ImmutableMap<String, Company> allCompanies) { - this.allCompanies = allCompanies; + public void setAllOrganisations(ImmutableMap<String, Organisation> allOrganisations) { + this.allOrganisations = allOrganisations; } public ImmutableMap<String, Dcf5Code> getAllDcf5Codes() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java index e3c1806..fa8a3bf 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java @@ -41,11 +41,11 @@ public class ObsMerFixtures extends WaoFixtures { } public AuthenticatedWaoUser admin() { - return newAuthenticatedWaoUser("admin", ObsProgram.OBSMER, UserRole.ADMIN); + return newAuthenticatedWaoUser("admin", ObsProgram.OBSMER, UserRole.ADMIN, ifremer()); } public AuthenticatedWaoUser jmichmuche() { - return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR); + return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR, ifremer()); } public void samplingPlan() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java index 431bcb7..5c97dd3 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java @@ -19,7 +19,15 @@ public class SclerochronologyFixtures extends WaoFixtures { } public AuthenticatedWaoUser admin() { - return newAuthenticatedWaoUser("admin", ObsProgram.SCLEROCHRONOLOGY, UserRole.ADMIN); + return newAuthenticatedWaoUser("admin", ObsProgram.SCLEROCHRONOLOGY, UserRole.ADMIN, ifremer()); + } + + public AuthenticatedWaoUser coordinator() { + return newAuthenticatedWaoUser("coordinator", ObsProgram.SCLEROCHRONOLOGY, UserRole.COORDINATOR, emh()); + } + + public AuthenticatedWaoUser observer() { + return newAuthenticatedWaoUser("observer", ObsProgram.SCLEROCHRONOLOGY, UserRole.OBSERVER, ifremer()); } public void species() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java index a729ace..b1b0c0b 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -8,6 +8,7 @@ import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.services.AbstractWaoServiceTest; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.administration.UnknownBoatRegistrationCodesException; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -66,6 +67,16 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT } @Test + public void newSampleRowsFilterMustEnsureSecurity() { + SampleRowsFilter adminFilter = service.newSampleRowsFilter(fixtures.admin()); + Assert.assertTrue(CollectionUtils.isEmpty(adminFilter.getOrganisationIds())); + + SampleRowsFilter coordinatorFilter = service.newSampleRowsFilter(fixtures.coordinator()); + Assert.assertFalse(coordinatorFilter.getOrganisationIds().isEmpty()); + Assert.assertTrue(coordinatorFilter.getOrganisationIds().contains(fixtures.coordinator().getOrganisation().getTopiaId())); + } + + @Test public void samplingPlan() { fixtures.samplingPlan(); AuthenticatedWaoUser admin = fixtures.admin(); diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java index 7279bd3..f85e3a7 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java @@ -4,7 +4,10 @@ import com.google.common.collect.Iterables; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyTopiaDao; +import fr.ifremer.wao.entity.Laboratory; +import fr.ifremer.wao.entity.LaboratoryTopiaDao; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.UserProfile; import fr.ifremer.wao.entity.UserProfileImpl; import fr.ifremer.wao.entity.UserRole; @@ -26,6 +29,8 @@ public class WaoFixtures { protected Map<String, Company> companies = new HashMap<>(); + protected Map<String, Laboratory> laboratories = new HashMap<>(); + public WaoFixtures(WaoServiceContext serviceContext) { this.serviceContext = serviceContext; } @@ -43,12 +48,26 @@ public class WaoFixtures { return company; } - protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole) { + protected Laboratory getLaboratory(String laboratoryName) { + Laboratory laboratory = laboratories.get(laboratoryName); + if (laboratory == null) { + LaboratoryTopiaDao laboratoryDao = serviceContext.getPersistenceContext().getLaboratoryDao(); + laboratory = laboratoryDao.create( + Laboratory.PROPERTY_NAME, laboratoryName, + Laboratory.PROPERTY_COMPANY, ifremer(), + Laboratory.PROPERTY_ACTIVE, true); + laboratories.put(laboratoryName, laboratory); + serviceContext.getPersistenceContext().commit(); + } + return laboratory; + } + + protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole, Organisation organisation) { WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao(); WaoUser waoUser = waoUserDao.forLoginEquals(login).findUniqueOrNull(); if (waoUser == null) { waoUser = new WaoUserImpl(); - waoUser.setOrganisation(ifremer()); + waoUser.setOrganisation(organisation); waoUser.setLogin(login); waoUser.setActive(true); UserProfile userProfile = new UserProfileImpl(); @@ -70,6 +89,10 @@ public class WaoFixtures { return getCompany("OCEANET"); } + public Laboratory emh() { + return getLaboratory("EMH"); + } + public void fishingZones() { InputStream input = null; try { diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index e540698..b17a646 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -260,6 +260,7 @@ wao.ui.field.SampleRow.nbObservants=Number of observers wao.ui.field.SampleRow.observationType=Observation type wao.ui.field.SampleRow.observationUnit=Observation unit wao.ui.field.SampleRow.observers=Observers +wao.ui.field.SampleRow.organisation=Organisation wao.ui.field.SampleRow.other=Other wao.ui.field.SampleRow.periodBegin=Begin wao.ui.field.SampleRow.periodEnd=End diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 0726cc6..e7d66ba 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -261,6 +261,7 @@ wao.ui.field.SampleRow.nbObservants=Nombre d'observateurs wao.ui.field.SampleRow.observationType=Type d'observation wao.ui.field.SampleRow.observationUnit=Unité d'observation wao.ui.field.SampleRow.observers=Observateurs +wao.ui.field.SampleRow.organisation=Organisation wao.ui.field.SampleRow.other=Autre wao.ui.field.SampleRow.periodBegin=Début wao.ui.field.SampleRow.periodEnd=Fin diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp index ab8ccd4..0b3bc70 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp @@ -260,11 +260,11 @@ cssClass="input-small" /> </s:if> - <s:select name="updateSampleRowCommand.companyId" - label="%{getText('wao.ui.field.SampleRow.company')}" + <s:select name="updateSampleRowCommand.organisationId" + label="%{getText('wao.ui.field.SampleRow.organisation')}" disabled="updateSampleRowCommand.observationAlreadyStarted" - list="updateSampleRowCommand.allCompanies" - listValue="%{value.name}" + list="updateSampleRowCommand.allOrganisations" + listValue="%{value.fullName}" cssClass="input-xxlarge" /> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm