Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
April 2013
- 5 participants
- 210 discussions
r740 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
by kmorin@users.forge.codelutin.com 05 Apr '13
by kmorin@users.forge.codelutin.com 05 Apr '13
05 Apr '13
Author: kmorin
Date: 2013-04-05 16:19:05 +0200 (Fri, 05 Apr 2013)
New Revision: 740
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/740
Log:
fixes #2232 [CAPTURE] - Import/Export PUPITRI : ne pas demander le fichier pupitri ?\195?\160 ce stade
fixes #1868 [CAPTURE] - Import/Export PUPITRI
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-04-05 13:36:16 UTC (rev 739)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-04-05 14:19:05 UTC (rev 740)
@@ -68,8 +68,7 @@
file = TuttiUIUtil.chooseFile(
getContext().getMainUI(),
_("tutti.editProtocol.title.choose.speciesExportFile"),
- _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
- "^.*\\.ibts", _("tutti.common.file.ibts")
+ _("tutti.editProtocol.action.chooseProtocolSpeciesFile")
);
if (file == null) {
@@ -77,9 +76,6 @@
doAction = false;
} else {
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".ibts");
-
// ask user to confirm overwrite.
doAction = getHandler().askOverwriteFile(file);
}
1
0
05 Apr '13
Author: kmorin
Date: 2013-04-05 15:36:16 +0200 (Fri, 05 Apr 2013)
New Revision: 739
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/739
Log:
fixes #2230 [PROTOCOLE] - erreur ?\195?\160 l'import d'un .csv
refs #2232 [CAPTURE] - Import/Export PUPITRI : ne pas demander le fichier pupitri ?\195?\160 ce stade
fixes #2237 [CAPTURE] Ne pas prendre en compte les poids de tr?\195?\169mie et carrousel pour l'?\195?\169l?\195?\169vation
refs #1868 [CAPTURE] - Import/Export PUPITRI
refs #2079: [CONTROLE] - Contr?\195?\180le / Validation apr?\195?\168s la saisie
Added:
trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/SpeciesBatch-error-validation.xml
Modified:
trunk/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/Program-error-validation.xml
trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.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/pom.xml
===================================================================
--- trunk/pom.xml 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/pom.xml 2013-04-05 13:36:16 UTC (rev 739)
@@ -270,11 +270,6 @@
</dependency>
<!-- swing widgets -->
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-widgets</artifactId>
- <version>1.1.1</version>
- </dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -128,6 +128,10 @@
return Multimaps.index(list, GET_TAXON_ID);
}
+ public static Multimap<String, Species> splitByRefTaxCode(Iterable<Species> list) {
+ return Multimaps.index(list, GET_REF_TAX_CODE);
+ }
+
public static final Function<Species, String> GET_TAXON_ID = new Function<Species, String>() {
@Override
public String apply(Species input) {
@@ -135,6 +139,13 @@
}
};
+ public static final Function<Species, String> GET_REF_TAX_CODE = new Function<Species, String>() {
+ @Override
+ public String apply(Species input) {
+ return String.valueOf(input.getRefTaxCode());
+ }
+ };
+
public static final Function<TuttiEntity, String> GET_ID = new Function<TuttiEntity, String>() {
@Override
public String apply(TuttiEntity input) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -60,6 +60,8 @@
public static final String BY_NAME = "byName";
+ public static final String ONLY_NAME = "onlyName";
+
public static final String SEPARATOR = "#";
/** Delegate decorator provider. */
@@ -112,6 +114,7 @@
});
registerDecorator(new VesselDecorator());
registerDecorator(new ProgramDecorator());
+ registerTuttiDecorator(Program.class, ONLY_NAME, "${name}$s", SEPARATOR, " - ");
registerDecorator(new SpeciesDecorator());
registerDecorator(FROM_PROTOCOL, new SpeciesFromProtocolDecorator());
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import org.nuiton.validator.NuitonValidator;
import org.nuiton.validator.NuitonValidatorFactory;
@@ -63,4 +64,10 @@
NuitonValidatorResult result = validator.validate(fishingOperation);
return result;
}
+
+ public NuitonValidatorResult validateSpeciesBatch(SpeciesBatch speciesBatch) {
+ NuitonValidator<SpeciesBatch> validator = NuitonValidatorFactory.newValidator(SpeciesBatch.class);
+ NuitonValidatorResult result = validator.validate(speciesBatch);
+ return result;
+ }
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -1,44 +1,18 @@
package fr.ifremer.tutti.service.catches;
-/*
- * #%L
- * Tutti :: Service
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.TuttiBusinessException;
-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.SortedUnsortedEnum;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.*;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.AbstractTuttiService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.ValidationService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.validator.NuitonValidatorResult;
+import javax.swing.*;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -54,15 +28,18 @@
protected PersistenceService persistenceService;
+ protected ValidationService validationService;
+
@Override
public void setServiceContext(TuttiServiceContext context) {
super.setServiceContext(context);
persistenceService = getService(PersistenceService.class);
+ validationService = getService(ValidationService.class);
}
public void computeCatchBatchWeights(CatchBatch catchBatch,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<SpeciesBatch> rootBenthosBatch) {
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<SpeciesBatch> rootBenthosBatch) {
// Species
Float speciesTotalComputedSortedWeight = 0f;
@@ -173,15 +150,11 @@
catchBatch.setBenthosTotalComputedWeight(benthosTotalWeight);
// Catch
- Float carrouselWeight = catchBatch.getCatchTotalSortedCarousselWeight();
Float totalUnsortedWeight = catchBatch.getSpeciesTotalUnsortedComputedWeight() +
catchBatch.getBenthosTotalUnsortedComputedWeight();
- Float totalSortedWeight;
- if (carrouselWeight != null) {
- totalSortedWeight = carrouselWeight;
- } else {
- totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight;
- }
+
+ Float totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight;
+
catchBatch.setCatchTotalSortedComputedWeight(totalSortedWeight);
catchBatch.setCatchTotalUnsortedComputedWeight(totalUnsortedWeight);
@@ -193,10 +166,11 @@
+ totalSortedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
+ } else {
+ catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
+ - totalUnsortedWeight
+ - totalSortedWeight);
}
- catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
- - totalUnsortedWeight
- - totalSortedWeight);
} else if (totalWeight == null) {
if (rejectedWeight == null) {
@@ -204,8 +178,8 @@
catchBatch.setCatchTotalRejectedComputedWeight(0f);
}
catchBatch.setCatchTotalComputedWeight(totalUnsortedWeight
- + totalSortedWeight
- + rejectedWeight);
+ + totalSortedWeight
+ + rejectedWeight);
} else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
@@ -220,7 +194,8 @@
if (rootSpeciesBatch != null) {
List<SpeciesBatch> roots = rootSpeciesBatch.getChildren();
- for (SpeciesBatch batch : roots) {
+ for (int i = 0; i < roots.size(); i++) {
+ SpeciesBatch batch = roots.get(i);
computeSpeciesBatch(batch);
}
}
@@ -235,7 +210,8 @@
List<SpeciesBatch> roots = rootBenthosBatch.getChildren();
- for (SpeciesBatch batch : roots) {
+ for (int i = 0; i < roots.size(); i++) {
+ SpeciesBatch batch = roots.get(i);
computeSpeciesBatch(batch);
}
@@ -247,6 +223,12 @@
Float categoryWeight = batch.getSampleCategoryWeight();
Float rowWeight = batch.getWeight();
+ NuitonValidatorResult validation = validationService.validateSpeciesBatch(batch);
+ if (!validation.isValid()) {
+ List<String> messages = validation.getErrorMessages(SpeciesBatch.PROPERTY_WEIGHT);
+ throw new TuttiBusinessException(_(messages.get(0)));
+ }
+
List<SpeciesBatch> children = batch.getChildBatchs();
// if the row is not a leaf
if (batch.sizeChildBatchs() > 0) {
@@ -262,23 +244,6 @@
}
if (sum != null) {
-// if (categoryWeight == null) {
-// finestCategory.setComputedWeight(sum);
-// for (SpeciesBatchRowModel child : children) {
-// child.getFinestCategory().setSubSample(false);
-// }
-//
-// } else if (categoryWeight < sum) {
-// throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight"));
-//
-// } else {
-// boolean subSample = categoryWeight > sum;
-// for (SpeciesBatchRowModel child : children) {
-// child.getFinestCategory().setSubSample(subSample);
-// }
-// sum = categoryWeight;
-// }
-// result = sum;
if (categoryWeight == null) {
batch.setSampleCategoryComputedWeight(sum);
@@ -316,7 +281,7 @@
}
if (categoryWeight == null && rowWeight != null) {
- throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentRowWeightCategory"));
+// throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentRowWeightCategory"));
} else if (categoryWeight == null && frequencyWeight != null) {
// if the category weight is null and the frequencies have a weight,
@@ -325,7 +290,7 @@
result = frequencyWeight;
} else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
+ && !frequencyWeight.equals(categoryWeight)) {
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -27,13 +27,11 @@
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
+import com.google.common.collect.*;
import com.google.common.io.Files;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -49,6 +47,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.AbstractTuttiService;
import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiDataContext;
import fr.ifremer.tutti.service.TuttiServiceContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
@@ -62,10 +61,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* @author kmorin <kmorin(a)codelutin.com>
@@ -78,6 +74,8 @@
protected PersistenceService persistenceService;
+ protected TuttiDataContext dataContext;
+
protected CaracteristicQualitativeValue sortedCaracteristic;
protected CaracteristicQualitativeValue unsortedCaracteristic;
@@ -96,6 +94,7 @@
public void setServiceContext(TuttiServiceContext context) {
super.setServiceContext(context);
persistenceService = getService(PersistenceService.class);
+ dataContext = context.getDataContext();
// get the sorted/unsorted caracteristics
Caracteristic sortedUnsortedcaracteristic =
@@ -113,22 +112,29 @@
bigCaracteristic = SizeEnum.BIG.getValue(sizeCaracteristic);
}
- public void importPupitri(File trunkFile,
+ /**
+ *
+ * @param trunkFile
+ * @param carrouselFile
+ * @param operation
+ * @param catchBatch
+ * @return the number of rows of the .car file which have not been imported
+ */
+ public int importPupitri(File trunkFile,
File carrouselFile,
- File speciesFile,
FishingOperation operation,
- CatchBatch catchBatch,
- List<Species> referentSpecies) {
+ CatchBatch catchBatch) {
importPupitriTrunk(trunkFile, operation, catchBatch);
- importPupitriCarrousel(carrouselFile, speciesFile, operation, catchBatch, referentSpecies);
+ int result = importPupitriCarrousel(carrouselFile, operation, catchBatch);
addFileAsAttachment(trunkFile, catchBatch);
addFileAsAttachment(carrouselFile, catchBatch);
- addFileAsAttachment(speciesFile, catchBatch);
persistenceService.saveCatchBatch(catchBatch);
+
+ return result;
}
protected void addFileAsAttachment(File f, CatchBatch catchBatch) {
@@ -213,66 +219,43 @@
}
- protected void importPupitriCarrousel(File carrouselFile,
- File speciesFile,
+ protected int importPupitriCarrousel(File carrouselFile,
FishingOperation operation,
- CatchBatch catchBatch,
- List<Species> referentSpecies) {
+ CatchBatch catchBatch) {
if (log.isInfoEnabled()) {
log.info("Will import pupitri operation [" + operation.toString() +
"] carrousel from file: " + carrouselFile);
}
+ int result = 0;
Reader reader = null;
File fileWithHeaders = null;
- Import<SpeciesRow> speciesImporter = null;
Import<CarrouselRow> carrouselImporter = null;
-
- char speciesSeparator = ';';
- SpeciesRowModel speciesCsvModel = new SpeciesRowModel(speciesSeparator);
char carrouselSeparator = ',';
CarrouselRowModel carrouselCsvModel = new CarrouselRowModel(carrouselSeparator);
try {
- // import the species
- String[] header = new String[]{
- SpeciesRow.PROPERTY_CODE_FIRST_PART,
- SpeciesRow.PROPERTY_CODE_SECOND_PART,
- SpeciesRow.PROPERTY_SCIENTIFIC_NAME
- };
- fileWithHeaders = createFileWithHeaders(speciesFile, header, speciesSeparator);
- reader = Files.newReader(fileWithHeaders, Charsets.UTF_8);
- speciesImporter = Import.newImport(speciesCsvModel, reader);
-
// get the map of species by survey code
- Multimap<String, Species> speciesBySurveyCode =
- Multimaps.index(referentSpecies, new Function<Species, String>() {
- @Override
- public String apply(Species input) {
- String surveyCode = String.valueOf(input.getSurveyCode());
- int end = Math.min(surveyCode.length(), 7);
- return surveyCode.substring(0, end);
- }
- });
- // keep only the species whose survey code and name are the same
- // in theimported file and the referent species
- Map<String, Species> speciesMap = Maps.newHashMap();
- for (SpeciesRow bean : speciesImporter) {
- String code = bean.getCodeFirstPart() + bean.getCodeSecondPart();
- Collection<Species> speciesCollection = speciesBySurveyCode.get(code.trim());
- for (Species species : speciesCollection) {
- if (species.getName().equals(bean.getScientificName())) {
- speciesMap.put(code, species);
- break;
- }
- }
- }
+ ListMultimap<String, Species> speciesBySurveyCode = ArrayListMultimap.create();
+ speciesBySurveyCode.putAll(
+ Multimaps.index(dataContext.getReferentSpeciesWithSurveyCode(),
+ new Function<Species, String>() {
+ @Override
+ public String apply(Species input) {
+ String surveyCode = String.valueOf(input.getSurveyCode());
+ int end = Math.min(surveyCode.length(), 7);
+ return surveyCode.substring(0, end);
+ }
+ })
+ );
+ speciesBySurveyCode.putAll(TuttiEntities.splitByRefTaxCode(dataContext.getReferentSpecies()));
+
// import the batches
- header = new String[]{
+ String[] header = new String[]{
CarrouselRow.PROPERTY_FILE_ORIGIN,
CarrouselRow.PROPERTY_DATE,
CarrouselRow.PROPERTY_TIME,
@@ -296,13 +279,15 @@
Float carrouselSortedWeight = 0f;
List<PupitriCatch> catches = Lists.newArrayList();
+ Set<String> notFoundSpecies = Sets.newHashSet();
+
for (CarrouselRow bean : carrouselImporter) {
// is the bean from the current operation and rig ?
if (bean.getOperationCode().equals(operationNumber)
&& bean.getRigNumber().equals(rigNumber)) {
String speciesId = bean.getSpeciesId();
- Species species = speciesMap.get(speciesId);
+ List<Species> speciesList = speciesBySurveyCode.get(speciesId);
Float beanWeight = bean.getWeight();
if (beanWeight < 0f) {
beanWeight = 0f;
@@ -318,8 +303,9 @@
carrouselSortedWeight += beanWeight;
}
- if (species != null) {
+ if (!CollectionUtils.isEmpty(speciesList)) {
+ Species species = speciesList.get(0);
PupitriCatch pupitriCatch = new PupitriCatch(species, sorted);
int catchIndex = catches.indexOf(pupitriCatch);
if (catchIndex >= 0) {
@@ -328,9 +314,13 @@
catches.add(pupitriCatch);
}
pupitriCatch.addToSign(bean.getSign(), beanWeight);
+
+ } else {
+ notFoundSpecies.add(speciesId);
}
}
}
+ result = notFoundSpecies.size();
catchBatch.setCatchTotalSortedCarousselWeight(carrouselSortedWeight);
BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId());
@@ -398,7 +388,6 @@
}
carrouselImporter.close();
- speciesImporter.close();
reader.close();
} catch (Exception e) {
@@ -406,10 +395,11 @@
} finally {
IOUtils.closeQuietly(carrouselImporter);
- IOUtils.closeQuietly(speciesImporter);
IOUtils.closeQuietly(reader);
FileUtils.deleteQuietly(fileWithHeaders);
}
+
+ return result;
}
public void exportSpecies(List<Species> species, File target) {
Modified: trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/Program-error-validation.xml
===================================================================
--- trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/Program-error-validation.xml 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/Program-error-validation.xml 2013-04-05 13:36:16 UTC (rev 739)
@@ -36,7 +36,7 @@
<field-validator type="collectionUniqueKey" short-circuit="true">
<param name="collectionFieldName">existingPrograms</param>
- <param name="keys">name, zone</param>
+ <param name="keys">name</param>
<param name="againstMe">true</param>
<param name="nullValueSkipped">true</param>
<message>tutti.validator.error.program.existingKey</message>
Added: trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/SpeciesBatch-error-validation.xml
===================================================================
--- trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/SpeciesBatch-error-validation.xml (rev 0)
+++ trunk/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/SpeciesBatch-error-validation.xml 2013-04-05 13:36:16 UTC (rev 739)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="weight">
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ !(sampleCategoryWeight == null && weight != null) ]]>
+ </param>
+ <message>tutti.service.catches.computeWeights.error.incoherentRowWeightCategory</message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ weight == null || sampleCategoryWeight == null || weight <= sampleCategoryWeight ]]>
+ </param>
+ <message>tutti.service.catches.computeWeights.error.incoherentSampleWeight</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -52,6 +52,7 @@
tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight=
tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=
tutti.service.catches.computeWeights.error.incoherentRowWeightFrequency=
+tutti.service.catches.computeWeights.error.incoherentSampleWeight=
tutti.service.catches.computeWeights.error.incoherentSpeciesTotalSorted=
tutti.service.catches.computeWeights.error.incoherentTotal=
tutti.validator.error.comment.too.long=
@@ -97,5 +98,6 @@
tutti.validator.error.program.zone.required=
tutti.validator.error.protocol.name.alreadyUsed=
tutti.validator.error.protocol.name.required=
+tutti.validator.error.speciesBatch.species.required=
tutti.validator.warning.latitude.outOfBounds=
tutti.validator.warning.longitude.outOfBounds=
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -7,7 +7,6 @@
tutti.config.option.tmp.directory.description=Répertoire temporaire utilisée par l'application (est nettoyé à chaque démarrage de l'application).
tutti.config.option.version.description=Version courante de l'application
tutti.config.service=Configuration des services de Tutti
-tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight=
tutti.property.attachment=Pièce jointe
tutti.property.caracteristic=Caractéristique
tutti.property.country=Pays
@@ -49,6 +48,7 @@
tutti.service.catches.computeWeights.error.incoherentParentCategoryWeight=Le poids de la catégorie est différent de la somme des poids de ses sous-catégories
tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=Le poids de la catégorie ne peut pas être nul si le poids de sous-échantillonage est renseigné
tutti.service.catches.computeWeights.error.incoherentRowWeightFrequency=Le poids total des mensurations est différent du poids du sous-échantillon
+tutti.service.catches.computeWeights.error.incoherentSampleWeight=Le poids de sous-échantillonage est supérieur au poids de la catégorie
tutti.service.catches.computeWeights.error.incoherentSpeciesTotalSorted=Le poids total Vrac des espèces est inférieur à la somme des poids Vrac triés, inerte trié et vivant non détaillé trié
tutti.service.catches.computeWeights.error.incoherentTotal=Le poids total de la capture ne correspond pas à la somme des poids totaux Vrac, Hors Vrac et non triés
tutti.validator.error.comment.too.long=Taille de commentaire trop longue (limitée à %s caractères)
@@ -89,10 +89,11 @@
tutti.validator.error.longitude.start.required=La longitude de début de traîne est obligatoire
tutti.validator.error.program.description.required=La description de la série est obligatoire
tutti.validator.error.program.description.too.long=Taille de la description trop longue (limitée à %s caractères)
-tutti.validator.error.program.existingKey=Le couple nom/zone existe déjà
+tutti.validator.error.program.existingKey=Le nom du programme est déjà utilisé
tutti.validator.error.program.name.required=Le nom de la série est obligatoire
tutti.validator.error.program.zone.required=La zone de la série est obligatoire
tutti.validator.error.protocol.name.alreadyUsed=Le nom du protocol est déjà utilisé
tutti.validator.error.protocol.name.required=Le nom du protocol est obligatoire
+tutti.validator.error.speciesBatch.species.required=
tutti.validator.warning.latitude.outOfBounds=La Latitude doit être comprise entre -90.0 et 90.0
tutti.validator.warning.longitude.outOfBounds=La longitude doit être comprise entre -180.0 et 180.0
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Thu Apr 04 20:09:11 CEST 2013
+#Fri Mar 29 10:09:57 CET 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Thu Apr 04 20:09:11 CEST 2013
+#Fri Mar 29 10:09:57 CET 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiDataContext;
import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.TuttiWeightComputingService;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
@@ -517,6 +518,10 @@
return serviceContext.getService(TuttiReferentialImportExportService.class);
}
+ public TuttiWeightComputingService getTuttiWeightComputingService() {
+ return serviceContext.getService(TuttiWeightComputingService.class);
+ }
+
public boolean useRealPersistenceService() {
return isDbExist() && isDbLoaded();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -33,6 +33,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.CloseableUI;
@@ -181,7 +182,8 @@
initBeanFilterableComboBox(ui.getProgramComboBox(),
persistenceService.getAllProgram(),
- model.getProgram());
+ model.getProgram(),
+ DecoratorService.ONLY_NAME);
initBeanFilterableComboBox(ui.getDepartureLocationComboBox(),
persistenceService.getAllHarbour(),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -25,8 +25,13 @@
* #L%
*/
+import com.google.common.collect.Lists;
import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.service.catches.TuttiWeightComputingService;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
@@ -53,121 +58,23 @@
@Override
protected void doAction() throws Exception {
- EditCatchesUIModel model = getModel();
+ TuttiWeightComputingService tuttiWeightComputingService = getContext().getTuttiWeightComputingService();
- computeSpeciesBatches();
- computeBenthosBatches();
-
- Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight();
- if (speciesTotalSortedWeight == null) {
- speciesTotalSortedWeight = model.getSpeciesTotalSortedComputedWeight();
- }
-
- Float benthosTotalSortedWeight = model.getBenthosTotalSortedWeight();
- if (benthosTotalSortedWeight == null) {
- benthosTotalSortedWeight = model.getBenthosTotalSortedComputedWeight();
- }
-
- Float carrouselWeight = model.getCatchTotalSortedCarousselWeight();
- Float totalUnsortedWeight = model.getSpeciesTotalUnsortedComputedWeight() +
- model.getBenthosTotalUnsortedComputedWeight();
- Float totalSortedWeight;
- if (carrouselWeight != null) {
- totalSortedWeight = carrouselWeight;
- } else {
- totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight;
- }
- model.setCatchTotalSortedComputedWeight(totalSortedWeight);
- model.setCatchTotalUnsortedComputedWeight(totalUnsortedWeight);
-
- Float totalWeight = model.getCatchTotalWeight();
- Float rejectedWeight = model.getCatchTotalRejectedWeight();
-
- if (rejectedWeight == null && totalWeight != null) {
- if (!totalWeight.equals(totalUnsortedWeight
- + totalSortedWeight)) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentTotal"));
-
- } else {
- model.setCatchTotalRejectedComputedWeight(totalWeight
- - totalUnsortedWeight
- - totalSortedWeight);
- }
-
- } else if (totalWeight == null) {
- if (rejectedWeight == null) {
- rejectedWeight = 0f;
- model.setCatchTotalRejectedComputedWeight(0f);
- }
- model.setCatchTotalComputedWeight(totalUnsortedWeight
- + totalSortedWeight
- + rejectedWeight);
-
- } else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentTotal"));
- }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- getUI().repaint();
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void computeSpeciesBatches() {
EditCatchesUIModel model = getModel();
- Float totalSortedWeight = 0f;
- Float totalUnsortedWeight = 0f;
+ BatchContainer<SpeciesBatch> computedSpeciesBatches =
+ tuttiWeightComputingService.getComputedSpeciesBatches(model.getFishingOperation());
+ Float totalSpeciesSortedWeight = computeSpeciesBatches(computedSpeciesBatches);
- List<SpeciesBatchRowModel> roots = getUI().getSpeciesTabContent().getModel().getRows();
- for (int i = 0; i < roots.size(); i++) {
- SpeciesBatchRowModel row = roots.get(i);
- if (row.isBatchRoot()) {
- Float weight = computeSpeciesBatch(row);
- if (weight == null) {
- AbstractSelectTableAction.doSelectCell(getUI().getSpeciesTabContent().getTable(), i, 1);
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight"));
- }
- if (SortedUnsortedEnum.SORTED.matchValue(row.getSortedUnsortedCategory().getCategoryValue())) {
- totalSortedWeight += weight;
- } else {
- totalUnsortedWeight += weight;
- }
- }
- }
+ BatchContainer<SpeciesBatch> computedBenthosBatches =
+ tuttiWeightComputingService.getComputedBenthosBatches(model.getFishingOperation());
+ Float totalBenthosSortedWeight = computeBenthosBatches(computedBenthosBatches);
- Number inertWeight = model.getSpeciesTotalInertWeight();
- if (inertWeight != null) {
- totalSortedWeight += inertWeight.floatValue();
- } else {
- model.setSpeciesTotalInertComputedWeight(0f);
- }
-
- Number livingNotItemizedWeight = model.getSpeciesTotalLivingNotItemizedWeight();
- if (livingNotItemizedWeight != null) {
- totalSortedWeight += livingNotItemizedWeight.floatValue();
- } else {
- model.setSpeciesTotalLivingNotItemizedComputedWeight(0f);
- }
-
- model.setSpeciesTotalSampleSortedComputedWeight(totalSortedWeight);
-
- Float speciesTotalSortedWeight = model.getSpeciesTotalSortedWeight();
Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights();
- if (speciesTotalSortedWeight == null) {
- speciesTotalSortedWeight = totalSortedWeight;
- model.setSpeciesTotalSortedComputedWeight(totalSortedWeight);
+ if (model.getSpeciesTotalSortedWeight() != null
+ && model.getSpeciesTotalSortedWeight() >= totalSpeciesSortedWeight
+ && model.getSpeciesTotalSortedWeight() < (1 + rate / 100) * totalSpeciesSortedWeight) {
- } else if (speciesTotalSortedWeight < totalSortedWeight) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentSpeciesTotalSorted"));
-
- } else if (speciesTotalSortedWeight < (1 + rate / 100) * totalSortedWeight) {
// Si le "Poids total VRAC" est saisi est que sa valeur
// est supérieure de moins de x% (x en configuration)
// du "Poids total Vrac trié", demander confirmation que
@@ -179,175 +86,20 @@
_("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ htmlMessage,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.NO_OPTION) {
model.setSpeciesTotalSortedWeight(null);
- speciesTotalSortedWeight = totalSortedWeight;
- model.setSpeciesTotalSortedComputedWeight(totalSortedWeight);
+ model.setSpeciesTotalSortedComputedWeight(totalSpeciesSortedWeight);
}
}
+ if (model.getBenthosTotalSortedWeight() != null
+ && model.getBenthosTotalSortedWeight() >= totalBenthosSortedWeight
+ && model.getBenthosTotalSortedWeight() < (1 + rate / 100) * totalSpeciesSortedWeight) {
- model.setSpeciesTotalUnsortedComputedWeight(totalUnsortedWeight);
-
- Float totalWeight = totalUnsortedWeight + speciesTotalSortedWeight;
- model.setSpeciesTotalComputedWeight(totalWeight);
- }
-
- protected Float computeSpeciesBatch(SpeciesBatchRowModel row) {
- SampleCategory finestCategory = row.getFinestCategory();
-
- Float result = null;
- Float categoryWeight = finestCategory.getCategoryWeight();
- Float rowWeight = row.getWeight();
-
- List<SpeciesBatchRowModel> children = row.getChildBatch();
- // if the row is not a leaf
- if (!row.isBatchLeaf()) {
- Float sum = 0f;
- // make the sum of the children weights
- for (SpeciesBatchRowModel child : children) {
- Float weight = computeSpeciesBatch(child);
- if (weight == null) {
- sum = null;
- break;
- }
- sum += weight;
- }
-
- if (sum != null) {
- if (categoryWeight == null) {
- finestCategory.setComputedWeight(sum);
- for (SpeciesBatchRowModel child : children) {
- child.getFinestCategory().setSubSample(false);
- }
-
- } else if (categoryWeight < sum) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight"));
-
- } else {
- boolean subSample = categoryWeight > sum;
- for (SpeciesBatchRowModel child : children) {
- child.getFinestCategory().setSubSample(subSample);
- }
- sum = categoryWeight;
- }
- result = sum;
- }
-
- } else {// the row is a leaf
- row.setComputedWeight(null);
-
- List<SpeciesFrequencyRowModel> frequency = row.getFrequency();
-
- if (CollectionUtils.isNotEmpty(frequency)) {
- // if there are frequencies, then compute their weight
- Float frequencyWeight = 0f;
- for (SpeciesFrequencyRowModel frequencyModel : frequency) {
- Float w = frequencyModel.getWeight();
- if (w == null) {
-
- // can't sum when a null value appears
- frequencyWeight = null;
- break;
-
- } else if (frequencyWeight != null) {
-
- // still can sum weights
- frequencyWeight += w;
- }
- }
-
- if (categoryWeight == null && rowWeight != null) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightCategory"));
-
- } else if (categoryWeight == null && frequencyWeight != null) {
- // if the category weight is null and the frequencies have a weight,
- // then this weight is the result
- finestCategory.setComputedWeight(frequencyWeight);
- result = frequencyWeight;
-
- } else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
-
- // if the weight of the frequencies is different from the category
- // weight, then set the weight of the sample
- if (frequencyWeight > categoryWeight) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentCategoryWeight"));
-
- } else if (rowWeight == null) {
- row.setComputedWeight(frequencyWeight);
-
- } else if (!rowWeight.equals(frequencyWeight)) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightFrequency"));
- }
- result = categoryWeight;
-
- } else {
- result = categoryWeight;
- }
-
- } else {
- result = categoryWeight;
- }
- }
-
- return result;
- }
-
- protected void computeBenthosBatches() {
-
- EditCatchesUIModel model = getModel();
-
- Float totalSortedWeight = 0f;
- Float totalUnsortedWeight = 0f;
-
- List<BenthosBatchRowModel> roots = getUI().getBenthosTabContent().getModel().getRows();
- for (int i = 0; i < roots.size(); i++) {
- BenthosBatchRowModel row = roots.get(i);
- if (row.isBatchRoot()) {
- Float weight = computeBenthosBatch(row);
- if (weight == null) {
- AbstractSelectTableAction.doSelectCell(getUI().getBenthosTabContent().getTable(), i, 1);
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight"));
- }
- if (SortedUnsortedEnum.SORTED.matchValue(row.getSortedUnsortedCategory().getCategoryValue())) {
- totalSortedWeight += weight;
- } else {
- totalUnsortedWeight += weight;
- }
- }
- }
-
- Number inertWeight = model.getBenthosTotalInertWeight();
- if (inertWeight != null) {
- totalSortedWeight += inertWeight.floatValue();
- } else {
- model.setBenthosTotalInertComputedWeight(0f);
- }
-
- Number livingNotItemizedWeight = model.getBenthosTotalLivingNotItemizedWeight();
- if (livingNotItemizedWeight != null) {
- totalSortedWeight += livingNotItemizedWeight.floatValue();
- } else {
- model.setBenthosTotalLivingNotItemizedComputedWeight(0f);
- }
-
- model.setBenthosTotalSampleSortedComputedWeight(totalSortedWeight);
-
- Float benthosTotalSortedWeight = model.getBenthosTotalSortedWeight();
- Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights();
- if (benthosTotalSortedWeight == null) {
- benthosTotalSortedWeight = totalSortedWeight;
- model.setBenthosTotalSortedComputedWeight(totalSortedWeight);
-
- } else if (benthosTotalSortedWeight < totalSortedWeight) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentSpeciesTotalSorted"));
-
- } else if (benthosTotalSortedWeight < (1 + rate / 100) * totalSortedWeight) {
// Si le "Poids total VRAC" est saisi est que sa valeur
// est supérieure de moins de x% (x en configuration)
// du "Poids total Vrac trié", demander confirmation que
@@ -359,122 +111,95 @@
_("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ htmlMessage,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.NO_OPTION) {
- model.setSpeciesTotalSortedWeight(null);
- benthosTotalSortedWeight = totalSortedWeight;
- model.setBenthosTotalSortedComputedWeight(totalSortedWeight);
+ model.setBenthosTotalSortedWeight(null);
+ model.setBenthosTotalSortedComputedWeight(totalBenthosSortedWeight);
}
}
- model.setBenthosTotalUnsortedComputedWeight(totalUnsortedWeight);
+ boolean modified = model.isModify();
+ CatchBatch catchBatch = model.toBean();
+ tuttiWeightComputingService.computeCatchBatchWeights(catchBatch,
+ computedSpeciesBatches,
+ computedBenthosBatches);
+ model.setCatchBatch(catchBatch);
+ model.fromBean(catchBatch);
+ model.setModify(modified);
+ }
- Float totalWeight = totalUnsortedWeight + benthosTotalSortedWeight;
- model.setBenthosTotalComputedWeight(totalWeight);
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ getUI().repaint();
}
- protected Float computeBenthosBatch(BenthosBatchRowModel row) {
- SampleCategory finestCategory = row.getFinestCategory();
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
- Float result = null;
- Float categoryWeight = finestCategory.getCategoryWeight();
- Float rowWeight = row.getWeight();
+ protected Float computeSpeciesBatches(BatchContainer<SpeciesBatch> computedSpeciesBatches) {
+ Float totalSortedWeight = 0f;
- List<BenthosBatchRowModel> children = row.getChildBatch();
- // if the row is not a leaf
- if (!row.isBatchLeaf()) {
- Float sum = 0f;
- // make the sum of the children weights
- for (BenthosBatchRowModel child : children) {
- Float weight = computeBenthosBatch(child);
- if (weight == null) {
- sum = null;
- break;
- }
- sum += weight;
+ List<SpeciesBatchRowModel> rows = Lists.newArrayList();
+ List<SpeciesBatch> children = computedSpeciesBatches.getChildren();
+ int rowIndex = 0;
+ for (SpeciesBatch batch : children) {
+ SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows);
+ Float weight = row.getSortedUnsortedCategoryWeight();
+ if (weight == null) {
+ weight = row.getSortedUnsortedCategoryComputedWeight();
}
+ if (weight == null) {
+ AbstractSelectTableAction.doSelectCell(getUI().getSpeciesTabContent().getTable(), rowIndex, 1);
+ throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight"));
- if (sum != null) {
- if (categoryWeight == null) {
- finestCategory.setComputedWeight(sum);
- for (BenthosBatchRowModel child : children) {
- child.getFinestCategory().setSubSample(false);
- }
-
- } else if (categoryWeight < sum) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight"));
-
- } else {
- boolean subSample = categoryWeight > sum;
- for (BenthosBatchRowModel child : children) {
- child.getFinestCategory().setSubSample(subSample);
- }
- sum = categoryWeight;
- }
- result = sum;
+ } else if (SortedUnsortedEnum.SORTED.matchValue(
+ row.getSortedUnsortedCategoryValue())) {
+ totalSortedWeight += weight;
}
+ rowIndex++;
+ if (row.getChildBatch() != null) {
+ rowIndex += row.getChildBatch().size();
+ }
+ }
+ getUI().getSpeciesTabContent().getModel().setRows(rows);
- } else {// the row is a leaf
- row.setComputedWeight(null);
+ return totalSortedWeight;
+ }
- List<BenthosFrequencyRowModel> frequency = row.getFrequency();
+ protected Float computeBenthosBatches(BatchContainer<SpeciesBatch> computedBenthosBatches) {
+ Float totalSortedWeight = 0f;
- if (CollectionUtils.isNotEmpty(frequency)) {
- // if there are frequencies, then compute their weight
- Float frequencyWeight = 0f;
- for (BenthosFrequencyRowModel frequencyModel : frequency) {
- Float w = frequencyModel.getWeight();
- if (w == null) {
+ List<BenthosBatchRowModel> rows = Lists.newArrayList();
+ List<SpeciesBatch> children = computedBenthosBatches.getChildren();
+ int rowIndex = 0;
+ for (SpeciesBatch batch : children) {
+ BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows);
+ Float weight = row.getSortedUnsortedCategoryWeight();
+ if (weight == null) {
+ weight = row.getSortedUnsortedCategoryComputedWeight();
+ }
+ if (weight == null) {
+ AbstractSelectTableAction.doSelectCell(getUI().getBenthosTabContent().getTable(), rowIndex, 1);
+ throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.noWeight"));
- // can't sum when a null value appears
- frequencyWeight = null;
- break;
-
- } else if (frequencyWeight != null) {
-
- // still can sum weights
- frequencyWeight += w;
- }
- }
-
- if (categoryWeight == null && rowWeight != null) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightCategory"));
-
- } else if (categoryWeight == null && frequencyWeight != null) {
- // if the category weight is null and the frequencies have a weight,
- // then this weight is the result
- finestCategory.setComputedWeight(frequencyWeight);
- result = frequencyWeight;
-
- } else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
-
- // if the weight of the frequencies is different from the category
- // weight, then set the weight of the sample
- if (frequencyWeight > categoryWeight) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentCategoryWeight"));
-
- } else if (rowWeight == null) {
- row.setComputedWeight(frequencyWeight);
-
- } else if (!rowWeight.equals(frequencyWeight)) {
- throw new TuttiBusinessException(_("tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightFrequency"));
- }
- result = categoryWeight;
-
- } else {
- result = categoryWeight;
- }
-
- } else {
- result = categoryWeight;
+ } else if (SortedUnsortedEnum.SORTED.matchValue(
+ row.getSortedUnsortedCategoryValue())) {
+ totalSortedWeight += weight;
}
+ rowIndex++;
+ if (row.getChildBatch() != null) {
+ rowIndex += row.getChildBatch().size();
+ }
}
+ getUI().getBenthosTabContent().getModel().setRows(rows);
- return result;
+ return totalSortedWeight;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-05 13:36:16 UTC (rev 739)
@@ -105,6 +105,10 @@
_computed: true;
}
+#tremieCarrouselRow {
+ visible: {model.getFishingOperation().getVessel() != null && model.getFishingOperation().getVessel().getId().equals(handler.getConfig().getTremieCarousselVesselId())};
+}
+
#catchTotalSortedTremisWeightLabel {
text: "tutti.editCatchBatch.field.catchTotalSortedTremisWeight";
toolTipText: {"tutti.editCatchBatch.field.catchTotalSortedTremisWeight.tip"};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-05 13:36:16 UTC (rev 739)
@@ -100,9 +100,6 @@
<CardLayout2Ext id='marineLitterTabPanelLayout'
constructorParams='this, "marineLitterTabPanel"'/>
- <CardLayout2Ext id='catchTotalSortedWeightPanelLayout'
- constructorParams='this, "catchTotalSortedWeightPanel"'/>
-
<TuttiHelpBroker id='broker' constructorParams='"tutti.editCatchBatch.help"'/>
<JToolBar id='catchesCaracteristicsTabToolBar'>
@@ -138,33 +135,32 @@
<JLabel id='catchTotalSortedWeightLabel'/>
</cell>
<cell columns='4' weightx='1.0'>
- <JPanel id='catchTotalSortedWeightPanel'>
- <JTextField id='catchTotalSortedWeightField'
- constraints='EditCatchesUIHandler.CLASSIC_VESSEL'/>
- <Table
- constraints='EditCatchesUIHandler.CAROUSSEL_TREMIE_VESSEL'
- fill='both'>
- <row>
- <cell anchor='west'>
- <JLabel
- id='catchTotalSortedCarousselWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField
- id='catchTotalSortedCarousselWeightField'/>
- </cell>
- <cell anchor='west'>
- <JLabel id='catchTotalSortedTremisWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField
- id='catchTotalSortedTremisWeightField'/>
- </cell>
- </row>
- </Table>
- </JPanel>
+ <JTextField id='catchTotalSortedWeightField'/>
</cell>
</row>
+ <row>
+ <cell columns='5'>
+ <Table fill='both' id='tremieCarrouselRow'>
+ <row>
+ <cell anchor='west'>
+ <JLabel
+ id='catchTotalSortedCarousselWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField
+ id='catchTotalSortedCarousselWeightField'/>
+ </cell>
+ <cell anchor='west'>
+ <JLabel id='catchTotalSortedTremisWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField
+ id='catchTotalSortedTremisWeightField'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
<!--Poids total hors vrac-->
<row>
<cell>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -123,14 +123,6 @@
setCustomTab(2, ui.getBenthosTabContent().getModel());
setCustomTab(3, ui.getMarineLitterTabContent().getModel());
- getParentUi().getFishingOperationTabContent().getModel()
- .addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_VESSEL, new PropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent evt) {
- Vessel vessel = (Vessel) evt.getNewValue();
- selectCatchTotalSortedWeightPanel(vessel);
- }
- });
}
@Override
@@ -407,15 +399,4 @@
}
}
- public void selectCatchTotalSortedWeightPanel(Vessel vessel) {
- String card;
- String carousselTremieVesselId = getConfig().getTremieCarousselVesselId();
- if (vessel != null && vessel.getId().equals(carousselTremieVesselId)) {
- card = CAROUSSEL_TREMIE_VESSEL;
- } else {
- card = CLASSIC_VESSEL;
- }
- ui.getCatchTotalSortedWeightPanelLayout().setSelected(card);
- }
-
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -54,8 +54,6 @@
protected File importedCarrouselFile;
- protected File importedSpeciesFile;
-
protected ImportPupitriPopupUI importPupitriDialog;
protected TuttiProtocol currentProtocol;
@@ -80,25 +78,11 @@
@Override
protected boolean prepareAction() throws Exception {
- boolean result;
+ boolean result = true;
+ currentProtocol = getDataContext().getProtocol();
- if (!getContext().isProtocolFilled()) {
- result = false;
-
- } else {
- currentProtocol = getDataContext().getProtocol();
- result = currentProtocol != null && !currentProtocol.getSpecies().isEmpty();
- }
-
- if (!result) {
- JOptionPane.showMessageDialog(getContext().getActionUI(),
- _("tutti.editCatchBatch.action.importPupitri.noProtocol.message"),
- _("tutti.editCatchBatch.action.importPupitri.noProtocol.title"),
- JOptionPane.ERROR_MESSAGE);
- }
-
SpeciesBatchUIModel speciesBatchUIModel = getUI().getSpeciesTabContent().getModel();
- if (result && speciesBatchUIModel.getRowCount() > 0) {
+ if (speciesBatchUIModel.getRowCount() > 0) {
String htmlMessage = String.format(
AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
_("tutti.editCatchBatch.action.importPupitri.existingData.message"),
@@ -117,10 +101,8 @@
importPupitriDialog.open();
importedTrunkFile = importPupitriDialog.getTrunkFile().getSelectedFile();
importedCarrouselFile = importPupitriDialog.getCarrouselFile().getSelectedFile();
- importedSpeciesFile = importPupitriDialog.getSpeciesFile().getSelectedFile();
result = importedTrunkFile != null
- && importedCarrouselFile != null
- && importedSpeciesFile != null;
+ && importedCarrouselFile != null;
}
return result;
@@ -136,27 +118,21 @@
FishingOperation operation = model.getFishingOperation();
CatchBatch catchBatch = model.getCatchBatch();
- // import trunk
- pupitriImportExportService.importPupitri(importedTrunkFile,
- importedCarrouselFile,
- importedSpeciesFile,
- operation,
- catchBatch,
- getDataContext().getReferentSpeciesWithSurveyCode());
+ // import
+ int rejectedSpeciesNb =
+ pupitriImportExportService.importPupitri(importedTrunkFile,
+ importedCarrouselFile,
+ operation,
+ catchBatch);
String fishingOperationText = getEditAction().getFishingOperationTitle(operation);
getEditAction().loadCatchBatch(operation, fishingOperationText, true);
+ sendMessage(_("tutti.editCatchBatch.action.importPupitri.success", getUI().getSpeciesTabContent().getModel().getRootNumber(), rejectedSpeciesNb));
}
@Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage("TODO");
- }
-
- @Override
protected void releaseAction() {
super.releaseAction();
importedTrunkFile = null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css 2013-04-05 13:36:16 UTC (rev 739)
@@ -51,18 +51,6 @@
acceptAllFileFilterUsed: false;
}
-#speciesFileLabel {
- text: "tutti.importPupitri.field.speciesFile";
- labelFor: {carrouselFile};
-}
-
-#speciesFile {
- directoryEnabled: false;
- exts: {_("tutti.importPupitri.speciesFile.extension")};
- extsDescription: {_("tutti.importPupitri.speciesFile.extension.description")};
- acceptAllFileFilterUsed: false;
-}
-
#cancelButton {
actionIcon: cancel;
text: "tutti.common.cancel";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx 2013-04-05 13:36:16 UTC (rev 739)
@@ -81,15 +81,6 @@
</row>
<row>
- <cell>
- <JLabel id='speciesFileLabel'/>
- </cell>
- <cell weightx='1'>
- <FileEditor id='speciesFile'/>
- </cell>
- </row>
-
- <row>
<cell columns='2'>
<JPanel layout='{new GridLayout(1,0)}'>
<JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -67,7 +67,6 @@
protected void resetFields() {
ui.getTrunkFile().setSelectedFile((String) null);
ui.getCarrouselFile().setSelectedFile((String) null);
- ui.getSpeciesFile().setSelectedFile((String) null);
}
public void open() {
@@ -83,8 +82,7 @@
public void validate() {
if (ui.getTrunkFile().getSelectedFile() != null
- && ui.getCarrouselFile().getSelectedFile() != null
- && ui.getSpeciesFile().getSelectedFile() != null) {
+ && ui.getCarrouselFile().getSelectedFile() != null) {
ui.dispose();
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategory.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -154,6 +154,14 @@
return isEmpty() || isValid();
}
+ public Float getNotNullWeight() {
+ Float result = categoryWeight;
+ if (result == null) {
+ result = computedWeight;
+ }
+ return result;
+ }
+
@Override
public String toString() {
return new ReflectionToStringBuilder(this).
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -68,7 +68,7 @@
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
- public static final String PROPERTY_SORTED_UNSORTED_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight";
+ public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight";
public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
@@ -76,22 +76,30 @@
public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight";
+ public static final String PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
+
public static final String PROPERTY_SEX_CATEGORY = "sexCategory";
public static final String PROPERTY_SEX_CATEGORY_VALUE = "sexCategoryValue";
public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight";
+ public static final String PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT = "sexCategoryComputedWeight";
+
public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory";
public static final String PROPERTY_MATURITY_CATEGORY_VALUE = "maturityCategoryValue";
+ public static final String PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT = "maturityCategoryComputedWeight";
+
public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight";
public static final String PROPERTY_AGE_CATEGORY = "ageCategory";
public static final String PROPERTY_AGE_CATEGORY_VALUE = "ageCategoryValue";
+ public static final String PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT = "ageCategoryComputedWeight";
+
public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
public static final String PROPERTY_WEIGHT = "weight";
@@ -349,10 +357,12 @@
Object oldCategory = getSortedUnsortedCategory();
Object oldValue = getSortedUnsortedCategoryValue();
Object oldWeight = getSortedUnsortedCategoryWeight();
+ Object oldComputedWeight = getSortedUnsortedCategoryComputedWeight();
this.sortedUnsortedCategory = sortedUnsortedCategory;
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldCategory, sortedUnsortedCategory);
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE, oldValue, getSortedUnsortedCategoryValue());
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldWeight, getSortedUnsortedCategoryWeight());
+ firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSortedUnsortedCategoryComputedWeight());
}
public CaracteristicQualitativeValue getSortedUnsortedCategoryValue() {
@@ -369,6 +379,16 @@
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight);
}
+ public Float getSortedUnsortedCategoryComputedWeight() {
+ return sortedUnsortedCategory.getComputedWeight();
+ }
+
+ public void setSortedUnsortedCategoryComputedWeight(Float sortedUnsortedCategoryComputedWeight) {
+ Object oldValue = getSortedUnsortedCategoryComputedWeight();
+ sortedUnsortedCategory.setComputedWeight(sortedUnsortedCategoryComputedWeight);
+ firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_COMPUTED_WEIGHT, oldValue, sortedUnsortedCategoryComputedWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Size category --//
//------------------------------------------------------------------------//
@@ -381,10 +401,12 @@
Object oldCategory = getSizeCategory();
Object oldValue = getSizeCategoryValue();
Object oldWeight = getSizeCategoryWeight();
+ Object oldComputedWeight = getSizeCategoryComputedWeight();
this.sizeCategory = sizeCategory;
firePropertyChange(PROPERTY_SIZE_CATEGORY, oldCategory, sizeCategory);
firePropertyChange(PROPERTY_SIZE_CATEGORY_VALUE, oldValue, getSizeCategoryValue());
firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldWeight, getSizeCategoryWeight());
+ firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSizeCategoryComputedWeight());
}
public CaracteristicQualitativeValue getSizeCategoryValue() {
@@ -401,6 +423,16 @@
firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight);
}
+ public Float getSizeCategoryComputedWeight() {
+ return sizeCategory.getComputedWeight();
+ }
+
+ public void setSizeCategoryComputedWeight(Float sizeCategoryComputedWeight) {
+ Object oldValue = getSizeCategoryComputedWeight();
+ this.sizeCategory.setComputedWeight(sizeCategoryComputedWeight);
+ firePropertyChange(PROPERTY_SIZE_CATEGORY_COMPUTED_WEIGHT, oldValue, sizeCategoryComputedWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Sex category --//
//------------------------------------------------------------------------//
@@ -413,10 +445,12 @@
Object oldCategory = getSexCategory();
Object oldValue = getSexCategoryValue();
Object oldWeight = getSexCategoryWeight();
+ Object oldComputedWeight = getSexCategoryComputedWeight();
this.sexCategory = sexCategory;
firePropertyChange(PROPERTY_SEX_CATEGORY, oldCategory, sexCategory);
firePropertyChange(PROPERTY_SEX_CATEGORY_VALUE, oldValue, getSexCategoryValue());
firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldWeight, getSexCategoryWeight());
+ firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getSexCategoryComputedWeight());
}
public CaracteristicQualitativeValue getSexCategoryValue() {
@@ -433,6 +467,16 @@
firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight);
}
+ public Float getSexCategoryComputedWeight() {
+ return sexCategory.getComputedWeight();
+ }
+
+ public void setSexCategoryComputedWeight(Float sexCategoryComputedWeight) {
+ Object oldValue = getSexCategoryComputedWeight();
+ this.sexCategory.setComputedWeight(sexCategoryComputedWeight);
+ firePropertyChange(PROPERTY_SEX_CATEGORY_COMPUTED_WEIGHT, oldValue, sexCategoryComputedWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Maturity category --//
//------------------------------------------------------------------------//
@@ -445,10 +489,12 @@
Object oldCategory = getMaturityCategory();
Object oldValue = getMaturityCategoryValue();
Object oldWeight = getMaturityCategoryWeight();
+ Object oldComputedWeight = getMaturityCategoryComputedWeight();
this.maturityCategory = maturityCategory;
firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldCategory, maturityCategory);
firePropertyChange(PROPERTY_MATURITY_CATEGORY_VALUE, oldValue, getMaturityCategoryValue());
firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldWeight, getMaturityCategoryWeight());
+ firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getMaturityCategoryComputedWeight());
}
public CaracteristicQualitativeValue getMaturityCategoryValue() {
@@ -465,6 +511,16 @@
firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight);
}
+ public Float getMaturityCategoryComputedWeight() {
+ return maturityCategory.getComputedWeight();
+ }
+
+ public void setMaturityCategoryComputedWeight(Float maturityCategoryComputedWeight) {
+ Object oldValue = getMaturityCategoryComputedWeight();
+ this.maturityCategory.setComputedWeight(maturityCategoryComputedWeight);
+ firePropertyChange(PROPERTY_MATURITY_CATEGORY_COMPUTED_WEIGHT, oldValue, maturityCategoryComputedWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Age category --//
//------------------------------------------------------------------------//
@@ -477,11 +533,12 @@
Object oldCategory = getAgeCategory();
Object oldValue = getAgeCategoryValue();
Object oldWeight = getAgeCategoryWeight();
+ Object oldComputedWeight = getAgeCategoryComputedWeight();
this.ageCategory = ageCategory;
-
firePropertyChange(PROPERTY_AGE_CATEGORY, oldCategory, ageCategory);
firePropertyChange(PROPERTY_AGE_CATEGORY_VALUE, oldValue, getAgeCategoryValue());
firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldWeight, getAgeCategoryWeight());
+ firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldComputedWeight, getAgeCategoryComputedWeight());
}
public Float getAgeCategoryValue() {
@@ -498,6 +555,16 @@
firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight);
}
+ public Float getAgeCategoryComputedWeight() {
+ return ageCategory.getComputedWeight();
+ }
+
+ public void setAgeCategoryComputedWeight(Float ageCategoryComputedWeight) {
+ Object oldValue = getAgeCategoryComputedWeight();
+ ageCategory.setComputedWeight(ageCategoryComputedWeight);
+ firePropertyChange(PROPERTY_AGE_CATEGORY_COMPUTED_WEIGHT, oldValue, ageCategoryComputedWeight);
+ }
+
//------------------------------------------------------------------------//
//-- Navigation properties --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -983,7 +983,7 @@
}
}
- protected BenthosBatchRowModel loadBatch(SpeciesBatch aBatch,
+ public BenthosBatchRowModel loadBatch(SpeciesBatch aBatch,
BenthosBatchRowModel parentRow,
List<BenthosBatchRowModel> rows) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -72,12 +72,9 @@
tableModel.getEntry(selectedRowIndex);
Float sampleWeight = null;
- if (selectedRow.getFinestCategory().getCategoryWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getCategoryWeight();
+ if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
+ alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
- } else if (selectedRow.getFinestCategory().getComputedWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getComputedWeight();
-
} else if (selectedRow.getWeight() != null) {
sampleWeight = selectedRow.getWeight();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -72,12 +72,9 @@
tableModel.getEntry(selectedRowIndex);
Float sampleWeight = null;
- if (selectedRow.getFinestCategory().getCategoryWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getCategoryWeight();
+ if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
+ alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
- } else if (selectedRow.getFinestCategory().getComputedWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getComputedWeight();
-
} else if (selectedRow.getWeight() != null) {
sampleWeight = selectedRow.getWeight();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -742,7 +742,9 @@
}
}
- public void splitBatch(SampleCategoryEnum sampleCategoryEnum, List<SplitSpeciesBatchRowModel> rows) {
+ public void splitBatch(SampleCategoryEnum sampleCategoryEnum,
+ List<SplitSpeciesBatchRowModel> rows,
+ Float totalRowWeight) {
JXTable table = getTable();
// get selected row
@@ -753,6 +755,9 @@
// Create rows in batch table model
+ Float parentWeight = parentBatch.getFinestCategory().getNotNullWeight();
+ boolean subSample = parentWeight != null && totalRowWeight != null
+ && parentWeight > totalRowWeight;
List<SpeciesBatchRowModel> newBatches = Lists.newArrayList();
for (SplitSpeciesBatchRowModel row : rows) {
if (row.isValid()) {
@@ -764,8 +769,11 @@
newBatch,
sampleCategoryEnum,
row.getCategoryValue(),
- row.getWeight());
+ row.getWeight(),
+ null);
+ newBatch.getFinestCategory().setSubSample(subSample);
+
recomputeRowValidState(newBatch);
newBatches.add(newBatch);
@@ -991,7 +999,7 @@
}
}
- protected SpeciesBatchRowModel loadBatch(SpeciesBatch aBatch,
+ public SpeciesBatchRowModel loadBatch(SpeciesBatch aBatch,
SpeciesBatchRowModel parentRow,
List<SpeciesBatchRowModel> rows) {
@@ -1026,7 +1034,8 @@
newRow,
sampleCategoryEnum,
aBatch.getSampleCategoryValue(),
- aBatch.getSampleCategoryWeight());
+ aBatch.getSampleCategoryWeight(),
+ aBatch.getSampleCategoryComputedWeight());
rows.add(newRow);
@@ -1037,10 +1046,28 @@
List<SpeciesBatchRowModel> batchChilds = Lists.
newArrayListWithCapacity(aBatch.sizeChildBatchs());
+ Float childrenWeights = 0f;
for (SpeciesBatch childBatch : aBatch.getChildBatchs()) {
SpeciesBatchRowModel childRow = loadBatch(childBatch, newRow, rows);
+ if (childrenWeights != null) {
+ Float weight = childRow.getFinestCategory().getNotNullWeight();
+ if (weight == null) {
+ childrenWeights = null;
+ } else {
+ childrenWeights += weight;
+ }
+ }
+
batchChilds.add(childRow);
}
+
+ Float rowWeight = newRow.getFinestCategory().getNotNullWeight();
+ boolean subSample = rowWeight != null && childrenWeights != null
+ && childrenWeights < rowWeight;
+ for (SpeciesBatchRowModel childRow : batchChilds) {
+ childRow.getFinestCategory().setSubSample(subSample);
+ }
+
newRow.setChildBatch(batchChilds);
}
@@ -1051,7 +1078,8 @@
SpeciesBatchRowModel newRow,
SampleCategoryEnum sampleCategoryEnum,
Serializable categoryValue,
- Float categoryWeight) {
+ Float categoryWeight,
+ Float categoryComputedWeight) {
// get sample category from his type
SampleCategory sampleCategory =
@@ -1060,6 +1088,7 @@
// fill it
sampleCategory.setCategoryValue(categoryValue);
sampleCategory.setCategoryWeight(categoryWeight);
+ sampleCategory.setComputedWeight(categoryComputedWeight);
// push it back to row as his *main* sample category
newRow.setSampleCategory(sampleCategory);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -304,7 +304,8 @@
if (model.isValid()) {
parent.getSpeciesTabContent().getHandler().splitBatch(
model.getSelectedCategory(),
- model.getRows());
+ model.getRows(),
+ model.getSampleWeight());
}
// close dialog
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -119,8 +119,10 @@
// update rows in model
model.setBenthosRow(rows);
+ getHandler().getBenthosTableModel().setRows(rows);
+
int nbSynonym = 0;
- for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
+ for (SpeciesProtocol speciesProtocol : protocol.getBenthos()) {
if (!speciesProtocol.isMadeFromAReferentTaxon()) {
nbSynonym++;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-04-05 13:36:16 UTC (rev 739)
@@ -119,6 +119,8 @@
// update rows in model
model.setSpeciesRow(rows);
+ getHandler().getSpeciesTableModel().setRows(rows);
+
int nbSynonym = 0;
for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
if (!speciesProtocol.isMadeFromAReferentTaxon()) {
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-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -310,6 +310,7 @@
tutti.editCatchBatch.action.importPupitri.mnemonic=
tutti.editCatchBatch.action.importPupitri.noProtocol.message=
tutti.editCatchBatch.action.importPupitri.noProtocol.title=
+tutti.editCatchBatch.action.importPupitri.success=
tutti.editCatchBatch.action.importPupitri.tip=
tutti.editCatchBatch.action.saveCatchBatch=
tutti.editCatchBatch.action.saveCatchBatch.mnemonic=
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-04-04 19:49:47 UTC (rev 738)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-05 13:36:16 UTC (rev 739)
@@ -108,7 +108,7 @@
tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=
tutti.createBenthosBatch.field.species=Espèce du lot
tutti.createBenthosBatch.field.species.tip=
-tutti.createBenthosBatch.title=Créer un lôt
+tutti.createBenthosBatch.title=Créer un lot
tutti.createBenthosMelag.action.cancel=Annuler
tutti.createBenthosMelag.action.cancel.mnemonic=A
tutti.createBenthosMelag.action.cancel.tip=Annuler la création du MELAG
@@ -319,6 +319,7 @@
tutti.editCatchBatch.action.importPupitri.mnemonic=I
tutti.editCatchBatch.action.importPupitri.noProtocol.message=
tutti.editCatchBatch.action.importPupitri.noProtocol.title=
+tutti.editCatchBatch.action.importPupitri.success=
tutti.editCatchBatch.action.importPupitri.tip=Import Pupitri
tutti.editCatchBatch.action.saveCatchBatch=Sauver
tutti.editCatchBatch.action.saveCatchBatch.mnemonic=S
@@ -1101,4 +1102,4 @@
tutti.vesselUseFeatureTable.action.removeCaracteristic.tip=Supprimer la caractéristique
tutti.vesselUseFeatureTable.table.header.key=Caractéristique
tutti.vesselUseFeatureTable.table.header.value=Valeur
-tutti.vesselUseFeatureTable.title=Hydrologie et paramètres environnementaux
+tutti.vesselUseFeatureTable.title=Autres paramètres
1
0
r738 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches java/fr/ifremer/tutti/ui/swing/util java/fr/ifremer/tutti/ui/swing/util/attachment resources/i18n
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:49:47 +0200 (Thu, 04 Apr 2013)
New Revision: 738
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/738
Log:
fixes #2242: [ERGO] - Impossible de t?\195?\169l?\195?\169charger une pi?\195?\168ce-jointe
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-04 19:09:48 UTC (rev 737)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-04 19:49:47 UTC (rev 738)
@@ -352,10 +352,10 @@
</tab>
<tab id='marineLitterTab' title='tutti.label.tab.marineLitter'>
<JPanel id='marineLitterTabPanel'>
- <JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'>
+ <JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'
+ constraints='EditCatchesUIHandler.MAIN_CARD'>
<MarineLitterBatchUI id='marineLitterTabContent'
- constructorParams='this'
- constraints='EditCatchesUIHandler.MAIN_CARD'/>
+ constructorParams='this'/>
</JXTitledPanel>
<JXTitledPanel id='marineLitterTabCreateBatchReminderLabel'
constraints='EditCatchesUIHandler.CREATE_BATCH_CARD'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-04-04 19:09:48 UTC (rev 737)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-04-04 19:49:47 UTC (rev 738)
@@ -37,6 +37,7 @@
import org.jdesktop.swingx.decorator.Highlighter;
import org.nuiton.util.FileUtil;
+import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.Color;
@@ -96,6 +97,34 @@
}
/**
+ * Sauver un fichier via un sélecteur graphique de fichiers.
+ *
+ * @param parent le component swing appelant le controle
+ * @param title le titre du dialogue de sélection
+ * @param buttonLabel le label du boutton d'acceptation
+ * @param filters les filtres + descriptions sur le sélecteur de
+ * fichiers
+ * @return le fichier choisi ou le fichier incoming si l'opération a été
+ * annulée
+ */
+ public static File saveFile(String filename,
+ Component parent,
+ String title,
+ String buttonLabel,
+ String... filters) {
+
+ File file = saveFile(filename, title, buttonLabel, parent, filters);
+ if (log.isDebugEnabled()) {
+ log.debug(title + " : " + file);
+ }
+ if (file != null) {
+ Preconditions.checkState(!file.isDirectory());
+ FileUtil.setCurrentDirectory(file.getParentFile());
+ }
+ return file;
+ }
+
+ /**
* Choisir un répertoire via un sélecteur graphique de fichiers.
*
* @param parent le component swing appelant le controle
@@ -305,4 +334,87 @@
}
}
+ //TODO Move this to jaxx (but not to nuiton-utils)
+
+ /**
+ * Retourne le nom du fichier entre dans la boite de dialogue.
+ * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null.
+ *
+ * @param title le titre de la boite de dialogue
+ * @param approvalText le label du boutton d'acceptation
+ * @param parent le component parent du dialog
+ * @param patternOrDescriptionFilters les filtres a utiliser, les chaines doivent etre données
+ * par deux, le pattern du filtre + la description du filtre
+ * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé
+ */
+ public static File saveFile(String filename,
+ String title,
+ String approvalText,
+ Component parent,
+ String... patternOrDescriptionFilters) {
+
+ if (patternOrDescriptionFilters.length % 2 != 0) {
+ throw new IllegalArgumentException(
+ "Arguments must be (pattern, description) couple");
+ }
+ javax.swing.filechooser.FileFilter[] filters =
+ new javax.swing.filechooser.FileFilter[
+ patternOrDescriptionFilters.length / 2];
+ for (int i = 0; i < filters.length; i++) {
+ String pattern = patternOrDescriptionFilters[i * 2];
+ String description = patternOrDescriptionFilters[i * 2 + 1];
+ filters[i] = new FileUtil.PatternChooserFilter(pattern, description);
+ }
+ File result;
+ result = saveFile(filename, title, approvalText, parent, filters);
+ return result;
+ }
+
+ //TODO Move this to jaxx (but not to nuiton-utils)
+
+ /**
+ * Retourne le nom du fichier entre dans la boite de dialogue.
+ * Si le bouton annuler est utilisé, ou qu'il y a une erreur retourne null.
+ *
+ * @param title le titre de la boite de dialogue
+ * @param approvalText le label du boutton d'acceptation
+ * @param parent le component parent du dialog
+ * @param filters les filtres a ajouter
+ * @return le fichier accepté, ou null si rien n'est chois ou l'utilisateur a annulé
+ */
+ public static File saveFile(String filename,
+ String title,
+ String approvalText,
+ Component parent,
+ javax.swing.filechooser.FileFilter... filters) {
+ File selectedFile = new File(FileUtil.getCurrentDirectory(), filename);
+ JFileChooser chooser = new JFileChooser(selectedFile);
+
+ chooser.setDialogType(JFileChooser.SAVE_DIALOG);
+ chooser.setSelectedFile(selectedFile);
+ if (filters.length > 0) {
+ if (filters.length == 1) {
+ chooser.setFileFilter(filters[0]);
+ } else {
+ for (javax.swing.filechooser.FileFilter filter : filters) {
+ chooser.addChoosableFileFilter(filter);
+ }
+ }
+ }
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ chooser.setDialogTitle(title);
+
+ File result = null;
+
+ int returnVal = chooser.showDialog(parent, approvalText);
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ result = chooser.getSelectedFile();
+ if (result != null) {
+ FileUtil.setCurrentDirectory(result);
+ result = result.getAbsoluteFile();
+ }
+ }
+ return result;
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx 2013-04-04 19:09:48 UTC (rev 737)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx 2013-04-04 19:49:47 UTC (rev 738)
@@ -21,7 +21,8 @@
<http://www.gnu.org/licenses/gpl-3.0.html>.
#L%
-->
-<JDialog id='attachmentDialog' layout='{new BorderLayout()}'>
+<JDialog id='attachmentDialog' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<TuttiUIContext, AttachmentEditorUIHandler>'>
<import>
fr.ifremer.tutti.ui.swing.TuttiUIContext
@@ -31,6 +32,19 @@
javax.swing.JComponent
</import>
+ <!-- if true, display the form to add attachments
+ and the button to remove existing attachments -->
+ <Boolean id='editable' javaBean='true'/>
+
+ <!-- bean property -->
+ <AttachmentModelAware id='bean' javaBean='null'/>
+
+ <TuttiUIContext id='model'
+ initializer='getContextValue(TuttiUIContext.class)'/>
+
+ <AttachmentEditorUIHandler id='handler'
+ initializer='getContextValue(AttachmentEditorUIHandler.class)'/>
+
<script><![CDATA[
public AttachmentEditorUI(TuttiUIContext context) {
@@ -54,16 +68,6 @@
}
]]></script>
- <!-- if true, display the form to add attachments
- and the button to remove existing attachments -->
- <Boolean id='editable' javaBean='true'/>
-
- <!-- bean property -->
- <AttachmentModelAware id='bean' javaBean='null'/>
-
- <AttachmentEditorUIHandler id='handler'
- initializer='getContextValue(AttachmentEditorUIHandler.class)'/>
-
<JXTitledPanel id='attachmentBody' constraints='BorderLayout.CENTER'>
<JScrollPane id='attachmentBodyScrollPane'>
<Table id='mainPanel'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-04 19:49:47 UTC (rev 738)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.service.PersistenceService;
@@ -33,7 +34,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ComponentMover;
import jaxx.runtime.swing.ComponentResizer;
-import org.apache.commons.io.FileUtils;
+import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,7 +52,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
-import java.io.IOException;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -61,7 +61,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class AttachmentEditorUIHandler {
+public class AttachmentEditorUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, AttachmentEditorUI> {
/** Logger. */
private static final Log log =
@@ -79,15 +79,18 @@
public AttachmentEditorUIHandler(TuttiUIContext context,
AttachmentEditorUI ui) {
+ super(context, ui);
this.context = context;
this.ui = ui;
this.persistenceService = context.getPersistenceService();
}
- protected void beforeInitUI() {
+ @Override
+ public void beforeInitUI() {
}
- protected void afterInitUI() {
+ @Override
+ public void afterInitUI() {
ui.getFile().setDialogOwner(ui);
ui.pack();
@@ -151,6 +154,15 @@
ui.getAttachmentBody().setRightDecoration(jToolBar);
}
+ @Override
+ public void onCloseUI() {
+ }
+
+ @Override
+ public SwingValidator<TuttiUIContext> getValidator() {
+ return null;
+ }
+
protected Action closeAction;
protected Action openAction;
@@ -253,46 +265,53 @@
}
try {
File attachmentFile = persistenceService.getAttachmentFile(attachment.getId());
- File file = TuttiUIUtil.chooseFile(ui,
- _("tutti.attachmentEditor.saveAttachment.title"),
- _("tutti.attachmentEditor.saveAttachment.button"));
+ File file = TuttiUIUtil.saveFile(
+ attachment.getName(),
+ ui,
+ _("tutti.attachmentEditor.saveAttachment.title"),
+ _("tutti.attachmentEditor.saveAttachment.button"));
if (file != null) {
- if (file.exists()) {
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.attachmentEditor.saveAttachment.warning.message"),
- _("tutti.attachmentEditor.saveAttachment.warning.help"));
-
- int answer = JOptionPane.showConfirmDialog(ui,
- htmlMessage,
- _("tutti.attachmentEditor.saveAttachment.warning.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
-
- if (answer == JOptionPane.NO_OPTION) {
- return;
- }
+ boolean checkOverwrite = askOverwriteFile(file);
+ if (checkOverwrite) {
+ TuttiIOUtil.copyFile(attachmentFile, file, "Error while saving attachment");
+ context.showInformationMessage(
+ _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
}
- FileUtils.copyFile(attachmentFile, file);
- TuttiUIUtil.showSuccessMessage(ui,
- _("tutti.attachmentEditor.saveAttachment.success.title"),
- _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
+// if (file.exists()) {
+// String htmlMessage = String.format(
+// AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+// _("tutti.attachmentEditor.saveAttachment.warning.message"),
+// _("tutti.attachmentEditor.saveAttachment.warning.help"));
+//
+// int answer = JOptionPane.showConfirmDialog(ui,
+// htmlMessage,
+// _("tutti.attachmentEditor.saveAttachment.warning.title"),
+// JOptionPane.YES_NO_OPTION,
+// JOptionPane.WARNING_MESSAGE);
+//
+// if (answer == JOptionPane.NO_OPTION) {
+// return;
+// }
+// }
+// FileUtils.copyFile(attachmentFile, file);
+// context.showInformationMessage(
+// _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
}
if (hackDialog) {
ui.setAlwaysOnTop(true);
}
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("Error while saving attachment", e);
- }
- JOptionPane.showMessageDialog(
- ui,
- _("tutti.attachmentEditor.saveAttachment.fail.message"),
- _("tutti.attachmentEditor.saveAttachment.fail.title"),
- JOptionPane.ERROR_MESSAGE
- );
+// } catch (IOException e) {
+// if (log.isErrorEnabled()) {
+// log.error("Error while saving attachment", e);
+// }
+// JOptionPane.showMessageDialog(
+// ui,
+// _("tutti.attachmentEditor.saveAttachment.fail.message"),
+// _("tutti.attachmentEditor.saveAttachment.fail.title"),
+// JOptionPane.ERROR_MESSAGE
+// );
} finally {
if (hackDialog) {
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-04-04 19:09:48 UTC (rev 737)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-04 19:49:47 UTC (rev 738)
@@ -27,12 +27,12 @@
tutti.attachmentEditor.field.fileComment=Commentaire
tutti.attachmentEditor.field.fileName=Nom
tutti.attachmentEditor.none.tip=Pas de pièce-jointes
-tutti.attachmentEditor.saveAttachment.button=Choisir
+tutti.attachmentEditor.saveAttachment.button=Enregistrer
tutti.attachmentEditor.saveAttachment.fail.message=Une erreur est survenue lors de la sauvegarde du fichier.
tutti.attachmentEditor.saveAttachment.fail.title=Erreur de sauvegarde.
tutti.attachmentEditor.saveAttachment.success.message=Le fichier %s a été sauvegardé sur votre machine.
tutti.attachmentEditor.saveAttachment.success.title=Sauvegarde réussie.
-tutti.attachmentEditor.saveAttachment.title=Choisir un fichier
+tutti.attachmentEditor.saveAttachment.title=Sauver la pièce-jointe
tutti.attachmentEditor.saveAttachment.warning.help=Que voulez-vous faire ?<ul><li><strong>Non</strong> pour annuler la sauvegarde</li><li><strong>Oui</strong> pour écraser le fichier existant</li></ul>
tutti.attachmentEditor.saveAttachment.warning.message=Vous êtes sur le point d'écraser un fichier existant.
tutti.attachmentEditor.saveAttachment.warning.title=Fichier existant
1
0
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:09:48 +0200 (Thu, 04 Apr 2013)
New Revision: 737
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/737
Log:
fixes #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
add xml prolog on every validation file
fixes #2233: [TECH] d?\195?\169marage 1.2 sans dossier data : erreur
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel-error-validation.xml
Removed:
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/program/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/protocol/
Modified:
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
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-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,5 +1,28 @@
+###
+# #%L
+# Tutti :: UI
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 - 2013 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
-#Wed Apr 03 18:09:43 CEST 2013
+#Thu Apr 04 20:09:11 CEST 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
@@ -7,6 +30,12 @@
tutti.createBenthosBatch.field.sortedUnsortedCategory.help=createBenthosBatch.html\#fields
tutti.createBenthosBatch.field.species.help=createBenthosBatch.html\#fields
tutti.createBenthosBatch.help=createBenthosBatch.html
+tutti.createMarineLitterBatch.action.cancel.help=
+tutti.createMarineLitterBatch.action.save.help=
+tutti.createMarineLitterBatch.field.marineLitterCategory.help=
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=
+tutti.createMarineLitterBatch.field.number.help=
+tutti.createMarineLitterBatch.help=
tutti.createSpeciesBatch.action.addSpecies.help=createSpeciesBatch.html\#actions
tutti.createSpeciesBatch.action.cancel.help=createSpeciesBatch.html\#actions
tutti.createSpeciesBatch.action.save.help=createSpeciesBatch.html\#actions
@@ -118,6 +147,8 @@
tutti.editFishingOperation.field.trawlDistance.help=editFishingOperation.html\#fields
tutti.editFishingOperation.field.vessel.help=editFishingOperation.html\#fields
tutti.editFishingOperation.help=editFishingOperation.html
+tutti.editMarineLitterBatch.action.createBatch.help=
+tutti.editMarineLitterBatch.action.removeBatch.help=
tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help=
tutti.editProgram.action.cancelProgram.help=editProgram.html\#actions
tutti.editProgram.action.saveProgram.help=editProgram.html\#actions
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,5 +1,28 @@
+###
+# #%L
+# Tutti :: UI
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 - 2013 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
-#Wed Apr 03 18:09:43 CEST 2013
+#Thu Apr 04 20:09:11 CEST 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
@@ -7,6 +30,12 @@
tutti.createBenthosBatch.field.sortedUnsortedCategory.help=createBenthosBatch.html\#fields
tutti.createBenthosBatch.field.species.help=createBenthosBatch.html\#fields
tutti.createBenthosBatch.help=createBenthosBatch.html
+tutti.createMarineLitterBatch.action.cancel.help=
+tutti.createMarineLitterBatch.action.save.help=
+tutti.createMarineLitterBatch.field.marineLitterCategory.help=
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=
+tutti.createMarineLitterBatch.field.number.help=
+tutti.createMarineLitterBatch.help=
tutti.createSpeciesBatch.action.addSpecies.help=createSpeciesBatch.html\#actions
tutti.createSpeciesBatch.action.cancel.help=createSpeciesBatch.html\#actions
tutti.createSpeciesBatch.action.save.help=createSpeciesBatch.html\#actions
@@ -127,6 +156,8 @@
tutti.editFishingOperation.field.trawlDistance.help=editFishingOperation.html\#fields
tutti.editFishingOperation.field.vessel.help=editFishingOperation.html\#fields
tutti.editFishingOperation.help=editFishingOperation.html
+tutti.editMarineLitterBatch.action.createBatch.help=
+tutti.editMarineLitterBatch.action.removeBatch.help=
tutti.editMarineLitterBatch.field.marineLitterTotalWeight.help=
tutti.editProgram.action.cancelProgram.help=editProgram.html\#actions
tutti.editProgram.action.saveProgram.help=editProgram.html\#actions
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -45,7 +45,11 @@
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
-import fr.ifremer.tutti.ui.swing.util.*;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.CloseableUI;
+import fr.ifremer.tutti.ui.swing.util.RemoveablePropertyChangeListener;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.action.TuttiUIAction;
@@ -56,8 +60,12 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.I18n;
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JToolBar;
+import java.awt.Cursor;
import java.beans.PropertyChangeEvent;
import java.net.URL;
import java.util.Locale;
@@ -127,7 +135,9 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
Boolean newvalue = (Boolean) evt.getNewValue();
- getUI().getBody().setVisible(newvalue != null && newvalue);
+ if (getUI() != null && getUI().getBody() != null) {
+ getUI().getBody().setVisible(newvalue != null && newvalue);
+ }
}
});
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-04-04 19:09:48 UTC (rev 737)
@@ -267,6 +267,10 @@
_computed: true;
}
+#marineLitterTabPanel {
+ layout:{marineLitterTabPanelLayout};
+}
+
#marineLitterTable {
border: {BorderFactory.createTitledBorder(_("tutti.editCatchBatch.legend.marineLitter"))};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-04 19:09:48 UTC (rev 737)
@@ -31,6 +31,7 @@
fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create.CreateMarineLitterBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchUI
@@ -96,6 +97,9 @@
<CardLayout2Ext id='benthosTabPanelLayout'
constructorParams='this, "benthosTabPanel"'/>
+ <CardLayout2Ext id='marineLitterTabPanelLayout'
+ constructorParams='this, "marineLitterTabPanel"'/>
+
<CardLayout2Ext id='catchTotalSortedWeightPanelLayout'
constructorParams='this, "catchTotalSortedWeightPanel"'/>
@@ -347,11 +351,20 @@
</JPanel>
</tab>
<tab id='marineLitterTab' title='tutti.label.tab.marineLitter'>
- <JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'>
- <MarineLitterBatchUI id='marineLitterTabContent'
- constructorParams='this'/>
- </JXTitledPanel>
+ <JPanel id='marineLitterTabPanel'>
+ <JXTitledPanel id='marineLitterTabFishingOperationReminderLabel'>
+ <MarineLitterBatchUI id='marineLitterTabContent'
+ constructorParams='this'
+ constraints='EditCatchesUIHandler.MAIN_CARD'/>
+ </JXTitledPanel>
+ <JXTitledPanel id='marineLitterTabCreateBatchReminderLabel'
+ constraints='EditCatchesUIHandler.CREATE_BATCH_CARD'>
+ <CreateMarineLitterBatchUI id='marineLitterTabCreateBatch'
+ constructorParams='this'/>
+ </JXTitledPanel>
+ </JPanel>
</tab>
+
<tab id='planktonTab' title='tutti.label.tab.plancton'>
<!--JXTitledPanel id='planktonTabFishingOperationReminderLabel'>
<PlanktonBatchUI id='planktonTabContent' constructorParams='this'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -374,6 +374,39 @@
}
}
+ public void setMarineLitterSelectedCard(String card) {
+ JPanel panel = ui.getMarineLitterTabPanel();
+ CardLayout2Ext layout = (CardLayout2Ext) panel.getLayout();
+ if (!card.equals(layout.getSelected())) {
+ layout.setSelected(card);
+
+ JPanel actionPanel = getUI().getCreateFishingOperationActions();
+ if (MAIN_CARD.equals(card)) {
+ registerValidators();
+ actionPanel.setVisible(true);
+ } else {
+ actionPanel.setVisible(false);
+ TuttiUI tuttiUi = null;
+ JXTitledPanel titlePanel = null;
+ String title = "";
+ switch (card) {
+ case CREATE_BATCH_CARD:
+ tuttiUi = ui.getMarineLitterTabCreateBatch();
+ titlePanel = ui.getMarineLitterTabCreateBatchReminderLabel();
+ title = n_("tutti.createMarineLitterBatch.title");
+ break;
+ }
+
+ if (tuttiUi != null) {
+ registerValidators(tuttiUi.getHandler().getValidator());
+ }
+ if (titlePanel != null) {
+ titlePanel.setTitle(ui.getMarineLitterTabCreateBatchReminderLabel().getTitle() + " - " + _(title));
+ }
+ }
+ }
+ }
+
public void selectCatchTotalSortedWeightPanel(Vessel vessel) {
String card;
String carousselTremieVesselId = getConfig().getTremieCarousselVesselId();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -69,7 +69,7 @@
n_("tutti.editMarineLitterBatch.table.header.file.tip"));
public MarineLitterBatchTableModel(TableColumnModelExt columnModel) {
- super(columnModel, true, true);
+ super(columnModel, false, false);
setNoneEditableCols();
}
@@ -82,20 +82,4 @@
result.setValid(false);
return result;
}
-
- @Override
- protected boolean isCellEditable(int rowIndex,
- int columnIndex,
- ColumnIdentifier<MarineLitterBatchRowModel> propertyName) {
- boolean cellEditable = super.isCellEditable(rowIndex,
- columnIndex,
- propertyName);
- if (ATTACHMENT == propertyName) {
-
- // only editable if row exists
- MarineLitterBatchRowModel entry = getEntry(rowIndex);
- cellEditable = entry.getObjectId() != null;
- }
- return cellEditable;
- }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-04-04 19:09:48 UTC (rev 737)
@@ -69,7 +69,16 @@
sortable: false;
}
-#removeSpeciesBatchMenu {
+#createMarineLitterBatchButton {
+ actionIcon: batch-create;
+ text: "tutti.editMarineLitterBatch.action.createBatch";
+ toolTipText: "tutti.editMarineLitterBatch.action.createBatch.tip";
+ i18nMnemonic: "tutti.editMarineLitterBatch.action.createBatch.mnemonic";
+ /*enabled: {model.isCreateBatchEnabled()};*/
+ _help: {"tutti.editMarineLitterBatch.action.createBatch.help"};
+}
+
+#removeMarineLitterBatchMenu {
actionIcon: batch-delete;
text: "tutti.editMarineLitterBatch.action.removeBatch";
toolTipText: "tutti.editMarineLitterBatch.action.removeBatch.tip";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-04-04 19:09:48 UTC (rev 737)
@@ -90,10 +90,23 @@
constructorParams='this'/>
</cell>
</row>
+
+ <!-- Toolbar / Filter -->
+ <row>
+ <cell columns="2">
+ <JPanel id='tableToolbar' layout='{new BorderLayout()}'>
+ <JPanel layout='{new GridLayout(1,0)}'
+ constraints='BorderLayout.WEST'>
+ <JButton id='createMarineLitterBatchButton'
+ onActionPerformed='handler.createBatch()'/>
+ </JPanel>
+ </JPanel>
+ </cell>
+ </row>
</Table>
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table'
+ <JXTable id='table' onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'
onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
</JScrollPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -33,8 +33,11 @@
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create.CreateMarineLitterBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create.CreateMarineLitterBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -42,6 +45,8 @@
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
+import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -178,35 +183,17 @@
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MarineLitterBatchRowModel> rowMonitor,
MarineLitterBatchRowModel row) {
- if (row != null) {
+ if (row != null && row.isValid() && rowMonitor.wasModified()) {
- if (row.isValid()) {
- // there is a valid bean attached to the monitor
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
- if (rowMonitor.wasModified()) {
+ saveRow(row);
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + row + " was modified, will save it");
- }
-
- saveRow(row);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- MarineLitterBatch batch = row.toBean();
-
- if (!TuttiEntities.isNew(batch)) {
-
- // remove this
- persistenceService.deleteMarineLitterBatch(batch.getId());
- }
- }
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
}
}
@@ -389,6 +376,36 @@
//-- Public methods --//
//------------------------------------------------------------------------//
+ public void createBatch() {
+
+ EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
+ CreateMarineLitterBatchUI createBatchEditor = parent.getMarineLitterTabCreateBatch();
+
+ createBatchEditor.getHandler().openUI();
+ parent.getHandler().setMarineLitterSelectedCard(EditCatchesUIHandler.CREATE_BATCH_CARD);
+ }
+
+ public void addBatch(CreateMarineLitterBatchUIModel model) {
+ if (model.isValid()) {
+
+ MarineLitterBatchTableModel tableModel = getTableModel();
+
+ MarineLitterBatchRowModel newRow = tableModel.createNewRow();
+ newRow.setMarineLitterCategory(model.getMarineLitterCategory());
+ newRow.setMarineLitterSizeCategory(model.getMarineLitterSizeCategory());
+ newRow.setNumber(model.getNumber());
+
+ recomputeRowValidState(newRow);
+
+ saveRow(newRow);
+
+ tableModel.addNewRow(newRow);
+ AbstractSelectTableAction.doSelectCell(getTable(), tableModel.getRowCount() - 1, 0);
+ }
+
+ recomputeBatchActionEnable();
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
@@ -402,9 +419,7 @@
if (rowIndex != -1) {
// there is a selected row
-
enableRemove = true;
-
}
MarineLitterBatchUIModel model = getModel();
model.setRemoveBatchEnabled(enableRemove);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.TuttiPersistence;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css 2013-04-04 19:09:48 UTC (rev 737)
@@ -0,0 +1,94 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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%
+ */
+BeanFilterableComboBox {
+ showReset: true;
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+ showReset: true;
+}
+
+#createMarineLitterBatchTopPanel {
+ _help: {"tutti.createMarineLitterBatch.help"};
+}
+
+#marineLitterCategoryLabel {
+ text: "tutti.createMarineLitterBatch.field.marineLitterCategory";
+ toolTipText: "tutti.createMarineLitterBatch.field.marineLitterCategory.tip";
+ labelFor: {marineLitterCategoryComboBox};
+ _help: {"tutti.createMarineLitterBatch.field.marineLitterCategory.help"};
+}
+
+#marineLitterCategoryComboBox {
+ property: marineLitterCategory;
+ selectedItem: {model.getMarineLitterCategory()};
+}
+
+#marineLitterSizeCategoryLabel {
+ text: "tutti.createMarineLitterBatch.field.marineLitterSizeCategory";
+ toolTipText: "tutti.createMarineLitterBatch.field.marineLitterSizeCategory.tip";
+ labelFor: {marineLitterSizeCategoryComboBox};
+ _help: {"tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help"};
+}
+
+#marineLitterSizeCategoryComboBox {
+ property: marineLitterSizeCategory;
+ selectedItem: {model.getMarineLitterSizeCategory()};
+}
+
+#numberLabel {
+ text: "tutti.createMarineLitterBatch.field.number";
+ toolTipText: "tutti.createMarineLitterBatch.field.number.tip";
+ labelFor: {numberField};
+ _help: {"tutti.createMarineLitterBatch.field.number.help"};
+}
+
+#numberField {
+ property: number;
+ model: {model.getNumber()};
+ useFloat: true;
+ numberPattern: {DECIMAL3_PATTERN};
+ bean: {model};
+}
+
+#saveButton {
+ actionIcon: save;
+ text: "tutti.createMarineLitterBatch.action.save";
+ toolTipText: "tutti.createMarineLitterBatch.action.save.tip";
+ i18nMnemonic: "tutti.createMarineLitterBatch.action.save.mnemonic";
+ enabled: {model.isValid()};
+ _help: {"tutti.createMarineLitterBatch.action.save.help"};
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ text: "tutti.createMarineLitterBatch.action.cancel";
+ toolTipText: "tutti.createMarineLitterBatch.action.cancel.tip";
+ i18nMnemonic: "tutti.createMarineLitterBatch.action.cancel.mnemonic";
+ _help: {"tutti.createMarineLitterBatch.action.cancel.help"};
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.jaxx 2013-04-04 19:09:48 UTC (rev 737)
@@ -0,0 +1,112 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<JPanel id='createMarineLitterBatchTopPanel' layout='{new BorderLayout()}'
+ decorator='help'
+ implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<CreateMarineLitterBatchUIModel, CreateMarineLitterBatchUIHandler>'>
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue
+
+ fr.ifremer.tutti.ui.swing.TuttiHelpBroker
+ fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI
+ fr.ifremer.tutti.ui.swing.util.TuttiUI
+
+ jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
+ jaxx.runtime.swing.editor.NumberEditor
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+public CreateMarineLitterBatchUI(EditCatchesUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ CreateMarineLitterBatchUIHandler handler = new CreateMarineLitterBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <CreateMarineLitterBatchUIHandler id='handler'
+ initializer='getContextValue(CreateMarineLitterBatchUIHandler.class)'/>
+
+ <CreateMarineLitterBatchUIModel id='model'
+ initializer='getContextValue(CreateMarineLitterBatchUIModel.class)'/>
+
+ <BeanValidator id='validator' bean='model'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='marineLitterCategory'
+ component='marineLitterCategoryComboBox'/>
+ <field name='marineLitterSizeCategory'
+ component='marineLitterSizeCategoryComboBox'/>
+ <field name='number' component='numberField'/>
+ </BeanValidator>
+
+ <TuttiHelpBroker id='broker'
+ constructorParams='"tutti.createMarineLitterBatch.help"'/>
+
+ <Table id='configurationPanel' constraints='BorderLayout.CENTER' fill='both'>
+
+ <!-- MarineLitterCategory -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='marineLitterCategoryLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanFilterableComboBox id='marineLitterCategoryComboBox' constructorParams='this'
+ genericType='CaracteristicQualitativeValue'/>
+ </cell>
+ </row>
+
+ <!-- MarineLitterSizeCategory-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='marineLitterSizeCategoryLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanFilterableComboBox id='marineLitterSizeCategoryComboBox'
+ constructorParams='this'
+ genericType='CaracteristicQualitativeValue'/>
+ </cell>
+ </row>
+
+ <!-- MarineLitter number -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='numberLabel'/>
+ </cell>
+ <cell weightx='1.0' columns='2'>
+ <NumberEditor id='numberField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ </Table>
+
+ <!-- Form Actions -->
+ <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -0,0 +1,173 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
+import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.Dimension;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CreateMarineLitterBatchUIHandler extends AbstractTuttiUIHandler<CreateMarineLitterBatchUIModel, CreateMarineLitterBatchUI> implements Cancelable {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CreateMarineLitterBatchUIHandler.class);
+
+ private final TuttiPersistence persistenceService;
+
+ public CreateMarineLitterBatchUIHandler(TuttiUI parentUi,
+ CreateMarineLitterBatchUI ui) {
+ super(parentUi.getHandler().getContext(), ui);
+ this.persistenceService = context.getPersistenceService();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+ CreateMarineLitterBatchUIModel model = new CreateMarineLitterBatchUIModel();
+ ui.setContextValue(model);
+ listModelIsModify(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ Caracteristic marineLitterCategoryCaracteristic =
+ persistenceService.getMarineLitterCategoryCaracteristic();
+ initBeanFilterableComboBox(ui.getMarineLitterCategoryComboBox(),
+ marineLitterCategoryCaracteristic.getQualitativeValue(),
+ null);
+
+ Caracteristic marineLitterSizeCategoryCaracteristic =
+ persistenceService.getMarineLitterSizeCategoryCaracteristic();
+
+ initBeanFilterableComboBox(ui.getMarineLitterSizeCategoryComboBox(),
+ marineLitterSizeCategoryCaracteristic.getQualitativeValue(),
+ null);
+
+ listenValidatorValid(ui.getValidator(), getModel());
+ }
+
+ @Override
+ public void onCloseUI() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("closing: " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model
+ getModel().setValid(false);
+
+ EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
+ parent.getHandler().setMarineLitterSelectedCard(EditCatchesUIHandler.MAIN_CARD);
+ }
+
+ @Override
+ public SwingValidator<CreateMarineLitterBatchUIModel> getValidator() {
+ return ui.getValidator();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+ closeUI(ui);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void openUI() {
+
+ CreateMarineLitterBatchUIModel model = getModel();
+
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
+ model.reset();
+
+ ui.getMarineLitterCategoryComboBox().requestFocus();
+ }
+
+ public void save() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Save UI " + ui);
+ }
+
+ EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
+ parent.getMarineLitterTabContent().getHandler().addBatch(getModel());
+
+ // close dialog
+ closeUI(ui);
+ }
+
+ public Species openAddSpeciesDialog(String title, List<Species> species) {
+ SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
+ SelectSpeciesUIModel model = dialogContent.getModel();
+ model.setSelectedSpecies(null);
+ model.setSpecies(species);
+
+ openDialog(dialogContent, title, new Dimension(400, 130));
+
+ Species result = model.getSelectedSpecies();
+ return result;
+ }
+
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -0,0 +1,94 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.create;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+
+/**
+ * Model to create a new marine litter batch.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CreateMarineLitterBatchUIModel extends AbstractTuttiBeanUIModel<CreateMarineLitterBatchUIModel, CreateMarineLitterBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Delegate edit object.
+ *
+ * @since 1.3
+ */
+ protected final MarineLitterBatch editObject =
+ TuttiBeanFactory.newMarineLitterBatch();
+
+ public CreateMarineLitterBatchUIModel() {
+ super(CreateMarineLitterBatchUIModel.class, null, null);
+ }
+
+ public CaracteristicQualitativeValue getMarineLitterCategory() {
+ return editObject.getMarineLitterCategory();
+ }
+
+ public void setMarineLitterCategory(CaracteristicQualitativeValue marineLitterCategory) {
+ Object oldValue = getMarineLitterCategory();
+ editObject.setMarineLitterCategory(marineLitterCategory);
+ firePropertyChange(MarineLitterBatch.PROPERTY_MARINE_LITTER_CATEGORY, oldValue, marineLitterCategory);
+ }
+
+ public CaracteristicQualitativeValue getMarineLitterSizeCategory() {
+ return editObject.getMarineLitterSizeCategory();
+ }
+
+ public void setMarineLitterSizeCategory(CaracteristicQualitativeValue marineLitterSizeCategory) {
+ Object oldValue = getMarineLitterSizeCategory();
+ editObject.setMarineLitterSizeCategory(marineLitterSizeCategory);
+ firePropertyChange(MarineLitterBatch.PROPERTY_MARINE_LITTER_SIZE_CATEGORY, oldValue, marineLitterSizeCategory);
+ }
+
+ public Integer getNumber() {
+ return editObject.getNumber();
+ }
+
+ public void setNumber(Integer number) {
+ Object oldValue = getNumber();
+ editObject.setNumber(number);
+ firePropertyChange(MarineLitterBatch.PROPERTY_NUMBER, oldValue, number);
+ }
+
+ @Override
+ protected CreateMarineLitterBatchUIModel newEntity() {
+ return new CreateMarineLitterBatchUIModel();
+ }
+
+ public void reset() {
+ editObject.setMarineLitterCategory(null);
+ editObject.setMarineLitterSizeCategory(null);
+ editObject.setNumber(null);
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 19:09:48 UTC (rev 737)
@@ -28,7 +28,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
@@ -38,7 +37,6 @@
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -53,13 +51,11 @@
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
-import java.awt.Color;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="marineLitterCategory">
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.createMarineLitterBatch.marineLitterCategory.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="marineLitterSizeCategory">
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.createMarineLitterBatch.marineLitterSizeCategory.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="number">
+
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.createMarineLitterBatch.number.required
+ </message>
+ </field-validator>
+
+ <field-validator type="double" short-circuit="true">
+ <param name="minExclusive">0</param>
+ <message>
+ tutti.validator.error.createMarineLitterBatch.number.invalidValue
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml 2013-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml 2013-04-04 19:09:48 UTC (rev 737)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Tutti :: UI
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-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-04 19:09:48 UTC (rev 737)
@@ -116,6 +116,19 @@
tutti.createBenthosBatch.title=
tutti.createBenthosMelag.error.message=
tutti.createBenthosMelag.error.title=
+tutti.createMarineLitterBatch.action.cancel=
+tutti.createMarineLitterBatch.action.cancel.mnemonic=
+tutti.createMarineLitterBatch.action.cancel.tip=
+tutti.createMarineLitterBatch.action.save=
+tutti.createMarineLitterBatch.action.save.mnemonic=
+tutti.createMarineLitterBatch.action.save.tip=
+tutti.createMarineLitterBatch.field.marineLitterCategory=
+tutti.createMarineLitterBatch.field.marineLitterCategory.tip=
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory=
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory.tip=
+tutti.createMarineLitterBatch.field.number=
+tutti.createMarineLitterBatch.field.number.tip=
+tutti.createMarineLitterBatch.title=
tutti.createSpeciesBatch.action.addSpecies=
tutti.createSpeciesBatch.action.addSpecies.mnemonic=
tutti.createSpeciesBatch.action.addSpecies.tip=
@@ -477,6 +490,12 @@
tutti.editFishingOperation.label.traitReminder.inCreation=
tutti.editFishingOperation.pane.other=
tutti.editFishingOperation.tab.general=
+tutti.editMarineLitterBatch.action.createBatch=
+tutti.editMarineLitterBatch.action.createBatch.mnemonic=
+tutti.editMarineLitterBatch.action.createBatch.tip=
+tutti.editMarineLitterBatch.action.removeBatch=
+tutti.editMarineLitterBatch.action.removeBatch.mnemonic=
+tutti.editMarineLitterBatch.action.removeBatch.tip=
tutti.editMarineLitterBatch.field.marineLitterTotalWeight=
tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip=
tutti.editMarineLitterBatch.table.header.comment=
@@ -1007,6 +1026,10 @@
tutti.update.jre=
tutti.update.tutti=
tutti.validator.error.comment.too.long=
+tutti.validator.error.createMarineLitterBatch.marineLitterCategory.required=
+tutti.validator.error.createMarineLitterBatch.marineLitterSizeCategory.required=
+tutti.validator.error.createMarineLitterBatch.number.invalidValue=
+tutti.validator.error.createMarineLitterBatch.number.required=
tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue=
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required=
tutti.validator.error.createSpeciesBatch.species.required=
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-04-04 19:02:11 UTC (rev 736)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-04 19:09:48 UTC (rev 737)
@@ -108,7 +108,7 @@
tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=
tutti.createBenthosBatch.field.species=Espèce du lot
tutti.createBenthosBatch.field.species.tip=
-tutti.createBenthosBatch.title=Créer un lot
+tutti.createBenthosBatch.title=Créer un lôt
tutti.createBenthosMelag.action.cancel=Annuler
tutti.createBenthosMelag.action.cancel.mnemonic=A
tutti.createBenthosMelag.action.cancel.tip=Annuler la création du MELAG
@@ -119,6 +119,19 @@
tutti.createBenthosMelag.error.title=Erreur
tutti.createBenthosMelag.message=Combien pesait le MELAG (kg) ?
tutti.createBenthosMelag.title=Poids du MELAG (kg)
+tutti.createMarineLitterBatch.action.cancel=Annuler
+tutti.createMarineLitterBatch.action.cancel.mnemonic=A
+tutti.createMarineLitterBatch.action.cancel.tip=Annuler la création du lôt macro-déchet
+tutti.createMarineLitterBatch.action.save=Enregistrer
+tutti.createMarineLitterBatch.action.save.mnemonic=E
+tutti.createMarineLitterBatch.action.save.tip=Enregistrer la création du lôt macro-déchet
+tutti.createMarineLitterBatch.field.marineLitterCategory=Catégorie de déchets
+tutti.createMarineLitterBatch.field.marineLitterCategory.tip=
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory=Catégorie de taille
+tutti.createMarineLitterBatch.field.marineLitterSizeCategory.tip=
+tutti.createMarineLitterBatch.field.number=Nombre
+tutti.createMarineLitterBatch.field.number.tip=
+tutti.createMarineLitterBatch.title=Créer un lôt
tutti.createSpeciesBatch.action.addSpecies=...
tutti.createSpeciesBatch.action.addSpecies.mnemonic=.
tutti.createSpeciesBatch.action.addSpecies.tip=Sélectionner une autre espèce
@@ -484,6 +497,12 @@
tutti.editFishingOperation.label.traitReminder.inCreation=en cours de création
tutti.editFishingOperation.pane.other=Autres caractéristiques
tutti.editFishingOperation.tab.general=Trait
+tutti.editMarineLitterBatch.action.createBatch=Créer un lot de déchet
+tutti.editMarineLitterBatch.action.createBatch.mnemonic=C
+tutti.editMarineLitterBatch.action.createBatch.tip=Créer un nouveau lot de déchet
+tutti.editMarineLitterBatch.action.removeBatch=Supprimer la ligne sélectionnée
+tutti.editMarineLitterBatch.action.removeBatch.mnemonic=S
+tutti.editMarineLitterBatch.action.removeBatch.tip=Supprimer la ligne sélectionnée
tutti.editMarineLitterBatch.field.marineLitterTotalWeight=Poids total (Kg)
tutti.editMarineLitterBatch.field.marineLitterTotalWeight.tip=Poids total (Kg)
tutti.editMarineLitterBatch.table.header.comment=Commentaire
@@ -1011,6 +1030,10 @@
tutti.update.jre=Java
tutti.update.tutti=Tutti
tutti.validator.error.comment.too.long=Taille de commentaire trop longue (limitée à %s caractères)
+tutti.validator.error.createMarineLitterBatch.marineLitterCategory.required=
+tutti.validator.error.createMarineLitterBatch.marineLitterSizeCategory.required=
+tutti.validator.error.createMarineLitterBatch.number.invalidValue=
+tutti.validator.error.createMarineLitterBatch.number.required=
tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue=Le poids du lot doit être strictement positif
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required=La catégorie Vrac / Hors Vrac est obligatoire
tutti.validator.error.createSpeciesBatch.species.required=L'espèce est obligatoire
1
0
r736 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:02:11 +0200 (Thu, 04 Apr 2013)
New Revision: 736
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/736
Log:
reformat + import + ...
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-04 19:01:21 UTC (rev 735)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-04-04 19:02:11 UTC (rev 736)
@@ -1,7 +1,36 @@
package fr.ifremer.tutti.service.catches;
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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 fr.ifremer.tutti.TuttiBusinessException;
-import fr.ifremer.tutti.persistence.entities.data.*;
+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.SortedUnsortedEnum;
+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 fr.ifremer.tutti.service.AbstractTuttiService;
import fr.ifremer.tutti.service.PersistenceService;
@@ -10,7 +39,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.*;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -33,8 +61,8 @@
}
public void computeCatchBatchWeights(CatchBatch catchBatch,
- BatchContainer<SpeciesBatch> rootSpeciesBatch,
- BatchContainer<SpeciesBatch> rootBenthosBatch) {
+ BatchContainer<SpeciesBatch> rootSpeciesBatch,
+ BatchContainer<SpeciesBatch> rootBenthosBatch) {
// Species
Float speciesTotalComputedSortedWeight = 0f;
@@ -165,11 +193,10 @@
+ totalSortedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
- } else {
- catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
- - totalUnsortedWeight
- - totalSortedWeight);
}
+ catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
+ - totalUnsortedWeight
+ - totalSortedWeight);
} else if (totalWeight == null) {
if (rejectedWeight == null) {
@@ -177,8 +204,8 @@
catchBatch.setCatchTotalRejectedComputedWeight(0f);
}
catchBatch.setCatchTotalComputedWeight(totalUnsortedWeight
- + totalSortedWeight
- + rejectedWeight);
+ + totalSortedWeight
+ + rejectedWeight);
} else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
throw new TuttiBusinessException(_("tutti.service.catches.computeWeights.error.incoherentTotal"));
@@ -193,8 +220,7 @@
if (rootSpeciesBatch != null) {
List<SpeciesBatch> roots = rootSpeciesBatch.getChildren();
- for (int i = 0; i < roots.size(); i++) {
- SpeciesBatch batch = roots.get(i);
+ for (SpeciesBatch batch : roots) {
computeSpeciesBatch(batch);
}
}
@@ -209,8 +235,7 @@
List<SpeciesBatch> roots = rootBenthosBatch.getChildren();
- for (int i = 0; i < roots.size(); i++) {
- SpeciesBatch batch = roots.get(i);
+ for (SpeciesBatch batch : roots) {
computeSpeciesBatch(batch);
}
@@ -300,7 +325,7 @@
result = frequencyWeight;
} else if (frequencyWeight != null
- && !frequencyWeight.equals(categoryWeight)) {
+ && !frequencyWeight.equals(categoryWeight)) {
// if the weight of the frequencies is different from the category
// weight, then set the weight of the sample
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r735 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 21:01:21 +0200 (Thu, 04 Apr 2013)
New Revision: 735
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/735
Log:
fixes #2248: [TECH] Pi?\195?\168ces-jointes non supprim?\195?\169es
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -24,10 +24,12 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -43,6 +45,9 @@
private static final Log log =
LogFactory.getLog(AccidentalBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Override
public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) {
List<AccidentalBatch> result = Lists.newArrayList();
@@ -68,5 +73,7 @@
@Override
public void deleteAccidentalBatch(String id) {
+ Preconditions.checkNotNull(id);
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -85,4 +85,12 @@
@Transactional(readOnly = false)
void deleteAttachment(String attachmentId);
+ /**
+ * Deletes all attachments of the given object id.
+ *
+ * @param objectId id of the object
+ */
+ @Transactional(readOnly = false)
+ void deleteAllAttachment(Integer objectId);
+
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -236,12 +236,17 @@
Attachment target = TuttiBeanFactory.newAttachment();
loadAttachment(source, target);
- measurementFileDao.remove(id);
+ delete(target);
+
getCurrentSession().flush();
+ }
- File file = getFile(target);
- //TODO Hum we do not have a transaction manager for file :(
- TuttiIOUtil.deleteFile(file, "Could not delete attachement file " + file);
+ @Override
+ public void deleteAllAttachment(Integer objectId) {
+ List<Attachment> attachments = getAllAttachments(objectId);
+ for (Attachment attachment : attachments) {
+ delete(attachment);
+ }
}
//------------------------------------------------------------------------//
@@ -269,4 +274,13 @@
File result = new File(dbAttachmentDirectory, attachment.getPath());
return result;
}
+
+ protected void delete(Attachment target) {
+
+ measurementFileDao.remove(target.getObjectId());
+
+ File file = getFile(target);
+ TuttiIOUtil.deleteFile(file, "Could not delete attachement file " + file);
+
+ }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -39,6 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -61,9 +62,12 @@
private static final Log log =
LogFactory.getLog(BenthosBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -188,8 +192,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -46,6 +46,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
import org.hibernate.type.IntegerType;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Service;
@@ -63,9 +64,12 @@
private static final Log log =
LogFactory.getLog(CatchBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceService.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -48,4 +48,7 @@
@Transactional(readOnly = false)
FishingOperation saveFishingOperation(FishingOperation bean);
+
+ @Transactional(readOnly = false)
+ void deleteFishingOperation(String id);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -103,6 +103,9 @@
@Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "scientificCruiseDao")
protected ScientificCruiseDao scientificCruiseDao;
@@ -391,6 +394,13 @@
return bean;
}
+ @Override
+ public void deleteFishingOperation(String id) {
+ Preconditions.checkNotNull(id);
+
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -45,6 +45,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -64,9 +65,12 @@
private static final Log log =
LogFactory.getLog(MarineLitterBatchPersistenceServiceImpl.class);
- @Resource(name = "referentialPersistenceService")
+ @Autowired
protected ReferentialPersistenceService referentialService;
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -186,8 +190,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -24,10 +24,12 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -43,6 +45,9 @@
private static final Log log =
LogFactory.getLog(PlanktonBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Override
public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) {
List<PlanktonBatch> result = Lists.newArrayList();
@@ -69,5 +74,7 @@
@Override
public void deletePlanktonBatch(String id) {
+ Preconditions.checkNotNull(id);
+ attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id));
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 11:29:07 UTC (rev 734)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 19:01:21 UTC (rev 735)
@@ -39,6 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.FlushMode;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@@ -61,6 +62,9 @@
private static final Log log =
LogFactory.getLog(SpeciesBatchPersistenceServiceImpl.class);
+ @Autowired
+ protected AttachmentPersistenceService attachmentPersistenceService;
+
@Resource(name = "catchBatchDao")
protected CatchBatchExtendDao catchBatchDao;
@@ -187,8 +191,11 @@
getCurrentSession().setFlushMode(FlushMode.COMMIT);
- catchBatchDao.removeWithChildren(Integer.valueOf(id));
+ Integer batchId = Integer.valueOf(id);
+ catchBatchDao.removeWithChildren(batchId);
+ attachmentPersistenceService.deleteAllAttachment(batchId);
+
getCurrentSession().flush();
}
1
0
r734 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/benthos content/operation/catches/marinelitter content/operation/catches/species util/table
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:29:07 +0200 (Thu, 04 Apr 2013)
New Revision: 734
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/734
Log:
fixes #2244: [CAPTURES] Benthos - La cellule des commentaires et pi?\195?\168ces-jointes n'ont pas un fond vert si il y a des donn?\195?\169es dedans
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
continue ?\195?\160 r?\195?\169usiner les mod?\195?\168les d'ui (SpeciesBatch)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -66,6 +66,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -86,6 +87,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
+import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@@ -354,6 +356,79 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+
+ super.addHighlighters(table);
+
+ Color toConfirmColor = getConfig().getColorRowToConfirm();
+
+ // paint the cell in orange if the row is to confirm
+ Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm();
+ }
+
+ }, toConfirmColor);
+ table.addHighlighter(confirmHighlighter);
+
+ // highlight only the species column if the row is selected
+ Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ HighlightPredicate.IS_SELECTED,
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)),
+ UIManager.getColor("Table[Enabled+Selected].textBackground"));
+
+ table.addHighlighter(selectedHighlighter);
+
+ // paint the cell in dark orange if the row is to confirm and the cell is not editable
+ Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
+ }
+
+ }, toConfirmColor.darker());
+ table.addHighlighter(confirmNotEditableHighlighter);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -559,48 +634,6 @@
ui.getBenthosBatchAttachmentsButton().onCloseUI();
}
- @Override
- protected void addHighlighters(JXTable table) {
-
- super.addHighlighters(table);
-
- Color toConfirmColor = getConfig().getColorRowToConfirm();
-
- // paint the cell in orange if the row is to confirm
- Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm();
- }
-
- }, toConfirmColor);
- table.addHighlighter(confirmHighlighter);
-
- // highlight only the species column if the row is selected
- Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- HighlightPredicate.IS_SELECTED,
- new HighlightPredicate.IdentifierHighlightPredicate(BenthosBatchTableModel.SPECIES)),
- UIManager.getColor("Table[Enabled+Selected].textBackground"));
-
- table.addHighlighter(selectedHighlighter);
-
- // paint the cell in dark orange if the row is to confirm and the cell is not editable
- Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- BenthosBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm() && !adapter.isEditable();
- }
-
- }, toConfirmColor.darker());
- table.addHighlighter(confirmNotEditableHighlighter);
-
- }
-
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -76,9 +76,11 @@
super(MarineLitterBatch.class, fromBeanBinder, toBeanBinder);
}
- public MarineLitterBatchRowModel(MarineLitterBatch aBatch) {
+ public MarineLitterBatchRowModel(MarineLitterBatch aBatch,
+ List<Attachment> attachments) {
this();
fromBean(aBatch);
+ this.attachment.addAll(attachments);
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchTableModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -83,4 +83,19 @@
return result;
}
+ @Override
+ protected boolean isCellEditable(int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<MarineLitterBatchRowModel> propertyName) {
+ boolean cellEditable = super.isCellEditable(rowIndex,
+ columnIndex,
+ propertyName);
+ if (ATTACHMENT == propertyName) {
+
+ // only editable if row exists
+ MarineLitterBatchRowModel entry = getEntry(rowIndex);
+ cellEditable = entry.getObjectId() != null;
+ }
+ return cellEditable;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -34,19 +34,29 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.Collection;
import java.util.List;
/**
@@ -108,8 +118,7 @@
}
for (MarineLitterBatch aBatch : batchContainer.getChildren()) {
- MarineLitterBatchRowModel entry =
- new MarineLitterBatchRowModel(aBatch);
+ MarineLitterBatchRowModel entry = loadBatch(aBatch);
rows.add(entry);
}
}
@@ -118,6 +127,19 @@
recomputeBatchActionEnable();
}
+ protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) {
+
+ Integer id = aBatch.getIdAsInt();
+
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(id);
+
+ MarineLitterBatchRowModel newRow =
+ new MarineLitterBatchRowModel(aBatch, attachments);
+
+ return newRow;
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiTableUIHandler methods --//
//------------------------------------------------------------------------//
@@ -210,6 +232,43 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+ super.addHighlighters(table);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(MarineLitterBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -58,10 +58,6 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
-
- public static final String PROPERTY_SPECIES = "species";
-
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
@@ -102,18 +98,12 @@
public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
- public static final String PROPERTY_WEIGHT = "weight";
-
- public static final String PROPERTY_NUMBER = "number";
-
public static final String PROPERTY_FREQUENCY = "frequency";
public static final String PROPERTY_COMPUTED_NUMBER = "computedOrNotNumber";
public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight";
- public static final String PROPERTY_PARENT_BATCH = "parentBatch";
-
public static final String PROPERTY_CHILD_BATCH = "childBatch";
public static final String PROPERTY_BATCH_LEAF = "batchLeaf";
@@ -130,7 +120,7 @@
protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch();
/**
- * Sorted - Unsroted category (can not be null).
+ * Sorted - Unsorted category (can not be null).
*
* @since 0.2
*/
@@ -144,21 +134,21 @@
protected SampleCategory<CaracteristicQualitativeValue> sizeCategory;
/**
- * Sex (can be null).
+ * Sex category (can be null).
*
* @since 0.2
*/
protected SampleCategory<CaracteristicQualitativeValue> sexCategory;
/**
- * Maturity (can be null).
+ * Maturity category (can be null).
*
* @since 0.2
*/
protected SampleCategory<CaracteristicQualitativeValue> maturityCategory;
/**
- * Age (can be null).
+ * Age category (can be null).
*
* @since 0.2
*/
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -58,6 +58,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -74,6 +75,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
+import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@@ -364,6 +366,79 @@
recomputeBatchActionEnable();
}
+ @Override
+ protected void addHighlighters(JXTable table) {
+
+ super.addHighlighters(table);
+
+ Color toConfirmColor = getConfig().getColorRowToConfirm();
+
+ // paint the cell in orange if the row is to confirm
+ Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm();
+ }
+
+ }, toConfirmColor);
+ table.addHighlighter(confirmHighlighter);
+
+ // highlight only the species column if the row is selected
+ Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ HighlightPredicate.IS_SELECTED,
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)),
+ UIManager.getColor("Table[Enabled+Selected].textBackground"));
+
+ table.addHighlighter(selectedHighlighter);
+
+ // paint the cell in dark orange if the row is to confirm and the cell is not editable
+ Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate() {
+
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
+ return row.isSpeciesToConfirm() && !adapter.isEditable();
+ }
+
+ }, toConfirmColor.darker());
+ table.addHighlighter(confirmNotEditableHighlighter);
+
+ // paint in a special color for comment cell (with not null value)
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+
+ // paint in a special color for attachment cell (when some attachments)
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -578,48 +653,6 @@
ui.getSpeciesBatchAttachmentsButton().onCloseUI();
}
- @Override
- protected void addHighlighters(JXTable table) {
-
- super.addHighlighters(table);
-
- Color toConfirmColor = getConfig().getColorRowToConfirm();
-
- // paint the cell in orange if the row is to confirm
- Highlighter confirmHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm();
- }
-
- }, toConfirmColor);
- table.addHighlighter(confirmHighlighter);
-
- // highlight only the species column if the row is selected
- Highlighter selectedHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- HighlightPredicate.IS_SELECTED,
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.SPECIES)),
- UIManager.getColor("Table[Enabled+Selected].textBackground"));
-
- table.addHighlighter(selectedHighlighter);
-
- // paint the cell in dark orange if the row is to confirm and the cell is not editable
- Highlighter confirmNotEditableHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate() {
-
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- SpeciesBatchRowModel row = getTableModel().getEntry(adapter.row);
- return row.isSpeciesToConfirm() && !adapter.isEditable();
- }
-
- }, toConfirmColor.darker());
- table.addHighlighter(confirmNotEditableHighlighter);
-
- }
-
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 11:05:45 UTC (rev 733)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-04 11:29:07 UTC (rev 734)
@@ -297,43 +297,12 @@
}
protected void addHighlighters(JXTable table) {
+
// paint in a special color for read only cells
Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
table.addHighlighter(readOnlyHighlighter);
- // paint in a special color for comment cell (with not null value)
- Color cellWithValueColor = getConfig().getColorCellWithValue();
-
- Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- String value = (String) adapter.getValue();
- return StringUtils.isNotBlank(value);
- }
- }), cellWithValueColor);
- table.addHighlighter(commentHighlighter);
-
- // paint in a special color for attachment cell (when some attachments)
-
- Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- Collection attachments = (Collection) adapter.getValue();
- return CollectionUtils.isNotEmpty(attachments);
- }
- }
- ), cellWithValueColor);
- table.addHighlighter(attachmentHighlighter);
-
// paint in a special color inValid rows
Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
@@ -351,110 +320,6 @@
table.addHighlighter(validHighlighter);
}
-// protected void addColumnToModel(TableColumnModel model,
-// TableCellEditor editor,
-// TableCellRenderer renderer,
-// ColumnIdentifier<R> identifier) {
-//
-// TableColumnExt col = new TableColumnExt(model.getColumnCount());
-// col.setCellEditor(editor);
-// col.setCellRenderer(renderer);
-// col.setHeaderValue(_(identifier.getHeaderI18nKey()));
-// col.setToolTipText(_(identifier.getHeaderTipI18nKey()));
-//
-// col.setIdentifier(identifier);
-// model.addColumn(col);
-// }
-
-// protected void addColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier) {
-//
-// addColumnToModel(model, null, null, identifier);
-// }
-//
-// protected void addFloatColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern) {
-//
-// NumberCellEditor<Float> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// addColumnToModel(model, editor, null, identifier);
-//
-// }
-
-// protected void addIntegerColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern) {
-//
-// NumberCellEditor<Integer> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// addColumnToModel(model, editor, null, identifier);
-// }
-
-// protected void addBooleanColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// JTable table) {
-//
-// addColumnToModel(model,
-// table.getDefaultEditor(Boolean.class),
-// table.getDefaultRenderer(Boolean.class),
-// identifier);
-// }
-
-// protected <B> void addComboDataColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// Decorator<B> decorator,
-// List<B> data) {
-// JComboBox comboBox = new JComboBox();
-// comboBox.setRenderer(newListCellRender(decorator));
-//
-// List<B> dataToList = Lists.newArrayList(data);
-//
-// // add a null value at first position
-// if (!dataToList.isEmpty() && dataToList.get(0) != null) {
-// dataToList.add(0, null);
-// }
-// SwingUtil.fillComboBox(comboBox, dataToList, null);
-//
-// ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
-// BeanUIUtil.decorate(comboBox, converter);
-// ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
-//
-// addColumnToModel(model,
-// editor,
-// newTableCellRender(decorator),
-// identifier);
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
-//
-// return newTableCellRender(type, null);
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) {
-//
-// Decorator<O> decorator = getDecorator(type, name);
-//
-// TableCellRenderer result = newTableCellRender(decorator);
-// return result;
-// }
-//
-// protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
-//
-// Preconditions.checkNotNull(decorator);
-//
-// DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
-// return result;
-// }
-
//------------------------------------------------------------------------//
//-- Internal methods (listener methods) --//
//------------------------------------------------------------------------//
1
0
r733 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:05:45 +0200 (Thu, 04 Apr 2013)
New Revision: 733
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/733
Log:
reformat code + remove fqn on classes
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 11:02:34 UTC (rev 732)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-04 11:05:45 UTC (rev 733)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
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.tutti.persistence.entities.TuttiBeanFactory;
@@ -81,16 +82,17 @@
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
Collection<Batch> catchBatchChils = catchBatch.getChildBatchs();
// Vrac / Benthos
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChils,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
+ catchBatchChils,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
);
BatchContainer<SpeciesBatch> result = new BatchContainer<SpeciesBatch>();
@@ -108,9 +110,11 @@
}
// Hors-Vrac / Benthos
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChils,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(
+ catchBatchChils,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS
+ );
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
@@ -139,7 +143,7 @@
// Load full batch tree
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch batch = SortingBatch.Factory.newInstance();
benthosBatchToEntity(bean, batch, parentBatchId, catchBatch);
@@ -161,7 +165,7 @@
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
getCurrentSession().setFlushMode(FlushMode.COMMIT);
@@ -218,7 +222,7 @@
return results;
}
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(benthosBatchId));
@@ -253,7 +257,7 @@
Integer sortingBatchId = Integer.valueOf(benthosBatchId);
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
if (catchBatch == null) {
return frequencies;
@@ -325,7 +329,12 @@
protected void benthosBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- batchHelper.speciesBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
+ CatchBatch catchBatch) {
+ batchHelper.speciesBatchToEntity(
+ source,
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 11:02:34 UTC (rev 732)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-04 11:05:45 UTC (rev 733)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
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.tutti.persistence.entities.TuttiBeanFactory;
@@ -78,16 +79,17 @@
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
Collection<Batch> catchBatchChilds = catchBatch.getChildBatchs();
// Vrac / Species
- SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChilds,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
- );
+ SortingBatch vracSpeciesBatch = catchBatchDao.getSortingBatch(
+ catchBatchChilds,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED
+ );
// container of speciesBatch is arbitraty put on vrac type (there is
// no common ancestor for all species batch).
@@ -107,9 +109,10 @@
}
// Hors-Vrac / Species
- SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(catchBatchChilds,
- "pmfmId", enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
- "pmfmId", enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ SortingBatch horsVracSpeciesBatch = catchBatchDao.getSortingBatch(
+ catchBatchChilds,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID,
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (horsVracSpeciesBatch != null) {
for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) {
@@ -139,7 +142,7 @@
// Load full batch tree
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(bean.getFishingOperation().getIdAsInt());
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
SortingBatch batch = SortingBatch.Factory.newInstance();
speciesBatchToEntity(bean, batch, parentBatchId, catchBatch);
@@ -161,7 +164,7 @@
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(bean.getIdAsInt());
Preconditions.checkNotNull(catchBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
Preconditions.checkNotNull(catchBatch);
getCurrentSession().setFlushMode(FlushMode.COMMIT);
@@ -222,7 +225,7 @@
catchBatchId,
"Could not find catchBatch for speciesBatch: " + speciesBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch =
+ CatchBatch catchBatch =
catchBatchDao.loadFullTree(catchBatchId);
SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
@@ -266,7 +269,7 @@
Integer sortingBatchId = Integer.valueOf(speciesBatchId);
Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
if (catchBatch == null) {
return notNullFrequencies;
@@ -359,8 +362,13 @@
protected void speciesBatchToEntity(SpeciesBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
- batchHelper.speciesBatchToEntity(source, target, parentBatchId, catchBatch, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
+ CatchBatch catchBatch) {
+ batchHelper.speciesBatchToEntity(
+ source,
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
}
}
1
0
r732 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 04 Apr '13
by tchemit@users.forge.codelutin.com 04 Apr '13
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:02:34 +0200 (Thu, 04 Apr 2013)
New Revision: 732
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/732
Log:
refs #1865: [MACRODECHET] - Gestion de la saisie des Macrod?\195?\169chets
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 11:00:48 UTC (rev 731)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-04 11:02:34 UTC (rev 732)
@@ -207,7 +207,7 @@
// Should have 2 quantification measurements
- for (QuantificationMeasurement measurement : source.getQuantificationMeasurements()) {
+ for (SortingMeasurement measurement : source.getSortingMeasurements()) {
Integer pmfmId = measurement.getPmfm().getId();
if (marineLitterCategory.equals(pmfmId)) {
QualitativeValue qualitativeValue = measurement.getQualitativeValue();
@@ -266,7 +266,6 @@
// Force subgroup count to '1', as Allegro
target.setSubgroupCount(1f);
- //FIXME-TC Do we really need this ?
// Weight
if (source.getWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
@@ -284,26 +283,26 @@
if (source.getMarineLitterCategory() == null) {
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.getQuantificationMeasurement(
+ SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
target,
marineLitterCategory,
recorderDepartmentId,
true);
- quantificationMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterCategory().getIdAsInt()));
+ notChangedSortingMeasurements.remove(measurement);
}
// MarineLitterSizeCategory
if (source.getMarineLitterSizeCategory() == null) {
// Nothing to do : will be removed later, using notChangedQuantificationMeasurements
} else {
- QuantificationMeasurement quantificationMeasurement = catchBatchDao.getQuantificationMeasurement(
+ SortingMeasurement measurement = catchBatchDao.getSortingMeasurement(
target,
marineLitterSizeCategory,
recorderDepartmentId,
true);
- quantificationMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
- notChangedQuantificationMeasurements.remove(quantificationMeasurement);
+ measurement.setQualitativeValue(load(QualitativeValueImpl.class, source.getMarineLitterSizeCategory().getIdAsInt()));
+ notChangedSortingMeasurements.remove(measurement);
}
// Sampling Ratio
@@ -313,9 +312,6 @@
// Individual count
target.setIndividualCount(source.getNumber());
- // Weight
- target.setWeight(source.getWeight());
-
// QualityFlag
QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
target.setQualityFlag(qualityFlag);
1
0
04 Apr '13
Author: tchemit
Date: 2013-04-04 13:00:48 +0200 (Thu, 04 Apr 2013)
New Revision: 731
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/731
Log:
fixes #2243: Mauvaise r?\195?\169cup?\195?\169ration des valeurs qualitatives d'un pmfm
Modified:
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-04 08:17:58 UTC (rev 730)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-04 11:00:48 UTC (rev 731)
@@ -423,7 +423,7 @@
<![CDATA[
SELECT
qv.id AS id,
- case when (qv.name = qv.description) then qv.name else concat(qv.name, ' - ', qv.description) end AS name,
+ case when (qv.description is null or qv.name = qv.description) then qv.name else concat(qv.name, ' - ', qv.description) end AS name,
qv.status AS status
FROM
PmfmImpl p JOIN p.qualitativeValues qv
1
0