Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
April 2013
- 5 participants
- 210 discussions
r793 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 16 Apr '13
by tchemit@users.forge.codelutin.com 16 Apr '13
16 Apr '13
Author: tchemit
Date: 2013-04-16 12:01:18 +0200 (Tue, 16 Apr 2013)
New Revision: 793
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/793
Log:
fixes #2297: [TRAIT] erreur ?\195?\160 la cr?\195?\169ation d'un premier trait sur une nouvelle campagne
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-16 07:32:28 UTC (rev 792)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-16 10:01:18 UTC (rev 793)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
@@ -403,7 +402,7 @@
{
if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Lists.<Batch>newArrayList());
+ batch.setChildBatchs(Sets.<Batch>newHashSet());
}
Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
@@ -430,7 +429,7 @@
{
if (speciesBatch.getChildBatchs() == null) {
- speciesBatch.setChildBatchs(Lists.<Batch>newArrayList());
+ speciesBatch.setChildBatchs(Sets.<Batch>newHashSet());
}
Map<Integer, SortingBatch> speciesBatchChilds = getChildsMap(speciesBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
@@ -519,7 +518,7 @@
{
if (benthosBatch.getChildBatchs() == null) {
- benthosBatch.setChildBatchs(Lists.<Batch>newArrayList());
+ benthosBatch.setChildBatchs(Sets.<Batch>newHashSet());
}
Map<Integer, SortingBatch> benthosBatchChilds = getChildsMap(benthosBatch, enumeration.PMFM_ID_SORTING_TYPE_2);
@@ -610,7 +609,9 @@
{
Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
- batch.setChildBatchs(Lists.<Batch>newArrayList());
+ if (batch.getChildBatchs() == null) {
+ batch.setChildBatchs(Sets.<Batch>newHashSet());
+ }
// -----------------------------------------------------------------------------
// Hors Vrac > Species
// -----------------------------------------------------------------------------
@@ -619,11 +620,6 @@
if (speciesBatch == null) {
speciesBatch = SortingBatch.Factory.newInstance();
batch.getChildBatchs().add(speciesBatch);
-// if (batch.getChildBatchs() == null) {
-// batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
-// } else {
-// batch.getChildBatchs().add(speciesBatch);
-// }
}
beanToEntitySortingBatch(target,
batch,
1
0
r792 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 16 Apr '13
by maven-release@users.forge.codelutin.com 16 Apr '13
16 Apr '13
Author: maven-release
Date: 2013-04-16 09:32:28 +0200 (Tue, 16 Apr 2013)
New Revision: 792
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/792
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-04-16 07:32:19 UTC (rev 791)
+++ trunk/pom.xml 2013-04-16 07:32:28 UTC (rev 792)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4</version>
+ <version>2.0-SNAPSHOT</version>
<modules>
<module>tutti-persistence</module>
@@ -89,12 +89,12 @@
</developers>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
</developerConnection>
</scm>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-04-16 07:32:19 UTC (rev 791)
+++ trunk/tutti-persistence/pom.xml 2013-04-16 07:32:28 UTC (rev 792)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-04-16 07:32:19 UTC (rev 791)
+++ trunk/tutti-service/pom.xml 2013-04-16 07:32:28 UTC (rev 792)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-04-16 07:32:19 UTC (rev 791)
+++ trunk/tutti-ui-swing/pom.xml 2013-04-16 07:32:28 UTC (rev 792)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: maven-release
Date: 2013-04-16 09:32:19 +0200 (Tue, 16 Apr 2013)
New Revision: 791
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/791
Log:
[maven-release-plugin] copy for tag tutti-1.4
Added:
tags/tutti-1.4/
1
0
r790 - in trunk: . tutti-persistence tutti-service tutti-ui-swing
by maven-release@users.forge.codelutin.com 16 Apr '13
by maven-release@users.forge.codelutin.com 16 Apr '13
16 Apr '13
Author: maven-release
Date: 2013-04-16 09:32:10 +0200 (Tue, 16 Apr 2013)
New Revision: 790
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/790
Log:
[maven-release-plugin] prepare release tutti-1.4
Modified:
trunk/pom.xml
trunk/tutti-persistence/pom.xml
trunk/tutti-service/pom.xml
trunk/tutti-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-04-16 07:18:56 UTC (rev 789)
+++ trunk/pom.xml 2013-04-16 07:32:10 UTC (rev 790)
@@ -33,7 +33,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.4</version>
<modules>
<module>tutti-persistence</module>
@@ -89,12 +89,12 @@
</developers>
<scm>
- <url>http://svn.forge.codelutin.com/svn/tutti/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/tutti/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/tutti/tags/tutti-1.4
</developerConnection>
</scm>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-04-16 07:18:56 UTC (rev 789)
+++ trunk/tutti-persistence/pom.xml 2013-04-16 07:32:10 UTC (rev 790)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.4</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-service/pom.xml
===================================================================
--- trunk/tutti-service/pom.xml 2013-04-16 07:18:56 UTC (rev 789)
+++ trunk/tutti-service/pom.xml 2013-04-16 07:32:10 UTC (rev 790)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.4</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-04-16 07:18:56 UTC (rev 789)
+++ trunk/tutti-ui-swing/pom.xml 2013-04-16 07:32:10 UTC (rev 790)
@@ -28,7 +28,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>tutti</artifactId>
- <version>1.4-SNAPSHOT</version>
+ <version>1.4</version>
</parent>
<groupId>fr.ifremer.tutti</groupId>
1
0
Author: cbonnet
Date: 2013-04-16 09:18:56 +0200 (Tue, 16 Apr 2013)
New Revision: 789
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/789
Log:
Correction requ?\195?\170te jointure pour les taxons
Modified:
trunk/src/site/rst/referential.rst
Modified: trunk/src/site/rst/referential.rst
===================================================================
--- trunk/src/site/rst/referential.rst 2013-04-16 07:13:10 UTC (rev 788)
+++ trunk/src/site/rst/referential.rst 2013-04-16 07:18:56 UTC (rev 789)
@@ -238,18 +238,20 @@
::
- SELECT
+ SELECT
t.id,
t.reference_taxon_fk,
t.complete_name,
- ti.external_code as "code rubin",
+ trans.external_code as "code rubin",
t.is_referent
FROM
taxon_name t
- LEFT JOIN transcribing_item ti on t.reference_taxon_fk = ti.object_id
- LEFT JOIN transcribing_item_type tt on ti.transcribing_item_type_fk = tt.id
- and tt.name = 'TAXINOMIE-REFTAX.MNEMONIQUE'
+ LEFT JOIN (select object_id, external_code from transcribing_item ti, transcribing_item_type tt
+ where ti.transcribing_item_type_fk = tt.id
+ and tt.name = 'TAXINOMIE-REFTAX.MNEMONIQUE') as trans
+ on t.reference_taxon_fk = trans.object_id
+
NB :
- mettre tt.name en paramètre car ça pourrait changer
- il faut partir du modèle mis à jour pour la V2 (les tables transcribing ont évolué)
@@ -262,18 +264,20 @@
::
- SELECT
+ SELECT
t.id,
t.reference_taxon_fk,
t.complete_name,
- ti.external_code as "nom vernaculaire",
+ trans.external_code as "nom vernaculaire",
t.is_referent
FROM
taxon_name t
- LEFT JOIN transcribing_item ti on t.reference_taxon_fk = ti.object_id
- LEFT JOIN transcribing_item_type tt on ti.transcribing_item_type_fk = tt.id
- and tt.name = 'TAXINOMIE-COMMUN.NOM_VERNACULAIRE'
+ LEFT JOIN (select object_id, external_code from transcribing_item ti, transcribing_item_type tt
+ where ti.transcribing_item_type_fk = tt.id
+ and tt.name = 'TAXINOMIE-COMMUN.NOM_VERNACULAIRE') as trans
+ on t.reference_taxon_fk = trans.object_id
+
NB :
- mettre tt.name en paramètre car ça pourrait changer
- il faut partir du modèle mis à jour pour la V2 (les tables transcribing ont évolué)
1
0
r788 - in trunk/tutti-ui-swing/src/main/assembly: full min
by tchemit@users.forge.codelutin.com 16 Apr '13
by tchemit@users.forge.codelutin.com 16 Apr '13
16 Apr '13
Author: tchemit
Date: 2013-04-16 09:13:10 +0200 (Tue, 16 Apr 2013)
New Revision: 788
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/788
Log:
fixes #2261: [TECH] - Installation : non red?\195?\169marrage automatique suite mise ?\195?\160 jour logiciel
fixes #2226: [TECH] - Probl?\195?\168me ?\195?\160 l'installation de la 1.1.2
Modified:
trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat
trunk/tutti-ui-swing/src/main/assembly/min/update.bat
Modified: trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-04-15 23:10:49 UTC (rev 787)
+++ trunk/tutti-ui-swing/src/main/assembly/full/tutti.bat 2013-04-16 07:13:10 UTC (rev 788)
@@ -3,7 +3,6 @@
set OLDDIR=%CD%
cd /d %~dp0%
-
set TUTTI_BASEDIR="%CD%"
set JAVA_HOME=%TUTTI_BASEDIR%\jre
set JAVA_COMMAND=%JAVA_HOME%\bin\java
@@ -13,6 +12,8 @@
echo "tutti jre home: %JAVA_HOME%"
echo "tutti log file: %TUTTI_LOG_FILE%"
+:start
+
copy tutti\update.bat .
call update.bat
del update.bat
Modified: trunk/tutti-ui-swing/src/main/assembly/min/update.bat
===================================================================
--- trunk/tutti-ui-swing/src/main/assembly/min/update.bat 2013-04-15 23:10:49 UTC (rev 787)
+++ trunk/tutti-ui-swing/src/main/assembly/min/update.bat 2013-04-16 07:13:10 UTC (rev 788)
@@ -34,7 +34,7 @@
rem deplacement de l'ancien i18n
set /p oldVersion=<i18n\version.appup
set /p newVersion=<NEW\i18n\version.appup
-set backupdir=OLD\tutti-%oldVersion: =%-%BACKUP_DATE: =%
+set backupdir=OLD\i18n-%oldVersion: =%-%BACKUP_DATE: =%
echo Update i18n version %oldVersion: =% to %newVersion: =% old i18n keep in "%backupdir%"
if not exist "OLD" mkdir OLD
move i18n "%backupdir%"
@@ -47,7 +47,7 @@
rem deplacement de l'ancien help
set /p oldVersion=<help\version.appup
set /p newVersion=<NEW\help\version.appup
-set backupdir=OLD\tutti-%oldVersion: =%-%BACKUP_DATE: =%
+set backupdir=OLD\help-%oldVersion: =%-%BACKUP_DATE: =%
echo Update help version %oldVersion: =% to %newVersion: =% old help keep in "%backupdir%"
if not exist "OLD" mkdir OLD
move help "%backupdir%"
1
0
r787 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches content/operation/catches/benthos content/operation/catches/species util/table
by tchemit@users.forge.codelutin.com 15 Apr '13
by tchemit@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: tchemit
Date: 2013-04-16 01:10:49 +0200 (Tue, 16 Apr 2013)
New Revision: 787
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/787
Log:
fixes #2253: [CAPTURE] - Esp?\195?\168ces - Le changement de poids des cat?\195?\169gories parentes ?\195?\160 partir d'une cat?\195?\169gorie fille ne fonctionne pas
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -56,8 +56,7 @@
String weightPropertyName,
SampleCategoryEnum sampleCategoryType,
String headerI18nKey,
- String headerTipI18nKey
- ) {
+ String headerTipI18nKey ) {
super(propertyName, headerI18nKey, headerTipI18nKey);
this.weightPropertyName = weightPropertyName;
this.sampleCategoryType = sampleCategoryType;
@@ -70,4 +69,8 @@
public SampleCategoryEnum getSampleCategoryType() {
return sampleCategoryType;
}
+
+ public String getWeightPropertyName() {
+ return weightPropertyName;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -40,6 +40,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -47,6 +48,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
/**
* Represents a species batch (i.e a row in the batch table).
@@ -841,4 +843,28 @@
@Override
public void setFishingOperation(FishingOperation fishingOperation) {
}
+
+ public void collectShell(Set<BenthosBatchRowModel> collectedRows) {
+
+ if (!isBatchLeaf()) {
+
+ for (BenthosBatchRowModel batchChild : getChildBatch()) {
+ collectedRows.add(batchChild);
+ batchChild.collectShell(collectedRows);
+ }
+ }
+ }
+
+ public BenthosBatchRowModel getFirstAncestor( SampleCategory<?> entrySampleCategory) {
+ BenthosBatchRowModel result = this;
+ if (getParentBatch() != null) {
+ BenthosBatchRowModel parentBatch = getParentBatch();
+ SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategory(entrySampleCategory.getCategoryType());
+ if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
+
+ result = parentBatch.getFirstAncestor( entrySampleCategory);
+ }
+ }
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -31,6 +31,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.table.TableColumnModelExt;
import java.util.Set;
@@ -45,40 +47,44 @@
private static final long serialVersionUID = 1L;
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(BenthosBatchTableModel.class);
+
public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editBenthosBatch.table.header.species"),
n_("tutti.editBenthosBatch.table.header.species.tip"));
- public static final ColumnIdentifier<BenthosBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
SampleCategoryEnum.sortedUnsorted,
n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory"),
n_("tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip"));
- public static final ColumnIdentifier<BenthosBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY,
BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
SampleCategoryEnum.size,
n_("tutti.editBenthosBatch.table.header.sizeCategory"),
n_("tutti.editBenthosBatch.table.header.sizeCategory.tip"));
- public static final ColumnIdentifier<BenthosBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SEX_CATEGORY,
BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
SampleCategoryEnum.sex,
n_("tutti.editBenthosBatch.table.header.sexCategory"),
n_("tutti.editBenthosBatch.table.header.sexCategory.tip"));
- public static final ColumnIdentifier<BenthosBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY,
BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
SampleCategoryEnum.maturity,
n_("tutti.editBenthosBatch.table.header.maturityCategory"),
n_("tutti.editBenthosBatch.table.header.maturityCategory.tip"));
- public static final ColumnIdentifier<BenthosBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<BenthosBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_AGE_CATEGORY,
BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
SampleCategoryEnum.age,
@@ -122,7 +128,7 @@
*
* @since 0.2
*/
- protected final Set<ColumnIdentifier<BenthosBatchRowModel>> sampleCols;
+ protected final Set<SampleCategoryColumnIdentifier<BenthosBatchRowModel>> sampleCols;
public BenthosBatchTableModel(TableColumnModelExt columnModel) {
super(columnModel, false, false);
@@ -140,6 +146,17 @@
sampleCols.add(AGE_CATEGORY);
}
+ public SampleCategoryColumnIdentifier<BenthosBatchRowModel> getCategoryIdentifierForWeightProperty(String weightPropertyName) {
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> result = null;
+ for (SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCol : sampleCols) {
+ if (weightPropertyName.equals(sampleCol.getWeightPropertyName())) {
+ result = sampleCol;
+ break;
+ }
+ }
+ return result;
+ }
+
@Override
public BenthosBatchRowModel createNewRow() {
BenthosBatchRowModel result = new BenthosBatchRowModel();
@@ -155,30 +172,48 @@
int columnIndex,
ColumnIdentifier<BenthosBatchRowModel> propertyName,
BenthosBatchRowModel entry) {
+ /*
if (sampleCols.contains(propertyName)) {
((SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName).setWeightValue(entry, aValue);
} else {
super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
}
+ */
+ if (sampleCols.contains(propertyName)) {
-// if (propertyName == COMPUTED_NUMBER) {
-//
-// // update also other columns
-// fireTableCellUpdated(rowIndex, COMPUTED_WEIGHT);
-//
-// } else if (propertyName == COMPUTED_WEIGHT) {
-//
-// // update also other columns
-// fireTableCellUpdated(rowIndex, COMPUTED_NUMBER);
-// }
- }
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCategoryColumnIdentifier = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) propertyName;
+ sampleCategoryColumnIdentifier.setWeightValue(entry, aValue);
- public void updateSamplingRatio(Set<BenthosBatchRowModel> rows) {
-// for (BenthosBatchRowModel row : rows) {
-// int rowIndex = getRows().indexOf(row);
-// fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO);
-// }
+ // must find out first ancestor with this category
+ SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ if (log.isDebugEnabled()) {
+ log.debug("Sample category: " + sampleCategoryType + " modified at row: " + rowIndex);
+ }
+ SampleCategory<?> sampleCategory = entry.getSampleCategory(sampleCategoryType);
+ BenthosBatchRowModel firstAncestor = entry.getFirstAncestor(sampleCategory);
+
+ int firstRowIndex = getRowIndex(firstAncestor);
+ if (log.isDebugEnabled()) {
+ log.debug("First ancestor row: " + firstRowIndex);
+ }
+
+ // must save this row now
+
+ // get shell of the ancestor
+ Set<BenthosBatchRowModel> shell = Sets.newHashSet();
+ firstAncestor.collectShell(shell);
+
+ for (BenthosBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
+ } else {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ }
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -42,6 +42,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI;
@@ -120,6 +121,13 @@
BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
+ public static final Set<String> SAMPLING_WEIGHT_PROPERTIES = Sets.newHashSet(
+ BenthosBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
+
private final EnumMap<TableViewMode, RowFilter<BenthosBatchTableModel, Integer>> tableFilters;
public BenthosBatchUIHandler(TuttiUI<?, ?> parentUi,
@@ -278,8 +286,45 @@
Object oldValue,
Object newValue) {
- if (SAMPLING_PROPERTIES.contains(propertyName)) {
+ if (SAMPLING_WEIGHT_PROPERTIES.contains(propertyName)) {
+ // sampling category weight has changed, must then save the top
+ // ancestor row
+
+ recomputeRowValidState(row);
+
+ BenthosBatchTableModel tableModel = getTableModel();
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleCategoryColumnIdentifier = tableModel.getCategoryIdentifierForWeightProperty(propertyName);
+
+ SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ SampleCategory<?> sampleCategory = row.getSampleCategory(sampleCategoryType);
+ BenthosBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory);
+ int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow);
+ if (rowIndex != firstAncestorIndex) {
+
+ // ancestor is not this row
+ // then only save ancestor
+
+ if (log.isInfoEnabled()) {
+ log.info("Sample category " + sampleCategoryType +
+ " weight was modified, First ancestor row: " +
+ firstAncestorIndex + " will save it");
+ }
+ saveRow(firstAncestorRow);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+
+ cleanrRowMonitor();
+
+ return;
+ }
+
+ // modified sample weight is a leaf
+ // will save it after
+
+ } else if (SAMPLING_PROPERTIES.contains(propertyName)) {
+
// species has changed, recompute valid property
recomputeRowValidState(row);
}
@@ -290,6 +335,25 @@
recomputeBatchActionEnable();
}
+// @Override
+// protected void onRowModified(int rowIndex,
+// BenthosBatchRowModel row,
+// String propertyName,
+// Object oldValue,
+// Object newValue) {
+//
+// if (SAMPLING_PROPERTIES.contains(propertyName)) {
+//
+// // species has changed, recompute valid property
+// recomputeRowValidState(row);
+// }
+//
+// saveSelectedRowIfNeeded();
+//
+// // when row valid state has changed, recompute action enabled states
+// recomputeBatchActionEnable();
+// }
+
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor,
BenthosBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -40,6 +40,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -47,6 +48,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
/**
* Represents a species batch (i.e a row in the batch table).
@@ -800,4 +802,28 @@
this.computedOrNotWeight = computedOrNotWeight;
}
+
+ public void collectShell(Set<SpeciesBatchRowModel> collectedRows) {
+
+ if (!isBatchLeaf()) {
+
+ for (SpeciesBatchRowModel batchChild : getChildBatch()) {
+ collectedRows.add(batchChild);
+ batchChild.collectShell(collectedRows);
+ }
+ }
+ }
+
+ public SpeciesBatchRowModel getFirstAncestor( SampleCategory<?> entrySampleCategory) {
+ SpeciesBatchRowModel result = this;
+ if (getParentBatch() != null) {
+ SpeciesBatchRowModel parentBatch = getParentBatch();
+ SampleCategory<?> parentSampleCategory = parentBatch.getSampleCategory(entrySampleCategory.getCategoryType());
+ if (ObjectUtils.equals(entrySampleCategory, parentSampleCategory)) {
+
+ result = parentBatch.getFirstAncestor( entrySampleCategory);
+ }
+ }
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -31,6 +31,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.table.TableColumnModelExt;
import java.util.Set;
@@ -45,40 +47,44 @@
private static final long serialVersionUID = 1L;
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SpeciesBatchTableModel.class);
+
public static final ColumnIdentifier<SpeciesBatchRowModel> SPECIES = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SPECIES,
n_("tutti.editSpeciesBatch.table.header.species"),
n_("tutti.editSpeciesBatch.table.header.species"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = SampleCategoryColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
SampleCategoryEnum.sortedUnsorted,
n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"),
n_("tutti.editSpeciesBatch.table.header.sortedUnsortedCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = SampleCategoryColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
SampleCategoryEnum.size,
n_("tutti.editSpeciesBatch.table.header.sizeCategory"),
n_("tutti.editSpeciesBatch.table.header.sizeCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = SampleCategoryColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
SampleCategoryEnum.sex,
n_("tutti.editSpeciesBatch.table.header.sexCategory"),
n_("tutti.editSpeciesBatch.table.header.sexCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = SampleCategoryColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
SampleCategoryEnum.maturity,
n_("tutti.editSpeciesBatch.table.header.maturityCategory"),
n_("tutti.editSpeciesBatch.table.header.maturityCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
+ public static final SampleCategoryColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = SampleCategoryColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
SampleCategoryEnum.age,
@@ -122,7 +128,7 @@
*
* @since 0.2
*/
- protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
+ protected final Set<SampleCategoryColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
public SpeciesBatchTableModel(TableColumnModelExt columnModel) {
super(columnModel, false, false);
@@ -140,6 +146,17 @@
sampleCols.add(AGE_CATEGORY);
}
+ public SampleCategoryColumnIdentifier<SpeciesBatchRowModel> getCategoryIdentifierForWeightProperty(String weightPropertyName) {
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> result = null;
+ for (SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleCol : sampleCols) {
+ if (weightPropertyName.equals(sampleCol.getWeightPropertyName())) {
+ result = sampleCol;
+ break;
+ }
+ }
+ return result;
+ }
+
@Override
public SpeciesBatchRowModel createNewRow() {
SpeciesBatchRowModel result = new SpeciesBatchRowModel();
@@ -157,30 +174,54 @@
SpeciesBatchRowModel entry) {
if (sampleCols.contains(propertyName)) {
- ((SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue);
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleCategoryColumnIdentifier = (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName;
+ sampleCategoryColumnIdentifier.setWeightValue(entry, aValue);
+
+ // must find out first ancestor with this category
+ SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ if (log.isDebugEnabled()) {
+ log.debug("Sample category: " + sampleCategoryType + " modified at row: " + rowIndex);
+ }
+ SampleCategory<?> sampleCategory = entry.getSampleCategory(sampleCategoryType);
+ SpeciesBatchRowModel firstAncestor = entry.getFirstAncestor(sampleCategory);
+
+ int firstRowIndex = getRowIndex(firstAncestor);
+ if (log.isDebugEnabled()) {
+ log.debug("First ancestor row: " + firstRowIndex);
+ }
+
+ // must save this row now
+
+ // get shell of the ancestor
+ Set<SpeciesBatchRowModel> shell = Sets.newHashSet();
+ firstAncestor.collectShell(shell);
+
+ for (SpeciesBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
} else {
super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
}
+ }
-// if (propertyName == COMPUTED_NUMBER) {
+// @Override
+// public void setValueAt(Object aValue,
+// int rowIndex,
+// int columnIndex,
+// ColumnIdentifier<SpeciesBatchRowModel> propertyName,
+// SpeciesBatchRowModel entry) {
+// if (sampleCols.contains(propertyName)) {
//
-// // update also other columns
-// fireTableCellUpdated(rowIndex, COMPUTED_WEIGHT);
-//
-// } else if (propertyName == COMPUTED_WEIGHT) {
-//
-// // update also other columns
-// fireTableCellUpdated(rowIndex, COMPUTED_NUMBER);
+// ((SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) propertyName).setWeightValue(entry, aValue);
+// } else {
+// super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
// }
- }
+// }
- public void updateSamplingRatio(Set<SpeciesBatchRowModel> rows) {
-// for (SpeciesBatchRowModel row : rows) {
-// int rowIndex = getRows().indexOf(row);
-// fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO);
-// }
- }
-
@Override
protected boolean isCellEditable(int rowIndex,
int columnIndex,
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -45,6 +45,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryColumnIdentifier;
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI;
@@ -122,6 +123,13 @@
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
+ public static final Set<String> SAMPLING_WEIGHT_PROPERTIES = Sets.newHashSet(
+ SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT);
+
private final EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>> tableFilters;
public SpeciesBatchUIHandler(TuttiUI<?, ?> parentUi,
@@ -302,8 +310,45 @@
Object oldValue,
Object newValue) {
- if (SAMPLING_PROPERTIES.contains(propertyName)) {
+ if (SAMPLING_WEIGHT_PROPERTIES.contains(propertyName)) {
+ // sampling category weight has changed, must then save the top
+ // ancestor row
+
+ recomputeRowValidState(row);
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleCategoryColumnIdentifier = tableModel.getCategoryIdentifierForWeightProperty(propertyName);
+
+ SampleCategoryEnum sampleCategoryType = sampleCategoryColumnIdentifier.getSampleCategoryType();
+ SampleCategory<?> sampleCategory = row.getSampleCategory(sampleCategoryType);
+ SpeciesBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategory);
+ int firstAncestorIndex = tableModel.getRowIndex(firstAncestorRow);
+ if (rowIndex != firstAncestorIndex) {
+
+ // ancestor is not this row
+ // then only save ancestor
+
+ if (log.isInfoEnabled()) {
+ log.info("Sample category " + sampleCategoryType +
+ " weight was modified, First ancestor row: " +
+ firstAncestorIndex + " will save it");
+ }
+ saveRow(firstAncestorRow);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+
+ cleanrRowMonitor();
+
+ return;
+ }
+
+ // modified sample weight is a leaf
+ // will save it after
+
+ } else if (SAMPLING_PROPERTIES.contains(propertyName)) {
+
// species has changed, recompute valid property
recomputeRowValidState(row);
}
@@ -314,6 +359,25 @@
recomputeBatchActionEnable();
}
+// @Override
+// protected void onRowModified(int rowIndex,
+// SpeciesBatchRowModel row,
+// String propertyName,
+// Object oldValue,
+// Object newValue) {
+//
+// if (SAMPLING_PROPERTIES.contains(propertyName)) {
+//
+// // species has changed, recompute valid property
+// recomputeRowValidState(row);
+// }
+//
+// saveSelectedRowIfNeeded();
+//
+// // when row valid state has changed, recompute action enabled states
+// recomputeBatchActionEnable();
+// }
+
@Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
SpeciesBatchRowModel row) {
@@ -339,7 +403,7 @@
}
} else {
- //FIXME See how to delete rows ? Or moreover how to save tehem...
+ //FIXME See how to delete rows ? Or moreover how to save them...
if (log.isWarnEnabled()) {
log.warn("Will not remove not valid speciesBatch: " + row.getId());
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-15 23:10:19 UTC (rev 786)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-04-15 23:10:49 UTC (rev 787)
@@ -510,6 +510,11 @@
}
}
+
+ protected void cleanrRowMonitor() {
+ rowMonitor.clearModified();
+ }
+
protected final void recomputeRowValidState(R row) {
// recompute row valid state
1
0
r786 - in trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service: . batch
by tchemit@users.forge.codelutin.com 15 Apr '13
by tchemit@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: tchemit
Date: 2013-04-16 01:10:19 +0200 (Tue, 16 Apr 2013)
New Revision: 786
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/786
Log:
fixes #2293: [BENTHOS] Erreur lors de la cr?\195?\169ation de lots
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 20:48:35 UTC (rev 785)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 23:10:19 UTC (rev 786)
@@ -233,22 +233,28 @@
@Override
public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId) {
+ Preconditions.checkNotNull(benthosBatchId);
+
+// List<BenthosBatchFrequency> results = Lists.newArrayList();
+//
+// Integer sortingBatchId = Integer.valueOf(benthosBatchId);
+// Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
+// Preconditions.checkNotNull(
+// catchBatchId,
+// "Could not find catchBatch for benthosBatch: " + benthosBatchId);
+//
+// CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+//
+// SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+// catchBatch, sortingBatchId);
+//
+// List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(sortingBatch);
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(benthosBatchId);
List<BenthosBatchFrequency> results = Lists.newArrayList();
-
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(Integer.valueOf(benthosBatchId));
- if (catchBatchId == null) {
- return results;
- }
-
- CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
-
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(benthosBatchId));
-
- for (Batch batch : sortingBatch.getChildBatchs()) {
- SortingBatch source = (SortingBatch) batch;
+ for (SortingBatch child : frequencyChilds) {
BenthosBatchFrequency target = TuttiBeanFactory.newBenthosBatchFrequency();
- entityToBenthosBatchFrequency(source, target);
+ entityToBenthosBatchFrequency(child, target);
results.add(target);
}
return Collections.unmodifiableList(results);
@@ -286,10 +292,14 @@
// Remember child ids, to remove unchanged item (see at bottom in this method)
List<Integer> notUpdatedChildIds = Lists.newArrayList();
- for (Batch batch : parentBatch.getChildBatchs()) {
- SortingBatch sortingBatch = (SortingBatch) batch;
- notUpdatedChildIds.add(sortingBatch.getId());
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(parentBatch);
+ for (SortingBatch child : frequencyChilds) {
+ notUpdatedChildIds.add(child.getId());
}
+// for (Batch batch : parentBatch.getChildBatchs()) {
+// SortingBatch sortingBatch = (SortingBatch) batch;
+// notUpdatedChildIds.add(sortingBatch.getId());
+// }
short rankOrder = 0;
List<SortingBatch> batchsToUpdate = Lists.newArrayList();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 20:48:35 UTC (rev 785)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 23:10:19 UTC (rev 786)
@@ -279,21 +279,22 @@
String speciesBatchId) {
Preconditions.checkNotNull(speciesBatchId);
+// List<SpeciesBatchFrequency> results = Lists.newArrayList();
+//
+// Integer sortingBatchId = Integer.valueOf(speciesBatchId);
+// Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
+// Preconditions.checkNotNull(
+// catchBatchId,
+// "Could not find catchBatch for speciesBatch: " + speciesBatchId);
+//
+// CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+//
+// SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+// catchBatch, sortingBatchId);
+//
+// List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(sortingBatch);
+ List<SortingBatch> frequencyChilds = batchHelper.getFrequencies(speciesBatchId);
List<SpeciesBatchFrequency> results = Lists.newArrayList();
-
- Integer sortingBatchId = Integer.valueOf(speciesBatchId);
- Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
- Preconditions.checkNotNull(
- catchBatchId,
- "Could not find catchBatch for speciesBatch: " + speciesBatchId);
-
- CatchBatch catchBatch =
- catchBatchDao.loadFullTree(catchBatchId);
-
- SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
- catchBatch, sortingBatchId);
-
- List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(sortingBatch);
for (SortingBatch child : frequencyChilds) {
SpeciesBatchFrequency target = TuttiBeanFactory.newSpeciesBatchFrequency();
@@ -421,7 +422,6 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
-
protected SpeciesBatch entityToSpeciesBatch(SortingBatch source,
SpeciesBatch target) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 20:48:35 UTC (rev 785)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 23:10:19 UTC (rev 786)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.adagio.core.dao.data.batch.Batch;
+import fr.ifremer.adagio.core.dao.data.batch.CatchBatch;
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.measure.Measurement;
@@ -40,8 +41,6 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.service.AbstractPersistenceService;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
@@ -59,9 +58,9 @@
@Component("batchPersistenceHelper")
public class BatchPersistenceHelper extends AbstractPersistenceService {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(BatchPersistenceHelper.class);
+// /** Logger. */
+// private static final Log log =
+// LogFactory.getLog(BatchPersistenceHelper.class);
public static final String BATCH_PMFM_ID = "pmfmId";
@@ -83,16 +82,33 @@
return result;
}
- public List<SortingBatch> getNotFrequencyChilds(SortingBatch sortingBatch) {
- List<SortingBatch> result = Lists.newArrayList();
+// public List<SortingBatch> getNotFrequencyChilds(SortingBatch sortingBatch) {
+// List<SortingBatch> result = Lists.newArrayList();
+//
+// for (Batch batch : sortingBatch.getChildBatchs()) {
+// SortingBatch child = (SortingBatch) batch;
+// if (isFrequencyBatch(child)) {
+// result.add(child);
+// }
+// }
+// return result;
+// }
- for (Batch batch : sortingBatch.getChildBatchs()) {
- SortingBatch child = (SortingBatch) batch;
- if (isFrequencyBatch(child)) {
- result.add(child);
- }
- }
- return result;
+ public List<SortingBatch> getFrequencies(String batchId) {
+ Preconditions.checkNotNull(batchId);
+ Integer sortingBatchId = Integer.valueOf(batchId);
+ Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(sortingBatchId);
+ Preconditions.checkNotNull(
+ catchBatchId,
+ "Could not find catchBatch for batch: " + batchId);
+
+ CatchBatch catchBatch = catchBatchDao.loadFullTree(catchBatchId);
+
+ SortingBatch sortingBatch = catchBatchDao.getSortingBatchById(
+ catchBatch, sortingBatchId);
+
+ List<SortingBatch> frequencyChilds = getFrequencyChilds(sortingBatch);
+ return frequencyChilds;
}
/**
1
0
r785 - in trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service: . batch
by tchemit@users.forge.codelutin.com 15 Apr '13
by tchemit@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: tchemit
Date: 2013-04-15 22:48:35 +0200 (Mon, 15 Apr 2013)
New Revision: 785
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/785
Log:
clean some codes
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 20:31:51 UTC (rev 784)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 20:48:35 UTC (rev 785)
@@ -43,8 +43,6 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.logging.Log;
@@ -55,7 +53,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
-import java.text.MessageFormat;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -575,52 +573,6 @@
}
}
-// protected void setBatchParents(BenthosBatch source,
-// SortingBatch target,
-// String parentBatchIdStr,
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
-// Integer batchPmfmId) {
-//
-// Preconditions.checkNotNull(target);
-// Preconditions.checkNotNull(source.getFishingOperation());
-// Preconditions.checkNotNull(source.getFishingOperation().getId());
-//
-// SortingBatch parentBatch;
-// if (parentBatchIdStr != null) {
-//
-// // Load existing parent and root
-// parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
-// } else {
-//
-// // Or retrieve parent batch, from pmfm id
-// // Retrieve category type
-// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
-// if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
-// throw new DataIntegrityViolationException(MessageFormat.format(
-// "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
-// SampleCategoryEnum.sortedUnsorted.name(),
-// enumeration.PMFM_ID_SORTED_UNSORTED));
-// }
-// Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-//
-// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
-// BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
-// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
-// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
-// );
-// }
-//
-//
-// if (parentBatch == null) {
-// throw new DataIntegrityViolationException(
-// "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a BenthosBatch.");
-// }
-//
-// // Parent Batch
-// target.setParentBatch(parentBatch);
-// target.setRootBatch(catchBatch);
-// }
-
protected void benthosBatchFrequencyToEntity(BenthosBatchFrequency source,
SortingBatch target,
SortingBatch parentBatch,
@@ -711,26 +663,32 @@
Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
target.setSampleCategoryType(sampleCategory);
- if (numericalvalue != null) {
- target.setSampleCategoryValue(numericalvalue);
- return;
- }
- if (alphanumericalValue != null) {
- target.setSampleCategoryValue(alphanumericalValue);
- return;
- }
-
- Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
- if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
- return;
- }
- CaracteristicQualitativeValue value = null;
- for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
- if (qualitativeValueId.equals(qv.getIdAsInt())) {
- value = qv;
- break;
- }
- }
- target.setSampleCategoryValue(value);
+ Serializable categoryValue = batchHelper.getSampleCategoryQualitative(
+ pmfmId,
+ numericalvalue,
+ alphanumericalValue,
+ qualitativeValueId);
+ target.setSampleCategoryValue(categoryValue);
+// if (numericalvalue != null) {
+// target.setSampleCategoryValue(numericalvalue);
+// return;
+// }
+// if (alphanumericalValue != null) {
+// target.setSampleCategoryValue(alphanumericalValue);
+// return;
+// }
+//
+// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
+// return;
+// }
+// CaracteristicQualitativeValue value = null;
+// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
+// if (qualitativeValueId.equals(qv.getIdAsInt())) {
+// value = qv;
+// break;
+// }
+// }
+// target.setSampleCategoryValue(value);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 20:31:51 UTC (rev 784)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 20:48:35 UTC (rev 785)
@@ -43,8 +43,6 @@
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper;
import org.apache.commons.collections.CollectionUtils;
@@ -56,7 +54,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
-import java.text.MessageFormat;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -655,52 +653,6 @@
}
}
-// protected void setBatchParents(SpeciesBatch source,
-// SortingBatch target,
-// String parentBatchIdStr,
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
-// Integer batchPmfmId) {
-//
-// Preconditions.checkNotNull(target);
-// Preconditions.checkNotNull(source.getFishingOperation());
-// Preconditions.checkNotNull(source.getFishingOperation().getId());
-//
-// SortingBatch parentBatch;
-// if (parentBatchIdStr != null) {
-//
-// // Load existing parent and root
-// parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
-// } else {
-//
-// // Or retrieve parent batch, from pmfm id
-// // Retrieve category type
-// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
-// if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
-// throw new DataIntegrityViolationException(MessageFormat.format(
-// "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
-// SampleCategoryEnum.sortedUnsorted.name(),
-// enumeration.PMFM_ID_SORTED_UNSORTED));
-// }
-// Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-//
-// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
-// BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
-// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
-// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
-// );
-// }
-//
-//
-// if (parentBatch == null) {
-// throw new DataIntegrityViolationException(
-// "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
-// }
-//
-// // Parent Batch
-// target.setParentBatch(parentBatch);
-// target.setRootBatch(catchBatch);
-// }
-
protected void speciesBatchFrequencyToEntity(SpeciesBatchFrequency source,
SortingBatch target,
SortingBatch parentBatch,
@@ -791,27 +743,33 @@
Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
target.setSampleCategoryType(sampleCategory);
- if (numericalvalue != null) {
- target.setSampleCategoryValue(numericalvalue);
- return;
- }
- if (alphanumericalValue != null) {
- target.setSampleCategoryValue(alphanumericalValue);
- return;
- }
-
- Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
- if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
- return;
- }
- CaracteristicQualitativeValue value = null;
- for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
- if (qualitativeValueId.equals(qv.getIdAsInt())) {
- value = qv;
- break;
- }
- }
- target.setSampleCategoryValue(value);
+ Serializable categoryValue = batchHelper.getSampleCategoryQualitative(
+ pmfmId,
+ numericalvalue,
+ alphanumericalValue,
+ qualitativeValueId);
+ target.setSampleCategoryValue(categoryValue);
+// if (numericalvalue != null) {
+// target.setSampleCategoryValue(numericalvalue);
+// return;
+// }
+// if (alphanumericalValue != null) {
+// target.setSampleCategoryValue(alphanumericalValue);
+// return;
+// }
+//
+// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
+// return;
+// }
+// CaracteristicQualitativeValue value = null;
+// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
+// if (qualitativeValueId.equals(qv.getIdAsInt())) {
+// value = qv;
+// break;
+// }
+// }
+// target.setSampleCategoryValue(value);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 20:31:51 UTC (rev 784)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 20:48:35 UTC (rev 785)
@@ -142,7 +142,7 @@
// Retrieve category type
if (!sampleCategoryType.equals(SampleCategoryEnum.sortedUnsorted)) {
throw new DataIntegrityViolationException(MessageFormat.format(
- "A benthos batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
+ "A species or benthos batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
SampleCategoryEnum.sortedUnsorted.name(),
enumeration.PMFM_ID_SORTED_UNSORTED));
}
@@ -182,347 +182,6 @@
target.setRootBatch(catchBatch);
}
-// public SpeciesBatch entityToSpeciesBatch(SortingBatch source,
-// SpeciesBatch target) {
-//
-// target.setId(source.getId().toString());
-//
-// // Individual count
-// target.setNumber(source.getIndividualCount());
-//
-// // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight
-// if (source.getWeight() != null && source.getWeightBeforeSampling() == null) {
-// target.setSampleCategoryWeight(source.getWeight());
-// } else {
-// target.setWeight(source.getWeight());
-// target.setSampleCategoryWeight(source.getWeightBeforeSampling());
-// }
-//
-// // Comments
-// target.setComment(source.getComments());
-//
-// // Sample category type (only one is applied)
-// SortingMeasurement sm = null;
-// if (source.getSortingMeasurements().size() == 1) {
-// sm = source.getSortingMeasurements().iterator().next();
-// } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) {
-// sm = catchBatchDao.getInheritedSortingMeasurement(source, enumeration.PMFM_ID_SORTED_UNSORTED);
-// }
-// if (sm != null) {
-// SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(sm.getPmfm().getId());
-// if (sampleCategory != null) {
-// Integer qualitativeId = null;
-// if (sm.getQualitativeValue() != null) {
-// qualitativeId = sm.getQualitativeValue().getId();
-// }
-// setSampleCategoryQualitative(target, sm.getPmfm().getId(), sm.getNumericalValue(), sm.getAlphanumericalValue(), qualitativeId);
-// }
-// }
-//
-// // Species
-// Integer referenceTaxonId = source.getInheritedReferenceTaxonId();
-// if (referenceTaxonId == null && source.getReferenceTaxon() != null) {
-// referenceTaxonId = source.getReferenceTaxon().getId();
-// }
-// if (referenceTaxonId != null) {
-// // TODO : add cache on getSpeciesByReferenceTaxonId
-// Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId);
-// target.setSpecies(species);
-// }
-// //FIXME-TC Check the test is still ok?
-// //FIXME-TC We should a stronger test
-//// if (target.getSampleCategoryType() != null && source.getChildBatchs().size() > 0) {
-// if (target.getSampleCategoryType() != null) {
-// List<SpeciesBatch> targetChilds = Lists.newArrayList();
-// for (Batch batch : source.getChildBatchs()) {
-// SortingBatch sourceChild = (SortingBatch) batch;
-// SpeciesBatch targetChild = TuttiBeanFactory.newSpeciesBatch();
-// entityToSpeciesBatch(sourceChild, targetChild);
-// if (log.isInfoEnabled()) {
-// log.info("Loaded CatchBatch Hors Vrac > (Species|Benthos) > " + target.getSpecies().getReferenceTaxonId() + " : " + target.getId());
-// }
-// if (targetChild.getSampleCategoryValue() != null) {
-// targetChilds.add(targetChild);
-// targetChild.setParentBatch(target);
-// }
-// }
-// target.setChildBatchs(targetChilds);
-// }
-//
-// QualityFlag qualityFlag = source.getQualityFlag();
-// target.setSpeciesToConfirm(qualityFlag != null && enumeration.QUALITY_FLAG_CODE_DOUBTFUL.equals(qualityFlag.getCode()));
-//
-// return target;
-// }
-//
-// public void entityToSpeciesBatchFrequency(SortingBatch source,
-// SpeciesBatchFrequency target) {
-//
-// target.setId(source.getId());
-//
-// target.setNumber(source.getIndividualCount());
-// target.setWeight(source.getWeight());
-//
-// Preconditions.checkState(source.getSortingMeasurements().size() == 1, "SortingBatch [" + source.getId() + "] need exactly one sortingMeasurement (to store the length step category), but had " + source.getSortingMeasurements().size());
-// SortingMeasurement sm = source.getSortingMeasurements().iterator().next();
-// Preconditions.checkNotNull(sm.getPmfm(), "SortingMeasurement [" + sm.getId() + "] can not have a null pmfm");
-// Preconditions.checkNotNull(sm.getPmfm().getId(), "SortingMeasurement [" + sm.getId() + "] can not have a pmfm with null id");
-//
-// // Length step category
-// Caracteristic lengthStepCaracteristic =
-// referentialService.getCaracteristic(sm.getPmfm().getId());
-// target.setLengthStepCaracteristic(lengthStepCaracteristic);
-//
-// // Length
-// target.setLengthStep(sm.getNumericalValue());
-// }
-//
-// public void speciesBatchToEntity(SpeciesBatch source,
-// SortingBatch target,
-// String parentBatchId,
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
-// Integer batchPmfm) {
-//
-// Preconditions.checkNotNull(source.getFishingOperation());
-// Preconditions.checkNotNull(source.getFishingOperation().getId());
-//
-// // Retrieve recorder department
-// Integer recorderDepartmentId = getRecorderDepartmentId();
-//
-// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
-// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-//
-// // Create lists to store all updates, then remove not updated items
-//
-// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
-// if (quantificationMeasurements != null) {
-// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
-// }
-// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
-// if (sortingMeasurements != null) {
-// notChangedSortingMeasurements.addAll(sortingMeasurements);
-// }
-//
-// // If parent and root need to be set
-// if (target.getId() == null
-// || target.getRootBatch() == null
-// || (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
-// setBatchParents(source, target, parentBatchId, catchBatch, batchPmfm);
-// }
-//
-// // RankOrder (initialize once, at creation)
-// if (target.getRankOrder() == null) {
-// // Start rank order at 1
-// short rankOrder = (short) 1;
-// if (source.getParentBatch() != null && source.getParentBatch().getChildBatchs() != null) {
-// rankOrder += (short) source.getParentBatch().getChildBatchs().size();
-// } else if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null) {
-// rankOrder += (short) target.getParentBatch().getChildBatchs().size();
-// }
-// target.setRankOrder(rankOrder);
-// }
-//
-// // Force subgroup count to '1', as Allegro
-// target.setSubgroupCount(1f);
-//
-// // Weight or SampleCategoryWeight
-// if (source.getWeight() == null && source.getSampleCategoryWeight() == null) {
-// // Nothing to do : will be removed later, using notChangedSortingMeasurements
-// } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// }
-//
-// // Sampling Ratio
-// if (source.getSampleCategoryWeight() == null || source.getWeight() == null) {
-// target.setSamplingRatio(null);
-// target.setSamplingRatioText(null);
-// } else {
-// String samplingRatioText = source.getWeight() + "/" + source.getSampleCategoryWeight();
-// samplingRatioText = samplingRatioText.replaceAll(",", ".");
-// target.setSamplingRatioText(samplingRatioText);
-// target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// }
-//
-// // Sorting measurement
-// if ((source.getSampleCategoryType() == null || source.getSampleCategoryValue() == null)) {
-// // Nothing to do : will be removed later, using notChangedSortingMeasurements
-// } else {
-// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
-// // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch)
-// if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
-// SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId,
-// source.getSampleCategoryType(), source.getSampleCategoryValue());
-// notChangedSortingMeasurements.remove(sortingMeasurement);
-// }
-// }
-//
-// // Individual count
-// target.setIndividualCount(source.getNumber());
-//
-// // Species
-// ReferenceTaxon referenceTaxon;
-// if (source.getSpecies() == null || parentBatchId != null) {
-// referenceTaxon = null;
-// } else {
-// referenceTaxon = load(ReferenceTaxonImpl.class, source.getSpecies().getReferenceTaxonId());
-// }
-// target.setReferenceTaxon(referenceTaxon);
-//
-// // QualityFlag
-// String qualityFlag;
-// if (source.isSpeciesToConfirm()) {
-// qualityFlag = enumeration.QUALITY_FLAG_CODE_DOUBTFUL;
-// } else {
-// qualityFlag = enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED;
-// }
-// target.setQualityFlag(load(QualityFlagImpl.class, qualityFlag));
-//
-// // Comments
-// target.setComments(source.getComment());
-//
-// // Exhaustive inventory (always true under a species batch)
-// target.setExhaustiveInventory(true);
-//
-// // Removed not changed measurements (in sorting and quantification measurement lists)
-// if (quantificationMeasurements != null) {
-// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
-// }
-// if (sortingMeasurements != null) {
-// sortingMeasurements.removeAll(notChangedSortingMeasurements);
-// }
-// }
-
-// protected void setBatchParents(SpeciesBatch source,
-// SortingBatch target,
-// String parentBatchIdStr,
-// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
-// Integer batchPmfmId) {
-//
-// Preconditions.checkNotNull(target);
-// Preconditions.checkNotNull(source.getFishingOperation());
-// Preconditions.checkNotNull(source.getFishingOperation().getId());
-//
-// SortingBatch parentBatch;
-// if (parentBatchIdStr != null) {
-//
-// // Load existing parent and root
-// parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
-// } else {
-//
-// // Or retrieve parent batch, from pmfm id
-// // Retrieve category type
-// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
-// if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
-// throw new DataIntegrityViolationException(MessageFormat.format(
-// "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
-// SampleCategoryEnum.sortedUnsorted.name(),
-// enumeration.PMFM_ID_SORTED_UNSORTED));
-// }
-// Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-//
-// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
-// BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
-// BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
-// BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
-// );
-// }
-//
-//
-// if (parentBatch == null) {
-// throw new DataIntegrityViolationException(
-// "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
-// }
-//
-// // Parent Batch
-// target.setParentBatch(parentBatch);
-// target.setRootBatch(catchBatch);
-// }
-//
-// public void speciesBatchFrequencyToEntity(SpeciesBatchFrequency source,
-// SortingBatch target,
-// SortingBatch parentBatch,
-// short rankOrder) {
-// Preconditions.checkNotNull(source.getBatch());
-// Preconditions.checkNotNull(source.getBatch().getId());
-//
-// // Retrieve recorder department
-// Integer recorderDepartmentId = getRecorderDepartmentId();
-//
-// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements();
-// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements();
-//
-// // Create lists to store all updates, then remove not updated items
-// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet();
-// if (quantificationMeasurements != null) {
-// notChangedQuantificationMeasurements.addAll(quantificationMeasurements);
-// }
-// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet();
-// if (sortingMeasurements != null) {
-// notChangedSortingMeasurements.addAll(sortingMeasurements);
-// }
-//
-// // If parent and root need to be set
-// if (target.getId() == null
-// || target.getRootBatch() == null
-// || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) {
-//
-// target.setParentBatch(parentBatch);
-// target.setRootBatch(parentBatch.getRootBatch());
-// }
-//
-// // RankOrder
-// target.setRankOrder(rankOrder);
-//
-// // Weight or SampleCategoryWeight
-// if (source.getWeight() == null) {
-// // Nothing to do : will be removed later, using notChangedSortingMeasurements
-// } else {
-// QuantificationMeasurement quantificationMeasurement = catchBatchDao.setQuantificationMeasurement(
-// target,
-// enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
-// notChangedQuantificationMeasurements.remove(quantificationMeasurement);
-// }
-//
-// // Sorting measurement
-// if ((source.getLengthStepCaracteristic() == null || source.getLengthStep() == null)) {
-// // Nothing to do : will be removed later, using notChangedSortingMeasurements
-// } else {
-// Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt();
-// SortingMeasurement sortingMeasurement = setSortingMeasurement(target, recorderDepartmentId, pmfmId,
-// source.getLengthStep());
-// notChangedSortingMeasurements.remove(sortingMeasurement);
-// }
-//
-// // Individual count
-// target.setIndividualCount(source.getNumber());
-//
-// // Species
-// target.setReferenceTaxon(null);
-//
-// // QualityFlag
-// target.setQualityFlag(parentBatch.getQualityFlag());
-//
-// // Exhaustive inventory (always true under a species batch)
-// target.setExhaustiveInventory(true);
-//
-// // Removed not changed measurements (in sorting and quantification measurement lists)
-// if (quantificationMeasurements != null) {
-// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements);
-// }
-// if (sortingMeasurements != null) {
-// sortingMeasurements.removeAll(notChangedSortingMeasurements);
-// }
-// }
-
public Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) {
if (value == null)
return null;
@@ -536,43 +195,6 @@
return qualitativeValueId;
}
-// public void setSampleCategoryQualitative(SpeciesBatch target,
-// Integer pmfmId,
-// Float numericalvalue,
-// String alphanumericalValue,
-// Integer qualitativeValueId) {
-// // skip if null or corresponding to the SORTING_TYPE PMFM (Espèce, Benthos, Plancton, etc.)
-// if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) {
-// return;
-// }
-//
-// SampleCategoryEnum sampleCategory = enumeration.getSampleCategoryByPmfmId(pmfmId);
-// Preconditions.checkNotNull(sampleCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId);
-//
-// target.setSampleCategoryType(sampleCategory);
-// if (numericalvalue != null) {
-// target.setSampleCategoryValue(numericalvalue);
-// return;
-// }
-// if (alphanumericalValue != null) {
-// target.setSampleCategoryValue(alphanumericalValue);
-// return;
-// }
-//
-// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
-// if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
-// return;
-// }
-// CaracteristicQualitativeValue value = null;
-// for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
-// if (qualitativeValueId.equals(qv.getIdAsInt())) {
-// value = qv;
-// break;
-// }
-// }
-// target.setSampleCategoryValue(value);
-// }
-
public Integer getRecorderDepartmentId() {
// TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?)
return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
@@ -632,4 +254,31 @@
setMeasurement(sortingMeasurement, caracteristic, value);
return sortingMeasurement;
}
+
+ public Serializable getSampleCategoryQualitative(Integer pmfmId,
+ Float numericalvalue,
+ String alphanumericalValue,
+ Integer qualitativeValueId) {
+
+ if (numericalvalue != null) {
+ return numericalvalue;
+ }
+ if (alphanumericalValue != null) {
+ return alphanumericalValue;
+ }
+
+ Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
+ if (caracteristic == null || caracteristic.getCaracteristicType() != CaracteristicType.QUALITATIVE) {
+ return null;
+ }
+ CaracteristicQualitativeValue value = null;
+ for (CaracteristicQualitativeValue qv : caracteristic.getQualitativeValue()) {
+ if (qualitativeValueId.equals(qv.getIdAsInt())) {
+ value = qv;
+ break;
+ }
+ }
+
+ return value;
+ }
}
1
0
r784 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos
by tchemit@users.forge.codelutin.com 15 Apr '13
by tchemit@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: tchemit
Date: 2013-04-15 22:31:51 +0200 (Mon, 15 Apr 2013)
New Revision: 784
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/784
Log:
fixes #2269: [BENTHOS] - Erreur ?\195?\160 la cr?\195?\169ation d'un lot
fixes #2270: [BENTHOS] - Suite de l'erreur pr?\195?\169c?\195?\169dente vf pi?\195?\168ce jointe, il a cr?\195?\169er 2 lots jumeaux
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 20:27:37 UTC (rev 783)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-15 20:31:51 UTC (rev 784)
@@ -449,13 +449,11 @@
protected void benthosBatchToEntity(BenthosBatch source,
SortingBatch target,
String parentBatchId,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) {
+ CatchBatch catchBatch) {
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- Integer batchPmfm = enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS;
-
// Retrieve recorder department
Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
@@ -477,7 +475,13 @@
if (target.getId() == null
|| target.getRootBatch() == null
|| (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
- setBatchParents(source, target, parentBatchId, catchBatch, batchPmfm);
+ batchHelper.setBatchParents(
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue(),
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
}
// RankOrder (initialize once, at creation)
@@ -571,52 +575,52 @@
}
}
- protected void setBatchParents(BenthosBatch source,
- SortingBatch target,
- String parentBatchIdStr,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
- Integer batchPmfmId) {
+// protected void setBatchParents(BenthosBatch source,
+// SortingBatch target,
+// String parentBatchIdStr,
+// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+// Integer batchPmfmId) {
+//
+// Preconditions.checkNotNull(target);
+// Preconditions.checkNotNull(source.getFishingOperation());
+// Preconditions.checkNotNull(source.getFishingOperation().getId());
+//
+// SortingBatch parentBatch;
+// if (parentBatchIdStr != null) {
+//
+// // Load existing parent and root
+// parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
+// } else {
+//
+// // Or retrieve parent batch, from pmfm id
+// // Retrieve category type
+// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
+// if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
+// throw new DataIntegrityViolationException(MessageFormat.format(
+// "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
+// SampleCategoryEnum.sortedUnsorted.name(),
+// enumeration.PMFM_ID_SORTED_UNSORTED));
+// }
+// Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
+//
+// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+// BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
+// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
+// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+// );
+// }
+//
+//
+// if (parentBatch == null) {
+// throw new DataIntegrityViolationException(
+// "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a BenthosBatch.");
+// }
+//
+// // Parent Batch
+// target.setParentBatch(parentBatch);
+// target.setRootBatch(catchBatch);
+// }
- Preconditions.checkNotNull(target);
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
-
- SortingBatch parentBatch;
- if (parentBatchIdStr != null) {
-
- // Load existing parent and root
- parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
- } else {
-
- // Or retrieve parent batch, from pmfm id
- // Retrieve category type
- Integer pmfmId = source.getSampleCategoryType().getFieldValue();
- if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- throw new DataIntegrityViolationException(MessageFormat.format(
- "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
- SampleCategoryEnum.sortedUnsorted.name(),
- enumeration.PMFM_ID_SORTED_UNSORTED));
- }
- Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
- );
- }
-
-
- if (parentBatch == null) {
- throw new DataIntegrityViolationException(
- "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a BenthosBatch.");
- }
-
- // Parent Batch
- target.setParentBatch(parentBatch);
- target.setRootBatch(catchBatch);
- }
-
protected void benthosBatchFrequencyToEntity(BenthosBatchFrequency source,
SortingBatch target,
SortingBatch parentBatch,
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-15 20:27:37 UTC (rev 783)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-04-15 20:31:51 UTC (rev 784)
@@ -610,7 +610,7 @@
{
Map<Integer, SortingBatch> batchChilds = getChildsMap(batch, enumeration.PMFM_ID_SORTING_TYPE);
-
+ batch.setChildBatchs(Lists.<Batch>newArrayList());
// -----------------------------------------------------------------------------
// Hors Vrac > Species
// -----------------------------------------------------------------------------
@@ -618,11 +618,12 @@
SortingBatch speciesBatch = batchChilds.get(enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
if (speciesBatch == null) {
speciesBatch = SortingBatch.Factory.newInstance();
- if (batch.getChildBatchs() == null) {
- batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
- } else {
- batch.getChildBatchs().add(speciesBatch);
- }
+ batch.getChildBatchs().add(speciesBatch);
+// if (batch.getChildBatchs() == null) {
+// batch.setChildBatchs(Lists.newArrayList((Batch) speciesBatch));
+// } else {
+// batch.getChildBatchs().add(speciesBatch);
+// }
}
beanToEntitySortingBatch(target,
batch,
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 20:27:37 UTC (rev 783)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-15 20:31:51 UTC (rev 784)
@@ -533,8 +533,6 @@
Preconditions.checkNotNull(source.getFishingOperation());
Preconditions.checkNotNull(source.getFishingOperation().getId());
- Integer batchPmfm = enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES;
-
// Retrieve recorder department
Integer recorderDepartmentId = batchHelper.getRecorderDepartmentId();
@@ -556,7 +554,14 @@
if (target.getId() == null
|| target.getRootBatch() == null
|| (target.getParentBatch() != null && !target.getParentBatch().getId().toString().equals(parentBatchId))) {
- setBatchParents(source, target, parentBatchId, catchBatch, batchPmfm);
+
+ batchHelper.setBatchParents(
+ source.getSampleCategoryType(),
+ source.getSampleCategoryValue(),
+ target,
+ parentBatchId,
+ catchBatch,
+ enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES);
}
// RankOrder (initialize once, at creation)
@@ -650,52 +655,52 @@
}
}
- protected void setBatchParents(SpeciesBatch source,
- SortingBatch target,
- String parentBatchIdStr,
- fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
- Integer batchPmfmId) {
+// protected void setBatchParents(SpeciesBatch source,
+// SortingBatch target,
+// String parentBatchIdStr,
+// fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+// Integer batchPmfmId) {
+//
+// Preconditions.checkNotNull(target);
+// Preconditions.checkNotNull(source.getFishingOperation());
+// Preconditions.checkNotNull(source.getFishingOperation().getId());
+//
+// SortingBatch parentBatch;
+// if (parentBatchIdStr != null) {
+//
+// // Load existing parent and root
+// parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
+// } else {
+//
+// // Or retrieve parent batch, from pmfm id
+// // Retrieve category type
+// Integer pmfmId = source.getSampleCategoryType().getFieldValue();
+// if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
+// throw new DataIntegrityViolationException(MessageFormat.format(
+// "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
+// SampleCategoryEnum.sortedUnsorted.name(),
+// enumeration.PMFM_ID_SORTED_UNSORTED));
+// }
+// Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
+//
+// parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+// BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
+// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
+// BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+// );
+// }
+//
+//
+// if (parentBatch == null) {
+// throw new DataIntegrityViolationException(
+// "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
+// }
+//
+// // Parent Batch
+// target.setParentBatch(parentBatch);
+// target.setRootBatch(catchBatch);
+// }
- Preconditions.checkNotNull(target);
- Preconditions.checkNotNull(source.getFishingOperation());
- Preconditions.checkNotNull(source.getFishingOperation().getId());
-
- SortingBatch parentBatch;
- if (parentBatchIdStr != null) {
-
- // Load existing parent and root
- parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
- } else {
-
- // Or retrieve parent batch, from pmfm id
- // Retrieve category type
- Integer pmfmId = source.getSampleCategoryType().getFieldValue();
- if (pmfmId == null || !pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) {
- throw new DataIntegrityViolationException(MessageFormat.format(
- "A species batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
- SampleCategoryEnum.sortedUnsorted.name(),
- enumeration.PMFM_ID_SORTED_UNSORTED));
- }
- Integer qualitativeValueId = batchHelper.convertSampleCategoryValueIntoQualitativeId(source.getSampleCategoryValue());
-
- parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
- BatchPersistenceHelper.BATCH_PMFM_ID, pmfmId, qualitativeValueId, // vrac | hors vrac
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // species | Benthos
- BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
- );
- }
-
-
- if (parentBatch == null) {
- throw new DataIntegrityViolationException(
- "Could not retrieve parent batch, for a given speciesBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a SpeciesBatch.");
- }
-
- // Parent Batch
- target.setParentBatch(parentBatch);
- target.setRootBatch(catchBatch);
- }
-
protected void speciesBatchFrequencyToEntity(SpeciesBatchFrequency source,
SortingBatch target,
SortingBatch parentBatch,
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 20:27:37 UTC (rev 783)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-04-15 20:31:51 UTC (rev 784)
@@ -42,10 +42,12 @@
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.Serializable;
+import java.text.MessageFormat;
import java.util.List;
/**
@@ -120,6 +122,66 @@
return result;
}
+ public void setBatchParents(SampleCategoryEnum sampleCategoryType,
+ Serializable sampleCategoryValue,
+ SortingBatch target,
+ String parentBatchIdStr,
+ fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch,
+ Integer batchPmfmId) {
+
+ Preconditions.checkNotNull(target);
+
+ SortingBatch parentBatch;
+ if (parentBatchIdStr != null) {
+
+ // Load existing parent and root
+ parentBatch = catchBatchDao.getSortingBatchById(catchBatch, Integer.valueOf(parentBatchIdStr));
+ } else {
+
+ // Or retrieve parent batch, from pmfm id
+ // Retrieve category type
+ if (!sampleCategoryType.equals(SampleCategoryEnum.sortedUnsorted)) {
+ throw new DataIntegrityViolationException(MessageFormat.format(
+ "A benthos batch with no parent should have a sampleCategoryType {0} (PMFM.ID={1})",
+ SampleCategoryEnum.sortedUnsorted.name(),
+ enumeration.PMFM_ID_SORTED_UNSORTED));
+ }
+
+ Integer qualitativeValueId = convertSampleCategoryValueIntoQualitativeId(sampleCategoryValue);
+
+ if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) {
+
+ // vrac
+ parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, // vrac
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId, // Species | Benthos
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED // vivant trié
+ );
+ } else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) {
+
+ // hors-vrac
+ parentBatch = catchBatchDao.getSortingBatch(catchBatch.getChildBatchs(),
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, // hors vrac
+ BatchPersistenceHelper.BATCH_PMFM_ID, enumeration.PMFM_ID_SORTING_TYPE, batchPmfmId // Species | Benthos
+ );
+ } else {
+
+ // not possible
+ throw new DataIntegrityViolationException("Should have Vrac / Hor Vrac qualitative value, but had: " + qualitativeValueId);
+ }
+
+ }
+
+ if (parentBatch == null) {
+ throw new DataIntegrityViolationException(
+ "Could not retrieve parent batch, for a given speciesBatch or benthosBatch : invalid batch tree structure. Please make sure CatchBatch has been saved before to create a such batch.");
+ }
+
+ // Parent Batch
+ target.setParentBatch(parentBatch);
+ target.setRootBatch(catchBatch);
+ }
+
// public SpeciesBatch entityToSpeciesBatch(SortingBatch source,
// SpeciesBatch target) {
//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-15 20:27:37 UTC (rev 783)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-15 20:31:51 UTC (rev 784)
@@ -657,28 +657,28 @@
parent.getHandler().setBenthosSelectedCard(EditCatchesUIHandler.CREATE_BATCH_CARD);
}
- public void addBatch(CreateBenthosBatchUIModel speciesBatchRootRowModel) {
- if (speciesBatchRootRowModel.isValid()) {
+ public void addBatch(CreateBenthosBatchUIModel bethosBatchRootRowModel) {
+ if (bethosBatchRootRowModel.isValid()) {
BenthosBatchTableModel tableModel = getTableModel();
BenthosBatchRowModel newRow = tableModel.createNewRow();
- Species species = speciesBatchRootRowModel.getSpecies();
+ Species species = bethosBatchRootRowModel.getSpecies();
newRow.setSpecies(species);
- CaracteristicQualitativeValue sortedUnsortedCategory = speciesBatchRootRowModel.getSortedUnsortedCategory();
+ CaracteristicQualitativeValue sortedUnsortedCategory = bethosBatchRootRowModel.getSortedUnsortedCategory();
SampleCategory<CaracteristicQualitativeValue> category = newRow.getSortedUnsortedCategory();
category.setCategoryValue(sortedUnsortedCategory);
- category.setCategoryWeight(speciesBatchRootRowModel.getBatchWeight());
+ category.setCategoryWeight(bethosBatchRootRowModel.getBatchWeight());
newRow.setSampleCategory(category);
recomputeRowValidState(newRow);
+ saveRow(newRow);
+
tableModel.addNewRow(newRow);
AbstractSelectTableAction.doSelectCell(getTable(), tableModel.getRowCount() - 1, 0);
- saveRow(newRow);
-
// update speciesUsed
addToSpeciesUsed(newRow);
}
1
0