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
- 4058 discussions
r1367 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos/frequency species/frequency
by tchemit@users.forge.codelutin.com 21 Nov '13
by tchemit@users.forge.codelutin.com 21 Nov '13
21 Nov '13
Author: tchemit
Date: 2013-11-21 09:52:45 +0100 (Thu, 21 Nov 2013)
New Revision: 1367
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1367
Log:
fixes #3838: [CAPTURE] j'arrive ?\195?\160 enregistrer une classe de taille de valeur 0 avec un nombre non nul d'individus associ?\195?\169s. Ca doit pas ?\195?\170tre possible
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-20 13:56:44 UTC (rev 1366)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-21 08:52:45 UTC (rev 1367)
@@ -117,7 +117,7 @@
@Override
protected boolean isRowValid(BenthosFrequencyRowModel row) {
return row.getLengthStepCaracteristic() != null &&
- row.getLengthStep() != null &&
+ row.getLengthStep() != null && row.getLengthStep() > 0 &&
((row.getNumber() == null && row.getWeight() == null) ||
(row.getNumber() != null && row.getNumber() > 0 &&
(withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0)));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-20 13:56:44 UTC (rev 1366)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-21 08:52:45 UTC (rev 1367)
@@ -119,7 +119,7 @@
@Override
protected boolean isRowValid(SpeciesFrequencyRowModel row) {
return row.getLengthStepCaracteristic() != null &&
- row.getLengthStep() != null &&
+ row.getLengthStep() != null && row.getLengthStep() > 0 &&
((row.getNumber() == null && row.getWeight() == null) ||
(row.getNumber() != null && row.getNumber() > 0 &&
(withWeightRows.isEmpty() || row.getWeight() != null && row.getWeight() > 0)));
1
0
20 Nov '13
Author: tchemit
Date: 2013-11-20 14:56:44 +0100 (Wed, 20 Nov 2013)
New Revision: 1366
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1366
Log:
refs 3823: [TECH] Temps d'affichage d'un trait trop lent (use snapshot of adagio)
refs #3803: [CAPTURE] ?\195?\169l?\195?\169vations : marche pas en .csv et .pdf depuis l'onglet r?\195?\169sum?\195?\169 (improve pdf export code + add a test on medits
data)
Added:
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java
trunk/tutti-service/src/test/resources/tutti-test-read-dbMedits.properties
Modified:
trunk/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
trunk/tutti-ui-swing/src/main/profiling/META-INF/aop.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/pom.xml 2013-11-20 13:56:44 UTC (rev 1366)
@@ -137,9 +137,8 @@
<slf4jVersion>1.7.5</slf4jVersion>
- <adagioVersion>3.4</adagioVersion>
+ <adagioVersion>3.4.0-1-SNAPSHOT</adagioVersion>
<birtVersion>4.2.1a</birtVersion>
- <!--<adagioVersion>3.4.1-SNAPSHOT</adagioVersion>-->
<bluecoveVersion>2.1.0</bluecoveVersion>
@@ -218,7 +217,7 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-profiling</artifactId>
- <version>2.7</version>
+ <version>2.7.1</version>
</dependency>
<dependency>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -38,6 +38,7 @@
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -268,10 +269,12 @@
Caracteristic getCaracteristic(Integer pmfmId);
- boolean isVracSpeciesBatch(SpeciesBatch speciesBatch);
+ boolean isVracBatch(SpeciesAbleBatch speciesBatch);
- boolean isVracBenthosBatch(BenthosBatch benthosBatch);
+// boolean isVracSpeciesBatch(SpeciesBatch speciesBatch);
+// boolean isVracBenthosBatch(BenthosBatch benthosBatch);
+
boolean isTemporary(TuttiReferentialEntity entity);
List<Gear> getAllScientificGear();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -46,6 +46,7 @@
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
@@ -138,9 +139,11 @@
@Autowired
protected DatabaseSchemaDao databaseSchemaDao;
- protected Predicate<SpeciesBatch> speciesBatchVracPredicate;
+ protected Predicate<SpeciesAbleBatch> speciesAbleBatchVracPredicate;
- protected Predicate<BenthosBatch> benthosBatchVracPredicate;
+// protected Predicate<SpeciesBatch> speciesBatchVracPredicate;
+//
+// protected Predicate<BenthosBatch> benthosBatchVracPredicate;
@Override
public String getImplementationName() {
@@ -226,8 +229,9 @@
TuttiEnumerationFile enumerationFile = getEnumerationFile();
- speciesBatchVracPredicate = TuttiEntities.newSpeciesBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
- benthosBatchVracPredicate = TuttiEntities.newBenthosBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
+ speciesAbleBatchVracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
+// speciesBatchVracPredicate = TuttiEntities.newSpeciesBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
+// benthosBatchVracPredicate = TuttiEntities.newBenthosBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
}
@Override
@@ -416,14 +420,19 @@
}
@Override
- public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
- return speciesBatchVracPredicate.apply(speciesBatch);
+ public boolean isVracBatch(SpeciesAbleBatch speciesBatch) {
+ return speciesAbleBatchVracPredicate.apply(speciesBatch);
}
- @Override
- public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
- return benthosBatchVracPredicate.apply(benthosBatch);
- }
+// @Override
+// public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
+// return speciesBatchVracPredicate.apply(speciesBatch);
+// }
+//
+// @Override
+// public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
+// return benthosBatchVracPredicate.apply(benthosBatch);
+// }
@Override
public boolean isTemporary(TuttiReferentialEntity entity) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -38,6 +38,7 @@
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -96,17 +97,17 @@
throw notImplemented();
}
- @Override
- public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
- throw notImplemented();
- }
+// @Override
+// public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
+// throw notImplemented();
+// }
+//
+// @Override
+// public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
+// throw notImplemented();
+// }
@Override
- public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
- throw notImplemented();
- }
-
- @Override
public void clearAllCaches() {
throw notImplemented();
}
@@ -257,6 +258,11 @@
}
@Override
+ public boolean isVracBatch(SpeciesAbleBatch speciesBatch) {
+ throw notImplemented();
+ }
+
+ @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
throw notImplemented();
}
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-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -32,8 +32,7 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
@@ -189,14 +188,10 @@
return new SampleCategoryCaracteristicPredicate();
}
- public static Predicate<SpeciesBatch> newSpeciesBatchCategoryPredicate(Integer cateogryId, Integer value) {
- return new SpeciesBatchCategoryPredicate(cateogryId, value);
+ public static Predicate<SpeciesAbleBatch> newSpeciesAbleBatchCategoryPredicate(Integer cateogryId, Integer value) {
+ return new SpeciesAbleBatchCategoryPredicate(cateogryId, value);
}
- public static Predicate<BenthosBatch> newBenthosBatchCategoryPredicate(Integer cateogryId, Integer value) {
- return new BenthosBatchCategoryPredicate(cateogryId, value);
- }
-
public static <B extends TuttiEntity> B findById(Iterable<B> beans,
String id) {
B result = Iterables.tryFind(beans, newIdPredicate(id)).orNull();
@@ -386,44 +381,25 @@
}
}
- protected static class SpeciesBatchCategoryPredicate implements Predicate<SpeciesBatch> {
+ protected static class SpeciesAbleBatchCategoryPredicate implements Predicate<SpeciesAbleBatch> {
private final Integer id;
private final Integer qualitativeValue;
- public SpeciesBatchCategoryPredicate(Integer id, Integer qualitativeValue) {
+ public SpeciesAbleBatchCategoryPredicate(Integer id, Integer qualitativeValue) {
this.id = id;
this.qualitativeValue = qualitativeValue;
}
@Override
- public boolean apply(SpeciesBatch input) {
+ public boolean apply(SpeciesAbleBatch input) {
return id.equals(input.getSampleCategoryId()) &&
input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
qualitativeValue.equals(((CaracteristicQualitativeValue) input.getSampleCategoryValue()).getIdAsInt());
}
}
- protected static class BenthosBatchCategoryPredicate implements Predicate<BenthosBatch> {
-
- private final Integer id;
-
- private final Integer qualitativeValue;
-
- public BenthosBatchCategoryPredicate(Integer id, Integer qualitativeValue) {
- this.id = id;
- this.qualitativeValue = qualitativeValue;
- }
-
- @Override
- public boolean apply(BenthosBatch input) {
- return id.equals(input.getSampleCategoryId()) &&
- input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
- qualitativeValue.equals(((CaracteristicQualitativeValue) input.getSampleCategoryValue()).getIdAsInt());
- }
- }
-
public static <K, V> void fillEntries(Map<K, V> map,
Collection<K> keys,
Function<K, V> function) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -832,16 +832,11 @@
}
@Override
- public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
- return driver.isVracSpeciesBatch(speciesBatch);
+ public boolean isVracBatch(SpeciesAbleBatch speciesBatch) {
+ return driver.isVracBatch(speciesBatch);
}
@Override
- public boolean isVracBenthosBatch(BenthosBatch benthosBatch) {
- return driver.isVracBenthosBatch(benthosBatch);
- }
-
- @Override
public boolean isTemporary(TuttiReferentialEntity entity) {
return driver.isTemporary(entity);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ExportCatchesReportService.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -28,6 +28,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
@@ -184,10 +185,10 @@
// create operation data model
Map<String, Object> op = createOperation(fishingOperation);
- Float totalWeight = catchBatch.getCatchTotalWeight();
- if (totalWeight == null) {
- totalWeight = catchBatch.getCatchTotalComputedWeight();
- }
+ float totalWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getCatchTotalWeight(),
+ catchBatch.getCatchTotalComputedWeight());
+
op.put("totalWeight", totalWeight);
op.put("totalSortedWeight", catchBatch.getSpeciesTotalSampleSortedComputedWeight() + catchBatch.getBenthosTotalSampleSortedComputedWeight());
@@ -196,52 +197,77 @@
// Species
- Map<Species, Map<String, Object>> catches = Maps.newHashMap();
- Float ratio = (totalWeight - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+ Map<Species, SpeciesBatchEntry> catches = Maps.newHashMap();
- Float speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedWeight();
- if (speciesTotalSortedWeight == null) {
- speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedComputedWeight();
+ float globalRatio = (totalWeight - catchBatch.getCatchTotalUnsortedComputedWeight()) / catchBatch.getCatchTotalSortedComputedWeight();
+
+ float speciesTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalSortedWeight(),
+ catchBatch.getSpeciesTotalSortedComputedWeight());
+
+ // ratio total species weight / total sorted sampled species weight
+ float speciesRatio = globalRatio * speciesTotalSortedWeight;
+ if (catchBatch.getSpeciesTotalSampleSortedComputedWeight() > 0) {
+ speciesRatio /= catchBatch.getSpeciesTotalSampleSortedComputedWeight();
}
- // ratio total species weight / total sorted sampled species weight
- Float speciesRatio = speciesTotalSortedWeight / catchBatch.getSpeciesTotalSampleSortedComputedWeight();
// create catches rows
if (rootSpeciesBatch != null) {
+
List<SpeciesBatch> speciesBatches = rootSpeciesBatch.getChildren();
for (SpeciesBatch batch : speciesBatches) {
- createSpeciesCatch(batch, catches, speciesRatio * ratio, totalWeight);
+
+ createSpeciesCatch(batch, catches, speciesRatio);
}
}
- List<Map<String, Object>> catchList = Lists.newArrayList(catches.values());
+ List<SpeciesBatchEntry> catchList = Lists.newArrayList(catches.values());
+
// Benthos
- Float benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedWeight();
- if (benthosTotalSortedWeight == null) {
- benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedComputedWeight();
+ float benthosTotalSortedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalSortedWeight(),
+ catchBatch.getBenthosTotalSortedComputedWeight());
+
+ // ratio total benthos weight / total sorted sampled benthos weight
+ float benthosRatio = globalRatio * benthosTotalSortedWeight;
+ if (catchBatch.getBenthosTotalSampleSortedComputedWeight() > 0) {
+ benthosRatio /= catchBatch.getBenthosTotalSampleSortedComputedWeight();
}
- // ratio total benthos weight / total sorted sampled benthos weight
- Float benthosRatio = benthosTotalSortedWeight / catchBatch.getBenthosTotalSampleSortedComputedWeight();
// add the benthos row
if (rootBenthosBatch != null) {
+
if (CollectionUtils.isNotEmpty(rootBenthosBatch.getChildren())) {
- Map<String, Object> benthosCatch =
- createBenthosCatch(rootBenthosBatch, ratio * benthosRatio, totalWeight);
+ SpeciesBatchEntry benthosCatch =
+ createBenthosCatch(rootBenthosBatch, benthosRatio);
catchList.add(benthosCatch);
}
}
// Inert and living not itemized
- Map<String, Object> inertLivingNotItemizedCatch = createInertAndLivingNotItemizedCatch(catchBatch,
- ratio * speciesRatio,
- ratio * benthosRatio,
- totalWeight);
- if ((Float) inertLivingNotItemizedCatch.get("sortedWeight") > 0f) {
+ SpeciesBatchEntry inertLivingNotItemizedCatch =
+ createInertAndLivingNotItemizedCatch(catchBatch,
+ speciesRatio,
+ benthosRatio);
+ if (inertLivingNotItemizedCatch.getSortedWeight() > 0f) {
catchList.add(inertLivingNotItemizedCatch);
}
+ if (log.isDebugEnabled()) {
+
+ // recompute total for check
+ float computedTotalWeight = 0f;
+ float computedPercentage = 0f;
+ for (SpeciesBatchEntry entry : catchList) {
+ entry.computePercentage(totalWeight);
+ computedTotalWeight += entry.getTotalWeight();
+ computedPercentage += entry.getPercentage();
+ }
+ log.debug("TotalWeight: " + totalWeight);
+ log.debug("ComputedTotalWeight: " + computedTotalWeight);
+ log.debug("ComputedPercentage: " + computedPercentage);
+ }
op.put("catches", catchList);
operations.add(op);
}
@@ -290,128 +316,178 @@
}
protected void createSpeciesCatch(SpeciesBatch batch,
- Map<Species, Map<String, Object>> catches,
- float ratio,
- float totalWeight) {
+ Map<Species, SpeciesBatchEntry> catches,
+ float ratio) {
Species species = batch.getSpecies();
- Float existingSortedWeight;
- Float existingTotalWeight;
- Map<String, Object> ktch = catches.get(species);
+ SpeciesBatchEntry ktch = catches.get(species);
if (ktch == null) {
- ktch = Maps.newHashMap();
- ktch.put("code", species.getRefTaxCode());
- ktch.put("scientificName", species.getName());
+ Species speciesWithVerncularCode =
+ persistenceService.getSpeciesByReferenceTaxonIdWithVernacularCode(species.getReferenceTaxonId());
- Species speciesWithVerncularCode = persistenceService.getSpeciesByReferenceTaxonIdWithVernacularCode(species.getReferenceTaxonId());
- ktch.put("commonName", speciesWithVerncularCode.getVernacularCode());
+ ktch = new SpeciesBatchEntry(
+ species.getRefTaxCode(),
+ species.getName(),
+ speciesWithVerncularCode.getVernacularCode()
+ );
+ catches.put(species, ktch);
+ }
- existingSortedWeight = 0f;
- existingTotalWeight = 0f;
+ float sortedWeight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
- } else {
- existingSortedWeight = (Float) ktch.get("sortedWeight");
- existingTotalWeight = (Float) ktch.get("totalWeight");
- }
+ ktch.addSortedWeight(sortedWeight);
- Float weight = batch.getSampleCategoryWeight();
- if (weight == null) {
- weight = batch.getSampleCategoryComputedWeight();
+ float speciesTotalWeight = sortedWeight;
+ if (persistenceService.isVracBatch(batch)) {
+ speciesTotalWeight *= ratio;
}
- ktch.put("sortedWeight", weight + existingSortedWeight);
-
- if (persistenceService.isVracSpeciesBatch(batch)) {
- weight *= ratio;
- }
- weight += existingTotalWeight;
-
- ktch.put("totalWeight", weight);
- ktch.put("percentage", 100 * weight / totalWeight);
- catches.put(species, ktch);
+ ktch.addTotalWeight(speciesTotalWeight);
}
- protected Map<String, Object> createBenthosCatch(BatchContainer<BenthosBatch> rootBenthosBatch,
- float ratio,
- float totalWeight) {
- Map<String, Object> ktch = Maps.newHashMap();
- ktch.put("code", _("tutti.service.operations.exportCatchesReport.specialRows.benthos.code"));
- ktch.put("scientificName", "");
- ktch.put("commonName", _("tutti.service.operations.exportCatchesReport.specialRows.benthos.name"));
+ protected SpeciesBatchEntry createBenthosCatch(BatchContainer<BenthosBatch> rootBenthosBatch,
+ float ratio) {
+ SpeciesBatchEntry ktch = new SpeciesBatchEntry(
+ _("tutti.service.operations.exportCatchesReport.specialRows.benthos.code"),
+ "",
+ _("tutti.service.operations.exportCatchesReport.specialRows.benthos.name")
+ );
- Float sortedWeight = 0f;
- Float benthosTotalWeight = 0f;
+ float sortedWeight = 0f;
+ float benthosTotalWeight = 0f;
List<BenthosBatch> benthosBatches = rootBenthosBatch.getChildren();
for (BenthosBatch batch : benthosBatches) {
- Float batchWeight = batch.getSampleCategoryWeight();
- if (batchWeight == null) {
- batchWeight = batch.getSampleCategoryComputedWeight();
- }
+ float batchWeight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
sortedWeight += batchWeight;
- if (persistenceService.isVracBenthosBatch(batch)) {
+ if (persistenceService.isVracBatch(batch)) {
batchWeight *= ratio;
}
benthosTotalWeight += batchWeight;
}
- ktch.put("sortedWeight", sortedWeight);
- ktch.put("totalWeight", benthosTotalWeight);
- ktch.put("percentage", 100 * benthosTotalWeight / totalWeight);
+ ktch.addSortedWeight(sortedWeight);
+ ktch.addTotalWeight(benthosTotalWeight);
return ktch;
}
- protected Map<String, Object> createInertAndLivingNotItemizedCatch(CatchBatch catchBatch,
- float speciesRatio,
- float benthosRatio,
- float totalWeight) {
- Map<String, Object> inertLivingNotItemizedCatch = Maps.newHashMap();
- inertLivingNotItemizedCatch.put("code", _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code"));
- inertLivingNotItemizedCatch.put("scientificName", "");
- inertLivingNotItemizedCatch.put("commonName", _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name"));
+ protected SpeciesBatchEntry createInertAndLivingNotItemizedCatch(CatchBatch catchBatch,
+ float speciesRatio,
+ float benthosRatio) {
+ SpeciesBatchEntry ktch = new SpeciesBatchEntry(
+ _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code"),
+ "",
+ _("tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name"));
- Float inertLivingNotItemizedSortedWeight = 0f;
- Float inertLivingNotItemizedTotalWeight = 0f;
+ float sortedWeight = 0f;
+ float totalWeight = 0f;
- Float speciesInterWeight = catchBatch.getSpeciesTotalInertWeight();
- if (speciesInterWeight == null) {
- speciesInterWeight = catchBatch.getSpeciesTotalInertComputedWeight();
- }
+ Float speciesInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalInertWeight(),
+ catchBatch.getSpeciesTotalInertComputedWeight());
+
if (speciesInterWeight != null) {
- inertLivingNotItemizedSortedWeight += speciesInterWeight;
- inertLivingNotItemizedTotalWeight += speciesInterWeight * speciesRatio;
+ sortedWeight += speciesInterWeight;
+ totalWeight += speciesInterWeight * speciesRatio;
}
- Float speciesLivingNotItemizedWeigth = catchBatch.getSpeciesTotalLivingNotItemizedWeight();
- if (speciesLivingNotItemizedWeigth == null) {
- speciesLivingNotItemizedWeigth = catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight();
- }
+ Float speciesLivingNotItemizedWeigth = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getSpeciesTotalLivingNotItemizedWeight(),
+ catchBatch.getSpeciesTotalLivingNotItemizedComputedWeight());
+
if (speciesLivingNotItemizedWeigth != null) {
- inertLivingNotItemizedSortedWeight += speciesLivingNotItemizedWeigth;
- inertLivingNotItemizedTotalWeight += speciesLivingNotItemizedWeigth * speciesRatio;
+ sortedWeight += speciesLivingNotItemizedWeigth;
+ totalWeight += speciesLivingNotItemizedWeigth * speciesRatio;
}
- Float benthosInterWeight = catchBatch.getBenthosTotalInertWeight();
- if (benthosInterWeight == null) {
- benthosInterWeight = catchBatch.getBenthosTotalInertComputedWeight();
- }
+ Float benthosInterWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalInertWeight(),
+ catchBatch.getBenthosTotalInertComputedWeight());
+
if (benthosInterWeight != null) {
- inertLivingNotItemizedSortedWeight += benthosInterWeight;
- inertLivingNotItemizedTotalWeight += benthosInterWeight * benthosRatio;
+ sortedWeight += benthosInterWeight;
+ totalWeight += benthosInterWeight * benthosRatio;
}
- Float benthosLivingNotItemizedWeight = catchBatch.getBenthosTotalLivingNotItemizedWeight();
- if (benthosLivingNotItemizedWeight == null) {
- benthosLivingNotItemizedWeight = catchBatch.getBenthosTotalLivingNotItemizedComputedWeight();
- }
+ Float benthosLivingNotItemizedWeight = TuttiEntities.getValueOrComputedValue(
+ catchBatch.getBenthosTotalLivingNotItemizedWeight(),
+ catchBatch.getBenthosTotalLivingNotItemizedComputedWeight());
+
if (benthosLivingNotItemizedWeight != null) {
- inertLivingNotItemizedSortedWeight += benthosLivingNotItemizedWeight;
- inertLivingNotItemizedTotalWeight += benthosLivingNotItemizedWeight * benthosRatio;
+ sortedWeight += benthosLivingNotItemizedWeight;
+ totalWeight += benthosLivingNotItemizedWeight * benthosRatio;
}
- inertLivingNotItemizedCatch.put("sortedWeight", inertLivingNotItemizedSortedWeight);
- inertLivingNotItemizedCatch.put("totalWeight", inertLivingNotItemizedTotalWeight);
- inertLivingNotItemizedCatch.put("percentage", 100 * inertLivingNotItemizedTotalWeight / totalWeight);
+ ktch.addSortedWeight(sortedWeight);
+ ktch.addTotalWeight(totalWeight);
- return inertLivingNotItemizedCatch;
+ return ktch;
}
+
+ /**
+ * To store a species or batch entry within his speices informations,
+ * his sorted weight, total weight and percentage amoong the total catch
+ * weight.
+ *
+ * @since 2.10
+ */
+ public static class SpeciesBatchEntry {
+
+ protected final String code;
+
+ protected final String scientificName;
+
+ protected final String commonName;
+
+ float sortedWeight;
+
+ float totalWeight;
+
+ float percentage;
+
+ SpeciesBatchEntry(String code, String scientificName, String commonName) {
+ this.code = code;
+ this.scientificName = scientificName;
+ this.commonName = commonName;
+ }
+
+ public void addSortedWeight(float weight) {
+ sortedWeight += weight;
+ }
+
+ public void addTotalWeight(float weight) {
+ totalWeight += weight;
+ }
+
+ public void computePercentage(float totalWeight) {
+ this.percentage = 100 * this.totalWeight / totalWeight;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+ public String getCommonName() {
+ return commonName;
+ }
+
+ public float getSortedWeight() {
+ return sortedWeight;
+ }
+
+ public float getTotalWeight() {
+ return totalWeight;
+ }
+
+ public float getPercentage() {
+ return percentage;
+ }
+ }
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -186,7 +186,7 @@
break;
}
- if (persistenceService.isVracSpeciesBatch(row)) {
+ if (persistenceService.isVracBatch(row)) {
speciesTotalComputedSortedWeight += weight;
} else {
speciesTotalComputedUnsortedWeight += weight;
@@ -243,7 +243,7 @@
break;
}
- if (persistenceService.isVracBenthosBatch(row)) {
+ if (persistenceService.isVracBatch(row)) {
benthosTotalComputedSortedWeight += weight;
} else {
benthosTotalComputedUnsortedWeight += weight;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -114,7 +114,7 @@
row.setSpecies(speciesBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
- if (persistenceService.isVracSpeciesBatch(speciesBatch)) {
+ if (persistenceService.isVracBatch(speciesBatch)) {
// compute species total weight in catch
@@ -142,7 +142,7 @@
row.setSpecies(benthosBatch.getSpecies());
row.setBatchWeightUnit(batchWeightUnit);
- if (persistenceService.isVracBenthosBatch(benthosBatch)) {
+ if (persistenceService.isVracBatch(benthosBatch)) {
// compute species total weight in catch
Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -0,0 +1,70 @@
+package fr.ifremer.tutti.service.catches;
+
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Locale;
+
+/**
+ * Created on 11/19/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.10
+ */
+public class ExportCatchesReportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbMedits");
+
+ public static final String PROGRAM_ID = "CAM-MEDITS";
+
+ public static final String CRUISE_ID = "100001";
+
+ public static final String OPERATION_1_ID = "100106";
+
+ protected ExportCatchesReportService exportService;
+
+ protected PersistenceService persistenceService;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+ exportService = serviceContext.getService(ExportCatchesReportService.class);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void generateFishingOperationPDFFile() throws Exception {
+
+ File exportFile = new File(dataDirectory, "exportOperation.pdf");
+
+ Assert.assertFalse(exportFile.exists());
+
+ exportService.generateFishingOperationPDFFile(exportFile,
+ OPERATION_1_ID,
+ Locale.FRENCH);
+
+ Assert.assertTrue(exportFile.exists());
+ }
+}
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/ExportCatchesReportServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: trunk/tutti-service/src/test/resources/tutti-test-read-dbMedits.properties (from rev 1361, trunk/tutti-service/src/test/resources/tutti-test-read-dbCGFS.properties)
===================================================================
--- trunk/tutti-service/src/test/resources/tutti-test-read-dbMedits.properties (rev 0)
+++ trunk/tutti-service/src/test/resources/tutti-test-read-dbMedits.properties 2013-11-20 13:56:44 UTC (rev 1366)
@@ -0,0 +1,25 @@
+###
+# #%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%
+###
+tutti.persistence.db.directory=src/test/dbMedits
+tutti.persistence.jdbc.url=jdbc:hsqldb:file:src/test/dbMedits/allegro
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-20 13:56:44 UTC (rev 1366)
@@ -273,7 +273,7 @@
List<SpeciesBatch> children = computedSpeciesBatches.getChildren();
for (SpeciesBatch batch : children) {
SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows);
- if (persistenceService.isVracSpeciesBatch(row)) {
+ if (persistenceService.isVracBatch(row)) {
SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
Float weight = TuttiEntities.getValueOrComputedValue(
sampleCategory.getCategoryWeight(),
@@ -296,7 +296,7 @@
for (BenthosBatch batch : children) {
BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows);
- if (persistenceService.isVracBenthosBatch(row)) {
+ if (persistenceService.isVracBatch(row)) {
SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
Float weight = TuttiEntities.getValueOrComputedValue(
sampleCategory.getCategoryWeight(),
Modified: trunk/tutti-ui-swing/src/main/profiling/META-INF/aop.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/profiling/META-INF/aop.xml 2013-11-20 08:11:09 UTC (rev 1365)
+++ trunk/tutti-ui-swing/src/main/profiling/META-INF/aop.xml 2013-11-20 13:56:44 UTC (rev 1366)
@@ -33,9 +33,9 @@
expression="
execution(* fr.ifremer.tutti..*(..))
||execution(* fr.ifremer.adagio.core..*(..))
- ||execution(* org.springframework..*(..))
- ||execution(* org.hibernate..*(..))
"/>
</concrete-aspect>
</aspects>
+ <!--||execution(* org.springframework..*(..))-->
+ <!--||execution(* org.hibernate..*(..))-->
</aspectj>
\ No newline at end of file
1
0
r1365 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content content/db util/action
by tchemit@users.forge.codelutin.com 20 Nov '13
by tchemit@users.forge.codelutin.com 20 Nov '13
20 Nov '13
Author: tchemit
Date: 2013-11-20 09:11:09 +0100 (Wed, 20 Nov 2013)
New Revision: 1365
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1365
Log:
fixes #3841: [TECH] Am?\195?\169lioration du d?\195?\169marrage de l'application
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/StartAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionHelper.java
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-11-19 18:25:58 UTC (rev 1364)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-11-20 08:11:09 UTC (rev 1365)
@@ -40,7 +40,6 @@
import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
import fr.ifremer.tutti.ui.swing.content.db.DbManagerUI;
import fr.ifremer.tutti.ui.swing.content.db.DbManagerUIHandler;
-import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
@@ -54,9 +53,7 @@
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;
import jaxx.runtime.JAXXBinding;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.session.SwingSession;
@@ -106,9 +103,10 @@
public void reloadDbManagerText() {
- AbstractTuttiUIHandler currentHandler = getCurrentHandler();
- if (currentHandler instanceof DbManagerUIHandler) {
- DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) currentHandler;
+ TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
+
+ if (body != null && body.getHandler() instanceof DbManagerUIHandler) {
+ DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) body.getHandler();
dbManagerUIHandler.updateMessage();
}
}
@@ -207,37 +205,6 @@
JToolBar bar = ui.getBottomBar();
ui.getStatus().addWidget(bar, 0);
-
- if (context.isDbLoaded()) {
-
- // db already opened (happens when reloading ui)
- // just go to select cruise screen
- TuttiUIAction<SelectCruiseAction> uiAction = TuttiActionHelper.createUIAction(this, SelectCruiseAction.class);
- SelectCruiseAction logicAction = uiAction.getLogicAction();
- logicAction.setSkipCheckCurrentScreen(true);
- logicAction.setActionDescription(ui.getMenuActionSelectCruise().getToolTipText());
- uiAction.actionPerformed(null);
-
- } else {
-
- if (context.isDbExist()) {
-
- // open tutti db (using a fake button to have simple api)
- TuttiUIAction<OpenDbAction> uiAction = TuttiActionHelper.createUIAction(this, OpenDbAction.class);
- OpenDbAction logicAction = uiAction.getLogicAction();
- logicAction.setSkipCheckCurrentScreen(true);
- logicAction.setUpdateReferentiel(true);
- uiAction.actionPerformed(null);
-
- } else {
-
- // clean db context
- context.clearDbContext();
-
- // go to manage db screen (to install db)
- context.setScreen(TuttiScreen.MANAGE_DB);
- }
- }
}
@Override
@@ -377,11 +344,6 @@
return canClose;
}
- public AbstractTuttiUIHandler getCurrentHandler() {
- TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody;
- return body.getHandler();
- }
-
/**
* Reload the persistence service and set the new ne into the handler.
*
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java 2013-11-19 18:25:58 UTC (rev 1364)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java 2013-11-20 08:11:09 UTC (rev 1365)
@@ -25,8 +25,10 @@
*/
import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.db.ImportDbAction;
import fr.ifremer.tutti.ui.swing.content.db.InstallDbAction;
+import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,8 +38,10 @@
import static org.nuiton.i18n.I18n._;
/**
- * Start action (when the start action file is present when
- * starting application).
+ * Start action.
+ * <p/>
+ * If there is a start action file, then load it and run inside actions, otherwise
+ * just starts normal ui action (open db if exists, or go to manage db screen).
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4
@@ -69,22 +73,28 @@
if (InstallDbAction.class.getName().equals(content)) {
// install db
- delegateAction = TuttiActionHelper.createLogicAction(getHandler(), InstallDbAction.class);
+ delegateAction = TuttiActionHelper.createLogicAction(handler, InstallDbAction.class);
if (log.isInfoEnabled()) {
log.info("Found install db action");
}
+ deleteOldDatabaseDirectory();
+
} else if (content.startsWith(ImportDbAction.class.getName())) {
// import db
- ImportDbAction action = TuttiActionHelper.createLogicAction(getHandler(), ImportDbAction.class);
+ ImportDbAction action = TuttiActionHelper.createLogicAction(handler, ImportDbAction.class);
File importFile = new File(content.substring(ImportDbAction.class.getName().length() + 1));
action.setImportFile(importFile);
delegateAction = action;
if (log.isInfoEnabled()) {
log.info("Found import db action (with file " + importFile + ")");
}
+ deleteOldDatabaseDirectory();
} else {
+ if (log.isWarnEnabled()) {
+ log.warn("Unknown start action: " + content);
+ }
doAction = false;
}
@@ -97,11 +107,46 @@
}
}
+ if (!doAction) {
- if (doAction) {
- setActionDescription(delegateAction.getActionDescription());
- doAction = delegateAction.prepareAction();
+ // no start action, normal start
+
+ TuttiUIContext context = getContext();
+
+ if (context.isDbLoaded()) {
+
+ // db already opened (happens when reloading ui)
+ // just go to select cruise screen
+ SelectCruiseAction action = TuttiActionHelper.createLogicAction(handler, SelectCruiseAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ action.setActionDescription(getUI().getMenuActionSelectCruise().getToolTipText());
+ delegateAction = action;
+
+ } else {
+
+ if (context.isDbExist()) {
+
+ // open tutti db (using a fake button to have simple api)
+ OpenDbAction action = TuttiActionHelper.createLogicAction(handler, OpenDbAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ action.setUpdateReferentiel(true);
+ delegateAction = action;
+
+ } else {
+
+ // clean db context
+ context.clearDbContext();
+
+ // go to manage db screen (to install db)
+ ManageDbAction action = TuttiActionHelper.createLogicAction(handler, ManageDbAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ delegateAction = action;
+ }
+ }
}
+
+ setActionDescription(delegateAction.getActionDescription());
+ doAction = delegateAction.prepareAction();
return doAction;
}
@@ -116,4 +161,16 @@
delegateAction = null;
super.releaseAction();
}
+
+ protected void deleteOldDatabaseDirectory() {
+ File dbDirectory = getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
+ if (dbDirectory.exists()) {
+
+ // delete it before install
+ if (log.isInfoEnabled()) {
+ log.info("Delete previous database directory: " + dbDirectory);
+ }
+ TuttiIOUtil.deleteDirectory(dbDirectory, "Could not delete old db directory");
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-11-19 18:25:58 UTC (rev 1364)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-11-20 08:11:09 UTC (rev 1365)
@@ -337,7 +337,7 @@
String message = _("tutti.openDb.step.check.dbContext",
dbVersion, applicationVersion);
- getProgressionModel().increments(message);
+ progressionModel.increments(message);
if (log.isDebugEnabled()) {
log.debug("Check db context");
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionHelper.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionHelper.java 2013-11-19 18:25:58 UTC (rev 1364)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/TuttiActionHelper.java 2013-11-20 08:11:09 UTC (rev 1365)
@@ -29,6 +29,8 @@
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import org.apache.commons.lang3.reflect.ConstructorUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.swing.AbstractButton;
import javax.swing.Action;
@@ -43,6 +45,9 @@
*/
public class TuttiActionHelper {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TuttiActionHelper.class);
+
public static <A extends AbstractTuttiAction> void runInternalAction(A action) {
Throwable error = null;
@@ -51,6 +56,9 @@
action.postSuccessAction();
} catch (Throwable e) {
error = e;
+ if (log.isErrorEnabled()) {
+ log.error("Error in action:", e);
+ }
throw TuttiActionException.propagateError(action, e);
} finally {
try {
1
0
r1364 - in trunk/src: conception/specifications conception/specifications/Concepts-metiers conception/specifications/Presentation site/rst
by lkaufmann@users.forge.codelutin.com 19 Nov '13
by lkaufmann@users.forge.codelutin.com 19 Nov '13
19 Nov '13
Author: lkaufmann
Date: 2013-11-19 19:25:58 +0100 (Tue, 19 Nov 2013)
New Revision: 1364
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1364
Log:
Specifications v0.2 update & spelling correction in help rst files
Modified:
trunk/src/conception/specifications/AllegroCampagne-Specifications.odt
trunk/src/conception/specifications/AllegroCampagne-Specifications.pdf
trunk/src/conception/specifications/Concepts-metiers/Campagne.txt
trunk/src/conception/specifications/Concepts-metiers/Capture.txt
trunk/src/conception/specifications/Concepts-metiers/OperationPecheTrait.txt
trunk/src/conception/specifications/Presentation/PresentationGenerale.txt
trunk/src/site/rst/features.rst
Modified: trunk/src/conception/specifications/AllegroCampagne-Specifications.odt
===================================================================
(Binary files differ)
Modified: trunk/src/conception/specifications/AllegroCampagne-Specifications.pdf
===================================================================
(Binary files differ)
Modified: trunk/src/conception/specifications/Concepts-metiers/Campagne.txt
===================================================================
--- trunk/src/conception/specifications/Concepts-metiers/Campagne.txt 2013-11-19 13:16:50 UTC (rev 1363)
+++ trunk/src/conception/specifications/Concepts-metiers/Campagne.txt 2013-11-19 18:25:58 UTC (rev 1364)
@@ -3,7 +3,7 @@
* Observations et méthodes
Les campagnes suivent toujours les mêmes méthodes d'échantillonnage. Elles sont toujours réalisées dans la même zone, à la même saison, avec des engins de pêche standardisés, afin que les données soient comparables d'année en année.
-Chaque campagne est généralement accomplie une fois par an. Mais certains cas spécifiques imposent sa réalisation plusieurs fois par an, on parle alors de série partielle.
+Chaque campagne est généralement accomplie une fois par an. Mais certains cas spécifiques imposent sa réalisation plusieurs fois par an, on parle alors de leg ou de série partielle.
Chaque zone étudiée est découpée en strates en fonction de la profondeur, de la latitude ou d'autres critères. L'échantillonnage prévoit un nombre de traits de chalut ou de mouillages de casiers par strate.
Modified: trunk/src/conception/specifications/Concepts-metiers/Capture.txt
===================================================================
--- trunk/src/conception/specifications/Concepts-metiers/Capture.txt 2013-11-19 13:16:50 UTC (rev 1363)
+++ trunk/src/conception/specifications/Concepts-metiers/Capture.txt 2013-11-19 18:25:58 UTC (rev 1364)
@@ -3,16 +3,34 @@
* Espèces
+Les observations parmi les prises se font généralement par lots d'espèce. Une quantité significative d'une même nature fournit des observations plus représentatives.
+Les espèces étudiées sont des poissons, des mollusques et des crustacés.
-
* Benthos
-Le benthos regroupe l'ensemble des organismes vivant en relation étroite avec les fonds subaquatiques.
+Le benthos regroupe l'ensemble des organismes vivant en relation étroite avec les fonds subaquatiques : benthos végétal ou phytobenthos (algues et phanérogames) et benthos animal ou
+zoobenthos (vers, mollusques, crustacés...)
+* Macro déchets
+Malheureusement, l'environnement maritime a été affecté par les activités humaines, intentionnellement ou par accident. La problématique ne se pose pas uniquement pour les littoraux mais également les grandes profondeurs. Les déchets sont en effet transportés par les courants océaniques et terminent leurs parcours dans des zones où ils s'accumulent et constituent de véritables décharges sous-marines.
+Exemples de macro déchets :
+- Plastique (sac, emballage, bouteille, …)
+- Verre (bouteille, flacon)
+- Métal (Canette, Conserve, ...)
+- Vêtement et tissu (Gant, botte, chaussure, ...)
+- Baril
-Macro déchets
+* Observations individuelles
-Observations individuelles
+Les analyses se portent sur des espèces, principalement par lots, mais elles peuvent également être effectuées séparément, par individu.
+Les mesures peuvent alors êtres plus détaillées, apportant des observations d'une précision accrue.
-Captures accidentelles
+* Captures accidentelles
+
+Toute capture réalisée en mer peut inclure des espèces non ciblées par les campagnes d'observations, et captées fortuitement dans les chaluts.
+
+Exemples de captures accidentelles :
+- Dauphin
+- Baleine
+- Tortue
Modified: trunk/src/conception/specifications/Concepts-metiers/OperationPecheTrait.txt
===================================================================
--- trunk/src/conception/specifications/Concepts-metiers/OperationPecheTrait.txt 2013-11-19 13:16:50 UTC (rev 1363)
+++ trunk/src/conception/specifications/Concepts-metiers/OperationPecheTrait.txt 2013-11-19 18:25:58 UTC (rev 1364)
@@ -0,0 +1,3 @@
+Une campagne de pêche scientifique est composé d'une ou plusieurs sortie(s) en mer. Lors de ces sorties un certain nombre de captures est effectué à la traîne grâce au chalut. Chaque session de traîne représente un trait.
+
+Lors de ces opérations, un trait dure généralement entre une demi-heure et trois heures.
\ No newline at end of file
Modified: trunk/src/conception/specifications/Presentation/PresentationGenerale.txt
===================================================================
--- trunk/src/conception/specifications/Presentation/PresentationGenerale.txt 2013-11-19 13:16:50 UTC (rev 1363)
+++ trunk/src/conception/specifications/Presentation/PresentationGenerale.txt 2013-11-19 18:25:58 UTC (rev 1364)
@@ -1,24 +1,29 @@
1. Contexte
-L'Ifremer contribue, par ses travaux et expertises, à la connaissance des océans et de leurs ressources, à la surveillance du milieu marin et du littoral et au développement durable des activités maritimes. À ces fins, il conçoit et met en œuvre des outils d'observation, d'expérimentation et de surveillance, et gère des bases de données océanographiques.
+L'Institut Français de Recherche pour l'Exploitation de la MER contribue, par ses travaux et expertises, à la connaissance des océans et de leurs ressources, à la surveillance du milieu marin et du littoral et au développement durable des activités maritimes. À ces fins, il conçoit et met en œuvre des outils d'observation, d'expérimentation et de surveillance, et gère des bases de données océanographiques.
Parmi ses axes stratégiques principaux, la pêche est un domaine de recherche et d'expertise clé de l'Ifremer afin de contribuer à une pêche durable et à la valorisation des ressources biologiques. Dans cette optique, l’objectif est d'appréhender le système halieutique dans toutes ses composantes et sur l’ensemble des façades. Pour cela, l'Ifremer a mis en place un système d'information visant à connaître, évaluer, mettre en valeur les ressources des océans et permettre leur exploitation durable.
Un Système d'Informations Halieutiques (SIH), véritable observatoire national des ressources halieutiques et des usages, a été mis en place au début des années 2000. Il mobilise des compétences de biologistes, économistes, statisticiens et informaticiens.
Il constitue le réseau pérenne et opérationnel d'observation des ressources halieutiques et des usages associés (pêche professionnelle et progressivement pêche récréative) de l’Ifremer.
+
L’Ifremer a mis en place un réseau d’observation des ressources halieutiques et des usages associés, et mène par ailleurs la collecte de données qui lui sont propres, par des enquêtes auprès des professionnels, des échantillonnages et des observations à terre et en mer. Il développe aussi des outils de simulation et modélisation, des outils d’observation vidéo, des outils acoustiques ou des engins de captures spécifiques qui sont mis au point lors d’essais en mer. L’ensemble des données collectées par l’Ifremer ainsi que celles provenant des autres opérateurs sont archivées dans une même base de données.
-Le projet Allegro Campagne est une composante de ce système d'information en tant qu'outil dédié à la saisie de données d'opérations et de captures.
+Le projet Allegro Campagne est une composante de ce système d'information, le objectif étant de fournir un outil dédié à la saisie de données d'opérations et de captures.
2. Historique
-Depuis une vingtaine d'années, l'Ifremer organise des campagnes de pêche scientifique en mer du Nord, en Manche, en Atlantique et en Méditerranée concernant les ressources démersales et benthiques. L'objectif prioritaire est de produire des indices d'abondance des principales espèces commerciales. Elles recueillent également des données sur les espèces capturées non commerciales. Elles contribuent ainsi aux connaissances nécessaires au développement de l'approche écosystémique des pêches, notamment dans le cadre de la politique commune des pêches et plus largement de la stratégie marine de l'Union européenne.
+À l'origine de l'Ifremer, le Centre National pour l'exploitation des Océans (CNEXO) et l'Institut Scientifique et Technique des Pêches Maritimes (ISTPM) ont été uni le 5 juin 1984 afin de constituer l' Institut Français de Recherche pour l'Exploitation de la MER.
+Depuis plus d'une vingtaine d'années, l'Ifremer organise des campagnes de pêche scientifique en mer du Nord, en Manche, en Atlantique et en Méditerranée concernant les ressources démersales et benthiques. L'objectif prioritaire est de produire des indices d'abondance des principales espèces commerciales. Elles recueillent également des données sur les espèces capturées non commerciales. Elles contribuent ainsi aux connaissances nécessaires au développement de l'approche écosystémique des pêches, notamment dans le cadre de la politique commune des pêches et plus largement de la stratégie marine de l'Union européenne.
+Le développement du projet Allegro Campagne (anciennement dénommé Tutti) a été lancé en Novembre 2012.
+
+
3. Description générale
Le développement d’une démarche écosystémique pour la gestion de ressources halieutiques, aujourd’hui plus ou moins fortement dégradées, constitue une priorité de l’Ifremer. L'étude et les observations des ressources actuelles sont à l'origine de l'élaboration de programmes visant à développer le monde maritime. Le volet « Recherche » des actions de l'Ifremer est essentiel car il permet d'améliorer les connaissances et leur vulgarisation.
-Le projet Allegro Campagne fait partie de cette démarche de recueil et de capitalisation des informations. Il vise à fournir un outil spécialement dédié à la collecte de données au cours des campagnes halieutiques. Le périmètre des renseignements à glaner se limite aux opérations de pêches et aux captures réalisées.
+Le recueil et la capitalisation des informations représentent un axe principal de cette démarche où s'inscrit Allegro Campagne. La finalité de l'application cible du projet est la collecte de données au cours des campagnes halieutiques. Le périmètre des renseignements à glaner se limite aux opérations de pêches et aux captures réalisées.
4. Objectifs
Modified: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst 2013-11-19 13:16:50 UTC (rev 1363)
+++ trunk/src/site/rst/features.rst 2013-11-19 18:25:58 UTC (rev 1364)
@@ -255,8 +255,8 @@
- **pmfmId** (entier) : identifiant du psfm
- **pmfmType** (LENGTH_STEP,GEAR_USE_FEATURE,VESSEL_USE_FEATURE) : écran où intervient la caractéristique
- pmfmParameterName (chaîne de caractères) : paramètre de la caractéristique
-- pmfmMatrixName (chaîne de caractères) : support de la caractérisque
-- pmfmFractionName (chaîne de caractères) : fraction de la caractérisque
+- pmfmMatrixName (chaîne de caractères) : support de la caractéristique
+- pmfmFractionName (chaîne de caractères) : fraction de la caractéristique
- pmfmMethodName (chaîne de caractères) : méthode de la caractéristique
A noter que seules les colonnes identifiées en gras sont prises en compte lors
1
0
r1363 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities tutti-service/src/main/java/fr/ifremer/tutti/service/catches
by tchemit@users.forge.codelutin.com 19 Nov '13
by tchemit@users.forge.codelutin.com 19 Nov '13
19 Nov '13
Author: tchemit
Date: 2013-11-19 14:16:50 +0100 (Tue, 19 Nov 2013)
New Revision: 1363
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1363
Log:
fixes #3804: [CAPTURE] mauvais affichage des //
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
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-11-19 07:51:45 UTC (rev 1362)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-11-19 13:16:50 UTC (rev 1363)
@@ -46,6 +46,8 @@
import org.hibernate.cfg.Environment;
import java.io.File;
+import java.math.BigDecimal;
+import java.math.MathContext;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
@@ -97,6 +99,8 @@
}
};
+ private static final MathContext MATH_CONTEXT_4_DIGIT = new MathContext(4);
+
/** Logger. */
private static final Log log = LogFactory.getLog(TuttiEntities.class);
@@ -113,8 +117,8 @@
public static <B extends TuttiEntity> List<Integer> toIntegerIds(Collection<B> list) {
List<Integer> result = list == null ?
- Collections.<Integer>emptyList() :
- Lists.transform(Lists.newArrayList(list), GET_ID_AS_INT);
+ Collections.<Integer>emptyList() :
+ Lists.transform(Lists.newArrayList(list), GET_ID_AS_INT);
return result;
}
@@ -333,6 +337,19 @@
}
}
+ /**
+ * Round the given value to max 4 digits.
+ *
+ * @param value the float to round.
+ * @return the rounded value
+ * @since 2.10
+ */
+ public static float roundKiloGram(float value) {
+ BigDecimal sumB = new BigDecimal(value);
+ float result = sumB.abs(MATH_CONTEXT_4_DIGIT).floatValue();
+ return result;
+ }
+
protected static class IdPredicate<B extends TuttiEntity> implements Predicate<B> {
private final String id;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-19 07:51:45 UTC (rev 1362)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2013-11-19 13:16:50 UTC (rev 1363)
@@ -213,18 +213,21 @@
Float speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedWeight();
if (speciesTotalSortedWeight == null) {
speciesTotalSortedWeight = speciesTotalComputedSortedWeight;
- catchBatch.setSpeciesTotalSortedComputedWeight(speciesTotalSortedWeight);
+ catchBatch.setSpeciesTotalSortedComputedWeight(
+ TuttiEntities.roundKiloGram(speciesTotalSortedWeight));
} else if (speciesTotalSortedWeight < speciesTotalComputedSortedWeight) {
throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.species.incoherentTotalSorted"));
}
- catchBatch.setSpeciesTotalUnsortedComputedWeight(speciesTotalComputedUnsortedWeight);
+ catchBatch.setSpeciesTotalUnsortedComputedWeight(
+ TuttiEntities.roundKiloGram(speciesTotalComputedUnsortedWeight));
if (speciesTotalSortedWeight == null) {
speciesTotalSortedWeight = catchBatch.getSpeciesTotalSortedComputedWeight();
}
Float speciesTotalWeight = speciesTotalComputedUnsortedWeight + speciesTotalSortedWeight;
- catchBatch.setSpeciesTotalComputedWeight(speciesTotalWeight);
+ catchBatch.setSpeciesTotalComputedWeight(
+ TuttiEntities.roundKiloGram(speciesTotalWeight));
// Benthos
Float benthosTotalComputedSortedWeight = 0f;
@@ -262,23 +265,27 @@
catchBatch.setBenthosTotalLivingNotItemizedComputedWeight(0f);
}
- catchBatch.setBenthosTotalSampleSortedComputedWeight(benthosTotalComputedSortedWeight);
+ catchBatch.setBenthosTotalSampleSortedComputedWeight(
+ TuttiEntities.roundKiloGram(benthosTotalComputedSortedWeight));
Float benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedWeight();
if (benthosTotalSortedWeight == null) {
benthosTotalSortedWeight = benthosTotalComputedSortedWeight;
- catchBatch.setBenthosTotalSortedComputedWeight(benthosTotalSortedWeight);
+ catchBatch.setBenthosTotalSortedComputedWeight(
+ TuttiEntities.roundKiloGram(benthosTotalSortedWeight));
} else if (benthosTotalSortedWeight < benthosTotalComputedSortedWeight) {
throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.benthos.incoherentTotalSorted"));
}
- catchBatch.setBenthosTotalUnsortedComputedWeight(benthosTotalComputedUnsortedWeight);
+ catchBatch.setBenthosTotalUnsortedComputedWeight(
+ TuttiEntities.roundKiloGram(benthosTotalComputedUnsortedWeight));
if (benthosTotalSortedWeight == null) {
benthosTotalSortedWeight = catchBatch.getBenthosTotalSortedComputedWeight();
}
Float benthosTotalWeight = benthosTotalComputedUnsortedWeight + benthosTotalSortedWeight;
- catchBatch.setBenthosTotalComputedWeight(benthosTotalWeight);
+ catchBatch.setBenthosTotalComputedWeight(
+ TuttiEntities.roundKiloGram(benthosTotalWeight));
// Marine litter
Float marineLitterTotalComputedWeight = 0f;
@@ -294,7 +301,8 @@
marineLitterTotalComputedWeight += rowWeight;
}
}
- catchBatch.setMarineLitterTotalComputedWeight(marineLitterTotalComputedWeight);
+ catchBatch.setMarineLitterTotalComputedWeight(
+ TuttiEntities.roundKiloGram(marineLitterTotalComputedWeight));
Float marineLitterTotalWeight = catchBatch.getMarineLitterTotalWeight();
if (marineLitterTotalWeight == null) {
@@ -311,8 +319,8 @@
Float totalSortedWeight = speciesTotalSortedWeight + benthosTotalSortedWeight;
- catchBatch.setCatchTotalSortedComputedWeight(totalSortedWeight);
- catchBatch.setCatchTotalUnsortedComputedWeight(totalUnsortedWeight);
+ catchBatch.setCatchTotalSortedComputedWeight(TuttiEntities.roundKiloGram(totalSortedWeight));
+ catchBatch.setCatchTotalUnsortedComputedWeight(TuttiEntities.roundKiloGram(totalUnsortedWeight));
Float totalWeight = catchBatch.getCatchTotalWeight();
Float rejectedWeight = catchBatch.getCatchTotalRejectedWeight();
@@ -323,9 +331,10 @@
throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentTotal"));
} else {
- catchBatch.setCatchTotalRejectedComputedWeight(totalWeight
- - totalUnsortedWeight
- - totalSortedWeight);
+ catchBatch.setCatchTotalRejectedComputedWeight(
+ TuttiEntities.roundKiloGram(totalWeight
+ - totalUnsortedWeight
+ - totalSortedWeight));
}
} else if (totalWeight == null) {
@@ -333,9 +342,10 @@
rejectedWeight = 0f;
catchBatch.setCatchTotalRejectedComputedWeight(0f);
}
- catchBatch.setCatchTotalComputedWeight(totalUnsortedWeight
- + totalSortedWeight
- + rejectedWeight);
+ catchBatch.setCatchTotalComputedWeight(
+ TuttiEntities.roundKiloGram(totalUnsortedWeight
+ + totalSortedWeight
+ + rejectedWeight));
} else if (!totalWeight.equals(totalUnsortedWeight + totalSortedWeight + rejectedWeight)) {
throw new TuttiBusinessException(_("tutti.service.operations.computeWeights.error.incoherentTotal"));
@@ -410,7 +420,7 @@
if (sum != null) {
if (categoryWeight == null) {
- batch.setSampleCategoryComputedWeight(sum);
+ batch.setSampleCategoryComputedWeight(TuttiEntities.roundKiloGram(sum));
} else if (categoryWeight < sum) {
String categoryLabel = getCategoryLabel(batch.getSampleCategoryId());
@@ -475,7 +485,7 @@
} else if (categoryWeight == null && frequencyWeight != null) {
// if the category weight is null and the frequencies have a weight,
// then this weight is the result
- batch.setSampleCategoryComputedWeight(frequencyWeight);
+ batch.setSampleCategoryComputedWeight(TuttiEntities.roundKiloGram(frequencyWeight));
result = frequencyWeight;
} else if (frequencyWeight != null
@@ -498,7 +508,7 @@
thisIndex);
} else if (rowWeight == null) {
- batch.setComputedWeight(frequencyWeight);
+ batch.setComputedWeight(TuttiEntities.roundKiloGram(frequencyWeight));
}
result = categoryWeight;
@@ -532,7 +542,7 @@
thisIndex);
}
- return result;
+ return TuttiEntities.roundKiloGram(result);
}
private int currentBenthosRowIndex;
@@ -597,7 +607,7 @@
if (sum != null) {
if (categoryWeight == null) {
- batch.setSampleCategoryComputedWeight(sum);
+ batch.setSampleCategoryComputedWeight(TuttiEntities.roundKiloGram(sum));
} else if (categoryWeight < sum) {
String categoryLabel =
@@ -666,7 +676,7 @@
} else if (categoryWeight == null && frequencyWeight != null) {
// if the category weight is null and the frequencies have a weight,
// then this weight is the result
- batch.setSampleCategoryComputedWeight(frequencyWeight);
+ batch.setSampleCategoryComputedWeight(TuttiEntities.roundKiloGram(frequencyWeight));
result = frequencyWeight;
} else if (frequencyWeight != null
@@ -690,7 +700,7 @@
thisIndex);
} else if (rowWeight == null) {
- batch.setComputedWeight(frequencyWeight);
+ batch.setComputedWeight(TuttiEntities.roundKiloGram(frequencyWeight));
}
result = categoryWeight;
@@ -724,7 +734,7 @@
thisIndex);
}
- return result;
+ return TuttiEntities.roundKiloGram(result);
}
public BatchContainer<MarineLitterBatch> getComputedMarineLitterBatches(String fishingOperationId,
1
0
r1362 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 19 Nov '13
by tchemit@users.forge.codelutin.com 19 Nov '13
19 Nov '13
Author: tchemit
Date: 2013-11-19 08:51:45 +0100 (Tue, 19 Nov 2013)
New Revision: 1362
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1362
Log:
fixes #3823: [TECH] Temps d'affichage d'un trait trop lent
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-11-18 09:09:03 UTC (rev 1361)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-11-19 07:51:45 UTC (rev 1362)
@@ -172,7 +172,7 @@
* @see Species#getRefTaxCode()
* @since 0.3
*/
- @Cacheable(value = "referentSpeciesById", key = "#referenceTaxonId", condition = "#referenceTaxonId != null")
+ @Cacheable(value = "referentSpeciesById", key = "#referenceTaxonId")
Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId);
/**
@@ -187,7 +187,7 @@
* @see Species#getVernacularCode()
* @since 2.0
*/
- @Cacheable(value = "referentSpeciesByIdVernacular", key = "#referenceTaxonId", condition = "#referenceTaxonId != null")
+ @Cacheable(value = "referentSpeciesByIdVernacular", key = "#referenceTaxonId")
Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId);
/**
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-11-18 09:09:03 UTC (rev 1361)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-11-19 07:51:45 UTC (rev 1362)
@@ -436,9 +436,9 @@
}
@Override
- public Species getSpeciesByReferenceTaxonId(Integer speciesId) {
+ public Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId) {
Species result = getSpeciesByReferenceTaxonId(
- speciesId,
+ referenceTaxonId,
enumeration.TRANSCRIBING_TYPE_ID_REFTAX);
if (result != null) {
result.setRefTaxCode(result.getExternalCode());
@@ -447,9 +447,9 @@
}
@Override
- public Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer speciesId) {
+ public Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId) {
Species result = getSpeciesByReferenceTaxonId(
- speciesId,
+ referenceTaxonId,
enumeration.TRANSCRIBING_TYPE_ID_VERNACULAIRE);
if (result != null) {
result.setVernacularCode(result.getExternalCode());
@@ -457,12 +457,12 @@
return result;
}
- protected Species getSpeciesByReferenceTaxonId(Integer speciesId,
+ protected Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId,
Integer transcribingTypeId) {
Species target;
try {
TaxonRefVO source = taxonNameDao.getTaxonNameReferent(
- speciesId, transcribingTypeId);
+ referenceTaxonId, transcribingTypeId);
target = loadSpecies(source);
} catch (DataRetrievalFailureException drfe) {
target = null;
@@ -769,7 +769,7 @@
// Fill the result bean
Person result = Persons.newPerson();
- result.setId(target.getId().toString());
+ result.setId(target.getId());
result.setLastName(source.getLastName());
result.setFirstName(source.getFirstName());
setStatus(status, result);
@@ -792,7 +792,7 @@
// Add to cache
Cache cache = cacheService.getCache("referentSpeciesById");
- cache.put(Integer.valueOf(result.getId()), result);
+ cache.put(result.getIdAsInt(), result);
return result;
}
@@ -813,7 +813,7 @@
// Fill the result bean
Gear result = Gears.newGear();
- result.setId(target.getId().toString());
+ result.setId(target.getId());
result.setLabel(source.getLabel());
result.setName(source.getName());
result.setScientificGear(source.isScientificGear());
@@ -843,7 +843,7 @@
Integer pmfmId = (Integer) source[0];
Caracteristic result = Caracteristics.newCaracteristic();
- result.setId(pmfmId.toString());
+ result.setId(pmfmId);
result.setParameterName((String) source[1]);
result.setMatrixName((String) source[2]);
result.setFractionName((String) source[3]);
@@ -892,7 +892,7 @@
protected Species loadSpecies(TaxonRefVO source) {
Species target = Speciess.newSpecies();
- target.setId(String.valueOf(source.getTaxonNameId()));
+ target.setId(source.getTaxonNameId());
target.setName(source.getName());
target.setExternalCode(source.getExternalCode());
target.setReferenceTaxonId(source.getReferenceTaxonId());
@@ -941,7 +941,7 @@
protected TuttiLocation loadLocation(Object[] source) {
TuttiLocation target = TuttiLocations.newTuttiLocation();
- target.setId(String.valueOf(source[0]));
+ target.setId((Integer) source[0]);
target.setLabel((String) source[1]);
target.setName((String) source[2]);
setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[3], target);
1
0
r1361 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos/frequency species/frequency
by tchemit@users.forge.codelutin.com 18 Nov '13
by tchemit@users.forge.codelutin.com 18 Nov '13
18 Nov '13
Author: tchemit
Date: 2013-11-18 10:09:03 +0100 (Mon, 18 Nov 2013)
New Revision: 1361
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1361
Log:
fixes #3807: [CAPTURE] mensurations, non r?\195?\169initialisation des champs taile min et max entre deux ouverture de l'?\195?\169cran...
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-17 17:39:59 UTC (rev 1360)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-18 09:09:03 UTC (rev 1361)
@@ -427,22 +427,22 @@
Float maxStep = model.getLengthStep(model.getMaxStep());
Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic();
+ Set<Float> existingKeys = Sets.newHashSet(rowsByStep.keySet());
+ List<BenthosFrequencyRowModel> rows = Lists.newArrayList(rowsByStep.values());
+
for (float i = minStep, step = model.getStep(); i <= maxStep;
i = TuttiUIUtil.getRoundedLengthStep(i + step, true)) {
- if (!rowsByStep.containsKey(i)) {
+ if (!existingKeys.contains(i)) {
// add it
BenthosFrequencyRowModel newRow = tableModel.createNewRow();
newRow.setLengthStep(i);
newRow.setLengthStepCaracteristic(lengthStepCaracteristic);
- rowsByStep.put(i, newRow);
+ rows.add(newRow);
}
}
-
- List<BenthosFrequencyRowModel> rows =
- Lists.newArrayList(rowsByStep.values());
-
+ Collections.sort(rows);
model.setRows(rows);
// select first cell in table (see http://forge.codelutin.com/issues/2496)
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-17 17:39:59 UTC (rev 1360)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-18 09:09:03 UTC (rev 1361)
@@ -424,22 +424,22 @@
Float maxStep = model.getLengthStep(model.getMaxStep());
Caracteristic lengthStepCaracteristic = model.getLengthStepCaracteristic();
+ Set<Float> existingKeys = Sets.newHashSet(rowsByStep.keySet());
+ List<SpeciesFrequencyRowModel> rows = Lists.newArrayList(rowsByStep.values());
+
for (float i = minStep, step = model.getStep(); i <= maxStep;
i = TuttiUIUtil.getRoundedLengthStep(i + step, true)) {
- if (!rowsByStep.containsKey(i)) {
+ if (!existingKeys.contains(i)) {
// add it
SpeciesFrequencyRowModel newRow = tableModel.createNewRow();
newRow.setLengthStep(i);
newRow.setLengthStepCaracteristic(lengthStepCaracteristic);
- rowsByStep.put(i, newRow);
+ rows.add(newRow);
}
}
-
- List<SpeciesFrequencyRowModel> rows =
- Lists.newArrayList(rowsByStep.values());
-
+ Collections.sort(rows);
model.setRows(rows);
// select first cell in table (see http://forge.codelutin.com/issues/2496)
1
0
r1360 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
by tchemit@users.forge.codelutin.com 17 Nov '13
by tchemit@users.forge.codelutin.com 17 Nov '13
17 Nov '13
Author: tchemit
Date: 2013-11-17 18:39:59 +0100 (Sun, 17 Nov 2013)
New Revision: 1360
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1360
Log:
fixes #3808: [CAPTURE] erreur suite suppression d'un lot esp?\195?\168ce et fermeture de l'?\195?\169cran de saisie. A analyser
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360)
@@ -31,8 +31,6 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import javax.swing.JOptionPane;
@@ -48,10 +46,6 @@
*/
public class RemoveBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(RemoveBenthosBatchAction.class);
-
/**
* Selected row to treat.
*
@@ -59,6 +53,13 @@
*/
protected int rowIndex;
+ /**
+ * Rows to delete after all.
+ *
+ * @since 2.10
+ */
+ protected Set<BenthosBatchRowModel> rowToRemove;
+
public RemoveBenthosBatchAction(BenthosBatchUIHandler handler) {
super(handler, false);
}
@@ -115,21 +116,10 @@
}
// collect of rows to remove from model
- Set<BenthosBatchRowModel> rowToRemove = Sets.newHashSet();
+ rowToRemove = Sets.newHashSet();
rowToRemove.add(selectedBatch);
handler.collectChildren(selectedBatch, rowToRemove);
-
-//FIXME TC-2013-10-14 Comment this line, don't see the point
-// table.clearSelection();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
-// // refresh table from parent batch row index to the end
-// tableModel.fireTableDataChanged();
-//
-// TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
}
@Override
@@ -138,6 +128,9 @@
JXTable table = handler.getTable();
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
// refresh table from parent batch row index to the end
handler.getTableModel().fireTableDataChanged();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360)
@@ -53,6 +53,20 @@
*/
protected int rowIndex;
+ /**
+ * Rows to delete after all.
+ *
+ * @since 2.10
+ */
+ protected Set<BenthosBatchRowModel> rowToRemove;
+
+ /**
+ * Parent batch of rows to delete.
+ *
+ * @since 2.10
+ */
+ protected BenthosBatchRowModel parentBatch;
+
public RemoveBenthosSubBatchAction(BenthosBatchUIHandler handler) {
super(handler, false);
}
@@ -87,7 +101,7 @@
Preconditions.checkState(rowIndex != -1,
"Cant remove sub batch if no batch selected");
- BenthosBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex);
+ parentBatch = handler.getTableModel().getEntry(rowIndex);
Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
"Can't remove sub batch if batch is not persisted");
@@ -96,30 +110,9 @@
persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
// collect of rows to remove from model
- Set<BenthosBatchRowModel> rowToRemove = Sets.newHashSet();
+ rowToRemove = Sets.newHashSet();
handler.collectChildren(parentBatch, rowToRemove);
-
-//FIXME TC-2013-10-14 Comment this line, don't see the point
-// table.clearSelection();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
- // remove childs from parent batch
- parentBatch.setChildBatch(null);
-
-// // refresh table from parent batch row index to the end
-// handler.getTableModel().fireTableDataChanged();
-//
-// // select parent batch row
-// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
-//
-// if (table.isEditing()) {
-//
-// // but no edit it
-// table.getCellEditor().stopCellEditing();
-// }
}
@Override
@@ -128,6 +121,12 @@
JXTable table = handler.getTable();
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // remove childs from parent batch
+ parentBatch.setChildBatch(null);
+
// refresh table from parent batch row index to the end
handler.getTableModel().fireTableDataChanged();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360)
@@ -31,8 +31,6 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import javax.swing.JOptionPane;
@@ -48,9 +46,12 @@
*/
public class RemoveSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(RemoveSpeciesBatchAction.class);
+ /**
+ * Rows to delete after all.
+ *
+ * @since 2.10
+ */
+ protected Set<SpeciesBatchRowModel> rowToRemove;
public RemoveSpeciesBatchAction(SpeciesBatchUIHandler handler) {
super(handler, false);
@@ -85,6 +86,7 @@
"Cant remove batch if no batch selected");
SpeciesBatchTableModel tableModel = handler.getTableModel();
+
SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
Preconditions.checkState(!TuttiEntities.isNew(selectedBatch),
@@ -106,32 +108,10 @@
}
// collect of rows to remove from model
- Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet();
+ rowToRemove = Sets.newHashSet();
rowToRemove.add(selectedBatch);
handler.collectChildren(selectedBatch, rowToRemove);
-
-//FIXME TC-2013-10-14 Comment this line, don't see the point
-// table.clearSelection();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
-// // refresh table from parent batch row index to the end
-// tableModel.fireTableDataChanged();
-//
-// if (!getModel().getRows().isEmpty()) {
-//
-// // select first row
-// AbstractSelectTableAction.doSelectCell(table, 0, 0);
-//
-// }
-//
-// if (table.isEditing()) {
-//
-// // but no edit it
-// table.getCellEditor().stopCellEditing();
-// }
}
@Override
@@ -140,6 +120,9 @@
JXTable table = handler.getTable();
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
// refresh table from parent batch row index to the end
handler.getTableModel().fireTableDataChanged();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-17 17:12:02 UTC (rev 1359)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-17 17:39:59 UTC (rev 1360)
@@ -53,6 +53,20 @@
*/
protected int rowIndex;
+ /**
+ * Rows to delete after all.
+ *
+ * @since 2.10
+ */
+ protected Set<SpeciesBatchRowModel> rowToRemove;
+
+ /**
+ * Parent batch of rows to delete.
+ *
+ * @since 2.10
+ */
+ protected SpeciesBatchRowModel parentBatch;
+
public RemoveSpeciesSubBatchAction(SpeciesBatchUIHandler handler) {
super(handler, false);
}
@@ -87,8 +101,9 @@
Preconditions.checkState(rowIndex != -1,
"Cant remove sub batch if no batch selected");
- SpeciesBatchRowModel parentBatch = handler.getTableModel().getEntry(rowIndex);
+ parentBatch = handler.getTableModel().getEntry(rowIndex);
+
Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
"Can't remove sub batch if batch is not persisted");
@@ -96,38 +111,24 @@
persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
// collect of rows to remove from model
- Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet();
+ rowToRemove = Sets.newHashSet();
+
handler.collectChildren(parentBatch, rowToRemove);
+ }
-//FIXME TC-2013-10-14 Comment this line, don't see the point
-// table.clearSelection();
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ JXTable table = handler.getTable();
+
// remove all rows from the model
getModel().getRows().removeAll(rowToRemove);
// remove childs from parent batch
parentBatch.setChildBatch(null);
-// // refresh table from parent batch row index to the end
-// handler.getTableModel().fireTableDataChanged();
-//
-// // select parent batch row
-// TuttiUIUtil.selectFirstCellOnRow(table, rowIndex);
-//
-// if (table.isEditing()) {
-//
-// // but no edit it
-// table.getCellEditor().stopCellEditing();
-// }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
// refresh table from parent batch row index to the end
handler.getTableModel().fireTableDataChanged();
1
0
r1359 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 17 Nov '13
by tchemit@users.forge.codelutin.com 17 Nov '13
17 Nov '13
Author: tchemit
Date: 2013-11-17 18:12:02 +0100 (Sun, 17 Nov 2013)
New Revision: 1359
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1359
Log:
fixes #3822: Am?\195?\169liorer l'affichage lors de l'?\195?\169l?\195?\169vation des poids
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-17 17:10:15 UTC (rev 1358)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-17 17:12:02 UTC (rev 1359)
@@ -59,7 +59,7 @@
protected final WeightCleaningService cleaningService;
public ComputeBatchWeightsAction(EditCatchesUIHandler handler) {
- super(handler, false);
+ super(handler, true);
cleaningService = getContext().getWeightCleaningService();
}
1
0
r1358 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
by tchemit@users.forge.codelutin.com 17 Nov '13
by tchemit@users.forge.codelutin.com 17 Nov '13
17 Nov '13
Author: tchemit
Date: 2013-11-17 18:10:15 +0100 (Sun, 17 Nov 2013)
New Revision: 1358
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1358
Log:
fixes #3821: [CAPTURES] Poids sous-?\195?\169chantillon?\195?\169 calcul?\195?\169 non converti
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/species/SpeciesBatchRowModel.java
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-11-17 17:09:27 UTC (rev 1357)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-11-17 17:10:15 UTC (rev 1358)
@@ -249,6 +249,7 @@
// convert weight
setWeight(weightUnit.fromEntity(getWeight()));
+ setComputedWeight(weightUnit.fromEntity(getComputedWeight()));
}
@Override
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-11-17 17:09:27 UTC (rev 1357)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-11-17 17:10:15 UTC (rev 1358)
@@ -214,6 +214,7 @@
// convert weight
setWeight(weightUnit.fromEntity(getWeight()));
+ setComputedWeight(weightUnit.fromEntity(getComputedWeight()));
}
@Override
1
0