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
September 2013
- 4 participants
- 100 discussions
r1230 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol tutti-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 26 Sep '13
by tchemit@users.forge.codelutin.com 26 Sep '13
26 Sep '13
Author: tchemit
Date: 2013-09-26 09:38:06 +0200 (Thu, 26 Sep 2013)
New Revision: 1230
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1230
Log:
fixes #3324: [CAPTURE] la cat?\195?\169gorisation propos?\195?\169e ?\195?\160 la cr?\195?\169ation d'un lot ne tient pas compte du protocole
clean db cache at application starts to avoid some troubles!!!
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-09-26 07:38:06 UTC (rev 1230)
@@ -63,7 +63,7 @@
import static org.nuiton.i18n.I18n._;
/**
- * Helper classaround {@link TuttiProtocol}.
+ * Helper class around {@link TuttiProtocol}.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -102,6 +102,8 @@
// transform String to Integer...
+ Integer sampleCategoryIdToRemove = enumeration.PMFM_ID_SORTED_UNSORTED;
+
if (!result.isBenthosEmpty()) {
for (SpeciesProtocol speciesProtocol : result.getBenthos()) {
List mandatorySampleCategoryId = speciesProtocol.getMandatorySampleCategoryId();
@@ -109,6 +111,7 @@
for (Object o : mandatorySampleCategoryId) {
mandatorySampleCategoryIdInteger.add(Integer.valueOf(o.toString()));
}
+ mandatorySampleCategoryIdInteger.remove(sampleCategoryIdToRemove);
speciesProtocol.setMandatorySampleCategoryId(mandatorySampleCategoryIdInteger);
}
@@ -120,6 +123,7 @@
for (Object o : mandatorySampleCategoryId) {
mandatorySampleCategoryIdInteger.add(Integer.valueOf(o.toString()));
}
+ mandatorySampleCategoryIdInteger.remove(sampleCategoryIdToRemove);
speciesProtocol.setMandatorySampleCategoryId(mandatorySampleCategoryIdInteger);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-09-26 07:38:06 UTC (rev 1230)
@@ -344,8 +344,21 @@
}
}));
+ //--------------------------------------------------------------------//
+ // init db configuration
+ //--------------------------------------------------------------------//
+
config.getServiceConfig().getPersistenceConfig().initConfig(getResourceLoader());
+ // clean db cache (avoid a lots of headache :(
+ File cacheDirectory = config.getServiceConfig().getPersistenceConfig().getCacheDirectory();
+ if (cacheDirectory.exists()) {
+ // clean cache directory (fix soem headaches...)
+ TuttiIOUtil.cleanDirectory(
+ cacheDirectory,
+ _("tutti.db.deleteCache.error", cacheDirectory));
+ }
+
//--------------------------------------------------------------------//
// init i18n
//--------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-26 07:38:06 UTC (rev 1230)
@@ -282,16 +282,24 @@
if (getDataContext().isProtocolFilled()) {
+ if (log.isInfoEnabled()) {
+ log.info("Use protocol to find first category");
+ }
// try to find the first category from protocol
TuttiProtocol protocol = getDataContext().getProtocol();
SpeciesProtocol speciesProtocol = TuttiProtocols.getSpeciesProtocol(protocol, newValue);
if (speciesProtocol != null) {
+ if (log.isInfoEnabled()) {
+ log.info("Use protocol species to find first category: " + speciesProtocol.getMandatorySampleCategoryId());
+ }
+
// species defined in protocol
- if (speciesProtocol.sizeMandatorySampleCategoryId() > 1) {
+ if (!speciesProtocol.isMandatorySampleCategoryIdEmpty()) {
- // use the second category (the first one is V/HV)
- Integer categoryId = speciesProtocol.getMandatorySampleCategoryId().get(1);
+ // use the first category
+ Integer categoryId = speciesProtocol.getMandatorySampleCategoryId().get(0);
+
selectedCategory = sampleCategoryModel.getCategoryById(categoryId);
if (log.isInfoEnabled()) {
log.info("Use category from protocol: " + categoryId + " :: " + selectedCategory);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-09-26 07:38:06 UTC (rev 1230)
@@ -74,7 +74,8 @@
private static final long serialVersionUID = 1L;
- public EditProtocolSpeciesTableModel(SampleCategoryModel sampleCategoryModel, TableColumnModelExt columnModel) {
+ public EditProtocolSpeciesTableModel(SampleCategoryModel sampleCategoryModel,
+ TableColumnModelExt columnModel) {
super(columnModel, false, false);
this.sampleCategoryModel = sampleCategoryModel;
setNoneEditableCols(SPECIES_ID);
@@ -85,7 +86,8 @@
List<Integer> mandatoryIds =
Lists.newArrayList(sampleCategoryModel.getSamplingOrder());
-
+ // always remove the first category (V/HV)
+ mandatoryIds.remove(0);
result.setMandatorySampleCategoryId(mandatoryIds);
result.setWeightEnabled(true);
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-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-26 07:38:06 UTC (rev 1230)
@@ -268,6 +268,7 @@
tutti.createSpeciesMelag.error.title=
tutti.createSpeciesMelag.message=
tutti.createSpeciesMelag.title=
+tutti.db.deleteCache.error=
tutti.dbMabager.title=
tutti.dbManager.action.chooseDbBackupFile=
tutti.dbManager.action.chooseDbExportFile=
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-09-26 06:20:09 UTC (rev 1229)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-26 07:38:06 UTC (rev 1230)
@@ -267,6 +267,7 @@
tutti.createSpeciesMelag.error.title=Erreur
tutti.createSpeciesMelag.message=Combien pesait le MELAG (mélange) (%s) ?
tutti.createSpeciesMelag.title=Poids du MELAG (mélange) (%s)
+tutti.db.deleteCache.error=Erreur à la suppression du cache de base
tutti.dbMabager.title=Gérer les bases de données
tutti.dbManager.action.chooseDbBackupFile=Sauvegarder la base de données
tutti.dbManager.action.chooseDbExportFile=Exporter la base de données
1
0
r1229 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency java/fr/ifremer/tutti/ui/swing/content/operation/catches/species java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency resources/i18n
by tchemit@users.forge.codelutin.com 26 Sep '13
by tchemit@users.forge.codelutin.com 26 Sep '13
26 Sep '13
Author: tchemit
Date: 2013-09-26 08:20:09 +0200 (Thu, 26 Sep 2013)
New Revision: 1229
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1229
Log:
fixes #3360: [MENSURATION] Mauvais rafraichissement des valeurs dans le tableau des esp?\195?\168ces
fixes #3329: [MENSURATION] - Renseigner le champ "Type de mesure" ?\195?\160 la saisie des mensuration avec la valeur du lot fr?\195?\168re
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/frequency/BenthosFrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/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/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -39,6 +39,7 @@
import javax.swing.table.TableColumn;
import java.io.Serializable;
import java.util.Enumeration;
+import java.util.List;
import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
@@ -286,6 +287,26 @@
updateShell(row, columnIndex);
}
+ /**
+ * Return previous sibling row, or {@code null} if not exist.
+ *
+ * @param row where to start
+ * @return the previous sibling row, or {@code null} if not exist.
+ * @since 2.6
+ */
+ public BenthosBatchRowModel getPreviousSibling(BenthosBatchRowModel row) {
+ BenthosBatchRowModel result = null;
+ BenthosBatchRowModel parentBatch = row.getParentBatch();
+ if (parentBatch != null) {
+ List<BenthosBatchRowModel> childBatch = parentBatch.getChildBatch();
+ int i = childBatch.indexOf(row);
+ if (i > 0) {
+ result = childBatch.get(i - 1);
+ }
+ }
+ return result;
+ }
+
protected void updateShell(BenthosBatchRowModel entry, int columnIndex) {
Set<BenthosBatchRowModel> shell = Sets.newHashSet();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -123,6 +123,8 @@
protected Integer columnIndex;
+ protected BenthosBatchRowModel previousSiblingRow;
+
public FrequencyCellEditor(BenthosBatchUI ui, Color computedDataColor) {
this.ui = ui;
component = new BenthosFrequencyCellComponent(computedDataColor);
@@ -155,6 +157,10 @@
return nextEditableRowIndex;
}
+ public BenthosBatchRowModel getPreviousSiblingRow() {
+ return previousSiblingRow;
+ }
+
public void startEdit() {
Preconditions.checkNotNull(tableModel, "No table model assigned.");
@@ -164,9 +170,13 @@
nextEditableRowIndex =
tableModel.getNextEditableFrequencyRow(rowIndex + 1);
+ // compute the previous sibling row
+ previousSiblingRow = tableModel.getPreviousSibling(editRow);
+
if (log.isDebugEnabled()) {
log.debug("Will edit frequencies for row: " + rowIndex +
- ", nextEditableRow: " + nextEditableRowIndex);
+ ", nextEditableRow: " + nextEditableRowIndex +
+ ", previous siblingRow: " + previousSiblingRow);
}
EditCatchesUI parent =
@@ -226,14 +236,22 @@
} else {
+ // keep next cell to edit
+ int r = rowIndex;
+ int nextR = nextEditableRowIndex;
+ int c = columnIndex;
+
+ // stop edition of this row
+ stopCellEditing();
+
// use now the next row data
- rowIndex = nextEditableRowIndex;
+ rowIndex = nextR;
// load the row
editRow = tableModel.getEntry(rowIndex);
- // will save the row in the species row
- AbstractSelectTableAction.doSelectCell(table, rowIndex, columnIndex);
+ // will save the previous row in the species row
+ AbstractSelectTableAction.doSelectCell(table, rowIndex, c);
// start edit
startEdit();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -549,6 +549,31 @@
}
}
+ BenthosBatchRowModel previousSiblingRow =
+ frequencyEditor.getPreviousSiblingRow();
+
+ if (lengthStepCaracteristic == null && previousSiblingRow != null) {
+
+ // try to get it from his previous brother row
+ List<BenthosFrequencyRowModel> previousFrequency =
+ previousSiblingRow.getFrequency();
+
+ if (CollectionUtils.isNotEmpty(previousFrequency)) {
+
+ // use the first frequency length step caracteristic / step
+ BenthosFrequencyRowModel rowModel = previousFrequency.get(0);
+ lengthStepCaracteristic =
+ rowModel.getLengthStepCaracteristic();
+ lengthStep = rowModel.getLengthStep();
+ if (log.isInfoEnabled()) {
+ log.info("Use previous sibling existing lengthStep " +
+ "caracteristic / step " +
+ decorate(lengthStepCaracteristic) + " / " +
+ lengthStep);
+ }
+ }
+ }
+
if (lengthStepCaracteristic == null && protocol != null) {
Species species = speciesBatch.getSpecies();
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-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -39,6 +39,7 @@
import javax.swing.table.TableColumn;
import java.io.Serializable;
import java.util.Enumeration;
+import java.util.List;
import java.util.Set;
import static org.nuiton.i18n.I18n.n_;
@@ -266,7 +267,7 @@
/**
* Update the sample category value of the given {@code row}.
*
- * @param row the row to walk through
+ * @param row the row to walk through
* @param columnIndex index of the column where the sample category is
* @param newValue new sample category value to set
* @since 2.6
@@ -285,6 +286,26 @@
updateShell(row, columnIndex);
}
+ /**
+ * Return previous sibling row, or {@code null} if not exist.
+ *
+ * @param row where to start
+ * @return the previous sibling row, or {@code null} if not exist.
+ * @since 2.6
+ */
+ public SpeciesBatchRowModel getPreviousSibling(SpeciesBatchRowModel row) {
+ SpeciesBatchRowModel result = null;
+ SpeciesBatchRowModel parentBatch = row.getParentBatch();
+ if (parentBatch != null) {
+ List<SpeciesBatchRowModel> childBatch = parentBatch.getChildBatch();
+ int i = childBatch.indexOf(row);
+ if (i > 0) {
+ result = childBatch.get(i - 1);
+ }
+ }
+ return result;
+ }
+
protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) {
Set<SpeciesBatchRowModel> shell = Sets.newHashSet();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -123,6 +123,8 @@
protected Integer columnIndex;
+ protected SpeciesBatchRowModel previousSiblingRow;
+
public FrequencyCellEditor(SpeciesBatchUI ui, Color computedDataColor) {
this.ui = ui;
component = new SpeciesFrequencyCellComponent(computedDataColor);
@@ -155,6 +157,10 @@
return nextEditableRowIndex;
}
+ public SpeciesBatchRowModel getPreviousSiblingRow() {
+ return previousSiblingRow;
+ }
+
public void startEdit() {
Preconditions.checkNotNull(tableModel, "No table model assigned.");
@@ -164,9 +170,13 @@
nextEditableRowIndex =
tableModel.getNextEditableFrequencyRow(rowIndex + 1);
+ // compute the previous sibling row
+ previousSiblingRow = tableModel.getPreviousSibling(editRow);
+
if (log.isDebugEnabled()) {
log.debug("Will edit frequencies for row: " + rowIndex +
- ", nextEditableRow: " + nextEditableRowIndex);
+ ", nextEditableRow: " + nextEditableRowIndex +
+ ", previous siblingRow: " + previousSiblingRow);
}
EditCatchesUI parent =
@@ -226,14 +236,22 @@
} else {
+ // keep next cell to edit
+ int r = rowIndex;
+ int nextR = nextEditableRowIndex;
+ int c = columnIndex;
+
+ // stop edition of this row
+ stopCellEditing();
+
// use now the next row data
- rowIndex = nextEditableRowIndex;
+ rowIndex = nextR;
// load the row
editRow = tableModel.getEntry(rowIndex);
- // will save the row in the species row
- AbstractSelectTableAction.doSelectCell(table, rowIndex, columnIndex);
+ // will save the previous row in the species row
+ AbstractSelectTableAction.doSelectCell(table, rowIndex, c);
// start edit
startEdit();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-09-26 06:20:09 UTC (rev 1229)
@@ -548,6 +548,31 @@
}
}
+ SpeciesBatchRowModel previousSiblingRow =
+ frequencyEditor.getPreviousSiblingRow();
+
+ if (lengthStepCaracteristic == null && previousSiblingRow != null) {
+
+ // try to get it from his previous brother row
+ List<SpeciesFrequencyRowModel> previousFrequency =
+ previousSiblingRow.getFrequency();
+
+ if (CollectionUtils.isNotEmpty(previousFrequency)) {
+
+ // use the first frequency length step caracteristic / step
+ SpeciesFrequencyRowModel rowModel = previousFrequency.get(0);
+ lengthStepCaracteristic =
+ rowModel.getLengthStepCaracteristic();
+ lengthStep = rowModel.getLengthStep();
+ if (log.isInfoEnabled()) {
+ log.info("Use previous sibling existing lengthStep " +
+ "caracteristic / step " +
+ decorate(lengthStepCaracteristic) + " / " +
+ lengthStep);
+ }
+ }
+ }
+
if (lengthStepCaracteristic == null && protocol != null) {
Species species = speciesBatch.getSpecies();
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-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-26 06:20:09 UTC (rev 1229)
@@ -1029,6 +1029,7 @@
tutti.exportDb.step.createArchive=
tutti.exportDb.step.openDb=
tutti.exportDb.step.reloadApplication=
+tutti.exportProgram.action.exportErrors=
tutti.exportProgram.action.success=
tutti.exportProtocol.action.success=
tutti.fishingOperations.action.deleteFishingOperation.mnemonic=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 17:12:02 UTC (rev 1228)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-26 06:20:09 UTC (rev 1229)
@@ -1023,7 +1023,6 @@
tutti.error.update.could.not.reach.url=Mise à jour impossible (l'url <strong>%s</strong> n'est pas joignable)
tutti.error.write.startActionFile=impossible d'écrire dans le fichier %s
tutti.exportCruise.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids de la campagne <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
-tutti.exportProgram.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids d'une campagne de la série <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
tutti.exportCruise.action.success=La campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportCruiseForSumatra.action.chooseFile=Choisir le fichier d'export
tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s
@@ -1032,6 +1031,7 @@
tutti.exportDb.step.createArchive=Création de l'archive %s
tutti.exportDb.step.openDb=Réouverture de la base courante
tutti.exportDb.step.reloadApplication=Redémarrage de l'application
+tutti.exportProgram.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids d'une campagne de la série <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
tutti.exportProgram.action.success=La série de campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportProtocol.action.success=Protocole [%1s] exporté dans le fichier <strong>%2s</strong>.
tutti.fishingOperations.action.deleteFishingOperation.mnemonic=S
1
0
r1228 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/home resources/i18n
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 19:12:02 +0200 (Wed, 25 Sep 2013)
New Revision: 1228
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1228
Log:
refs #3313: [EXPORT GENERIQUE] Ne pas bloquer l'export en cas de probl?\195?\168me sur l'?\195?\169l?\195?\169vation (improve error display in ui)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 17:03:03 UTC (rev 1227)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 17:12:02 UTC (rev 1228)
@@ -30,7 +30,6 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -108,22 +107,25 @@
}
}
+ TuttiBusinessException exportError = null;
+
TuttiExportService service = getContext().getTuttiExportService();
try {
service.exportCruise(cruise.getId(), protocol, file, progressionModel);
} catch (TuttiBusinessException e) {
- String message = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage());
- TuttiUIContext.getErrorHelper().showErrorDialog(message);
+
+ String errorMessage;
+ errorMessage = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage());
+ exportError = new TuttiBusinessException(errorMessage);
}
- getHandler().resetEditCruiseAction();
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- Cruise cruise = getModel().getCruise();
sendMessage(_("tutti.exportCruise.action.success",
cruise.getName(), file.getName()));
+
+ handler.resetEditCruiseAction();
+
+ if (exportError != null) {
+ throw exportError;
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 17:03:03 UTC (rev 1227)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 17:12:02 UTC (rev 1228)
@@ -31,7 +31,6 @@
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -68,7 +67,7 @@
// choose file to export
file = saveFile(
- "exportProgram-" + program.getName() ,"zip",
+ "exportProgram-" + program.getName(), "zip",
_("tutti.selectCruise.title.choose.exportProgramFile"),
_("tutti.selectCruise.action.chooseProgramExportFile"),
"^.+\\.zip$", _("tutti.common.file.zip")
@@ -110,22 +109,26 @@
log.info("Will use protocol " + protocol.getName());
}
}
+ TuttiBusinessException exportError = null;
+
TuttiExportService service = getContext().getTuttiExportService();
try {
service.exportProgram(program.getId(), protocol, file, progressionModel);
} catch (TuttiBusinessException e) {
- TuttiBusinessException e2 = new TuttiBusinessException("Des erreurs sont apparues pendant l'élévation des poids<hr/>L'export a cependant été réalisé.", e.getCause());
- TuttiUIContext.getErrorHelper().showErrorDialog(null, e2);
+
+ String errorMessage;
+ errorMessage = _("tutti.exportProgram.action.exportErrors", program.getName(), e.getMessage());
+
+ exportError = new TuttiBusinessException(errorMessage);
}
- getHandler().resetEditProgramAction();
- }
+ handler.resetEditProgramAction();
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- Program program = getModel().getProgram();
sendMessage(_("tutti.exportProgram.action.success", program.getName(),
file.getName()));
+
+ if (exportError != null) {
+ throw exportError;
+ }
}
}
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-09-25 17:03:03 UTC (rev 1227)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 17:12:02 UTC (rev 1228)
@@ -1023,6 +1023,7 @@
tutti.error.update.could.not.reach.url=Mise à jour impossible (l'url <strong>%s</strong> n'est pas joignable)
tutti.error.write.startActionFile=impossible d'écrire dans le fichier %s
tutti.exportCruise.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids de la campagne <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
+tutti.exportProgram.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids d'une campagne de la série <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
tutti.exportCruise.action.success=La campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportCruiseForSumatra.action.chooseFile=Choisir le fichier d'export
tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s
1
0
r1227 - in trunk: tutti-service/src/main/java/fr/ifremer/tutti/service/export tutti-service/src/main/resources/i18n tutti-service/src/test/java/fr/ifremer/tutti/service tutti-service/src/test/java/fr/ifremer/tutti/service/export tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home tutti-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 19:03:03 +0200 (Wed, 25 Sep 2013)
New Revision: 1227
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1227
Log:
fixes #3313: [EXPORT GENERIQUE] Ne pas bloquer l'export en cas de probl?\195?\168me sur l'?\195?\169l?\195?\169vation
refs #3314: [EXPORT GENERIQUE] erreur ?\195?\160 l'export si pas d'engin affect?\195?\169 sur l'op?\195?\169ration
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.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-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/AccidentalCatchExportModel.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -74,7 +74,7 @@
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?");
newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER);
newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportModel.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -67,7 +67,7 @@
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?");
newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER);
newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
@@ -80,27 +80,6 @@
addSampleCategory(entry.getLabel(), entry.getOrder());
}
-// for (SampleCategoryEnum sampleCategoryEnum : samplingOrder) {
-// switch (sampleCategoryEnum) {
-//
-// case sortedUnsorted:
-// addSampleCategory("VracHorsVrac", CatchExportRow.SORTED_UNSORTED_SAMPLE_CATEGORY);
-// break;
-// case size:
-// addSampleCategory("Cat_Tri", CatchExportRow.SIZE_SAMPLE_CATEGORY);
-// break;
-// case sex:
-// addSampleCategory("Sexe", CatchExportRow.SEX_SAMPLE_CATEGORY);
-// break;
-// case maturity:
-// addSampleCategory("Maturite", CatchExportRow.MATURITY_SAMPLE_CATEGORY);
-// break;
-// case age:
-// addSampleCategory("Age", CatchExportRow.AGE_SAMPLE_CATEGORY);
-// break;
-// }
-// }
-
// mensuration
newNullableColumnForExport("Code_Longueur", CatchExportRow.FREQUENCY_LENGTH_STEP_CARACTERISTIC + "." + Caracteristic.PROPERTY_ID);
@@ -139,12 +118,12 @@
// compute species total weight in catch
- float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
+ Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
speciesBatch.getSampleCategoryWeight(),
speciesBatch.getSampleCategoryComputedWeight());
- float totalBatchWeight = speciesCatchRaisingFactor *
- sortedBatchWeight;
+ float totalBatchWeight = sortedBatchWeight == null ? 0 : speciesCatchRaisingFactor *
+ sortedBatchWeight;
prepareSortedRows(persistenceService,
row,
@@ -167,12 +146,12 @@
// compute species total weight in catch
- float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
+ Float sortedBatchWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
- float totalBatchWeight = benthosCatchRaisingFactor *
- sortedBatchWeight;
+ float totalBatchWeight = sortedBatchWeight == null ? 0 : benthosCatchRaisingFactor *
+ sortedBatchWeight;
prepareSortedRows(persistenceService,
row,
@@ -422,7 +401,7 @@
CatchExportRow row = currentRow.copy();
row.addComment(benthosBatch.getComment());
- float referenceWeight = TuttiEntities.getValueOrComputedValue(
+ Float referenceWeight = TuttiEntities.getValueOrComputedValue(
benthosBatch.getSampleCategoryWeight(),
benthosBatch.getSampleCategoryComputedWeight());
@@ -433,9 +412,9 @@
protected void setRaisingFactor(CatchExportRow row,
float totalBatchWeight,
- float referenceWeight) {
+ Float referenceWeight) {
row.setReferenceWeight(referenceWeight);
- row.setRaisingFactor(totalBatchWeight / referenceWeight);
+ row.setRaisingFactor(referenceWeight == null ? 1.0f : (totalBatchWeight / referenceWeight));
}
protected void prepareBatch(CatchExportRow currentRow,
@@ -465,15 +444,7 @@
}
protected void addSampleCategory(String headerPrefix, int categoryOrder) {
-// String categoryName = CatchExportRow.SAMPLE_CATEGORY + "[" + categoryOrder + "]";
-// newNullableColumnForExport(headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
-// newNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName + "." + ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
-// newNullableColumnForExport("Tot_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT);
-// newNullableColumnForExport("Ech_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT);
-// newNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, categoryName + "." + ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE);
-// newNullableColumnForExport("Unite_Volume_Poids_" + headerPrefix, CatchExportRow.BATCH_WEIGHT_UNIT);
-
String categoryName = CatchExportRow.SAMPLE_CATEGORY;
newIndexNullableColumnForExport(headerPrefix, categoryName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER);
newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", categoryName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/CatchExportRow.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -88,7 +88,7 @@
protected Species species;
- protected float referenceWeight;
+ protected Float referenceWeight;
protected float raisingFactor;
@@ -106,7 +106,7 @@
this.fishingOperation = fishingOperation;
}
- public void setReferenceWeight(float referenceWeight) {
+ public void setReferenceWeight(Float referenceWeight) {
this.referenceWeight = referenceWeight;
}
@@ -186,7 +186,7 @@
this.species = species;
}
- public float getReferenceWeight() {
+ public Float getReferenceWeight() {
return referenceWeight;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/IndividualObservationExportModel.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -73,7 +73,7 @@
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?");
newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER);
newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/MarineLitterExportModel.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -51,7 +51,7 @@
newColumnForExport("Annee", Cruise.PROPERTY_BEGIN_DATE, TuttiCsvUtil.YEAR);
newColumnForExport("Serie", Cruise.PROPERTY_PROGRAM, Program.PROPERTY_NAME);
newColumnForExport("Serie_Partielle", Cruise.PROPERTY_SURVEY_PART);
- newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?");
newColumnForExport("Id_Operation", FishingOperation.PROPERTY_STATION_NUMBER);
newColumnForExport("NumOrdre_Station", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/TuttiExportService.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -196,7 +196,16 @@
}
// check cruise fishing operations
- checkCruise(progressionModel, cruise);
+ TuttiBusinessException checkError = null;
+ try {
+ checkCruise(progressionModel, cruise);
+ } catch (TuttiBusinessException e) {
+ // error while checking cruise
+ if (log.isDebugEnabled()) {
+ log.debug("Got a check cruise error", e);
+ }
+ checkError = e;
+ }
File basedir = new File(context.getConfig().newTempFile(
"exportCruise"), "exportCruise-" + cruiseId);
@@ -217,6 +226,11 @@
} finally {
IOUtils.closeQuietly(exportContext);
}
+
+ if (checkError != null) {
+ // rethrow error
+ throw checkError;
+ }
}
protected ExportContext createExportContext(File basedir,
@@ -277,6 +291,7 @@
String cruiseStr = cruiseDecorator.toString(cruise);
throw new TuttiBusinessException(
_("tutti.service.export.invalid.cruise", cruiseStr, sb.toString()));
+// _("tutti.service.export.invalid.cruise2", cruiseStr, sb.toString()));
}
}
@@ -514,7 +529,7 @@
catchBatch.getCatchTotalWeight(),
catchBatch.getCatchTotalComputedWeight());
- float totalUnsortedWeight =
+ Float totalUnsortedWeight =
catchBatch.getCatchTotalUnsortedComputedWeight();
@@ -537,10 +552,10 @@
//FIXME tchemit 2013-07-12 J'utilise en fait la formule (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée)
// (Poids de la capture totale - poids du HV dans la capture totale) / (poids total capture triée - poids du HV dans la capture totale)
- Float catchRaisingFactor = (totalWeight - totalUnsortedWeight) / totalSortedWeight;
+ Float catchRaisingFactor = totalWeight == null || totalUnsortedWeight == null || totalSortedWeight == null ? 1 : (totalWeight - totalUnsortedWeight) / totalSortedWeight;
- Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor;
- Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor;
+ Float speciesCatchRaisingFactor = totalSampleSortedSpeciesWeight == null || totalSortedSpeciesWeight == null || totalSampleSortedSpeciesWeight == null ? 1 : (totalSampleSortedSpeciesWeight == 0 ? 0 : (totalSortedSpeciesWeight / totalSampleSortedSpeciesWeight) * catchRaisingFactor);
+ Float benthosCatchRaisingFactor = totalSampleSortedBenthosWeight == null || totalSortedBenthosWeight == null || totalSampleSortedBenthosWeight == null ? 1 : (totalSampleSortedBenthosWeight == 0 ? 0 : (totalSortedBenthosWeight / totalSampleSortedBenthosWeight) * catchRaisingFactor);
if (log.isDebugEnabled()) {
String message = "\ncatchTotalWeight : " + totalWeight +
@@ -552,7 +567,7 @@
"\nspeciesCatchRaisingFactor : " + speciesCatchRaisingFactor +
"\nbenthosCatchRaisingFactor : " + benthosCatchRaisingFactor;
- log.info(message);
+ log.debug(message);
}
List<CatchExportRow> rows = Lists.newArrayList();
@@ -665,6 +680,8 @@
Map<String, Species> speciesById;
+ String checkError;
+
ExportContext(File basedir,
char csvSeparator,
DecoratorService decoratorService,
@@ -784,6 +801,14 @@
IOUtils.closeQuietly(speciesWriter);
}
+ public String getCheckError() {
+ return checkError;
+ }
+
+ public void setCheckError(String checkError) {
+ this.checkError = checkError;
+ }
+
public void addSpecies(Species species) {
String speciesId = species.getId();
if (!speciesToExport.containsKey(speciesId)) {
@@ -816,12 +841,13 @@
private final CatchBatch catchBatch;
- private final BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
+ private BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
- private final BatchContainer<SpeciesBatch> rootSpeciesBatch;
+ private BatchContainer<SpeciesBatch> rootSpeciesBatch;
- private final BatchContainer<BenthosBatch> rootBenthosBatch;
+ private BatchContainer<BenthosBatch> rootBenthosBatch;
+
protected boolean withCatchBatch;
public OperationContext(FishingOperation operation,
@@ -844,22 +870,43 @@
persistenceService.getCatchBatchFromFishingOperation(
operationId);
- rootSpeciesBatch =
- tuttiWeightComputingService.getComputedSpeciesBatches(operation);
+ boolean withError = false;
- rootBenthosBatch =
- tuttiWeightComputingService.getComputedBenthosBatches(operation);
+ try {
+ rootSpeciesBatch = tuttiWeightComputingService.getComputedSpeciesBatches(operation);
+ } catch (Exception e) {
+ withError = true;
+ rootSpeciesBatch =
+ persistenceService.getRootSpeciesBatch(operationId, null);
+ }
- rootMarineLitterBatch =
- tuttiWeightComputingService.getComputedMarineLitterBatches(operation, catchBatch.getMarineLitterTotalWeight());
+ try {
+ rootBenthosBatch =
+ tuttiWeightComputingService.getComputedBenthosBatches(operation);
+ } catch (Exception e) {
+ withError = true;
+ rootBenthosBatch =
+ persistenceService.getRootBenthosBatch(operationId, null);
+ }
+ try {
+ rootMarineLitterBatch =
+ tuttiWeightComputingService.getComputedMarineLitterBatches(operation, catchBatch.getMarineLitterTotalWeight());
+ } catch (Exception e) {
+ withError = true;
+ rootMarineLitterBatch =
+ persistenceService.getRootMarineLitterBatch(operationId);
+ }
+
// apply compute weights
- tuttiWeightComputingService.computeCatchBatchWeights(
- catchBatch,
- rootSpeciesBatch,
- rootBenthosBatch,
- rootMarineLitterBatch);
+ if (!withError) {
+ tuttiWeightComputingService.computeCatchBatchWeights(
+ catchBatch,
+ rootSpeciesBatch,
+ rootBenthosBatch,
+ rootMarineLitterBatch);
+ }
} else {
if (log.isWarnEnabled()) {
log.warn("Skip fishing operation " + operationId +
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-09-25 17:03:03 UTC (rev 1227)
@@ -57,6 +57,7 @@
tutti.service.export.closeContext.error=
tutti.service.export.context.error=
tutti.service.export.invalid.cruise=
+tutti.service.export.invalid.cruise2=
tutti.service.export.invalid.fishingOperation=
tutti.service.export.operations.error=
tutti.service.export.parameters.error=
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-09-25 17:03:03 UTC (rev 1227)
@@ -56,7 +56,8 @@
tutti.service.export.catches.error=Erreur lors de l'export des captures
tutti.service.export.closeContext.error=Erreur lors de la fermeture du contexte d'export
tutti.service.export.context.error=Erreur lors de la création des fichiers pour l'export
-tutti.service.export.invalid.cruise=L'export de la campagne %s ne peut pas être réalisé suite aux erreurs rencontrées sur ses traits lors de l'élévation des poids \:<ul>%s</ul>
+tutti.service.export.invalid.cruise=Erreur d'élévation de poids sur les traits de la campagne %s \:<ul>%s</ul>
+tutti.service.export.invalid.cruise2=L'export de la campagne %s ne peut pas être réalisé suite aux erreurs rencontrées sur ses traits lors de l'élévation des poids \:<ul>%s</ul>
tutti.service.export.invalid.fishingOperation=<li>L'élévation des poids ne peut pas être réalisée sur le trait %s, pour la raison suivante \:<ul><li>%s</li></ul></li>
tutti.service.export.operations.error=Erreur lors de l'export des traits
tutti.service.export.parameters.error=Erreur lors de l'export des paramètres
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -52,6 +52,8 @@
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -100,6 +102,21 @@
}
}
+ public static void assertFileContent(String message,
+ URL actualFile,
+ String expectedContent) throws IOException {
+
+ Assert.assertNotNull(actualFile);
+ InputStream inputStream = actualFile.openStream();
+ Assert.assertNotNull(inputStream);
+ String fileContent = IOUtils.toString(inputStream, Charsets.UTF_8).trim();
+ Assert.assertEquals(expectedContent, fileContent);
+
+ if (log.isInfoEnabled()) {
+ log.info(message + fileContent);
+ }
+ }
+
protected TuttiServiceContext createServiceContext(RessourceClassLoader loader,
TuttiServiceConfig config) {
return new TuttiServiceContext(loader, config) {
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -24,13 +24,22 @@
* #L%
*/
+import com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
+import fr.ifremer.tutti.service.catches.TuttiWeightComputingService;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import java.io.File;
+import java.net.URL;
+import java.util.List;
/**
* Test export of catches.
@@ -52,27 +61,7 @@
public static final String OPERATION_2_ID = "100113";
- public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" +
- "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" +
- "\n" +
- "avec \n" +
- "\n" +
- "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" +
- "\n" +
- "avec \n" +
- "\n" +
- "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;";
+ public static final String OPERATION_3_ID = "100114";
protected TuttiExportService service;
@@ -93,22 +82,184 @@
service = serviceContext.getService(TuttiExportService.class);
- dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
}
@Test
- public void exportCatches() throws Exception {
+ public void exportWithErrors() throws Exception {
- TuttiExportService.ExportContext exportContext =
- service.createExportContext(dataDirectory, null);
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ PersistenceService persistenceService = serviceContext.getService(PersistenceService.class);
+
+ // check there is a error while compute weight for a cruise
+ boolean errorDetected = false;
+ TuttiWeightComputingService computingService = serviceContext.getService(TuttiWeightComputingService.class);
+ List<FishingOperation> allFishingOperation = persistenceService.getAllFishingOperation(CRUISE_ID);
+ for (FishingOperation fishingOperation : allFishingOperation) {
+ try {
+ computingService.getComputedSpeciesBatches(fishingOperation);
+ } catch (Exception e) {
+ errorDetected = true;
+ break;
+ }
+ }
+
+ Assert.assertTrue(errorDetected);
+
+ File exportFile = new File(dataDirectory, "exportCruise.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(9);
try {
- service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
- } finally {
- exportContext.close();
+ service.exportCruise(CRUISE_ID, null, exportFile, progressionModel);
+ // got an error after but export was still performed
+ Assert.fail();
+ } catch (TuttiBusinessException e) {
+ // got an error
+ Assert.assertTrue(true);
}
- ServiceDbResource.assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT);
+ // export perform, file exist
+ Assert.assertTrue(exportFile.exists());
+
+ String urlPrefix = "jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/";
+ {
+ // check species file content
+
+ URL url = new URL(urlPrefix + "species.csv");
+ ServiceDbResource.assertFileContent("species export:\n",
+ url,
+ "Id;Code_Rubin;Nom Scientifique;Code campagne\n" +
+ "380;ACANECH;Acanthocardia echinata;;\n" +
+ "1358;ALOSALO;Alosa alosa;;\n" +
+ "1938;AGONCAT;Agonus cataphractus;;\n" +
+ "4622;ABIEABI;Abietinaria abietina;;\n" +
+ "11183;;Brissopsis atlantica;;");
+
+ }
+
+ {
+ // check accidentalCatch file content
+
+ URL url = new URL(urlPrefix + "accidentalCatch.csv");
+ ServiceDbResource.assertFileContent("accidentalCatch export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
+
+ }
+
+ {
+ // check operation file content
+
+ URL url = new URL(urlPrefix + "operation.csv");
+ ServiceDbResource.assertFileContent("operation export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2013;test elevation;1;B;2;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;\"Commentaire sur le trait B-2-1\n" +
+ "\n" +
+ "avec\n" +
+ "saut\n" +
+ "de \n" +
+ "ligne\";1000.0;Y;280.0;Y;20.0;Y;700.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;100.0;Y;100.0;N;50.0;Y;0.0;Y;2.0;N;0.0;Y;100.0;N;\n" +
+ "2013;test elevation;1;A;1;1;OTB 20/28.10;278970;01/07/2013 00:00:00;;;01/07/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;\"commentaire trait A-1-1\n" +
+ "Avec \n" +
+ "saut\n" +
+ "de\n" +
+ "ligne\n" +
+ "...\";1000.0;Y;180.0;Y;20.0;Y;800.0;N;;?;;?;200.0;Y;180.0;Y;180.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;\n" +
+ "2013;test elevation;1;C;3;1;?;278970;25/09/2013 00:00:00;;;25/09/2013 00:00:00;;;00;NA;NA;NA;?;N;;NA;NA;NA;;;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;");
+
+ }
+
+ {
+ // check survey file content
+
+ URL url = new URL(urlPrefix + "survey.csv");
+ ServiceDbResource.assertFileContent("survey export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Navire;Pays;Zone_Etude;Campagne;Id_Sismer;Date_Deb_Campagne;Port_Deb_Campagne;Date_Fin_Campagne;Port_Fin_Campagne;Chef_Mission;Resp_Salle_Tri;Commentaire\n" +
+ "2013;test elevation;1;278970;FRA;CGFS - Manche Est / Sud Mer du Nord;test elevation_2013_1;;01/07/2013 00:00:00;La Barbotière (Gujan-Mestras);04/07/2013 00:00:00;La Barbotière (Gujan-Mestras);Adrian LEVREL;Alain BISEAU;;");
+
+ }
+
+ {
+ // check individualObservation file content
+
+ URL url = new URL(urlPrefix + "individualObservation.csv");
+ ServiceDbResource.assertFileContent("individualObservation export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;BatchId;ReferenceTaxonId;ReferenceTaxonName;Commentaire;CaracteristicId;CaracteristicValue");
+
+ }
+
+ {
+ // check catch file content
+
+ URL url = new URL("jar:" + exportFile.toURI().toURL() + "!/exportCruise-" + CRUISE_ID + "/catch.csv");
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-vrac 80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;3.5;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1358;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;1938;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;4622;Abietinaria abietina;\"Trait B-2-1 Benthos ABIEABI Vrac 30\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;380;Acanthocardia echinata;\"Trait B-2-1 Benthos ACANECH Vrac 18\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;6.0;2;0.4;cm;1.0;10;0.4;1361.1111;\n" +
+ "2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-horsvrac-20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;\n" +
+ "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;UNK - Indéterminé;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;0.0;\n" +
+ "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Mâle;2;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;0.0;\n" +
+ "2013;test elevation;1;?;C;3;1;278970;11183;Brissopsis atlantica;|;Vrac;1;;;Poids;kg;NA;;;;;kg;Femelle;3;;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;;1.0;");
+
+ }
+
+ {
+ // check gearCaracteristics file content
+
+ URL url = new URL(urlPrefix + "gearCaracteristics.csv");
+ ServiceDbResource.assertFileContent("gearCaracteristics export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Code_PMFM;Libelle_PMFM;Valeur");
+
+ }
+
+ {
+ // check marineLitter file content
+
+ URL url = new URL(urlPrefix + "marineLitter.csv");
+ ServiceDbResource.assertFileContent("marineLitter export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;278970;L1 PLASTIQUE;A: <5*5 cm= 25 cm2;10;;\"Trait B-2-1 Macro dechet L1 Plastique (nb 10)\n" +
+ "\n" +
+ "avec \n" +
+ "\n" +
+ "commentaire...\";");
+
+ }
+ {
+ // check parameter file content
+
+ URL url = new URL(urlPrefix + "parameter.csv");
+ ServiceDbResource.assertFileContent("parameter export:\n",
+ url,
+ "Annee;Serie;Serie_Partielle;Id_Operation;NumOrdre_Station;Poche;Code_PMFM;Libelle_PMFm;Valeur");
+
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -25,10 +25,12 @@
*/
import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -107,7 +109,12 @@
}
TuttiExportService service = getContext().getTuttiExportService();
- service.exportCruise(cruise.getId(), protocol, file, progressionModel);
+ try {
+ service.exportCruise(cruise.getId(), protocol, file, progressionModel);
+ } catch (TuttiBusinessException e) {
+ String message = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage());
+ TuttiUIContext.getErrorHelper().showErrorDialog(message);
+ }
getHandler().resetEditCruiseAction();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-09-25 17:03:03 UTC (rev 1227)
@@ -25,11 +25,13 @@
*/
import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -109,7 +111,12 @@
}
}
TuttiExportService service = getContext().getTuttiExportService();
- service.exportProgram(program.getId(), protocol, file, progressionModel);
+ try {
+ service.exportProgram(program.getId(), protocol, file, progressionModel);
+ } catch (TuttiBusinessException e) {
+ TuttiBusinessException e2 = new TuttiBusinessException("Des erreurs sont apparues pendant l'élévation des poids<hr/>L'export a cependant été réalisé.", e.getCause());
+ TuttiUIContext.getErrorHelper().showErrorDialog(null, e2);
+ }
getHandler().resetEditProgramAction();
}
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-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 17:03:03 UTC (rev 1227)
@@ -1020,6 +1020,7 @@
tutti.error.update.could.not.found.url=
tutti.error.update.could.not.reach.url=
tutti.error.write.startActionFile=could not write action content to file %s
+tutti.exportCruise.action.exportErrors=
tutti.exportCruise.action.success=
tutti.exportCruiseForSumatra.action.chooseFile=
tutti.exportCruiseForSumatra.action.success=
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-09-25 16:36:22 UTC (rev 1226)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 17:03:03 UTC (rev 1227)
@@ -1022,6 +1022,7 @@
tutti.error.update.could.not.found.url=Mise à jour impossible (l'url <strong>%s</strong> n'existe pas)
tutti.error.update.could.not.reach.url=Mise à jour impossible (l'url <strong>%s</strong> n'est pas joignable)
tutti.error.write.startActionFile=impossible d'écrire dans le fichier %s
+tutti.exportCruise.action.exportErrors=Des erreurs sont apparues pendant l'élévation des poids de la campagne <strong>%s</strong>.<br/>L'export a cependant été réalisé.<hr/>Erreur(s) rencontrée(s) \: <br/>%s
tutti.exportCruise.action.success=La campagne <strong>%s</strong> a été exportée dans le fichier <strong>%s</strong>.
tutti.exportCruiseForSumatra.action.chooseFile=Choisir le fichier d'export
tutti.exportCruiseForSumatra.action.success=Les captures ont correctement été exporté dans le fichier %s
1
0
r1226 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content: . db
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 18:36:22 +0200 (Wed, 25 Sep 2013)
New Revision: 1226
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1226
Log:
refs #3317: [TECH] - Mise ?\195?\160 jour de la base de donn?\195?\169es : pas de v?\195?\169rification au lancement (bad check)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 14:49:08 UTC (rev 1225)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 16:36:22 UTC (rev 1226)
@@ -49,8 +49,7 @@
public class UpdateDbAction extends AbstractMainUITuttiAction {
/** Logger. */
- private static final Log log =
- LogFactory.getLog(UpdateDbAction.class);
+ private static final Log log = LogFactory.getLog(UpdateDbAction.class);
protected ApplicationInfo updateDbVersion;
@@ -82,7 +81,7 @@
updateDbVersion =
dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
- if (updateDbVersion != null) {
+ if (updateDbVersion != null && updateDbVersion.newVersion != null) {
// ask user if it wants to do the update
String htmlMessage = String.format(
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 14:49:08 UTC (rev 1225)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 16:36:22 UTC (rev 1226)
@@ -110,7 +110,7 @@
updateDbVersion =
dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
- if (updateDbVersion != null) {
+ if (updateDbVersion != null && updateDbVersion.newVersion != null) {
// ask user if it wants to do the update
String htmlMessage = String.format(
1
0
r1225 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 16:49:08 +0200 (Wed, 25 Sep 2013)
New Revision: 1225
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1225
Log:
always allow to create a new root species/bethos batch
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
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/BenthosBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
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/SpeciesBatchUIModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-25 14:49:08 UTC (rev 1225)
@@ -267,6 +267,5 @@
text: "tutti.editBenthosBatch.action.createBatch";
toolTipText: "tutti.editBenthosBatch.action.createBatch.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.createBatch.mnemonic";
- enabled: {model.isCreateBatchEnabled()};
_help: {"tutti.editBenthosBatch.action.createBatch.help"};
}
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-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 14:49:08 UTC (rev 1225)
@@ -453,8 +453,6 @@
protected void beforeOpenPopup(int rowIndex, int columnIndex) {
super.beforeOpenPopup(rowIndex, columnIndex);
- boolean enableAdd = true;
-
boolean enableRename = false;
boolean enableSplit = false;
boolean enableChangeSampleCategory = false;
@@ -587,7 +585,6 @@
}
}
BenthosBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
model.setSplitBatchEnabled(enableSplit);
model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
model.setRemoveBatchEnabled(enableRemove);
@@ -596,9 +593,8 @@
model.setCreateMelagEnabled(enableCreateMelag);
model.setEditFrequenciesEnabled(enableEditFrequencies);
- if (log.isInfoEnabled()) {
+ if (log.isDebugEnabled()) {
StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
- builder.append("\nenableAdd: ").append(enableAdd);
builder.append("\nenableSplit: ").append(enableSplit);
builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
builder.append("\nenableRemove: ").append(enableRemove);
@@ -606,7 +602,7 @@
builder.append("\nenableRename: ").append(enableRename);
builder.append("\nenableCreateMelag: ").append(enableCreateMelag);
builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies);
- log.info(builder.toString());
+ log.debug(builder.toString());
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-25 14:49:08 UTC (rev 1225)
@@ -47,8 +47,6 @@
public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode";
- public static final String PROPERTY_CREATE_BATCH_ENABLED = "createBatchEnabled";
-
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
@@ -74,13 +72,6 @@
public static final String PROPERTY_LEAF_NUMBER = "leafNumber";
/**
- * Can user create a new species batch ?
- *
- * @since 0.3
- */
- protected boolean createBatchEnabled;
-
- /**
* Can user split a selected species batch ?
*
* @since 0.3
@@ -304,15 +295,6 @@
firePropertyChange(PROPERTY_LEAF_NUMBER, oldValue, leafNumber);
}
- public boolean isCreateBatchEnabled() {
- return createBatchEnabled;
- }
-
- public void setCreateBatchEnabled(boolean createBatchEnabled) {
- this.createBatchEnabled = createBatchEnabled;
- firePropertyChange(PROPERTY_CREATE_BATCH_ENABLED, null, createBatchEnabled);
- }
-
public boolean isSplitBatchEnabled() {
return splitBatchEnabled;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-25 14:49:08 UTC (rev 1225)
@@ -276,6 +276,5 @@
text: "tutti.editSpeciesBatch.action.createBatch";
toolTipText: "tutti.editSpeciesBatch.action.createBatch.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.createBatch.mnemonic";
- enabled: {model.isCreateBatchEnabled()};
_help: {"tutti.editSpeciesBatch.action.createBatch.help"};
}
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-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 14:49:08 UTC (rev 1225)
@@ -456,8 +456,6 @@
protected void beforeOpenPopup(int rowIndex, int columnIndex) {
super.beforeOpenPopup(rowIndex, columnIndex);
- boolean enableAdd = true;
-
boolean enableRename = false;
boolean enableSplit = false;
boolean enableChangeSampleCategory = false;
@@ -590,7 +588,6 @@
}
}
SpeciesBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
model.setSplitBatchEnabled(enableSplit);
model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
model.setRemoveBatchEnabled(enableRemove);
@@ -601,7 +598,6 @@
if (log.isInfoEnabled()) {
StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
- builder.append("\nenableAdd: ").append(enableAdd);
builder.append("\nenableSplit: ").append(enableSplit);
builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
builder.append("\nenableRemove: ").append(enableRemove);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-25 14:22:24 UTC (rev 1224)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-25 14:49:08 UTC (rev 1225)
@@ -45,8 +45,6 @@
private static final long serialVersionUID = 1L;
- public static final String PROPERTY_CREATE_BATCH_ENABLED = "createBatchEnabled";
-
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
@@ -74,13 +72,6 @@
public static final String PROPERTY_LEAF_NUMBER = "leafNumber";
/**
- * Can user create a new species batch ?
- *
- * @since 0.3
- */
- protected boolean createBatchEnabled;
-
- /**
* Can user split a selected species batch ?
*
* @since 0.3
@@ -286,15 +277,6 @@
firePropertyChange(PROPERTY_LEAF_NUMBER, oldValue, leafNumber);
}
- public boolean isCreateBatchEnabled() {
- return createBatchEnabled;
- }
-
- public void setCreateBatchEnabled(boolean createBatchEnabled) {
- this.createBatchEnabled = createBatchEnabled;
- firePropertyChange(PROPERTY_CREATE_BATCH_ENABLED, null, createBatchEnabled);
- }
-
public boolean isSplitBatchEnabled() {
return splitBatchEnabled;
}
1
0
r1224 - in trunk/tutti-service/src: main/java/fr/ifremer/tutti/service main/java/fr/ifremer/tutti/service/export test/java/fr/ifremer/tutti/service/export
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 16:22:24 +0200 (Wed, 25 Sep 2013)
New Revision: 1224
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1224
Log:
fixes #3314: [EXPORT GENERIQUE] erreur ?\195?\160 l'export si pas d'engin affect?\195?\169 sur l'op?\195?\169ration
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java 2013-09-25 13:31:19 UTC (rev 1223)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java 2013-09-25 14:22:24 UTC (rev 1224)
@@ -159,6 +159,10 @@
return modelBuilder.newColumnForExport(headerName, new BeanNullableGetter<M, T>(propertyName), valueFormatter);
}
+ public ExportableColumn<M, String> newNullableColumnForExport(String headerName, String propertyName, String nullValue) {
+ return newNullableColumnForExport(headerName, propertyName, newStringParserFormatter2(nullValue, true));
+ }
+
public ExportableColumn<M, String> newNullableColumnForExport(String headerName, String propertyName) {
return newNullableColumnForExport(headerName, propertyName, TuttiCsvUtil.STRING);
}
@@ -173,6 +177,33 @@
}
+ public static ValueParserFormatter<String> newStringParserFormatter2(String defaultValue, boolean nullAllowed) {
+ return new StringParserFormatter2(defaultValue, nullAllowed);
+ }
+
+ public static class StringParserFormatter2 extends Common.NullableParserFormatter<String> {
+
+ public StringParserFormatter2(String defaultValue, boolean nullAllowed) {
+ super(defaultValue, nullAllowed);
+ }
+
+ @Override
+ public String format(String value) {
+ String str;
+ if (value == null) {
+ str = defaultValue;
+ } else {
+ str = String.valueOf(value);
+ }
+ return str;
+ }
+
+ @Override
+ protected String parseNoneEmptyValue(String value) {
+ return value;
+ }
+ }
+
public static class StringParserFormatter extends Common.NullableParserFormatter<String> {
public StringParserFormatter(String defaultValue, boolean nullAllowed) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java 2013-09-25 13:31:19 UTC (rev 1223)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/OperationExportModel.java 2013-09-25 14:22:24 UTC (rev 1224)
@@ -65,7 +65,7 @@
newColumnForExport("Numero_Trait", FishingOperation.PROPERTY_FISHING_OPERATION_NUMBER, TuttiCsvUtil.INTEGER);
newColumnForExport("Poche", FishingOperation.PROPERTY_MULTIRIG_AGGREGATION);
- newColumnForExport("Engin", FishingOperation.PROPERTY_GEAR, Gear.PROPERTY_NAME);
+ newNullableColumnForExport("Engin", FishingOperation.PROPERTY_GEAR + "." + Gear.PROPERTY_NAME, "?");
newColumnForExport("Navire", FishingOperation.PROPERTY_VESSEL, TuttiCsvUtil.VESSEL_VALUE_FORMATTER);
newColumnForExport("DateDeb_Op", FishingOperation.PROPERTY_GEAR_SHOOTING_START_DATE, TuttiCsvUtil.DAY_TIME_SECOND);
newColumnForExport("LatDeb", FishingOperation.PROPERTY_GEAR_SHOOTING_START_LATITUDE, TuttiCsvUtil.FLOAT);
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-09-25 13:31:19 UTC (rev 1223)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-09-25 14:22:24 UTC (rev 1224)
@@ -79,6 +79,10 @@
"Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
"2010;Campagne CGFS;;65;65;1;GOV 19.7/25.9;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
+ public static final String OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR =
+ "Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
+ "2010;Campagne CGFS;;65;65;1;?;278970;13/10/2010 13:35:00;50.22833;0.31833;13/10/2010 14:05:00;50.22167;0.28333;30;Strate 4J;NA;Localité 4J2;N;Y;2512.0;NA;NA;NA;;avarie - chalut annulé completement à poil;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;;?;";
+
public static final String OPERATION_CONTENT =
"Annee;Serie;Serie_Partielle;Code_Station;Numero_Trait;Poche;Engin;Navire;DateDeb_Op;LatDeb;LongDeb;DateFin_Op;LatFin;LongFin;Duree;Strate;Sous-Strate;Localite;Validite_OP;Rectiligne;Distance;Ouv_Verticale;Ouv_Horizontale_Ailes;Ouv_Horizontale_Panneaux;Saisisseur;Commentaire;Poids_Total;Poids_Total_Calcule;Poids_Total_Vrac;Poids_Total_Vrac_Calcule;Poids_Total_HorsVrac;Poids_Total_HorsVrac_Calcule;Poids_Total_Non_Trie;Poids_Total_Non_Trie_Calcule;Poids_Total_Tremis;Poids_Total_Tremis_Calcule;Poids_Total_Carroussel;Poids_Total_Carroussel_Calcule;Poids_Total_Espece;Poids_Total_Espece_Calcule;Poids_Total_Espece_Vrac;Poids_Total_Espece_Vrac_Calcule;Poids_Total_Espece_Vrac_Trie;Poids_Total_Espece_Vrac_Trie_Calcule;Poids_Total_Espece_HorsVrac;Poids_Total_Espece_HorsVrac_Calcule;Poids_Total_Espece_Inerte_Trie;Poids_Total_Espece_Inerte_Trie_Calcule;Poids_Total_Espece_Vivant_non_detaille_trie;Poids_Total_Espece_Vivant_non_detaille_trie_Calcule;Poids_Total_Benthos;Poids_Total_Benthos_Calcule;Poids_Total_Benthos_Vrac;Poids_Total_Benthos_Vrac_Calcule;Poids_Total_Benthos_Vrac_Trie;Poids_Total_Benthos_Vrac_Trie_Calcule;Poids_Total_Benthos_HorsVrac;Poids_Total_Benthos_HorsVrac_Calcule;Poids_Total_Benthos_Inerte_Trie;Poids_Total_Benthos_Inerte_Trie_Calcule;Poids_Total_Benthos_Vivant_non_detaille_trie;Poids_Total_Benthos_Vivant_non_detaille_trie_Calcule;Poids_Total_Macro_Dechet;Poids_Total_Macro_Dechet_Calcule\n" +
"2013;Campagne CGFS;;A;1;1;GOV 19.7/25.9;278970;01/05/2013 00:00:00;;;01/05/2013 00:23:00;;;23;Strate 1D;NA;Localité 1D2;?;N;;NA;NA;NA;Vincent AURECHE;op1;120.0;Y;100.0;Y;20.0;Y;0.0;Y;;?;;?;120.0;Y;100.0;Y;100.0;Y;20.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;0.0;Y;6.0;Y;\n" +
@@ -318,6 +322,29 @@
}
@Test
+ public void exportOperationsWithNoGear() throws Exception {
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
+
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
+ operation.setGear(null);
+ dataContext.operations = Lists.newArrayList(operation);
+
+ TuttiExportService.ExportContext exportContext =
+ service.createExportContext(dataDirectory, null);
+
+ try {
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
+ } finally {
+ exportContext.close();
+ }
+
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_WITH_NO_CATCH_CONTENT_AND_NO_GEAR);
+ }
+
+ @Test
public void exportParameters() throws Exception {
TuttiExportService.ExportContext exportContext =
1
0
r1223 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content java/fr/ifremer/tutti/ui/swing/content/db resources/i18n
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 15:31:19 +0200 (Wed, 25 Sep 2013)
New Revision: 1223
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1223
Log:
fixes #3317: [TECH] - Mise ?\195?\160 jour de la base de donn?\195?\169es : pas de v?\195?\169rification au lancement
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.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/ShowAboutAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.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/RunTutti.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -102,15 +102,6 @@
// check application url is reachable
boolean canUpdate = context.checkUpdateApplicationReachable();
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// config.getUpdateApplicationUrl(),
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// canUpdate = false;
-// }
if (canUpdate) {
// try to update jre - i18n - application - help and exit if so
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -29,24 +29,16 @@
import com.google.common.collect.Maps;
import fr.ifremer.tutti.LabelAware;
import fr.ifremer.tutti.TuttiIOUtil;
-import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
-import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionException;
-import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.updater.ApplicationInfo;
-import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.updater.ApplicationUpdaterCallback;
import java.io.File;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -54,7 +46,7 @@
import static org.nuiton.i18n.I18n.n_;
/**
- * CallBack to update jre, application, i18n or db.
+ * CallBack to update jre, application, i18n.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -69,8 +61,7 @@
JRE(n_("tutti.update.jre")),
TUTTI(n_("tutti.update.tutti")),
I18N(n_("tutti.update.i18n")),
- HELP(n_("tutti.update.help")),
- DB(n_("tutti.update.db"));
+ HELP(n_("tutti.update.help"));
private final String i18nKey;
@@ -92,10 +83,6 @@
protected boolean applicationUpdated;
- protected boolean dbInstalled;
-
- protected boolean dbUpdated;
-
protected final AbstractTuttiAction action;
public TuttiApplicationUpdaterCallBack(AbstractTuttiAction action,
@@ -113,14 +100,6 @@
return applicationUpdated;
}
- public boolean isDbUpdated() {
- return dbUpdated;
- }
-
- public boolean isDbInstalled() {
- return dbInstalled;
- }
-
@Override
public Map<String, ApplicationInfo> updateToDo(Map<String, ApplicationInfo> appToUpdate) {
Map<String, ApplicationInfo> result = Maps.newHashMap();
@@ -129,48 +108,13 @@
ApplicationInfo info = getInfo(type, appToUpdate);
if (info != null) {
result.put(info.name, info);
- if (UpdateType.DB.equals(type)) {
- // add auth
- info.setAuthentication(
- "t" + "u" + "t" + "t" + "i" + "d" + "b",
- new char[]{'3', 'R', 'A', 'C', 'e', 'v', '2', 'N', 'w', '8', 'u', 'E', 'D', 'E', 'v', 's', 'y', '0', 'v', 'J'}
- );
- }
}
}
- if (types.contains(UpdateType.DB)) {
-
- ApplicationInfo info = getInfo(UpdateType.DB, result);
-
- if (info == null) {
- dbInstalled = false;
- dbUpdated = false;
- } else {
- if (context.isDbExist()) {
-
- // when db exists always an update
- dbUpdated = true;
- } else {
-
- // when no db, then always install
- dbInstalled = true;
- }
- }
- }
return result;
}
@Override
public void startUpdate(ApplicationInfo info) {
- if (UpdateType.DB.name().toLowerCase().equals(info.name)) {
-
- if (dbInstalled) {
-
- progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
- } else if (dbUpdated) {
- progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
- }
- }
if (UpdateType.JRE.name().toLowerCase().equals(info.name)) {
progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.jre", info.newVersion));
}
@@ -198,8 +142,6 @@
boolean doRestart = updateJRE || updateTutti || updateI18n || updateHelp;
- updateDoneDb(appToUpdate, appUpdateError);
-
if (doRestart) {
applicationUpdated = true;
@@ -284,6 +226,13 @@
i18nDirectory,
_("tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error", i18nDirectory)
);
+
+ // must remove db cache directory
+ File cacheDirectory = context.getConfig().getServiceConfig().getPersistenceConfig().getCacheDirectory();
+ TuttiIOUtil.forceDeleteOnExit(
+ cacheDirectory,
+ _("tutti.applicationUpdater.updateDone.deleteDirectory.caches.error", i18nDirectory)
+ );
}
}
return doRestart;
@@ -339,56 +288,6 @@
return doRestart;
}
- protected void updateDoneDb(Map<String, ApplicationInfo> appToUpdate,
- Map<String, Exception> appUpdateError) {
- Exception error = getError(UpdateType.DB, appUpdateError);
- if (error != null) {
-
- // something bad while updating db
- if (log.isErrorEnabled()) {
- log.error("Could not update db", error);
- }
- throw new TuttiActionException(action, error);
- } else {
- ApplicationInfo info = getInfo(UpdateType.DB, appToUpdate);
- if (info != null) {
-
- if (log.isInfoEnabled()) {
- log.info(String.format(
- "A db update was downloaded (oldVersion: %s, newVersion: %s), will process it.",
- info.oldVersion, info.newVersion));
- }
-
- // before install or update, regenerate db configuration files
-
- TuttiPersistenceConfig persistenceConfig = regenerateDbConf();
-
- persistenceConfig.generateExternalDbFiles(true);
-
- if (dbInstalled) {
-
- // first database, just copy it to correct directory
-
- prepareFirstDatabase(info);
- } else if (dbUpdated) {
-
- // launch a referential synchronize operation
- synchronizetDatabase(info);
- }
- }
- }
- }
-
- protected TuttiPersistenceConfig regenerateDbConf() {
-
- TuttiPersistenceConfig persistenceConfig =
- context.getConfig().getServiceConfig().getPersistenceConfig();
-
- context.showInformationMessage(
- "Regénérer les fichiers de configuration de la base");
- return persistenceConfig;
- }
-
protected ApplicationInfo getInfo(UpdateType type,
Map<String, ApplicationInfo> appToUpdate) {
return appToUpdate.get(type.name().toLowerCase());
@@ -407,67 +306,4 @@
File result = sources[0];
return result;
}
-
- protected void prepareFirstDatabase(ApplicationInfo info) {
- if (log.isInfoEnabled()) {
- log.info("First time database was downloaded at version: " + info.newVersion);
- }
- File source = getDbDirectory(info);
- File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
- if (log.isInfoEnabled()) {
- log.info("Copy from " + source + " to " + target);
- }
- try {
- FileUtils.copyDirectory(source, target);
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.copyDirectory.error", source, target), e);
- }
- try {
- FileUtils.deleteDirectory(source.getParentFile());
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error", target), e);
- }
- }
-
- protected void synchronizetDatabase(ApplicationInfo info) {
- if (log.isInfoEnabled()) {
- log.info(String.format("A database update was downloaded (oldVersion: %s, newVersion: %s), will launch a referential synchronize operation ", info.oldVersion, info.newVersion));
- }
- TuttiReferentialSynchronizeService service = context.getTuttiReferentialSynchronizeService();
- ReferentialSynchronizeResult result = new ReferentialSynchronizeResult();
- File dbDirectory = getDbDirectory(info);
-
- TuttiActionUI actionUI = context.getActionUI();
- actionUI.getModel().setProgressionModel(result.getProgressionModel());
- service.prepare(dbDirectory, result);
-
- if (!result.isSuccess()) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.prepare.error"), result.getError());
- }
-
- service.synchronize(dbDirectory, result);
-
- if (!result.isSuccess()) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.synchro.error"), result.getError());
- }
-
- // reset cache
- if (log.isInfoEnabled()) {
- log.info("Reset all caches.");
- }
- PersistenceService persistence = context.getPersistenceService();
- persistence.clearAllCaches();
-
- // replace the version.appup file content
- File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
- File versionFile = ApplicationUpdater.getVersionFile(target);
- if (log.isInfoEnabled()) {
- log.info("Replace content of file " + versionFile + " with " + info.newVersion);
- }
- try {
- ApplicationUpdater.storeVersionFile(target, info.newVersion);
- } catch (IOException e) {
- throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.writeVersion.error", versionFile));
- }
- }
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java (from rev 1217, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -0,0 +1,273 @@
+package fr.ifremer.tutti.ui.swing;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
+import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.util.action.TuttiActionException;
+import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+import org.nuiton.updater.ApplicationUpdaterCallback;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * CallBack to update db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6
+ */
+public class TuttiDbUpdaterCallBack implements ApplicationUpdaterCallback {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(TuttiDbUpdaterCallBack.class);
+
+ public static final String DB_UPDATE_NAME = "db";
+
+ static {
+ n_("tutti.update.db");
+ }
+
+ protected final TuttiUIContext context;
+
+ protected ProgressionModel progressionModel;
+
+ protected boolean dbInstalled;
+
+ protected boolean dbUpdated;
+
+ protected final AbstractTuttiAction action;
+
+ public TuttiDbUpdaterCallBack(AbstractTuttiAction action,
+ ProgressionModel progressionModel) {
+ this.action = action;
+ this.context = action.getContext();
+ this.progressionModel = progressionModel;
+ }
+
+ public boolean isDbUpdated() {
+ return dbUpdated;
+ }
+
+ public boolean isDbInstalled() {
+ return dbInstalled;
+ }
+
+ @Override
+ public Map<String, ApplicationInfo> updateToDo(Map<String, ApplicationInfo> appToUpdate) {
+ Map<String, ApplicationInfo> result = Maps.newHashMap();
+
+ ApplicationInfo info = appToUpdate.get(DB_UPDATE_NAME);
+ if (info == null) {
+ dbInstalled = false;
+ dbUpdated = false;
+ } else {
+ result.put(info.name, info);
+
+ // add auth
+ info.setAuthentication(
+ "t" + "u" + "t" + "t" + "i" + "d" + "b",
+ new char[]{'3', 'R', 'A', 'C', 'e', 'v', '2', 'N', 'w', '8', 'u', 'E', 'D', 'E', 'v', 's', 'y', '0', 'v', 'J'}
+ );
+
+ if (context.isDbExist()) {
+
+ // when db exists always an update
+ dbUpdated = true;
+ } else {
+
+ // when no db, then always install
+ dbInstalled = true;
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void startUpdate(ApplicationInfo info) {
+
+ if (dbInstalled) {
+ progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.installation", info.newVersion));
+ } else if (dbUpdated) {
+ progressionModel.setMessage(_("tutti.applicationUpdater.startUpdate.db.update", info.newVersion));
+ }
+ }
+
+ @Override
+ public void updateDone(Map<String, ApplicationInfo> appToUpdate,
+ Map<String, Exception> appUpdateError) {
+
+ updateDoneDb(appToUpdate, appUpdateError);
+ }
+
+ @Override
+ public void aborted(String propertiesURL, Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not update from " + propertiesURL, eee);
+ }
+ throw TuttiActionException.propagateError(action, eee);
+ }
+
+
+ protected void updateDoneDb(Map<String, ApplicationInfo> appToUpdate,
+ Map<String, Exception> appUpdateError) {
+ Exception error = appUpdateError.get(DB_UPDATE_NAME);
+ if (error != null) {
+
+ // something bad while updating db
+ if (log.isErrorEnabled()) {
+ log.error("Could not update db", error);
+ }
+ throw new TuttiActionException(action, error);
+ } else {
+ ApplicationInfo info = appToUpdate.get(DB_UPDATE_NAME);
+ if (info != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format(
+ "A db update was downloaded (oldVersion: %s, newVersion: %s), will process it.",
+ info.oldVersion, info.newVersion));
+ }
+
+ // before install or update, regenerate db configuration files
+
+ TuttiPersistenceConfig persistenceConfig = regenerateDbConf();
+
+ persistenceConfig.generateExternalDbFiles(true);
+
+ if (dbInstalled) {
+
+ // first database, just copy it to correct directory
+
+ prepareFirstDatabase(info);
+ } else if (dbUpdated) {
+
+ // launch a referential synchronize operation
+ synchronizetDatabase(info);
+ }
+ }
+ }
+ }
+
+ protected TuttiPersistenceConfig regenerateDbConf() {
+
+ TuttiPersistenceConfig persistenceConfig =
+ context.getConfig().getServiceConfig().getPersistenceConfig();
+
+ context.showInformationMessage(
+ "Regénérer les fichiers de configuration de la base");
+ return persistenceConfig;
+ }
+
+ protected File getDbDirectory(ApplicationInfo info) {
+ File[] sources = info.destDir.listFiles();
+ Preconditions.checkState(
+ sources != null && sources.length == 1,
+ "Downloaded db should contains one directory at " + info.destDir);
+ File result = sources[0];
+ return result;
+ }
+
+ protected void prepareFirstDatabase(ApplicationInfo info) {
+ if (log.isInfoEnabled()) {
+ log.info("First time database was downloaded at version: " + info.newVersion);
+ }
+ File source = getDbDirectory(info);
+ File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
+ if (log.isInfoEnabled()) {
+ log.info("Copy from " + source + " to " + target);
+ }
+ try {
+ FileUtils.copyDirectory(source, target);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.copyDirectory.error", source, target), e);
+ }
+ try {
+ FileUtils.deleteDirectory(source.getParentFile());
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error", target), e);
+ }
+ }
+
+ protected void synchronizetDatabase(ApplicationInfo info) {
+ if (log.isInfoEnabled()) {
+ log.info(String.format("A database update was downloaded (oldVersion: %s, newVersion: %s), will launch a referential synchronize operation ", info.oldVersion, info.newVersion));
+ }
+ TuttiReferentialSynchronizeService service = context.getTuttiReferentialSynchronizeService();
+ ReferentialSynchronizeResult result = new ReferentialSynchronizeResult();
+ File dbDirectory = getDbDirectory(info);
+
+ TuttiActionUI actionUI = context.getActionUI();
+ actionUI.getModel().setProgressionModel(result.getProgressionModel());
+ service.prepare(dbDirectory, result);
+
+ if (!result.isSuccess()) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.prepare.error"), result.getError());
+ }
+
+ service.synchronize(dbDirectory, result);
+
+ if (!result.isSuccess()) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.synchro.error"), result.getError());
+ }
+
+ // reset cache
+ if (log.isInfoEnabled()) {
+ log.info("Reset all caches.");
+ }
+ PersistenceService persistence = context.getPersistenceService();
+ persistence.clearAllCaches();
+
+ // replace the version.appup file content
+ File target = context.getConfig().getServiceConfig().getPersistenceConfig().getDbDirectory();
+ File versionFile = ApplicationUpdater.getVersionFile(target);
+ if (log.isInfoEnabled()) {
+ log.info("Replace content of file " + versionFile + " with " + info.newVersion);
+ }
+ try {
+ ApplicationUpdater.storeVersionFile(target, info.newVersion);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_("tutti.applicationUpdater.synchroDB.writeVersion.error", versionFile));
+ }
+ }
+}
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-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -39,6 +39,7 @@
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
import fr.ifremer.tutti.ui.swing.content.db.DbManagerUI;
+import fr.ifremer.tutti.ui.swing.content.db.DbManagerUIHandler;
import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
@@ -102,6 +103,15 @@
this.persistenceService = null;
}
+ public void reloadDbManagerText() {
+
+ AbstractTuttiUIHandler currentHandler = getCurrentHandler();
+ if (currentHandler instanceof DbManagerUIHandler) {
+ DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) currentHandler;
+ dbManagerUIHandler.updateMessage();
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -215,6 +225,7 @@
TuttiUIAction<OpenDbAction> uiAction = TuttiActionHelper.createUIAction(this, OpenDbAction.class);
OpenDbAction logicAction = uiAction.getLogicAction();
logicAction.setSkipCheckCurrentScreen(true);
+ logicAction.setUpdateReferentiel(true);
uiAction.actionPerformed(null);
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -28,6 +28,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -184,12 +185,9 @@
protected void addUpdate(Map<String, ApplicationInfo> source,
Map<String, ApplicationInfo> target,
- TuttiApplicationUpdaterCallBack.UpdateType... types) {
- for (TuttiApplicationUpdaterCallBack.UpdateType type : types) {
- String appName = type.name().toLowerCase();
- ApplicationInfo info = source.get(appName);
- target.put(appName, info);
- }
+ String type) {
+ ApplicationInfo info = source.get(type.toLowerCase());
+ target.put(type, info);
}
protected void addUpdateTab(TuttiApplicationConfig config) {
@@ -207,11 +205,14 @@
// create final update map
final Map<String, ApplicationInfo> versions = Maps.newTreeMap();
- addUpdate(applicationVersions, versions,
- UpdateApplicationAction.ALL_APPLICATION_TYPES);
- addUpdate(dbVersions, versions,
- TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.JRE.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.TUTTI.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.I18N.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.HELP.name());
+
+ addUpdate(dbVersions, versions, TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
JScrollPane updatePane = new JScrollPane();
JEditorPane updateArea = new JEditorPane();
updateArea.setContentType("text/html");
@@ -222,12 +223,13 @@
updateArea.setBorder(null);
List<String> params = Lists.newArrayList();
- for (TuttiApplicationUpdaterCallBack.UpdateType type : TuttiApplicationUpdaterCallBack.UpdateType.values()) {
- String appName = type.name().toLowerCase();
- ApplicationInfo info = versions.get(appName);
+ for (Map.Entry<String, ApplicationInfo> entry : versions.entrySet()) {
+ String appName = entry.getKey();
+ ApplicationInfo info = entry.getValue();
String oldVersion = info.oldVersion;
String newVersion = info.newVersion;
- String appLabel = type.getLabel();
+ String i18nKey = "tutti.update." + appName.toLowerCase();
+ String appLabel = _(i18nKey);
if (log.isInfoEnabled()) {
log.info(String.format(
@@ -243,6 +245,7 @@
params.add(_("tutti.about.update.app.up.detail", appLabel, oldVersion, newVersion, appName));
}
}
+
String updateText = _("tutti.about.update.content", urlApplication, urlDb, Joiner.on("\n").join(params));
updateArea.setText(updateText);
updatePane.getViewport().add(updateArea);
@@ -255,33 +258,33 @@
TuttiUIUtil.openLink(url);
} else {
String appType = e.getDescription();
- TuttiApplicationUpdaterCallBack.UpdateType updateType =
- TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
+
if (log.isInfoEnabled()) {
- log.info("Open url: " + updateType);
+ log.info("Open url: " + appType);
}
AbstractTuttiAction action;
- switch (updateType) {
- case DB: {
- UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
- action = logicAction;
- if (!getContext().isDbExist()) {
+ if (TuttiDbUpdaterCallBack.DB_UPDATE_NAME.equals(appType)) {
+ UpdateDbAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateDbAction.class);
+ action = logicAction;
+ if (!getContext().isDbExist()) {
- // install db
- action.setActionDescription(
- _("tutti.dbManager.action.installDb.tip"));
- }
+ // install db
+ action.setActionDescription(
+ _("tutti.dbManager.action.installDb.tip"));
}
- break;
- default: {
- UpdateApplicationAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateApplicationAction.class);
- logicAction.setTypes(updateType);
- logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
- action = logicAction;
- }
+ } else {
+
+ TuttiApplicationUpdaterCallBack.UpdateType updateType =
+ TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
+
+ UpdateApplicationAction logicAction = TuttiActionHelper.createLogicAction(getHandler(), UpdateApplicationAction.class);
+ logicAction.setTypes(updateType);
+ logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
+ action = logicAction;
}
+
// close this dialog
TuttiActionHelper.runAction(about.getClose());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -51,17 +51,10 @@
private static final Log log =
LogFactory.getLog(UpdateApplicationAction.class);
- public static final TuttiApplicationUpdaterCallBack.UpdateType[] ALL_APPLICATION_TYPES = new TuttiApplicationUpdaterCallBack.UpdateType[]{
- TuttiApplicationUpdaterCallBack.UpdateType.JRE,
- TuttiApplicationUpdaterCallBack.UpdateType.I18N,
- TuttiApplicationUpdaterCallBack.UpdateType.TUTTI,
- TuttiApplicationUpdaterCallBack.UpdateType.HELP
- };
-
public UpdateApplicationAction(MainUIHandler handler) {
super(handler, true);
setActionDescription(_("tutti.main.action.updateApplication.tip"));
- types = ALL_APPLICATION_TYPES;
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
}
protected TuttiApplicationUpdaterCallBack.UpdateType[] types;
@@ -76,18 +69,6 @@
// check application url is reachable
TuttiUIContext context = getContext();
doAction = context.checkUpdateApplicationReachable();
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateApplicationUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
}
return doAction;
}
@@ -95,7 +76,7 @@
@Override
public void releaseAction() {
super.releaseAction();
- types = ALL_APPLICATION_TYPES;
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,16 +25,18 @@
*/
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
-import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
-import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
import org.nuiton.updater.ApplicationUpdater;
+import javax.swing.JOptionPane;
import java.io.File;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -50,6 +52,8 @@
private static final Log log =
LogFactory.getLog(UpdateDbAction.class);
+ protected ApplicationInfo updateDbVersion;
+
public UpdateDbAction(MainUIHandler handler) {
super(handler, true);
setActionDescription(_("tutti.dbManager.action.upgradeDb.tip"));
@@ -59,24 +63,42 @@
public boolean prepareAction() throws Exception {
boolean doAction = super.prepareAction();
+ updateDbVersion = null;
+
if (doAction) {
// check db url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDbReachable();
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateDbUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
+ doAction = getContext().checkUpdateDbReachable();
}
+ if (doAction) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDbUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (updateDbVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ doAction = i == JOptionPane.OK_OPTION;
+ }
+ }
return doAction;
}
@@ -96,10 +118,10 @@
ProgressionModel progressionModel = new ProgressionModel();
context.getActionUI().getModel().setProgressionModel(progressionModel);
progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiApplicationUpdaterCallBack callback =
- new TuttiApplicationUpdaterCallBack(this, progressionModel);
- callback.setTypes(TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
ApplicationUpdater up = new ApplicationUpdater();
+
up.update(url,
current,
dest,
@@ -107,24 +129,24 @@
callback,
progressionModel);
- if (callback.isDbInstalled()) {
+ if (callback.isDbUpdated()) {
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.opening"));
+ sendMessage(_("tutti.dbManager.action.upgradeDb.done", updateDbVersion.newVersion));
- getContext().setDbExist(true);
-
- // open db
- TuttiActionHelper.runInternalAction(getHandler(), OpenDbAction.class);
-
- } else if (callback.isDbUpdated()) {
-
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
-
- // open db
- TuttiActionHelper.runInternalAction(getHandler(), OpenDbAction.class);
-
} else {
sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
}
}
+
+ @Override
+ public void postSuccessAction() {
+ handler.reloadDbManagerText();
+ super.postSuccessAction();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -74,9 +74,6 @@
// clean db context
getContext().clearDbContext();
-
- // Close the application, will exit and restart application
- //RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
}
@Override
@@ -86,7 +83,13 @@
sendMessage(_("tutti.flash.info.db.closed", jdbcUrl));
// make sure title is reloaded
- getUI().getHandler().changeTitle();
+ handler.reloadDbManagerText();
+ handler.changeTitle();
}
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-09-25 13:31:19 UTC (rev 1223)
@@ -36,7 +36,6 @@
focusable:false;
contentType: "text/html";
border: {new EmptyBorder(5, 5, 5, 5)};
- text: {handler.updateMessage(model.isDbExist(), model.isDbLoaded())};
}
#installOrReinstallDbButton {
@@ -67,16 +66,6 @@
_help: {"tutti.dbManager.action.openDb.help"};
}
-/*#closeDbButton {
- actionIcon: close-db;
- text: "tutti.dbManager.action.closeDb";
- i18nMnemonic: "tutti.dbManager.action.closeDb.mnemonic";
- visible: {model.isDbLoaded()};
- _tuttiAction: {CloseDbAction.class};
- toolTipText: "tutti.dbManager.action.closeDb.tip";
- _help: {"tutti.dbManager.action.closeDb.help"};
-}*/
-
#upgradeDbButton {
actionIcon: update-referential;
text: "tutti.dbManager.action.upgradeDb";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUIHandler.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -24,18 +24,27 @@
* #L%
*/
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.util.Version;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -43,6 +52,9 @@
*/
public class DbManagerUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, DbManagerUI> {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(DbManagerUIHandler.class);
+
public DbManagerUIHandler(TuttiUIContext context, DbManagerUI ui) {
super(context, ui);
}
@@ -51,32 +63,84 @@
public void beforeInitUI() {
}
- public String updateMessage(boolean dbExist, boolean dbLoaded) {
+ public void updateMessage() {
+
+ boolean dbExist = getContext().isDbExist();
+ boolean dbLoaded = getContext().isDbLoaded();
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Rebuild information text... (dbExist?" + dbExist +
+ "/ dbLoaded?" + dbLoaded + ")");
+ }
+
String message;
if (dbExist) {
- String jdbcUrl = getConfig().getServiceConfig().getPersistenceConfig().getJdbcUrl();
+ TuttiApplicationConfig config = getConfig();
+ String jdbcUrl = config.getServiceConfig().getPersistenceConfig().getJdbcUrl();
+
+ Map<String, String> caracteristics = Maps.newLinkedHashMap();
+
+ String title;
+
+ caracteristics.put(_("tutti.dbManager.caracteristic.url"), jdbcUrl);
+
if (dbLoaded) {
Version dbVersion = getContext().getPersistenceService().getDbVersion();
// db loaded
- message = _("tutti.dbManager.info.db.loaded", jdbcUrl, dbVersion);
+ title = n_("tutti.dbManager.info.db.loaded");
+ caracteristics.put(_("tutti.dbManager.caracteristic.schemaVersion"), dbVersion.toString());
+
} else {
// no db loaded
- message = _("tutti.dbManager.info.no.db.loaded", jdbcUrl);
+ title = n_("tutti.dbManager.info.no.db.loaded");
}
+
+ // get referential version
+
+ if (getContext().checkUpdateDbReachable()) {
+ String urlDb = config.getUpdateDbUrl();
+
+ ApplicationUpdater up = new ApplicationUpdater();
+ Map<String, ApplicationInfo> dbVersions = up.getVersions(urlDb, config.getDataDirectory());
+
+ ApplicationInfo updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ String currentReferentialVersion = updateDbVersion.oldVersion;
+ String newReferentialVersion = updateDbVersion.newVersion;
+ caracteristics.put(_("tutti.dbManager.caracteristic.referentialVersion"), currentReferentialVersion);
+ if (newReferentialVersion != null) {
+ caracteristics.put(_("tutti.dbManager.caracteristic.lastReferentialVersion"), newReferentialVersion);
+ }
+ }
+
+ StringBuilder caracteristicsToString = new StringBuilder("<ul>");
+ for (Map.Entry<String, String> entry : caracteristics.entrySet()) {
+ caracteristicsToString.append("<li>");
+ caracteristicsToString.append(entry.getKey());
+ caracteristicsToString.append(" : <strong>");
+ caracteristicsToString.append(entry.getValue());
+ caracteristicsToString.append("</strong></li>");
+ }
+ caracteristicsToString.append("</ul>");
+
+ message = _(title, caracteristicsToString);
+
} else {
// db does not exist
message = _("tutti.dbManager.info.no.db.exist");
-// ui.getInformationLabel().setText(_(message));
}
- return "<html><body>" + message + "</body></html>";
+ String result = "<html><body>" + message + "</body></html>";
+ getUI().getInformationArea().setText(result);
}
@Override
@@ -102,6 +166,8 @@
}
});
+ updateMessage();
+
SwingUtilities.invokeLater(
new Runnable() {
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -281,14 +281,6 @@
getHandler().getPersistenceService().updateSchema();
sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
-
- // reload a special databinding (dbLoaded)
- AbstractTuttiUIHandler currentHandler = getHandler().getCurrentHandler();
- if (currentHandler instanceof DbManagerUIHandler) {
- DbManagerUIHandler dbManagerUIHandler = (DbManagerUIHandler) currentHandler;
- dbManagerUIHandler.getUI().applyDataBinding(DbManagerUI.BINDING_INFORMATION_AREA_TEXT);
-
- }
}
// ------------------------------------------------------------------ //
@@ -308,6 +300,8 @@
@Override
public void postSuccessAction() {
+ handler.reloadDbManagerText();
+
super.postSuccessAction();
if (closeDb) {
@@ -319,4 +313,11 @@
// make sure title is reloaded
getUI().getHandler().changeTitle();
}
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -26,7 +26,7 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
@@ -70,21 +70,7 @@
if (doAction) {
// check db url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDbReachable();
-
-// TuttiApplicationConfig config = context.getConfig();
-// String url = config.getUpdateDbUrl();
-//
-// try {
-// TuttiUIUtil.tryToConnectToUpdateUrl(
-// url,
-// n_("tutti.error.update.could.not.reach.url")
-// );
-// } catch (TuttiBusinessException e) {
-// TuttiUIContext.getErrorHelper().showWarningDialog(e.getMessage());
-// doAction = false;
-// }
+ doAction = getContext().checkUpdateDbReachable();
}
if (doAction) {
@@ -118,9 +104,8 @@
File dest = new File(config.getTuttiBasedir(), "NEW");
progressionModel.increments(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiApplicationUpdaterCallBack callback =
- new TuttiApplicationUpdaterCallBack(this, progressionModel);
- callback.setTypes(TuttiApplicationUpdaterCallBack.UpdateType.DB);
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
ApplicationUpdater up = new ApplicationUpdater();
up.update(url,
current,
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-09-25 13:31:19 UTC (rev 1223)
@@ -28,7 +28,9 @@
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
@@ -36,11 +38,14 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiUIAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
import org.nuiton.util.Version;
import javax.swing.JOptionPane;
import java.io.File;
import java.util.Date;
+import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -63,15 +68,23 @@
protected boolean updateSchema;
+ protected boolean updateReferentiel;
+
protected boolean closeDb;
protected String jdbcUrl;
+ protected ApplicationInfo updateDbVersion;
+
public OpenDbAction(MainUIHandler handler) {
super(handler, true, TuttiScreen.SELECT_CRUISE);
setActionDescription(_("tutti.dbManager.action.openDb.tip"));
}
+ public void setUpdateReferentiel(boolean updateReferentiel) {
+ this.updateReferentiel = updateReferentiel;
+ }
+
@Override
public boolean prepareAction() throws Exception {
@@ -81,6 +94,40 @@
dbVersion = applicationVersion = null;
file = null;
closeDb = updateSchema = false;
+ updateDbVersion = null;
+
+ updateReferentiel &= getContext().checkUpdateDbReachable();
+
+ if (updateReferentiel) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDbUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (updateDbVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ updateReferentiel = i == JOptionPane.OK_OPTION;
+ }
+
+ }
}
return canContinue;
}
@@ -97,7 +144,7 @@
// at the beginning 3 steps (open db + check version + check db context)
ProgressionModel progressionModel = new ProgressionModel();
setProgressionModel(progressionModel);
- progressionModel.setTotal(3);
+ progressionModel.setTotal(3 + (updateReferentiel ? 1 : 0));
// ------------------------------------------------------------------ //
// --- open db //
@@ -140,6 +187,7 @@
log.info("Detected schema application version:" + applicationVersion);
}
+ TuttiApplicationConfig config = getConfig();
if (dbVersion.equals(applicationVersion)) {
// database schema is up to date
@@ -172,7 +220,7 @@
// ask user file where to backup db
file = saveFile(
- getConfig().getServiceConfig().getPersistenceConfig().getDbBackupDirectory(),
+ config.getServiceConfig().getPersistenceConfig().getDbBackupDirectory(),
"tutti-db-" + ExportDbAction.df.format(new Date()),
"zip",
_("tutti.dbManager.title.choose.dbBackupFile"),
@@ -249,6 +297,39 @@
getHandler().getPersistenceService().updateSchema();
}
+ if (updateReferentiel) {
+
+ // ------------------------------------------------------------------ //
+ // --- update referentiel //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.openDb.step.updateReferential"));
+
+ File current = config.getDataDirectory();
+ String url = config.getUpdateDbUrl();
+
+ File dest = new File(config.getTuttiBasedir(), "NEW");
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isDbUpdated()) {
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
+
+ } else {
+ sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
+ }
+ }
+
// ------------------------------------------------------------------ //
// --- check db context //
// ------------------------------------------------------------------ //
@@ -269,8 +350,10 @@
@Override
public void postSuccessAction() {
+ handler.reloadDbManagerText();
+
// make sure title is reloaded
- getUI().getHandler().changeTitle();
+ handler.changeTitle();
if (closeDb) {
sendMessage(_("tutti.flash.info.db.not.opened", jdbcUrl));
@@ -284,4 +367,12 @@
sendMessage(_("tutti.flash.info.db.opened", jdbcUrl));
}
}
+
+ @Override
+ public void postFailedAction(Throwable error) {
+
+ handler.reloadDbManagerText();
+
+ super.postFailedAction(error);
+ }
}
\ No newline at end of file
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-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,6 +25,7 @@
tutti.applicationUpdater.synchroDB.prepare.error=
tutti.applicationUpdater.synchroDB.synchro.error=
tutti.applicationUpdater.synchroDB.writeVersion.error=
+tutti.applicationUpdater.updateDone.deleteDirectory.caches.error=
tutti.applicationUpdater.updateDone.deleteDirectory.dbConf.error=
tutti.applicationUpdater.updateDone.deleteDirectory.enum.error=
tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error=
@@ -63,6 +64,7 @@
tutti.common.askBeforeEditProtocol.help=
tutti.common.askBeforeEditProtocol.title=
tutti.common.askBeforeImportProtocol.help=
+tutti.common.askBeforeUpdate.help=
tutti.common.askCancelEditBeforeLeaving.help=
tutti.common.askCancelEditBeforeLeaving.title=
tutti.common.askOverwriteFile.help=
@@ -294,6 +296,7 @@
tutti.dbManager.action.reinstallDb.tip=
tutti.dbManager.action.upgradeDb=
tutti.dbManager.action.upgradeDb.check=
+tutti.dbManager.action.upgradeDb.done=
tutti.dbManager.action.upgradeDb.mnemonic=
tutti.dbManager.action.upgradeDb.no.backup.db.choosen=
tutti.dbManager.action.upgradeDb.opening=
@@ -306,6 +309,10 @@
tutti.dbManager.action.upgradeDb.schema.version.not.found=
tutti.dbManager.action.upgradeDb.tip=
tutti.dbManager.action.upgradeDb.upToDate=
+tutti.dbManager.caracteristic.lastReferentialVersion=
+tutti.dbManager.caracteristic.referentialVersion=
+tutti.dbManager.caracteristic.schemaVersion=
+tutti.dbManager.caracteristic.url=
tutti.dbManager.info.db.loaded=
tutti.dbManager.info.no.db.exist=
tutti.dbManager.info.no.db.loaded=
@@ -313,7 +320,9 @@
tutti.dbManager.title.choose.dbBackupFile=
tutti.dbManager.title.choose.dbExportFile=
tutti.dbManager.title.choose.dbImportFile=
+tutti.dbManager.title.confirm.updatedb=
tutti.dbManager.title.schema.toupdate=
+tutti.dbManager.updatedb.found=
tutti.editAccidentalBatch.action.createBatch=
tutti.editAccidentalBatch.action.createBatch.mnemonic=
tutti.editAccidentalBatch.action.createBatch.tip=
@@ -922,6 +931,7 @@
tutti.editSpeciesBatch.action.splitBatch=
tutti.editSpeciesBatch.action.splitBatch.mnemonic=
tutti.editSpeciesBatch.action.splitBatch.tip=
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=
tutti.editSpeciesBatch.field.speciesTotalInertWeight=
tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip=
tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight=
@@ -951,6 +961,7 @@
tutti.editSpeciesBatch.table.header.species=
tutti.editSpeciesBatch.table.header.toConfirm=
tutti.editSpeciesBatch.table.header.weight=
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=
tutti.editSpeciesFrequencies.action.cancel=
tutti.editSpeciesFrequencies.action.cancel.mnemonic=
tutti.editSpeciesFrequencies.action.cancel.tip=
@@ -1239,6 +1250,7 @@
tutti.openDb.step.check.dbContext=
tutti.openDb.step.checkSchemaVersion=
tutti.openDb.step.open=
+tutti.openDb.step.updateReferential=
tutti.openDb.step.will.migrateSchema=
tutti.option.cancel=
tutti.option.cleanAndClone=
@@ -1353,6 +1365,7 @@
tutti.splitSpeciesBatch.table.header.weight=
tutti.splitSpeciesBatch.title=
tutti.timeeditor.H=
+tutti.update.=
tutti.update.db=
tutti.update.help=
tutti.update.i18n=
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-09-25 10:48:17 UTC (rev 1222)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 13:31:19 UTC (rev 1223)
@@ -25,6 +25,7 @@
tutti.applicationUpdater.synchroDB.prepare.error=Erreur lors de la préparation de la synchronisation de la base
tutti.applicationUpdater.synchroDB.synchro.error=Erreur lors de la synchronisation de la base
tutti.applicationUpdater.synchroDB.writeVersion.error=Erreur lors de l'écriture de la nouvelle version de la base de données dans le fichier %s
+tutti.applicationUpdater.updateDone.deleteDirectory.caches.error=Erreur lors de la suppression du dossier des caches
tutti.applicationUpdater.updateDone.deleteDirectory.dbConf.error=Erreur lors de la suppression du dossier de configuration de base de données
tutti.applicationUpdater.updateDone.deleteDirectory.enum.error=Erreur lors de la suppression du dossier d'énumération
tutti.applicationUpdater.updateDone.deleteDirectory.i18n.error=Erreur lors de la suppression du dossier d'internationalisation
@@ -63,6 +64,7 @@
tutti.common.askBeforeEditProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas éditer le protocole</li><li><strong>Éditer</strong> pour éditer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Éditer</strong> pour supprimer les catégories non compatibles et éditer le protocole</li></ul>
tutti.common.askBeforeEditProtocol.title=Catégories non compatibles détectées dans le protocole
tutti.common.askBeforeImportProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas importer le protocole</li><li><strong>Importer</strong> pour importer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Importer</strong> pour supprimer les catégories non compatibles dans le protocole importé</li></ul>
+tutti.common.askBeforeUpdate.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas effectuer la mise à jour</li><li><strong>OK</strong> pour lancer la mise à jour</li></ul>
tutti.common.askCancelEditBeforeLeaving.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>OK</strong> pour quitter l'écran en abandonnant les modifications</li></ul>
tutti.common.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides
tutti.common.askOverwriteFile.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas écraser le fichier et annuler l'opération</li><li><strong>Oui</strong> pour écraser le fichier et continuer l'opération</li></ul>
@@ -293,6 +295,7 @@
tutti.dbManager.action.reinstallDb.tip=Télécharger puis ré-installer la base de données
tutti.dbManager.action.upgradeDb=Mettre à jour les référentiels
tutti.dbManager.action.upgradeDb.check=Recherche des mises à jour de la base
+tutti.dbManager.action.upgradeDb.done=La mise à jour des référentiel en version <strong>%s</strong> est terminée.
tutti.dbManager.action.upgradeDb.mnemonic=V
tutti.dbManager.action.upgradeDb.no.backup.db.choosen=La base ne sera pas migrée (vous avez annulé la sauvegarde avant migration).
tutti.dbManager.action.upgradeDb.opening=Ouverture de la base de données
@@ -304,15 +307,21 @@
tutti.dbManager.action.upgradeDb.schema.too.high.help=Souhaitez-vous poursuivre l'import de la base de données ?<ul><li><strong>Oui</strong> pour charger la base en version plus récente</li><li><strong>Annuler</strong> pour ne pas charger la base</li></ul>
tutti.dbManager.action.upgradeDb.schema.version.not.found=L'application n'a pas pu déterminer la version de la base de données à importer. L'import ne peut pas être réalisé, veuillez contacter les administrateurs de l'application.
tutti.dbManager.action.upgradeDb.tip=Mettre à jour les référentiels
-tutti.dbManager.action.upgradeDb.upToDate=Aucune mise à jour de base détectée
-tutti.dbManager.info.db.loaded=Tutti est connecté à une base de données<hr/>Caractéristiques de cette base \:<ul><li>Url de connexion \: <strong>%s</strong></li><li>Version\: <strong>%s</strong></li></ul>
+tutti.dbManager.action.upgradeDb.upToDate=<strong>Aucune mise à jour de base détectée</strong>
+tutti.dbManager.caracteristic.lastReferentialVersion=Version du référentiel disponible en mis à jour
+tutti.dbManager.caracteristic.referentialVersion=Version du référentiel utilisé
+tutti.dbManager.caracteristic.schemaVersion=Version du schema
+tutti.dbManager.caracteristic.url=Url de connexion
+tutti.dbManager.info.db.loaded=Tutti est connecté à une base de données<hr/>Caractéristiques de cette base \: %s
tutti.dbManager.info.no.db.exist=Aucune base détectée.<hr/>Vous pouvez installer la dernière disponible sur le réseau via l'action <strong>installer</strong>; ou bien en importer une via l'action <strong>importer</strong>.
-tutti.dbManager.info.no.db.loaded=Une base a été détectée (<strong>%s</strong>).<hr/>La base n'est pas ouverte, vous pouvez l'ouvrir via l'action <strong>Ouvrir</strong>.<br/>Si l'ouverture ne fonctionne pas; veuillez bien prendre soin de quitter les applications qui pourraient utiliser cette base.
+tutti.dbManager.info.no.db.loaded=Une base a été détectée.<hr/>La base n'est pas ouverte, vous pouvez l'ouvrir via l'action <strong>Ouvrir</strong>.<br/>Si l'ouverture ne fonctionne pas; veuillez bien prendre soin de quitter les applications qui pourraient utiliser cette base.<br/>Caractéristiques de cette base \: %s
tutti.dbManager.title.backup.db=Sauvegarde de la base
tutti.dbManager.title.choose.dbBackupFile=Sauvegarder la base de données
tutti.dbManager.title.choose.dbExportFile=Exporter la base de données
tutti.dbManager.title.choose.dbImportFile=Importer la base de données
+tutti.dbManager.title.confirm.updatedb=Confirmer la mise à jour des réferentiels
tutti.dbManager.title.schema.toupdate=Mise à jour de la base détéctée
+tutti.dbManager.updatedb.found=Une mise à jour des référentiels (version <strong>%s</strong>) est disponible.
tutti.editAccidentalBatch.action.createBatch=Créer une capture accidentelle
tutti.editAccidentalBatch.action.createBatch.mnemonic=C
tutti.editAccidentalBatch.action.createBatch.tip=Créer une capture accidentelle
@@ -392,7 +401,6 @@
tutti.editBenthosBatch.action.splitBatch.mnemonic=C
tutti.editBenthosBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
-tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editBenthosBatch.field.benthosTotalInertWeight=Poids inerte trié
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=Poids de la fraction inerte restante après le tri du benthos (cailloux, vase, débris coquilliers, etc.)
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -429,7 +437,6 @@
tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné
tutti.editBenthosBatch.table.header.weight.tip=Poids du lot mesuré ou dénombré
tutti.editBenthosBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
-tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editBenthosFrequencies.action.cancel=Annuler
tutti.editBenthosFrequencies.action.cancel.mnemonic=A
tutti.editBenthosFrequencies.action.cancel.tip=Annuler l'édition des mensurations
@@ -925,6 +932,7 @@
tutti.editSpeciesBatch.action.splitBatch=Catégoriser le lot
tutti.editSpeciesBatch.action.splitBatch.mnemonic=C
tutti.editSpeciesBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editSpeciesBatch.field.speciesTotalInertWeight=Poids inerte trié
tutti.editSpeciesBatch.field.speciesTotalInertWeight.tip=Poids de la fraction inerte restante après le tri des espèces (cailloux, vase, débris coquilliers, etc.)
tutti.editSpeciesBatch.field.speciesTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -954,6 +962,7 @@
tutti.editSpeciesBatch.table.header.species=Espèce
tutti.editSpeciesBatch.table.header.toConfirm=A Confirmer
tutti.editSpeciesBatch.table.header.weight=Poids sous-échantillonné
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editSpeciesFrequencies.action.cancel=Annuler
tutti.editSpeciesFrequencies.action.cancel.mnemonic=A
tutti.editSpeciesFrequencies.action.cancel.tip=Annuler l'édition des mensurations
@@ -1079,6 +1088,7 @@
tutti.importDb.step.closeDb=Fermeture de la base
tutti.importDb.step.openDb=Ouverture de la base de données <strong>%s</strong>
tutti.importDb.step.unzipArchive=Décompression de l'archive
+tutti.importDb.step.updateReferential=Mise à jour des référentiels
tutti.importDb.step.will.migrateSchema=Démarrage de la mise à jour du schéma de la base depuis la version %s vers la version %s
tutti.importProtocol.action.success=Protocole [%s] lu depuis le fichier.
tutti.importPupitri.carrouselFile.extension=car
@@ -1243,6 +1253,7 @@
tutti.openDb.step.check.dbContext=Vérification du context de saisie
tutti.openDb.step.checkSchemaVersion=Vérification de la compatibilité de la base
tutti.openDb.step.open=Ouverture de la base <strong>%s</strong>
+tutti.openDb.step.updateReferential=
tutti.openDb.step.will.migrateSchema=Démarrage de la mise à jour du schéma de la base depuis la version %s vers la version %s
tutti.option.cancel=Annuler
tutti.option.cleanAndClone=Nettoyer et Cloner
1
0
r1222 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches: benthos species
by tchemit@users.forge.codelutin.com 25 Sep '13
by tchemit@users.forge.codelutin.com 25 Sep '13
25 Sep '13
Author: tchemit
Date: 2013-09-25 12:48:17 +0200 (Wed, 25 Sep 2013)
New Revision: 1222
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1222
Log:
refs #3315: [CAPTURE] pouvoir modifier la valeur de la cat?\195?\169gorisation d'un lot (fix auto save)
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/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
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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -474,6 +474,12 @@
//-- Other properties --//
//------------------------------------------------------------------------//
+ public BenthosBatchRowModel getFirstAncestor(Integer sampleCategoryId) {
+ SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = getFirstAncestor(sampleCategory);
+ return firstAncestor;
+ }
+
@Override
public boolean isSpeciesToConfirm() {
return speciesToConfirm;
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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -265,30 +265,25 @@
}
/**
- * Update the sample category value of all childs of the given {@code row}.
+ * Update the sample category value of the given {@code row}.
*
- * @param row the row to walk through
+ * @param row the row to walk through
* @param columnIndex index of the column where the sample category is
* @param newValue new sample category value to set
* @since 2.6
*/
public void updateSampleCategorieValue(BenthosBatchRowModel row,
- int sampleCategoryId,
int columnIndex,
Serializable newValue) {
SampleCategoryColumnIdentifier<BenthosBatchRowModel> identifier =
(SampleCategoryColumnIdentifier<BenthosBatchRowModel>) getIdentifier(columnIndex);
- // get the first ancestor using the category to update
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
// set category value
- identifier.setCategoryValue(firstAncestor, newValue);
+ identifier.setCategoryValue(row, newValue);
// update row shell
- updateShell(firstAncestor, columnIndex);
+ updateShell(row, columnIndex);
}
protected void updateShell(BenthosBatchRowModel entry, int columnIndex) {
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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -518,9 +518,13 @@
SampleCategoryModelEntry category =
sampleCategoryModel.getCategoryById(sampleCategoryId);
+ // get the first ancestor row using this category
+ BenthosBatchRowModel firstAncestorRow =
+ row.getFirstAncestor(sampleCategoryId);
+
// get all used values for this category
Set<Serializable> used = getSampleUsedValues(
- row, sampleCategoryId);
+ firstAncestorRow, sampleCategoryId);
if (category.getCaracteristic().isNumericType()) {
@@ -901,11 +905,15 @@
// get his sample category
Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
- SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
- Caracteristic caracteristic = sampleCategory.getCaracteristic();
+ SampleCategoryModelEntry sampleCategoryEntry = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategoryEntry.getCaracteristic();
+ // get the first ancestor row using this category
+ BenthosBatchRowModel firstAncestorRow =
+ selectedRow.getFirstAncestor(sampleCategoryId);
+
// get used values
- Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ Set<Serializable> usedValues = getSampleUsedValues(firstAncestorRow,
sampleCategoryId);
// get the new selected value for this category
@@ -979,10 +987,12 @@
if (selectedItem != null) {
// update rows values
- tableModel.updateSampleCategorieValue(selectedRow,
- sampleCategoryId,
+ tableModel.updateSampleCategorieValue(firstAncestorRow,
columnIndex,
selectedItem);
+
+ // save the first ancestor row with the modified category value
+ saveRow(firstAncestorRow);
}
}
@@ -1364,16 +1374,12 @@
protected Set<Serializable> getSampleUsedValues(BenthosBatchRowModel row,
int sampleCategoryId) {
- // get the first ancestor for the sample category
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
Set<Serializable> usedValues = Sets.newHashSet();
List<BenthosBatchRowModel> childs;
- if (firstAncestor.isBatchRoot()) {
+ if (row.isBatchRoot()) {
// on a root must take all his brothers (but have no common ancestor...)
- Species species = firstAncestor.getSpecies();
+ Species species = row.getSpecies();
childs = Lists.newArrayList();
for (BenthosBatchRowModel rowToScan : getModel().getRows()) {
if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
@@ -1382,7 +1388,7 @@
}
} else {
// on a son, must take all the brother directly from his father
- BenthosBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ BenthosBatchRowModel parentBatch = row.getParentBatch();
childs = parentBatch.getChildBatch();
}
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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -576,6 +576,12 @@
//-- Other properties --//
//------------------------------------------------------------------------//
+ public SpeciesBatchRowModel getFirstAncestor(Integer sampleCategoryId) {
+ SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = getFirstAncestor(sampleCategory);
+ return firstAncestor;
+ }
+
public List<SpeciesBatchRowModel> getChildBatch() {
return childBatch;
}
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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -264,7 +264,7 @@
}
/**
- * Update the sample category value of all childs of the given {@code row}.
+ * Update the sample category value of the given {@code row}.
*
* @param row the row to walk through
* @param columnIndex index of the column where the sample category is
@@ -272,22 +272,17 @@
* @since 2.6
*/
public void updateSampleCategorieValue(SpeciesBatchRowModel row,
- int sampleCategoryId,
int columnIndex,
Serializable newValue) {
SampleCategoryColumnIdentifier<SpeciesBatchRowModel> identifier =
(SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) getIdentifier(columnIndex);
- // get the first ancestor using the category to update
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
-
// set category value
- identifier.setCategoryValue(firstAncestor, newValue);
+ identifier.setCategoryValue(row, newValue);
// update row shell
- updateShell(firstAncestor, columnIndex);
+ updateShell(row, columnIndex);
}
protected void updateShell(SpeciesBatchRowModel entry, 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-09-25 07:22:58 UTC (rev 1221)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 10:48:17 UTC (rev 1222)
@@ -521,9 +521,13 @@
SampleCategoryModelEntry category =
sampleCategoryModel.getCategoryById(sampleCategoryId);
+ // get the first ancestor row using this category
+ SpeciesBatchRowModel firstAncestorRow =
+ row.getFirstAncestor(sampleCategoryId);
+
// get all used values for this category
Set<Serializable> used = getSampleUsedValues(
- row, sampleCategoryId);
+ firstAncestorRow, sampleCategoryId);
if (category.getCaracteristic().isNumericType()) {
@@ -903,11 +907,15 @@
// get his sample category
Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
- SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
- Caracteristic caracteristic = sampleCategory.getCaracteristic();
+ SampleCategoryModelEntry sampleCategoryEntry = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategoryEntry.getCaracteristic();
- // get used values
- Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ // get the first ancestor row using this category
+ SpeciesBatchRowModel firstAncestorRow =
+ selectedRow.getFirstAncestor(sampleCategoryId);
+
+ // get used values of the category
+ Set<Serializable> usedValues = getSampleUsedValues(firstAncestorRow,
sampleCategoryId);
// get the new selected value for this category
@@ -981,10 +989,12 @@
if (selectedItem != null) {
// update rows values
- tableModel.updateSampleCategorieValue(selectedRow,
- sampleCategoryId,
+ tableModel.updateSampleCategorieValue(firstAncestorRow,
columnIndex,
selectedItem);
+
+ // save the first ancestor row with the modified category value
+ saveRow(firstAncestorRow);
}
}
@@ -1367,16 +1377,16 @@
protected Set<Serializable> getSampleUsedValues(SpeciesBatchRowModel row,
int sampleCategoryId) {
- // get the first ancestor for the sample category
- SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
- SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+// // get the first ancestor for the sample category
+// SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+// SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
Set<Serializable> usedValues = Sets.newHashSet();
List<SpeciesBatchRowModel> childs;
- if (firstAncestor.isBatchRoot()) {
+ if (row.isBatchRoot()) {
// on a root must take all his brothers (but have no common ancestor...)
- Species species = firstAncestor.getSpecies();
+ Species species = row.getSpecies();
childs = Lists.newArrayList();
for (SpeciesBatchRowModel rowToScan : getModel().getRows()) {
if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
@@ -1385,7 +1395,7 @@
}
} else {
// on a son, must take all the brother directly from his father
- SpeciesBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ SpeciesBatchRowModel parentBatch = row.getParentBatch();
childs = parentBatch.getChildBatch();
}
1
0
25 Sep '13
Author: tchemit
Date: 2013-09-25 09:22:58 +0200 (Wed, 25 Sep 2013)
New Revision: 1221
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1221
Log:
fixes #3315: [CAPTURE] pouvoir modifier la valeur de la cat?\195?\169gorisation d'un lot
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
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/BenthosBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
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/BenthosBatchUIModel.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/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
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/SpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SampleCategory.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -40,6 +40,8 @@
public static final String PROPERTY_CATEGORY_WEIGHT = "categoryWeight";
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
/**
* Sample category definition.
*
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Sep 24 16:21:02 CEST 2013
+#Tue Sep 24 18:46:35 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -26,8 +26,8 @@
tutti.createIndividualObservationBatch.action.addSpecies.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.action.cancel.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.action.save.help=editFishingOperation.html\#captureObservationsIndividuellesActions
-tutti.createIndividualObservationBatch.action.saveAndClose.help=
-tutti.createIndividualObservationBatch.action.saveAndContinue.help=
+tutti.createIndividualObservationBatch.action.saveAndClose.help=editFishingOperation.html\#captureObservationsIndividuellesActions
+tutti.createIndividualObservationBatch.action.saveAndContinue.help=editFishingOperation.html\#captureObservationsIndividuellesActions
tutti.createIndividualObservationBatch.field.individualObservationLengthStepCaracteristic.help=editFishingOperation.html\#captureObservationsIndividuellesFields
tutti.createIndividualObservationBatch.field.individualObservationSize.help=editFishingOperation.html\#captureObservationsIndividuellesFields
tutti.createIndividualObservationBatch.field.individualObservationSpecies.help=editFishingOperation.html\#captureObservationsIndividuellesFields
@@ -38,9 +38,9 @@
tutti.createMarineLitterBatch.action.saveAndContinue.help=editFishingOperation.html\#captureMacroDechetsActions
tutti.createMarineLitterBatch.field.marineLitterCategory.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.marineLitterWeight.help=
+tutti.createMarineLitterBatch.field.marineLitterWeight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.number.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.weight.help=
+tutti.createMarineLitterBatch.field.weight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.help=editFishingOperation.html\#captureMacroDechets
tutti.createSpeciesBatch.action.addSpecies.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
@@ -68,6 +68,7 @@
tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles
+tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.editFrequencies.help=editFishingOperation.html\#captureBenthosActions
@@ -94,8 +95,8 @@
tutti.editBenthosFrequencies.action.cancel.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.action.generate.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.action.save.help=editFishingOperation.html\#captureBenthosActions
-tutti.editBenthosFrequencies.action.saveAndClose.help=
-tutti.editBenthosFrequencies.action.saveAndContinue.help=
+tutti.editBenthosFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureBenthosActions
+tutti.editBenthosFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureBenthosFields
tutti.editBenthosFrequencies.field.maxStep.help=editFishingOperation.html\#captureBenthosFields
tutti.editBenthosFrequencies.field.minStep.help=editFishingOperation.html\#captureBenthosFields
@@ -231,6 +232,7 @@
tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.help=editSampleCategory.html
+tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -251,10 +253,10 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.reset.help=
+tutti.editSpeciesFrequencies.action.reset.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.save.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.saveAndClose.help=
-tutti.editSpeciesFrequencies.action.saveAndContinue.help=
+tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions
+tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureEspecesMensurationFields
tutti.editSpeciesFrequencies.field.maxStep.help=editFishingOperation.html\#captureEspecesMensurationFields
tutti.editSpeciesFrequencies.field.minStep.help=editFishingOperation.html\#captureEspecesMensurationFields
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1,5 +1,5 @@
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Sep 24 16:21:02 CEST 2013
+#Tue Sep 24 18:46:35 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -37,9 +37,9 @@
tutti.createMarineLitterBatch.action.saveAndContinue.help=editFishingOperation.html\#captureMacroDechetsActions
tutti.createMarineLitterBatch.field.marineLitterCategory.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.marineLitterSizeCategory.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.marineLitterWeight.help=
+tutti.createMarineLitterBatch.field.marineLitterWeight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.field.number.help=editFishingOperation.html\#captureMacroDechetsFields
-tutti.createMarineLitterBatch.field.weight.help=
+tutti.createMarineLitterBatch.field.weight.help=editFishingOperation.html\#captureMacroDechetsFields
tutti.createMarineLitterBatch.help=editFishingOperation.html\#captureMacroDechets
tutti.createSpeciesBatch.action.addSpecies.help=editFishingOperation.html\#captureEspecesCreeLotActions
tutti.createSpeciesBatch.action.cancel.help=editFishingOperation.html\#captureEspecesCreeLotActions
@@ -67,6 +67,7 @@
tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles
+tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions
tutti.editBenthosBatch.action.editFrequencies.help=editFishingOperation.html\#captureBenthosActions
@@ -229,6 +230,7 @@
tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions
tutti.editSampleCategoryModel.help=editSampleCategory.html
+tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -249,7 +251,7 @@
tutti.editSpeciesBatch.help=editFishingOperation.html\#captureEspeces
tutti.editSpeciesFrequencies.action.cancel.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.generate.help=editFishingOperation.html\#captureEspecesMensurationActions
-tutti.editSpeciesFrequencies.action.reset.help=
+tutti.editSpeciesFrequencies.action.reset.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndClose.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.action.saveAndContinue.help=editFishingOperation.html\#captureEspecesMensurationActions
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic.help=editFishingOperation.html\#captureEspecesMensurationFields
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,8 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import java.io.Serializable;
+
/**
* Contract for model using {@link SampleCategory}.
*
@@ -44,6 +46,8 @@
SampleCategory getSampleCategoryById(Integer sampleCategoryId);
+ void setSampleCategoryValue(Integer sampleCategoryId, Serializable value);
+
void setSampleCategoryWeight(Integer sampleCategoryId, Object value);
E getFirstAncestor(SampleCategory<?> entrySampleCategory);
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryColumnIdentifier.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -27,6 +27,8 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import java.io.Serializable;
+
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2
@@ -66,6 +68,11 @@
entry.setSampleCategoryWeight(getSampleCategoryId(), value);
}
+ public void setCategoryValue(R entry, Serializable value) {
+
+ entry.setSampleCategoryValue(getSampleCategoryId(), value);
+ }
+
public Integer getSampleCategoryId() {
return sampleCategoryId;
}
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -324,6 +324,15 @@
}
@Override
+ public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_VALUE, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory);
+ }
+
+ @Override
public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
SampleCategory<?> sampleCategory =
getSampleCategoryById(sampleCategoryId);
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -37,6 +37,7 @@
import org.jdesktop.swingx.table.TableColumnModelExt;
import javax.swing.table.TableColumn;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Set;
@@ -171,19 +172,9 @@
log.debug("First ancestor row: " + firstRowIndex);
}
- // must save this row now
+ // save this row and his shell
+ updateShell(firstAncestor, columnIndex);
- // 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);
}
@@ -253,4 +244,65 @@
}
return result;
}
+
+ /**
+ * Return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ *
+ * @param columnIndex index of the column to look at
+ * @return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ * @since 2.6
+ */
+ public Integer getSampleCategoryId(int columnIndex) {
+ Integer result = null;
+ ColumnIdentifier<BenthosBatchRowModel> identifier = getIdentifier(columnIndex);
+ if (sampleCols.contains(identifier)) {
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> sampleId = (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) identifier;
+ result = sampleId.getSampleCategoryId();
+ }
+ return result;
+ }
+
+ /**
+ * Update the sample category value of all childs of the given {@code row}.
+ *
+ * @param row the row to walk through
+ * @param columnIndex index of the column where the sample category is
+ * @param newValue new sample category value to set
+ * @since 2.6
+ */
+ public void updateSampleCategorieValue(BenthosBatchRowModel row,
+ int sampleCategoryId,
+ int columnIndex,
+ Serializable newValue) {
+
+ SampleCategoryColumnIdentifier<BenthosBatchRowModel> identifier =
+ (SampleCategoryColumnIdentifier<BenthosBatchRowModel>) getIdentifier(columnIndex);
+
+ // get the first ancestor using the category to update
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ // set category value
+ identifier.setCategoryValue(firstAncestor, newValue);
+
+ // update row shell
+ updateShell(firstAncestor, columnIndex);
+ }
+
+ protected void updateShell(BenthosBatchRowModel entry, int columnIndex) {
+
+ Set<BenthosBatchRowModel> shell = Sets.newHashSet();
+ entry.collectShell(shell);
+ shell.add(entry);
+
+ for (BenthosBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-25 07:22:58 UTC (rev 1221)
@@ -186,6 +186,15 @@
_help: {"tutti.editBenthosBatch.action.splitBatch.help"};
}
+#changeSampleCategoryMenu {
+ actionIcon: batch-split;
+ text: "tutti.editBenthosBatch.action.changeSampleCategory";
+ toolTipText: "tutti.editBenthosBatch.action.changeSampleCategory.tip";
+ i18nMnemonic: "tutti.editBenthosBatch.action.changeSampleCategory.mnemonic";
+ enabled: {model.isTableViewModeAll() && model.isChangeSampleCategoryEnabled()};
+ _help: {"tutti.editBenthosBatch.action.changeSampleCategory.help"};
+}
+
#removeBenthosBatchMenu {
actionIcon: batch-delete;
text: "tutti.editBenthosBatch.action.removeBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-09-25 07:22:58 UTC (rev 1221)
@@ -77,6 +77,8 @@
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitBenthosBatchMenu'
onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='changeSampleCategoryMenu'
+ onActionPerformed='handler.changeBatchCategory()'/>
<JMenuItem id='removeBenthosBatchMenu'/>
<JMenuItem id='removeBenthosSubBatchMenu'/>
<JMenuItem id='renameBenthosBatchMenu'/>
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -36,6 +37,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
@@ -68,6 +70,8 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.NumberEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -83,6 +87,7 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
@@ -241,7 +246,6 @@
}
model.setRows(rows);
- recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -320,9 +324,6 @@
}
saveRow(firstAncestorRow);
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
-
cleanrRowMonitor();
return;
@@ -333,9 +334,6 @@
}
saveSelectedRowIfNeeded();
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
}
@Override
@@ -380,28 +378,6 @@
}
@Override
- protected void onRowValidStateChanged(int rowIndex,
- BenthosBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex,
- BenthosBatchRowModel oldRow,
- int newRowIndex,
- BenthosBatchRowModel newRow) {
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
-
- // when selected row has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
protected void addHighlighters(JXTable table) {
super.addHighlighters(table);
@@ -473,6 +449,163 @@
table.addHighlighter(attachmentHighlighter);
}
+ @Override
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+ super.beforeOpenPopup(rowIndex, columnIndex);
+
+ boolean enableAdd = true;
+
+ boolean enableRename = false;
+ boolean enableSplit = false;
+ boolean enableChangeSampleCategory = false;
+ boolean enableRemove = false;
+ boolean enableRemoveSub = false;
+ boolean enableCreateMelag = false;
+ boolean enableEditFrequencies = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ BenthosBatchTableModel tableModel = getTableModel();
+ BenthosBatchRowModel row = tableModel.getEntry(rowIndex);
+ int selectedRowCount = getTable().getSelectedRowCount();
+
+ // can edit frequencies on a single selected leaf row
+
+
+ enableSplit = true;
+
+ // action with single selection
+ enableRemove = selectedRowCount == 1;
+ enableRemoveSub = selectedRowCount == 1;
+ enableRename = selectedRowCount == 1;
+ enableCreateMelag = selectedRowCount > 1;
+ enableEditFrequencies = selectedRowCount == 1;
+ enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex);
+
+ if (enableSplit) {
+
+ // can split if selected batch is a leaf
+
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
+
+ enableSplit = row.isBatchLeaf()
+ && selectedRowCount == 1
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
+ && row.getNumber() == null
+ && (row.getComputedNumber() == null
+ || row.getComputedNumber() == 0);
+ }
+
+ if (enableChangeSampleCategory) {
+
+ // can change category if there is still a brother category free
+ Integer sampleCategoryId =
+ tableModel.getSampleCategoryId(columnIndex);
+
+ if (sampleCategoryId == null) {
+
+ // not on a sample category column
+ enableChangeSampleCategory = false;
+ } else {
+
+ // get category
+ SampleCategoryModelEntry category =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+
+ // get all used values for this category
+ Set<Serializable> used = getSampleUsedValues(
+ row, sampleCategoryId);
+
+ if (category.getCaracteristic().isNumericType()) {
+
+ // if number then can always change it
+
+ } else {
+
+ // get all possible values
+
+ List<CaracteristicQualitativeValue> available =
+ Lists.newArrayList(category.getCaracteristic().getQualitativeValue());
+ available.removeAll(used);
+
+ // action possible only if there is still some available values
+ enableChangeSampleCategory = !available.isEmpty();
+ }
+ }
+
+ }
+
+ if (enableEditFrequencies) {
+
+ // can edit frequencies only on a leaf
+ enableEditFrequencies = row.isBatchLeaf();
+ }
+
+ if (enableRename) {
+
+ // can rename if selected batch is a parent
+ enableRename = row.isBatchRoot();
+ }
+
+ if (enableRemove) {
+
+ // can always remove the batch
+ // no more test
+ }
+
+ if (enableRemoveSub) {
+
+ // can remove sub batch if selected batch is not a leaf
+ enableRemoveSub = !row.isBatchLeaf();
+ }
+
+ if (enableCreateMelag) {
+
+ JXTable table = getTable();
+
+ // can add species to a melag if several root are selected
+ int[] selectedRows = table.getSelectedRows();
+ for (int selectedRowIndex : selectedRows) {
+ BenthosBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ if (!selectedRow.isBatchRoot()) {
+ enableCreateMelag = false;
+ break;
+ }
+ }
+ }
+ }
+ BenthosBatchUIModel model = getModel();
+ model.setCreateBatchEnabled(enableAdd);
+ model.setSplitBatchEnabled(enableSplit);
+ model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
+ model.setRemoveBatchEnabled(enableRemove);
+ model.setRemoveSubBatchEnabled(enableRemoveSub);
+ model.setRenameBatchEnabled(enableRename);
+ model.setCreateMelagEnabled(enableCreateMelag);
+ model.setEditFrequenciesEnabled(enableEditFrequencies);
+
+ if (log.isInfoEnabled()) {
+ StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
+ builder.append("\nenableAdd: ").append(enableAdd);
+ builder.append("\nenableSplit: ").append(enableSplit);
+ builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
+ builder.append("\nenableRemove: ").append(enableRemove);
+ builder.append("\nenableRemoveSub: ").append(enableRemoveSub);
+ builder.append("\nenableRename: ").append(enableRename);
+ builder.append("\nenableCreateMelag: ").append(enableCreateMelag);
+ builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies);
+ log.info(builder.toString());
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -686,8 +819,6 @@
);
}
}
-
- recomputeBatchActionEnable();
}
public void editFrequencies() {
@@ -754,6 +885,107 @@
}
}
+ public void changeBatchCategory() {
+
+ // get table model
+ BenthosBatchTableModel tableModel = getTableModel();
+
+ // get selected row
+ int rowIndex = getTable().getSelectedRow();
+
+ // get selected column
+ int columnIndex = getTable().getSelectedColumn();
+
+ // get selected row
+ BenthosBatchRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // get his sample category
+ Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
+ SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategory.getCaracteristic();
+
+ // get used values
+ Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ sampleCategoryId);
+
+ // get the new selected value for this category
+ Serializable selectedItem;
+
+ String categoryDecorated = decorate(caracteristic, DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
+ String dialogTitle = _("tutti.editBenthosBatch.title.changeSampleCategoryValue", categoryDecorated);
+
+ if (caracteristic.isNumericType()) {
+
+ // open a simple number editor
+ NumberEditor editor = new NumberEditor();
+ editor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+ editor.setUseSign(false);
+ editor.setUseFloat(true);
+ editor.setShowPopupButton(false);
+ editor.setShowReset(false);
+
+ int response = JOptionPane.showConfirmDialog(
+ getUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = editor.getModel();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+
+ if (usedValues.contains(selectedItem)) {
+
+ // impossible de choisir cette valeur (déjà utilisée)
+ JOptionPane.showMessageDialog(
+ getTopestUI(),
+ _("tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable", selectedItem, categoryDecorated));
+ selectedItem = null;
+ }
+
+ } else {
+
+ // open a combobox to select new value
+
+ List<CaracteristicQualitativeValue> availableValues =
+ Lists.newArrayList(caracteristic.getQualitativeValue());
+ availableValues.removeAll(usedValues);
+
+ JComboBox editor = new JComboBox();
+ editor.setRenderer(new DecoratorListCellRenderer(getDecorator(CaracteristicQualitativeValue.class, null)));
+ SwingUtil.fillComboBox(editor, availableValues, availableValues.get(0));
+
+ int response = JOptionPane.showConfirmDialog(
+ getTopestUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = (CaracteristicQualitativeValue) editor.getSelectedItem();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("New selected category: " + selectedItem);
+ }
+
+ if (selectedItem != null) {
+
+ // update rows values
+ tableModel.updateSampleCategorieValue(selectedRow,
+ sampleCategoryId,
+ columnIndex,
+ selectedItem);
+ }
+ }
+
public void splitBatch(SampleCategoryModelEntry sampleCategoryDef,
List<SplitBenthosBatchRowModel> rows,
Float totalRowWeight) {
@@ -805,8 +1037,6 @@
BenthosBatchUIModel model = getModel();
model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
-
- recomputeBatchActionEnable();
}
public void updateTotalFromFrequencies(BenthosBatchRowModel row) {
@@ -824,8 +1054,6 @@
}
row.setComputedNumber(totalNumber);
row.getFinestCategory().setOnlyOneFrequency(onlyOneFrequency);
-
- recomputeBatchActionEnable();
}
public void saveRows(Iterable<BenthosBatchRowModel> rows) {
@@ -835,190 +1063,10 @@
}
}
- protected void saveRow(BenthosBatchRowModel row) {
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
-
- Preconditions.checkNotNull(fishingOperation);
- Preconditions.checkNotNull(row.getSpecies());
- Preconditions.checkNotNull(row.getFinestCategory());
- Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
- Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
-
-// SampleCategory<?> sampleCategory = row.getFinestCategory();
-// Preconditions.checkNotNull(sampleCategory);
-// Preconditions.checkNotNull(sampleCategory.getCategoryId());
-// Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
- BenthosBatch entityToSave = row.toEntity();
-
- entityToSave.setFishingOperation(fishingOperation);
-
- BenthosBatchRowModel parent = row.getParentBatch();
- if (parent != null) {
- //FIXME Check no need to convert parent weight ? :(
- entityToSave.setParentBatch(parent.toBean());
- }
-
-// // apply sample category
-// entityToSave.setSampleCategoryId(sampleCategory.getCategoryId());
-// entityToSave.setSampleCategoryValue(sampleCategory.getCategoryValue());
-//
-// // convert sample category weight
-// Float categoryWeight = sampleCategory.getCategoryWeight();
-// entityToSave.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
- if (TuttiEntities.isNew(entityToSave)) {
-
- BenthosBatchRowModel batchParent = row.getParentBatch();
- String parentBatchId = null;
-
- if (batchParent != null) {
- parentBatchId = batchParent.getId();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Persist new species batch with parentId: " +
- parentBatchId);
- }
- entityToSave = persistenceService.createBenthosBatch(entityToSave,
- parentBatchId);
- row.setId(entityToSave.getId());
- } else {
- if (log.isInfoEnabled()) {
- log.info("Persist existing species batch: " + entityToSave.getId() + " (parent : " + entityToSave.getParentBatch() + ")");
- }
- persistenceService.saveBenthosBatch(entityToSave);
- }
-
- List<BenthosFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<BenthosBatchFrequency> frequency =
- BenthosFrequencyRowModel.toEntity(
- frequencyRows,
- entityToSave);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveBenthosBatchFrequency(
- entityToSave.getId(), frequency);
-
- // push it back to row model
- frequencyRows = BenthosFrequencyRowModel.fromEntity(weightUnit, frequency);
- row.setFrequency(frequencyRows);
-
- getModel().fireBatchUpdated(row);
- }
-
public String getFilterBenthosBatchRootButtonText(int rootNumber) {
return _("tutti.editBenthosBatch.filterBatch.mode.root", rootNumber);
}
- protected void recomputeBatchActionEnable() {
-
- int rowIndex = getTable().getSelectedRow();
-
- //TODO Improve this test
- boolean enableAdd = true;
-
- boolean enableRename = false;
- boolean enableSplit = false;
- boolean enableRemove = false;
- boolean enableRemoveSub = false;
- boolean enableCreateMelag = false;
- boolean enableEditFrequencies = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- BenthosBatchTableModel tableModel = getTableModel();
- BenthosBatchRowModel row = tableModel.getEntry(rowIndex);
- int selectedRowCount = getTable().getSelectedRowCount();
-
- // can edit frequencies on a single selected leaf row
-
-
- enableSplit = true;
-
- // action with single selection
- enableRemove = selectedRowCount == 1;
- enableRemoveSub = selectedRowCount == 1;
- enableRename = selectedRowCount == 1;
- enableCreateMelag = selectedRowCount > 1;
- enableEditFrequencies = selectedRowCount == 1;
-
- if (enableSplit) {
-
- // can split if selected batch is a leaf
-
- Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
-
- enableSplit = row.isBatchLeaf()
- && selectedRowCount == 1
- && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
- && row.getNumber() == null
- && (row.getComputedNumber() == null
- || row.getComputedNumber() == 0);
- }
-
- if (enableEditFrequencies) {
-
- // can edit frequencies only on a leaf
- enableEditFrequencies = row.isBatchLeaf();
- }
-
- if (enableRename) {
-
- // can rename if selected batch is a parent
- enableRename = row.isBatchRoot();
- }
-
- if (enableRemove) {
-
- // can always remove the batch
- // no more test
- }
-
- if (enableRemoveSub) {
-
- // can remove sub batch if selected batch is not a leaf
- enableRemoveSub = !row.isBatchLeaf();
- }
-
- if (enableCreateMelag) {
-
- JXTable table = getTable();
-
- // can add species to a melag if several root are selected
- int[] selectedRows = table.getSelectedRows();
- for (int selectedRowIndex : selectedRows) {
- BenthosBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- if (!selectedRow.isBatchRoot()) {
- enableCreateMelag = false;
- break;
- }
- }
- }
- }
-
- BenthosBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
- model.setSplitBatchEnabled(enableSplit);
- model.setRemoveBatchEnabled(enableRemove);
- model.setRemoveSubBatchEnabled(enableRemoveSub);
- model.setRenameBatchEnabled(enableRename);
- model.setCreateMelagEnabled(enableCreateMelag);
- model.setEditFrequenciesEnabled(enableEditFrequencies);
- }
-
public void collectChildren(BenthosBatchRowModel row,
Set<BenthosBatchRowModel> collectedRows) {
@@ -1112,6 +1160,101 @@
return newRow;
}
+ public void removeFromSpeciesUsed(BenthosBatchRowModel row) {
+ Preconditions.checkNotNull(row);
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
+ if (log.isInfoEnabled()) {
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
+ }
+ BenthosBatchUIModel model = getModel();
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
+
+ if (row.isBatchRoot()) {
+ model.setRootNumber(model.getRootNumber() - 1);
+ }
+ }
+
+ public Species openAddSpeciesDialog(String title, List<Species> species) {
+ SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
+ SelectSpeciesUIModel model = dialogContent.getModel();
+ model.setSelectedSpecies(null);
+ model.setSpecies(species);
+
+ openDialog(dialogContent, title, new Dimension(400, 130));
+
+ return model.getSelectedSpecies();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void saveRow(BenthosBatchRowModel row) {
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+
+ Preconditions.checkNotNull(fishingOperation);
+ Preconditions.checkNotNull(row.getSpecies());
+ Preconditions.checkNotNull(row.getFinestCategory());
+ Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
+ Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
+
+ BenthosBatch entityToSave = row.toEntity();
+
+ entityToSave.setFishingOperation(fishingOperation);
+
+ BenthosBatchRowModel parent = row.getParentBatch();
+ if (parent != null) {
+ //FIXME Check no need to convert parent weight ? :(
+ entityToSave.setParentBatch(parent.toBean());
+ }
+
+ if (TuttiEntities.isNew(entityToSave)) {
+
+ BenthosBatchRowModel batchParent = row.getParentBatch();
+ String parentBatchId = null;
+
+ if (batchParent != null) {
+ parentBatchId = batchParent.getId();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Persist new species batch with parentId: " +
+ parentBatchId);
+ }
+ entityToSave = persistenceService.createBenthosBatch(entityToSave,
+ parentBatchId);
+ row.setId(entityToSave.getId());
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("Persist existing species batch: " + entityToSave.getId() + " (parent : " + entityToSave.getParentBatch() + ")");
+ }
+ persistenceService.saveBenthosBatch(entityToSave);
+ }
+
+ List<BenthosFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<BenthosBatchFrequency> frequency =
+ BenthosFrequencyRowModel.toEntity(
+ frequencyRows,
+ entityToSave);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveBenthosBatchFrequency(
+ entityToSave.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = BenthosFrequencyRowModel.fromEntity(weightUnit, frequency);
+ row.setFrequency(frequencyRows);
+
+ getModel().fireBatchUpdated(row);
+ }
+
protected void loadBatchRow(BenthosBatchRowModel parentRow,
BenthosBatchRowModel newRow,
Integer sampleCategoryId,
@@ -1164,23 +1307,6 @@
weightUnit);
}
- public void removeFromSpeciesUsed(BenthosBatchRowModel row) {
- Preconditions.checkNotNull(row);
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
- Preconditions.checkNotNull(firstSampleCategory);
- if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
- }
- BenthosBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
-
- if (row.isBatchRoot()) {
- model.setRootNumber(model.getRootNumber() - 1);
- }
- }
-
protected void addToSpeciesUsed(BenthosBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
@@ -1198,17 +1324,6 @@
model.setRootNumber(model.getRootNumber() + 1);
}
- public Species openAddSpeciesDialog(String title, List<Species> species) {
- SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
- SelectSpeciesUIModel model = dialogContent.getModel();
- model.setSelectedSpecies(null);
- model.setSpecies(species);
-
- openDialog(dialogContent, title, new Dimension(400, 130));
-
- return model.getSelectedSpecies();
- }
-
protected BenthosBatch convertRowToEntity(BenthosBatchRowModel row, boolean convertParent) {
SampleCategory<?> sampleCategory = row.getFinestCategory();
Preconditions.checkNotNull(sampleCategory);
@@ -1236,4 +1351,45 @@
return catchBean;
}
+
+ /**
+ * Return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ *
+ * @param row the row
+ * @param sampleCategoryId id of the sample category to seek in brothers of the given row
+ * @return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ */
+ protected Set<Serializable> getSampleUsedValues(BenthosBatchRowModel row,
+ int sampleCategoryId) {
+
+ // get the first ancestor for the sample category
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ BenthosBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ Set<Serializable> usedValues = Sets.newHashSet();
+ List<BenthosBatchRowModel> childs;
+ if (firstAncestor.isBatchRoot()) {
+
+ // on a root must take all his brothers (but have no common ancestor...)
+ Species species = firstAncestor.getSpecies();
+ childs = Lists.newArrayList();
+ for (BenthosBatchRowModel rowToScan : getModel().getRows()) {
+ if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
+ childs.add(rowToScan);
+ }
+ }
+ } else {
+ // on a son, must take all the brother directly from his father
+ BenthosBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ childs = parentBatch.getChildBatch();
+ }
+
+ for (BenthosBatchRowModel child : childs) {
+ SampleCategory<?> category = child.getSampleCategoryById(sampleCategoryId);
+ usedValues.add(category.getCategoryValue());
+ }
+ return usedValues;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -51,6 +51,8 @@
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
+ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
+
public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled";
public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled";
@@ -86,6 +88,13 @@
protected boolean splitBatchEnabled;
/**
+ * Can user change a sample category of the selected species batch ?
+ *
+ * @since 2.6
+ */
+ protected boolean changeSampleCategoryEnabled;
+
+ /**
* Can user remove a selected species batch?
*
* @since 0.3
@@ -313,6 +322,15 @@
firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, null, splitBatchEnabled);
}
+ public boolean isChangeSampleCategoryEnabled() {
+ return changeSampleCategoryEnabled;
+ }
+
+ public void setChangeSampleCategoryEnabled(boolean changeSampleCategoryEnabled) {
+ this.changeSampleCategoryEnabled = changeSampleCategoryEnabled;
+ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled);
+ }
+
public boolean isRemoveBatchEnabled() {
return removeBatchEnabled;
}
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -475,6 +475,15 @@
}
@Override
+ public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) {
+ SampleCategory<?> sampleCategory =
+ getSampleCategoryById(sampleCategoryId);
+ TuttiUIUtil.setProperty(sampleCategory,
+ SampleCategory.PROPERTY_CATEGORY_VALUE, value);
+ firePropertyChange(PROPERTY_SAMPLE_CATEGORY_VALUE, null, sampleCategory);
+ }
+
+ @Override
public void setSampleCategoryWeight(Integer sampleCategoryId, Object value) {
SampleCategory<?> sampleCategory =
getSampleCategoryById(sampleCategoryId);
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -37,6 +37,7 @@
import org.jdesktop.swingx.table.TableColumnModelExt;
import javax.swing.table.TableColumn;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Set;
@@ -170,19 +171,9 @@
log.debug("First ancestor row: " + firstRowIndex);
}
- // must save this row now
+ // save this row and his shell
+ updateShell(firstAncestor, columnIndex);
- // 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);
}
@@ -252,4 +243,65 @@
}
return result;
}
+
+ /**
+ * Return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ *
+ * @param columnIndex index of the column to look at
+ * @return the sample category id of a column or {@code null} if not on a
+ * sample category column.
+ * @since 2.6
+ */
+ public Integer getSampleCategoryId(int columnIndex) {
+ Integer result = null;
+ ColumnIdentifier<SpeciesBatchRowModel> identifier = getIdentifier(columnIndex);
+ if (sampleCols.contains(identifier)) {
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> sampleId = (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) identifier;
+ result = sampleId.getSampleCategoryId();
+ }
+ return result;
+ }
+
+ /**
+ * Update the sample category value of all childs of the given {@code row}.
+ *
+ * @param row the row to walk through
+ * @param columnIndex index of the column where the sample category is
+ * @param newValue new sample category value to set
+ * @since 2.6
+ */
+ public void updateSampleCategorieValue(SpeciesBatchRowModel row,
+ int sampleCategoryId,
+ int columnIndex,
+ Serializable newValue) {
+
+ SampleCategoryColumnIdentifier<SpeciesBatchRowModel> identifier =
+ (SampleCategoryColumnIdentifier<SpeciesBatchRowModel>) getIdentifier(columnIndex);
+
+ // get the first ancestor using the category to update
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ // set category value
+ identifier.setCategoryValue(firstAncestor, newValue);
+
+ // update row shell
+ updateShell(firstAncestor, columnIndex);
+ }
+
+ protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) {
+
+ Set<SpeciesBatchRowModel> shell = Sets.newHashSet();
+ entry.collectShell(shell);
+ shell.add(entry);
+
+ for (SpeciesBatchRowModel batchRowModel : shell) {
+ int currentRowIndex = getRowIndex(batchRowModel);
+ if (log.isDebugEnabled()) {
+ log.debug("Update shell row: " + currentRowIndex);
+ }
+ fireTableCellUpdated(currentRowIndex, columnIndex);
+ }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-25 07:22:58 UTC (rev 1221)
@@ -162,6 +162,15 @@
_help: {"tutti.editSpeciesBatch.action.splitBatch.help"};
}
+#changeSampleCategoryMenu {
+ actionIcon: batch-split;
+ text: "tutti.editSpeciesBatch.action.changeSampleCategory";
+ toolTipText: "tutti.editSpeciesBatch.action.changeSampleCategory.tip";
+ i18nMnemonic: "tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic";
+ enabled: {model.isTableViewModeAll() && model.isChangeSampleCategoryEnabled()};
+ _help: {"tutti.editSpeciesBatch.action.changeSampleCategory.help"};
+}
+
#removeSpeciesBatchMenu {
actionIcon: batch-delete;
text: "tutti.editSpeciesBatch.action.removeBatch";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-09-25 07:22:58 UTC (rev 1221)
@@ -78,6 +78,8 @@
<JPopupMenu id='tablePopup'>
<JMenuItem id='splitSpeciesBatchMenu'
onActionPerformed='handler.splitBatch()'/>
+ <JMenuItem id='changeSampleCategoryMenu'
+ onActionPerformed='handler.changeBatchCategory()'/>
<JMenuItem id='removeSpeciesBatchMenu'/>
<JMenuItem id='removeSpeciesSubBatchMenu'/>
<JMenuItem id='renameSpeciesBatchMenu'/>
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -36,6 +37,7 @@
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.DecoratorService;
@@ -54,6 +56,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.WeightUnit;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
@@ -66,6 +69,8 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.NumberEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -81,6 +86,7 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.validator.NuitonValidatorResult;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.RowFilter;
@@ -247,7 +253,6 @@
}
model.setRows(rows);
- recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -321,9 +326,6 @@
}
saveRow(firstAncestorRow);
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
-
cleanrRowMonitor();
return;
@@ -334,9 +336,6 @@
}
saveSelectedRowIfNeeded();
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
}
@Override
@@ -381,28 +380,6 @@
}
@Override
- protected void onRowValidStateChanged(int rowIndex,
- SpeciesBatchRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
-
- // when row valid state has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex,
- SpeciesBatchRowModel oldRow,
- int newRowIndex,
- SpeciesBatchRowModel newRow) {
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
-
- // when selected row has changed, recompute action enabled states
- recomputeBatchActionEnable();
- }
-
- @Override
protected void addHighlighters(JXTable table) {
super.addHighlighters(table);
@@ -475,6 +452,163 @@
table.addHighlighter(attachmentHighlighter);
}
+ @Override
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+ super.beforeOpenPopup(rowIndex, columnIndex);
+
+ boolean enableAdd = true;
+
+ boolean enableRename = false;
+ boolean enableSplit = false;
+ boolean enableChangeSampleCategory = false;
+ boolean enableRemove = false;
+ boolean enableRemoveSub = false;
+ boolean enableCreateMelag = false;
+ boolean enableEditFrequencies = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+ SpeciesBatchRowModel row = tableModel.getEntry(rowIndex);
+ int selectedRowCount = getTable().getSelectedRowCount();
+
+ // can edit frequencies on a single selected leaf row
+
+
+ enableSplit = true;
+
+ // action with single selection
+ enableRemove = selectedRowCount == 1;
+ enableRemoveSub = selectedRowCount == 1;
+ enableRename = selectedRowCount == 1;
+ enableCreateMelag = selectedRowCount > 1;
+ enableEditFrequencies = selectedRowCount == 1;
+ enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex);
+
+ if (enableSplit) {
+
+ // can split if selected batch is a leaf
+
+ Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
+
+ enableSplit = row.isBatchLeaf()
+ && selectedRowCount == 1
+ && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
+ && row.getNumber() == null
+ && (row.getComputedNumber() == null
+ || row.getComputedNumber() == 0);
+ }
+
+ if (enableChangeSampleCategory) {
+
+ // can change category if there is still a brother category free
+ Integer sampleCategoryId =
+ tableModel.getSampleCategoryId(columnIndex);
+
+ if (sampleCategoryId == null) {
+
+ // not on a sample category column
+ enableChangeSampleCategory = false;
+ } else {
+
+ // get category
+ SampleCategoryModelEntry category =
+ sampleCategoryModel.getCategoryById(sampleCategoryId);
+
+ // get all used values for this category
+ Set<Serializable> used = getSampleUsedValues(
+ row, sampleCategoryId);
+
+ if (category.getCaracteristic().isNumericType()) {
+
+ // if number then can always change it
+
+ } else {
+
+ // get all possible values
+
+ List<CaracteristicQualitativeValue> available =
+ Lists.newArrayList(category.getCaracteristic().getQualitativeValue());
+ available.removeAll(used);
+
+ // action possible only if there is still some available values
+ enableChangeSampleCategory = !available.isEmpty();
+ }
+ }
+
+ }
+
+ if (enableEditFrequencies) {
+
+ // can edit frequencies only on a leaf
+ enableEditFrequencies = row.isBatchLeaf();
+ }
+
+ if (enableRename) {
+
+ // can rename if selected batch is a parent
+ enableRename = row.isBatchRoot();
+ }
+
+ if (enableRemove) {
+
+ // can always remove the batch
+ // no more test
+ }
+
+ if (enableRemoveSub) {
+
+ // can remove sub batch if selected batch is not a leaf
+ enableRemoveSub = !row.isBatchLeaf();
+ }
+
+ if (enableCreateMelag) {
+
+ JXTable table = getTable();
+
+ // can add species to a melag if several root are selected
+ int[] selectedRows = table.getSelectedRows();
+ for (int selectedRowIndex : selectedRows) {
+ SpeciesBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ if (!selectedRow.isBatchRoot()) {
+ enableCreateMelag = false;
+ break;
+ }
+ }
+ }
+ }
+ SpeciesBatchUIModel model = getModel();
+ model.setCreateBatchEnabled(enableAdd);
+ model.setSplitBatchEnabled(enableSplit);
+ model.setChangeSampleCategoryEnabled(enableChangeSampleCategory);
+ model.setRemoveBatchEnabled(enableRemove);
+ model.setRemoveSubBatchEnabled(enableRemoveSub);
+ model.setRenameBatchEnabled(enableRename);
+ model.setCreateMelagEnabled(enableCreateMelag);
+ model.setEditFrequenciesEnabled(enableEditFrequencies);
+
+ if (log.isInfoEnabled()) {
+ StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):");
+ builder.append("\nenableAdd: ").append(enableAdd);
+ builder.append("\nenableSplit: ").append(enableSplit);
+ builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory);
+ builder.append("\nenableRemove: ").append(enableRemove);
+ builder.append("\nenableRemoveSub: ").append(enableRemoveSub);
+ builder.append("\nenableRename: ").append(enableRename);
+ builder.append("\nenableCreateMelag: ").append(enableCreateMelag);
+ builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies);
+ log.info(builder.toString());
+ }
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -625,8 +759,6 @@
getTable().setRowFilter(filter);
}
});
-
- recomputeBatchActionEnable();
}
@Override
@@ -689,8 +821,6 @@
);
}
}
-
- recomputeBatchActionEnable();
}
public void editFrequencies() {
@@ -757,6 +887,107 @@
}
}
+ public void changeBatchCategory() {
+
+ // get table model
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ // get selected row
+ int rowIndex = getTable().getSelectedRow();
+
+ // get selected column
+ int columnIndex = getTable().getSelectedColumn();
+
+ // get selected row
+ SpeciesBatchRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // get his sample category
+ Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex);
+ SampleCategoryModelEntry sampleCategory = sampleCategoryModel.getCategoryById(sampleCategoryId);
+ Caracteristic caracteristic = sampleCategory.getCaracteristic();
+
+ // get used values
+ Set<Serializable> usedValues = getSampleUsedValues(selectedRow,
+ sampleCategoryId);
+
+ // get the new selected value for this category
+ Serializable selectedItem;
+
+ String categoryDecorated = decorate(caracteristic, DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
+ String dialogTitle = _("tutti.editSpeciesBatch.title.changeSampleCategoryValue", categoryDecorated);
+
+ if (caracteristic.isNumericType()) {
+
+ // open a simple number editor
+ NumberEditor editor = new NumberEditor();
+ editor.setNumberPattern(TuttiUI.DECIMAL3_PATTERN);
+ editor.setUseSign(false);
+ editor.setUseFloat(true);
+ editor.setShowPopupButton(false);
+ editor.setShowReset(false);
+
+ int response = JOptionPane.showConfirmDialog(
+ getUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = editor.getModel();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+
+ if (usedValues.contains(selectedItem)) {
+
+ // impossible de choisir cette valeur (déjà utilisée)
+ JOptionPane.showMessageDialog(
+ getTopestUI(),
+ _("tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable", selectedItem, categoryDecorated));
+ selectedItem = null;
+ }
+
+ } else {
+
+ // open a combobox to select new value
+
+ List<CaracteristicQualitativeValue> availableValues =
+ Lists.newArrayList(caracteristic.getQualitativeValue());
+ availableValues.removeAll(usedValues);
+
+ JComboBox editor = new JComboBox();
+ editor.setRenderer(new DecoratorListCellRenderer(getDecorator(CaracteristicQualitativeValue.class, null)));
+ SwingUtil.fillComboBox(editor, availableValues, availableValues.get(0));
+
+ int response = JOptionPane.showConfirmDialog(
+ getTopestUI(),
+ editor,
+ dialogTitle,
+ JOptionPane.OK_CANCEL_OPTION);
+
+ if (response == JOptionPane.OK_OPTION) {
+ selectedItem = (CaracteristicQualitativeValue) editor.getSelectedItem();
+ } else {
+ // user cancel selection
+ selectedItem = null;
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("New selected category: " + selectedItem);
+ }
+
+ if (selectedItem != null) {
+
+ // update rows values
+ tableModel.updateSampleCategorieValue(selectedRow,
+ sampleCategoryId,
+ columnIndex,
+ selectedItem);
+ }
+ }
+
public void splitBatch(SampleCategoryModelEntry sampleCategoryDef,
List<SplitSpeciesBatchRowModel> rows,
Float totalRowWeight) {
@@ -808,8 +1039,6 @@
SpeciesBatchUIModel model = getModel();
model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
-
- recomputeBatchActionEnable();
}
public void updateTotalFromFrequencies(SpeciesBatchRowModel row) {
@@ -827,8 +1056,6 @@
}
row.setComputedNumber(totalNumber);
row.getFinestCategory().setOnlyOneFrequency(onlyOneFrequency);
-
- recomputeBatchActionEnable();
}
public void saveRows(Iterable<SpeciesBatchRowModel> rows) {
@@ -838,188 +1065,10 @@
}
}
- protected void saveRow(SpeciesBatchRowModel row) {
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(fishingOperation);
-
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> sampleCategory = row.getFinestCategory();
- Preconditions.checkNotNull(sampleCategory);
- Preconditions.checkNotNull(sampleCategory.getCategoryId());
- Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
- SpeciesBatch catchBean = row.toBean();
-
- // convert weight
- Float weight = catchBean.getWeight();
- catchBean.setWeight(weightUnit.toEntity(weight));
-
- catchBean.setFishingOperation(fishingOperation);
-
- SpeciesBatchRowModel parent = row.getParentBatch();
- if (parent != null) {
- //FIXME Check no need to convert parent weight ? :(
- catchBean.setParentBatch(parent.toBean());
- }
-
- // apply sample category
- catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
- catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
-
- // convert sample category weight
- Float categoryWeight = sampleCategory.getCategoryWeight();
- catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
- if (TuttiEntities.isNew(catchBean)) {
-
- String parentBatchId = null;
- if (parent != null) {
- parentBatchId = parent.getId();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Persist new species batch with parentId: " +
- parentBatchId);
- }
- catchBean = persistenceService.createSpeciesBatch(catchBean,
- parentBatchId);
- row.setId(catchBean.getId());
- } else {
- if (log.isInfoEnabled()) {
- log.info("Persist existing species batch: " + catchBean.getId() + " (parent : " + catchBean.getParentBatch() + ")");
- }
- persistenceService.saveSpeciesBatch(catchBean);
- }
-
- List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
-
- List<SpeciesBatchFrequency> frequency =
- SpeciesFrequencyRowModel.toEntity(
- frequencyRows,
- catchBean);
-
- if (log.isInfoEnabled()) {
- log.info("Will save " + frequency.size() + " frequencies.");
- }
- frequency = persistenceService.saveSpeciesBatchFrequency(
- catchBean.getId(), frequency);
-
- // push it back to row model
- frequencyRows = SpeciesFrequencyRowModel.fromEntity(weightUnit,
- frequency);
- row.setFrequency(frequencyRows);
-
- getModel().fireBatchUpdated(row);
- }
-
public String getFilterSpeciesBatchRootButtonText(int rootNumber) {
return _("tutti.editSpeciesBatch.filterBatch.mode.root", rootNumber);
}
- protected void recomputeBatchActionEnable() {
-
- int rowIndex = getTable().getSelectedRow();
-
- //TODO Improve this test
- boolean enableAdd = true;
-
- boolean enableRename = false;
- boolean enableSplit = false;
- boolean enableRemove = false;
- boolean enableRemoveSub = false;
- boolean enableCreateMelag = false;
- boolean enableEditFrequencies = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- SpeciesBatchTableModel tableModel = getTableModel();
- SpeciesBatchRowModel row = tableModel.getEntry(rowIndex);
- int selectedRowCount = getTable().getSelectedRowCount();
-
- // can edit frequencies on a single selected leaf row
-
-
- enableSplit = true;
-
- // action with single selection
- enableRemove = selectedRowCount == 1;
- enableRemoveSub = selectedRowCount == 1;
- enableRename = selectedRowCount == 1;
- enableCreateMelag = selectedRowCount > 1;
- enableEditFrequencies = selectedRowCount == 1;
-
- if (enableSplit) {
-
- // can split if selected batch is a leaf
- Integer lastSamplingId = sampleCategoryModel.getLastCategoryId();
-
- enableSplit = row.isBatchLeaf()
- && selectedRowCount == 1
- && ObjectUtils.notEqual(lastSamplingId, row.getFinestCategory().getCategoryId())
- && row.getNumber() == null
- && (row.getComputedNumber() == null
- || row.getComputedNumber() == 0);
- }
-
- if (enableEditFrequencies) {
-
- // can edit frequencies only on a leaf
- enableEditFrequencies = row.isBatchLeaf();
- }
-
- if (enableRename) {
-
- // can rename if selected batch is a parent
- enableRename = row.isBatchRoot();
- }
-
- if (enableRemove) {
-
- // can always remove the batch
- // no more test
- }
-
- if (enableRemoveSub) {
-
- // can remove sub batch if selected batch is not a leaf
- enableRemoveSub = !row.isBatchLeaf();
- }
-
- if (enableCreateMelag) {
-
- JXTable table = getTable();
-
- // can add species to a melag if several root are selected
- int[] selectedRows = table.getSelectedRows();
- for (int selectedRowIndex : selectedRows) {
- SpeciesBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- if (!selectedRow.isBatchRoot()) {
- enableCreateMelag = false;
- break;
- }
- }
- }
- }
-
- SpeciesBatchUIModel model = getModel();
- model.setCreateBatchEnabled(enableAdd);
- model.setSplitBatchEnabled(enableSplit);
- model.setRemoveBatchEnabled(enableRemove);
- model.setRemoveSubBatchEnabled(enableRemoveSub);
- model.setRenameBatchEnabled(enableRename);
- model.setCreateMelagEnabled(enableCreateMelag);
- model.setEditFrequenciesEnabled(enableEditFrequencies);
- }
-
public void collectChildren(SpeciesBatchRowModel row,
Set<SpeciesBatchRowModel> collectedRows) {
@@ -1114,6 +1163,113 @@
return newRow;
}
+ public void removeFromSpeciesUsed(SpeciesBatchRowModel row) {
+ Preconditions.checkNotNull(row);
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
+ Preconditions.checkNotNull(firstSampleCategory);
+ if (log.isInfoEnabled()) {
+ log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
+ }
+ SpeciesBatchUIModel model = getModel();
+ model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
+
+ if (row.isBatchRoot()) {
+ model.setRootNumber(model.getRootNumber() - 1);
+ }
+ }
+
+ public Species openAddSpeciesDialog(String title, List<Species> species) {
+ SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
+ SelectSpeciesUIModel model = dialogContent.getModel();
+ model.setSelectedSpecies(null);
+ model.setSpecies(species);
+
+ openDialog(dialogContent, title, new Dimension(400, 130));
+
+ return model.getSelectedSpecies();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void saveRow(SpeciesBatchRowModel row) {
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(fishingOperation);
+
+ Preconditions.checkNotNull(row.getSpecies());
+ SampleCategory<?> sampleCategory = row.getFinestCategory();
+ Preconditions.checkNotNull(sampleCategory);
+ Preconditions.checkNotNull(sampleCategory.getCategoryId());
+ Preconditions.checkNotNull(sampleCategory.getCategoryValue());
+
+ SpeciesBatch catchBean = row.toBean();
+
+ // convert weight
+ Float weight = catchBean.getWeight();
+ catchBean.setWeight(weightUnit.toEntity(weight));
+
+ catchBean.setFishingOperation(fishingOperation);
+
+ SpeciesBatchRowModel parent = row.getParentBatch();
+ if (parent != null) {
+ //FIXME Check no need to convert parent weight ? :(
+ catchBean.setParentBatch(parent.toBean());
+ }
+
+ // apply sample category
+ catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
+ catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
+
+ // convert sample category weight
+ Float categoryWeight = sampleCategory.getCategoryWeight();
+ catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
+
+ if (TuttiEntities.isNew(catchBean)) {
+
+ String parentBatchId = null;
+ if (parent != null) {
+ parentBatchId = parent.getId();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Persist new species batch with parentId: " +
+ parentBatchId);
+ }
+ catchBean = persistenceService.createSpeciesBatch(catchBean,
+ parentBatchId);
+ row.setId(catchBean.getId());
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("Persist existing species batch: " + catchBean.getId() + " (parent : " + catchBean.getParentBatch() + ")");
+ }
+ persistenceService.saveSpeciesBatch(catchBean);
+ }
+
+ List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency();
+
+ List<SpeciesBatchFrequency> frequency =
+ SpeciesFrequencyRowModel.toEntity(
+ frequencyRows,
+ catchBean);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save " + frequency.size() + " frequencies.");
+ }
+ frequency = persistenceService.saveSpeciesBatchFrequency(
+ catchBean.getId(), frequency);
+
+ // push it back to row model
+ frequencyRows = SpeciesFrequencyRowModel.fromEntity(weightUnit,
+ frequency);
+ row.setFrequency(frequencyRows);
+
+ getModel().fireBatchUpdated(row);
+ }
+
protected void loadBatchRow(SpeciesBatchRowModel parentRow,
SpeciesBatchRowModel newRow,
Integer sampleCategoryId,
@@ -1161,29 +1317,11 @@
SampleCategoryComponent.newEditor(decorator, weightUnit),
SampleCategoryComponent.newRender(defaultRenderer,
decorator,
- getConfig().getColorComputedWeights()
- ),
+ getConfig().getColorComputedWeights()),
columnIdentifier,
weightUnit);
}
- public void removeFromSpeciesUsed(SpeciesBatchRowModel row) {
- Preconditions.checkNotNull(row);
- Preconditions.checkNotNull(row.getSpecies());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- CaracteristicQualitativeValue categoryValue = (CaracteristicQualitativeValue) firstSampleCategory.getCategoryValue();
- Preconditions.checkNotNull(firstSampleCategory);
- if (log.isInfoEnabled()) {
- log.info("Remove from speciesUsed: " + decorate(categoryValue) + " - " + decorate(row.getSpecies()));
- }
- SpeciesBatchUIModel model = getModel();
- model.getSpeciesUsed().remove(categoryValue, row.getSpecies());
-
- if (row.isBatchRoot()) {
- model.setRootNumber(model.getRootNumber() - 1);
- }
- }
-
protected void addToSpeciesUsed(SpeciesBatchRowModel row) {
Preconditions.checkNotNull(row);
Preconditions.checkNotNull(row.getSpecies());
@@ -1201,38 +1339,14 @@
model.setRootNumber(model.getRootNumber() + 1);
}
- public Species openAddSpeciesDialog(String title, List<Species> species) {
- SelectSpeciesUI dialogContent = new SelectSpeciesUI(ui);
- SelectSpeciesUIModel model = dialogContent.getModel();
- model.setSelectedSpecies(null);
- model.setSpecies(species);
-
- openDialog(dialogContent, title, new Dimension(400, 130));
-
- return model.getSelectedSpecies();
- }
-
protected SpeciesBatch convertRowToEntity(SpeciesBatchRowModel row,
boolean convertParent) {
Preconditions.checkNotNull(row.getFinestCategory());
Preconditions.checkNotNull(row.getFinestCategory().getCategoryId());
Preconditions.checkNotNull(row.getFinestCategory().getCategoryValue());
-// SampleCategory<?> sampleCategory = row.getFinestCategory();
-// Preconditions.checkNotNull(sampleCategory);
-// Preconditions.checkNotNull(sampleCategory.getCategoryId());
-// Preconditions.checkNotNull(sampleCategory.getCategoryValue());
-
SpeciesBatch catchBean = row.toEntity();
-// // apply sample category
-// catchBean.setSampleCategoryId(sampleCategory.getCategoryId());
-// catchBean.setSampleCategoryValue(sampleCategory.getCategoryValue());
-//
-// // convert sample category weight
-// Float categoryWeight = sampleCategory.getCategoryWeight();
-// catchBean.setSampleCategoryWeight(weightUnit.toEntity(categoryWeight));
-
if (convertParent && row.getParentBatch() != null) {
SpeciesBatch parent = convertRowToEntity(row.getParentBatch(), true);
catchBean.setParentBatch(parent);
@@ -1240,4 +1354,45 @@
return catchBean;
}
+
+ /**
+ * Return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ *
+ * @param row the row
+ * @param sampleCategoryId id of the sample category to seek in brothers of the given row
+ * @return all the sample category values (of the given
+ * {@code sampleCategoryId}) for all brothers of the given {@code row}.
+ */
+ protected Set<Serializable> getSampleUsedValues(SpeciesBatchRowModel row,
+ int sampleCategoryId) {
+
+ // get the first ancestor for the sample category
+ SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId);
+ SpeciesBatchRowModel firstAncestor = row.getFirstAncestor(sampleCategory);
+
+ Set<Serializable> usedValues = Sets.newHashSet();
+ List<SpeciesBatchRowModel> childs;
+ if (firstAncestor.isBatchRoot()) {
+
+ // on a root must take all his brothers (but have no common ancestor...)
+ Species species = firstAncestor.getSpecies();
+ childs = Lists.newArrayList();
+ for (SpeciesBatchRowModel rowToScan : getModel().getRows()) {
+ if (rowToScan.isBatchRoot() && species.equals(rowToScan.getSpecies())) {
+ childs.add(rowToScan);
+ }
+ }
+ } else {
+ // on a son, must take all the brother directly from his father
+ SpeciesBatchRowModel parentBatch = firstAncestor.getParentBatch();
+ childs = parentBatch.getChildBatch();
+ }
+
+ for (SpeciesBatchRowModel child : childs) {
+ SampleCategory<?> category = child.getSampleCategoryById(sampleCategoryId);
+ usedValues.add(category.getCategoryValue());
+ }
+ return usedValues;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -49,6 +49,8 @@
public static final String PROPERTY_SPLIT_BATCH_ENABLED = "splitBatchEnabled";
+ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled";
+
public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled";
public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled";
@@ -86,6 +88,13 @@
protected boolean splitBatchEnabled;
/**
+ * Can user change a sample category of the selected species batch ?
+ *
+ * @since 2.6
+ */
+ protected boolean changeSampleCategoryEnabled;
+
+ /**
* Can user remove a selected species batch?
*
* @since 0.3
@@ -295,6 +304,15 @@
firePropertyChange(PROPERTY_SPLIT_BATCH_ENABLED, null, splitBatchEnabled);
}
+ public boolean isChangeSampleCategoryEnabled() {
+ return changeSampleCategoryEnabled;
+ }
+
+ public void setChangeSampleCategoryEnabled(boolean changeSampleCategoryEnabled) {
+ this.changeSampleCategoryEnabled = changeSampleCategoryEnabled;
+ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled);
+ }
+
public boolean isRemoveBatchEnabled() {
return removeBatchEnabled;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-09-25 07:22:58 UTC (rev 1221)
@@ -1008,12 +1008,16 @@
JXTable source = (JXTable) e.getSource();
int[] selectedRows = source.getSelectedRows();
+ int[] selectedColumns = source.getSelectedColumns();
// get the row index at this point
int rowIndex = source.rowAtPoint(p);
+ // get the column index at this point
+ int columnIndex = source.columnAtPoint(p);
+
if (log.isDebugEnabled()) {
- log.debug("At point [" + p + "] found Row " + rowIndex);
+ log.debug("At point [" + p + "] found Row " + rowIndex + ", Column " + columnIndex);
}
boolean canContinue = true;
@@ -1039,8 +1043,17 @@
source.setRowSelectionInterval(rowIndex, rowIndex);
}
+ // select column (could empty selection)
+ if (columnIndex == -1) {
+ source.clearSelection();
+ } else if (!ArrayUtils.contains(selectedColumns, columnIndex)) {
+ source.setColumnSelectionInterval(columnIndex, columnIndex);
+ }
+
if (rightClick) {
+ beforeOpenPopup(rowIndex, columnIndex);
+
// on right click show popup
popup.show(source, e.getX(), e.getY());
}
@@ -1048,6 +1061,20 @@
}
}
+ /**
+ * Hook to prepare popup just before showing it.
+ * <p/>
+ * The right place to update actions accessibility; a quite better design
+ * than trying to update each time something change in the table...
+ *
+ * @param rowIndex selected row index (or lowest selected one)
+ * @param columnIndex selected column index
+ * @since 2.6
+ */
+ protected void beforeOpenPopup(int rowIndex, int columnIndex) {
+
+ }
+
public void openRowMenu(KeyEvent e, JPopupMenu popup) {
if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
@@ -1061,7 +1088,8 @@
lowestRow = Math.max(lowestRow, row);
}
// get the selected column
- Rectangle r = source.getCellRect(lowestRow, source.getSelectedColumn(), true);
+ int selectedColumn = source.getSelectedColumn();
+ Rectangle r = source.getCellRect(lowestRow, selectedColumn, true);
// get the point in the middle lower of the cell
Point p = new Point(r.x + r.width / 2, r.y + r.height);
@@ -1085,6 +1113,9 @@
}
if (canContinue) {
+
+ beforeOpenPopup(lowestRow, selectedColumn);
+
popup.show(source, p.x, p.y);
}
}
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-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -352,6 +352,9 @@
tutti.editAccidentalBatch.table.header.species.tip=
tutti.editAccidentalBatch.table.header.weight=
tutti.editAccidentalBatch.table.header.weight.tip=
+tutti.editBenthosBatch.action.changeSampleCategory=
+tutti.editBenthosBatch.action.changeSampleCategory.mnemonic=
+tutti.editBenthosBatch.action.changeSampleCategory.tip=
tutti.editBenthosBatch.action.createBatch=
tutti.editBenthosBatch.action.createBatch.mnemonic=
tutti.editBenthosBatch.action.createBatch.tip=
@@ -389,6 +392,7 @@
tutti.editBenthosBatch.action.splitBatch=
tutti.editBenthosBatch.action.splitBatch.mnemonic=
tutti.editBenthosBatch.action.splitBatch.tip=
+tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=
tutti.editBenthosBatch.field.benthosTotalInertWeight=
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=
@@ -424,6 +428,7 @@
tutti.editBenthosBatch.table.header.toConfirm.tip=
tutti.editBenthosBatch.table.header.weight=
tutti.editBenthosBatch.table.header.weight.tip=
+tutti.editBenthosBatch.title.changeSampleCategoryValue=
tutti.editBenthosFrequencies.action.cancel=
tutti.editBenthosFrequencies.action.cancel.mnemonic=
tutti.editBenthosFrequencies.action.cancel.tip=
@@ -868,6 +873,9 @@
tutti.editSampleCategoryModel.table.header.label=
tutti.editSampleCategoryModel.table.header.label.tip=
tutti.editSampleCategoryModel.title=
+tutti.editSpeciesBatch.action.changeSampleCategory=
+tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=
+tutti.editSpeciesBatch.action.changeSampleCategory.tip=
tutti.editSpeciesBatch.action.createBatch=
tutti.editSpeciesBatch.action.createBatch.mnemonic=
tutti.editSpeciesBatch.action.createBatch.tip=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-24 15:43:28 UTC (rev 1220)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-25 07:22:58 UTC (rev 1221)
@@ -351,6 +351,9 @@
tutti.editAccidentalBatch.table.header.species.tip=Espèce
tutti.editAccidentalBatch.table.header.weight=Poids observé
tutti.editAccidentalBatch.table.header.weight.tip=Poids observé
+tutti.editBenthosBatch.action.changeSampleCategory=Modifier la catégorie
+tutti.editBenthosBatch.action.changeSampleCategory.mnemonic=M
+tutti.editBenthosBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée
tutti.editBenthosBatch.action.createBatch=Créer un lot pour une espèce
tutti.editBenthosBatch.action.createBatch.mnemonic=C
tutti.editBenthosBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -388,6 +391,8 @@
tutti.editBenthosBatch.action.splitBatch=Catégoriser le lot
tutti.editBenthosBatch.action.splitBatch.mnemonic=C
tutti.editBenthosBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné)
+tutti.editBenthosBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
+tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée
tutti.editBenthosBatch.field.benthosTotalInertWeight=Poids inerte trié
tutti.editBenthosBatch.field.benthosTotalInertWeight.tip=Poids de la fraction inerte restante après le tri du benthos (cailloux, vase, débris coquilliers, etc.)
tutti.editBenthosBatch.field.benthosTotalLivingNotItemizedWeight=Poids vivant non détaillé trié
@@ -423,12 +428,16 @@
tutti.editBenthosBatch.table.header.toConfirm.tip=Case à cocher si il y a un doute sur l'identification de l'espèce
tutti.editBenthosBatch.table.header.weight=Poids sous-échantillonné
tutti.editBenthosBatch.table.header.weight.tip=Poids du lot mesuré ou dénombré
+tutti.editBenthosBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
+tutti.editSpeciesBatch.title.changeSampleCategoryValue=Changer la valeur de la catégorie %s
tutti.editBenthosFrequencies.action.cancel=Annuler
tutti.editBenthosFrequencies.action.cancel.mnemonic=A
tutti.editBenthosFrequencies.action.cancel.tip=Annuler l'édition des mensurations
tutti.editBenthosFrequencies.action.generate=Générer
tutti.editBenthosFrequencies.action.generate.mnemonic=G
tutti.editBenthosFrequencies.action.generate.tip=Générer les mensurations
+tutti.editBenthosFrequencies.action.reset=Réinitialiser
+tutti.editBenthosFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
tutti.editBenthosFrequencies.action.saveAndClose=Enregistrer et Fermer
tutti.editBenthosFrequencies.action.saveAndClose.mnemonic=F
tutti.editBenthosFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
@@ -867,6 +876,9 @@
tutti.editSampleCategoryModel.table.header.label=Label
tutti.editSampleCategoryModel.table.header.label.tip=Label de la catéogire (sera utilisée dans les entêtes de tableau)
tutti.editSampleCategoryModel.title=Configurer les catégorisations
+tutti.editSpeciesBatch.action.changeSampleCategory=Modifier la catégorie
+tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=M
+tutti.editSpeciesBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée
tutti.editSpeciesBatch.action.createBatch=Créer un lot pour une espèce
tutti.editSpeciesBatch.action.createBatch.mnemonic=C
tutti.editSpeciesBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -951,9 +963,6 @@
tutti.editSpeciesFrequencies.action.reset=Réinitialiser
tutti.editSpeciesFrequencies.action.reset.mnemonic=R
tutti.editSpeciesFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
-tutti.editBenthosFrequencies.action.reset=Réinitialiser
-tutti.editbenthosFrequencies.action.reset.mnemonic=R
-tutti.editBenthosFrequencies.action.reset.tip=Supprimer toutes les mensurations saisies
tutti.editSpeciesFrequencies.action.saveAndClose=Enregistrer et Fermer
tutti.editSpeciesFrequencies.action.saveAndClose.mnemonic=F
tutti.editSpeciesFrequencies.action.saveAndClose.tip=Enregistrer les mensurations
@@ -992,6 +1001,7 @@
tutti.editSpeciesFrequencies.table.header.number=Nombre
tutti.editSpeciesFrequencies.table.header.weight=Poids observé
tutti.editSpeciesFrequencies.title=Mensuration
+tutti.editbenthosFrequencies.action.reset.mnemonic=R
tutti.error.about.could.not.reach.url=Récupération des versions de mises à jour impossible (l'url <strong>%s</strong> n'est pas joignable)
tutti.error.delete.startActionFile=Impossible de supprimer le fichier %s
tutti.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html>
1
0