Author: tchemit Date: 2013-03-13 08:33:30 +0100 (Wed, 13 Mar 2013) New Revision: 601 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/601 Log: fixes #2067: [CAPTURE] - Rendre configurable la modification de l'arbre d'?\195?\169chantillonage Removed: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/ Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-03-13 07:33:30 UTC (rev 601) @@ -389,17 +389,15 @@ /** * Get the catchBatch from the fishing Operation id. * <p/> - * If batch model is not compatible with Tutti and {@code canRepair} flag - * is on, then it will try to repair it. + * If batch model is not compatible with Tutti then a + * {@link InvalidBatchModelException} will be thrown. * - * @param id id of the fihsing operation - * @param canRepair flag to try to repair the batch model in not in Tutti-awre format. + * @param id id of the fihsing operation * @return found catchbatch - * @throws InvalidBatchModelException if batch model is not compatible with Tutti and could be repaired (in cause of canRepair is on). + * @throws InvalidBatchModelException if batch model is not compatible + * with Tutti. */ - @Transactional(readOnly = false) - CatchBatch getCatchBatchFromFishingOperation(String id, - boolean canRepair) throws InvalidBatchModelException; + CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException; /** * Create the given CatchBatch and return it. Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-03-13 07:33:30 UTC (rev 601) @@ -491,12 +491,12 @@ //------------------------------------------------------------------------// @Override - public CatchBatch getCatchBatchFromFishingOperation(String id, - boolean canRepair) throws InvalidBatchModelException { + public CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException { try { - return batchService.getCatchBatchFromFishingOperation(id, canRepair); + return batchService.getCatchBatchFromFishingOperation(id); } catch (CatchBatchValidationException e) { - throw new InvalidBatchModelException("L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e); + throw new InvalidBatchModelException( + "L'arbre d'échantillonage n'est pas compatible avec celui de Tutti.", e); } } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-03-13 07:33:30 UTC (rev 601) @@ -320,7 +320,7 @@ } @Override - public CatchBatch getCatchBatchFromFishingOperation(String id, boolean canRepair) { + public CatchBatch getCatchBatchFromFishingOperation(String id) { throw new RuntimeException("method not implemented"); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-13 07:33:30 UTC (rev 601) @@ -25,7 +25,6 @@ */ -import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao; import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -38,39 +37,20 @@ import java.util.List; @Transactional(readOnly = true) -public interface - BatchPersistenceService extends TuttiPersistenceServiceImplementor { +public interface BatchPersistenceService extends TuttiPersistenceServiceImplementor { //------------------------------------------------------------------------// //-- CatchBatch methods --// //------------------------------------------------------------------------// /** - * Used to initialize a catch when fixing it. - * - * @param catchBatch (original batch to fix) - * @param keepTotalWeight flag to keep weight assigned on catch batch - */ - void cleanEntity(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch, - boolean keepTotalWeight); - - /** - * Used to mock dao in unit tests. - * - * @param dao dao to use - */ - void setCatchBatchDao(CatchBatchExtendDao dao); - - /** * Get the catchBatch from the fishing Operation id. * * @param fishingOperationId id of the fihsing operation - * @return found catchbatch + * @return found catchBatch * @throws CatchBatchValidationException */ - @Transactional(readOnly = false) - CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId, - boolean tryToRepair) throws CatchBatchValidationException; + CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException; /** * Create the given CatchBatch and return it. Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-13 07:33:30 UTC (rev 601) @@ -44,7 +44,6 @@ import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -105,14 +104,14 @@ //------------------------------------------------------------------------// @Override - public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId, - boolean tryToRepair) throws CatchBatchValidationException { + public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException { Preconditions.checkNotNull(fishingOperationId); Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId)); fr.ifremer.adagio.core.dao.data.batch.CatchBatch source; - source = catchBatchDao.loadFullTree(catchBatchId, true, tryToRepair); + // wenever want to repair anything from Tutti + source = catchBatchDao.loadFullTree(catchBatchId, true, false); CatchBatch result = new CatchBatch(); result.setId(source.getId().toString()); @@ -192,41 +191,6 @@ } @Override - public void cleanEntity(fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch, - boolean keepTotalWeight) { - - Preconditions.checkNotNull(catchBatch); - Preconditions.checkNotNull(catchBatch.getChildBatchs()); - - for (Batch batch : catchBatch.getChildBatchs()) { - catchBatchDao.removeWithChildren(batch.getId(), catchBatch); - } - catchBatch.getChildBatchs().clear(); - - // Create a new tutti bean CatchBatch, need for method beanToEntity() - fr.ifremer.tutti.persistence.entities.data.CatchBatch bean = new fr.ifremer.tutti.persistence.entities.data.CatchBatch(); - bean.setId(catchBatch.getId().toString()); - - // Link the bean to a fake fishingOperation, need in the preconditions for method beanToEntity() - FishingOperation fishingOperation = new FishingOperation(); - fishingOperation.setId(catchBatch.getFishingOperation().getId().toString()); - bean.setFishingOperation(fishingOperation); - - // If need, copy the total weight, to be sure beanToEntity() will restore it - if (keepTotalWeight) { - bean.setCatchTotalWeight(catchBatch.getWeight()); - } - - beanToEntity(bean, catchBatch, true); - } - - @Override - public void setCatchBatchDao(CatchBatchExtendDao catchBatchDao) { - this.catchBatchDao = catchBatchDao; - } - - - @Override public CatchBatch createCatchBatch(CatchBatch bean) { Preconditions.checkNotNull(bean); Preconditions.checkArgument(bean.getId() == null); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-03-13 07:33:30 UTC (rev 601) @@ -25,11 +25,8 @@ */ -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.data.batch.Batch; -import fr.ifremer.adagio.core.dao.data.batch.CatchBatch; import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao; import fr.ifremer.adagio.core.dao.data.batch.SortingBatch; import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchQuickFix; @@ -41,11 +38,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Component; import java.util.Collection; -import java.util.HashSet; import java.util.List; import static org.nuiton.i18n.I18n._; @@ -161,8 +156,6 @@ addWarning(errors, n_("tutti.persistence.batch.validation.horsVracSpeciesNotFound")); } - //FIXME - make this work with data to repair :( - // Hors Vrac > Benthos SortingBatch benthosBatch = catchBatchDao.getSortingBatch(horsVracBatch.getChildBatchs(), "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); @@ -208,86 +201,81 @@ } if (allBatchHasSpecies && !someBatchHasSortingMeasurement) { errors.clear(); - addError(errors, n_("tutti.persistence.batch.validation.onlySpeciesBatchStructure"), new CatchBatchQuickFix() { - @Override - public CatchBatch repair(CatchBatch catchBatch) { - return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, false); - } - }); + addError(errors, + n_("tutti.persistence.batch.validation.onlySpeciesBatchStructure"), + null); + } else if (allBatchHasSpecies && allBatchHasVrac) { errors.clear(); - addError(errors, n_("tutti.persistence.batch.validation.onlySpeciesBatchStructure"), new CatchBatchQuickFix() { - @Override - public CatchBatch repair(CatchBatch catchBatch) { - return ScientificCruiseCatchBatchValidator.this.repairHistoricalData(catchBatch, true); - } - }); + addError(errors, + n_("tutti.persistence.batch.validation.onlySpeciesBatchStructure"), + null); } } } - /** - * Repair tree batch, when only species have been found under the cacth batch. - * This append typically with CGFS cruise. - * - * @param catchBatch - * @return - */ - protected CatchBatch repairHistoricalData(CatchBatch catchBatch, - boolean batchHasVracSortingMeasurement) { - Preconditions.checkNotNull(catchBatch); - Preconditions.checkNotNull(catchBatch.getId()); - Preconditions.checkNotNull(catchBatch.getFishingOperation()); - Preconditions.checkNotNull(catchBatch.getFishingOperation().getId()); +// /** +// * Repair tree batch, when only species have been found under the cacth batch. +// * This append typically with CGFS cruise. +// * +// * @param catchBatch +// * @return +// */ +// protected CatchBatch repairHistoricalData(CatchBatch catchBatch, +// boolean batchHasVracSortingMeasurement) { +// Preconditions.checkNotNull(catchBatch); +// Preconditions.checkNotNull(catchBatch.getId()); +// Preconditions.checkNotNull(catchBatch.getFishingOperation()); +// Preconditions.checkNotNull(catchBatch.getFishingOperation().getId()); +// +// // Copy catch batch children +// Collection<Batch> speciesBatchChilds = Sets.newHashSet(); +// speciesBatchChilds.addAll(catchBatch.getChildBatchs()); +// catchBatch.setChildBatchs(new HashSet<Batch>()); +// +// // Clean catch batch +// batchService.cleanEntity(catchBatch, true); +// +// SortingBatch speciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), +// "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, +// "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); +// if (speciesBatch == null) { +// throw new DataIntegrityViolationException("Invalid batch tree format. Could not retrieve 'Vrac>Species' batch."); +// } +// +// // For all species batch : set the batch 'Vrac>Species' as new parent +// for (Batch speciesBatchChild : speciesBatchChilds) { +// SortingBatch batch = (SortingBatch) speciesBatchChild; +// batch.setParentBatch(speciesBatch); +// +// if (batchHasVracSortingMeasurement) { +// // Remove redundant 'Vrac' sorting measurement +// SortingMeasurement sm = catchBatchDao.getSortingMeasurement(batch, enumeration.PMFM_ID_SORTED_UNSORTED, null, false); +// batch.getSortingMeasurements().remove(sm); +// } +// +// batch.setExhaustiveInventory(Boolean.TRUE); +// +// // Add an offset into the rank order, because of special batchs 'Biota' (=live) and 'Inert' +// short rankOrder = (short) (batch.getRankOrder() + 2); +// batch.setRankOrder(rankOrder); +// +// //FIXME-TC We should do nothing with this: this is not our problem... +// //TODO What to do with weird comments! categorie_individu +// // Reset comments if set to "taxon" +// if (batch.getComments() != null && "taxon".equals(batch.getComments())) { +// batch.setComments(null); +// } +// +// speciesBatch.getChildBatchs().add(batch); +// } +// +// // Save mofidifications : +// catchBatchDao.update(catchBatch); +// +// return catchBatch; +// } - // Copy catch batch children - Collection<Batch> speciesBatchChilds = Sets.newHashSet(); - speciesBatchChilds.addAll(catchBatch.getChildBatchs()); - catchBatch.setChildBatchs(new HashSet<Batch>()); - - // Clean catch batch - batchService.cleanEntity(catchBatch, true); - - SortingBatch speciesBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(), - "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, - "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); - if (speciesBatch == null) { - throw new DataIntegrityViolationException("Invalid batch tree format. Could not retrieve 'Vrac>Species' batch."); - } - - // For all species batch : set the batch 'Vrac>Species' as new parent - for (Batch speciesBatchChild : speciesBatchChilds) { - SortingBatch batch = (SortingBatch) speciesBatchChild; - batch.setParentBatch(speciesBatch); - - if (batchHasVracSortingMeasurement) { - // Remove redundant 'Vrac' sorting measurement - SortingMeasurement sm = catchBatchDao.getSortingMeasurement(batch, enumeration.PMFM_ID_SORTED_UNSORTED, null, false); - batch.getSortingMeasurements().remove(sm); - } - - batch.setExhaustiveInventory(Boolean.TRUE); - - // Add an offset into the rank order, because of special batchs 'Biota' (=live) and 'Inert' - short rankOrder = (short) (batch.getRankOrder() + 2); - batch.setRankOrder(rankOrder); - - //FIXME-TC We should do nothing with this: this is not our problem... - //TODO What to do with weird comments! categorie_individu - // Reset comments if set to "taxon" - if (batch.getComments() != null && "taxon".equals(batch.getComments())) { - batch.setComments(null); - } - - speciesBatch.getChildBatchs().add(batch); - } - - // Save mofidifications : - catchBatchDao.update(catchBatch); - - return catchBatch; - } - protected void addError(List<CatchBatchValidationError> errors, String messageKey, CatchBatchQuickFix quickFix) { Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-03-13 07:33:30 UTC (rev 601) @@ -28,13 +28,11 @@ import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException; import fr.ifremer.tutti.persistence.DatabaseResource; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; import org.junit.Ignore; @@ -81,18 +79,11 @@ @Test(expected = CatchBatchValidationException.class) public void getCatchBatchFromFishingOperation() throws Exception { + //TODO-TC Change test when data will be Tutti-aware // old CGFS tree structure is still not valid - service.getCatchBatchFromFishingOperation(fishingOperation.getId(), false); + service.getCatchBatchFromFishingOperation(fishingOperation.getId()); } - @Test - public void getCatchBatchFromFishingOperationAndRepair() throws Exception { - - // old CGFS tree structure is still not valid, but can be repair - CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId(), true); - Assert.assertNotNull(catchBatch); - } - @Ignore @Test public void getRootSpeciesBatch(/*String fishingOperationId*/) { @@ -113,7 +104,9 @@ } - public static void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) { + public static void assertSpeciesBatch(SpeciesBatch expectedBatch, + SpeciesBatch actualBatch, + boolean assertIdEquals) { assertNotNull(actualBatch); assertNotNull(actualBatch.getId()); if (assertIdEquals && expectedBatch.getId() != null) { Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-13 07:33:30 UTC (rev 601) @@ -723,7 +723,7 @@ CatchBatch reloadedCatchBatch = null; try { - reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId, false); + reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId); } catch (CatchBatchValidationException e) { Assert.fail(e.getMessage()); } @@ -740,7 +740,7 @@ CatchBatch reloadedCatchBatch = null; try { - reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId, false); + reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId); } catch (CatchBatchValidationException e) { Assert.fail(e.getMessage()); } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-03-13 07:33:30 UTC (rev 601) @@ -534,11 +534,9 @@ //------------------------------------------------------------------------// @Override - public CatchBatch getCatchBatchFromFishingOperation(String id, - boolean canRepair) throws InvalidBatchModelException { + public CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException { + return driver.getCatchBatchFromFishingOperation(id); - return driver.getCatchBatchFromFishingOperation(id, canRepair); - } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-13 07:33:30 UTC (rev 601) @@ -25,6 +25,7 @@ */ import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; @@ -516,6 +517,8 @@ attachments = Collections.emptyList(); + getModel().setCatchEnabled(true); + } else { String operationId = bean.getId(); @@ -528,14 +531,23 @@ PersistenceService persistenceService = getContext().getPersistenceService(); - batch = persistenceService.getCatchBatchFromFishingOperation( - operationId, true); - batch.setFishingOperation(bean); + try { + batch = persistenceService.getCatchBatchFromFishingOperation(operationId); + batch.setFishingOperation(bean); + Integer objectId = Integer.valueOf(batch.getId()); + attachments = persistenceService.getAllAttachments(objectId); + getModel().setCatchEnabled(true); + } catch (InvalidBatchModelException e) { - Integer objectId = Integer.valueOf(batch.getId()); + // batch is not compatible with Tutti + if (log.isDebugEnabled()) { + log.debug("Invalid batch model"); + } + batch = null; + attachments = Collections.emptyList(); - - attachments = persistenceService.getAllAttachments(objectId); + getModel().setCatchEnabled(false); + } } catchesUIModel.setCatchBatch(batch); @@ -560,7 +572,7 @@ // 4) Propagate new selected fishingoperation to others tabs - ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean); + ui.getSpeciesTabContent().getHandler().selectFishingOperation(batch == null ? null : bean); // ui.getBenthosTabContent().getHandler().selectFishingOperation(bean); // ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean); // ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-03-13 07:33:30 UTC (rev 601) @@ -52,8 +52,19 @@ _help: {"tuttihelp.fishingOperations.field.fishingOperation.help"}; } +#warningContainer { + background: {new java.awt.Color(245, 218, 88)}; + visible: {!model.isCatchEnabled()}; +} + +#warningLabel { + actionIcon: warning; + border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)}; + text: "tutti.warn.invalid.batch.model"; +} + #catchesTab { - enabled: {model.getSelectedFishingOperation() != null}; + enabled: {model.getSelectedFishingOperation() != null && model.isCatchEnabled()}; } #noTraitPane { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-03-13 07:33:30 UTC (rev 601) @@ -74,6 +74,13 @@ <JButton id='newFishingOperationButton'/> </cell> </row> + <row> + <cell columns='2'> + <JPanel id='warningContainer' layout='{new BorderLayout(10, 10)}'> + <JLabel id='warningLabel' constraints='BorderLayout.CENTER'/> + </JPanel> + </cell> + </row> </Table> <!-- Current selected fishingOperation --> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-03-13 07:33:30 UTC (rev 601) @@ -53,6 +53,7 @@ public static final String PROPERTY_SELECTED_FISHING_OPERATION = "selectedFishingOperation"; public static final String PROPERTY_EDITED_FISHING_OPERATION = "editedFishingOperation"; + public static final String PROPERTY_CATCH_ENABLED = "catchEnabled"; /** * List of existing fishing operation for the selected cruise. @@ -106,6 +107,12 @@ */ protected boolean editionAdjusting; + /** + * Flag to use or not catch tab. + * @since 1.1 + */ + protected boolean catchEnabled; + public List<FishingOperation> getFishingOperation() { return fishingOperation; } @@ -195,4 +202,14 @@ TuttiEntities.findById(fishingOperation, id); return result; } + + public boolean isCatchEnabled() { + return catchEnabled; + } + + public void setCatchEnabled(boolean catchEnabled) { + boolean oldValue = isCatchEnabled(); + this.catchEnabled = catchEnabled; + firePropertyChange(PROPERTY_CATCH_ENABLED, oldValue, catchEnabled); + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-03-13 07:33:30 UTC (rev 601) @@ -51,6 +51,8 @@ // deselect selected fishingOperation // Will remove the selection fishing operation from the comboBox + model.setCatchEnabled(true); + model.setEditionAdjusting(true); try { model.setSelectedFishingOperation(null); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-13 07:33:30 UTC (rev 601) @@ -264,6 +264,8 @@ public static final String CONFIRMATION_FORMAT = "<html>%s<hr/><br/>%s</html>"; + public static final String WARNING_FORMAT = "<html>%s<hr/></html>"; + public int askSaveBeforeLeaving(String message) { String htmlMessage = String.format( CONFIRMATION_FORMAT, Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java 2013-03-13 07:33:30 UTC (rev 601) @@ -66,28 +66,6 @@ Throwable cause = ex; -// if (cause instanceof NullPointerException) { -// -// // See http://forge.codelutin.com/issues/2055 -// if (ex.getStackTrace().length > 0 && -// ex.getStackTrace()[0].getClassName().contains("swing.")) { -// if (log.isWarnEnabled()) { -// log.warn("AWT bad error (See http://forge.codelutin.com/issues/2055)", ex); -// } -// return; -// } -// } -// -// if (cause instanceof IndexOutOfBoundsException) { -// // See http://forge.codelutin.com/issues/2055 -// if (ex.getStackTrace().length > 0 && -// "convertRowIndexToModel".equals(ex.getStackTrace()[0].getMethodName())) { -// if (log.isWarnEnabled()) { -// log.warn("AWT bad error (See http://forge.codelutin.com/issues/2055)", ex); -// } -// return; -// } -// } if (cause instanceof TuttiTechnicalException) { cause = cause.getCause(); } @@ -101,18 +79,14 @@ TuttiActionException actionException = (TuttiActionException) cause; cause = cause.getCause(); - // close action ui - - action = actionException.getAction(); if (action instanceof AbstractChangeScreenAction) { backToScreen = true; } -// TuttiUIContext.getApplicationContext().getActionUI().getModel().clear(); } - TuttiUIContext.getErrorHelper().showErrorDialog(cause.getMessage(), ex); + TuttiUIContext.getErrorHelper().showErrorDialog(cause.getMessage(), cause); if (backToScreen) { action.getContext().setScreen(TuttiScreen.SELECT_CRUISE); Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-13 07:33:30 UTC (rev 601) @@ -138,6 +138,7 @@ tutti.dialog.createMelag.error.title= tutti.dialog.createMelag.message= tutti.dialog.createMelag.title= +tutti.dialog.warnUser.title= tutti.duration.format= tutti.error.errorpane.htmlmessage= tutti.file.csv= @@ -150,6 +151,7 @@ tutti.flash.information.cruiseSaved= tutti.flash.information.db.closed= tutti.flash.information.db.exported= +tutti.flash.information.db.installed= tutti.flash.information.db.installed.= tutti.flash.information.db.opened= tutti.flash.information.programCreated= @@ -159,6 +161,8 @@ tutti.flash.information.species.add.to.protocol= tutti.flash.information.species.exported.from.protocol= tutti.flash.information.species.imported.in.protocol= +tutti.flash.information.species.imported.in.protocol.oneReplaced= +tutti.flash.information.species.imported.in.protocol.severalReplaced= tutti.flash.information.species.remove.from.protocol= tutti.flash.information.species.replaced= tutti.information.db.loaded= @@ -519,6 +523,7 @@ tutti.validator.warning.longitude.minute.outOfBounds= tutti.validator.warning.longitude.outOfBounds= tutti.validator.warning.longitude.second.outOfBounds= +tutti.warn.invalid.batch.model= tutti.weights.rate.difference.totalAndSorted.description= tuttihelp.createSpeciesBatch.action.addSpecies.tip= tuttihelp.createSpeciesBatch.action.cancel.tip= Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-12 23:08:47 UTC (rev 600) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-13 07:33:30 UTC (rev 601) @@ -148,6 +148,7 @@ tutti.dialog.createMelag.error.title=Erreur tutti.dialog.createMelag.message=Combien pesait le MELAG (kg) ? tutti.dialog.createMelag.title=Poids du MELAG (kg) +tutti.dialog.warnUser.title=Avertissement\! tutti.duration.format=dj Hh m'm' tutti.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html> tutti.file.csv=Extension d'un fichier csv @@ -545,6 +546,7 @@ tutti.validator.warning.longitude.minute.outOfBounds=La minute de la latitude doit être comprise entre 0 et 60 tutti.validator.warning.longitude.outOfBounds=La Latitude doit être comprise entre -180.0 et 180.0 tutti.validator.warning.longitude.second.outOfBounds=La seconde de la longitude doit être comprise entre 0 et 60 +tutti.warn.invalid.batch.model=L'arbre d'échantillonage n'est pas compatible. Les captures ne seront pas visibles. tuttihelp.createSpeciesBatch.action.addSpecies.tip=Sélectionner une autre espèce tuttihelp.createSpeciesBatch.action.cancel.tip= tuttihelp.createSpeciesBatch.action.save.tip=