Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4058 discussions
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
r783 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/util java/fr/ifremer/tutti/ui/swing/util/attachment resources/i18n
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:27:37 +0200 (Mon, 15 Apr 2013)
New Revision: 783
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/783
Log:
fixes #2292: [TECH] Probl?\195?\168me lors de la visualisation d'une pi?\195?\168ce-jointe
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiErrorHelper.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiErrorHelper.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiErrorHelper.java 2013-04-15 16:37:54 UTC (rev 782)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiErrorHelper.java 2013-04-15 20:27:37 UTC (rev 783)
@@ -56,7 +56,11 @@
*/
public void showErrorDialog(String message, Throwable cause) {
- if (cause instanceof TuttiBusinessException) {
+ if (cause == null) {
+ JOptionPane.showMessageDialog(context.getMainUI(), message,
+ _("tutti.error.ui.business.error"),
+ JOptionPane.ERROR_MESSAGE);
+ } else if (cause instanceof TuttiBusinessException) {
JOptionPane.showMessageDialog(context.getMainUI(), cause.getMessage(),
_("tutti.error.ui.business.error"),
JOptionPane.ERROR_MESSAGE);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-04-15 16:37:54 UTC (rev 782)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-04-15 20:27:37 UTC (rev 783)
@@ -260,52 +260,46 @@
}
}
- public static void openLink(URI uri) {
+ public static Desktop getDesktopForBrowse() {
- try {
- if (!Desktop.isDesktopSupported()) {
- throw new TuttiTechnicalException(
- _("swing.error.desktop.not.supported"));
- }
+ if (!Desktop.isDesktopSupported()) {
+ throw new TuttiTechnicalException(
+ _("swing.error.desktop.not.supported"));
+ }
+ Desktop desktop = Desktop.getDesktop();
- Desktop desktop = Desktop.getDesktop();
+ if (!desktop.isSupported(Desktop.Action.BROWSE)) {
- if (!desktop.isSupported(Desktop.Action.BROWSE)) {
+ throw new TuttiTechnicalException(
+ _("swing.error.desktop.browse.not.supported"));
+ }
- throw new TuttiTechnicalException(
- _("swing.error.desktop.browse.not.supported"));
- }
+ return desktop;
+ }
- desktop.browse(uri);
- throw new RuntimeException(_("swing.error.cannot.open.link"));
- } catch (Exception e) {
+ public static void openLink(URI uri) {
- throw new TuttiTechnicalException(_("swing.error.cannot.open.link"), e);
+ if (!Desktop.isDesktopSupported()) {
+ throw new TuttiTechnicalException(
+ _("swing.error.desktop.not.supported"));
}
- }
- public static void editLink(File uri) {
+ Desktop desktop = Desktop.getDesktop();
- try {
- if (!Desktop.isDesktopSupported()) {
- throw new TuttiTechnicalException(
- _("swing.error.desktop.not.supported"));
- }
+ if (!desktop.isSupported(Desktop.Action.BROWSE)) {
+ throw new TuttiTechnicalException(
+ _("swing.error.desktop.browse.not.supported"));
+ }
- Desktop desktop = Desktop.getDesktop();
+ try {
- if (!desktop.isSupported(Desktop.Action.EDIT)) {
-
- throw new TuttiTechnicalException(
- _("swing.error.desktop.browse.not.supported"));
- }
-
- desktop.edit(uri);
+ desktop.browse(uri);
} catch (Exception e) {
- throw new TuttiTechnicalException("Could not open link: " + uri, e);
+ throw new TuttiTechnicalException(
+ _("swing.error.cannot.open.link", uri), e);
}
}
@@ -323,7 +317,6 @@
}
bean.removePropertyChangeListener(listener);
}
-
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-15 16:37:54 UTC (rev 782)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-15 20:27:37 UTC (rev 783)
@@ -50,9 +50,11 @@
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import java.awt.Component;
+import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
+import java.io.IOException;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -261,17 +263,17 @@
public void openAttachment(Attachment attachment) {
File file = persistenceService.getAttachmentFile(attachment.getId());
+
+ if (!file.exists()) {
+ throw new TuttiTechnicalException("File " + file.getAbsolutePath() + " does not exists.");
+ }
+
+ Desktop desktop = TuttiUIUtil.getDesktopForBrowse();
try {
- TuttiUIUtil.openLink(file.toURI());
+ desktop.browse(file.toURI());
- } catch (TuttiTechnicalException e) {
- String message;
- if (e.getCause() instanceof TuttiTechnicalException) {
- message = e.getCause().getMessage();
- } else {
- message = _("swing.error.cannot.open.file");
- }
- TuttiUIContext.getErrorHelper().showErrorDialog(message, e);
+ } catch (IOException e) {
+ TuttiUIContext.getErrorHelper().showErrorDialog(_("swing.error.cannot.open.file"), null);
}
}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-15 16:37:54 UTC (rev 782)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-15 20:27:37 UTC (rev 783)
@@ -1,5 +1,5 @@
swing.error.cannot.open.file=Aucun programme n'est défini pour ouvrir ce type de fichier. Enregistrez le fichier et ouvrez le en dehors de Tutti.
-swing.error.cannot.open.link=La cible du lien n'existe pas.
+swing.error.cannot.open.link=Impossible d'ouvrir le fichier %s.
swing.error.desktop.browse.not.supported=Le navigateur n'a pas pu être ouvert. Vérifiez que vous avez défini un navigateur par défaut dans votre système.
swing.error.desktop.not.supported=Votre système ne permet pas d'ouvrir des liens ou fichiers en dehors de Tutti.
tutti.about.bottomText=Copyright %s - %s - version %s
1
0
r782 - in trunk: tutti-service/src/main/java/fr/ifremer/tutti/service tutti-service/src/main/java/fr/ifremer/tutti/service/config tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor
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 18:37:54 +0200 (Mon, 15 Apr 2013)
New Revision: 782
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/782
Log:
fixes #2290: [PROTOCOLE] Le protocole n'est plus s?\195?\169lectionn?\195?\169 au d?\195?\169marrage de l'application
fixes #2291: [PROTOCOLE] Un protocole est s?\195?\169lectionn?\195?\169 mais dans le titre on ne le voit pas
refs #1875: [IMP/EXP] - Export des donn?\195?\169es de campagne : format g?\195?\169n?\195?\169rique (ajout dans la configuration du pays de l'export)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-04-15 16:12:04 UTC (rev 781)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -186,8 +186,7 @@
public void clearContext() {
program = null;
cruise = null;
- protocolId = null;
- fishingOperationId = null;
+ fishingOperation = null;
resetProtocol();
resetVessels();
resetGears();
@@ -209,6 +208,12 @@
}
setProtocolId(null);
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("protocolId valid: " + getProtocolId());
+ }
+
+ setProtocolId(getProtocolId());
}
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java 2013-04-15 16:12:04 UTC (rev 781)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/config/TuttiServiceConfigOption.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -71,7 +71,7 @@
"tutti.export.countryId",
n_("tutti.config.option.export.countryId.description"),
"12",
- char.class),
+ String.class),
// TRANSIENT CONFIG
VERSION(
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-04-15 16:12:04 UTC (rev 781)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -512,8 +512,7 @@
if (context.isCruiseFilled()) {
// selected cruise
- Cruise cruise;
- cruise = getDataContext().getCruise();
+ Cruise cruise = getDataContext().getCruise();
if (cruise != null) {
title += _("tutti.main.title.selectedCruise", cruise.getName());
@@ -525,29 +524,27 @@
title += _("tutti.main.title.noSelectedCruise");
}
- title += " / ";
+ } else {
- if (context.isProtocolFilled()) {
+ // no program selected (so neither cruise)
- // selected protocol
- TuttiProtocol protocol = getDataContext().getProtocol();
+ title = _("tutti.main.title.noSelectedProgram");
- log.fatal(protocol.getId() + " " + protocol.getName());
+ }
- title += _("tutti.main.title.selectedProtocol", protocol.getName());
- } else {
+ title += " / ";
- // no selected protocol
+ if (context.isProtocolFilled()) {
- title += _("tutti.main.title.noSelectedProtocol");
- }
+ // selected protocol
+ TuttiProtocol protocol = getDataContext().getProtocol();
+ title += _("tutti.main.title.selectedProtocol", protocol.getName());
} else {
- // no program selected (so neither cruise)
+ // no selected protocol
- title = _("tutti.main.title.noSelectedProgram");
-
+ title += _("tutti.main.title.noSelectedProtocol");
}
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-04-15 16:12:04 UTC (rev 781)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -34,6 +34,7 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
+import fr.ifremer.tutti.ui.swing.util.editor.TuttiLocationTableCell;
import fr.ifremer.tutti.ui.swing.util.editor.VesselTableCell;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.config.ConfigUI;
@@ -137,6 +138,11 @@
.setOptionEditor(vesselTableCellComponent.getNewTableCellEditor())
.setOptionRenderer(vesselTableCellComponent.getNewTableCellRenderer());
+ TuttiLocationTableCell tuttiLocationTableCellComponent = new TuttiLocationTableCell(context);
+ helper.addOption(TuttiServiceConfigOption.EXPORT_COUNTRY_ID)
+ .setOptionEditor(tuttiLocationTableCellComponent.getNewTableCellEditor())
+ .setOptionRenderer(tuttiLocationTableCellComponent.getNewTableCellRenderer());
+
SampleOrderIdsTableCell comp = new SampleOrderIdsTableCell(context);
TableCellEditor sampleOrderEditor = comp.getNewTableCellEditor();
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -0,0 +1,166 @@
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+import org.nuiton.util.decorator.Decorator;
+import org.nuiton.util.decorator.JXPathDecorator;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To edit a {@link TuttiLocation}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class TuttiLocationTableCell {
+
+ protected Decorator<TuttiLocation> decorator;
+
+ protected List<TuttiLocation> entities;
+
+ protected Map<String, TuttiLocation> entityMap;
+
+ public TuttiLocationTableCell(TuttiUIContext context) {
+ DecoratorService decoratorService = context.getDecoratorService();
+ decorator = decoratorService.getDecoratorByType(TuttiLocation.class);
+
+ entities = Lists.newArrayList(context.getPersistenceService().getAllCountry());
+ entityMap = TuttiEntities.splitById(entities);
+ }
+
+ public TableCellEditor getNewTableCellEditor() {
+ return new TuttiLocationTableCellEditor();
+ }
+
+ public TableCellRenderer getNewTableCellRenderer() {
+ return new TuttiLocationTableCellRenderer();
+ }
+
+ protected class TuttiLocationTableCellEditor extends DefaultCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ protected TuttiLocationTableCellEditor() {
+ super(new JComboBox());
+
+ final BeanFilterableComboBox<TuttiLocation> component = new BeanFilterableComboBox<TuttiLocation>();
+ component.setI18nPrefix("tutti.property.");
+ component.setShowReset(true);
+ setClickCountToStart(1);
+
+ editorComponent = component;
+ delegate = new DefaultCellEditor.EditorDelegate() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setValue(Object value) {
+ if (value != null && String.class.isInstance(value)) {
+ value = entityMap.get(value);
+ }
+ component.setSelectedItem(value);
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ String result = null;
+ Object selectedItem = component.getSelectedItem();
+ if (TuttiLocation.class.isInstance(selectedItem)) {
+ TuttiLocation entity = (TuttiLocation) component.getSelectedItem();
+ if (entity != null) {
+ result = entity.getId();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean shouldSelectCell(EventObject anEvent) {
+ if (anEvent instanceof MouseEvent) {
+ MouseEvent e = (MouseEvent) anEvent;
+ return e.getID() != MouseEvent.MOUSE_DRAGGED;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ if (component.isEditable()) {
+ // Commit edited value.
+ component.getCombobox().actionPerformed(
+ new ActionEvent(TuttiLocationTableCellEditor.this, 0, ""));
+ }
+ return super.stopCellEditing();
+ }
+ };
+
+ component.init((JXPathDecorator<TuttiLocation>) decorator, entities);
+ }
+
+ class TuttiLocationListCellRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ return super.getListCellRendererComponent(list, decorator.toString(value), index, isSelected, cellHasFocus);
+ }
+ }
+ }
+
+ protected class TuttiLocationTableCellRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus,
+ int row, int column) {
+
+ String entityId = String.valueOf(value);
+ TuttiLocation entity = entityMap.get(entityId);
+ return super.getTableCellRendererComponent(table, decorator.toString(entity), isSelected, hasFocus, row, column);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiLocationTableCell.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java 2013-04-15 16:12:04 UTC (rev 781)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/VesselTableCell.java 2013-04-15 16:37:54 UTC (rev 782)
@@ -56,17 +56,17 @@
protected Decorator<Vessel> decorator;
- protected List<Vessel> vessels;
+ protected List<Vessel> entities;
- protected Map<String, Vessel> vesselMap;
+ protected Map<String, Vessel> entityMap;
public VesselTableCell(TuttiUIContext context) {
DecoratorService decoratorService = context.getDecoratorService();
decorator = decoratorService.getDecoratorByType(Vessel.class);
- vessels = Lists.newArrayList(context.getDataContext().getFishingVessels());
- vessels.addAll(context.getDataContext().getScientificVessels());
- vesselMap = TuttiEntities.splitById(vessels);
+ entities = Lists.newArrayList(context.getDataContext().getFishingVessels());
+ entities.addAll(context.getDataContext().getScientificVessels());
+ entityMap = TuttiEntities.splitById(entities);
}
public TableCellEditor getNewTableCellEditor() {
@@ -96,7 +96,7 @@
@Override
public void setValue(Object value) {
if (value != null && String.class.isInstance(value)) {
- value = vesselMap.get(value);
+ value = entityMap.get(value);
}
component.setSelectedItem(value);
}
@@ -134,7 +134,7 @@
}
};
- component.init((JXPathDecorator<Vessel>) decorator, vessels);
+ component.init((JXPathDecorator<Vessel>) decorator, entities);
}
class VesselListCellRenderer extends DefaultListCellRenderer {
@@ -158,7 +158,7 @@
int row, int column) {
String vesselId = String.valueOf(value);
- Vessel vessel = vesselMap.get(vesselId);
+ Vessel vessel = entityMap.get(vesselId);
return super.getTableCellRendererComponent(table, decorator.toString(vessel), isSelected, hasFocus, row, column);
}
}
1
0
r781 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches resources/i18n
by kmorin@users.forge.codelutin.com 15 Apr '13
by kmorin@users.forge.codelutin.com 15 Apr '13
15 Apr '13
Author: kmorin
Date: 2013-04-15 18:12:04 +0200 (Mon, 15 Apr 2013)
New Revision: 781
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/781
Log:
refs #1866 [CAPTURE] - Captures accidentelles
refs #1867 [CAPTURE] - Observations individuelles
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-15 15:54:09 UTC (rev 780)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-04-15 16:12:04 UTC (rev 781)
@@ -378,7 +378,7 @@
</JXTitledPanel-->
</tab>
- <tab id='accidentalTab' title='tutti.label.tab.accidentel'>
+ <tab id='accidentalTab'>
<JPanel id='accidentalTabPanel'>
<JXTitledPanel id='accidentalTabFishingOperationReminderLabel'
constraints='EditCatchesUIHandler.MAIN_CARD'>
@@ -392,8 +392,7 @@
</JXTitledPanel>
</JPanel>
</tab>
- <tab id='individualObservationTab'
- title='tutti.label.tab.individualObservation'>
+ <tab id='individualObservationTab'>
<JPanel id='individualObservationTabPanel'>
<JXTitledPanel
id='individualObservationTabFishingOperationReminderLabel'
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-15 15:54:09 UTC (rev 780)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-04-15 16:12:04 UTC (rev 781)
@@ -121,6 +121,8 @@
setCustomTab(1, ui.getSpeciesTabContent().getModel());
setCustomTab(2, ui.getBenthosTabContent().getModel());
setCustomTab(3, ui.getMarineLitterTabContent().getModel());
+ setCustomTab(4, ui.getAccidentalTabContent().getModel());
+ setCustomTab(5, ui.getIndividualObservationTabContent().getModel());
}
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-15 15:54:09 UTC (rev 780)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-04-15 16:12:04 UTC (rev 781)
@@ -1053,6 +1053,9 @@
tutti.selectCruise.action.validateCatches=
tutti.selectCruise.action.validateCatches.mnemonic=
tutti.selectCruise.action.validateCatches.tip=
+tutti.selectCruise.action.validateCruise=
+tutti.selectCruise.action.validateCruise.mnemonic=
+tutti.selectCruise.action.validateCruise.tip=
tutti.selectCruise.field.cruise=
tutti.selectCruise.field.cruise.tip=
tutti.selectCruise.field.program=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-15 15:54:09 UTC (rev 780)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-04-15 16:12:04 UTC (rev 781)
@@ -870,12 +870,12 @@
tutti.importPupitri.trunkFile.extension.description=Fichier du trémie (.tnk)
tutti.label.catches.planktonTotalSampleWeight=Poids total échantillonné
tutti.label.catches.planktonTotalWeight=Poids total
-tutti.label.tab.accidentel=Captures accidentelles
+tutti.label.tab.accidental=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
tutti.label.tab.catchesCaracteristics=Résumé
tutti.label.tab.fishingOperation=Trait
-tutti.label.tab.individualObservation=Observations individuelles
+tutti.label.tab.individualObservations=Observations individuelles
tutti.label.tab.marineLitter=Macro déchets
tutti.label.tab.plancton=Plancton
tutti.label.tab.species=Espèces
@@ -1051,6 +1051,9 @@
tutti.selectCruise.action.validateCatches=Valider les captures
tutti.selectCruise.action.validateCatches.mnemonic=V
tutti.selectCruise.action.validateCatches.tip=Valider les captures
+tutti.selectCruise.action.validateCruise=Valider la campagne
+tutti.selectCruise.action.validateCruise.mnemonic=d
+tutti.selectCruise.action.validateCruise.tip=Valider la campagne
tutti.selectCruise.field.cruise=Campagne
tutti.selectCruise.field.cruise.tip=
tutti.selectCruise.field.program=Série de campagne
1
0
Author: tchemit
Date: 2013-04-15 17:54:09 +0200 (Mon, 15 Apr 2013)
New Revision: 780
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/780
Log:
use last jaxx version
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-04-15 15:39:32 UTC (rev 779)
+++ trunk/pom.xml 2013-04-15 15:54:09 UTC (rev 780)
@@ -132,7 +132,7 @@
<eugenePluginVersion>2.6.2</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <jaxxVersion>2.5.17-SNAPSHOT</jaxxVersion>
+ <jaxxVersion>2.5.17</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<xworkVersion>2.3.7</xworkVersion>
1
0