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
May 2014
- 5 participants
- 105 discussions
Author: tchemit
Date: 2014-05-14 17:10:28 +0200 (Wed, 14 May 2014)
New Revision: 1771
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1771
Log:
use last jaxx release
Modified:
branches/tutti-3.4.x/pom.xml
Modified: branches/tutti-3.4.x/pom.xml
===================================================================
--- branches/tutti-3.4.x/pom.xml 2014-05-14 14:41:51 UTC (rev 1770)
+++ branches/tutti-3.4.x/pom.xml 2014-05-14 15:10:28 UTC (rev 1771)
@@ -140,7 +140,7 @@
<nuitonValidatorVersion>3.0-rc-1</nuitonValidatorVersion>
<eugenePluginVersion>2.7.4</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <jaxxVersion>2.8.5-SNAPSHOT</jaxxVersion>
+ <jaxxVersion>2.8.5</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<slf4jVersion>1.7.5</slf4jVersion>
<adagioVersion>3.4.1</adagioVersion>
1
0
r1770 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: action content/operation
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 16:41:51 +0200 (Wed, 14 May 2014)
New Revision: 1770
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1770
Log:
reports refs #5034 (from version 3.4.2)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java 2014-05-14 14:27:35 UTC (rev 1769)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java 2014-05-14 14:41:51 UTC (rev 1770)
@@ -28,9 +28,14 @@
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
/**
* Opens the operations edition screen.
*
@@ -58,14 +63,23 @@
}
@Override
- public void postFailedAction(Throwable error) {
-// TuttiUIContext context = getContext();
-// if (error != null) {
-// if (context.isDbLoaded()) {
-// context.setScreen(TuttiScreen.SELECT_CRUISE);
-// } else {
-// context.setScreen(TuttiScreen.MANAGE_DB);
-// }
-// }
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+
+ FishingOperationsUI currentBoby = (FishingOperationsUI) getHandler().getCurrentBody();
+ EditFishingOperationUI fishingOperationTabContent = currentBoby.getFishingOperationTabContent();
+
+ JComponent componentToFocus = fishingOperationTabContent.getHandler().getComponentToFocus();
+ componentToFocus.requestFocusInWindow();
+
+ }
+ }
+ );
+
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java 2014-05-14 14:27:35 UTC (rev 1769)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java 2014-05-14 14:41:51 UTC (rev 1770)
@@ -58,9 +58,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -410,6 +412,18 @@
super.postSuccessAction();
final EditFishingOperationUI fishingOperationTabContent = getUI().getFishingOperationTabContent();
fishingOperationTabContent.getModel().setModify(false);
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+
+ JComponent componentToFocus = fishingOperationTabContent.getHandler().getComponentToFocus();
+ componentToFocus.requestFocusInWindow();
+
+ }
+ }
+ );
// SwingUtilities.invokeLater(
// new Runnable() {
// @Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 14:27:35 UTC (rev 1769)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 14:41:51 UTC (rev 1770)
@@ -520,9 +520,7 @@
}
@Override
- protected JComponent getComponentToFocus() {
-
- //TODO
+ public JComponent getComponentToFocus() {
return getUI().getStationNumberField();
}
1
0
14 May '14
Author: tchemit
Date: 2014-05-14 16:27:35 +0200 (Wed, 14 May 2014)
New Revision: 1769
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1769
Log:
fixes #5034 [TRAIT] mettre le curseur (ou focus) sur le champ Code Station ?\195?\160 la cr?\195?\169ation d'un nouveau trait (et pas dans le champ qui porte l'intitul?\195?\169 du trait)
Modified:
branches/tutti-3.4.x/pom.xml
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java
Modified: branches/tutti-3.4.x/pom.xml
===================================================================
--- branches/tutti-3.4.x/pom.xml 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/pom.xml 2014-05-14 14:27:35 UTC (rev 1769)
@@ -140,7 +140,7 @@
<nuitonValidatorVersion>3.0-rc-1</nuitonValidatorVersion>
<eugenePluginVersion>2.7.4</eugenePluginVersion>
<hibernateVersion>3.6.10.Final</hibernateVersion>
- <jaxxVersion>2.8.4</jaxxVersion>
+ <jaxxVersion>2.8.5-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<slf4jVersion>1.7.5</slf4jVersion>
<adagioVersion>3.4.1</adagioVersion>
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -28,9 +28,14 @@
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+
/**
* Opens the operations edition screen.
*
@@ -58,14 +63,24 @@
}
@Override
- public void postFailedAction(Throwable error) {
-// TuttiUIContext context = getContext();
-// if (error != null) {
-// if (context.isDbLoaded()) {
-// context.setScreen(TuttiScreen.SELECT_CRUISE);
-// } else {
-// context.setScreen(TuttiScreen.MANAGE_DB);
-// }
-// }
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+
+ FishingOperationsUI currentBoby = (FishingOperationsUI) getHandler().getCurrentBody();
+ EditFishingOperationUI fishingOperationTabContent = currentBoby.getFishingOperationTabContent();
+
+ JComponent componentToFocus = fishingOperationTabContent.getHandler().getComponentToFocus();
+ componentToFocus.requestFocusInWindow();
+
+ }
+ }
+ );
+
}
+
}
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -58,9 +58,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -410,6 +412,18 @@
super.postSuccessAction();
final EditFishingOperationUI fishingOperationTabContent = getUI().getFishingOperationTabContent();
fishingOperationTabContent.getModel().setModify(false);
+
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+
+ JComponent componentToFocus = fishingOperationTabContent.getHandler().getComponentToFocus();
+ componentToFocus.requestFocusInWindow();
+
+ }
+ }
+ );
// SwingUtilities.invokeLater(
// new Runnable() {
// @Override
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -560,4 +560,8 @@
public void setBodyTitle(String title) {
ui.getBody().setTitle(title);
}
+
+ public JComponent getCurrentBody() {
+ return currentBody;
+ }
}
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -520,7 +520,7 @@
}
@Override
- protected JComponent getComponentToFocus() {
+ public JComponent getComponentToFocus() {
return getUI().getStationNumberField();
}
@@ -583,6 +583,11 @@
return ui.getFishingOperationTabPane();
}
+ @Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- TabHandler methods --//
//------------------------------------------------------------------------//
@@ -652,6 +657,11 @@
registerValidators(ui.getValidator());
}
+ @Override
+ public boolean onRemoveTab() {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -287,6 +287,11 @@
}
@Override
+ public boolean isCloseable() {
+ return false;
+ }
+
+ @Override
public boolean isEmpty() {
boolean result;
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -123,6 +123,8 @@
initUI(this.ui);
+ this.ui.getFishingOperationComboBox().setAutoFocus(false);
+
editFishingOperationAction =
getContext().getActionFactory().createLogicAction(this, EditFishingOperationAction.class);
@@ -269,6 +271,11 @@
return ui.getTabPane();
}
+ @Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -203,6 +203,11 @@
}
@Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
+ @Override
public boolean onTabChanged(int currentIndex, int newIndex) {
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
ui.getComputeSpeciesBatchButton().setVisible(newIndex < 4);
@@ -276,6 +281,11 @@
registerValidators();
}
+ @Override
+ public boolean onRemoveTab() {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -349,6 +349,11 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
// public CatchBatch getCatchBatch() {
// return editObject;
// }
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -91,4 +91,9 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
}
\ No newline at end of file
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -187,6 +187,11 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
public Float getBenthosTotalComputedWeight() {
return catchesUIModel.getBenthosTotalComputedWeight();
}
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -134,4 +134,9 @@
public String getIcon() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -122,4 +122,9 @@
public String getIcon() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
\ No newline at end of file
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -403,6 +403,11 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
public List<SpeciesBatchRowModel> getLeafs(Species species) {
List<SpeciesBatchRowModel> result = Lists.newArrayList();
for (SpeciesBatchRowModel rowModel : getRows()) {
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2014-05-14 13:05:47 UTC (rev 1768)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2014-05-14 14:27:35 UTC (rev 1769)
@@ -117,4 +117,9 @@
protected FishingOperation newEntity() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
1
0
r1768 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: . catches
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 15:05:47 +0200 (Wed, 14 May 2014)
New Revision: 1768
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1768
Log:
updates to jaxx last version
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 12:56:04 UTC (rev 1767)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
@@ -521,6 +521,8 @@
@Override
protected JComponent getComponentToFocus() {
+
+ //TODO
return getUI().getStationNumberField();
}
@@ -583,6 +585,11 @@
return ui.getFishingOperationTabPane();
}
+ @Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- TabHandler methods --//
//------------------------------------------------------------------------//
@@ -658,6 +665,11 @@
}
}
+ @Override
+ public boolean onRemoveTab() {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2014-05-14 12:56:04 UTC (rev 1767)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
@@ -269,6 +269,11 @@
return ui.getTabPane();
}
+ @Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2014-05-14 12:56:04 UTC (rev 1767)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2014-05-14 13:05:47 UTC (rev 1768)
@@ -276,6 +276,16 @@
registerValidators();
}
+ @Override
+ public boolean removeTab(int i) {
+ return false;
+ }
+
+ @Override
+ public boolean onRemoveTab() {
+ return false;
+ }
+
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
1
0
14 May '14
Author: tchemit
Date: 2014-05-14 14:56:04 +0200 (Wed, 14 May 2014)
New Revision: 1767
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1767
Log:
updates to jaxx last version
Modified:
trunk/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.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/individualobservation/IndividualObservationBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.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/content/operation/fishing/AbstractCaracteristicTabUIModel.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/pom.xml 2014-05-14 12:56:04 UTC (rev 1767)
@@ -143,7 +143,7 @@
<nuitonI18nVersion>3.0</nuitonI18nVersion>
<nuitonValidatorVersion>3.0-rc-1</nuitonValidatorVersion>
<eugenePluginVersion>2.9-SNAPSHOT</eugenePluginVersion>
- <jaxxVersion>2.8.4</jaxxVersion>
+ <jaxxVersion>2.8.5-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.4</swingXVersion>
<slf4jVersion>1.7.5</slf4jVersion>
<adagioVersion>3.5.2</adagioVersion>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -287,6 +287,11 @@
}
@Override
+ public boolean isCloseable() {
+ return false;
+ }
+
+ @Override
public boolean isEmpty() {
boolean result;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -361,6 +361,11 @@
firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, fishingOperation);
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
public Multimap<CaracteristicQualitativeValue, Species> getSpeciesUsed() {
return speciesUsed;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -91,4 +91,9 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
}
\ 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 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -187,6 +187,11 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
public Float getBenthosTotalComputedWeight() {
return catchesUIModel.getBenthosTotalComputedWeight();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -134,4 +134,9 @@
public String getIcon() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -122,4 +122,9 @@
public String getIcon() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
\ No newline at end of file
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 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -403,6 +403,11 @@
return null;
}
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
+
public List<SpeciesBatchRowModel> getLeafs(Species species) {
List<SpeciesBatchRowModel> result = Lists.newArrayList();
for (SpeciesBatchRowModel rowModel : getRows()) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2014-05-14 12:55:14 UTC (rev 1766)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2014-05-14 12:56:04 UTC (rev 1767)
@@ -117,4 +117,9 @@
protected FishingOperation newEntity() {
return null;
}
+
+ @Override
+ public boolean isCloseable() {
+ return false;
+ }
}
1
0
r1766 - in trunk: tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport tutti-service/src/main/resources/i18n tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport tutti-service/src/test/resources/psion tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action tutti-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 14:55:14 +0200 (Wed, 14 May 2014)
New Revision: 1766
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1766
Log:
report refs #5059 (l'import psion est ?\195?\160 corriger) (from version 3.4.2)
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.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/psionimport/PsionImportServiceTest.java
trunk/tutti-service/src/test/resources/psion/CC053.IWA
trunk/tutti-service/src/test/resources/psion/FM001.IWA
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java
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/psionimport/PsionImportBatchModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -150,6 +150,17 @@
return frequencies.size();
}
+ void merge(PsionImportBatchModel batchModel) {
+ setWeight(getWeight() + batchModel.getWeight());
+ setSampleWeight(getSampleWeight() + batchModel.getSampleWeight());
+
+ for (Map.Entry<Float, MutableInt> entry : batchModel.getFrequencies().entrySet()) {
+ Float stepClass = entry.getKey();
+ int number = entry.getValue().intValue();
+ addFrequency(stepClass, number);
+ }
+ }
+
@Override
public String toString() {
return new ToStringBuilder(this)
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -24,19 +24,29 @@
* #L%
*/
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import org.apache.commons.lang3.mutable.MutableInt;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Created on 1/20/14.
*
@@ -48,40 +58,67 @@
/** Logger. */
private static final Log log = LogFactory.getLog(PsionImportModel.class);
- protected final Map<String, PsionImportBatchModel> batchsByCategory;
+ /**
+ * All registred species in their registred order.
+ */
+ protected final LinkedHashSet<Species> speciesSet;
+ /**
+ * All sorted batch indexed by their species.
+ *
+ * @since 3.4.2
+ */
+ protected final Multimap<Species, PsionImportBatchModel> sortedBatchsBySpecies;
+
+ /**
+ * All unsorted batch indexed by their species.
+ *
+ * @since 3.4.2
+ */
+ protected final Multimap<Species, PsionImportBatchModel> unsortedBatchsBySpecies;
+
protected final List<String> errors;
public PsionImportModel() {
- batchsByCategory = Maps.newLinkedHashMap();
+ speciesSet = new LinkedHashSet<>();
+ sortedBatchsBySpecies = ArrayListMultimap.create();
+ unsortedBatchsBySpecies = ArrayListMultimap.create();
errors = Lists.newArrayList();
}
public boolean withBatchs() {
- return !batchsByCategory.isEmpty();
+ return !speciesSet.isEmpty();
}
public Set<Species> getSpecies() {
- Set<Species> result = Sets.newLinkedHashSet();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
- result.add(batch.getSpecies());
+ Set<Species> result = ImmutableSet.copyOf(speciesSet);
+ return result;
+ }
+
+ public List<PsionImportBatchModel> getUnsortedBatches(Species species) {
+ Collection<PsionImportBatchModel> batches = unsortedBatchsBySpecies.get(species);
+ List<PsionImportBatchModel> result = null;
+
+ if (batches != null) {
+ result = ImmutableList.copyOf(batches);
+
}
return result;
}
- public List<PsionImportBatchModel> getBatchs(Species species) {
- List<PsionImportBatchModel> result = Lists.newArrayList();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
- if (species.equals(batch.getSpecies())) {
- result.add(batch);
- }
+ public List<PsionImportBatchModel> getSortedBatches(Species species) {
+ Collection<PsionImportBatchModel> batches = sortedBatchsBySpecies.get(species);
+ List<PsionImportBatchModel> result = null;
+
+ if (batches != null) {
+ result = ImmutableList.copyOf(batches);
}
return result;
}
public Set<Integer> getSampleCategoryIdUsed() {
Set<Integer> result = Sets.newHashSet();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
+ for (PsionImportBatchModel batch : sortedBatchsBySpecies.values()) {
Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batch.getCategoryIterator();
while (categoryIterator.hasNext()) {
PsionImportBatchModel.SampleCategory next = categoryIterator.next();
@@ -89,6 +126,14 @@
result.add(next.getCategoryId());
}
}
+ for (PsionImportBatchModel batch : unsortedBatchsBySpecies.values()) {
+ Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batch.getCategoryIterator();
+ while (categoryIterator.hasNext()) {
+ PsionImportBatchModel.SampleCategory next = categoryIterator.next();
+
+ result.add(next.getCategoryId());
+ }
+ }
return result;
}
@@ -96,32 +141,65 @@
return !errors.isEmpty();
}
+ public List<String> getErrors() {
+ return errors;
+ }
+
void addBatch(PsionImportBatchModel batchModel) {
- String cacheCode = batchModel.getSpecies().getSurveyCode() + "_" + batchModel.getCategoryCode();
+ Species species = batchModel.getSpecies();
+ speciesSet.add(species);
+
+ String categoryCode = batchModel.getCategoryCode();
+ Float weight = batchModel.getWeight();
+ Float sampleWeight = batchModel.getSampleWeight();
- PsionImportBatchModel mergeBatch = batchsByCategory.get(cacheCode);
+ Multimap<Species, PsionImportBatchModel> store;
+ // --- Guess if sorted or unsorted batch --- //
+ if (TuttiEntities.isGreaterWeight(weight, 0) && TuttiEntities.isEqualWeight(weight, sampleWeight)) {
+
+ store = unsortedBatchsBySpecies;
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Found a unsorted batch [%s] %s - %s", species.getSurveyCode(), weight, sampleWeight));
+ }
+ } else {
+
+ store = sortedBatchsBySpecies;
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Found a sorted batch [%s] %s - %s", species.getSurveyCode(), weight, sampleWeight));
+ }
+ }
+
+ // --- Get if exist the previous batch --- //
+
+ Collection<PsionImportBatchModel> psionImportBatchModels = store.get(species);
+
+ PsionImportBatchModel mergeBatch = null;
+
+ if (CollectionUtils.isNotEmpty(psionImportBatchModels)) {
+
+ for (PsionImportBatchModel importBatchModel : psionImportBatchModels) {
+ if (categoryCode.equals(importBatchModel.getCategoryCode())) {
+ mergeBatch = importBatchModel;
+ break;
+ }
+ }
+ }
+
if (mergeBatch == null) {
// new batch
- batchsByCategory.put(cacheCode, batchModel);
+ store.put(species, batchModel);
if (log.isDebugEnabled()) {
log.debug("Added " + batchModel);
}
} else {
- // merge data with this batch
+ // merge batch
+ mergeBatch.merge(batchModel);
- mergeBatch.setWeight(mergeBatch.getWeight() + batchModel.getWeight());
- mergeBatch.setSampleWeight(mergeBatch.getSampleWeight() + batchModel.getSampleWeight());
-
- for (Map.Entry<Float, MutableInt> entry : batchModel.getFrequencies().entrySet()) {
- Float stepClass = entry.getKey();
- int number = entry.getValue().intValue();
- mergeBatch.addFrequency(stepClass, number);
- }
if (log.isDebugEnabled()) {
log.debug("Merged " + batchModel + " to " + mergeBatch);
}
@@ -132,7 +210,72 @@
errors.add(error);
}
- public List<String> getErrors() {
- return errors;
+ void cleanSortedBatches() {
+
+ for (Species species : sortedBatchsBySpecies.keySet()) {
+
+ for (PsionImportBatchModel batchModel : sortedBatchsBySpecies.get(species)) {
+
+ Float weight = batchModel.getWeight();
+ Float sampleWeight = batchModel.getSampleWeight();
+
+ if (TuttiEntities.isEqualWeight(weight, 0) && TuttiEntities.isGreaterWeight(sampleWeight, 0)) {
+
+ // POID = 0 et TAIL != POID : un seul poids à positionner
+ batchModel.setWeight(sampleWeight);
+ batchModel.setSampleWeight(null);
+
+ }
+
+ }
+
+ }
}
+
+ void cleanUnsortedBatches() {
+
+ for (Species species : unsortedBatchsBySpecies.keySet()) {
+
+ for (PsionImportBatchModel batchModel : unsortedBatchsBySpecies.get(species)) {
+
+ // POID = TAIL un seul poids à positionner
+ batchModel.setSampleWeight(null);
+ }
+
+ }
+ }
+
+ void checkSortedBatches() throws IOException {
+
+ Set<Species> speciesSet = sortedBatchsBySpecies.keySet();
+
+ for (Species species : speciesSet) {
+
+ Collection<PsionImportBatchModel> sortedBatches = sortedBatchsBySpecies.get(species);
+
+ Map<String, Float> weightByCategory = new HashMap<>();
+
+ for (PsionImportBatchModel sortedBatch : sortedBatches) {
+ Float weight = sortedBatch.getWeight();
+ if (TuttiEntities.isGreaterWeight(weight, 0)) {
+
+ Float rootweight = weightByCategory.get(sortedBatch.getCategoryCode());
+
+ if (rootweight == null) {
+
+ // first time
+ weightByCategory.put(sortedBatch.getCategoryCode(), weight);
+ } else if (!TuttiEntities.isEqualWeight(rootweight, weight)) {
+
+ // can't have 2 batches with different vrac batch weight
+ throw new IOException(
+ t("tutti.service.psionimport.error.inconsistentVracWeight.message", species.getSurveyCode()));
+ }
+
+ }
+ }
+ }
+
+ }
+
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -41,8 +41,10 @@
protected final List<String> errors;
- protected int nbImported;
+ protected int nbSortedImported;
+ protected int nbUnsortedImported;
+
public PsionImportResult(File importFile, List<String> errors) {
this.importFile = importFile;
this.errors = Lists.newArrayList(errors);
@@ -52,18 +54,26 @@
return importFile;
}
- public int getNbImported() {
- return nbImported;
+ public int getNbSortedImported() {
+ return nbSortedImported;
}
+ public int getNbUnsortedImported() {
+ return nbUnsortedImported;
+ }
+
public List<String> getErrors() {
return errors;
}
- void incrementNbImported() {
- this.nbImported++;
+ void incrementNbSortedImported() {
+ this.nbSortedImported++;
}
+ void incrementNbUnsortedImported() {
+ this.nbUnsortedImported++;
+ }
+
void addError(String error) {
errors.add(error);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -55,6 +55,7 @@
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.type.WeightUnit;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.mutable.MutableInt;
@@ -230,33 +231,48 @@
if (log.isWarnEnabled()) {
log.warn("Won't import psion file, errors detected.");
}
- } else {
- // check sample categories exists
+ return result;
+ }
- SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel();
- Set<Integer> sampleCategoryIdUsed = importModel.getSampleCategoryIdUsed();
- List<String> missingCategories = Lists.newArrayList();
- for (Integer categoryId : sampleCategoryIdUsed) {
- if (!sampleCategoryModel.containsCategoryId(categoryId)) {
- missingCategories.add("<li>" + categoryId + "</li>");
- }
+ // --- Check sample category id used --- //
+ SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel();
+ Set<Integer> sampleCategoryIdUsed = importModel.getSampleCategoryIdUsed();
+ List<String> missingCategories = Lists.newArrayList();
+ for (Integer categoryId : sampleCategoryIdUsed) {
+ if (!sampleCategoryModel.containsCategoryId(categoryId)) {
+ missingCategories.add("<li>" + categoryId + "</li>");
}
+ }
- if (!missingCategories.isEmpty()) {
+ if (!missingCategories.isEmpty()) {
- result.addError(
- t("tutti.service.psionimport.error.invalidSampleCategoryModel.message",
- Joiner.on("").join(missingCategories))
- );
- } else {
+ result.addError(
+ t("tutti.service.psionimport.error.invalidSampleCategoryModel.message",
+ Joiner.on("").join(missingCategories))
+ );
- // persist in db
- persist(result, importModel, operation, catchBatch);
- }
+ return result;
+ }
+ // --- Check sorted batches --- //
+ try {
+ importModel.checkSortedBatches();
+ } catch (IOException e) {
+ result.addError(e.getMessage());
+ return result;
}
+ // --- clean sorted batches --- //
+ importModel.cleanSortedBatches();
+
+ // --- clean unsorted batches --- //
+ importModel.cleanUnsortedBatches();
+
+ // --- Ok no error, can persist --- //
+
+ persist(result, importModel, operation, catchBatch);
+
return result;
}
@@ -283,7 +299,7 @@
throw new IOException(t("tutti.service.psionimport.error.invalid.date.format"));
}
- boolean correctOperation = Objects.equals(operationCode, operation.getStationNumber()) &&
+ boolean correctOperation = Objects.equals(operationCode, String.valueOf(operation.getFishingOperationNumber())) &&
Objects.equals(operationDate, operation.getGearShootingStartDate());
if (!correctOperation) {
@@ -494,106 +510,199 @@
for (Species specy : species) {
- List<PsionImportBatchModel> batchs = importModel.getBatchs(specy);
+ List<PsionImportBatchModel> sortedBatchs = importModel.getSortedBatches(specy);
- if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+ if (CollectionUtils.isNotEmpty(sortedBatchs)) {
+ persistSortedBatches(operation, specy, sortedBatchs);
- PsionImportBatchModel batchModel = batchs.get(0);
+ result.incrementNbSortedImported();
+ }
- // simple batch with no category
- SpeciesBatch batch = createSpeciesBatch(operation,
- batchModel.getSpecies(),
- batchModel.getWeight(),
- batchModel.getSampleWeight(),
+ List<PsionImportBatchModel> unsortedBatchs = importModel.getUnsortedBatches(specy);
+
+ if (CollectionUtils.isNotEmpty(unsortedBatchs)) {
+ persistUnsortedBatches(operation, specy, unsortedBatchs);
+
+ result.incrementNbUnsortedImported();
+ }
+
+ }
+
+ persistenceService.saveCatchBatch(catchBatch);
+ }
+
+ protected void persistSortedBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs) {
+
+ if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+
+ PsionImportBatchModel batchModel = batchs.get(0);
+
+ // simple batch with no category
+ SpeciesBatch batch = createSpeciesBatch(operation,
+ batchModel.getSpecies(),
+ batchModel.getWeight(),
+ batchModel.getSampleWeight(),
+ PmfmId2.SORTED_UNSORTED.getValue(),
+ sortedCaracteristic);
+
+
+ batch = persistenceService.createSpeciesBatch(batch, null);
+
+ persistFrequencies(batch, batchModel);
+
+ } else {
+
+ // batch with categories
+
+ // Is there two weights ? If so then the weight has to be placed in the sorted batch
+
+ Float sortedBatchWeight = null;
+
+ Float weight = batchs.get(0).getWeight();
+ Float sampleWeight = batchs.get(0).getSampleWeight();
+
+ if (sampleWeight != null) {
+
+ // use the weight as sorted batch weight
+ sortedBatchWeight = weight;
+ }
+
+ SpeciesBatch rootBatch = createSpeciesBatch(operation,
+ specy,
+ sortedBatchWeight,
+ null,
PmfmId2.SORTED_UNSORTED.getValue(),
sortedCaracteristic);
- batch = persistenceService.createSpeciesBatch(batch, null);
+ rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
- persistFrequencies(batch, batchModel);
+ createCategoryBatches(operation, specy, batchs, rootBatch, sortedBatchWeight != null);
- } else {
+ }
- // batch with categories
+ }
- SpeciesBatch rootBatch = createSpeciesBatch(operation,
- specy,
- null,
- null,
- PmfmId2.SORTED_UNSORTED.getValue(),
- sortedCaracteristic);
+ protected void persistUnsortedBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs) {
- rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
+ if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+ PsionImportBatchModel batchModel = batchs.get(0);
- for (PsionImportBatchModel batchModel : batchs) {
+ // simple batch with no category
+ SpeciesBatch batch = createSpeciesBatch(operation,
+ batchModel.getSpecies(),
+ batchModel.getWeight(),
+ batchModel.getSampleWeight(),
+ PmfmId2.SORTED_UNSORTED.getValue(),
+ unsortedCaracteristic);
- SpeciesBatch parentBatch = rootBatch;
+ batch = persistenceService.createSpeciesBatch(batch, null);
- SpeciesBatch childBatch = null;
+ persistFrequencies(batch, batchModel);
- Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batchModel.getCategoryIterator();
+ } else {
- while (categoryIterator.hasNext()) {
- PsionImportBatchModel.SampleCategory sampleCategory = categoryIterator.next();
+ // batch with categories
- boolean lastCategory = !categoryIterator.hasNext();
+ SpeciesBatch rootBatch = createSpeciesBatch(operation,
+ specy,
+ null,
+ null,
+ PmfmId2.SORTED_UNSORTED.getValue(),
+ unsortedCaracteristic);
- Integer categoryId = sampleCategory.getCategoryId();
- Serializable categoryValue = sampleCategory.getCategoryValue();
+ rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
- if (lastCategory) {
+ createCategoryBatches(operation, specy, batchs, rootBatch, false);
- // always create the leaf
- childBatch = createSpeciesBatch(operation,
- specy,
- batchModel.getWeight(),
- batchModel.getSampleWeight(),
- categoryId,
- categoryValue);
- } else {
+ }
- // try to find child in parent children
+ }
- childBatch = null;
- for (SpeciesBatch speciesBatch : parentBatch.getChildBatchs()) {
+ protected void createCategoryBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs,
+ SpeciesBatch rootBatch,
+ boolean applyOnlySampleWeight) {
- if (speciesBatch.getSampleCategoryId().equals(categoryId) &&
- speciesBatch.getSampleCategoryValue().equals(categoryValue)) {
- childBatch = speciesBatch;
- break;
- }
- }
+ for (PsionImportBatchModel batchModel : batchs) {
- if (childBatch == null) {
+ SpeciesBatch parentBatch = rootBatch;
- // must create it
- childBatch = createSpeciesBatch(operation,
- specy,
- null,
- null,
- categoryId,
- categoryValue);
- }
- }
+ SpeciesBatch childBatch = null;
- if (TuttiEntities.isNew(childBatch)) {
+ Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batchModel.getCategoryIterator();
- // persist it
- childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId());
- parentBatch.addChildBatchs(childBatch);
+ while (categoryIterator.hasNext()) {
+ PsionImportBatchModel.SampleCategory sampleCategory = categoryIterator.next();
+
+ boolean lastCategory = !categoryIterator.hasNext();
+
+ Integer categoryId = sampleCategory.getCategoryId();
+ Serializable categoryValue = sampleCategory.getCategoryValue();
+
+ if (lastCategory) {
+
+ // always create the leaf
+
+ Float weight;
+ Float sampleWeight;
+
+ if (applyOnlySampleWeight) {
+ weight = batchModel.getSampleWeight();
+ sampleWeight = null;
+ } else {
+ weight = batchModel.getWeight();
+ sampleWeight = batchModel.getSampleWeight();
+ }
+ childBatch = createSpeciesBatch(operation,
+ specy,
+ weight,
+ sampleWeight,
+ categoryId,
+ categoryValue);
+ } else {
+
+ // try to find child in parent children
+
+ childBatch = null;
+ for (SpeciesBatch speciesBatch : parentBatch.getChildBatchs()) {
+
+ if (speciesBatch.getSampleCategoryId().equals(categoryId) &&
+ speciesBatch.getSampleCategoryValue().equals(categoryValue)) {
+ childBatch = speciesBatch;
+ break;
}
+ }
- parentBatch = childBatch;
+ if (childBatch == null) {
+
+ // must create it
+ childBatch = createSpeciesBatch(operation,
+ specy,
+ null,
+ null,
+ categoryId,
+ categoryValue);
}
+ }
- persistFrequencies(childBatch, batchModel);
+ if (TuttiEntities.isNew(childBatch)) {
+
+ // persist it
+ childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId());
+ parentBatch.addChildBatchs(childBatch);
}
+
+ parentBatch = childBatch;
}
- result.incrementNbImported();
+
+ persistFrequencies(childBatch, batchModel);
}
-
- persistenceService.saveCatchBatch(catchBatch);
}
protected PsionImportBatchModel.SampleCategory guessCategory(String categoryCode) {
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 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2014-05-14 12:55:14 UTC (rev 1766)
@@ -160,6 +160,7 @@
tutti.service.protocol.import.species.error=
tutti.service.protocol.import.taxonUsed.error=
tutti.service.psion.import.attachment.comment=
+tutti.service.psionimport.error.inconsistentVracWeight.message=
tutti.service.psionimport.error.invalid.category.syntax=
tutti.service.psionimport.error.invalid.command.syntax=
tutti.service.psionimport.error.invalid.date.format=
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 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2014-05-14 12:55:14 UTC (rev 1766)
@@ -159,6 +159,7 @@
tutti.service.protocol.import.species.error=Erreur lors de l'import des espèces du protocole %1s du fichier %2s
tutti.service.protocol.import.taxonUsed.error=Le taxon référent d'id %s est déjà utilisé
tutti.service.psion.import.attachment.comment=Import Psion du %s
+tutti.service.psionimport.error.inconsistentVracWeight.message=Pour l'espèce '%s', il existe deux enregistrements de lot vrac avec le champs 'POID' différent, ce qui est interdit
tutti.service.psionimport.error.invalid.category.syntax=Ligne %s, catégorisation '%s' inconnue, l'espèce %s sera ignorée
tutti.service.psionimport.error.invalid.command.syntax=Ligne %s, la commande '%s' n'est pas reconnue
tutti.service.psionimport.error.invalid.date.format=Format de la date du trait incorrecte (mm-dd-aaaa)
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -24,11 +24,16 @@
* #L%
*/
+import com.google.common.base.Predicate;
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId;
import fr.ifremer.tutti.TuttiConfigurationOption;
import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
@@ -79,6 +84,8 @@
protected File dataDirectory;
+ protected Predicate<SpeciesAbleBatch> vracPredicate;
+
@Before
public void setUp() throws Exception {
@@ -99,6 +106,8 @@
progressionModel.setTotal(9);
dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, OPERATION_2_ID, OPERATION_1_ID, OPERATION_3_ID);
+
+ vracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(PmfmId2.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue());
}
@Test
@@ -111,24 +120,55 @@
catchBatch.setFishingOperation(operation);
BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false);
- int oldNbBatchs = rootSpeciesBatch.sizeChildren();
+ int oldSortedBatchs = 0;
+ int oldUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ oldSortedBatchs++;
+ } else {
+ oldUnsortedBatchs++;
+ }
+ }
+
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(17, nbAdded);
+ int nbNewSortedBatchs = 10;
+ int nbNewUnsortedBatchs = 9;
+ Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded);
+ Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded);
Assert.assertEquals(0, errors.size());
// no batch imported
BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false);
- Assert.assertEquals(oldNbBatchs + 17, rootSpeciesBatchAfter.sizeChildren());
+
+ int totalSortedBatchs = 0;
+ int totalUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ totalSortedBatchs++;
+ } else {
+ totalUnsortedBatchs++;
+ }
+ }
+
+ Assert.assertEquals(oldSortedBatchs + nbNewSortedBatchs, totalSortedBatchs);
+ Assert.assertEquals(oldUnsortedBatchs + nbNewUnsortedBatchs, totalUnsortedBatchs);
}
@Test
@@ -141,23 +181,54 @@
catchBatch.setFishingOperation(operation);
BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false);
- int oldNbBatchs = rootSpeciesBatch.sizeChildren();
+ int oldSortedBatchs = 0;
+ int oldUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ oldSortedBatchs++;
+ } else {
+ oldUnsortedBatchs++;
+ }
+ }
+
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(10, nbAdded);
+ int nbNewSortedBatchs = 0;
+ int nbNewUnsortedBatchs = 10;
+ Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded);
+ Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded);
Assert.assertEquals(0, errors.size());
BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false);
- Assert.assertEquals(oldNbBatchs + 10, rootSpeciesBatchAfter.sizeChildren());
+
+ int totalSortedBatchs = 0;
+ int totalUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ totalSortedBatchs++;
+ } else {
+ totalUnsortedBatchs++;
+ }
+ }
+
+ Assert.assertEquals(oldSortedBatchs + nbNewSortedBatchs, totalSortedBatchs);
+ Assert.assertEquals(oldUnsortedBatchs + nbNewUnsortedBatchs, totalUnsortedBatchs);
}
@Test
@@ -173,15 +244,18 @@
int oldNbBatchs = rootSpeciesBatch.sizeChildren();
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(0, nbAdded);
+ Assert.assertEquals(0, nbSortedAdded);
+ Assert.assertEquals(0, nbUnsortedAdded);
Assert.assertEquals(1, errors.size());
// no batch imported
Modified: trunk/tutti-service/src/test/resources/psion/CC053.IWA
===================================================================
--- trunk/tutti-service/src/test/resources/psion/CC053.IWA 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/test/resources/psion/CC053.IWA 2014-05-14 12:55:14 UTC (rev 1766)
@@ -1,5 +1,5 @@
cc
-A
+1
07-01-2013
07:19:11
Modified: trunk/tutti-service/src/test/resources/psion/FM001.IWA
===================================================================
--- trunk/tutti-service/src/test/resources/psion/FM001.IWA 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-service/src/test/resources/psion/FM001.IWA 2014-05-14 12:55:14 UTC (rev 1766)
@@ -1,5 +1,5 @@
fm
-A
+1
07-01-2013
18:28:13
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java 2014-05-14 12:55:14 UTC (rev 1766)
@@ -125,7 +125,7 @@
if (importResult.isDone()) {
sendMessage(t("tutti.editSpeciesBatch.action.importPsion.success",
- importResult.getNbImported()));
+ importResult.getNbSortedImported(), importResult.getNbUnsortedImported()));
} else {
StringBuilder sb = new StringBuilder();
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 2014-05-14 12:32:05 UTC (rev 1765)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2014-05-14 12:55:14 UTC (rev 1766)
@@ -984,7 +984,7 @@
tutti.editSpeciesBatch.action.importPsion.no.matching.data=Import psion non réalisé (des erreurs ont été détectées lors de la lecture du fichier)
tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation=L'import Psion n'a pas été réalisé, des erreurs ont été détectées \:<ul>%s</ul><br/>Aucun lot n'a donc été importé.
tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation.title=Import Psion
-tutti.editSpeciesBatch.action.importPsion.success=Import Psion réussi \: %1s espèces importées
+tutti.editSpeciesBatch.action.importPsion.success=Import Psion réussi \: %1s espèces importées (Vrac), %2s espèces importées (Hors-Vrac)
tutti.editSpeciesBatch.action.importPsion.tip=Import Psion
tutti.editSpeciesBatch.action.importPupitri=Import Pupitri
tutti.editSpeciesBatch.action.importPupitri.existingData.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas importer les données Pupitri et conserver les espèces saisies</li><li><strong>OK</strong> pour supprimer les espèces existantes et les remplacer par les données de Pupitri</li></ul>
1
0
r1765 - in trunk/tutti-service/src: main/java/fr/ifremer/tutti/service/pupitri test/java/fr/ifremer/tutti/service/pupitri test/resources/pupitri
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 14:32:05 +0200 (Wed, 14 May 2014)
New Revision: 1765
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1765
Log:
report refs #5062 [PUPITRI] Gestion du m?\195?\169lange (from version 3.4.2)
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
trunk/tutti-service/src/test/resources/pupitri/evo-5062.car
trunk/tutti-service/src/test/resources/pupitri/evo-5062.tnk
trunk/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2014-05-14 12:27:19 UTC (rev 1764)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -66,7 +66,7 @@
protected String speciesId;
- protected String sign;
+ protected Signs sign;
protected Directions direction;
@@ -101,11 +101,11 @@
this.speciesId = speciesId;
}
- public String getSign() {
+ public Signs getSign() {
return sign;
}
- public void setSign(String sign) {
+ public void setSign(Signs sign) {
this.sign = sign;
}
@@ -127,7 +127,7 @@
public boolean isSorted() {
- boolean sorted = Directions.VAT == direction && !"H".equals(sign);
+ boolean sorted = Directions.VAT == direction && !Signs.UNSORTED.equals(sign);
return sorted;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2014-05-14 12:27:19 UTC (rev 1764)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -25,7 +25,10 @@
*/
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.nuiton.csv.ValueParser;
+import java.text.ParseException;
+
/**
* @author kmorin <kmorin(a)codelutin.com>
* @since 1.2
@@ -38,7 +41,18 @@
newMandatoryColumn(CarrouselRow.PROPERTY_OPERATION_CODE);
newMandatoryColumn(CarrouselRow.PROPERTY_RIG_NUMBER);
newMandatoryColumn(CarrouselRow.PROPERTY_SPECIES_ID);
- newMandatoryColumn(CarrouselRow.PROPERTY_SIGN);
+ newMandatoryColumn(CarrouselRow.PROPERTY_SIGN,
+ new ValueParser<Signs>() {
+ @Override
+ public Signs parse(String value) throws ParseException {
+ Signs result = Signs.getSign(value.toUpperCase());
+ if (result == null) {
+ throw new ParseException("Could not parse Sign value: " + value, 0);
+ }
+ return result;
+ }
+ }
+ );
newMandatoryColumn(CarrouselRow.PROPERTY_DIRECTION,
TuttiCsvUtil.newEnumByNameParserFormatter(Directions.class));
newMandatoryColumn(CarrouselRow.PROPERTY_WEIGHT,
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java 2014-05-14 12:27:19 UTC (rev 1764)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -25,12 +25,6 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2;
-import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId;
-import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-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 org.apache.commons.lang3.mutable.MutableFloat;
@@ -45,116 +39,8 @@
private static final long serialVersionUID = 1L;
- public static enum Signs {
- DEFAULT("0") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SEX.getValue();
- }
+ public static final String MELAG_META_SPECIES = "MELA-NGE";
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId2.SEX_UNDEFINED.getValue();
- }
- },
- UNSORTED("H") {
- @Override
- public Integer getCategory() {
- // special case, there is no cateogry possible here
- return null;
- }
-
- @Override
- public Integer getQualitativeValueId() {
- // special case, there is no cateogry possible here
- return null;
- }
- },
- MALE("1") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SEX.getValue();
- }
-
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId.SEX_MALE.getValue();
- }
- },
- FEMALE("2") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SEX.getValue();
- }
-
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId.SEX_FEMALE.getValue();
- }
- },
- SMALL("P") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SIZE_CATEGORY.getValue();
- }
-
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId.SIZE_SMALL.getValue();
- }
- },
- MEDIUM("M") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SIZE_CATEGORY.getValue();
- }
-
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId.SIZE_MEDIUM.getValue();
- }
- },
- BIG("G") {
- @Override
- public Integer getCategory() {
- return PmfmId2.SIZE_CATEGORY.getValue();
- }
-
- @Override
- public Integer getQualitativeValueId() {
- return QualitativeValueId.SIZE_BIG.getValue();
- }
- };
-
- private String sign;
-
- Signs(String sign) {
- this.sign = sign;
- }
-
- public static Signs getSign(String sign) {
- Signs result = null;
- for (Signs s : values()) {
- if (s.sign.equals(sign)) {
- result = s;
- break;
- }
- }
- return result;
- }
-
- public abstract Integer getCategory();
-
- public abstract Integer getQualitativeValueId();
-
- public void registerSign(Caracteristic caracteristic,
- Map<Signs, CaracteristicQualitativeValue> map) {
- Integer valueId = getQualitativeValueId();
- CaracteristicQualitativeValue result = TuttiEntities.getQualitativeValue(caracteristic, valueId);
- map.put(this, result);
- }
- }
-
protected Species species;
protected boolean sorted;
@@ -174,20 +60,41 @@
return sorted;
}
+ public boolean isForMelag() {
+ return weightBySign.containsKey(Signs.MELAG);
+ }
+
+ public boolean isMelagMetaSpecies() {
+
+ boolean melagMetaSpecies = MELAG_META_SPECIES.equals(species.getSurveyCode());
+ return melagMetaSpecies;
+
+ }
+
+ public Float getWeight(Signs signs) {
+
+ MutableFloat mutableFloat = weightBySign.get(signs);
+ return mutableFloat == null ? null : mutableFloat.floatValue();
+
+ }
+
public Map<Signs, MutableFloat> getWeightBySign() {
return weightBySign;
}
- public void addToSign(String sign, Float weight) {
- Signs s = Signs.getSign(sign);
- MutableFloat f = weightBySign.get(s);
+ public void addToSign(Signs sign, Float weight) {
+ MutableFloat f = weightBySign.get(sign);
if (f == null) {
f = new MutableFloat();
- weightBySign.put(s, f);
+ weightBySign.put(sign, f);
}
f.add(weight);
}
+ public void removeSign(Signs sign) {
+ weightBySign.remove(sign);
+ }
+
@Override
public int hashCode() {
int speciesHashCode = species != null ? species.hashCode() : 0;
@@ -212,5 +119,4 @@
}
return true;
}
-
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-05-14 12:27:19 UTC (rev 1764)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -96,7 +96,7 @@
protected CaracteristicQualitativeValue unsortedCaracteristic;
- protected Map<PupitriCatch.Signs, CaracteristicQualitativeValue> signsToCaracteristicValue;
+ protected Map<Signs, CaracteristicQualitativeValue> signsToCaracteristicValue;
@Override
public void setServiceContext(TuttiServiceContext context) {
@@ -105,7 +105,7 @@
decoratorService = getService(DecoratorService.class);
dataContext = context.getDataContext();
- signsToCaracteristicValue = Maps.newEnumMap(PupitriCatch.Signs.class);
+ signsToCaracteristicValue = Maps.newEnumMap(Signs.class);
{ // sorted/unsorted caracteristic
Caracteristic caracteristic =
@@ -118,16 +118,16 @@
{ // sex category
Caracteristic caracteristic = persistenceService.getSexCaracteristic();
- PupitriCatch.Signs.DEFAULT.registerSign(caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.FEMALE.registerSign(caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.MALE.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.DEFAULT.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.FEMALE.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.MALE.registerSign(caracteristic, signsToCaracteristicValue);
}
{ // size category
Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic();
- PupitriCatch.Signs.SMALL.registerSign(caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.MEDIUM.registerSign(caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.BIG.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.SMALL.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.MEDIUM.registerSign(caracteristic, signsToCaracteristicValue);
+ Signs.BIG.registerSign(caracteristic, signsToCaracteristicValue);
}
}
@@ -153,6 +153,8 @@
// there is some matching rows to import
+ result.prepareMelag();
+
savePupitriImportResult(result, operation, catchBatch);
}
@@ -384,7 +386,7 @@
boolean splitSpecies = isSplitSpecies(pupitriCatch);
- Map<PupitriCatch.Signs, MutableFloat> weightBySign =
+ Map<Signs, MutableFloat> weightBySign =
pupitriCatch.getWeightBySign();
if (splitSpecies) {
@@ -403,9 +405,9 @@
String parentBatchId = batch.getId();
- for (Map.Entry<PupitriCatch.Signs, MutableFloat> entry : weightBySign.entrySet()) {
+ for (Map.Entry<Signs, MutableFloat> entry : weightBySign.entrySet()) {
- PupitriCatch.Signs signs = entry.getKey();
+ Signs signs = entry.getKey();
float catchWeight = entry.getValue().floatValue();
Integer categoryId = signs.getCategory();
@@ -446,24 +448,24 @@
persistenceService.saveCatchBatch(catchBatch);
}
- public static final Set<PupitriCatch.Signs> DEFAULT_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.DEFAULT
+ public static final Set<Signs> DEFAULT_SIGNS = Sets.newHashSet(
+ Signs.DEFAULT
);
- public static final Set<PupitriCatch.Signs> UNSORTED_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.UNSORTED
+ public static final Set<Signs> UNSORTED_SIGNS = Sets.newHashSet(
+ Signs.UNSORTED
);
- public static final Set<PupitriCatch.Signs> SEX_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.DEFAULT,
- PupitriCatch.Signs.MALE,
- PupitriCatch.Signs.FEMALE
+ public static final Set<Signs> SEX_SIGNS = Sets.newHashSet(
+ Signs.DEFAULT,
+ Signs.MALE,
+ Signs.FEMALE
);
- public static final Set<PupitriCatch.Signs> SIZE_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.SMALL,
- PupitriCatch.Signs.MEDIUM,
- PupitriCatch.Signs.BIG
+ public static final Set<Signs> SIZE_SIGNS = Sets.newHashSet(
+ Signs.SMALL,
+ Signs.MEDIUM,
+ Signs.BIG
);
@@ -482,9 +484,9 @@
*/
private boolean isSplitSpecies(PupitriCatch speciesCatch) {
boolean result;
- Map<PupitriCatch.Signs, MutableFloat> weightBySign =
+ Map<Signs, MutableFloat> weightBySign =
speciesCatch.getWeightBySign();
- Set<PupitriCatch.Signs> signs =
+ Set<Signs> signs =
Sets.newHashSet(weightBySign.keySet());
if (DEFAULT_SIGNS.equals(signs)) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java 2014-05-14 12:27:19 UTC (rev 1764)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -24,8 +24,16 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import org.apache.commons.lang3.mutable.MutableFloat;
+
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
* Result of a pupitri import.
@@ -55,11 +63,34 @@
private Float carrouselSortedWeight;
- private List<PupitriCatch> catches;
+ private final List<PupitriCatch> catches;
+ /**
+ * Total weight of all entries of species {@code MELA-GNE}.
+ *
+ * @since 3.4.2
+ */
+ private MutableFloat melagTotalWeight;
+
+ /**
+ * Total weight of all entries of sorted species of melag (sign = {@code T}).
+ *
+ * @since 3.4.2
+ */
+ private MutableFloat melagSortedWeight;
+
+ /**
+ * Set of all species in the melag (sign = {@code T}).
+ *
+ * @since 3.4.2
+ */
+ private final Set<Species> melagSpecies;
+
public PupitriImportResult(File trunkFile, File carrousselFile) {
this.trunkFile = trunkFile;
this.carrousselFile = carrousselFile;
+ catches = new ArrayList<>();
+ melagSpecies = new HashSet<>();
}
public boolean isFishingOperationFound() {
@@ -102,6 +133,38 @@
return carrouselSortedWeight;
}
+ public List<PupitriCatch> getCatches() {
+ return catches;
+ }
+
+ public Float getMelagTotalWeight() {
+ return melagTotalWeight == null ? null : melagTotalWeight.floatValue();
+ }
+
+ public Float getMelagSortedWeight() {
+ return melagSortedWeight == null ? null : melagSortedWeight.floatValue();
+ }
+
+ public Set<Species> getMelagSpecies() {
+ return melagSpecies;
+ }
+
+ /**
+ * @return {@code true} if there is a total melga weight defined (at least one species MELA-GNE found).
+ * @since 3.4.2
+ */
+ public boolean isFoundTotalMelag() {
+ return melagTotalWeight != null;
+ }
+
+ /**
+ * @return {@code true} if at least one species has a sorted melag weight.
+ * @since 3.4.2
+ */
+ public boolean isFoundSortedMelag() {
+ return melagSortedWeight != null;
+ }
+
void incrementNbTrunkImported() {
this.nbTrunkImported++;
}
@@ -135,10 +198,98 @@
}
void setCatches(List<PupitriCatch> catches) {
- this.catches = catches;
+ for (PupitriCatch aCatch : catches) {
+ addCatch(aCatch);
+ }
}
- List<PupitriCatch> getCatches() {
- return catches;
+ void addCatch(PupitriCatch aCatch) {
+
+ catches.add(aCatch);
+
+ if (aCatch.isMelagMetaSpecies()) {
+
+
+ // add weight to melag
+ addMelagTotalWeight(aCatch.getWeight(Signs.DEFAULT));
+
+ }
+
+ if (aCatch.isForMelag()) {
+
+ // add species as a melag one
+ melagSpecies.add(aCatch.getSpecies());
+
+ // add weight to sorted melag
+ addMelagSortedWeight(aCatch.getWeight(Signs.MELAG));
+
+ }
+
}
+
+ void addMelagTotalWeight(float weight) {
+
+ if (melagTotalWeight == null) {
+ melagTotalWeight = new MutableFloat();
+ }
+ melagTotalWeight.add(weight);
+
+ }
+
+ void addMelagSortedWeight(float weight) {
+
+ if (melagSortedWeight == null) {
+ melagSortedWeight = new MutableFloat();
+ }
+ melagSortedWeight.add(weight);
+
+ }
+
+ void prepareMelag() {
+
+ boolean useMelag = isFoundTotalMelag() && isFoundSortedMelag();
+
+ float melagRatio = 1f;
+
+ if (useMelag) {
+ melagRatio = melagSortedWeight.floatValue() * melagTotalWeight.floatValue();
+ }
+
+ Iterator<PupitriCatch> iterator = catches.iterator();
+ while (iterator.hasNext()) {
+ PupitriCatch aCatch = iterator.next();
+
+ if (useMelag && aCatch.isMelagMetaSpecies()) {
+
+ // remove the MELA-GNE species from import
+ iterator.remove();
+ continue;
+
+ }
+
+ if (aCatch.isForMelag()) {
+
+ if (useMelag) {
+
+ // compute the weight from melag
+
+ Float sampleWeight = aCatch.getWeight(Signs.MELAG);
+ Float weight = TuttiEntities.roundKiloGram(sampleWeight / melagRatio);
+ aCatch.addToSign(Signs.DEFAULT, weight);
+ aCatch.removeSign(Signs.MELAG);
+
+ } else {
+
+ // move the melag weight as a default weight
+
+ Float weight = aCatch.getWeight(Signs.MELAG);
+ aCatch.addToSign(Signs.DEFAULT, weight);
+ aCatch.removeSign(Signs.MELAG);
+
+ }
+ }
+
+ }
+
+ }
}
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -0,0 +1,145 @@
+package fr.ifremer.tutti.service.pupitri;
+
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+
+import java.util.Map;
+
+/**
+ * Created on 5/14/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 3.4.2
+ */
+public enum Signs {
+
+ DEFAULT("0") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SEX.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId2.SEX_UNDEFINED.getValue();
+ }
+ },
+ UNSORTED("H") {
+ @Override
+ public Integer getCategory() {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+ },
+ MALE("1") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SEX.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId.SEX_MALE.getValue();
+ }
+ },
+ FEMALE("2") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SEX.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId.SEX_FEMALE.getValue();
+ }
+ },
+ SMALL("P") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SIZE_CATEGORY.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId.SIZE_SMALL.getValue();
+ }
+ },
+ MEDIUM("M") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SIZE_CATEGORY.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId.SIZE_MEDIUM.getValue();
+ }
+ },
+ BIG("G") {
+ @Override
+ public Integer getCategory() {
+ return PmfmId2.SIZE_CATEGORY.getValue();
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ return QualitativeValueId.SIZE_BIG.getValue();
+ }
+ },
+
+ MELAG("T") {
+ @Override
+ public Integer getCategory() {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+
+ @Override
+ public Integer getQualitativeValueId() {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+ };
+
+ private String sign;
+
+ Signs(String sign) {
+ this.sign = sign;
+ }
+
+ public String getSign() {
+ return sign;
+ }
+
+ public static Signs getSign(String sign) {
+ Signs result = null;
+ for (Signs s : values()) {
+ if (s.sign.equals(sign)) {
+ result = s;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public abstract Integer getCategory();
+
+ public abstract Integer getQualitativeValueId();
+
+ public void registerSign(Caracteristic caracteristic,
+ Map<Signs, CaracteristicQualitativeValue> map) {
+ Integer valueId = getQualitativeValueId();
+ CaracteristicQualitativeValue result = TuttiEntities.getQualitativeValue(caracteristic, valueId);
+ map.put(this, result);
+ }
+}
Property changes on: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java 2014-05-14 12:32:05 UTC (rev 1765)
@@ -0,0 +1,153 @@
+package fr.ifremer.tutti.service.pupitri;
+
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.TuttiConfigurationOption;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.nuiton.decorator.Decorator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Created on 5/14/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 3.4.2
+ */
+public class PupitriImportServiceEvo5062Test {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PupitriImportServiceEvo5062Test.class);
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.writeDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_ID = "100003";
+
+ public static final String OPERATION_1_ID = "100112";
+
+ public static final String OPERATION_2_ID = "100113";
+
+ public static final String OPERATION_3_ID = "100115";
+
+ protected PupitriImportExportService service;
+
+ protected PersistenceService persistenceService;
+
+ protected DecoratorService decoratorService;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ @Before
+ public void setUp() throws Exception {
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ decoratorService = serviceContext.getService(DecoratorService.class);
+
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(PupitriImportExportService.class);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3,
+ OPERATION_2_ID,
+ OPERATION_1_ID,
+ OPERATION_3_ID);
+ }
+
+ @Test
+ public void importPupitri() throws IOException {
+
+ File trunk = dbResource.copyClassPathResource("pupitri/evo-5062.tnk", "pupitri.tnk");
+ File carroussel = dbResource.copyClassPathResource("pupitri/evo-5062.car", "pupitri.car");
+ File protocol = dbResource.copyClassPathResource("pupitri/evo-5062.tuttiProtocol", "evo-5062.tuttiProtocol");
+ dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath());
+ TuttiProtocol protocol1 = persistenceService.getProtocol("evo-5062");
+ persistenceService.setProtocol(protocol1);
+
+ FishingOperation operation = dataContext.operations.get(1);
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false);
+ Assert.assertEquals(3, rootSpeciesBatch.sizeChildren());
+
+ int nbNotAdded = service.importPupitri(trunk, carroussel, operation, catchBatch).getNbCarrousselNotImported();
+ Assert.assertEquals(0, nbNotAdded);
+ BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false);
+ Assert.assertEquals(9, rootSpeciesBatchAfter.sizeChildren());
+
+ Set<Integer> unexpectedSpecies = Sets.newHashSet(
+ );
+ Set<Integer> expectedSpecies = Sets.newHashSet(
+
+ 18237, // EUPH-AUX
+ 16994, // MERL-MCC
+ 17116, // TRAC-TRU
+ 16816, // ENGR-ENC
+ 17374, // EUTR-GUR
+ 17226, // SCOM-SCO
+ 17007, // MICR-POU
+ 16869 // MYCT-PUN
+ );
+
+ Set<Integer> alreadyFound = new HashSet<>();
+
+ Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class);
+
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ Species species = speciesBatch.getSpecies();
+ Integer speciesId = species.getIdAsInt();
+ if (alreadyFound.contains(speciesId)) {
+
+ // already found
+ continue;
+
+ }
+
+ boolean remove = expectedSpecies.remove(speciesId);
+ if (log.isInfoEnabled()) {
+ log.info("Species : " + speciesId + " : " + speciesDecorator.toString(species));
+ }
+ if (remove) {
+
+ // ok mark it as safe specieId
+ alreadyFound.add(speciesId);
+
+ }
+
+ if (!remove) {
+ unexpectedSpecies.add(speciesId);
+ if (log.isWarnEnabled()) {
+ log.warn("Unexpected Species " + speciesId);
+ }
+ }
+ }
+
+ Assert.assertTrue("Expected species not found: " + expectedSpecies, expectedSpecies.isEmpty());
+ Assert.assertTrue("Unexpected species found: " + unexpectedSpecies, unexpectedSpecies.isEmpty());
+ }
+}
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/tutti-service/src/test/resources/pupitri/evo-5062.car
===================================================================
--- trunk/tutti-service/src/test/resources/pupitri/evo-5062.car (rev 0)
+++ trunk/tutti-service/src/test/resources/pupitri/evo-5062.car 2014-05-14 12:32:05 UTC (rev 1765)
@@ -0,0 +1,29 @@
+$TSMES,27/11/13,13:14:46.647,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0018.0,
+$TSMES,27/11/13,13:16:26.243,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0011.9,
+$TSMES,27/11/13,13:16:41.355,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.2,
+$TSMES,27/11/13,13:17:21.436,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0016.9,
+$TSMES,27/11/13,13:17:36.955,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.6,
+$TSMES,27/11/13,13:19:05.279,BLCAR, 0,A,1,001,EUPH-AUX,H,VAT,0011.7, (lettre H = hors vrac)
+$TSMES,27/11/13,13:19:39.641,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0015.5,
+$TSMES,27/11/13,13:20:06.166,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.9,
+$TSMES,27/11/13,13:20:23.156,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.3,
+$TSMES,27/11/13,13:21:04.512,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.9,
+$TSMES,27/11/13,13:23:22.732,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0015.6,
+$TSMES,27/11/13,13:23:54.472,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0011.7,
+$TSMES,27/11/13,13:25:04.666,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.7,
+$TSMES,27/11/13,13:26:06.042,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.9,
+$TSMES,27/11/13,13:27:00.467,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0010.4,
+$TSMES,27/11/13,13:28:00.475,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.7,
+$TSMES,27/11/13,13:28:27.717,BLCAR, 0,A,1,002,MERL-MCC,G,VAT,0008.4, (du merlu gros)
+$TSMES,27/11/13,13:29:02.786,BLCAR, 0,A,1,002,MERL-MCC,G,VAT,0006.6, (du merlu gros)
+$TSMES,27/11/13,13:30:08.665,BLCAR, 0,A,1,001,TRAC-TRU,0,VAT,0007.9,
+$TSMES,27/11/13,13:30:30.398,BLCAR, 0,A,1,001,MERL-MCC,P,VAT,0010.1, (du merlu petit)
+$TSMES,27/11/13,13:31:17.004,BLCAR, 0,A,1,001,ENGR-ENC,0,VAT,0000.4,
+$TSMES,27/11/13,13:32:57.554,BLCAR, 0,A,1,001,EUTR-GUR,0,VAT,0000.4,
+$TSMES,27/11/13,13:33:49.235,BLCAR, 0,A,1,001,SCOM-SCO,0,VAT,0000.7,
+$TSMES,27/11/13,13:34:20.335,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0014.9, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:34:46.793,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0019.0, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:36:40.963,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0014.8, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:37:18.484,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0011.1, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:38:26.381,BLCAR, 0,A,1,002,EUPH-AUX,T,VAT,0009.6, (lettre T pour des euphausiacés triés dans le mélange)
+$TSMES,27/11/13,13:49:51.688,BLCAR, 0,A,1,001,MYCT-PUN,T,VAT,0001.1, (lettre T pour des myctophidés triés dans le mélange)
Added: trunk/tutti-service/src/test/resources/pupitri/evo-5062.tnk
===================================================================
--- trunk/tutti-service/src/test/resources/pupitri/evo-5062.tnk (rev 0)
+++ trunk/tutti-service/src/test/resources/pupitri/evo-5062.tnk 2014-05-14 12:32:05 UTC (rev 1765)
@@ -0,0 +1,32 @@
+$TSMES,27/11/13,09:08:45.130,BLTNK, 0,A,1,VAT,0045.4,
+$TSMES,27/11/13,09:10:10.522,BLTNK, 0,A,1,VAT,0045.0,
+$TSMES,27/11/13,09:12:14.730,BLTNK, 0,A,1,VAT,0043.9,
+$TSMES,27/11/13,09:14:06.033,BLTNK, 0,A,1,VAT,0044.0,
+$TSMES,27/11/13,09:16:08.907,BLTNK, 0,A,1,VAT,0042.4,
+$TSMES,27/11/13,09:17:47.515,BLTNK, 0,A,1,VAT,0044.3,
+$TSMES,27/11/13,09:19:44.039,BLTNK, 0,A,1,VAT,0043.6,
+$TSMES,27/11/13,09:21:49.166,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,09:26:57.681,BLTNK, 0,A,1,VAT,0045.9,
+$TSMES,27/11/13,09:29:20.020,BLTNK, 0,A,1,VAT,0045.8,
+$TSMES,27/11/13,09:30:37.535,BLTNK, 0,A,1,VAT,0047.0,
+$TSMES,27/11/13,09:32:16.153,BLTNK, 0,A,1,VAT,0046.6,
+$TSMES,27/11/13,09:33:30.882,BLTNK, 0,A,1,VAT,0044.4,
+$TSMES,27/11/13,09:34:50.649,BLTNK, 0,A,1,VAT,0044.5,
+$TSMES,27/11/13,09:36:36.933,BLTNK, 0,A,1,VAT,0043.7,
+$TSMES,27/11/13,09:37:53.424,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:41:40.944,BLTNK, 0,A,1,VAT,0048.6,
+$TSMES,27/11/13,09:43:33.377,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:44:46.487,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:46:12.192,BLTNK, 0,A,1,VAT,0045.2,
+$TSMES,27/11/13,09:47:34.846,BLTNK, 0,A,1,VAT,0045.4,
+$TSMES,27/11/13,09:48:55.920,BLTNK, 0,A,1,VAT,0048.4,
+$TSMES,27/11/13,09:51:12.724,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:54:14.063,BLTNK, 0,A,1,VAT,0040.4,
+$TSMES,27/11/13,09:56:11.000,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,09:57:38.344,BLTNK, 0,A,1,VAT,0047.3,
+$TSMES,27/11/13,09:59:23.603,BLTNK, 0,A,1,VAT,0047.6,
+$TSMES,27/11/13,10:00:51.868,BLTNK, 0,A,1,VAT,0047.9,
+$TSMES,27/11/13,10:02:29.655,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,10:04:14.101,BLTNK, 0,A,1,VAT,0045.9,
+$TSMES,27/11/13,10:06:08.886,BLTNK, 0,A,1,VAT,0043.2,
+$TSMES,27/11/13,10:08:35.000,BLTNK, 0,A,1,VAT,0007.5,
Added: trunk/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol
===================================================================
--- trunk/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol (rev 0)
+++ trunk/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol 2014-05-14 12:32:05 UTC (rev 1765)
@@ -0,0 +1,154 @@
+id: c6ee2088-9720-46c0-b8d2-8f21c902676f
+name: Protocole EVHOE 2013
+benthos:
+comment: Protocole pour les tests 2013 avec Jean Jacques Rivoalen
+gearUseFeaturePmfmId:
+- 131
+- 828
+- 884
+- 965
+lengthClassesPmfmId:
+- 306
+- 622
+- 307
+- 302
+- 299
+- 1394
+- 1417
+- 1425
+- 1426
+- 1427
+- 283
+- 284
+- 285
+- 294
+- 295
+- 300
+- 301
+- 304
+- 318
+- 319
+- 322
+- 323
+- 661
+- 662
+species:
+- !SpeciesProtocol
+ id: 056a7ad4-934c-4d69-b068-1a2dd64012cb
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 2786
+ speciesSurveyCode: EUPH-AUX
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 5f7e400c-6a03-4092-9ccf-0031823b3a14
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ - 196
+ speciesReferenceTaxonId: 1540
+ speciesSurveyCode: MERL-MCC
+ weightEnabled: true
+- !SpeciesProtocol
+ id: dc5738bb-ed38-4814-a016-9fabfd833212
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ speciesReferenceTaxonId: 1662
+ speciesSurveyCode: TRAC-TRU
+ weightEnabled: true
+- !SpeciesProtocol
+ id: e4577b1e-18d1-459c-acff-04aedf4e917d
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 307
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1362
+ speciesSurveyCode: ENGR-ENC
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 4076fe7e-01fe-4164-820a-47b50dfa8e02
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1920
+ speciesSurveyCode: EUTR-GUR
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 16f4a094-1904-4e50-aff9-1f2dcab3a909
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ speciesReferenceTaxonId: 1772
+ speciesSurveyCode: SCOM-SCO
+ weightEnabled: true
+- !SpeciesProtocol
+ id: d5887f0e-bd99-4f66-a967-8fcff8224b32
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ - 196
+ speciesReferenceTaxonId: 1553
+ speciesSurveyCode: MICR-POU
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 944db3c6-d870-4f03-8abc-9a985a6feb65
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1415
+ speciesSurveyCode: MYCT-PUN
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 2a8122cf-d238-4820-a7b9-eacaf1f302bd
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1551
+ speciesSurveyCode: MELA-NGE
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 0de3f5c9-0ca9-4a7c-84aa-323d9eaa7f7f
+ countIfNoFrequencyEnabled: true
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 872
+ speciesSurveyCode: ACAN-PEL
+ weightEnabled: true
+- !SpeciesProtocol
+ id: ddffa4c9-cbb5-447f-a829-e2ac0cfea0f5
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1732
+ speciesSurveyCode: ACANPAL
+ weightEnabled: true
+vesselUseFeaturePmfmId:
+- 173
+- 194
+- 230
+- 782
+- 843
+- 844
+- 846
+- 847
+- 848
+- 849
+- 850
+- 851
+- 857
+- 858
+- 859
+- 861
+- 862
+- 863
+- 881
+- 882
+- 883
1
0
r1764 - in branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export: generic sumatra
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 14:27:19 +0200 (Wed, 14 May 2014)
New Revision: 1764
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1764
Log:
fix some tests
Modified:
branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java
branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceV2Test.java
Modified: branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java 2014-05-14 12:03:51 UTC (rev 1763)
+++ branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java 2014-05-14 12:27:19 UTC (rev 1764)
@@ -196,8 +196,8 @@
"2013;test elevation;1;OTB 20/28.10;B;2;1;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;1.0\n" +
"2013;test elevation;1;OTB 20/28.10;B;2;1;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;1.0\n" +
"2013;test elevation;1;OTB 20/28.10;B;2;1;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;1.0\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;4622;;Abietinaria abietina;Trait B-2-1 Benthos ABIEABI Vrac 30@@@@avec @@@@commentaire...;Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;1.0\n" +
- "2013;test elevation;1;OTB 20/28.10;B;2;1;380;;Acanthocardia echinata;Trait B-2-1 Benthos ACANECH Vrac 18@@@@avec @@@@commentaire...;Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;1.0\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;4622;;Abietinaria abietina;Trait B-2-1 Benthos ABIEABI Vrac 30@@@@avec @@@@commentaire...;Vrac;101;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;1.0\n" +
+ "2013;test elevation;1;OTB 20/28.10;B;2;1;380;;Acanthocardia echinata;Trait B-2-1 Benthos ACANECH Vrac 18@@@@avec @@@@commentaire...;Vrac;102;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;1.0\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;1938;;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;1.0\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;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;1.0\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;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;1.0\n" +
Modified: branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceV2Test.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceV2Test.java 2014-05-14 12:03:51 UTC (rev 1763)
+++ branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/export/sumatra/CatchesSumatraExportServiceV2Test.java 2014-05-14 12:27:19 UTC (rev 1764)
@@ -64,7 +64,7 @@
"Année;Station;Poche;Espèce;Signe;Tri;Total;PoidsMoy;LongueurMoy;NbIndividus;Moule\n" +
"2013;A;1;CHAMMAG;;100.0;100.0;2.5;NA;40;0.4\n" +
"2013;A;1;ECHIGAM;;100.0;100.0;0.23980816;NA;417;4.17\n" +
- "2013;A;1;BRISATLAN;;100.0;100.0;1.0638298;NA;94;0.94";
+ "2013;A;1;BRISATLAN;;100.0;100.0;1.0638298;10.571428;94;0.94";
protected CatchesSumatraExportServiceV2 service;
1
0
r1763 - in branches/tutti-3.4.x/tutti-service/src: main/java/fr/ifremer/tutti/service/pupitri test/java/fr/ifremer/tutti/service/pupitri test/resources/pupitri
by tchemit@users.forge.codelutin.com 14 May '14
by tchemit@users.forge.codelutin.com 14 May '14
14 May '14
Author: tchemit
Date: 2014-05-14 14:03:51 +0200 (Wed, 14 May 2014)
New Revision: 1763
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1763
Log:
fixes #5062 [PUPITRI] Gestion du m?\195?\169lange
Added:
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.car
branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tnk
branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol
Modified:
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2014-05-13 20:52:44 UTC (rev 1762)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -66,7 +66,7 @@
protected String speciesId;
- protected String sign;
+ protected Signs sign;
protected Directions direction;
@@ -101,11 +101,11 @@
this.speciesId = speciesId;
}
- public String getSign() {
+ public Signs getSign() {
return sign;
}
- public void setSign(String sign) {
+ public void setSign(Signs sign) {
this.sign = sign;
}
@@ -127,7 +127,7 @@
public boolean isSorted() {
- boolean sorted = Directions.VAT == direction && !"H".equals(sign);
+ boolean sorted = Directions.VAT == direction && !Signs.UNSORTED.equals(sign);
return sorted;
}
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2014-05-13 20:52:44 UTC (rev 1762)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -25,7 +25,10 @@
*/
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import org.nuiton.csv.ValueParser;
+import java.text.ParseException;
+
/**
* @author kmorin <kmorin(a)codelutin.com>
* @since 1.2
@@ -38,7 +41,18 @@
newMandatoryColumn(CarrouselRow.PROPERTY_OPERATION_CODE);
newMandatoryColumn(CarrouselRow.PROPERTY_RIG_NUMBER);
newMandatoryColumn(CarrouselRow.PROPERTY_SPECIES_ID);
- newMandatoryColumn(CarrouselRow.PROPERTY_SIGN);
+ newMandatoryColumn(CarrouselRow.PROPERTY_SIGN,
+ new ValueParser<Signs>() {
+ @Override
+ public Signs parse(String value) throws ParseException {
+ Signs result = Signs.getSign(value.toUpperCase());
+ if (result == null) {
+ throw new ParseException("Could not parse Sign value: " + value, 0);
+ }
+ return result;
+ }
+ }
+ );
newMandatoryColumn(CarrouselRow.PROPERTY_DIRECTION,
TuttiCsvUtil.newEnumByNameParserFormatter(Directions.class));
newMandatoryColumn(CarrouselRow.PROPERTY_WEIGHT,
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java 2014-05-13 20:52:44 UTC (rev 1762)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -25,11 +25,7 @@
*/
import com.google.common.collect.Maps;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-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.persistence.service.TuttiEnumerationFile;
import org.apache.commons.lang3.mutable.MutableFloat;
import java.io.Serializable;
@@ -43,117 +39,8 @@
private static final long serialVersionUID = 1L;
- public static enum Signs {
- DEFAULT("0") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SEX;
- }
+ public static final String MELAG_META_SPECIES = "MELA-NGE";
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SEX_UNDEFINED_ID;
- }
- },
- UNSORTED("H") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- // special case, there is no cateogry possible here
- return null;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- // special case, there is no cateogry possible here
- return null;
- }
- },
- MALE("1") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SEX;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SEX_MALE_ID;
- }
- },
- FEMALE("2") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SEX;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SEX_FEMALE_ID;
- }
- },
- SMALL("P") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SIZE_CATEGORY;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SIZE_SMALL_ID;
- }
- },
- MEDIUM("M") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SIZE_CATEGORY;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SIZE_MEDIUM_ID;
- }
- },
- BIG("G") {
- @Override
- public Integer getCategory(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.PMFM_ID_SIZE_CATEGORY;
- }
-
- @Override
- public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
- return enumerationFile.QUALITATIVE_SIZE_BIG_ID;
- }
- };
-
- private String sign;
-
- Signs(String sign) {
- this.sign = sign;
- }
-
- public static Signs getSign(String sign) {
- Signs result = null;
- for (Signs s : values()) {
- if (s.sign.equals(sign)) {
- result = s;
- break;
- }
- }
- return result;
- }
-
- public abstract Integer getCategory(TuttiEnumerationFile enumerationFile);
-
- public abstract Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile);
-
- public void registerSign(TuttiEnumerationFile enumerationFile,
- Caracteristic caracteristic,
- Map<Signs, CaracteristicQualitativeValue> map) {
- Integer valueId = getQualitativeValueId(enumerationFile);
- CaracteristicQualitativeValue result = TuttiEntities.getQualitativeValue(caracteristic, valueId);
- map.put(this, result);
- }
- }
-
protected Species species;
protected boolean sorted;
@@ -173,20 +60,41 @@
return sorted;
}
+ public boolean isForMelag() {
+ return weightBySign.containsKey(Signs.MELAG);
+ }
+
+ public boolean isMelagMetaSpecies() {
+
+ boolean melagMetaSpecies = MELAG_META_SPECIES.equals(species.getSurveyCode());
+ return melagMetaSpecies;
+
+ }
+
+ public Float getWeight(Signs signs) {
+
+ MutableFloat mutableFloat = weightBySign.get(signs);
+ return mutableFloat == null ? null : mutableFloat.floatValue();
+
+ }
+
public Map<Signs, MutableFloat> getWeightBySign() {
return weightBySign;
}
- public void addToSign(String sign, Float weight) {
- Signs s = Signs.getSign(sign);
- MutableFloat f = weightBySign.get(s);
+ public void addToSign(Signs sign, Float weight) {
+ MutableFloat f = weightBySign.get(sign);
if (f == null) {
f = new MutableFloat();
- weightBySign.put(s, f);
+ weightBySign.put(sign, f);
}
f.add(weight);
}
+ public void removeSign(Signs sign) {
+ weightBySign.remove(sign);
+ }
+
@Override
public int hashCode() {
int speciesHashCode = species != null ? species.hashCode() : 0;
@@ -211,5 +119,4 @@
}
return true;
}
-
}
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-05-13 20:52:44 UTC (rev 1762)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -95,7 +95,7 @@
protected CaracteristicQualitativeValue unsortedCaracteristic;
- protected Map<PupitriCatch.Signs, CaracteristicQualitativeValue> signsToCaracteristicValue;
+ protected Map<Signs, CaracteristicQualitativeValue> signsToCaracteristicValue;
@Override
public void setServiceContext(TuttiServiceContext context) {
@@ -107,7 +107,7 @@
TuttiEnumerationFile enumerationFile =
persistenceService.getEnumerationFile();
- signsToCaracteristicValue = Maps.newEnumMap(PupitriCatch.Signs.class);
+ signsToCaracteristicValue = Maps.newEnumMap(Signs.class);
{ // sorted/unsorted caracteristic
Caracteristic caracteristic =
@@ -120,16 +120,16 @@
{ // sex category
Caracteristic caracteristic = persistenceService.getSexCaracteristic();
- PupitriCatch.Signs.DEFAULT.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.FEMALE.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.MALE.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.DEFAULT.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.FEMALE.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.MALE.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
}
{ // size category
Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic();
- PupitriCatch.Signs.SMALL.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.MEDIUM.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
- PupitriCatch.Signs.BIG.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.SMALL.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.MEDIUM.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
+ Signs.BIG.registerSign(enumerationFile, caracteristic, signsToCaracteristicValue);
}
}
@@ -155,6 +155,9 @@
// there is some matching rows to import
+ result.prepareMelag();
+
+
savePupitriImportResult(result, operation, catchBatch);
}
@@ -411,7 +414,7 @@
boolean splitSpecies = isSplitSpecies(pupitriCatch);
- Map<PupitriCatch.Signs, MutableFloat> weightBySign =
+ Map<Signs, MutableFloat> weightBySign =
pupitriCatch.getWeightBySign();
if (splitSpecies) {
@@ -430,9 +433,9 @@
String parentBatchId = batch.getId();
- for (Map.Entry<PupitriCatch.Signs, MutableFloat> entry : weightBySign.entrySet()) {
+ for (Map.Entry<Signs, MutableFloat> entry : weightBySign.entrySet()) {
- PupitriCatch.Signs signs = entry.getKey();
+ Signs signs = entry.getKey();
float catchWeight = entry.getValue().floatValue();
Integer categoryId = signs.getCategory(enumerationFile);
@@ -473,24 +476,24 @@
persistenceService.saveCatchBatch(catchBatch);
}
- public static final Set<PupitriCatch.Signs> DEFAULT_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.DEFAULT
+ public static final Set<Signs> DEFAULT_SIGNS = Sets.newHashSet(
+ Signs.DEFAULT
);
- public static final Set<PupitriCatch.Signs> UNSORTED_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.UNSORTED
+ public static final Set<Signs> UNSORTED_SIGNS = Sets.newHashSet(
+ Signs.UNSORTED
);
- public static final Set<PupitriCatch.Signs> SEX_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.DEFAULT,
- PupitriCatch.Signs.MALE,
- PupitriCatch.Signs.FEMALE
+ public static final Set<Signs> SEX_SIGNS = Sets.newHashSet(
+ Signs.DEFAULT,
+ Signs.MALE,
+ Signs.FEMALE
);
- public static final Set<PupitriCatch.Signs> SIZE_SIGNS = Sets.newHashSet(
- PupitriCatch.Signs.SMALL,
- PupitriCatch.Signs.MEDIUM,
- PupitriCatch.Signs.BIG
+ public static final Set<Signs> SIZE_SIGNS = Sets.newHashSet(
+ Signs.SMALL,
+ Signs.MEDIUM,
+ Signs.BIG
);
@@ -509,9 +512,9 @@
*/
private boolean isSplitSpecies(PupitriCatch speciesCatch) {
boolean result;
- Map<PupitriCatch.Signs, MutableFloat> weightBySign =
+ Map<Signs, MutableFloat> weightBySign =
speciesCatch.getWeightBySign();
- Set<PupitriCatch.Signs> signs =
+ Set<Signs> signs =
Sets.newHashSet(weightBySign.keySet());
if (DEFAULT_SIGNS.equals(signs)) {
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java 2014-05-13 20:52:44 UTC (rev 1762)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportResult.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -24,8 +24,16 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import org.apache.commons.lang3.mutable.MutableFloat;
+
import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
/**
* Result of a pupitri import.
@@ -55,11 +63,34 @@
private Float carrouselSortedWeight;
- private List<PupitriCatch> catches;
+ private final List<PupitriCatch> catches;
+ /**
+ * Total weight of all entries of species {@code MELA-GNE}.
+ *
+ * @since 3.4.2
+ */
+ private MutableFloat melagTotalWeight;
+
+ /**
+ * Total weight of all entries of sorted species of melag (sign = {@code T}).
+ *
+ * @since 3.4.2
+ */
+ private MutableFloat melagSortedWeight;
+
+ /**
+ * Set of all species in the melag (sign = {@code T}).
+ *
+ * @since 3.4.2
+ */
+ private final Set<Species> melagSpecies;
+
public PupitriImportResult(File trunkFile, File carrousselFile) {
this.trunkFile = trunkFile;
this.carrousselFile = carrousselFile;
+ catches = new ArrayList<>();
+ melagSpecies = new HashSet<>();
}
public boolean isFishingOperationFound() {
@@ -102,6 +133,38 @@
return carrouselSortedWeight;
}
+ public List<PupitriCatch> getCatches() {
+ return catches;
+ }
+
+ public Float getMelagTotalWeight() {
+ return melagTotalWeight == null ? null : melagTotalWeight.floatValue();
+ }
+
+ public Float getMelagSortedWeight() {
+ return melagSortedWeight == null ? null : melagSortedWeight.floatValue();
+ }
+
+ public Set<Species> getMelagSpecies() {
+ return melagSpecies;
+ }
+
+ /**
+ * @return {@code true} if there is a total melga weight defined (at least one species MELA-GNE found).
+ * @since 3.4.2
+ */
+ public boolean isFoundTotalMelag() {
+ return melagTotalWeight != null;
+ }
+
+ /**
+ * @return {@code true} if at least one species has a sorted melag weight.
+ * @since 3.4.2
+ */
+ public boolean isFoundSortedMelag() {
+ return melagSortedWeight != null;
+ }
+
void incrementNbTrunkImported() {
this.nbTrunkImported++;
}
@@ -135,10 +198,98 @@
}
void setCatches(List<PupitriCatch> catches) {
- this.catches = catches;
+ for (PupitriCatch aCatch : catches) {
+ addCatch(aCatch);
+ }
}
- List<PupitriCatch> getCatches() {
- return catches;
+ void addCatch(PupitriCatch aCatch) {
+
+ catches.add(aCatch);
+
+ if (aCatch.isMelagMetaSpecies()) {
+
+
+ // add weight to melag
+ addMelagTotalWeight(aCatch.getWeight(Signs.DEFAULT));
+
+ }
+
+ if (aCatch.isForMelag()) {
+
+ // add species as a melag one
+ melagSpecies.add(aCatch.getSpecies());
+
+ // add weight to sorted melag
+ addMelagSortedWeight(aCatch.getWeight(Signs.MELAG));
+
+ }
+
}
+
+ void addMelagTotalWeight(float weight) {
+
+ if (melagTotalWeight == null) {
+ melagTotalWeight = new MutableFloat();
+ }
+ melagTotalWeight.add(weight);
+
+ }
+
+ void addMelagSortedWeight(float weight) {
+
+ if (melagSortedWeight == null) {
+ melagSortedWeight = new MutableFloat();
+ }
+ melagSortedWeight.add(weight);
+
+ }
+
+ void prepareMelag() {
+
+ boolean useMelag = isFoundTotalMelag() && isFoundSortedMelag();
+
+ float melagRatio = 1f;
+
+ if (useMelag) {
+ melagRatio = melagSortedWeight.floatValue() * melagTotalWeight.floatValue();
+ }
+
+ Iterator<PupitriCatch> iterator = catches.iterator();
+ while (iterator.hasNext()) {
+ PupitriCatch aCatch = iterator.next();
+
+ if (useMelag && aCatch.isMelagMetaSpecies()) {
+
+ // remove the MELA-GNE species from import
+ iterator.remove();
+ continue;
+
+ }
+
+ if (aCatch.isForMelag()) {
+
+ if (useMelag) {
+
+ // compute the weight from melag
+
+ Float sampleWeight = aCatch.getWeight(Signs.MELAG);
+ Float weight = TuttiEntities.roundKiloGram(sampleWeight / melagRatio);
+ aCatch.addToSign(Signs.DEFAULT, weight);
+ aCatch.removeSign(Signs.MELAG);
+
+ } else {
+
+ // move the melag weight as a default weight
+
+ Float weight = aCatch.getWeight(Signs.MELAG);
+ aCatch.addToSign(Signs.DEFAULT, weight);
+ aCatch.removeSign(Signs.MELAG);
+
+ }
+ }
+
+ }
+
+ }
}
Added: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java (rev 0)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -0,0 +1,143 @@
+package fr.ifremer.tutti.service.pupitri;
+
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+
+import java.util.Map;
+
+/**
+ * Created on 5/14/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 3.4.2
+ */
+public enum Signs {
+
+ DEFAULT("0") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SEX;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SEX_UNDEFINED_ID;
+ }
+ },
+ UNSORTED("H") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+ },
+ MALE("1") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SEX;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SEX_MALE_ID;
+ }
+ },
+ FEMALE("2") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SEX;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SEX_FEMALE_ID;
+ }
+ },
+ SMALL("P") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SIZE_CATEGORY;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SIZE_SMALL_ID;
+ }
+ },
+ MEDIUM("M") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SIZE_CATEGORY;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SIZE_MEDIUM_ID;
+ }
+ },
+ BIG("G") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.PMFM_ID_SIZE_CATEGORY;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ return enumerationFile.QUALITATIVE_SIZE_BIG_ID;
+ }
+ },
+ MELAG("T") {
+ @Override
+ public Integer getCategory(TuttiEnumerationFile enumerationFile) {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+
+ @Override
+ public Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile) {
+ // special case, there is no cateogry possible here
+ return null;
+ }
+ };
+
+ private String sign;
+
+ Signs(String sign) {
+ this.sign = sign;
+ }
+
+ public String getSign() {
+ return sign;
+ }
+
+ public static Signs getSign(String sign) {
+ Signs result = null;
+ for (Signs s : values()) {
+ if (s.sign.equals(sign)) {
+ result = s;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public abstract Integer getCategory(TuttiEnumerationFile enumerationFile);
+
+ public abstract Integer getQualitativeValueId(TuttiEnumerationFile enumerationFile);
+
+ public void registerSign(TuttiEnumerationFile enumerationFile,
+ Caracteristic caracteristic,
+ Map<Signs, CaracteristicQualitativeValue> map) {
+ Integer valueId = getQualitativeValueId(enumerationFile);
+ CaracteristicQualitativeValue result = TuttiEntities.getQualitativeValue(caracteristic, valueId);
+ map.put(this, result);
+ }
+}
Property changes on: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/Signs.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java (rev 0)
+++ branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java 2014-05-14 12:03:51 UTC (rev 1763)
@@ -0,0 +1,153 @@
+package fr.ifremer.tutti.service.pupitri;
+
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.TuttiConfigurationOption;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.nuiton.decorator.Decorator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Created on 5/14/14.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 3.4.2
+ */
+public class PupitriImportServiceEvo5062Test {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(PupitriImportServiceEvo5062Test.class);
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.writeDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_ID = "100003";
+
+ public static final String OPERATION_1_ID = "100112";
+
+ public static final String OPERATION_2_ID = "100113";
+
+ public static final String OPERATION_3_ID = "100115";
+
+ protected PupitriImportExportService service;
+
+ protected PersistenceService persistenceService;
+
+ protected DecoratorService decoratorService;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ @Before
+ public void setUp() throws Exception {
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ decoratorService = serviceContext.getService(DecoratorService.class);
+
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(PupitriImportExportService.class);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3,
+ OPERATION_2_ID,
+ OPERATION_1_ID,
+ OPERATION_3_ID);
+ }
+
+ @Test
+ public void importPupitri() throws IOException {
+
+ File trunk = dbResource.copyClassPathResource("pupitri/evo-5062.tnk", "pupitri.tnk");
+ File carroussel = dbResource.copyClassPathResource("pupitri/evo-5062.car", "pupitri.car");
+ File protocol = dbResource.copyClassPathResource("pupitri/evo-5062.tuttiProtocol", "evo-5062.tuttiProtocol");
+ dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath());
+ TuttiProtocol protocol1 = persistenceService.getProtocol("evo-5062");
+ persistenceService.setProtocol(protocol1);
+
+ FishingOperation operation = dataContext.operations.get(1);
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
+ Assert.assertEquals(3, rootSpeciesBatch.sizeChildren());
+
+ int nbNotAdded = service.importPupitri(trunk, carroussel, operation, catchBatch).getNbCarrousselNotImported();
+ Assert.assertEquals(0, nbNotAdded);
+ BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null);
+ Assert.assertEquals(9, rootSpeciesBatchAfter.sizeChildren());
+
+ Set<Integer> unexpectedSpecies = Sets.newHashSet(
+ );
+ Set<Integer> expectedSpecies = Sets.newHashSet(
+
+ 18237, // EUPH-AUX
+ 16994, // MERL-MCC
+ 17116, // TRAC-TRU
+ 16816, // ENGR-ENC
+ 17374, // EUTR-GUR
+ 17226, // SCOM-SCO
+ 17007, // MICR-POU
+ 16869 // MYCT-PUN
+ );
+
+ Set<Integer> alreadyFound = new HashSet<>();
+
+ Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class);
+
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ Species species = speciesBatch.getSpecies();
+ Integer speciesId = species.getIdAsInt();
+ if (alreadyFound.contains(speciesId)) {
+
+ // already found
+ continue;
+
+ }
+
+ boolean remove = expectedSpecies.remove(speciesId);
+ if (log.isInfoEnabled()) {
+ log.info("Species : " + speciesId + " : " + speciesDecorator.toString(species));
+ }
+ if (remove) {
+
+ // ok mark it as safe specieId
+ alreadyFound.add(speciesId);
+
+ }
+
+ if (!remove) {
+ unexpectedSpecies.add(speciesId);
+ if (log.isWarnEnabled()) {
+ log.warn("Unexpected Species " + speciesId);
+ }
+ }
+ }
+
+ Assert.assertTrue("Expected species not found: " + expectedSpecies, expectedSpecies.isEmpty());
+ Assert.assertTrue("Unexpected species found: " + unexpectedSpecies, unexpectedSpecies.isEmpty());
+ }
+}
\ No newline at end of file
Property changes on: branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo5062Test.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Copied: branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.car (from rev 1758, branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5060.car)
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.car (rev 0)
+++ branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.car 2014-05-14 12:03:51 UTC (rev 1763)
@@ -0,0 +1,29 @@
+$TSMES,27/11/13,13:14:46.647,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0018.0,
+$TSMES,27/11/13,13:16:26.243,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0011.9,
+$TSMES,27/11/13,13:16:41.355,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.2,
+$TSMES,27/11/13,13:17:21.436,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0016.9,
+$TSMES,27/11/13,13:17:36.955,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.6,
+$TSMES,27/11/13,13:19:05.279,BLCAR, 0,A,1,001,EUPH-AUX,H,VAT,0011.7, (lettre H = hors vrac)
+$TSMES,27/11/13,13:19:39.641,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0015.5,
+$TSMES,27/11/13,13:20:06.166,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.9,
+$TSMES,27/11/13,13:20:23.156,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.3,
+$TSMES,27/11/13,13:21:04.512,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.9,
+$TSMES,27/11/13,13:23:22.732,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0015.6,
+$TSMES,27/11/13,13:23:54.472,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0011.7,
+$TSMES,27/11/13,13:25:04.666,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0014.7,
+$TSMES,27/11/13,13:26:06.042,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.9,
+$TSMES,27/11/13,13:27:00.467,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0010.4,
+$TSMES,27/11/13,13:28:00.475,BLCAR, 0,A,1,002,MELA-NGE,0,VAT,0013.7,
+$TSMES,27/11/13,13:28:27.717,BLCAR, 0,A,1,002,MERL-MCC,G,VAT,0008.4, (du merlu gros)
+$TSMES,27/11/13,13:29:02.786,BLCAR, 0,A,1,002,MERL-MCC,G,VAT,0006.6, (du merlu gros)
+$TSMES,27/11/13,13:30:08.665,BLCAR, 0,A,1,001,TRAC-TRU,0,VAT,0007.9,
+$TSMES,27/11/13,13:30:30.398,BLCAR, 0,A,1,001,MERL-MCC,P,VAT,0010.1, (du merlu petit)
+$TSMES,27/11/13,13:31:17.004,BLCAR, 0,A,1,001,ENGR-ENC,0,VAT,0000.4,
+$TSMES,27/11/13,13:32:57.554,BLCAR, 0,A,1,001,EUTR-GUR,0,VAT,0000.4,
+$TSMES,27/11/13,13:33:49.235,BLCAR, 0,A,1,001,SCOM-SCO,0,VAT,0000.7,
+$TSMES,27/11/13,13:34:20.335,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0014.9, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:34:46.793,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0019.0, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:36:40.963,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0014.8, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:37:18.484,BLCAR, 0,A,1,002,MICR-POU,T,VAT,0011.1, (lettre T pour du poutassou trié dans le mélange)
+$TSMES,27/11/13,13:38:26.381,BLCAR, 0,A,1,002,EUPH-AUX,T,VAT,0009.6, (lettre T pour des euphausiacés triés dans le mélange)
+$TSMES,27/11/13,13:49:51.688,BLCAR, 0,A,1,001,MYCT-PUN,T,VAT,0001.1, (lettre T pour des myctophidés triés dans le mélange)
\ No newline at end of file
Copied: branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tnk (from rev 1758, branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5060.tnk)
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tnk (rev 0)
+++ branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tnk 2014-05-14 12:03:51 UTC (rev 1763)
@@ -0,0 +1,32 @@
+$TSMES,27/11/13,09:08:45.130,BLTNK, 0,A,1,VAT,0045.4,
+$TSMES,27/11/13,09:10:10.522,BLTNK, 0,A,1,VAT,0045.0,
+$TSMES,27/11/13,09:12:14.730,BLTNK, 0,A,1,VAT,0043.9,
+$TSMES,27/11/13,09:14:06.033,BLTNK, 0,A,1,VAT,0044.0,
+$TSMES,27/11/13,09:16:08.907,BLTNK, 0,A,1,VAT,0042.4,
+$TSMES,27/11/13,09:17:47.515,BLTNK, 0,A,1,VAT,0044.3,
+$TSMES,27/11/13,09:19:44.039,BLTNK, 0,A,1,VAT,0043.6,
+$TSMES,27/11/13,09:21:49.166,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,09:26:57.681,BLTNK, 0,A,1,VAT,0045.9,
+$TSMES,27/11/13,09:29:20.020,BLTNK, 0,A,1,VAT,0045.8,
+$TSMES,27/11/13,09:30:37.535,BLTNK, 0,A,1,VAT,0047.0,
+$TSMES,27/11/13,09:32:16.153,BLTNK, 0,A,1,VAT,0046.6,
+$TSMES,27/11/13,09:33:30.882,BLTNK, 0,A,1,VAT,0044.4,
+$TSMES,27/11/13,09:34:50.649,BLTNK, 0,A,1,VAT,0044.5,
+$TSMES,27/11/13,09:36:36.933,BLTNK, 0,A,1,VAT,0043.7,
+$TSMES,27/11/13,09:37:53.424,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:41:40.944,BLTNK, 0,A,1,VAT,0048.6,
+$TSMES,27/11/13,09:43:33.377,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:44:46.487,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:46:12.192,BLTNK, 0,A,1,VAT,0045.2,
+$TSMES,27/11/13,09:47:34.846,BLTNK, 0,A,1,VAT,0045.4,
+$TSMES,27/11/13,09:48:55.920,BLTNK, 0,A,1,VAT,0048.4,
+$TSMES,27/11/13,09:51:12.724,BLTNK, 0,A,1,VAT,0046.4,
+$TSMES,27/11/13,09:54:14.063,BLTNK, 0,A,1,VAT,0040.4,
+$TSMES,27/11/13,09:56:11.000,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,09:57:38.344,BLTNK, 0,A,1,VAT,0047.3,
+$TSMES,27/11/13,09:59:23.603,BLTNK, 0,A,1,VAT,0047.6,
+$TSMES,27/11/13,10:00:51.868,BLTNK, 0,A,1,VAT,0047.9,
+$TSMES,27/11/13,10:02:29.655,BLTNK, 0,A,1,VAT,0044.2,
+$TSMES,27/11/13,10:04:14.101,BLTNK, 0,A,1,VAT,0045.9,
+$TSMES,27/11/13,10:06:08.886,BLTNK, 0,A,1,VAT,0043.2,
+$TSMES,27/11/13,10:08:35.000,BLTNK, 0,A,1,VAT,0007.5,
\ No newline at end of file
Copied: branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol (from rev 1758, branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5060.tuttiProtocol)
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol (rev 0)
+++ branches/tutti-3.4.x/tutti-service/src/test/resources/pupitri/evo-5062.tuttiProtocol 2014-05-14 12:03:51 UTC (rev 1763)
@@ -0,0 +1,154 @@
+id: c6ee2088-9720-46c0-b8d2-8f21c902676f
+name: Protocole EVHOE 2013
+benthos:
+comment: Protocole pour les tests 2013 avec Jean Jacques Rivoalen
+gearUseFeaturePmfmId:
+- 131
+- 828
+- 884
+- 965
+lengthClassesPmfmId:
+- 306
+- 622
+- 307
+- 302
+- 299
+- 1394
+- 1417
+- 1425
+- 1426
+- 1427
+- 283
+- 284
+- 285
+- 294
+- 295
+- 300
+- 301
+- 304
+- 318
+- 319
+- 322
+- 323
+- 661
+- 662
+species:
+- !SpeciesProtocol
+ id: 056a7ad4-934c-4d69-b068-1a2dd64012cb
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 2786
+ speciesSurveyCode: EUPH-AUX
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 5f7e400c-6a03-4092-9ccf-0031823b3a14
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ - 196
+ speciesReferenceTaxonId: 1540
+ speciesSurveyCode: MERL-MCC
+ weightEnabled: true
+- !SpeciesProtocol
+ id: dc5738bb-ed38-4814-a016-9fabfd833212
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ speciesReferenceTaxonId: 1662
+ speciesSurveyCode: TRAC-TRU
+ weightEnabled: true
+- !SpeciesProtocol
+ id: e4577b1e-18d1-459c-acff-04aedf4e917d
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 307
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1362
+ speciesSurveyCode: ENGR-ENC
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 4076fe7e-01fe-4164-820a-47b50dfa8e02
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1920
+ speciesSurveyCode: EUTR-GUR
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 16f4a094-1904-4e50-aff9-1f2dcab3a909
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ speciesReferenceTaxonId: 1772
+ speciesSurveyCode: SCOM-SCO
+ weightEnabled: true
+- !SpeciesProtocol
+ id: d5887f0e-bd99-4f66-a967-8fcff8224b32
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId:
+ - 198
+ - 196
+ speciesReferenceTaxonId: 1553
+ speciesSurveyCode: MICR-POU
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 944db3c6-d870-4f03-8abc-9a985a6feb65
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1415
+ speciesSurveyCode: MYCT-PUN
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 2a8122cf-d238-4820-a7b9-eacaf1f302bd
+ calcifySampleEnabled: true
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1551
+ speciesSurveyCode: MELA-NGE
+ weightEnabled: true
+- !SpeciesProtocol
+ id: 0de3f5c9-0ca9-4a7c-84aa-323d9eaa7f7f
+ countIfNoFrequencyEnabled: true
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 872
+ speciesSurveyCode: ACAN-PEL
+ weightEnabled: true
+- !SpeciesProtocol
+ id: ddffa4c9-cbb5-447f-a829-e2ac0cfea0f5
+ countIfNoFrequencyEnabled: true
+ lengthStepPmfmId: 306
+ mandatorySampleCategoryId: []
+ speciesReferenceTaxonId: 1732
+ speciesSurveyCode: ACANPAL
+ weightEnabled: true
+vesselUseFeaturePmfmId:
+- 173
+- 194
+- 230
+- 782
+- 843
+- 844
+- 846
+- 847
+- 848
+- 849
+- 850
+- 851
+- 857
+- 858
+- 859
+- 861
+- 862
+- 863
+- 881
+- 882
+- 883
\ No newline at end of file
1
0
r1762 - in branches/tutti-3.4.x: tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport tutti-service/src/main/resources/i18n tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport tutti-service/src/test/resources/psion tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action tutti-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 13 May '14
by tchemit@users.forge.codelutin.com 13 May '14
13 May '14
Author: tchemit
Date: 2014-05-13 22:52:44 +0200 (Tue, 13 May 2014)
New Revision: 1762
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1762
Log:
refs-90 #5059 (need new tests)
Modified:
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java
branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java
branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java
branches/tutti-3.4.x/tutti-service/src/test/resources/psion/CC053.IWA
branches/tutti-3.4.x/tutti-service/src/test/resources/psion/FM001.IWA
branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java
branches/tutti-3.4.x/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportBatchModel.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -150,6 +150,17 @@
return frequencies.size();
}
+ void merge(PsionImportBatchModel batchModel) {
+ setWeight(getWeight() + batchModel.getWeight());
+ setSampleWeight(getSampleWeight() + batchModel.getSampleWeight());
+
+ for (Map.Entry<Float, MutableInt> entry : batchModel.getFrequencies().entrySet()) {
+ Float stepClass = entry.getKey();
+ int number = entry.getValue().intValue();
+ addFrequency(stepClass, number);
+ }
+ }
+
@Override
public String toString() {
return new ToStringBuilder(this)
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportModel.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -24,19 +24,29 @@
* #L%
*/
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import org.apache.commons.lang3.mutable.MutableInt;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import static org.nuiton.i18n.I18n.t;
+
/**
* Created on 1/20/14.
*
@@ -48,40 +58,70 @@
/** Logger. */
private static final Log log = LogFactory.getLog(PsionImportModel.class);
- protected final Map<String, PsionImportBatchModel> batchsByCategory;
+// protected final Map<String, PsionImportBatchModel> batchsByCategory;
+ /**
+ * All registred species in their registred order.
+ */
+ protected final LinkedHashSet<Species> speciesSet;
+
+ /**
+ * All sorted batch indexed by their species.
+ *
+ * @since 3.4.2
+ */
+ protected final Multimap<Species, PsionImportBatchModel> sortedBatchsBySpecies;
+
+ /**
+ * All unsorted batch indexed by their species.
+ *
+ * @since 3.4.2
+ */
+ protected final Multimap<Species, PsionImportBatchModel> unsortedBatchsBySpecies;
+
protected final List<String> errors;
public PsionImportModel() {
- batchsByCategory = Maps.newLinkedHashMap();
+ speciesSet = new LinkedHashSet<>();
+ sortedBatchsBySpecies = ArrayListMultimap.create();
+ unsortedBatchsBySpecies = ArrayListMultimap.create();
+// batchsByCategory = Maps.newLinkedHashMap();
errors = Lists.newArrayList();
}
public boolean withBatchs() {
- return !batchsByCategory.isEmpty();
+ return !speciesSet.isEmpty();
}
public Set<Species> getSpecies() {
- Set<Species> result = Sets.newLinkedHashSet();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
- result.add(batch.getSpecies());
+ Set<Species> result = ImmutableSet.copyOf(speciesSet);
+ return result;
+ }
+
+ public List<PsionImportBatchModel> getUnsortedBatches(Species species) {
+ Collection<PsionImportBatchModel> batches = unsortedBatchsBySpecies.get(species);
+ List<PsionImportBatchModel> result = null;
+
+ if (batches != null) {
+ result = ImmutableList.copyOf(batches);
+
}
return result;
}
- public List<PsionImportBatchModel> getBatchs(Species species) {
- List<PsionImportBatchModel> result = Lists.newArrayList();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
- if (species.equals(batch.getSpecies())) {
- result.add(batch);
- }
+ public List<PsionImportBatchModel> getSortedBatches(Species species) {
+ Collection<PsionImportBatchModel> batches = sortedBatchsBySpecies.get(species);
+ List<PsionImportBatchModel> result = null;
+
+ if (batches != null) {
+ result = ImmutableList.copyOf(batches);
}
return result;
}
public Set<Integer> getSampleCategoryIdUsed() {
Set<Integer> result = Sets.newHashSet();
- for (PsionImportBatchModel batch : batchsByCategory.values()) {
+ for (PsionImportBatchModel batch : sortedBatchsBySpecies.values()) {
Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batch.getCategoryIterator();
while (categoryIterator.hasNext()) {
PsionImportBatchModel.SampleCategory next = categoryIterator.next();
@@ -89,6 +129,14 @@
result.add(next.getCategoryId());
}
}
+ for (PsionImportBatchModel batch : unsortedBatchsBySpecies.values()) {
+ Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batch.getCategoryIterator();
+ while (categoryIterator.hasNext()) {
+ PsionImportBatchModel.SampleCategory next = categoryIterator.next();
+
+ result.add(next.getCategoryId());
+ }
+ }
return result;
}
@@ -96,32 +144,65 @@
return !errors.isEmpty();
}
+ public List<String> getErrors() {
+ return errors;
+ }
+
void addBatch(PsionImportBatchModel batchModel) {
- String cacheCode = batchModel.getSpecies().getSurveyCode() + "_" + batchModel.getCategoryCode();
+ Species species = batchModel.getSpecies();
+ speciesSet.add(species);
+
+ String categoryCode = batchModel.getCategoryCode();
+ Float weight = batchModel.getWeight();
+ Float sampleWeight = batchModel.getSampleWeight();
- PsionImportBatchModel mergeBatch = batchsByCategory.get(cacheCode);
+ Multimap<Species, PsionImportBatchModel> store;
+ // --- Guess if sorted or unsorted batch --- //
+ if (TuttiEntities.isGreaterWeight(weight, 0) && TuttiEntities.isEqualWeight(weight, sampleWeight)) {
+
+ store = unsortedBatchsBySpecies;
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Found a unsorted batch [%s] %s - %s", species.getSurveyCode(), weight, sampleWeight));
+ }
+ } else {
+
+ store = sortedBatchsBySpecies;
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Found a sorted batch [%s] %s - %s", species.getSurveyCode(), weight, sampleWeight));
+ }
+ }
+
+ // --- Get if exist the previous batch --- //
+
+ Collection<PsionImportBatchModel> psionImportBatchModels = store.get(species);
+
+ PsionImportBatchModel mergeBatch = null;
+
+ if (CollectionUtils.isNotEmpty(psionImportBatchModels)) {
+
+ for (PsionImportBatchModel importBatchModel : psionImportBatchModels) {
+ if (categoryCode.equals(importBatchModel.getCategoryCode())) {
+ mergeBatch = importBatchModel;
+ break;
+ }
+ }
+ }
+
if (mergeBatch == null) {
// new batch
- batchsByCategory.put(cacheCode, batchModel);
+ store.put(species, batchModel);
if (log.isInfoEnabled()) {
log.info("Added " + batchModel);
}
} else {
- // merge data with this batch
+ // merge batch
+ mergeBatch.merge(batchModel);
- mergeBatch.setWeight(mergeBatch.getWeight() + batchModel.getWeight());
- mergeBatch.setSampleWeight(mergeBatch.getSampleWeight() + batchModel.getSampleWeight());
-
- for (Map.Entry<Float, MutableInt> entry : batchModel.getFrequencies().entrySet()) {
- Float stepClass = entry.getKey();
- int number = entry.getValue().intValue();
- mergeBatch.addFrequency(stepClass, number);
- }
if (log.isInfoEnabled()) {
log.info("Merged " + batchModel + " to " + mergeBatch);
}
@@ -132,7 +213,139 @@
errors.add(error);
}
- public List<String> getErrors() {
- return errors;
+ void cleanSortedBatches() {
+
+ for (Species species : sortedBatchsBySpecies.keySet()) {
+
+ for (PsionImportBatchModel batchModel : sortedBatchsBySpecies.get(species)) {
+
+ Float weight = batchModel.getWeight();
+ Float sampleWeight = batchModel.getSampleWeight();
+
+ if (TuttiEntities.isEqualWeight(weight, 0) && TuttiEntities.isGreaterWeight(sampleWeight, 0)) {
+
+ // POID = 0 et TAIL != POID : un seul poids à positionner
+ batchModel.setWeight(sampleWeight);
+ batchModel.setSampleWeight(null);
+
+ }
+
+ }
+
+ }
}
+
+ void cleanUnsortedBatches() {
+
+ for (Species species : unsortedBatchsBySpecies.keySet()) {
+
+ for (PsionImportBatchModel batchModel : unsortedBatchsBySpecies.get(species)) {
+
+ // POID = TAIL un seul poids à positionner
+ batchModel.setSampleWeight(null);
+ }
+
+ }
+ }
+
+ void checkSortedBatches() throws IOException {
+
+ Set<Species> speciesSet = sortedBatchsBySpecies.keySet();
+
+ for (Species species : speciesSet) {
+
+ Collection<PsionImportBatchModel> sortedBatches = sortedBatchsBySpecies.get(species);
+
+ Map<String, Float> weightByCategory = new HashMap<>();
+
+ for (PsionImportBatchModel sortedBatch : sortedBatches) {
+ Float weight = sortedBatch.getWeight();
+ if (TuttiEntities.isGreaterWeight(weight, 0)) {
+
+ Float rootweight = weightByCategory.get(sortedBatch.getCategoryCode());
+
+ if (rootweight == null) {
+
+ // first time
+ weightByCategory.put(sortedBatch.getCategoryCode(), weight);
+ } else if (!TuttiEntities.isEqualWeight(rootweight, weight)) {
+
+ // can't have 2 batches with different vrac batch weight
+ throw new IOException(
+ t("tutti.service.psionimport.error.inconsistentVracWeight.message", species.getSurveyCode()));
+ }
+
+ }
+ }
+ }
+
+ }
+
+// public boolean withBatchs() {
+// return !batchsByCategory.isEmpty();
+// }
+//
+// public Set<Species> getSpecies() {
+// Set<Species> result = Sets.newLinkedHashSet();
+// for (PsionImportBatchModel batch : batchsByCategory.values()) {
+// result.add(batch.getSpecies());
+// }
+// return result;
+// }
+//
+// public List<PsionImportBatchModel> getBatchs(Species species) {
+// List<PsionImportBatchModel> result = Lists.newArrayList();
+// for (PsionImportBatchModel batch : batchsByCategory.values()) {
+// if (species.equals(batch.getSpecies())) {
+// result.add(batch);
+// }
+// }
+// return result;
+// }
+//
+// public Set<Integer> getSampleCategoryIdUsed() {
+// Set<Integer> result = Sets.newHashSet();
+// for (PsionImportBatchModel batch : batchsByCategory.values()) {
+// Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batch.getCategoryIterator();
+// while (categoryIterator.hasNext()) {
+// PsionImportBatchModel.SampleCategory next = categoryIterator.next();
+//
+// result.add(next.getCategoryId());
+// }
+// }
+// return result;
+// }
+//
+// void addBatch(PsionImportBatchModel batchModel) {
+//
+// String cacheCode = batchModel.getSpecies().getSurveyCode() + "_" + batchModel.getCategoryCode();
+//
+// PsionImportBatchModel mergeBatch = batchsByCategory.get(cacheCode);
+//
+// if (mergeBatch == null) {
+//
+// // new batch
+// batchsByCategory.put(cacheCode, batchModel);
+//
+// if (log.isInfoEnabled()) {
+// log.info("Added " + batchModel);
+// }
+// } else {
+//
+// // merge data with this batch
+//
+// mergeBatch.setWeight(mergeBatch.getWeight() + batchModel.getWeight());
+// mergeBatch.setSampleWeight(mergeBatch.getSampleWeight() + batchModel.getSampleWeight());
+//
+// for (Map.Entry<Float, MutableInt> entry : batchModel.getFrequencies().entrySet()) {
+// Float stepClass = entry.getKey();
+// int number = entry.getValue().intValue();
+// mergeBatch.addFrequency(stepClass, number);
+// }
+// if (log.isInfoEnabled()) {
+// log.info("Merged " + batchModel + " to " + mergeBatch);
+// }
+// }
+// }
+
}
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportResult.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -41,8 +41,12 @@
protected final List<String> errors;
- protected int nbImported;
+ protected int nbSortedImported;
+ protected int nbUnsortedImported;
+
+// protected int nbImported;
+
public PsionImportResult(File importFile, List<String> errors) {
this.importFile = importFile;
this.errors = Lists.newArrayList(errors);
@@ -52,18 +56,30 @@
return importFile;
}
- public int getNbImported() {
- return nbImported;
+// public int getNbImported() {
+// return nbImported;
+// }
+
+ public int getNbSortedImported() {
+ return nbSortedImported;
}
+ public int getNbUnsortedImported() {
+ return nbUnsortedImported;
+ }
+
public List<String> getErrors() {
return errors;
}
- void incrementNbImported() {
- this.nbImported++;
+ void incrementNbSortedImported() {
+ this.nbSortedImported++;
}
+ void incrementNbUnsortedImported() {
+ this.nbUnsortedImported++;
+ }
+
void addError(String error) {
errors.add(error);
}
Modified: branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -53,6 +53,7 @@
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiServiceContext;
import fr.ifremer.tutti.type.WeightUnit;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.mutable.MutableInt;
@@ -232,33 +233,48 @@
if (log.isWarnEnabled()) {
log.warn("Won't import psion file, errors detected.");
}
- } else {
- // check sample categories exists
+ return result;
+ }
- SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel();
- Set<Integer> sampleCategoryIdUsed = importModel.getSampleCategoryIdUsed();
- List<String> missingCategories = Lists.newArrayList();
- for (Integer categoryId : sampleCategoryIdUsed) {
- if (!sampleCategoryModel.containsCategoryId(categoryId)) {
- missingCategories.add("<li>" + categoryId + "</li>");
- }
+ // --- Check sample category id used --- //
+ SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel();
+ Set<Integer> sampleCategoryIdUsed = importModel.getSampleCategoryIdUsed();
+ List<String> missingCategories = Lists.newArrayList();
+ for (Integer categoryId : sampleCategoryIdUsed) {
+ if (!sampleCategoryModel.containsCategoryId(categoryId)) {
+ missingCategories.add("<li>" + categoryId + "</li>");
}
+ }
- if (!missingCategories.isEmpty()) {
+ if (!missingCategories.isEmpty()) {
- result.addError(
- t("tutti.service.psionimport.error.invalidSampleCategoryModel.message",
- Joiner.on("").join(missingCategories))
- );
- } else {
+ result.addError(
+ t("tutti.service.psionimport.error.invalidSampleCategoryModel.message",
+ Joiner.on("").join(missingCategories))
+ );
- // persist in db
- persist(result, importModel, operation, catchBatch);
- }
+ return result;
+ }
+ // --- Check sorted batches --- //
+ try {
+ importModel.checkSortedBatches();
+ } catch (IOException e) {
+ result.addError(e.getMessage());
+ return result;
}
+ // --- clean sorted batches --- //
+ importModel.cleanSortedBatches();
+
+ // --- clean unsorted batches --- //
+ importModel.cleanUnsortedBatches();
+
+ // --- Ok no error, can persist --- //
+
+ persist(result, importModel, operation, catchBatch);
+
return result;
}
@@ -285,7 +301,7 @@
throw new IOException(t("tutti.service.psionimport.error.invalid.date.format"));
}
- boolean correctOperation = Objects.equals(operationCode, operation.getStationNumber()) &&
+ boolean correctOperation = Objects.equals(operationCode, String.valueOf(operation.getFishingOperationNumber())) &&
Objects.equals(operationDate, operation.getGearShootingStartDate());
if (!correctOperation) {
@@ -492,112 +508,305 @@
// insert all imported species batches
- TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
+// TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
Set<Species> species = importModel.getSpecies();
for (Species specy : species) {
- List<PsionImportBatchModel> batchs = importModel.getBatchs(specy);
+ List<PsionImportBatchModel> sortedBatchs = importModel.getSortedBatches(specy);
- if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+ if (CollectionUtils.isNotEmpty(sortedBatchs)) {
+ persistSortedBatches(operation, specy, sortedBatchs);
- PsionImportBatchModel batchModel = batchs.get(0);
+ result.incrementNbSortedImported();
+ }
- // simple batch with no category
- SpeciesBatch batch = createSpeciesBatch(operation,
- batchModel.getSpecies(),
- batchModel.getWeight(),
- batchModel.getSampleWeight(),
+ List<PsionImportBatchModel> unsortedBatchs = importModel.getUnsortedBatches(specy);
+
+ if (CollectionUtils.isNotEmpty(unsortedBatchs)) {
+ persistUnsortedBatches(operation, specy, unsortedBatchs);
+
+ result.incrementNbUnsortedImported();
+ }
+
+// List<PsionImportBatchModel> batchs = importModel.getSortedBatches(specy);
+//
+// if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+//
+// PsionImportBatchModel batchModel = batchs.get(0);
+//
+// // simple batch with no category
+// SpeciesBatch batch = createSpeciesBatch(operation,
+// batchModel.getSpecies(),
+// batchModel.getWeight(),
+// batchModel.getSampleWeight(),
+// enumerationFile.PMFM_ID_SORTED_UNSORTED,
+// sortedCaracteristic);
+//
+// batch = persistenceService.createSpeciesBatch(batch, null);
+//
+// persistFrequencies(batch, batchModel);
+//
+// } else {
+//
+// // batch with categories
+//
+// SpeciesBatch rootBatch = createSpeciesBatch(operation,
+// specy,
+// null,
+// null,
+// enumerationFile.PMFM_ID_SORTED_UNSORTED,
+// sortedCaracteristic);
+//
+// rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
+//
+//
+// for (PsionImportBatchModel batchModel : batchs) {
+//
+// SpeciesBatch parentBatch = rootBatch;
+//
+// SpeciesBatch childBatch = null;
+//
+// Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batchModel.getCategoryIterator();
+//
+// while (categoryIterator.hasNext()) {
+// PsionImportBatchModel.SampleCategory sampleCategory = categoryIterator.next();
+//
+// boolean lastCategory = !categoryIterator.hasNext();
+//
+// Integer categoryId = sampleCategory.getCategoryId();
+// Serializable categoryValue = sampleCategory.getCategoryValue();
+//
+// if (lastCategory) {
+//
+// // always create the leaf
+// childBatch = createSpeciesBatch(operation,
+// specy,
+// batchModel.getWeight(),
+// batchModel.getSampleWeight(),
+// categoryId,
+// categoryValue);
+// } else {
+//
+// // try to find child in parent children
+//
+// childBatch = null;
+// for (SpeciesBatch speciesBatch : parentBatch.getChildBatchs()) {
+//
+// if (speciesBatch.getSampleCategoryId().equals(categoryId) &&
+// speciesBatch.getSampleCategoryValue().equals(categoryValue)) {
+// childBatch = speciesBatch;
+// break;
+// }
+// }
+//
+// if (childBatch == null) {
+//
+// // must create it
+// childBatch = createSpeciesBatch(operation,
+// specy,
+// null,
+// null,
+// categoryId,
+// categoryValue);
+// }
+// }
+//
+// if (TuttiEntities.isNew(childBatch)) {
+//
+// // persist it
+// childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId());
+// parentBatch.addChildBatchs(childBatch);
+// }
+//
+// parentBatch = childBatch;
+// }
+//
+// persistFrequencies(childBatch, batchModel);
+// }
+// }
+// result.incrementNbImported();
+ }
+
+ persistenceService.saveCatchBatch(catchBatch);
+ }
+
+ protected void persistSortedBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs) {
+
+ CaracteristicQualitativeValue caracteristicQualitativeValue = sortedCaracteristic;
+
+ if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
+
+ PsionImportBatchModel batchModel = batchs.get(0);
+
+ // simple batch with no category
+ SpeciesBatch batch = createSpeciesBatch(operation,
+ batchModel.getSpecies(),
+ batchModel.getWeight(),
+ batchModel.getSampleWeight(),
+ enumerationFile.PMFM_ID_SORTED_UNSORTED,
+ caracteristicQualitativeValue);
+
+ batch = persistenceService.createSpeciesBatch(batch, null);
+
+ persistFrequencies(batch, batchModel);
+
+ } else {
+
+ // batch with categories
+
+ // Is there two weights ? If so then the weight has to be placed in the sorted batch
+
+ Float sortedBatchWeight = null;
+
+ Float weight = batchs.get(0).getWeight();
+ Float sampleWeight = batchs.get(0).getSampleWeight();
+
+ if (sampleWeight != null) {
+
+ // use the weight as sorted batch weight
+ sortedBatchWeight = weight;
+ }
+
+ SpeciesBatch rootBatch = createSpeciesBatch(operation,
+ specy,
+ sortedBatchWeight,
+ null,
enumerationFile.PMFM_ID_SORTED_UNSORTED,
- sortedCaracteristic);
+ caracteristicQualitativeValue);
- batch = persistenceService.createSpeciesBatch(batch, null);
+ rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
- persistFrequencies(batch, batchModel);
+ createCategoryBatches(operation, specy, batchs, rootBatch, sortedBatchWeight != null);
- } else {
+ }
- // batch with categories
+ }
- SpeciesBatch rootBatch = createSpeciesBatch(operation,
- specy,
- null,
- null,
- enumerationFile.PMFM_ID_SORTED_UNSORTED,
- sortedCaracteristic);
+ protected void persistUnsortedBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs) {
- rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
+ CaracteristicQualitativeValue caracteristicQualitativeValue = unsortedCaracteristic;
+ if (batchs.size() == 1 && !batchs.get(0).withCategories()) {
- for (PsionImportBatchModel batchModel : batchs) {
+ PsionImportBatchModel batchModel = batchs.get(0);
- SpeciesBatch parentBatch = rootBatch;
+ // simple batch with no category
+ SpeciesBatch batch = createSpeciesBatch(operation,
+ batchModel.getSpecies(),
+ batchModel.getWeight(),
+ batchModel.getSampleWeight(),
+ enumerationFile.PMFM_ID_SORTED_UNSORTED,
+ caracteristicQualitativeValue);
- SpeciesBatch childBatch = null;
+ batch = persistenceService.createSpeciesBatch(batch, null);
- Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batchModel.getCategoryIterator();
+ persistFrequencies(batch, batchModel);
- while (categoryIterator.hasNext()) {
- PsionImportBatchModel.SampleCategory sampleCategory = categoryIterator.next();
+ } else {
- boolean lastCategory = !categoryIterator.hasNext();
+ // batch with categories
- Integer categoryId = sampleCategory.getCategoryId();
- Serializable categoryValue = sampleCategory.getCategoryValue();
+ SpeciesBatch rootBatch = createSpeciesBatch(operation,
+ specy,
+ null,
+ null,
+ enumerationFile.PMFM_ID_SORTED_UNSORTED,
+ caracteristicQualitativeValue);
- if (lastCategory) {
+ rootBatch = persistenceService.createSpeciesBatch(rootBatch, null);
- // always create the leaf
- childBatch = createSpeciesBatch(operation,
- specy,
- batchModel.getWeight(),
- batchModel.getSampleWeight(),
- categoryId,
- categoryValue);
- } else {
+ createCategoryBatches(operation, specy, batchs, rootBatch, false);
- // try to find child in parent children
+ }
- childBatch = null;
- for (SpeciesBatch speciesBatch : parentBatch.getChildBatchs()) {
+ }
- if (speciesBatch.getSampleCategoryId().equals(categoryId) &&
- speciesBatch.getSampleCategoryValue().equals(categoryValue)) {
- childBatch = speciesBatch;
- break;
- }
- }
+ protected void createCategoryBatches(FishingOperation operation,
+ Species specy,
+ List<PsionImportBatchModel> batchs,
+ SpeciesBatch rootBatch,
+ boolean applyOnlySampleWeight) {
- if (childBatch == null) {
+ for (PsionImportBatchModel batchModel : batchs) {
- // must create it
- childBatch = createSpeciesBatch(operation,
- specy,
- null,
- null,
- categoryId,
- categoryValue);
- }
- }
+ SpeciesBatch parentBatch = rootBatch;
- if (TuttiEntities.isNew(childBatch)) {
+ SpeciesBatch childBatch = null;
- // persist it
- childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId());
- parentBatch.addChildBatchs(childBatch);
+ Iterator<PsionImportBatchModel.SampleCategory> categoryIterator = batchModel.getCategoryIterator();
+
+ while (categoryIterator.hasNext()) {
+ PsionImportBatchModel.SampleCategory sampleCategory = categoryIterator.next();
+
+ boolean lastCategory = !categoryIterator.hasNext();
+
+ Integer categoryId = sampleCategory.getCategoryId();
+ Serializable categoryValue = sampleCategory.getCategoryValue();
+
+ if (lastCategory) {
+
+ // always create the leaf
+
+ Float weight;
+ Float sampleWeight;
+
+ if (applyOnlySampleWeight) {
+ weight = batchModel.getSampleWeight();
+ sampleWeight = null;
+ } else {
+ weight = batchModel.getWeight();
+ sampleWeight = batchModel.getSampleWeight();
+ }
+ childBatch = createSpeciesBatch(operation,
+ specy,
+ weight,
+ sampleWeight,
+ categoryId,
+ categoryValue);
+ } else {
+
+ // try to find child in parent children
+
+ childBatch = null;
+ for (SpeciesBatch speciesBatch : parentBatch.getChildBatchs()) {
+
+ if (speciesBatch.getSampleCategoryId().equals(categoryId) &&
+ speciesBatch.getSampleCategoryValue().equals(categoryValue)) {
+ childBatch = speciesBatch;
+ break;
}
+ }
- parentBatch = childBatch;
+ if (childBatch == null) {
+
+ // must create it
+ childBatch = createSpeciesBatch(operation,
+ specy,
+ null,
+ null,
+ categoryId,
+ categoryValue);
}
+ }
- persistFrequencies(childBatch, batchModel);
+ if (TuttiEntities.isNew(childBatch)) {
+
+ // persist it
+ childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId());
+ parentBatch.addChildBatchs(childBatch);
}
+
+ parentBatch = childBatch;
}
- result.incrementNbImported();
+
+ persistFrequencies(childBatch, batchModel);
}
-
- persistenceService.saveCatchBatch(catchBatch);
}
protected PsionImportBatchModel.SampleCategory guessCategory(String categoryCode) {
Modified: branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2014-05-13 20:52:44 UTC (rev 1762)
@@ -160,6 +160,7 @@
tutti.service.protocol.import.species.error=
tutti.service.protocol.import.taxonUsed.error=
tutti.service.psion.import.attachment.comment=
+tutti.service.psionimport.error.inconsistentVracWeight.message=
tutti.service.psionimport.error.invalid.category.syntax=
tutti.service.psionimport.error.invalid.command.syntax=
tutti.service.psionimport.error.invalid.date.format=
Modified: branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2014-05-13 20:52:44 UTC (rev 1762)
@@ -159,6 +159,7 @@
tutti.service.protocol.import.species.error=Erreur lors de l'import des espèces du protocole %1s du fichier %2s
tutti.service.protocol.import.taxonUsed.error=Le taxon référent d'id %s est déjà utilisé
tutti.service.psion.import.attachment.comment=Import Psion du %s
+tutti.service.psionimport.error.inconsistentVracWeight.message=Pour l'espèce '%s', il existe deux enregistrements de lot vrac avec le champs 'POID' différent, ce qui est interdit
tutti.service.psionimport.error.invalid.category.syntax=Ligne %s, catégorisation '%s' inconnue, l'espèce %s sera ignorée
tutti.service.psionimport.error.invalid.command.syntax=Ligne %s, la commande '%s' n'est pas reconnue
tutti.service.psionimport.error.invalid.date.format=Format de la date du trait incorrecte (mm-dd-aaaa)
Modified: branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -24,12 +24,16 @@
* #L%
*/
+import com.google.common.base.Predicate;
import fr.ifremer.tutti.TuttiConfigurationOption;
import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
@@ -79,6 +83,8 @@
protected File dataDirectory;
+ protected Predicate<SpeciesAbleBatch> vracPredicate;
+
@Before
public void setUp() throws Exception {
@@ -99,6 +105,9 @@
progressionModel.setTotal(9);
dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, OPERATION_2_ID, OPERATION_1_ID, OPERATION_3_ID);
+
+ TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
+ vracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID);
}
@Test
@@ -111,24 +120,55 @@
catchBatch.setFishingOperation(operation);
BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
- int oldNbBatchs = rootSpeciesBatch.sizeChildren();
+ int oldSortedBatchs = 0;
+ int oldUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ oldSortedBatchs++;
+ } else {
+ oldUnsortedBatchs++;
+ }
+ }
+
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(17, nbAdded);
+ int nbNewSortedBatchs = 10;
+ int nbNewUnsortedBatchs = 9;
+ Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded);
+ Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded);
Assert.assertEquals(0, errors.size());
// no batch imported
BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null);
- Assert.assertEquals(oldNbBatchs + 17, rootSpeciesBatchAfter.sizeChildren());
+
+ int totalSortedBatchs = 0;
+ int totalUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ totalSortedBatchs++;
+ } else {
+ totalUnsortedBatchs++;
+ }
+ }
+
+ Assert.assertEquals(oldSortedBatchs + nbNewSortedBatchs, totalSortedBatchs);
+ Assert.assertEquals(oldUnsortedBatchs + nbNewUnsortedBatchs, totalUnsortedBatchs);
}
@Test
@@ -141,23 +181,54 @@
catchBatch.setFishingOperation(operation);
BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
- int oldNbBatchs = rootSpeciesBatch.sizeChildren();
+ int oldSortedBatchs = 0;
+ int oldUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) {
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ oldSortedBatchs++;
+ } else {
+ oldUnsortedBatchs++;
+ }
+ }
+
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(10, nbAdded);
+ int nbNewSortedBatchs = 0;
+ int nbNewUnsortedBatchs = 10;
+ Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded);
+ Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded);
Assert.assertEquals(0, errors.size());
BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null);
- Assert.assertEquals(oldNbBatchs + 10, rootSpeciesBatchAfter.sizeChildren());
+
+ int totalSortedBatchs = 0;
+ int totalUnsortedBatchs = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ boolean sorted = vracPredicate.apply(speciesBatch);
+
+ if (sorted) {
+ totalSortedBatchs++;
+ } else {
+ totalUnsortedBatchs++;
+ }
+ }
+
+ Assert.assertEquals(oldSortedBatchs + nbNewSortedBatchs, totalSortedBatchs);
+ Assert.assertEquals(oldUnsortedBatchs + nbNewUnsortedBatchs, totalUnsortedBatchs);
}
@Test
@@ -173,15 +244,18 @@
int oldNbBatchs = rootSpeciesBatch.sizeChildren();
PsionImportResult importResult = service.importFile(importFile, operation, catchBatch);
- int nbAdded = importResult.getNbImported();
+ int nbSortedAdded = importResult.getNbSortedImported();
+ int nbUnsortedAdded = importResult.getNbUnsortedImported();
List<String> errors = importResult.getErrors();
if (log.isInfoEnabled()) {
- log.info("Imported: " + nbAdded);
+ log.info("Sorted Imported: " + nbSortedAdded);
+ log.info("Unsorted Imported: " + nbUnsortedAdded);
log.info("Errors: " + errors.size());
}
- Assert.assertEquals(0, nbAdded);
+ Assert.assertEquals(0, nbSortedAdded);
+ Assert.assertEquals(0, nbUnsortedAdded);
Assert.assertEquals(1, errors.size());
// no batch imported
Modified: branches/tutti-3.4.x/tutti-service/src/test/resources/psion/CC053.IWA
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/resources/psion/CC053.IWA 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/test/resources/psion/CC053.IWA 2014-05-13 20:52:44 UTC (rev 1762)
@@ -1,5 +1,5 @@
cc
-A
+1
07-01-2013
07:19:11
Modified: branches/tutti-3.4.x/tutti-service/src/test/resources/psion/FM001.IWA
===================================================================
--- branches/tutti-3.4.x/tutti-service/src/test/resources/psion/FM001.IWA 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-service/src/test/resources/psion/FM001.IWA 2014-05-13 20:52:44 UTC (rev 1762)
@@ -1,5 +1,5 @@
fm
-A
+1
07-01-2013
18:28:13
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java 2014-05-13 20:52:44 UTC (rev 1762)
@@ -125,7 +125,7 @@
if (importResult.isDone()) {
sendMessage(t("tutti.editSpeciesBatch.action.importPsion.success",
- importResult.getNbImported()));
+ importResult.getNbSortedImported(), importResult.getNbUnsortedImported()));
} else {
StringBuilder sb = new StringBuilder();
Modified: branches/tutti-3.4.x/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- branches/tutti-3.4.x/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2014-05-13 14:30:26 UTC (rev 1761)
+++ branches/tutti-3.4.x/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2014-05-13 20:52:44 UTC (rev 1762)
@@ -982,7 +982,7 @@
tutti.editSpeciesBatch.action.importPsion.no.matching.data=Import psion non réalisé (des erreurs ont été détectées lors de la lecture du fichier)
tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation=L'import Psion n'a pas été réalisé, des erreurs ont été détectées \:<ul>%s</ul><br/>Aucun lot n'a donc été importé.
tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation.title=Import Psion
-tutti.editSpeciesBatch.action.importPsion.success=Import Psion réussi \: %1s espèces importées
+tutti.editSpeciesBatch.action.importPsion.success=Import Psion réussi \: %1s espèces importées (Vrac), %2s espèces importées (Hors-Vrac)
tutti.editSpeciesBatch.action.importPsion.tip=Import Psion
tutti.editSpeciesBatch.action.importPupitri=Import Pupitri
tutti.editSpeciesBatch.action.importPupitri.existingData.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas importer les données Pupitri et conserver les espèces saisies</li><li><strong>OK</strong> pour supprimer les espèces existantes et les remplacer par les données de Pupitri</li></ul>
1
0