branch feature/6575 created (now 3cf2fbc)
This is an automated email from the git hooks/post-receive script. New change to branch feature/6575 in repository tutti. See http://git.codelutin.com/tutti.git at 3cf2fbc start of #6575 This branch includes the following new commits: new 3cf2fbc start of #6575 The 1 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 3cf2fbcfbaac8a048247e518d27cbf03045b36f8 Author: Kevin Morin <morin@codelutin.com> Date: Thu Jan 29 15:47:32 2015 +0100 start of #6575 -- 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/6575 in repository tutti. See http://git.codelutin.com/tutti.git commit 3cf2fbcfbaac8a048247e518d27cbf03045b36f8 Author: Kevin Morin <morin@codelutin.com> Date: Thu Jan 29 15:47:32 2015 +0100 start of #6575 --- .../tutti/persistence/TuttiPersistenceImpl.java | 10 ++ .../persistence/TuttiPersistenceNoDbImpl.java | 10 ++ .../service/BenthosBatchPersistenceService.java | 10 ++ .../BenthosBatchPersistenceServiceImpl.java | 24 ++++ .../service/SpeciesBatchPersistenceService.java | 10 ++ .../SpeciesBatchPersistenceServiceImpl.java | 24 ++++ .../ifremer/tutti/service/PersistenceService.java | 10 ++ .../toconfirmreport/ToConfirmReportOperation.java | 50 +++++++++ .../toconfirmreport/ToConfirmReportService.java | 125 +++++++++++++++++++++ .../resources/ftl/toConfirmSpeciesReport_fr.ftl | 121 ++++++++++++++++++++ .../src/main/filtered-resources/log4j.properties | 5 +- .../filtered-resources/tutti-help-fr.properties | 26 +---- .../fr/ifremer/tutti/ui/swing/TuttiUIContext.java | 5 + .../SpeciesToConfirmReportForCruiseAction.java | 103 +++++++++++++++++ .../tutti/ui/swing/content/home/SelectCruiseUI.css | 10 +- .../ui/swing/content/home/SelectCruiseUI.jaxx | 1 + .../resources/i18n/tutti-ui-swing_en_GB.properties | 2 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 2 + 18 files changed, 521 insertions(+), 27 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java index 3195d44..b1095f0 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java @@ -975,6 +975,11 @@ public class TuttiPersistenceImpl implements TuttiPersistence { } @Override + public List<SpeciesBatch> getAllSpeciesBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + return getSpeciesBatchService().getAllSpeciesBatchToConfirm(fishingOperationId); + } + + @Override public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) { return getSpeciesBatchService().getAllSpeciesBatchFrequency(speciesBatchId); } @@ -1024,6 +1029,11 @@ public class TuttiPersistenceImpl implements TuttiPersistence { } @Override + public List<BenthosBatch> getAllBenthosBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + return getBenthosBatchService().getAllBenthosBatchToConfirm(fishingOperationId); + } + + @Override public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) { return getBenthosBatchService().getAllBenthosBatchFrequency(benthosBatchId); } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java index 0e21672..aa59651 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java @@ -549,6 +549,11 @@ public class TuttiPersistenceNoDbImpl implements TuttiPersistence { } @Override + public List<SpeciesBatch> getAllSpeciesBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + throw notImplemented(); + } + + @Override public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) { throw notImplemented(); } @@ -594,6 +599,11 @@ public class TuttiPersistenceNoDbImpl implements TuttiPersistence { } @Override + public List<BenthosBatch> getAllBenthosBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + throw notImplemented(); + } + + @Override public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) { throw notImplemented(); } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java index 0932219..430a2b5 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java @@ -81,6 +81,16 @@ public interface BenthosBatchPersistenceService extends TuttiPersistenceServiceI @Transactional(readOnly = false) void changeBenthosBatchSpecies(String batchId, Species species); + /** + * Get all the batches to confirm + * + * @param fishingOperationId if of the fishing operation to seek + * @return the list of {@link fr.ifremer.tutti.persistence.entities.data.BenthosBatch} to confirm + * @throws InvalidBatchModelException if batch does not respect the sample category model + * @since 3.13 + */ + List<BenthosBatch> getAllBenthosBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException; + //------------------------------------------------------------------------// //-- BenthosBatchFrequency methods --// //------------------------------------------------------------------------// diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java index 86ac8d6..8db972f 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java @@ -53,6 +53,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -225,6 +226,29 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi batchHelper.changeBatchSpecies(id, species); } + @Override + public List<BenthosBatch> getAllBenthosBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + List<BenthosBatch> batchesToConfirm = new ArrayList<>(); + + BatchContainer<BenthosBatch> rootBenthosBatch = getRootBenthosBatch(fishingOperationId, false); + for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) { + findBenthosBatchesToConfirm(benthosBatch, batchesToConfirm); + } + + return batchesToConfirm; + } + + protected void findBenthosBatchesToConfirm(BenthosBatch benthosBatch, List<BenthosBatch> batchesToConfirm) { + if (benthosBatch.isSpeciesToConfirm()) { + batchesToConfirm.add(benthosBatch); + + } else if (!benthosBatch.isChildBatchsEmpty()) { + for (BenthosBatch batch : benthosBatch.getChildBatchs()) { + findBenthosBatchesToConfirm(batch, batchesToConfirm); + } + } + } + //------------------------------------------------------------------------// //-- BenthosBatchFrequency methods (for benthos) --// //------------------------------------------------------------------------// diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java index 39a665b..8975c2c 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java @@ -83,6 +83,16 @@ public interface SpeciesBatchPersistenceService extends TuttiPersistenceServiceI @Transactional(readOnly = false) void changeSpeciesBatchSpecies(String batchId, Species species); + /** + * Get all the batches to confirm + * + * @param fishingOperationId if of the fishing operation to seek + * @return the list of {@link SpeciesBatch} to confirm + * @throws InvalidBatchModelException if batch does not respect the sample category model + * @since 3.13 + */ + List<SpeciesBatch> getAllSpeciesBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException; + //------------------------------------------------------------------------// //-- SpeciesBatchFrequency methods --// //------------------------------------------------------------------------// diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java index c91d502..4b97288 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java @@ -53,6 +53,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -234,6 +235,29 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi batchHelper.changeBatchSpecies(id, species); } + @Override + public List<SpeciesBatch> getAllSpeciesBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + List<SpeciesBatch> batchesToConfirm = new ArrayList<>(); + + BatchContainer<SpeciesBatch> rootSpeciesBatch = getRootSpeciesBatch(fishingOperationId, false); + for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { + findSpeciesBatchesToConfirm(speciesBatch, batchesToConfirm); + } + + return batchesToConfirm; + } + + protected void findSpeciesBatchesToConfirm(SpeciesBatch speciesBatch, List<SpeciesBatch> batchesToConfirm) { + if (speciesBatch.isSpeciesToConfirm()) { + batchesToConfirm.add(speciesBatch); + + } else if (!speciesBatch.isChildBatchsEmpty()) { + for (SpeciesBatch batch : speciesBatch.getChildBatchs()) { + findSpeciesBatchesToConfirm(batch, batchesToConfirm); + } + } + } + //------------------------------------------------------------------------// //-- SpeciesBatchFrequency methods --// //------------------------------------------------------------------------// diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java index a7ce38b..8de0b69 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java @@ -1393,6 +1393,11 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override + public List<SpeciesBatch> getAllSpeciesBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + return driver.getAllSpeciesBatchToConfirm(fishingOperationId); + } + + @Override public List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId) { return driver.getAllSpeciesBatchFrequency(speciesBatchId); } @@ -1444,6 +1449,11 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override + public List<BenthosBatch> getAllBenthosBatchToConfirm(String fishingOperationId) throws InvalidBatchModelException { + return driver.getAllBenthosBatchToConfirm(fishingOperationId); + } + + @Override public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) { return driver.getAllBenthosBatchFrequency(benthosBatchId); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportOperation.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportOperation.java new file mode 100644 index 0000000..abaa627 --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportOperation.java @@ -0,0 +1,50 @@ +package fr.ifremer.tutti.service.toconfirmreport; + +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; + +import java.util.List; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.13 + */ +public class ToConfirmReportOperation { + + protected String operation; + protected List<SpeciesBatch> speciesBatches; + protected List<BenthosBatch> benthosBatches; + + public ToConfirmReportOperation() { + } + + public ToConfirmReportOperation(String operation, List<SpeciesBatch> speciesBatches, List<BenthosBatch> benthosBatches) { + this.operation = operation; + this.speciesBatches = speciesBatches; + this.benthosBatches = benthosBatches; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public List<SpeciesBatch> getSpeciesBatches() { + return speciesBatches; + } + + public void setSpeciesBatches(List<SpeciesBatch> speciesBatches) { + this.speciesBatches = speciesBatches; + } + + public List<BenthosBatch> getBenthosBatches() { + return benthosBatches; + } + + public void setBenthosBatches(List<BenthosBatch> benthosBatches) { + this.benthosBatches = benthosBatches; + } +} diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportService.java new file mode 100644 index 0000000..15ed549 --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/toconfirmreport/ToConfirmReportService.java @@ -0,0 +1,125 @@ +package fr.ifremer.tutti.service.toconfirmreport; + +import fr.ifremer.tutti.persistence.InvalidBatchModelException; +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.Cruise; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.AbstractTuttiService; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PdfGeneratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.TuttiServiceContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.File; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.13 + */ +public class ToConfirmReportService extends AbstractTuttiService { + + private static final Log log = LogFactory.getLog(ToConfirmReportService.class); + + protected PersistenceService persistenceService; + protected DecoratorService decoratorService; + protected PdfGeneratorService pdfGeneratorService; + + @Override + public void setServiceContext(TuttiServiceContext context) { + super.setServiceContext(context); + persistenceService = getService(PersistenceService.class); + decoratorService = getService(DecoratorService.class); + pdfGeneratorService = getService(PdfGeneratorService.class); + } + + public void createToConfirmReport(String cruiseId, Locale locale) { + + Cruise cruise = persistenceService.getCruise(cruiseId); + if (log.isDebugEnabled()) { + log.debug("Cruise " + decoratorService.getDecorator(cruise).toString(cruise)); + } + + List<ToConfirmReportOperation> toConfirmReportOperations = new ArrayList<>(); + + List<FishingOperation> allFishingOperation = persistenceService.getAllFishingOperation(cruiseId); + for (FishingOperation fishingOperation : allFishingOperation) { + + if (log.isDebugEnabled()) { + log.debug("|- Operation " + decoratorService.getDecorator(fishingOperation).toString(fishingOperation)); + } + + String operationId = fishingOperation.getId(); + + boolean withCatchBath = persistenceService.isFishingOperationWithCatchBatch(operationId); + + List<SpeciesBatch> speciesBatchesToConfirm = null; + List<BenthosBatch> benthosBatchesToConfirm = null; + + if (withCatchBath) { + + // load it + try { + speciesBatchesToConfirm = persistenceService.getAllSpeciesBatchToConfirm(operationId); + for (SpeciesBatch speciesBatch : speciesBatchesToConfirm) { + if (log.isDebugEnabled()) { + Species species = speciesBatch.getSpecies(); + Serializable sampleCategoryValue = speciesBatch.getSampleCategoryValue(); + log.debug(" |- " + decoratorService.getDecorator(species).toString(species) + + " / " + decoratorService.getDecorator(sampleCategoryValue).toString(sampleCategoryValue)); + } + } + + benthosBatchesToConfirm = persistenceService.getAllBenthosBatchToConfirm(operationId); + for (BenthosBatch benthosBatch : benthosBatchesToConfirm) { + if (log.isDebugEnabled()) { + Species species = benthosBatch.getSpecies(); + Serializable sampleCategoryValue = benthosBatch.getSampleCategoryValue(); + log.debug(" |- " + decoratorService.getDecorator(species).toString(species) + + " / " + decoratorService.getDecorator(sampleCategoryValue).toString(sampleCategoryValue)); + } + } + + } catch (InvalidBatchModelException e) { + + // batch is not compatible with Tutti + if (log.isDebugEnabled()) { + log.debug("Invalid batch model", e); + } + } + + } else { + if (log.isDebugEnabled()) { + log.debug(" |- No catchBatch "); + } + } + + String operation = decoratorService.getDecorator(fishingOperation).toString(fishingOperation); + ToConfirmReportOperation toConfirmReportOperation = new ToConfirmReportOperation(operation, speciesBatchesToConfirm, benthosBatchesToConfirm); + toConfirmReportOperations.add(toConfirmReportOperation); + } + + + generatePdf(new File("/tmp/test.pdf"), locale, decoratorService.getDecorator(cruise).toString(cruise), toConfirmReportOperations); + + } + + protected void generatePdf(File targetFile, Locale locale, String cruiseName, List<ToConfirmReportOperation> toConfirmReportOperations) { + + Map<String, Object> data = new HashMap<>(); + data.put("cruise", cruiseName); + data.put("operations", toConfirmReportOperations); + + pdfGeneratorService.generatePdf(targetFile, locale, "toConfirmSpeciesReport.ftl", data); + + } +} diff --git a/tutti-service/src/main/resources/ftl/toConfirmSpeciesReport_fr.ftl b/tutti-service/src/main/resources/ftl/toConfirmSpeciesReport_fr.ftl new file mode 100644 index 0000000..7d84b28 --- /dev/null +++ b/tutti-service/src/main/resources/ftl/toConfirmSpeciesReport_fr.ftl @@ -0,0 +1,121 @@ +<#-- + #%L + Tutti :: Service + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 - 2014 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% +--> +<html> + <head> + <style type="text/css"> + + <#assign blueColor="#000080"> + + h1, h4 { + color: ${blueColor}; + font-weight: bold; + font-style: italic; + } + + th { + color: ${blueColor}; + font-weight: bold; + } + + td, th { + padding-right: 10pt; + } + + td.number { + text-align: right; + } + + .operationInfo { + font-weight: bold; + } + + .label { + color: ${blueColor}; + } + + .value { + margin-right: 50pt; + } + + </style> + </head> + <body> + + <h1>Rapport des espèces à confirmer</h1> + + <h2>${cruise}</h2> + + <#list operations as operation> + + <p class='operationInfo'> + <span class="label">Opération :</span> <span class="value">${operation.operation}</span> + </p> + + <#if operation.speciesBatches??> + <h4>Espèces :</h4> + + <table> + <tr> + <th>Espèce</th> + <th>Catégorie</th> + <th>Poids</th> + <th>Commentaire</th> + </tr> + + <#list operation.speciesBatches as batch> + <tr> + <td>${batch.species}</td> + <td></td><td></td> + <td>${batch.comment!""}</td> + </tr> + </#list> + </table> + + </#if> + + <#if operation.benthosBatches??> + <h4>Benthos :</h4> + <table> + <tr> + <th>Espèce</th> + <th>Catégorie</th> + <th>Poids</th> + <th>Commentaire</th> + </tr> + + <#list operation.benthosBatches as batch> + <tr> + <td>${batch.species}</td> + <td></td><td></td> + <td>${batch.comment!""}</td> + </tr> + </#list> + </table> + + </#if> + + </#list> + + </body> +</html> diff --git a/tutti-ui-swing/src/main/filtered-resources/log4j.properties b/tutti-ui-swing/src/main/filtered-resources/log4j.properties index f7dd83d..3792874 100644 --- a/tutti-ui-swing/src/main/filtered-resources/log4j.properties +++ b/tutti-ui-swing/src/main/filtered-resources/log4j.properties @@ -31,12 +31,13 @@ log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p (%c:%L) - %m%n # tutti levels log4j.logger.fr.ifremer=INFO -log4j.logger.fr.ifremer.tutti.persistence.service.util.BatchTreeHelper=DEBUG +#log4j.logger.fr.ifremer.tutti.persistence.service.util.BatchTreeHelper=DEBUG +log4j.logger.fr.ifremer.tutti.service.toconfirmreport=DEBUG #See https://forum.hibernate.org/viewtopic.php?p=2404391 log4j.logger.org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog=ERROR log4j.logger.fr.ifremer.adagio.core.service.technical.synchro=DEBUG -log4j.logger.fr.ifremer.tutti.persistence.service.CatchBatchPersistenceServiceImpl=DEBUG +#log4j.logger.fr.ifremer.tutti.persistence.service.CatchBatchPersistenceServiceImpl=DEBUG log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.file=${tutti.log.file} diff --git a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties index 1fa9eb7..cd85432 100644 --- a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties +++ b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties @@ -1,28 +1,5 @@ -### -# #%L -# Tutti :: UI -# $Id:$ -# $HeadURL:$ -# %% -# Copyright (C) 2012 - 2014 Ifremer -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU 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 General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Mon Dec 08 18:37:45 CET 2014 +#Thu Jan 29 11:48:31 CET 2015 \ "tutti.editProtocol.action.addCaracteristicMapping.help"\ = tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -420,6 +397,7 @@ tutti.selectCruise.action.newCruise.help=selectCruise.html\#actions tutti.selectCruise.action.newProgram.help=selectCruise.html\#actions tutti.selectCruise.action.newProtocol.help=selectCruise.html\#actions tutti.selectCruise.action.sendCruiseReport.help=selectCruise.html\#actions +tutti.selectCruise.action.speciesToConfirmReportForCruise.help= tutti.selectCruise.action.validateCatches.help=selectCruise.html\#actions tutti.selectCruise.action.validateCruise.help=selectCruise.html\#actions tutti.selectCruise.field.cruise.help=selectCruise.html\#fields diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java index d23d363..6e4284f 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java @@ -53,6 +53,7 @@ import fr.ifremer.tutti.service.referential.ReferentialTemporarySpeciesService; import fr.ifremer.tutti.service.referential.ReferentialTemporaryVesselService; import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService; import fr.ifremer.tutti.service.report.ReportService; +import fr.ifremer.tutti.service.toconfirmreport.ToConfirmReportService; import fr.ifremer.tutti.ui.swing.content.MainUI; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.UIMessageNotifier; @@ -721,6 +722,10 @@ public class TuttiUIContext extends AbstractBean implements Closeable, UIMessage return serviceContext.getService(CatchesPdfExportService.class); } + public ToConfirmReportService getToConfirmReportService() { + return serviceContext.getService(ToConfirmReportService.class); + } + public TuttiExportService getTuttiExportService() { return serviceContext.getService(TuttiExportService.class); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SpeciesToConfirmReportForCruiseAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SpeciesToConfirmReportForCruiseAction.java new file mode 100644 index 0000000..8828a97 --- /dev/null +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SpeciesToConfirmReportForCruiseAction.java @@ -0,0 +1,103 @@ +package fr.ifremer.tutti.ui.swing.action; + +/* + * #%L + * Tutti :: UI + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.base.Preconditions; +import fr.ifremer.tutti.persistence.entities.data.Cruise; +import fr.ifremer.tutti.service.toconfirmreport.ToConfirmReportService; +import fr.ifremer.tutti.ui.swing.content.MainUIHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.File; + +import static org.nuiton.i18n.I18n.t; + +/** + * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor. + * + * @author kmorin <morin@codelutin.com> + * @since 1.0 + */ +public class SpeciesToConfirmReportForCruiseAction extends AbstractMainUITuttiAction { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(SpeciesToConfirmReportForCruiseAction.class); + + protected File file; + + public SpeciesToConfirmReportForCruiseAction(MainUIHandler handler) { + super(handler, true); + } + + @Override + public boolean prepareAction() throws Exception { + + boolean doAction = super.prepareAction(); + +// if (doAction) { +// +// Cruise cruise = getDataContext().getCruise(); +// // choose file to export +// file = saveFile( +// "exportCruise-" + cruise.getName(), +// "pdf", +// t("tutti.sendCruiseReport.title.choose.exportFile"), +// t("tutti.sendCruiseReport.action.chooseFile"), +// "^.+\\.pdf$", t("tutti.common.file.pdf") +// ); +// doAction = file != null; +// } + return doAction; + } + + @Override + public void releaseAction() { + file = null; + super.releaseAction(); + } + + @Override + public void doAction() throws Exception { + Cruise cruise = getDataContext().getCruise(); + Preconditions.checkNotNull(cruise); +// Preconditions.checkNotNull(file); + + if (log.isInfoEnabled()) { + log.info("Will export cruise " + cruise.getId() + + " to file: " + file); + } + + // create report + ToConfirmReportService toConfirmReportService = getContext().getToConfirmReportService(); + toConfirmReportService.createToConfirmReport(cruise.getId(), getConfig().getI18nLocale()); + + } + + @Override + public void postSuccessAction() { + super.postSuccessAction(); + sendMessage(t("tutti.sendCruiseReport.action.success", file)); + } +} diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css index d69cbf4..ce72706 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css @@ -102,7 +102,7 @@ BeanFilterableComboBox { } #editCruiseComboBox { - model: {SwingUtil.newComboModel(editCruiseButton, exportCruiseButton, sendCruiseReportButton, exportCruiseForSumatraButton)}; + model: {SwingUtil.newComboModel(editCruiseButton, exportCruiseButton, sendCruiseReportButton, exportCruiseForSumatraButton, speciesToConfirmReportForCruiseButton)}; enabled: {model.isProgramFound() && model.isCruiseFound()}; renderer: {new ActionListCellRenderer()}; } @@ -139,6 +139,14 @@ BeanFilterableComboBox { _help: {"tutti.selectCruise.action.exportCruiseForSumatra.help"}; } +#speciesToConfirmReportForCruiseButton { + actionIcon: report; + text: "tutti.selectCruise.action.speciesToConfirmReportForCruise"; + toolTipText: "tutti.selectCruise.action.speciesToConfirmReportForCruise.tip"; + _applicationAction: {fr.ifremer.tutti.ui.swing.action.SpeciesToConfirmReportForCruiseAction.class}; + _help: {"tutti.selectCruise.action.speciesToConfirmReportForCruise.help"}; +} + #newCruiseButton { actionIcon: add; text: "tutti.selectCruise.action.newCruise"; diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx index baf33f8..bbff061 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx @@ -67,6 +67,7 @@ <JButton id='exportCruiseButton'/> <JButton id='sendCruiseReportButton'/> <JButton id='exportCruiseForSumatraButton'/> + <JButton id='speciesToConfirmReportForCruiseButton'/> <JButton id='newProtocolButton'/> <JButton id='importProtocolButton'/> <JButton id='editProtocolButton'/> diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index d9182b5..f62e1ce 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -1778,6 +1778,8 @@ tutti.selectCruise.action.newProtocol= tutti.selectCruise.action.newProtocol.tip= tutti.selectCruise.action.sendCruiseReport= tutti.selectCruise.action.sendCruiseReport.tip= +tutti.selectCruise.action.speciesToConfirmReportForCruise= +tutti.selectCruise.action.speciesToConfirmReportForCruise.tip= tutti.selectCruise.action.validateCatches= tutti.selectCruise.action.validateCatches.mnemonic= tutti.selectCruise.action.validateCatches.tip= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index c01ebb9..442ddd2 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -1678,6 +1678,8 @@ tutti.selectCruise.action.newProtocol=Nouveau tutti.selectCruise.action.newProtocol.tip=Créer un nouveau protocole tutti.selectCruise.action.sendCruiseReport=Export Pdf tutti.selectCruise.action.sendCruiseReport.tip=Exporter au format pdf et envoyer par courriel +tutti.selectCruise.action.speciesToConfirmReportForCruise=Espèces à confirmer +tutti.selectCruise.action.speciesToConfirmReportForCruise.tip=Créer le rapport des espèces à confirmer pour la campagne tutti.selectCruise.action.validateCatches=Valider les captures tutti.selectCruise.action.validateCatches.mnemonic=V tutti.selectCruise.action.validateCatches.tip=Lancer le processus de validation des données -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm