branch develop updated (238d604 -> 0be4426)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository wao. See http://git.codelutin.com/wao.git from 238d604 [jgitflow-maven-plugin]Updating develop poms back to pre merge state new 2f6ddd2 Export du réalisé depuis le plan scléro (fixes #6543) new 0be4426 Fusion des modifications faites pour la release dans develop 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 0be44262ff5b8b76ccdbf996573c833aee3d94dc Merge: 2f6ddd2 238d604 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Jan 27 16:01:56 2015 +0100 Fusion des modifications faites pour la release dans develop commit 2f6ddd2bf51920abe7a5242ecdf582b45d2f75bd Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Jan 27 15:58:05 2015 +0100 Export du réalisé depuis le plan scléro (fixes #6543) Summary of changes: .../wao/services/service/SamplingPlanService.java | 16 +++ .../SclerochronologySamplingPlanService.java | 44 ++++++++ .../SclerochronologySamplingPlanExportModel.java | 116 +++++++++++++++++++++ .../ExportSamplingPlanWithStatisticsAction.java | 9 +- .../WEB-INF/content/obsmer/sampling-plan.jsp | 2 +- .../content/sclerochronology/sampling-plan.jsp | 6 ++ 6 files changed, 187 insertions(+), 6 deletions(-) create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/csv/SclerochronologySamplingPlanExportModel.java rename wao-web/src/main/java/fr/ifremer/wao/web/action/{obsmer => }/ExportSamplingPlanWithStatisticsAction.java (85%) -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 2f6ddd2bf51920abe7a5242ecdf582b45d2f75bd Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Jan 27 15:58:05 2015 +0100 Export du réalisé depuis le plan scléro (fixes #6543) --- .../wao/services/service/SamplingPlanService.java | 16 +++ .../SclerochronologySamplingPlanService.java | 44 ++++++++ .../SclerochronologySamplingPlanExportModel.java | 116 +++++++++++++++++++++ .../ExportSamplingPlanWithStatisticsAction.java | 9 +- .../WEB-INF/content/obsmer/sampling-plan.jsp | 2 +- .../content/sclerochronology/sampling-plan.jsp | 6 ++ 6 files changed, 187 insertions(+), 6 deletions(-) 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 8dc23e5..978fc9a 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 @@ -831,4 +831,20 @@ public class SamplingPlanService extends WaoServiceSupport { return contacts; } + + public InputStream exportSamplingPlanWithStatistics(AuthenticatedWaoUser authenticatedWaoUser, SampleRowsFilter filter) { + + InputStream csv; + if (filter.getObsProgram().isObsMer()) { + ObsMerSamplingPlanService obsMerSamplingPlanService = newService(ObsMerSamplingPlanService.class); + csv = obsMerSamplingPlanService.exportSamplingPlanWithStatistics(authenticatedWaoUser, filter); + } else if (filter.getObsProgram().isSclerochronology()) { + SclerochronologySamplingPlanService sclerochronologySamplingPlanService = newService(SclerochronologySamplingPlanService.class); + csv = sclerochronologySamplingPlanService.exportSamplingPlanWithStatistics(authenticatedWaoUser, filter); + } else { + throw new UnsupportedOperationException(filter.getObsProgram() + " is not supported"); + } + return csv; + + } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java index 22666bb..145a1d6 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java @@ -21,16 +21,24 @@ package fr.ifremer.wao.services.service; * #L% */ +import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.cache.Cache; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactTopiaDao; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowTopiaDao; import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.service.csv.SclerochronologySamplingPlanExportModel; +import org.apache.commons.io.IOUtils; +import org.nuiton.csv.Export; +import org.nuiton.csv.ExportModel; +import java.io.InputStream; import java.util.Collection; +import java.util.LinkedHashSet; import java.util.List; public class SclerochronologySamplingPlanService extends SamplingPlanService { @@ -90,4 +98,40 @@ public class SclerochronologySamplingPlanService extends SamplingPlanService { } + public InputStream exportSamplingPlanWithStatistics(AuthenticatedWaoUser authenticatedWaoUser, SampleRowsFilter filter) { + + SclerochronologySamplingPlan samplingPlan = getSamplingPlan(authenticatedWaoUser, filter); + + Collection<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> sampleRows = new LinkedHashSet<>(); + for (SamplingPlan.SamplingPlanFacadePart facade : samplingPlan) { + for (SamplingPlan.SamplingPlanSectorPart<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> sector : facade) { + for (SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart SclerochronologySampleRowPart : sector) { + sampleRows.add(SclerochronologySampleRowPart); + } + } + } + + ExportModel<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> exportModel = + new SclerochronologySamplingPlanExportModel( + getLocale(), + filter.getPeriodFrom(), + filter.getPeriodTo()); + + Export<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> export = + Export.newExport(exportModel, sampleRows); + + try { + + String csvContent = export.toString(Charsets.UTF_8); + + InputStream csvInputStream = IOUtils.toInputStream(csvContent, Charsets.UTF_8); + + return csvInputStream; + + } catch (Exception e) { + throw new WaoTechnicalException(e); + } + + } + } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/SclerochronologySamplingPlanExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/SclerochronologySamplingPlanExportModel.java new file mode 100644 index 0000000..dda6fe0 --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/SclerochronologySamplingPlanExportModel.java @@ -0,0 +1,116 @@ +package fr.ifremer.wao.services.service.csv; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * 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 fr.ifremer.wao.WaoUtils; +import fr.ifremer.wao.services.service.SclerochronologySamplingPlan; +import org.nuiton.csv.Common; +import org.nuiton.csv.ValueGetter; +import org.nuiton.csv.ext.AbstractExportModel; +import org.nuiton.util.PeriodDates; + +import java.util.Collection; +import java.util.Date; +import java.util.Locale; + +public class SclerochronologySamplingPlanExportModel extends AbstractExportModel<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> { + + public SclerochronologySamplingPlanExportModel(Locale locale, Date periodFrom, Date periodTo) { + + super(';'); + + Common.DateValue monthYearFormatter = + new Common.DateValue(WaoUtils.getMonthPattern(locale)); + + modelBuilder.newColumnForExport("PLAN_CODE", "code"); + modelBuilder.newColumnForExport("ORGANISATION_NOM", "organisationFullName"); + modelBuilder.newColumnForExport("PROGRAMME_CODE", "programName"); + modelBuilder.newColumnForExport("PROGRAMME_DEBUT", "periodBegin", monthYearFormatter); + modelBuilder.newColumnForExport("PROGRAMME_DEBUT", "periodEnd", monthYearFormatter); + modelBuilder.newColumnForExport("PECHE_FACADE", "facade"); + modelBuilder.newColumnForExport("PECHE_ZONE", "sectors"); + modelBuilder.newColumnForExport("ZONES_PECHE", "fishingZones"); + modelBuilder.newColumnForExport("ZONES_PECHE_INFOS", "fishingZonesInfos"); + modelBuilder.newColumnForExport("ZONES_PECHE_INFOS", "fishingZonesInfos"); + modelBuilder.newColumnForExport("ESPECE_CIBLE", "species"); + modelBuilder.newColumnForExport("CONTEXTE", "samplingContext"); + modelBuilder.newColumnForExport("CONTEXTE_COMPLEMENT", "samplingContextInfo"); + modelBuilder.newColumnForExport("MESURES", "individualMeasurementStrategy"); + + Collection<Date> months = new PeriodDates(periodFrom, periodTo).getMonths(); + + for (Date month : months) { + String headerName = monthYearFormatter.format(month); + modelBuilder.newColumnForExport(headerName + "_EFFORT_INDIVIDUS", new ExpectedIndividualsValueGetter(month), Common.INTEGER); + modelBuilder.newColumnForExport(headerName + "_ESTIME_INDIVIDUS", new EstimatedIndividualsValueGetter(month), Common.INTEGER); + modelBuilder.newColumnForExport(headerName + "_REALISE_INDIVIDUS", new RealIndividualsValueGetter(month), Common.INTEGER); + } + + modelBuilder.newColumnForExport("TOTAL_EFFORT", "totalIndividuals.expected", Common.INTEGER); + modelBuilder.newColumnForExport("TOTAL_ESTIME", "totalIndividuals.estimated", Common.INTEGER); + modelBuilder.newColumnForExport("TOTAL_REALISE", "totalIndividuals.real", Common.INTEGER); + + } + + protected static class ExpectedIndividualsValueGetter implements ValueGetter<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart, Integer> { + + protected Date month; + + public ExpectedIndividualsValueGetter(Date month) { + this.month = month; + } + + @Override + public Integer get(SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart sampleRowPart) { + return sampleRowPart.getEffortInIndividualsPerMonths().get(month).getExpected(); + } + } + + protected static class EstimatedIndividualsValueGetter implements ValueGetter<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart, Integer> { + + protected Date month; + + public EstimatedIndividualsValueGetter(Date month) { + this.month = month; + } + + @Override + public Integer get(SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart sampleRowPart) { + return sampleRowPart.getEffortInIndividualsPerMonths().get(month).getEstimated(); + } + } + + protected static class RealIndividualsValueGetter implements ValueGetter<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart, Integer> { + + protected Date month; + + public RealIndividualsValueGetter(Date month) { + this.month = month; + } + + @Override + public Integer get(SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart sampleRowPart) { + return sampleRowPart.getEffortInIndividualsPerMonths().get(month).getReal(); + } + } + +} diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportSamplingPlanWithStatisticsAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportSamplingPlanWithStatisticsAction.java similarity index 85% rename from wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportSamplingPlanWithStatisticsAction.java rename to wao-web/src/main/java/fr/ifremer/wao/web/action/ExportSamplingPlanWithStatisticsAction.java index d6e5422..8efa03a 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/ExportSamplingPlanWithStatisticsAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/ExportSamplingPlanWithStatisticsAction.java @@ -1,4 +1,4 @@ -package fr.ifremer.wao.web.action.obsmer; +package fr.ifremer.wao.web.action; /* * #%L @@ -23,8 +23,7 @@ package fr.ifremer.wao.web.action.obsmer; import com.opensymphony.xwork2.Preparable; import fr.ifremer.wao.SampleRowsFilter; -import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; -import fr.ifremer.wao.web.action.AbstractDownloadCsvAction; +import fr.ifremer.wao.services.service.SamplingPlanService; import java.io.InputStream; import java.util.Date; @@ -33,11 +32,11 @@ public class ExportSamplingPlanWithStatisticsAction extends AbstractDownloadCsvA private static final long serialVersionUID = 1L; - protected transient ObsMerSamplingPlanService service; + protected transient SamplingPlanService service; protected SampleRowsFilter filter; - public void setService(ObsMerSamplingPlanService service) { + public void setService(SamplingPlanService service) { this.service = service; } diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index bc7bc74..f846885 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -175,7 +175,7 @@ </s:if> <s:if test="authenticatedWaoUser.authorizedToExportSamplingPlanWithStatistics"> - <s:submit namespace="/obsmer" action="export-sampling-plan-with-statistics" type="button" cssClass="btn"> + <s:submit action="export-sampling-plan-with-statistics" type="button" cssClass="btn"> <i class="icon-download"></i> <s:text name="wao.ui.action.exportSamplingPlanCsvWithStatistics" /> </s:submit> </s:if> diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index 72da63c..ea2e8a1 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -155,6 +155,12 @@ </s:submit> </s:if> + <s:if test="authenticatedWaoUser.authorizedToExportSamplingPlanWithStatistics"> + <s:submit action="export-sampling-plan-with-statistics" type="button" cssClass="btn"> + <i class="icon-download"></i> <s:text name="wao.ui.action.exportSamplingPlanCsvWithStatistics" /> + </s:submit> + </s:if> + </div> </s:form> -- 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 develop in repository wao. See http://git.codelutin.com/wao.git commit 0be44262ff5b8b76ccdbf996573c833aee3d94dc Merge: 2f6ddd2 238d604 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Jan 27 16:01:56 2015 +0100 Fusion des modifications faites pour la release dans develop pom.xml | 2 +- .../java/fr/ifremer/wao/AbstractWaoTopiaDao.java | 21 +++++++++++++++++++++ .../wao/entity/IndividualMeasurementStrategy.java | 21 +++++++++++++++++++++ .../java/fr/ifremer/wao/entity/LaboratoryImpl.java | 21 +++++++++++++++++++++ .../java/fr/ifremer/wao/entity/Organisations.java | 21 +++++++++++++++++++++ .../wao/entity/SclerochronologySamplingContext.java | 21 +++++++++++++++++++++ .../main/java/fr/ifremer/wao/entity/Specieses.java | 21 +++++++++++++++++++++ .../service/IllegalSampleReceptionException.java | 21 +++++++++++++++++++++ .../service/IllegalSampleSizeException.java | 21 +++++++++++++++++++++ .../service/IllegalSampleSubmissionException.java | 21 +++++++++++++++++++++ .../service/IllegalSampleTreatmentException.java | 21 +++++++++++++++++++++ ...ssingIndividualMeasurementStrategyException.java | 21 +++++++++++++++++++++ .../service/MissingSampleReceptionException.java | 21 +++++++++++++++++++++ .../service/MissingSampleSizeException.java | 21 +++++++++++++++++++++ .../service/MissingSampleSubmissionException.java | 21 +++++++++++++++++++++ ...ingSclerochronologySamplingContextException.java | 21 +++++++++++++++++++++ .../services/service/MissingSpeciesException.java | 21 +++++++++++++++++++++ .../service/administration/LaboratoriesService.java | 21 +++++++++++++++++++++ .../administration/OrganisationsService.java | 21 +++++++++++++++++++++ .../service/administration/WaoUsersList.java | 21 +++++++++++++++++++++ .../services/service/csv/SpeciesImportModel.java | 21 +++++++++++++++++++++ .../csv/operations/SpeciesParserFormatter.java | 21 +++++++++++++++++++++ .../services/service/SclerochronologyFixtures.java | 21 +++++++++++++++++++++ .../SclerochronologySamplingPlanServiceTest.java | 21 +++++++++++++++++++++ .../ifremer/wao/services/service/WaoFixtures.java | 21 +++++++++++++++++++++ .../action/administration/ImportSpeciesAction.java | 21 +++++++++++++++++++++ .../SamplingPlanAction-conversion.properties | 20 ++++++++++++++++++++ 27 files changed, 546 insertions(+), 1 deletion(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm