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
- 4130 discussions
r243 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/config java/fr/ifremer/tutti/ui/swing/content/operation java/fr/ifremer/tutti/ui/swing/util/editor resources/fr/ifremer/tutti/ui/swing/content/operation resources/i18n
by kmorinīŧ users.forge.codelutin.com 23 Jan '13
by kmorinīŧ users.forge.codelutin.com 23 Jan '13
23 Jan '13
Author: kmorin
Date: 2013-01-23 16:58:55 +0100 (Wed, 23 Jan 2013)
New Revision: 243
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/243
Log:
add the DMD editor + debug validation
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CoordinateEditorType.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
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/EditFishingOperationUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUI.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -117,5 +117,13 @@
* @since 0.1
*/
public static final String DECIMAL3_PATTERN = "\\d{0,6}|\\d{1,6}.\\d{0,3}";
+
+ /**
+ * Pattern to use for decimal numeric values with 2 digits + 3 decimal digits in
+ * editors.
+ *
+ * @since 1.0
+ */
+ public static final String DECIMAL2_3_PATTERN = "\\d{0,2}|\\d{1,2}\\.\\d{0,3}";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfig.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -27,6 +27,7 @@
import com.google.common.base.Throwables;
import fr.ifremer.tutti.service.TuttiServiceTechnicalException;
import fr.ifremer.tutti.service.config.TuttiServiceConfig;
+import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.logging.Log;
@@ -129,8 +130,9 @@
return applicationConfig.getOptionAsBoolean(TuttiConfigOption.SHOW_NUMBER_EDITOR_BUTTON.getKey());
}
- public boolean isUseSexagecimalEditor() {
- return applicationConfig.getOptionAsBoolean(TuttiConfigOption.USE_SEXAGECIMAL_EDITOR.getKey());
+ public CoordinateEditorType getCoordinateEditorType() {
+ String value = applicationConfig.getOption(TuttiConfigOption.COORDINATE_EDITOR_TYPE.getKey());
+ return CoordinateEditorType.valueOf(value);
}
public String getProgramId() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigOption.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import org.nuiton.util.ApplicationConfig;
import javax.swing.KeyStroke;
@@ -100,11 +101,11 @@
"alt pressed F",
KeyStroke.class),
- USE_SEXAGECIMAL_EDITOR(
- "tutti.ui.useSexagecimalEditor",
- n_("tutti.config.ui.useSexagecimalEditor"),
- "false",
- Boolean.class);
+ COORDINATE_EDITOR_TYPE(
+ "tutti.ui.coordinateEditorType",
+ n_("tutti.config.ui.coordinateEditorType"),
+ CoordinateEditorType.DD.toString(),
+ CoordinateEditorType.class);
/** Configuration key. */
private final String key;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/config/TuttiConfigUI.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -108,7 +108,7 @@
CALLBACK_UI)
.addOption(TuttiConfigOption.COLOR_ROW_INVALID)
.addOption(TuttiConfigOption.COLOR_ROW_READ_ONLY)
- .addOption(TuttiConfigOption.USE_SEXAGECIMAL_EDITOR);
+ .addOption(TuttiConfigOption.COORDINATE_EDITOR_TYPE);
// SHORTCUT
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-01-23 15:58:55 UTC (rev 243)
@@ -137,9 +137,8 @@
text: "tutti.label.fishingOperation.gearShootingEnd";
}
-
CardLayout2Ext {
- selected: {handler.getConfig().isUseSexagecimalEditor() ? "DMS" : "DD"};
+ selected: { ((CoordinateEditorType)handler.getConfig().getCoordinateEditorType()).toString() };
}
#traitVesselPanel {
@@ -192,6 +191,13 @@
numberPattern: {INT_2_DIGITS_PATTERN};
}
+.decimalMinute {
+ showReset: false;
+ useFloat: true;
+ useSign: false;
+ numberPattern: {DECIMAL2_3_PATTERN};
+}
+
.second {
showReset: false;
useFloat: false;
@@ -219,6 +225,17 @@
model: {model.getGearShootingStartLongitudeSecond()};
}
+#gearShootingStartLongitudeDMDDegreeField {
+ property: gearShootingStartLongitudeDegree;
+ model: {model.getGearShootingStartLongitudeDegree()};
+ numberPattern: {SIGNED_INT_3_DIGITS_PATTERN};
+}
+
+#gearShootingStartLongitudeDMDMinuteField {
+ property: gearShootingStartLongitudeDecimalMinute;
+ model: {model.getGearShootingStartLongitudeDecimalMinute()};
+}
+
#gearShootingStartLongitudeDDField {
property: gearShootingStartLongitude;
model: {model.getGearShootingStartLongitude()};
@@ -247,6 +264,17 @@
model: {model.getGearShootingStartLatitudeSecond()};
}
+#gearShootingStartLatitudeDMDDegreeField {
+ property: gearShootingStartLatitudeDegree;
+ model: {model.getGearShootingStartLatitudeDegree()};
+ numberPattern: {SIGNED_INT_2_DIGITS_PATTERN};
+}
+
+#gearShootingStartLatitudeDMDMinuteField {
+ property: gearShootingStartLatitudeDecimalMinute;
+ model: {model.getGearShootingStartLatitudeDecimalMinute()};
+}
+
#gearShootingStartLatitudeDDField {
property: gearShootingStartLatitude;
model: {model.getGearShootingStartLatitude()};
@@ -285,6 +313,17 @@
model: {model.getGearShootingEndLongitudeSecond()};
}
+#gearShootingEndLongitudeDMDDegreeField {
+ property: gearShootingEndLongitudeDegree;
+ model: {model.getGearShootingEndLongitudeDegree()};
+ numberPattern: {SIGNED_INT_3_DIGITS_PATTERN};
+}
+
+#gearShootingEndLongitudeDMDMinuteField {
+ property: gearShootingEndLongitudeDecimalMinute;
+ model: {model.getGearShootingEndLongitudeDecimalMinute()};
+}
+
#gearShootingEndLongitudeDDField {
property: gearShootingEndLongitude;
model: {model.getGearShootingEndLongitude()};
@@ -313,6 +352,17 @@
model: {model.getGearShootingEndLatitudeSecond()};
}
+#gearShootingEndLatitudeDMDDegreeField {
+ property: gearShootingEndLatitudeDegree;
+ model: {model.getGearShootingEndLatitudeDegree()};
+ numberPattern: {SIGNED_INT_2_DIGITS_PATTERN};
+}
+
+#gearShootingEndLatitudeDMDMinuteField {
+ property: gearShootingEndLatitudeDecimalMinute;
+ model: {model.getGearShootingEndLatitudeDecimalMinute()};
+}
+
#gearShootingEndLatitudeDDField {
property: gearShootingEndLatitude;
model: {model.getGearShootingEndLatitude()};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-01-23 15:58:55 UTC (rev 243)
@@ -30,11 +30,12 @@
fr.ifremer.tutti.persistence.entities.referential.Gear
fr.ifremer.tutti.persistence.entities.referential.Person
fr.ifremer.tutti.persistence.entities.referential.Vessel
-
- fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor
+
fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI
fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI
fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI
+ fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType
+ fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor
jaxx.runtime.swing.editor.bean.BeanComboBox
jaxx.runtime.swing.editor.bean.BeanListHeader
@@ -100,6 +101,10 @@
component='gearShootingStartLatitudeDMSMinuteField'/>
<field name='gearShootingStartLatitudeSecond'
component='gearShootingStartLatitudeDMSSecondField'/>
+ <field name='gearShootingStartLatitudeDecimalDegree'
+ component='gearShootingStartLatitudeDMDDegreeField'/>
+ <field name='gearShootingStartLatitudeDecimalMinute'
+ component='gearShootingStartLatitudeDMDMinuteField'/>
<field name='gearShootingStartLongitude'
component='gearShootingStartLongitudeDDField'/>
<field name='gearShootingStartLongitudeDegree'
@@ -108,6 +113,10 @@
component='gearShootingStartLongitudeDMSMinuteField'/>
<field name='gearShootingStartLongitudeSecond'
component='gearShootingStartLongitudeDMSSecondField'/>
+ <field name='gearShootingStartLongitudeDecimalDegree'
+ component='gearShootingStartLongitudeDMDDegreeField'/>
+ <field name='gearShootingStartLongitudeDecimalMinute'
+ component='gearShootingStartLongitudeDMDMinuteField'/>
<field name='gearShootingEndLatitude'
component='gearShootingEndLatitudeDDField'/>
<field name='gearShootingEndLatitudeDegree'
@@ -116,6 +125,10 @@
component='gearShootingEndLatitudeDMSMinuteField'/>
<field name='gearShootingEndLatitudeSecond'
component='gearShootingEndLatitudeDMSSecondField'/>
+ <field name='gearShootingEndLatitudeDecimalDegree'
+ component='gearShootingEndLatitudeDMDDegreeField'/>
+ <field name='gearShootingEndLatitudeDecimalMinute'
+ component='gearShootingEndLatitudeDMDMinuteField'/>
<field name='gearShootingEndLongitude'
component='gearShootingEndLongitudeDDField'/>
<field name='gearShootingEndLongitudeDegree'
@@ -124,6 +137,10 @@
component='gearShootingEndLongitudeDMSMinuteField'/>
<field name='gearShootingEndLongitudeSecond'
component='gearShootingEndLongitudeDMSSecondField'/>
+ <field name='gearShootingEndLongitudeDecimalDegree'
+ component='gearShootingEndLongitudeDMDDegreeField'/>
+ <field name='gearShootingEndLongitudeDecimalMinute'
+ component='gearShootingEndLongitudeDMDMinuteField'/>
</BeanValidator>
<CardLayout2Ext id='gearShootingStartLongitudeLayout'
@@ -239,7 +256,16 @@
id='gearShootingStartLatitudeDMSSecondField'
constructorParams='this' styleClass='second'/>
</JPanel>
- <!-- -->
+ <JPanel layout="{new GridLayout(1,0)}"
+ constraints='"DMD"'>
+ <NumberEditor
+ id='gearShootingStartLatitudeDMDDegreeField'
+ constructorParams='this' styleClass='degree'/>
+
+ <NumberEditor
+ id='gearShootingStartLatitudeDMDMinuteField'
+ constructorParams='this' styleClass='decimalMinute'/>
+ </JPanel>
</JPanel>
</cell>
<cell weightx='1'>
@@ -261,6 +287,16 @@
id='gearShootingStartLongitudeDMSSecondField'
constructorParams='this' styleClass='second'/>
</JPanel>
+ <JPanel layout="{new GridLayout(1,0)}"
+ constraints='"DMD"'>
+ <NumberEditor
+ id='gearShootingStartLongitudeDMDDegreeField'
+ constructorParams='this' styleClass='degree'/>
+
+ <NumberEditor
+ id='gearShootingStartLongitudeDMDMinuteField'
+ constructorParams='this' styleClass='decimalMinute'/>
+ </JPanel>
</JPanel>
</cell>
<cell>
@@ -295,6 +331,16 @@
id='gearShootingEndLatitudeDMSSecondField'
constructorParams='this' styleClass='second'/>
</JPanel>
+ <JPanel layout="{new GridLayout(1,0)}"
+ constraints='"DMD"'>
+ <NumberEditor
+ id='gearShootingEndLatitudeDMDDegreeField'
+ constructorParams='this' styleClass='degree'/>
+
+ <NumberEditor
+ id='gearShootingEndLatitudeDMDMinuteField'
+ constructorParams='this' styleClass='decimalMinute'/>
+ </JPanel>
</JPanel>
</cell>
<cell weightx='1'>
@@ -316,6 +362,16 @@
id='gearShootingEndLongitudeDMSSecondField'
constructorParams='this' styleClass='second'/>
</JPanel>
+ <JPanel layout="{new GridLayout(1,0)}"
+ constraints='"DMD"'>
+ <NumberEditor
+ id='gearShootingEndLongitudeDMDDegreeField'
+ constructorParams='this' styleClass='degree'/>
+
+ <NumberEditor
+ id='gearShootingEndLongitudeDMDMinuteField'
+ constructorParams='this' styleClass='decimalMinute'/>
+ </JPanel>
</JPanel>
</cell>
<cell>
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 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -47,19 +47,17 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
-
/**
* Handler for UI {@link EditFishingOperationUI}.
*
@@ -117,6 +115,7 @@
public void beforeInitUI() {
EditFishingOperationUIModel model = new EditFishingOperationUIModel();
+ model.setCoordinateEditorType(getConfig().getCoordinateEditorType());
model.setValidationContext(getContext().getValidationContext());
model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_EMPTY, new PropertyChangeListener() {
@@ -419,34 +418,6 @@
//TODO
}
- public void setGearShootingStartLatitude(String text) {
- getModel().setGearShootingStartLatitude(Float.valueOf(text));
- }
-
- public void setGearShootingStartLatitudeDegree(String text) {
- getModel().setGearShootingStartLatitude(Float.valueOf(text));
- }
-
- public void setGearShootingStartLatitudeMinute(String text) {
- getModel().setGearShootingStartLatitude(Float.valueOf(text));
- }
-
- public void setGearShootingStartLatitudeSecond(String text) {
- getModel().setGearShootingStartLatitude(Float.valueOf(text));
- }
-
- public void setGearShootingStartLongitude(String text) {
- getModel().setGearShootingStartLongitude(Float.valueOf(text));
- }
-
- public void setGearShootingEndLatitude(String text) {
- getModel().setGearShootingEndLatitude(Float.valueOf(text));
- }
-
- public void setGearShootingEndLongitude(String text) {
- getModel().setGearShootingEndLongitude(Float.valueOf(text));
- }
-
public FishingOperationsUI getParentUi() {
return parentUi;
}
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 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -34,9 +34,12 @@
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.spatial.SexagecimalPosition;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -51,6 +54,8 @@
public class EditFishingOperationUIModel extends AbstractTuttiBeanUIModel<FishingOperation, EditFishingOperationUIModel> {
private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(EditFishingOperationUIModel.class);
public static final String TITLE =
n_("tutti.label.tab.fishingOperation.general");
@@ -70,8 +75,10 @@
public static final String PROPERTY_GEAR_SHOOTING_START_LATITUDE = "gearShootingStartLatitude";
public static final String PROPERTY_GEAR_SHOOTING_START_LATITUDE_DEGREE = "gearShootingStartLatitudeDegree";
-
+
public static final String PROPERTY_GEAR_SHOOTING_START_LATITUDE_MINUTE = "gearShootingStartLatitudeMinute";
+
+ public static final String PROPERTY_GEAR_SHOOTING_START_LATITUDE_DECIMAL_MINUTE = "gearShootingStartLatitudeDecimalMinute";
public static final String PROPERTY_GEAR_SHOOTING_START_LATITUDE_SECOND = "gearShootingStartLatitudeSecond";
@@ -80,6 +87,8 @@
public static final String PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DEGREE = "gearShootingStartLongitudeDegree";
public static final String PROPERTY_GEAR_SHOOTING_START_LONGITUDE_MINUTE = "gearShootingStartLongitudeMinute";
+
+ public static final String PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DECIMAL_MINUTE = "gearShootingStartLongitudeDecimalMinute";
public static final String PROPERTY_GEAR_SHOOTING_START_LONGITUDE_SECOND = "gearShootingStartLongitudeSecond";
@@ -90,6 +99,8 @@
public static final String PROPERTY_GEAR_SHOOTING_END_LATITUDE_DEGREE = "gearShootingEndLatitudeDegree";
public static final String PROPERTY_GEAR_SHOOTING_END_LATITUDE_MINUTE = "gearShootingEndLatitudeMinute";
+
+ public static final String PROPERTY_GEAR_SHOOTING_END_LATITUDE_DECIMAL_MINUTE = "gearShootingEndLatitudeDecimalMinute";
public static final String PROPERTY_GEAR_SHOOTING_END_LATITUDE_SECOND = "gearShootingEndLatitudeSecond";
@@ -98,6 +109,8 @@
public static final String PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DEGREE = "gearShootingEndLongitudeDegree";
public static final String PROPERTY_GEAR_SHOOTING_END_LONGITUDE_MINUTE = "gearShootingEndLongitudeMinute";
+
+ public static final String PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DECIMAL_MINUTE = "gearShootingEndLongitudeDecimalMinute";
public static final String PROPERTY_GEAR_SHOOTING_END_LONGITUDE_SECOND = "gearShootingEndLongitudeSecond";
@@ -184,6 +197,8 @@
protected Integer trawlNetNumber;
+ protected CoordinateEditorType coordinateEditorType;
+
protected static Binder<EditFishingOperationUIModel, FishingOperation> toBeanBinder =
BinderFactory.newBinder(EditFishingOperationUIModel.class,
FishingOperation.class);
@@ -291,7 +306,11 @@
}
return result;
}
-
+
+ public Integer getGearShootingStartLatitudeDecimalDegree() {
+ return getGearShootingStartLatitudeDegree();
+ }
+
public void setGearShootingStartLatitudeDegree(Integer degree) {
Object oldValue = getGearShootingStartLatitudeDegree();
boolean sign = degree != null && degree < 0;
@@ -302,6 +321,10 @@
gearShootingStartLatitudeAsSexagecimal.setDegre(degree);
firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LATITUDE_DEGREE, oldValue, degree);
}
+
+ public void setGearShootingStartLatitudeDecimalDegree(Integer degree) {
+ setGearShootingStartLatitudeDegree(degree);
+ }
public Integer getGearShootingStartLatitudeMinute() {
return gearShootingStartLatitudeAsSexagecimal.getMinute();
@@ -311,7 +334,17 @@
Object oldValue = getGearShootingStartLatitudeMinute();
gearShootingStartLatitudeAsSexagecimal.setMinute(minute);
firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LATITUDE_MINUTE, oldValue, minute);
+ }
+
+ public Float getGearShootingStartLatitudeDecimalMinute() {
+ return gearShootingStartLatitudeAsSexagecimal.getMinuteDecimale();
+ }
+ public void setGearShootingStartLatitudeDecimalMinute(Float decimalMinute) {
+ gearShootingStartLatitudeAsSexagecimal.setMinuteDecimale(decimalMinute);
+ // 2013-01-22 kmorin: pass null as previous value,
+ // otherwise the filed is not filled with the value (I cannot explain why... :()
+ firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LATITUDE_DECIMAL_MINUTE, null, decimalMinute);
}
public Integer getGearShootingStartLatitudeSecond() {
@@ -342,6 +375,10 @@
}
return result;
}
+
+ public Integer getGearShootingStartLongitudeDecimalDegree() {
+ return getGearShootingStartLongitudeDegree();
+ }
public void setGearShootingStartLongitudeDegree(Integer degree) {
Object oldValue = getGearShootingStartLongitudeDegree();
@@ -353,6 +390,10 @@
gearShootingStartLongitudeAsSexagecimal.setDegre(degree);
firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DEGREE, oldValue, degree);
}
+
+ public void setGearShootingStartLongitudeDecimalDegree(Integer degree) {
+ setGearShootingStartLongitudeDegree(degree);
+ }
public Integer getGearShootingStartLongitudeMinute() {
return gearShootingStartLongitudeAsSexagecimal.getMinute();
@@ -362,7 +403,17 @@
Object oldValue = getGearShootingStartLongitudeMinute();
gearShootingStartLongitudeAsSexagecimal.setMinute(minute);
firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LONGITUDE_MINUTE, oldValue, minute);
+ }
+
+ public Float getGearShootingStartLongitudeDecimalMinute() {
+ return gearShootingStartLongitudeAsSexagecimal.getMinuteDecimale();
+ }
+ public void setGearShootingStartLongitudeDecimalMinute(Float decimalMinute) {
+ gearShootingStartLongitudeAsSexagecimal.setMinuteDecimale(decimalMinute);
+ // 2013-01-22 kmorin: pass null as previous value,
+ // otherwise the filed is not filled with the value (I cannot explain why... :()
+ firePropertyChange(PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DECIMAL_MINUTE, null, decimalMinute);
}
public Integer getGearShootingStartLongitudeSecond() {
@@ -410,6 +461,10 @@
}
return result;
}
+
+ public Integer getGearShootingEndLatitudeDecimalDegree() {
+ return getGearShootingEndLatitudeDegree();
+ }
public void setGearShootingEndLatitudeDegree(Integer degree) {
Object oldValue = getGearShootingEndLatitudeDegree();
@@ -421,6 +476,10 @@
gearShootingEndLatitudeAsSexagecimal.setDegre(degree);
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LATITUDE_DEGREE, oldValue, degree);
}
+
+ public void setGearShootingEndLatitudeDecimalDegree(Integer degree) {
+ setGearShootingEndLatitudeDegree(degree);
+ }
public Integer getGearShootingEndLatitudeMinute() {
return gearShootingEndLatitudeAsSexagecimal.getMinute();
@@ -430,7 +489,17 @@
Object oldValue = getGearShootingEndLatitudeMinute();
gearShootingEndLatitudeAsSexagecimal.setMinute(minute);
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LATITUDE_MINUTE, oldValue, minute);
+ }
+
+ public Float getGearShootingEndLatitudeDecimalMinute() {
+ return gearShootingEndLatitudeAsSexagecimal.getMinuteDecimale();
+ }
+ public void setGearShootingEndLatitudeDecimalMinute(Float decimalMinute) {
+ gearShootingEndLatitudeAsSexagecimal.setMinuteDecimale(decimalMinute);
+ // 2013-01-22 kmorin: pass null as previous value,
+ // otherwise the filed is not filled with the value (I cannot explain why... :()
+ firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LATITUDE_DECIMAL_MINUTE, null, decimalMinute);
}
public Integer getGearShootingEndLatitudeSecond() {
@@ -460,6 +529,10 @@
}
return result;
}
+
+ public Integer getGearShootingEndLongitudeDecimalDegree() {
+ return getGearShootingEndLongitudeDegree();
+ }
public void setGearShootingEndLongitudeDegree(Integer degree) {
Object oldValue = getGearShootingEndLongitudeDegree();
@@ -471,6 +544,10 @@
gearShootingEndLongitudeAsSexagecimal.setDegre(degree);
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DEGREE, oldValue, degree);
}
+
+ public void setGearShootingEndLongitudeDecimalDegree(Integer degree) {
+ setGearShootingEndLongitudeDegree(degree);
+ }
public Integer getGearShootingEndLongitudeMinute() {
return gearShootingEndLongitudeAsSexagecimal.getMinute();
@@ -480,9 +557,19 @@
Object oldValue = getGearShootingEndLongitudeMinute();
gearShootingEndLongitudeAsSexagecimal.setMinute(minute);
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LONGITUDE_MINUTE, oldValue, minute);
+ }
+ public Float getGearShootingEndLongitudeDecimalMinute() {
+ return gearShootingEndLongitudeAsSexagecimal.getMinuteDecimale();
}
+ public void setGearShootingEndLongitudeDecimalMinute(Float decimalMinute) {
+ gearShootingEndLongitudeAsSexagecimal.setMinuteDecimale(decimalMinute);
+ // 2013-01-22 kmorin: pass null as previous value,
+ // otherwise the filed is not filled with the value (I cannot explain why... :()
+ firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DECIMAL_MINUTE, null, decimalMinute);
+ }
+
public Integer getGearShootingEndLongitudeSecond() {
return gearShootingEndLongitudeAsSexagecimal.getSeconde();
}
@@ -614,6 +701,14 @@
firePropertyChange(PROPERTY_TRAWL_NET_NUMBER, oldValue, trawlNetNumber);
}
+ public CoordinateEditorType getCoordinateEditorType() {
+ return coordinateEditorType;
+ }
+
+ public void setCoordinateEditorType(CoordinateEditorType coordinateEditorType) {
+ this.coordinateEditorType = coordinateEditorType;
+ }
+
@Override
protected FishingOperation newEntity() {
return fishingOperation;
@@ -631,6 +726,7 @@
setGearShootingStartLatitudeDegree(degree);
setGearShootingStartLatitudeMinute(position.getMinute());
setGearShootingStartLatitudeSecond(position.getSeconde());
+ setGearShootingStartLatitudeDecimalMinute(position.getMinuteDecimale());
position = SexagecimalPosition.valueOf(gearShootingStartLongitude);
degree = position.getDegre();
@@ -640,6 +736,7 @@
setGearShootingStartLongitudeDegree(degree);
setGearShootingStartLongitudeMinute(position.getMinute());
setGearShootingStartLongitudeSecond(position.getSeconde());
+ setGearShootingStartLongitudeDecimalMinute(position.getMinuteDecimale());
position = SexagecimalPosition.valueOf(gearShootingEndLatitude);
degree = position.getDegre();
@@ -652,6 +749,7 @@
setGearShootingEndLatitudeDegree(degree);
setGearShootingEndLatitudeMinute(position.getMinute());
setGearShootingEndLatitudeSecond(position.getSeconde());
+ setGearShootingEndLatitudeDecimalMinute(position.getMinuteDecimale());
position = SexagecimalPosition.valueOf(gearShootingEndLongitude);
degree = position.getDegre();
@@ -661,6 +759,7 @@
setGearShootingEndLongitudeDegree(degree);
setGearShootingEndLongitudeMinute(position.getMinute());
setGearShootingEndLongitudeSecond(position.getSeconde());
+ setGearShootingEndLongitudeDecimalMinute(position.getMinuteDecimale());
}
public void convertGearShootingCoordinatesDMSToDD() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -28,6 +28,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,7 +74,7 @@
log.warn("Won't save new fishing operation, use explicit save button instead...");
}
} else if (beanToSave.isValid()) {
- if (handler.getConfig().isUseSexagecimalEditor()) {
+ if (beanToSave.getCoordinateEditorType() != CoordinateEditorType.DD) {
beanToSave.convertGearShootingCoordinatesDMSToDD();
}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CoordinateEditorType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CoordinateEditorType.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CoordinateEditorType.java 2013-01-23 15:58:55 UTC (rev 243)
@@ -0,0 +1,13 @@
+
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+/**
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public enum CoordinateEditorType {
+
+ DMS, DD, DMD
+
+}
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-edit-warning-validation.xml 2013-01-23 15:58:55 UTC (rev 243)
@@ -38,7 +38,8 @@
<param name="doubleParams">min:90.0|max:90.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingStartLatitude && gearShootingStartLatitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingStartLatitude && gearShootingStartLatitude <= doubles.max )
]]>
</param>
@@ -54,7 +55,7 @@
<param name="intParams">min:90|max:90</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
( -ints.min < getGearShootingStartLatitudeDegree() && getGearShootingStartLatitudeDegree() < ints.max )
|| (
( getGearShootingStartLatitudeDegree() == ints.max || getGearShootingStartLatitudeDegree() == -ints.min )
@@ -69,14 +70,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLatitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:90|max:90</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ ( -ints.min < getGearShootingStartLatitudeDecimalDegree() && getGearShootingStartLatitudeDecimalDegree() < ints.max )
+ || (
+ ( getGearShootingStartLatitudeDecimalDegree() == ints.max || getGearShootingStartLatitudeDecimalDegree() == -ints.min )
+ && getGearShootingStartLatitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.latitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLatitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLatitudeMinute() && getGearShootingStartLatitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLatitudeMinute() && getGearShootingStartLatitudeMinute() < ints.max )
]]>
</param>
@@ -85,14 +109,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLatitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingStartLatitudeDecimalMinute() && getGearShootingStartLatitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.latitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLatitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLatitudeSecond() && getGearShootingStartLatitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLatitudeSecond() && getGearShootingStartLatitudeSecond() < ints.max )
]]>
</param>
@@ -110,7 +151,8 @@
<param name="doubleParams">min:180.0|max:180.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingStartLongitude && gearShootingStartLongitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingStartLongitude && gearShootingStartLongitude <= doubles.max )
]]>
</param>
@@ -126,7 +168,7 @@
<param name="intParams">min:180|max:180</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingStartLongitudeDegree() && getGearShootingStartLongitudeDegree() < ints.max)
|| (
( getGearShootingStartLongitudeDegree() == ints.max || getGearShootingStartLongitudeDegree() == -ints.min )
@@ -141,14 +183,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLongitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:180|max:180</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingStartLongitudeDecimalDegree() && getGearShootingStartLongitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingStartLongitudeDecimalDegree() == ints.max || getGearShootingStartLongitudeDecimalDegree() == -ints.min )
+ && getGearShootingStartLongitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.longitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLongitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLongitudeMinute() && getGearShootingStartLongitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLongitudeMinute() && getGearShootingStartLongitudeMinute() < ints.max )
]]>
</param>
@@ -157,14 +222,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLongitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingStartLongitudeDecimalMinute() && getGearShootingStartLongitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.longitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLongitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLongitudeSecond() && getGearShootingStartLongitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLongitudeSecond() && getGearShootingStartLongitudeSecond() < ints.max )
]]>
</param>
@@ -182,7 +264,8 @@
<param name="doubleParams">min:90.0|max:90.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingEndLatitude && gearShootingEndLatitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingEndLatitude && gearShootingEndLatitude <= doubles.max )
]]>
</param>
@@ -199,7 +282,7 @@
<param name="intParams">min:90|max:90</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingEndLatitudeDegree() && getGearShootingEndLatitudeDegree() < ints.max)
|| (
( getGearShootingEndLatitudeDegree() == ints.max || getGearShootingEndLatitudeDegree() == -ints.min )
@@ -214,14 +297,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLatitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:90|max:90</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingEndLatitudeDecimalDegree() && getGearShootingEndLatitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingEndLatitudeDecimalDegree() == ints.max || getGearShootingEndLatitudeDecimalDegree() == -ints.min )
+ && getGearShootingEndLatitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.latitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLatitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLatitudeMinute() && getGearShootingEndLatitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLatitudeMinute() && getGearShootingEndLatitudeMinute() < ints.max )
]]>
</param>
@@ -230,14 +336,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLatitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingEndLatitudeDecimalMinute() && getGearShootingEndLatitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.latitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLatitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLatitudeSecond() && getGearShootingEndLatitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLatitudeSecond() && getGearShootingEndLatitudeSecond() < ints.max )
]]>
</param>
@@ -255,7 +378,8 @@
<param name="doubleParams">min:180.0|max:180.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingEndLongitude && gearShootingEndLongitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingEndLongitude && gearShootingEndLongitude <= doubles.max )
]]>
</param>
@@ -271,7 +395,7 @@
<param name="intParams">min:180|max:180</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingEndLongitudeDegree() && getGearShootingEndLongitudeDegree() < ints.max)
|| (
( getGearShootingEndLongitudeDegree() == ints.max || getGearShootingEndLongitudeDegree() == -ints.min )
@@ -286,14 +410,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLongitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:180|max:180</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingEndLongitudeDecimalDegree() && getGearShootingEndLongitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingEndLongitudeDecimalDegree() == ints.max || getGearShootingEndLongitudeDecimalDegree() == -ints.min )
+ && getGearShootingEndLongitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.longitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLongitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLongitudeMinute() && getGearShootingEndLongitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLongitudeMinute() && getGearShootingEndLongitudeMinute() < ints.max )
]]>
</param>
@@ -303,13 +450,30 @@
</field>
+ <field name="gearShootingEndLongitudeDecimalMinute">
+
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingEndLongitudeDecimalMinute() && getGearShootingEndLongitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.longitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLongitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLongitudeSecond() && getGearShootingEndLongitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLongitudeSecond() && getGearShootingEndLongitudeSecond() < ints.max )
]]>
</param>
Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml 2013-01-23 15:58:55 UTC (rev 243)
@@ -74,13 +74,14 @@
<!--gear shooting start latitude validation -->
- <field name="gearShootingStartLatitude">
+ <field name="gearShootingStartLatitude">
<field-validator type="fieldexpressionwithparams">
<param name="doubleParams">min:90.0|max:90.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingStartLatitude && gearShootingStartLatitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingStartLatitude && gearShootingStartLatitude <= doubles.max )
]]>
</param>
@@ -96,7 +97,7 @@
<param name="intParams">min:90|max:90</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
( -ints.min < getGearShootingStartLatitudeDegree() && getGearShootingStartLatitudeDegree() < ints.max )
|| (
( getGearShootingStartLatitudeDegree() == ints.max || getGearShootingStartLatitudeDegree() == -ints.min )
@@ -111,14 +112,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLatitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:90|max:90</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ ( -ints.min < getGearShootingStartLatitudeDecimalDegree() && getGearShootingStartLatitudeDecimalDegree() < ints.max )
+ || (
+ ( getGearShootingStartLatitudeDecimalDegree() == ints.max || getGearShootingStartLatitudeDecimalDegree() == -ints.min )
+ && getGearShootingStartLatitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.latitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLatitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLatitudeMinute() && getGearShootingStartLatitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLatitudeMinute() && getGearShootingStartLatitudeMinute() < ints.max )
]]>
</param>
@@ -127,14 +151,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLatitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingStartLatitudeDecimalMinute() && getGearShootingStartLatitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.latitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLatitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLatitudeSecond() && getGearShootingStartLatitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLatitudeSecond() && getGearShootingStartLatitudeSecond() < ints.max )
]]>
</param>
@@ -152,7 +193,8 @@
<param name="doubleParams">min:180.0|max:180.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingStartLongitude && gearShootingStartLongitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingStartLongitude && gearShootingStartLongitude <= doubles.max )
]]>
</param>
@@ -168,7 +210,7 @@
<param name="intParams">min:180|max:180</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingStartLongitudeDegree() && getGearShootingStartLongitudeDegree() < ints.max)
|| (
( getGearShootingStartLongitudeDegree() == ints.max || getGearShootingStartLongitudeDegree() == -ints.min )
@@ -183,14 +225,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLongitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:180|max:180</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingStartLongitudeDecimalDegree() && getGearShootingStartLongitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingStartLongitudeDecimalDegree() == ints.max || getGearShootingStartLongitudeDecimalDegree() == -ints.min )
+ && getGearShootingStartLongitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.longitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLongitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLongitudeMinute() && getGearShootingStartLongitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLongitudeMinute() && getGearShootingStartLongitudeMinute() < ints.max )
]]>
</param>
@@ -199,14 +264,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingStartLongitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingStartLongitudeDecimalMinute() && getGearShootingStartLongitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.longitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingStartLongitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingStartLongitudeSecond() && getGearShootingStartLongitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingStartLongitudeSecond() && getGearShootingStartLongitudeSecond() < ints.max )
]]>
</param>
@@ -224,7 +306,8 @@
<param name="doubleParams">min:90.0|max:90.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingEndLatitude && gearShootingEndLatitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingEndLatitude && gearShootingEndLatitude <= doubles.max )
]]>
</param>
@@ -241,7 +324,7 @@
<param name="intParams">min:90|max:90</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingEndLatitudeDegree() && getGearShootingEndLatitudeDegree() < ints.max)
|| (
( getGearShootingEndLatitudeDegree() == ints.max || getGearShootingEndLatitudeDegree() == -ints.min )
@@ -256,14 +339,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLatitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:90|max:90</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingEndLatitudeDecimalDegree() && getGearShootingEndLatitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingEndLatitudeDecimalDegree() == ints.max || getGearShootingEndLatitudeDecimalDegree() == -ints.min )
+ && getGearShootingEndLatitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.latitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLatitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLatitudeMinute() && getGearShootingEndLatitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLatitudeMinute() && getGearShootingEndLatitudeMinute() < ints.max )
]]>
</param>
@@ -272,14 +378,31 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLatitudeDecimalMinute">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingEndLatitudeDecimalMinute() && getGearShootingEndLatitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.latitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLatitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLatitudeSecond() && getGearShootingEndLatitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLatitudeSecond() && getGearShootingEndLatitudeSecond() < ints.max )
]]>
</param>
@@ -297,7 +420,8 @@
<param name="doubleParams">min:180.0|max:180.0</param>
<param name="expression">
<![CDATA[
- useSexagecimalFormat || ( -doubles.min <= gearShootingEndLongitude && gearShootingEndLongitude <= doubles.max )
+ !"DD".equals(coordinateEditorType.toString()) ||
+ ( -doubles.min <= gearShootingEndLongitude && gearShootingEndLongitude <= doubles.max )
]]>
</param>
@@ -313,7 +437,7 @@
<param name="intParams">min:180|max:180</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || (
+ !"DMS".equals(coordinateEditorType.toString()) || (
(-ints.min < getGearShootingEndLongitudeDegree() && getGearShootingEndLongitudeDegree() < ints.max)
|| (
( getGearShootingEndLongitudeDegree() == ints.max || getGearShootingEndLongitudeDegree() == -ints.min )
@@ -328,14 +452,37 @@
</field-validator>
</field>
+
+ <field name="gearShootingEndLongitudeDecimalDegree">
+ <field-validator type="fieldexpressionwithparams">
+ <param name="intParams">min:180|max:180</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) || (
+ (-ints.min < getGearShootingEndLongitudeDecimalDegree() && getGearShootingEndLongitudeDecimalDegree() < ints.max)
+ || (
+ ( getGearShootingEndLongitudeDecimalDegree() == ints.max || getGearShootingEndLongitudeDecimalDegree() == -ints.min )
+ && getGearShootingEndLongitudeDecimalMinute() == 0.0
+ )
+ )
+ ]]>
+ </param>
+
+ <message>tutti.validator.warning.longitude.degree.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLongitudeMinute">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLongitudeMinute() && getGearShootingEndLongitudeMinute() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLongitudeMinute() && getGearShootingEndLongitudeMinute() < ints.max )
]]>
</param>
@@ -345,13 +492,30 @@
</field>
+ <field name="gearShootingEndLongitudeDecimalMinute">
+
+ <field-validator type="fieldexpressionwithparams">
+ <param name="doubleParams">min:0.0|max:60.0</param>
+ <param name="expression">
+ <![CDATA[
+ !"DMD".equals(coordinateEditorType.toString()) ||
+ ( doubles.min <= getGearShootingEndLongitudeDecimalMinute() && getGearShootingEndLongitudeDecimalMinute() < doubles.max )
+ ]]>
+ </param>
+ <message>tutti.validator.warning.longitude.minute.outOfBounds</message>
+
+ </field-validator>
+
+ </field>
+
<field name="gearShootingEndLongitudeSecond">
<field-validator type="fieldexpressionwithparams">
<param name="intParams">min:0|max:60</param>
<param name="expression">
<![CDATA[
- !useSexagecimalFormat || ( ints.min <= getGearShootingEndLongitudeSecond() && getGearShootingEndLongitudeSecond() < ints.max )
+ !"DMS".equals(coordinateEditorType.toString()) ||
+ ( ints.min <= getGearShootingEndLongitudeSecond() && getGearShootingEndLongitudeSecond() < ints.max )
]]>
</param>
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-23 15:56:31 UTC (rev 242)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-23 15:58:55 UTC (rev 243)
@@ -90,9 +90,11 @@
tutti.config.ui.color.rowInvalid=Ligne invalide
tutti.config.ui.color.rowReadOnly=Cellule non Êditable
tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques
+tutti.config.ui.coordinateEditorType=
tutti.config.ui.shortcut.closePopup=Fermer une popup
tutti.config.ui.showNumberEditorButton=Afficher le pavÊ numÊrique de saisie
tutti.config.ui.useSexagecimalEditor=Utiliser l'Êditeur sexagÊcimal pour entrer des coordonnÊes
+tutti.duration.format=dj Hh m'm'
tutti.errorTable.title=Table d'erreurs
tutti.file.protocol=Extension d'un fichier de protocole Tutti
tutti.label.attachmentEditor.file=Fichier
1
0
r242 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/spatial
by kmorinīŧ users.forge.codelutin.com 23 Jan '13
by kmorinīŧ users.forge.codelutin.com 23 Jan '13
23 Jan '13
Author: kmorin
Date: 2013-01-23 16:56:31 +0100 (Wed, 23 Jan 2013)
New Revision: 242
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/242
Log:
add methods for the DMD editor
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/spatial/SexagecimalPosition.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/spatial/SexagecimalPosition.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/spatial/SexagecimalPosition.java 2013-01-23 14:09:16 UTC (rev 241)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/spatial/SexagecimalPosition.java 2013-01-23 15:56:31 UTC (rev 242)
@@ -27,6 +27,8 @@
import org.apache.commons.lang3.ObjectUtils;
import java.io.Serializable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Define a geo spatial position coordinate in degre, minute, second.
@@ -38,6 +40,8 @@
private static final long serialVersionUID = 1L;
+ private static final Log log = LogFactory.getLog(SexagecimalPosition.class);
+
protected boolean sign;
protected Integer degre;
@@ -169,6 +173,17 @@
public Integer getMinute() {
return minute;
}
+
+ public Float getMinuteDecimale() {
+ Float minuteDecimale = null;
+ if (minute != null) {
+ minuteDecimale = minute.floatValue();
+ if (seconde != null) {
+ minuteDecimale += seconde.floatValue() / 60;
+ }
+ }
+ return minuteDecimale;
+ }
public Integer getSeconde() {
return seconde;
@@ -185,6 +200,19 @@
public void setMinute(Integer minute) {
this.minute = minute;
}
+
+ public void setMinuteDecimale(Float minuteDecimale) {
+ if (minuteDecimale == null) {
+ minute = null;
+ seconde = null;
+
+ } else {
+ Double entier = Math.floor(minuteDecimale);
+ minute = entier.intValue();
+ Double reste = Math.floor((minuteDecimale - entier) * 60);
+ seconde = reste.intValue();
+ }
+ }
public void setSeconde(Integer seconde) {
this.seconde = seconde;
1
0
r241 - trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/service
by blavenierīŧ users.forge.codelutin.com 23 Jan '13
by blavenierīŧ users.forge.codelutin.com 23 Jan '13
23 Jan '13
Author: blavenier
Date: 2013-01-23 15:09:16 +0100 (Wed, 23 Jan 2013)
New Revision: 241
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/241
Log:
- Add fake impl of getCaracteristic(pmfmId)
Modified:
trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceDevImpl.java
Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceDevImpl.java
===================================================================
--- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceDevImpl.java 2013-01-23 10:00:00 UTC (rev 240)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceDevImpl.java 2013-01-23 14:09:16 UTC (rev 241)
@@ -40,6 +40,8 @@
import java.util.List;
+import javax.naming.OperationNotSupportedException;
+
import static fr.ifremer.tutti.persistence.TuttiPersistenceDevImpl.getKey;
/**
@@ -229,8 +231,12 @@
public boolean isSortedQualitativeValue(CaracteristicQualitativeValue value) {
return value !=null && value.getId().equals("311");
}
+
+ @Override
+ public Caracteristic getCaracteristic(Integer pmfmId) {
+ throw new RuntimeException("getCaracteristic() not supports is only support in tutti-persistence-adagio");
+ }
-
protected <B extends IdAware> List<B> getData(String entityType) {
List<B> result = (List<B>) cache.get(entityType);
return result;
@@ -257,4 +263,6 @@
Caracteristic result = data.get(0);
return result;
}
+
+
}
1
0
r240 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence-adagio/src/main/resources tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service
by blavenierīŧ users.forge.codelutin.com 23 Jan '13
by blavenierīŧ users.forge.codelutin.com 23 Jan '13
23 Jan '13
Author: blavenier
Date: 2013-01-23 11:00:00 +0100 (Wed, 23 Jan 2013)
New Revision: 240
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/240
Log:
ref refs #1920: [Persistence] Adagio Donnees thematiques
- Add storage of EnvironmentCaracteristics and GearShootingCaracteristics in createFishingOperation()
- Add loading of EnvironmentCaracteristics and GearShootingCaracteristics in getFishingOperation()
- Add of FishingOperation.save(), and manage cas when caracteristics have been deleted
Modified:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml
trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -129,6 +129,8 @@
Person getPerson(Integer personId);
Gear getGear(Integer gearId);
+
+ Caracteristic getCaracteristic(Integer pmfmId);
boolean isSortedQualitativeValue(CaracteristicQualitativeValue value);
}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -35,6 +35,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
+import java.io.Serializable;
import java.util.Iterator;
/**
@@ -118,4 +119,9 @@
}
return query;
}
+
+ protected <T extends Serializable> T load(Class<? extends T> clazz, Serializable id) {
+ T load = (T) getCurrentSession().load(clazz, id);
+ return load;
+ }
}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -54,10 +54,16 @@
import fr.ifremer.adagio.core.dao.referential.QualityFlag;
import fr.ifremer.adagio.core.dao.referential.QualityFlagDao;
import fr.ifremer.adagio.core.dao.referential.gear.GearDao;
+import fr.ifremer.adagio.core.dao.referential.gear.GearImpl;
import fr.ifremer.adagio.core.dao.referential.location.Location;
import fr.ifremer.adagio.core.dao.referential.location.LocationDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm;
import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue;
import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDaoImpl;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -247,15 +253,24 @@
if (result.getGear() == null) {
Iterator<Object[]> list = queryList(
"allCruiseGears",
- "cruiseId", IntegerType.INSTANCE, Integer.valueOf(id));
+ "cruiseId", IntegerType.INSTANCE, Integer.valueOf(id),
+ "pmfmIdTrawlNet", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_NET);
List<Gear> gears = Lists.newArrayList();
+ int maxTrawlNetFound = 0;
while (list.hasNext()) {
Object[] gearRow = list.next();
Gear target = referentielService.getGear((Integer) gearRow[0]);
+ Float trawlNet = (Float) gearRow[1];
+ if (trawlNet != null && trawlNet.intValue() > maxTrawlNetFound) {
+ maxTrawlNetFound = trawlNet.intValue();
+ }
gears.add(target);
}
result.setGear(gears);
+ if (maxTrawlNetFound > 0) {
+ result.setTrawlNet(maxTrawlNetFound);
+ }
}
return result;
}
@@ -502,10 +517,12 @@
GearPhysicalFeatures gearPhysicalFeature = GearPhysicalFeatures.Factory.newInstance();
gearPhysicalFeature.setFishingTrip(fishingTrip);
- fr.ifremer.adagio.core.dao.referential.gear.Gear gear = gearDao.load(gearId);
- if (gear == null) {
- throw new DataRetrievalFailureException("Gear not found with id=" + gearId);
- }
+
+ fr.ifremer.adagio.core.dao.referential.gear.Gear gear = (fr.ifremer.adagio.core.dao.referential.gear.Gear)getCurrentSession().load(GearImpl.class, gearId);
+ //fr.ifremer.adagio.core.dao.referential.gear.Gear gear = gearDao.load(gearId);
+ //if (gear == null) {
+ // throw new DataRetrievalFailureException("Gear not found with id=" + gearId);
+ //}
gearPhysicalFeature.setGear(gear);
if (fishingTrip.getGearPhysicalFeatures() == null) {
fishingTrip.setGearPhysicalFeatures(Lists.newArrayList(gearPhysicalFeature));
@@ -547,7 +564,9 @@
}
gearPhysicalMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
gearPhysicalMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
- gearPhysicalMeasurement.setPmfm(pmfmDao.load(pmfmId));
+ Pmfm pmfm = (Pmfm)getCurrentSession().load(PmfmImpl.class, pmfmId);
+ gearPhysicalMeasurement.setPmfm(pmfm);
+ //gearPhysicalMeasurement.setPmfm(pmfmDao.load(pmfmId));
}
return gearPhysicalMeasurement;
@@ -577,7 +596,9 @@
gearPhysicalMeasurement.setNumericalValue(numericalValue);
}
else if (qualitativevalueId != null) {
- gearPhysicalMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
+ QualitativeValue qv = (QualitativeValue)getCurrentSession().load(QualitativeValueImpl.class, qualitativevalueId);
+ gearPhysicalMeasurement.setQualitativeValue(qv);
+ //gearPhysicalMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
}
return gearPhysicalMeasurement;
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -24,17 +24,22 @@
* #L%
*/
+import java.io.Serializable;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.FlushMode;
import org.hibernate.type.IntegerType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
@@ -42,9 +47,14 @@
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea;
+import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea2RegulationLocation;
+import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea2RegulationLocationPK;
import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.GearUseMeasurement;
+import fr.ifremer.adagio.core.dao.data.measure.Measurement;
import fr.ifremer.adagio.core.dao.data.measure.VesselUseMeasurement;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
import fr.ifremer.adagio.core.dao.data.operation.Operation;
@@ -56,14 +66,23 @@
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.VesselUseFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.isActive;
import fr.ifremer.adagio.core.dao.data.vessel.position.VesselPosition;
-import fr.ifremer.adagio.core.dao.referential.QualityFlagDao;
-import fr.ifremer.adagio.core.dao.referential.gear.Gear;
+import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.gear.GearDao;
+import fr.ifremer.adagio.core.dao.referential.gear.GearImpl;
import fr.ifremer.adagio.core.dao.referential.location.LocationDao;
-import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao;
-import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId;
-import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao;
+import fr.ifremer.adagio.core.dao.referential.location.LocationExtendDao;
+import fr.ifremer.adagio.core.dao.referential.location.LocationImpl;
+import fr.ifremer.adagio.core.dao.referential.location.LocationLevelId;
+import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm;
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl;
+import fr.ifremer.adagio.core.service.referential.location.LocationService;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
+import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -80,29 +99,20 @@
protected MeasurementService measurementService;
@Autowired(required = true)
- protected ReferentialPersistenceService referentielService;
+ protected ReferentialPersistenceService referentialService;
+ @Resource(name = "scientificCruiseDao")
+ protected ScientificCruiseDao scientificCruiseDao;
+
@Resource(name = "fishingOperationDao")
protected FishingOperationDao fishingOperationDao;
+
+ @Resource(name = "locationService")
+ protected LocationService locationService;
- @Resource(name = "gearDao")
- protected GearDao gearDao;
-
@Resource(name = "locationDao")
- protected LocationDao locationDao;
-
- @Resource(name = "scientificCruiseDao")
- protected ScientificCruiseDao scientificCruiseDao;
+ protected LocationExtendDao locationDao;
- @Resource(name = "qualityFlagDao")
- protected QualityFlagDao qualityFlagDao;
-
- @Resource(name = "pmfmDao")
- protected PmfmDao pmfmDao;
-
- @Resource(name = "qualitativeValueDao")
- protected QualitativeValueDao qualitativeValueDao;
-
protected static Float DEFAULT_EMPTY_LATITUDE = 0.0001f;
protected static Float DEFAULT_EMPTY_LONGITUDE = 0.0001f;
@@ -124,7 +134,10 @@
"pmfmIdTrawlDistance", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_DISTANCE,
"pmfmIdRectilinearOperation", IntegerType.INSTANCE, enumeration.PMFM_ID_RECTILINEAR_OPERATION,
"pmfmIdHaulValid", IntegerType.INSTANCE, enumeration.PMFM_ID_HAUL_VALID,
- "pmfmTrawlNetNumber", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_NET_NUMBER
+ "pmfmIdTrawlNetNumber", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_NET_NUMBER,
+ "locationLevelIdStrata", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_STRATA,
+ "locationLevelIdSubStrata", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_SUB_STRATA,
+ "locationLevelIdLocalite", IntegerType.INSTANCE, enumeration.LOCATION_LEVEL_ID_LOCALITE
);
if (source == null) {
@@ -176,7 +189,7 @@
Integer gearId = (Integer)source[colIndex++];
if (gearId != null) {
// TODO TC : activer un cache sur getGear()
- fr.ifremer.tutti.persistence.entities.referential.Gear gear = referentielService.getGear(gearId);
+ fr.ifremer.tutti.persistence.entities.referential.Gear gear = referentialService.getGear(gearId);
result.setGear(gear);
}
@@ -210,18 +223,50 @@
// Haul valid ?
Integer haulValidQualitativeId = (Integer)source[colIndex++];
- if (haulValidQualitativeId != null) {
- result.setFishingOperationValid((enumeration.QUALITATIVE_HAUL_VALID_YES.equals(haulValidQualitativeId)));
- }
+ //if (haulValidQualitativeId != null) {
+ // result.setFishingOperationValid((enumeration.QUALITATIVE_HAUL_VALID_YES.equals(haulValidQualitativeId)));
+ //}
// Trawl net number (override the value found in the OP name)
Float trawlNetNumber = (Float)source[colIndex++];
if (trawlNetNumber != null) {
result.setTrawlNetNumber(trawlNetNumber.intValue());
}
+
+ // Strata :
+ Integer strataId = (Integer)source[colIndex++];
+ if (strataId != null) {
+ FishingOperationLocation strata = new FishingOperationLocation();
+ strata.setId(strataId.toString());
+ result.setStrata(strata);
+ }
+ // Sub Strata :
+ Integer subStrataId = (Integer)source[colIndex++];
+ if (subStrataId != null) {
+ FishingOperationLocation subStrata = new FishingOperationLocation();
+ subStrata.setId(subStrataId.toString());
+ result.setSubStrata(subStrata);
+ }
+
+ // Localite :
+ Integer localiteId = (Integer)source[colIndex++];
+ if (localiteId != null) {
+ FishingOperationLocation localite = new FishingOperationLocation();
+ localite.setId(localiteId.toString());
+ result.setLocation(localite);
+ }
+
+ // Retrieve environment caracteristics :
+ getEnvironmentCaracteristics(id, result);
+
+ // Retrieve gear shooting caracteristics :
+ getGearShootingCaracteristics(id, result);
+
return result;
}
+
+
@Override
public FishingOperation createFishingOperation(FishingOperation bean) {
@@ -231,21 +276,145 @@
if (bean.getCruise() == null || bean.getCruise().getId() == null) {
throw new IllegalArgumentException("fishingOperation.getCruise() could not be null");
}
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
fr.ifremer.adagio.core.dao.data.operation.FishingOperation fishingOperation = fr.ifremer.adagio.core.dao.data.operation.FishingOperation.Factory.newInstance();
beanToEntity(bean, fishingOperation, true);
fishingOperationDao.create(fishingOperation);
-
bean.setId(String.valueOf(fishingOperation.getId()));
+ getCurrentSession().flush();
return bean;
+ }
+
+ @Override
+ public FishingOperation saveFishingOperation(FishingOperation bean) {
+ if (bean == null) {
+ throw new IllegalArgumentException("fishingOperation could not be null");
+ }
+ if (bean.getId() == null || bean.getId().isEmpty()) {
+ throw new IllegalArgumentException("fishingOperation.id could not be null");
+ }
+ if (bean.getCruise() == null || bean.getCruise().getId() == null) {
+ throw new IllegalArgumentException("fishingOperation.getCruise() could not be null");
+ }
+ getCurrentSession().clear();
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
+ fr.ifremer.adagio.core.dao.data.operation.FishingOperation fishingOperation = fishingOperationDao.load(Integer.valueOf(bean.getId()));
+ beanToEntity(bean, fishingOperation, true);
+ fishingOperationDao.update(fishingOperation);
+ getCurrentSession().flush();
+ return bean;
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void getEnvironmentCaracteristics(String fishingOperationId, FishingOperation result) {
+ // retrieve fishing operation caracteristics
+ Iterator<Object[]> list = queryList(
+ "fishingOperationEnvironment",
+ "fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(fishingOperationId)
+ );
+
+ CaracteristicMap environmentCaracteristics = new CaracteristicMap();
+ while (list.hasNext()) {
+ int colIndex=0;
+ Object[] source = list.next();
+ Integer pmfmId = (Integer)source[colIndex++];
+ Float numericalValue = (Float)source[colIndex++];
+ String alphanumericalValue = (String)source[colIndex++];
+ Integer qualitativeValueId = (Integer)source[colIndex++];
+
+ // Trawl distance
+ if (enumeration.PMFM_ID_TRAWL_DISTANCE.equals(pmfmId)) {
+ result.setTrawlDistance(numericalValue);
+ }
+
+ // Rectilinear operation ?
+ else if (enumeration.PMFM_ID_RECTILINEAR_OPERATION.equals(pmfmId)) {
+ result.setFishingOperationRectiligne(enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES.equals(qualitativeValueId));
+ }
+
+ // Haul valid ?
+ else if (enumeration.PMFM_ID_HAUL_VALID.equals(pmfmId)) {
+ result.setFishingOperationValid(enumeration.QUALITATIVE_HAUL_VALID_YES.equals(qualitativeValueId));
+ }
+
+ // Station Number :
+ else if (enumeration.PMFM_ID_STATION_NUMBER.equals(pmfmId)) {
+ result.setStationNumber(alphanumericalValue);
+ }
+
+ // Environment caracteristic
+ else {
+ Caracteristic environmentCaracteristic = referentialService.getCaracteristic(pmfmId);
+ Serializable value = null;
+ if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ value = numericalValue;
+ }
+ else if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ value = alphanumericalValue;
+ }
+ else if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ value = qualitativeValueId;
+ }
+ environmentCaracteristics.put(environmentCaracteristic, value);
+ }
+ }
+
+ if (environmentCaracteristics.size() > 0) {
+ result.setEnvironmentCaracteristics(environmentCaracteristics);
+ }
+ }
+
+ protected void getGearShootingCaracteristics(String fishingOperationId, FishingOperation result) {
+ // retrieve fishing operation caracteristics
+ Iterator<Object[]> list = queryList(
+ "fishingOperationGearShooting",
+ "fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(fishingOperationId)
+ );
+
+ CaracteristicMap gearShootingCaracteristics = new CaracteristicMap();
+ while (list.hasNext()) {
+ int colIndex=0;
+ Object[] source = list.next();
+ Integer pmfmId = (Integer)source[colIndex++];
+ Float numericalValue = (Float)source[colIndex++];
+ String alphanumericalValue = (String)source[colIndex++];
+ Integer qualitativeValueId = (Integer)source[colIndex++];
+
+ // Trawl distance
+ if (enumeration.PMFM_ID_TRAWL_NET_NUMBER.equals(pmfmId)) {
+ result.setTrawlNetNumber(numericalValue.intValue());
+ }
+
+ // Gear Shooting Caracteristics
+ else {
+ Caracteristic gearShootingCaracteristic = referentialService.getCaracteristic(pmfmId);
+ Serializable value = null;
+ if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ value = numericalValue;
+ }
+ else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ value = alphanumericalValue;
+ }
+ else if (gearShootingCaracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ value = qualitativeValueId;
+ }
+ gearShootingCaracteristics.put(gearShootingCaracteristic, value);
+ }
+ }
+
+ if (gearShootingCaracteristics.size() > 0) {
+ result.setGearShootingCaracteristics(gearShootingCaracteristics);
+ }
+ }
+
protected void beanToEntity(FishingOperation source, fr.ifremer.adagio.core.dao.data.operation.FishingOperation target, boolean copyIfNull) {
-
// Retrieve entities : FishingTrip and ScientificCruise
ScientificCruise scientificCruise = null;
FishingTrip fishingTrip = target.getFishingTrip();
if (fishingTrip == null) {
- // TODO BLA Êviter ici un rechargement de fishingTrip :
scientificCruise = scientificCruiseDao.load(Integer.valueOf(source.getCruise().getId()));
fishingTrip = scientificCruise.getFishingTrips().iterator().next();
fishingTrip.getOperations().add(target); // Inverse link
@@ -262,10 +431,10 @@
if (target.getVesselPositions() != null) {
for (Iterator iterator = target.getVesselPositions().iterator(); iterator.hasNext();) {
VesselPosition position = (VesselPosition) iterator.next();
- if (position.getDateTime() != null && position.getDateTime().equals(target.getStartDateTime())) {
+ if (position.getDateTime() != null && position.getDateTime().getTime() == target.getStartDateTime().getTime()) {
startPosition = position;
}
- else if (position.getDateTime() == null || position.getDateTime().equals(target.getEndDateTime())) {
+ else if (position.getDateTime() == null || (target.getEndDateTime() != null && position.getDateTime().getTime() == target.getEndDateTime().getTime())) {
endPosition = position;
}
}
@@ -277,20 +446,26 @@
gearUseFeatures = GearUseFeatures.Factory.newInstance();
gearUseFeatures.setOperation(target);
if (target.getGearUseFeatures() == null) {
- target.setGearUseFeatures(Lists.newArrayList(gearUseFeatures));
+ target.setGearUseFeatures(Sets.newHashSet(gearUseFeatures));
} else {
target.getGearUseFeatures().add(gearUseFeatures);
}
} else {
gearUseFeatures = target.getGearUseFeatures().iterator().next();
}
+
+ // Create a list to store all updates, then remove not updated items
+ Set<GearUseMeasurement> notChangedGearUseMeasurements = new HashSet<GearUseMeasurement>();
+ if (gearUseFeatures.getGearUseMeasurements() != null) {
+ notChangedGearUseMeasurements.addAll(gearUseFeatures.getGearUseMeasurements());
+ }
// Retrieve entities : Vessel Use Features
VesselUseFeatures vesselUseFeatures = null;
if (target.getVesselUseFeatures() == null || target.getVesselUseFeatures().size() == 0) {
vesselUseFeatures = VesselUseFeatures.Factory.newInstance();
if (target.getVesselUseFeatures() == null) {
- target.setVesselUseFeatures(Lists.newArrayList(vesselUseFeatures));
+ target.setVesselUseFeatures(Sets.newHashSet(vesselUseFeatures));
vesselUseFeatures.setOperation(target);
} else {
target.getVesselUseFeatures().add(vesselUseFeatures);
@@ -300,6 +475,12 @@
vesselUseFeatures = target.getVesselUseFeatures().iterator().next();
}
+ // Create a list to store all updates, then remove not updated items
+ Set<VesselUseMeasurement> notChangedVesselUseMeasurements = new HashSet<VesselUseMeasurement>();
+ if (vesselUseFeatures.getVesselUseMeasurements() != null) {
+ notChangedVesselUseMeasurements.addAll(vesselUseFeatures.getVesselUseMeasurements());
+ }
+
// Retrieve entities : Gear Physical Features
GearPhysicalFeatures gearPhysicalFeatures = target.getGearPhysicalFeatures();
if (gearPhysicalFeatures == null && source.getGear() != null && source.getGear().getId() != null) {
@@ -309,26 +490,44 @@
}
target.setGearPhysicalFeatures(gearPhysicalFeatures);
if (gearPhysicalFeatures.getOperations() == null) {
- gearPhysicalFeatures.setOperations(Lists.newArrayList((Operation)target));
+ gearPhysicalFeatures.setOperations(Sets.newHashSet((Operation)target));
} else {
gearPhysicalFeatures.getOperations().add(target);
}
}
- // Retrieve tarwl net, from Gear physical features
+ // Retrieve entities : Fishing Area
+ FishingArea fishingArea = null;
+ if (gearUseFeatures.getFishingAreas() == null || gearUseFeatures.getFishingAreas().size() == 0) {
+ fishingArea = FishingArea.Factory.newInstance();
+ if (gearUseFeatures.getFishingAreas() == null) {
+ gearUseFeatures.setFishingAreas(Sets.newHashSet(fishingArea));
+ fishingArea.setGearUseFeatures(gearUseFeatures);
+ } else {
+ gearUseFeatures.getFishingAreas().add(fishingArea);
+ fishingArea.setGearUseFeatures(gearUseFeatures);
+ }
+ } else {
+ fishingArea = gearUseFeatures.getFishingAreas().iterator().next();
+ // Reset all other fishing areas
+ }
+
+ // Retrieve trawl net, from Gear physical features
int trawlNet = 1; // default value
GearPhysicalMeasurement gpmTrawlNet = measurementService.getGearPhysicalMeasurement(gearPhysicalFeatures, enumeration.PMFM_ID_TRAWL_NET);
if (gpmTrawlNet != null && gpmTrawlNet.getNumericalValue() != null) {
trawlNet = gpmTrawlNet.getNumericalValue().intValue();
- }
-
+ }
+
StringBuffer nameBuffer = new StringBuffer();
// StationNumber
if (copyIfNull && source.getStationNumber() == null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, "", null);
+ //setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, "", null);
} else if (source.getStationNumber() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null);
+ VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null);
+ notChangedVesselUseMeasurements.remove(vum);
+
nameBuffer.append(source.getStationNumber());
}
@@ -342,14 +541,12 @@
if (nameBuffer.length() > 0) {
nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR);
}
- // TODO BL : store OP N° ? or compute it ?
nameBuffer.append(source.getFishingOperationNumber());
}
// Trawl net number
if (copyIfNull && source.getTrawlNetNumber() == null) {
- // Remove from Gear Use Features
- removeGearUseMeasurement(gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER);
+ // Nothing to do : will be removed later, using notChangedGearUseMeasurements
if (nameBuffer.length() > 0) {
nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR);
}
@@ -358,7 +555,9 @@
throw new DataIntegrityViolationException("An operation could not have a 'trawl net number' greater than 'trawl net' defined in the cruise.");
}
// Store into Gear Use Features
- setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER, Float.valueOf(source.getTrawlNetNumber()), null, null);
+ GearUseMeasurement gum = setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER, Float.valueOf(source.getTrawlNetNumber()), null, null);
+ notChangedGearUseMeasurements.remove(gum);
+
// Store into the name attribute :
if (nameBuffer.length() > 0) {
nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR);
@@ -394,19 +593,24 @@
// Trawl distance
if (copyIfNull && source.getTrawlDistance() == null) {
- removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE);
+ // Nothing to do : will be removed later, using notChangedVesselUseMeasurements
} else if (source.getTrawlDistance() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null);
+ VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null);
+ notChangedVesselUseMeasurements.remove(vum);
}
// Rectilinear operation
- setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO);
-
+ {
+ VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO);
+ notChangedVesselUseMeasurements.remove(vum);
+ }
+
// Operation is valid ?
if (copyIfNull && source.getFishingOperationValid() == null) {
removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID);
} else if (source.getFishingOperationValid() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO);
+ VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO);
+ notChangedVesselUseMeasurements.remove(vum);
}
// Comment
@@ -421,7 +625,7 @@
// Quality Flag :
if (target.getQualityFlag() == null) {
- target.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
}
// Settings not null properties :
@@ -452,7 +656,7 @@
vesselUseFeatures.setCreationDate(calendar.getTime());
}
if (vesselUseFeatures.getQualityFlag() == null) {
- vesselUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ vesselUseFeatures.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
}
// GearUseFeatures :
@@ -472,15 +676,14 @@
gearUseFeatures.setCreationDate(calendar.getTime());
}
if (gearUseFeatures.getQualityFlag() == null) {
- gearUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ gearUseFeatures.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
}
// GearUseFeatures.Gear
if (copyIfNull && source.getGear() == null) {
gearUseFeatures.setGear(null);
} else if (source.getGear() != null && source.getGear().getId() != null) {
- Gear gear = gearDao.load(Integer.valueOf(source.getGear().getId()));
- gearUseFeatures.setGear(gear);
+ gearUseFeatures.setGear(load(GearImpl.class, Integer.valueOf(source.getGear().getId())));
}
// Start position :
@@ -493,7 +696,7 @@
startPosition = VesselPosition.Factory.newInstance();
startPosition.setOperation(target);
if (target.getVesselPositions() == null) {
- target.setVesselPositions(Lists.newArrayList(startPosition));
+ target.setVesselPositions(Sets.newHashSet(startPosition));
}
target.getVesselPositions().add(startPosition);
}
@@ -542,12 +745,130 @@
target.getVesselPositions().remove(endPosition);
}
+ // Environment Caracteristics
+ CaracteristicMap environmentCaracteristics = source.getEnvironmentCaracteristics();
+ if (copyIfNull && environmentCaracteristics == null || environmentCaracteristics.size() == 0) {
+ // Nothing to do : will be removed later, using notChangedVesselUseMeasurements
+ }
+ else if (environmentCaracteristics != null && environmentCaracteristics.size() > 0) {
+ for (Caracteristic caracteristic : environmentCaracteristics.keySet()) {
+ VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, caracteristic, environmentCaracteristics.get(caracteristic));
+ notChangedVesselUseMeasurements.remove(vum);
+ }
+ }
+
+ // Removed unecessary Vessel Use Measurement
+
+ // Gear shooting Caracteristics
+ CaracteristicMap gearShootingCaracteristics = source.getGearShootingCaracteristics();
+ if (copyIfNull && gearShootingCaracteristics == null || gearShootingCaracteristics.size() == 0) {
+ // Nothing to do : will be removed later, using notChangedGearUseMeasurements
+ }
+ else if (gearShootingCaracteristics != null && gearShootingCaracteristics.size() > 0) {
+ for (Caracteristic caracteristic : gearShootingCaracteristics.keySet()) {
+ GearUseMeasurement gum = setGearUseMeasurement(scientificCruise, gearUseFeatures, caracteristic, environmentCaracteristics.get(caracteristic));
+ notChangedGearUseMeasurements.remove(gum);
+ }
+ }
+
+ // Removed not changed measurements (in Vessel & Gear Use Measurement lists)
+ if (vesselUseFeatures.getVesselUseMeasurements() != null && notChangedVesselUseMeasurements.size() > 0) {
+ for (VesselUseMeasurement vum : notChangedVesselUseMeasurements) {
+ vesselUseFeatures.getVesselUseMeasurements().remove(vum);
+ }
+ }
+ if (gearUseFeatures.getGearUseMeasurements() != null && notChangedGearUseMeasurements.size() > 0) {
+ for (GearUseMeasurement gum : notChangedGearUseMeasurements) {
+ gearUseFeatures.getGearUseMeasurements().remove(gum);
+ }
+ }
+
+ // Fishing Area :
+ Integer statisticalLocationId = null;
+ if (source.getGearShootingStartLatitude() != null && source.getGearShootingStartLongitude() != null) {
+ statisticalLocationId = locationService.getLocationIdByLatLong(source.getGearShootingStartLatitude(), source.getGearShootingStartLongitude());
+ }
+ if (statisticalLocationId == null && source.getGearShootingEndLatitude() != null && source.getGearShootingEndLongitude() != null) {
+ statisticalLocationId = locationService.getLocationIdByLatLong(source.getGearShootingEndLatitude(), source.getGearShootingEndLongitude());
+ }
+
+ // Strata :
+ if (copyIfNull && (source.getStrata() == null || source.getStrata().getId() == null)) {
+ // TODO remove from fishing Area ?
+ }
+ else if (source.getStrata() != null && source.getStrata().getId() != null) {
+ FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
+ FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
+ fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
+ fa2rlPK.setFishingArea(fishingArea);
+ fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getStrata().getId())));
+ if (fishingArea.getRegulationLocation() == null) {
+ fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
+ }
+ else {
+ fishingArea.getRegulationLocation().add(fa2rl);
+ }
+ if (statisticalLocationId == null) {
+ statisticalLocationId = Integer.valueOf(source.getStrata().getId());
+ }
+ }
+
+ // Sub-Strata :
+ if (copyIfNull && (source.getSubStrata() == null || source.getSubStrata().getId() == null)) {
+ // TODO remove from fishing Area ?
+ }
+ else if (source.getSubStrata() != null && source.getSubStrata().getId() != null) {
+ FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
+ FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
+ fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
+ fa2rlPK.setFishingArea(fishingArea);
+ fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getSubStrata().getId())));
+ if (fishingArea.getRegulationLocation() == null) {
+ fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
+ }
+ else {
+ fishingArea.getRegulationLocation().add(fa2rl);
+ }
+ if (statisticalLocationId == null) {
+ statisticalLocationId = Integer.valueOf(source.getSubStrata().getId());
+ }
+ }
+
+ // Localite :
+ if (copyIfNull && (source.getLocation() == null || source.getLocation().getId() == null)) {
+ // TODO remove from fishing Area ?
+ }
+ else if (source.getLocation() != null && source.getLocation().getId() != null) {
+ FishingArea2RegulationLocation fa2rl = FishingArea2RegulationLocation.Factory.newInstance();
+ FishingArea2RegulationLocationPK fa2rlPK = new FishingArea2RegulationLocationPK();
+ fa2rl.setFishingArea2RegulationLocationPk(fa2rlPK);
+ fa2rlPK.setFishingArea(fishingArea);
+ fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getLocation().getId())));
+ if (fishingArea.getRegulationLocation() == null) {
+ fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl));
+ }
+ else {
+ fishingArea.getRegulationLocation().add(fa2rl);
+ }
+ if (statisticalLocationId == null) {
+ statisticalLocationId = Integer.valueOf(source.getLocation().getId());
+ }
+ }
+
+ // Fishing Area location (should be a statistical location)
+ if (copyIfNull && statisticalLocationId == null) {
+ gearUseFeatures.getFishingAreas().remove(fishingArea);
+ //Nothing to do : a gearUseFeatures.getFishingAreas().clear() has been done before
+ if (fishingArea.getRegulationLocation() != null) {
+ fishingArea.getRegulationLocation().clear();
+ }
+ }
+ else if (statisticalLocationId != null) {
+ fishingArea.setLocation(load(LocationImpl.class, statisticalLocationId));
+ //gearUseFeatures.getFishingAreas().add(fishingArea);
+ }
}
- @Override
- public FishingOperation saveFishingOperation(FishingOperation bean) {
- return null;
- }
/**
* Test if the date has millisecond set. This yes, return null, then return the date itself.
@@ -646,14 +967,14 @@
vesselUseMeasurement = VesselUseMeasurement.Factory.newInstance();
vesselUseMeasurement.setVesselUseFeatures(vesselUseFeatures);
if (vesselUseFeatures.getVesselUseMeasurements() == null) {
- vesselUseFeatures.setVesselUseMeasurements(Lists.newArrayList(vesselUseMeasurement));
+ vesselUseFeatures.setVesselUseMeasurements(Sets.newHashSet(vesselUseMeasurement));
}
else {
vesselUseFeatures.getVesselUseMeasurements().add(vesselUseMeasurement);
}
- vesselUseMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ vesselUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
vesselUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
- vesselUseMeasurement.setPmfm(pmfmDao.load(pmfmId));
+ vesselUseMeasurement.setPmfm(load(PmfmImpl.class, pmfmId));
}
return vesselUseMeasurement;
@@ -683,12 +1004,50 @@
vesselUseMeasurement.setNumericalValue(numericalValue);
}
else if (qualitativevalueId != null) {
- vesselUseMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
+ vesselUseMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, qualitativevalueId));
}
return vesselUseMeasurement;
}
+ protected VesselUseMeasurement setVesselUseMeasurement(ScientificCruise scientificCruise, VesselUseFeatures vesselUseFeatures,
+ Integer pmfmId,
+ Serializable value) {
+ VesselUseMeasurement vesselUseMeasurement = getVesselUseMeasurement(scientificCruise, vesselUseFeatures, pmfmId, true);
+
+ if (value instanceof String) {
+ vesselUseMeasurement.setAlphanumericalValue((String)value);
+ }
+ else if (value instanceof Float) {
+ vesselUseMeasurement.setNumericalValue((Float)value);
+ }
+ else if (value instanceof Integer) {
+ vesselUseMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, (Integer)value));
+ }
+
+ return vesselUseMeasurement;
+ }
+
+ protected VesselUseMeasurement setVesselUseMeasurement(ScientificCruise scientificCruise, VesselUseFeatures vesselUseFeatures,
+ Caracteristic caracteristic, Serializable value) {
+ VesselUseMeasurement vesselUseMeasurement = getVesselUseMeasurement(scientificCruise, vesselUseFeatures, Integer.valueOf(caracteristic.getId()), true);
+ setMeasurement(vesselUseMeasurement, caracteristic, value);
+ return vesselUseMeasurement;
+ }
+
+ protected void setMeasurement(Measurement measurement, Caracteristic caracteristic, Serializable value) {
+ if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ measurement.setAlphanumericalValue((String)value);
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ measurement.setNumericalValue((Float)value);
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ QualitativeValue qv = (QualitativeValue)getCurrentSession().load(QualitativeValueImpl.class, Integer.valueOf((String)value));
+ measurement.setQualitativeValue(qv);
+ }
+ }
+
protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures,
Integer pmfmId,
Float numericalValue,
@@ -703,12 +1062,20 @@
gearUseMeasurement.setNumericalValue(numericalValue);
}
else if (qualitativevalueId != null) {
- gearUseMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
+ QualitativeValue qv = (QualitativeValue)getCurrentSession().load(QualitativeValueImpl.class, qualitativevalueId);
+ gearUseMeasurement.setQualitativeValue(qv);
}
return gearUseMeasurement;
}
+ protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures,
+ Caracteristic caracteristic, Serializable value) {
+ GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, Integer.valueOf(caracteristic.getId()), true);
+ setMeasurement(gearUseMeasurement, caracteristic, value);
+ return gearUseMeasurement;
+ }
+
protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures,
Integer pmfmId, boolean createIfNotExists) {
GearUseMeasurement gearUseMeasurement = null;
@@ -728,14 +1095,15 @@
gearUseMeasurement = GearUseMeasurement.Factory.newInstance();
gearUseMeasurement.setGearUseFeatures(gearUseFeatures);
if (gearUseFeatures.getGearUseMeasurements() == null) {
- gearUseFeatures.setGearUseMeasurements(Lists.newArrayList(gearUseMeasurement));
+ gearUseFeatures.setGearUseMeasurements(Sets.newHashSet(gearUseMeasurement));
}
else {
gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement);
}
- gearUseMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ gearUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
- gearUseMeasurement.setPmfm(pmfmDao.load(pmfmId));
+ Pmfm pmfm = (Pmfm)getCurrentSession().load(PmfmImpl.class, pmfmId);
+ gearUseMeasurement.setPmfm(pmfm);
}
return gearUseMeasurement;
@@ -750,5 +1118,4 @@
gearUseFeatures.getGearUseMeasurements().remove(gearUseMeasurement);
// TOBO BLa : vÊrifier qu'il ne faut pas dao.delete() en plus
}
-
}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -385,59 +385,59 @@
@Override
public Caracteristic getSizeCategoryCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_SIZE_CATEGORY;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getSexCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_SEX;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getSortedUnsortedCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_SORTED_UNSORTED;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getMaturityCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MATURITY;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getMacroWasteCategoryCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MACRO_WASTE_CATEGORY;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
@Override
public Caracteristic getMacroWasteSizeCategoryCaracteristic() {
Integer pmfmId = enumeration.PMFM_ID_MACRO_WASTE_SIZE_CATEGORY;
- Caracteristic result = loadCaracteristic(pmfmId);
+ Caracteristic result = getCaracteristic(pmfmId);
return result;
}
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected Caracteristic loadCaracteristic(Integer pmfmId) {
-
+ @Override
+ public Caracteristic getCaracteristic(Integer pmfmId) {
Object[] source = queryUniqueWithStatus("pmfmById",
"pmfmId", IntegerType.INSTANCE, pmfmId,
"unitIdNone", IntegerType.INSTANCE, enumeration.UNIT_ID_NONE);
-
Caracteristic target = loadCaracteristic(source);
return target;
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+
protected Caracteristic loadCaracteristic(Object[] source) {
Integer pmfmId = (Integer) source[0];
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -118,6 +118,12 @@
@Value("${LocationLevelId.RECTANGLE_STATISTIQUE_MED}")
public final Integer RECTANGLE_STATISTIQUE_MED = null;
+
+ @Value("${LocationLevelId.RECTANGLE_STATISTIQUE}")
+ public final Integer RECTANGLE_STATISTIQUE = null;
+
+ @Value("${LocationLevelId.FAO_ZONE}")
+ public final Integer FAO_ZONE = null;
@Value("${QualitativeValueId.VRAC}")
public final Integer QUALITATIVE_VRAC_ID = null;
Modified: trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-23 10:00:00 UTC (rev 240)
@@ -130,11 +130,16 @@
<![CDATA[
SELECT
gpf.gear.id AS gearId,
+ MAX(CASE gpm.pmfm.id
+ WHEN :pmfmIdTrawlNet THEN gpm.numericalValue
+ ELSE 0
+ END) as trawlNet,
count(o.id) as operationCount
FROM
ScientificCruiseImpl sc
JOIN sc.fishingTrips ft
JOIN ft.gearPhysicalFeatures gpf
+ LEFT OUTER JOIN gpf.gearPhysicalMeasurements gpm
LEFT OUTER JOIN gpf.operations o
WHERE
sc.id = :cruiseId
@@ -143,6 +148,7 @@
ORDER BY count(o.id) DESC
]]>
<query-param name="cruiseId" type="java.lang.Integer"/>
+ <query-param name="pmfmIdTrawlNet" type="java.lang.Integer"/>
</query>
<query cacheable="true" name="allCruiseSecondaryVessels">
@@ -166,30 +172,68 @@
<![CDATA[
SELECT
o.name as name,
- o.startDateTime as startDateTime,
- o.endDateTime as endDateTime,
- o.comments as comments,
- guf.gear.id as gearId,
+ max(o.startDateTime) as startDateTime,
+ max(o.endDateTime) as endDateTime,
+ max(o.comments) as comments,
+ max(guf.gear.id) as gearId,
(select vp_start from VesselPositionImpl vp_start where vp_start.operation.id = o.id and vp_start.dateTime = o.startDateTime) as startVesselPosition,
(select vp_end from VesselPositionImpl vp_end where vp_end.operation.id = o.id and vp_end.dateTime = o.endDateTime) as endVesselPosition,
(select vum.numericalValue from VesselUseMeasurementImpl vum where vum.vesselUseFeatures.id=vuf.id and vum.pmfm.id=:pmfmIdTrawlDistance) as trawlDistance,
(select vum2.qualitativeValue.id from VesselUseMeasurementImpl vum2 where vum2.vesselUseFeatures.id=vuf.id and vum2.pmfm.id=:pmfmIdRectilinearOperation) as rectilinearQualitativeId,
(select vum3.qualitativeValue.id from VesselUseMeasurementImpl vum3 where vum3.vesselUseFeatures.id=vuf.id and vum3.pmfm.id=:pmfmIdHaulValid) as haulValidQualitativeId,
- (select gum.numericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id=guf.id and gum.pmfm.id=:pmfmTrawlNetNumber) as trawlNetNumber
+ (select gum.numericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id=guf.id and gum.pmfm.id=:pmfmIdTrawlNetNumber) as trawlNetNumber,
+ max(case when (rl.locationLevel.id = :locationLevelIdStrata) then rl.id else null end) AS strataId,
+ max(case when (rl.locationLevel.id = :locationLevelIdSubStrata) then rl.id else null end) AS subStrataId,
+ max(case when (rl.locationLevel.id = :locationLevelIdLocalite) then rl.id else null end) AS localiteId
FROM
FishingOperationImpl o
INNER JOIN o.gearUseFeatures guf
INNER JOIN o.vesselUseFeatures vuf
+ LEFT OUTER JOIN guf.fishingAreas fa
+ LEFT OUTER JOIN fa.regulationLocation fa2rl
+ LEFT OUTER JOIN fa2rl.id.location rl
WHERE
o.id=:fishingOperationId
+ GROUP BY o.name
]]>
<query-param name="fishingOperationId" type="java.lang.Integer"/>
<query-param name="pmfmIdTrawlDistance" type="java.lang.Integer"/>
<query-param name="pmfmIdRectilinearOperation" type="java.lang.Integer"/>
<query-param name="pmfmIdHaulValid" type="java.lang.Integer"/>
- <query-param name="pmfmTrawlNetNumber" type="java.lang.Integer"/>
+ <query-param name="pmfmIdTrawlNetNumber" type="java.lang.Integer"/>
</query>
+ <query cacheable="true" name="fishingOperationEnvironment">
+ <![CDATA[
+ SELECT
+ vum.pmfm.id as pmfmId,
+ vum.numericalValue as numericalValue,
+ vum.alphanumericalValue as alphanumericalValue,
+ vum.qualitativeValue.id as qualitativeValueId
+ from
+ VesselUseFeaturesImpl vuf
+ join vuf.vesselUseMeasurements vum
+ WHERE
+ vuf.operation = :fishingOperationId
+ ]]>
+ <query-param name="fishingOperationId" type="java.lang.Integer"/>
+ </query>
+
+ <query cacheable="true" name="fishingOperationGearShooting">
+ <![CDATA[
+ SELECT
+ gum.pmfm.id as pmfmId,
+ gum.numericalValue as numericalValue,
+ gum.alphanumericalValue as alphanumericalValue,
+ gum.qualitativeValue.id as qualitativeValueId
+ from
+ GearUseFeaturesImpl guf
+ join guf.gearUseMeasurements gum
+ WHERE
+ guf.operation = :fishingOperationId
+ ]]>
+ <query-param name="fishingOperationId" type="java.lang.Integer"/>
+ </query>
<!-- ===================================================================== -->
<!-- === Requete techniques sur rÊfÊrentiels [REF-TXXX] === -->
Modified: trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-23 10:00:00 UTC (rev 240)
@@ -304,9 +304,9 @@
LocationLevelId.LOCALITE=22
LocationLevelId.STRATA=23
#TODO Creer la bonne valeur
-LocationLevelId.SUBSTRATA=-23
+LocationLevelId.SUBSTRATA=113
#TODO Mettre la bonne valeur
-LocationLevelId.PROGRAM=21
+LocationLevelId.PROGRAM=101
MethodId.DECLARATION=1
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -43,4 +43,17 @@
public String fishingVesselCode() {
return "851751";
}
+
+ public String strataId() {
+ return "20990"; /*= Strate 24E4*/
+ }
+
+ public String subStrataId() {
+ // TODO TC : change ID into a real substrata !
+ return "6080"; /*= Rectangle 24E4 */
+ }
+
+ public String localite() {
+ return "21525"; /*= LocalitÊ 4F1 */
+ }
}
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -109,7 +109,7 @@
calendar.add(Calendar.MONTH, 1); // add one month
cruise.setEndDate(calendar.getTime());
-
+
Country country = null;
List<Country> countries = referentialService.getAllCountry();
for (Country aCountry : countries) {
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-21 15:51:02 UTC (rev 239)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-23 10:00:00 UTC (rev 240)
@@ -24,15 +24,22 @@
* #L%
*/
+import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
+import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import org.junit.Before;
@@ -89,6 +96,9 @@
@Test
public void createFishingOperation(/*FishingOperation bean*/) {
+ // -----------------------------------------------------------------------------
+ // Prepare data and other entities
+ // -----------------------------------------------------------------------------
Calendar calendar = new GregorianCalendar();
FishingOperation reloadedFishingOperation = null;
FishingOperation createdFishingOperation = null;
@@ -110,8 +120,52 @@
cruise = cruiseService.createCruise(cruise);
assertNotNull(cruise.getId());
-
+ // Retrieve some environment caracteristics
+ List<Caracteristic> allEnvironmentCaracteristics = referentialService.getAllFishingOperationEnvironmentCaracteristic();
+ CaracteristicMap environmentCaracteristics = new CaracteristicMap();
+ CaracteristicMap environmentValuesOneEntry = new CaracteristicMap();
+ for(Caracteristic caracteristic : allEnvironmentCaracteristics) {
+ Serializable value = null;
+ if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ value = new Float(1.0f);
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ value = new String("some text");
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ // Choose the first qualitative value
+ value = caracteristic.getQualitativeValue(0).getId();
+ }
+ environmentCaracteristics.put(caracteristic, value);
+ if (environmentValuesOneEntry.size() == 0) {
+ environmentValuesOneEntry.put(caracteristic, value);
+ }
+ }
+
+ // Retrieve some gear use caracteristics
+ List<Caracteristic> allGearShootingCaracteristics = referentialService.getAllFishingOperationGearCaracteristic();
+ CaracteristicMap gearShootingCaracteristics = new CaracteristicMap();
+ CaracteristicMap gearShootingCaracteristicsOneEntry = new CaracteristicMap();
+ for(Caracteristic caracteristic : allEnvironmentCaracteristics) {
+ Serializable value = null;
+ if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) {
+ value = new Float(1.0f);
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) {
+ value = new String("some text");
+ }
+ else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ // Choose the first qualitative value
+ value = caracteristic.getQualitativeValue(0).getId();
+ }
+ gearShootingCaracteristics.put(caracteristic, value);
+ if (gearShootingCaracteristicsOneEntry.size() == 0) {
+ gearShootingCaracteristicsOneEntry.put(caracteristic, value);
+ }
+ }
+
+
// Create new fishing operation :
FishingOperation fishingOperation = new FishingOperation();
@@ -157,19 +211,28 @@
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MILLISECOND, 99);
fishingOperation.setGearShootingEndDate(calendar.getTime());
-
- fishingOperation.setGearShootingStartLatitude(33.2541f);
- fishingOperation.setGearShootingStartLongitude(-5.514f);
- fishingOperation.setGearShootingEndLatitude(33.7441f);
+ fishingOperation.setGearShootingStartLatitude(47.6f);
+ fishingOperation.setGearShootingStartLongitude(-5.05f);
+ fishingOperation.setGearShootingEndLatitude(47.9854f);
fishingOperation.setGearShootingEndLongitude(-5.597f);
fishingOperation.setTrawlDistance(100.12345f);
fishingOperation.setFishingOperationRectiligne(true);
fishingOperation.setFishingOperationValid(Boolean.TRUE);
-
fishingOperation.setComment("Unit test createFishingOperation() - Part n°2 : All properties set");
-
fishingOperation.setGear(cruiseGear);
+ fishingOperation.setEnvironmentCaracteristics(environmentCaracteristics);
+ fishingOperation.setGearShootingCaracteristics(gearShootingCaracteristics);
+
+ FishingOperationLocation strata = new FishingOperationLocation();
+ strata.setId(dbResource.getFixtures().strataId());
+ fishingOperation.setStrata(strata);
+ FishingOperationLocation subStrata = new FishingOperationLocation();
+ subStrata.setId(dbResource.getFixtures().subStrataId());
+ fishingOperation.setSubStrata(subStrata);
+ FishingOperationLocation localite = new FishingOperationLocation();
+ localite.setId(dbResource.getFixtures().localite());
+ fishingOperation.setLocation(localite);
// Store fishing operation into database :
createdFishingOperation = service.createFishingOperation(fishingOperation);
@@ -197,6 +260,19 @@
assertEquals(fishingOperation.isFishingOperationRectiligne(), reloadedFishingOperation.isFishingOperationRectiligne());
assertEquals(fishingOperation.getFishingOperationValid(), reloadedFishingOperation.getFishingOperationValid());
assertEquals(fishingOperation.getComment(), reloadedFishingOperation.getComment());
+ assertNotNull(reloadedFishingOperation.getEnvironmentCaracteristics());
+ assertEquals(environmentCaracteristics.size(), fishingOperation.getEnvironmentCaracteristics().size());
+ assertNotNull(reloadedFishingOperation.getGearShootingCaracteristics());
+ assertEquals(gearShootingCaracteristics.size(), reloadedFishingOperation.getGearShootingCaracteristics().size());
+ assertNotNull(reloadedFishingOperation.getStrata());
+ assertNotNull(reloadedFishingOperation.getStrata().getId());
+ assertEquals(fishingOperation.getStrata().getId(), reloadedFishingOperation.getStrata().getId());
+ assertNotNull(reloadedFishingOperation.getSubStrata());
+ assertNotNull(reloadedFishingOperation.getSubStrata().getId());
+ assertEquals(fishingOperation.getSubStrata().getId(), reloadedFishingOperation.getSubStrata().getId());
+ assertNotNull(reloadedFishingOperation.getLocation());
+ assertNotNull(reloadedFishingOperation.getLocation().getId());
+ assertEquals(fishingOperation.getLocation().getId(), reloadedFishingOperation.getLocation().getId());
// -----------------------------------------------------------------------------
// 3. Test :
@@ -228,8 +304,8 @@
assertEquals(fishingOperation.getFishingOperationValid(), reloadedFishingOperation.getFishingOperationValid());
// -----------------------------------------------------------------------------
- // 4. Test :
- // - try to save a operation using a gear not declared uin the cruise
+ // 4. Test exceptions :
+ // - try to save a operation using a gear not declared in the cruise
// - try to save a operation using a trawl net number bigger than the cruise trawl net
// -----------------------------------------------------------------------------
fishingOperation.setId(null);
@@ -252,6 +328,7 @@
}
catch(DataIntegrityViolationException dive) {
assertNotNull(dive);
+ fishingOperation.setGear(cruiseGear);
}
fishingOperation.setTrawlNetNumber(new Integer(3));
@@ -261,11 +338,43 @@
}
catch(DataIntegrityViolationException dive) {
assertNotNull(dive);
+ fishingOperation.setTrawlNetNumber(new Integer(1));
}
- //reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId());
- //assertEquals(fishingOperation.getGearShootingStartLatitude(), reloadedFishingOperation.getGearShootingStartLatitude());
- //assertEquals(fishingOperation.getGearShootingStartLongitude(), reloadedFishingOperation.getGearShootingStartLongitude());
+ // -----------------------------------------------------------------------------
+ // 5. Test update (delete unecessary data)
+ // - remove positons
+ // - remove strata, substrata, localite
+ // - remove some environment carateristics
+ // - remove some gear shooting carateristics
+ // -----------------------------------------------------------------------------
+ fishingOperation.setId(reloadedFishingOperation.getId());
+ fishingOperation.setGearShootingStartLatitude(null);
+ fishingOperation.setGearShootingStartLongitude(null);
+ fishingOperation.setGearShootingEndDate(null);
+ fishingOperation.setGearShootingEndLatitude(null);
+ fishingOperation.setGearShootingEndLongitude(null);
+ fishingOperation.setTrawlDistance(null);
+ fishingOperation.setStrata(null);
+ fishingOperation.setSubStrata(null);
+ fishingOperation.setLocation(null);
+ fishingOperation.setEnvironmentCaracteristics(environmentValuesOneEntry);
+ fishingOperation.setGearShootingCaracteristics(gearShootingCaracteristicsOneEntry);
+ fishingOperation.setComment(fishingOperation.getComment() + "\n\nUnit test createFishingOperation() - Part n°5 : check if deleted sub items in DB");
+ createdFishingOperation = service.saveFishingOperation(fishingOperation);
+ reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId());
+ assertNull(reloadedFishingOperation.getGearShootingStartLatitude());
+ assertNull(reloadedFishingOperation.getGearShootingStartLongitude());
+ assertNull(reloadedFishingOperation.getGearShootingEndDate());
+ assertNull(reloadedFishingOperation.getGearShootingEndLatitude());
+ assertNull(reloadedFishingOperation.getGearShootingEndLongitude());
+ assertNull(reloadedFishingOperation.getStrata());
+ assertNull(reloadedFishingOperation.getSubStrata());
+ assertNull(reloadedFishingOperation.getLocation());
+ assertNotNull(reloadedFishingOperation.getEnvironmentCaracteristics());
+ assertEquals(environmentValuesOneEntry.size(), reloadedFishingOperation.getEnvironmentCaracteristics().size());
+ assertNotNull(reloadedFishingOperation.getGearShootingCaracteristics());
+ assertEquals(gearShootingCaracteristicsOneEntry.size(), reloadedFishingOperation.getGearShootingCaracteristics().size());
}
@Test
1
0
r239 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/protocol resources/i18n resources/icons
by kmorinīŧ users.forge.codelutin.com 21 Jan '13
by kmorinīŧ users.forge.codelutin.com 21 Jan '13
21 Jan '13
Author: kmorin
Date: 2013-01-21 16:51:02 +0100 (Mon, 21 Jan 2013)
New Revision: 239
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/239
Log:
add message on import to warn the user that the protocol will only be saved when he clicks on the save button
Added:
trunk/tutti-ui-swing/src/main/resources/icons/action-warning.png
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-01-21 15:08:12 UTC (rev 238)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-01-21 15:51:02 UTC (rev 239)
@@ -51,6 +51,17 @@
text: {getStringValue(model.getComment())};
}
+#warningContainer {
+ background: {new java.awt.Color(245, 218, 88)};
+ visible: {model.isImported()};
+}
+
+#importWarning {
+ text: "tutti.label.import.warning";
+ actionIcon: warning;
+ border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
+}
+
#saveButton {
enabled: {model.isModify() && model.isValid()};
action: {saveProtocolAction};
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-01-21 15:08:12 UTC (rev 238)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-01-21 15:51:02 UTC (rev 239)
@@ -168,7 +168,9 @@
</JTabbedPane>
-
+ <JPanel id='warningContainer' layout='{new BorderLayout(10, 10)}' constraints='BorderLayout.NORTH'>
+ <JLabel id='importWarning' constraints='BorderLayout.CENTER'/>
+ </JPanel>
<JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
<JButton id='cancelButton'/>
<JButton id='saveButton'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-21 15:08:12 UTC (rev 238)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-21 15:51:02 UTC (rev 239)
@@ -210,6 +210,7 @@
ImportProtocolAction.IMPORT_PROTOCOL_ENTRY.removeContextValue(ui);
model.fromBean(protocol);
+ model.setImported(true);
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-01-21 15:08:12 UTC (rev 238)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-01-21 15:51:02 UTC (rev 239)
@@ -55,6 +55,8 @@
public static final String PROPERTY_SAMPLE_CATEGORY_ORDER = "sampleCategoryOrder";
public static final String PROPERTY_REMOVE_SPECIES_ENABLED = "removeSpeciesEnabled";
+
+ public static final String PROPERTY_IMPORTED = "imported";
protected String name;
@@ -72,6 +74,8 @@
SampleCategoryEnum.sex,
SampleCategoryEnum.maturity,
SampleCategoryEnum.age);
+
+ protected boolean imported;
/**
* Can user remove a selected species?
@@ -198,4 +202,15 @@
public boolean isNameAlreadyUsed() {
return protocolNames.contains(getName());
}
+
+ public boolean isImported() {
+ return imported;
+ }
+
+ public void setImported(boolean imported) {
+ Object oldValue = isImported();
+ this.imported = imported;
+ firePropertyChange(PROPERTY_IMPORTED, oldValue, imported);
+ }
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-21 15:08:12 UTC (rev 238)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-21 15:51:02 UTC (rev 239)
@@ -175,6 +175,7 @@
tutti.label.frequencyConfiguration.no.configuration=< Pas de configuration >
tutti.label.frequencyConfiguration.rafaleStep=Classe de taille à incrÊmenter
tutti.label.frequencyConfiguration.step=Pas de la classe de taille
+tutti.label.import.warning=Le protocole que vous venez d'importer ne sera sauvegardÊ que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.label.list.gear=Engin(s)
tutti.label.list.headOfMission=Chef(s) de mission
tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-warning.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-warning.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r238 - in trunk/tutti-persistence-adagio/src: main/java/fr/ifremer/tutti/persistence/service main/resources test/java/fr/ifremer/tutti/persistence/service
by blavenierīŧ users.forge.codelutin.com 21 Jan '13
by blavenierīŧ users.forge.codelutin.com 21 Jan '13
21 Jan '13
Author: blavenier
Date: 2013-01-21 16:08:12 +0100 (Mon, 21 Jan 2013)
New Revision: 238
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/238
Log:
ref refs #1920: [Persistence] Adagio Donnees thematiques
- Continue implementation of FishingOperation.create() : trawl net number (in GearUseFeatures)
- Change storage of cruise.trawlNet and Gear into GearPhysicalFeatures (for allegro compatibility)
Added:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java
Modified:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml
trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -24,15 +24,40 @@
* #L%
*/
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.StringType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+
import com.google.common.collect.Lists;
+
import fr.ifremer.adagio.core.dao.administration.user.PersonDao;
+import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.ObservedFishingTrip;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
+import fr.ifremer.adagio.core.dao.referential.QualityFlag;
import fr.ifremer.adagio.core.dao.referential.QualityFlagDao;
+import fr.ifremer.adagio.core.dao.referential.gear.GearDao;
import fr.ifremer.adagio.core.dao.referential.location.Location;
import fr.ifremer.adagio.core.dao.referential.location.LocationDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao;
+import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao;
import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -41,28 +66,13 @@
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.type.IntegerType;
-import org.hibernate.type.StringType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataRetrievalFailureException;
-import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
@Service("cruisePersistenceService")
-public class CruisePersistenceServiceImpl extends AbstractPersistenceService implements CruisePersistenceService {
+public class CruisePersistenceServiceImpl extends AbstractPersistenceService implements CruisePersistenceService, MeasurementService {
/** Logger. */
private static final Log log =
@@ -71,6 +81,8 @@
protected static String CRUISE_MISC_DATA_VESSELS_TAG = "#VESSELS=";
protected static String CRUISE_MISC_DATA_GEARS_TAG = "#GEARS=";
+
+ protected static String CRUISE_MISC_DATA_TRAWL_NET_TAG = "#TRAWL_NET=";
@Autowired(required = true)
protected ReferentialPersistenceService referentielService;
@@ -93,6 +105,15 @@
@Resource(name = "qualityFlagDao")
protected QualityFlagDao qualityFlagDao;
+ @Resource(name = "pmfmDao")
+ protected PmfmDao pmfmDao;
+
+ @Resource(name = "qualitativeValueDao")
+ protected QualitativeValueDao qualitativeValueDao;
+
+ @Resource(name = "gearDao")
+ protected GearDao gearDao;
+
protected Calendar calendar = new GregorianCalendar();
@Override
@@ -176,6 +197,16 @@
String miscData = (String) source[11];
if (miscData != null && miscData.length() > 0) {
+ // Retrieve trawl net
+ int trawlNetIndex = miscData.indexOf(CRUISE_MISC_DATA_TRAWL_NET_TAG);
+ if (trawlNetIndex != -1) {
+ String trawlNetStr = miscData.substring(trawlNetIndex + CRUISE_MISC_DATA_TRAWL_NET_TAG.length()).trim();
+ miscData = miscData.substring(0, trawlNetIndex);
+ if (!trawlNetStr.isEmpty()) {
+ result.setTrawlNet(Integer.valueOf(trawlNetStr));
+ }
+ }
+
// Retrieve gears :
int gearTagIndex = miscData.indexOf(CRUISE_MISC_DATA_GEARS_TAG);
if (gearTagIndex == -1) {
@@ -200,6 +231,7 @@
int vesselTagIndex = miscData.indexOf(CRUISE_MISC_DATA_VESSELS_TAG);
if (vesselTagIndex != -1) {
String vesselCodesStr = miscData.substring(vesselTagIndex + CRUISE_MISC_DATA_VESSELS_TAG.length()).trim();
+ miscData = miscData.substring(0, vesselTagIndex);
if (!vesselCodesStr.isEmpty()) {
String[] vesselCodes = vesselCodesStr.split(",");
for (int i = 0; i < vesselCodes.length; i++) {
@@ -208,6 +240,7 @@
}
}
}
+
}
// get secondary gears from fishingOperation (first load from Allegro DB only)
@@ -253,7 +286,25 @@
protected void cruiseToEntity(Cruise source, ScientificCruise target, boolean copyIfNull) {
StringBuffer miscDataBuffer = new StringBuffer();
-
+ QualityFlag qualityFlagNotQualified = qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED);
+
+ // Retrieve entities : FishingTrip
+ ObservedFishingTrip fishingTrip = null;
+ if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) {
+ fishingTrip = ObservedFishingTrip.Factory.newInstance();
+ if (target.getFishingTrips() == null) {
+ target.setFishingTrips(Lists.newArrayList((FishingTrip)fishingTrip));
+ fishingTrip.setScientificCruise(target);
+ } else {
+ target.getFishingTrips().add(fishingTrip);
+ fishingTrip.setScientificCruise(target);
+ }
+ } else {
+ fishingTrip = (ObservedFishingTrip)target.getFishingTrips().iterator().next();
+ }
+
+
+
// Name
if (copyIfNull && source.getName() == null) {
target.setName(null);
@@ -316,9 +367,6 @@
calendar.set(Calendar.MILLISECOND, 0);
target.setReturnDateTime(calendar.getTime());
}
-
- // Poche
- // TODO BLA : voir si le PSFM exists
// Comment
if (copyIfNull && source.getComment() == null) {
@@ -360,23 +408,8 @@
if (target.getManagerPerson() != null) {
target.setRecorderPerson(target.getManagerPerson());
target.setRecorderDepartment(target.getManagerPerson().getDepartment());
- }
+ }
- // FishingTrip
- ObservedFishingTrip fishingTrip = null;
- if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) {
- fishingTrip = ObservedFishingTrip.Factory.newInstance();
- if (target.getFishingTrips() == null) {
- target.setFishingTrips(Lists.newArrayList((FishingTrip)fishingTrip));
- fishingTrip.setScientificCruise(target);
- } else {
- target.getFishingTrips().add(fishingTrip);
- fishingTrip.setScientificCruise(target);
- }
- } else {
- fishingTrip = (ObservedFishingTrip)target.getFishingTrips().iterator().next();
- }
-
// Fill fishing trip with scientificCruise info:
fishingTrip.setDepartureDateTime(target.getDepartureDateTime());
fishingTrip.setReturnDateTime(target.getReturnDateTime());
@@ -386,9 +419,7 @@
fishingTrip.setRecorderDepartment(target.getRecorderDepartment());
fishingTrip.setCreationDate(target.getCreationDate());
fishingTrip.setSynchronizationStatus(target.getSynchronizationStatus());
- if (fishingTrip.getQualityFlag() == null) {
- fishingTrip.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
- }
+ fishingTrip.setQualityFlag(qualityFlagNotQualified);
if (fishingTrip.getReturnDateTime() == null && fishingTrip.getDepartureDateTime() != null) {
calendar.setTime(fishingTrip.getDepartureDateTime());
@@ -413,13 +444,142 @@
//throw new UnsupportedOperationException("Cruise could not yet support gears storage.");
miscDataBuffer.append(CRUISE_MISC_DATA_GEARS_TAG);
for (int i = 0; i < source.getGear().size(); i++) {
+ Gear gear = source.getGear().get(i);
+ GearPhysicalFeatures guf = getGearPhysicalfeatures(fishingTrip, Integer.valueOf(gear.getId()), true);
+ guf.setStartDate(fishingTrip.getDepartureDateTime());
+ guf.setEndDate(fishingTrip.getReturnDateTime());
+ guf.setVessel(fishingTrip.getVessel());
+ guf.setProgram(fishingTrip.getProgram());
+ guf.setCreationDate(target.getCreationDate());
+ guf.setQualityFlag(qualityFlagNotQualified);
+ guf.setRankOrder((short)1);
+
+ // Trawl net (store in Gear Physical features)
+ if (copyIfNull && source.getTrawlNet() == null) {
+ removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_TRAWL_NET);
+ }
+ else {
+ setGearPhysicalMeasurement(target, guf, enumeration.PMFM_ID_TRAWL_NET, Float.valueOf(source.getTrawlNet()), null, null);
+ }
+
+ // TODO BLA : Ã supprimer :
if (i > 0) miscDataBuffer.append(',');
miscDataBuffer.append(source.getGear().get(i).getId());
}
}
-
+
+ // Trawl net (store in misc data)
+ if (copyIfNull && source.getTrawlNet() == null) {
+ miscDataBuffer.append(CRUISE_MISC_DATA_TRAWL_NET_TAG);
+ } else if (source.getTrawlNet() != null) {
+ //throw new UnsupportedOperationException("Cruise could not yet support gears storage.");
+ miscDataBuffer.append(CRUISE_MISC_DATA_TRAWL_NET_TAG);
+ miscDataBuffer.append(source.getTrawlNet());
+ }
+
// Save miscDataBuffer into fishing trip comments, because it's not used in Allegro
fishingTrip.setComments(miscDataBuffer.toString());
}
-
+
+ @Override
+ public GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId) {
+ return getGearPhysicalfeatures(fishingTrip, gearId, false);
+ }
+
+ protected GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId, boolean createIfNotExists) {
+ // Retrieve entities : Gear Physical Features
+ if (fishingTrip.getGearPhysicalFeatures() != null && fishingTrip.getGearPhysicalFeatures().size() >= 0) {
+ for (Iterator iterator = fishingTrip.getGearPhysicalFeatures().iterator(); iterator.hasNext();) {
+ GearPhysicalFeatures guf = (GearPhysicalFeatures) iterator.next();
+ if (gearId.equals(guf.getGear().getId())) {
+ return guf;
+ }
+ }
+ }
+ if (!createIfNotExists) {
+ return null;
+ }
+
+ GearPhysicalFeatures gearPhysicalFeature = GearPhysicalFeatures.Factory.newInstance();
+ gearPhysicalFeature.setFishingTrip(fishingTrip);
+ fr.ifremer.adagio.core.dao.referential.gear.Gear gear = gearDao.load(gearId);
+ if (gear == null) {
+ throw new DataRetrievalFailureException("Gear not found with id=" + gearId);
+ }
+ gearPhysicalFeature.setGear(gear);
+ if (fishingTrip.getGearPhysicalFeatures() == null) {
+ fishingTrip.setGearPhysicalFeatures(Lists.newArrayList(gearPhysicalFeature));
+ } else {
+ fishingTrip.getGearPhysicalFeatures().add(gearPhysicalFeature);
+ }
+
+ return gearPhysicalFeature;
+ }
+
+ @Override
+ public GearPhysicalMeasurement getGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures, Integer pmfmId) {
+ return getGearPhysicalMeasurement(null, gearPhysicalFeatures, pmfmId, false);
+ }
+
+ protected GearPhysicalMeasurement getGearPhysicalMeasurement(ScientificCruise scientificCruise, GearPhysicalFeatures gearPhysicalFeatures,
+ Integer pmfmId, boolean createIfNotExists) {
+ GearPhysicalMeasurement gearPhysicalMeasurement = null;
+ if (gearPhysicalFeatures.getGearPhysicalMeasurements() != null) {
+ for (Iterator iterator = gearPhysicalFeatures.getGearPhysicalMeasurements().iterator(); iterator.hasNext();) {
+ GearPhysicalMeasurement vum = (GearPhysicalMeasurement) iterator.next();
+ if (pmfmId.equals(vum.getPmfm().getId())) {
+ gearPhysicalMeasurement = vum;
+ break;
+ }
+ }
+ }
+ if (gearPhysicalMeasurement == null) {
+ if (!createIfNotExists) {
+ return null;
+ }
+ gearPhysicalMeasurement = GearPhysicalMeasurement.Factory.newInstance();
+ gearPhysicalMeasurement.setGearPhysicalFeatures(gearPhysicalFeatures);
+ if (gearPhysicalFeatures.getGearPhysicalMeasurements() == null) {
+ gearPhysicalFeatures.setGearPhysicalMeasurements(Lists.newArrayList(gearPhysicalMeasurement));
+ }
+ else {
+ gearPhysicalFeatures.getGearPhysicalMeasurements().add(gearPhysicalMeasurement);
+ }
+ gearPhysicalMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ gearPhysicalMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
+ gearPhysicalMeasurement.setPmfm(pmfmDao.load(pmfmId));
+ }
+
+ return gearPhysicalMeasurement;
+ }
+
+ protected void removeGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures,
+ Integer pmfmId) {
+ GearPhysicalMeasurement gearPhysicalMeasurement = getGearPhysicalMeasurement(null, gearPhysicalFeatures, pmfmId, false);
+ if (gearPhysicalMeasurement == null) {
+ return;
+ }
+ gearPhysicalFeatures.getGearPhysicalMeasurements().remove(gearPhysicalMeasurement);
+ // TOBO BLa : vÊrifier qu'il ne faut pas dao.delete() en plus
+ }
+
+ protected GearPhysicalMeasurement setGearPhysicalMeasurement(ScientificCruise scientificCruise, GearPhysicalFeatures gearPhysicalFeatures,
+ Integer pmfmId,
+ Float numericalValue,
+ String alphanumericalValue,
+ Integer qualitativevalueId) {
+ GearPhysicalMeasurement gearPhysicalMeasurement = getGearPhysicalMeasurement(scientificCruise, gearPhysicalFeatures, pmfmId, true);
+
+ if (alphanumericalValue != null) {
+ gearPhysicalMeasurement.setAlphanumericalValue(alphanumericalValue);
+ }
+ else if (numericalValue != null) {
+ gearPhysicalMeasurement.setNumericalValue(numericalValue);
+ }
+ else if (qualitativevalueId != null) {
+ gearPhysicalMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
+ }
+
+ return gearPhysicalMeasurement;
+ }
}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -37,16 +37,21 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.type.IntegerType;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
+import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement;
+import fr.ifremer.adagio.core.dao.data.measure.GearUseMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.VesselUseMeasurement;
import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao;
+import fr.ifremer.adagio.core.dao.data.operation.Operation;
import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise;
import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.GearUseFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.VesselUseFeatures;
import fr.ifremer.adagio.core.dao.data.vessel.feature.use.isActive;
@@ -71,6 +76,9 @@
private static final Log log =
LogFactory.getLog(FishingOperationPersistenceServiceImpl.class);
+ @Resource(name = "cruisePersistenceService")
+ protected MeasurementService measurementService;
+
@Autowired(required = true)
protected ReferentialPersistenceService referentielService;
@@ -115,7 +123,8 @@
"fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(id),
"pmfmIdTrawlDistance", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_DISTANCE,
"pmfmIdRectilinearOperation", IntegerType.INSTANCE, enumeration.PMFM_ID_RECTILINEAR_OPERATION,
- "pmfmIdHaulValid", IntegerType.INSTANCE, enumeration.PMFM_ID_HAUL_VALID
+ "pmfmIdHaulValid", IntegerType.INSTANCE, enumeration.PMFM_ID_HAUL_VALID,
+ "pmfmTrawlNetNumber", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_NET_NUMBER
);
if (source == null) {
@@ -204,6 +213,12 @@
if (haulValidQualitativeId != null) {
result.setFishingOperationValid((enumeration.QUALITATIVE_HAUL_VALID_YES.equals(haulValidQualitativeId)));
}
+
+ // Trawl net number (override the value found in the OP name)
+ Float trawlNetNumber = (Float)source[colIndex++];
+ if (trawlNetNumber != null) {
+ result.setTrawlNetNumber(trawlNetNumber.intValue());
+ }
return result;
}
@@ -228,18 +243,18 @@
// Retrieve entities : FishingTrip and ScientificCruise
ScientificCruise scientificCruise = null;
- FishingTrip fishingtrip = target.getFishingTrip();
- if (fishingtrip == null) {
+ FishingTrip fishingTrip = target.getFishingTrip();
+ if (fishingTrip == null) {
// TODO BLA Êviter ici un rechargement de fishingTrip :
scientificCruise = scientificCruiseDao.load(Integer.valueOf(source.getCruise().getId()));
- fishingtrip = scientificCruise.getFishingTrips().iterator().next();
- fishingtrip.getOperations().add(target); // Inverse link
+ fishingTrip = scientificCruise.getFishingTrips().iterator().next();
+ fishingTrip.getOperations().add(target); // Inverse link
}
else {
- scientificCruise = fishingtrip.getScientificCruise();
+ scientificCruise = fishingTrip.getScientificCruise();
}
// Link to parent fishing trip
- target.setFishingTrip(fishingtrip);
+ target.setFishingTrip(fishingTrip);
// Retrieve entities : VesselPosition (start and end)
VesselPosition startPosition = null;
@@ -257,42 +272,63 @@
}
// Retrieve entities : Gear Use Features
- GearUseFeatures gearUseFeature = null;
+ GearUseFeatures gearUseFeatures = null;
if (target.getGearUseFeatures() == null || target.getGearUseFeatures().size() == 0) {
- gearUseFeature = GearUseFeatures.Factory.newInstance();
+ gearUseFeatures = GearUseFeatures.Factory.newInstance();
+ gearUseFeatures.setOperation(target);
if (target.getGearUseFeatures() == null) {
- target.setGearUseFeatures(Lists.newArrayList(gearUseFeature));
- gearUseFeature.setOperation(target);
+ target.setGearUseFeatures(Lists.newArrayList(gearUseFeatures));
} else {
- target.getGearUseFeatures().add(gearUseFeature);
- gearUseFeature.setOperation(target);
+ target.getGearUseFeatures().add(gearUseFeatures);
}
} else {
- gearUseFeature = target.getGearUseFeatures().iterator().next();
+ gearUseFeatures = target.getGearUseFeatures().iterator().next();
}
// Retrieve entities : Vessel Use Features
- VesselUseFeatures vesselUseFeature = null;
+ VesselUseFeatures vesselUseFeatures = null;
if (target.getVesselUseFeatures() == null || target.getVesselUseFeatures().size() == 0) {
- vesselUseFeature = VesselUseFeatures.Factory.newInstance();
+ vesselUseFeatures = VesselUseFeatures.Factory.newInstance();
if (target.getVesselUseFeatures() == null) {
- target.setVesselUseFeatures(Lists.newArrayList(vesselUseFeature));
- vesselUseFeature.setOperation(target);
+ target.setVesselUseFeatures(Lists.newArrayList(vesselUseFeatures));
+ vesselUseFeatures.setOperation(target);
} else {
- target.getVesselUseFeatures().add(vesselUseFeature);
- vesselUseFeature.setOperation(target);
+ target.getVesselUseFeatures().add(vesselUseFeatures);
+ vesselUseFeatures.setOperation(target);
}
} else {
- vesselUseFeature = target.getVesselUseFeatures().iterator().next();
+ vesselUseFeatures = target.getVesselUseFeatures().iterator().next();
}
+
+ // Retrieve entities : Gear Physical Features
+ GearPhysicalFeatures gearPhysicalFeatures = target.getGearPhysicalFeatures();
+ if (gearPhysicalFeatures == null && source.getGear() != null && source.getGear().getId() != null) {
+ gearPhysicalFeatures = measurementService.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(source.getGear().getId()));
+ if (gearPhysicalFeatures == null) {
+ throw new DataIntegrityViolationException("An operation could not use a gear that is not declared in the cruise.");
+ }
+ target.setGearPhysicalFeatures(gearPhysicalFeatures);
+ if (gearPhysicalFeatures.getOperations() == null) {
+ gearPhysicalFeatures.setOperations(Lists.newArrayList((Operation)target));
+ } else {
+ gearPhysicalFeatures.getOperations().add(target);
+ }
+ }
+
+ // Retrieve tarwl net, from Gear physical features
+ int trawlNet = 1; // default value
+ GearPhysicalMeasurement gpmTrawlNet = measurementService.getGearPhysicalMeasurement(gearPhysicalFeatures, enumeration.PMFM_ID_TRAWL_NET);
+ if (gpmTrawlNet != null && gpmTrawlNet.getNumericalValue() != null) {
+ trawlNet = gpmTrawlNet.getNumericalValue().intValue();
+ }
StringBuffer nameBuffer = new StringBuffer();
// StationNumber
if (copyIfNull && source.getStationNumber() == null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_STATION_NUMBER, null, "", null);
+ setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, "", null);
} else if (source.getStationNumber() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null);
+ setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null);
nameBuffer.append(source.getStationNumber());
}
@@ -312,12 +348,21 @@
// Trawl net number
if (copyIfNull && source.getTrawlNetNumber() == null) {
- // TODO BL : where to store OP N°
+ // Remove from Gear Use Features
+ removeGearUseMeasurement(gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER);
+ if (nameBuffer.length() > 0) {
+ nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR);
+ }
} else if (source.getTrawlNetNumber() != null) {
+ if (source.getTrawlNetNumber().intValue() > trawlNet) {
+ throw new DataIntegrityViolationException("An operation could not have a 'trawl net number' greater than 'trawl net' defined in the cruise.");
+ }
+ // Store into Gear Use Features
+ setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER, Float.valueOf(source.getTrawlNetNumber()), null, null);
+ // Store into the name attribute :
if (nameBuffer.length() > 0) {
nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR);
}
- // TODO BL : store in Gear Use Measurement ?
nameBuffer.append(source.getTrawlNetNumber());
}
@@ -349,19 +394,19 @@
// Trawl distance
if (copyIfNull && source.getTrawlDistance() == null) {
- removeVesselUseMeasurement(vesselUseFeature, enumeration.PMFM_ID_TRAWL_DISTANCE);
+ removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE);
} else if (source.getTrawlDistance() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null);
+ setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null);
}
// Rectilinear operation
- setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO);
+ setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO);
// Operation is valid ?
if (copyIfNull && source.getFishingOperationValid() == null) {
- removeVesselUseMeasurement(vesselUseFeature, enumeration.PMFM_ID_HAUL_VALID);
+ removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID);
} else if (source.getFishingOperationValid() != null) {
- setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO);
+ setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO);
}
// Comment
@@ -372,7 +417,7 @@
}
// Vessel
- target.setVessel(fishingtrip.getVessel());
+ target.setVessel(fishingTrip.getVessel());
// Quality Flag :
if (target.getQualityFlag() == null) {
@@ -390,52 +435,52 @@
}
// VesselUseFeatures :
- vesselUseFeature.setStartDate(target.getStartDateTime());
- if (vesselUseFeature.getStartDate() == null) {
- vesselUseFeature.setStartDate(scientificCruise.getDepartureDateTime());
+ vesselUseFeatures.setStartDate(target.getStartDateTime());
+ if (vesselUseFeatures.getStartDate() == null) {
+ vesselUseFeatures.setStartDate(scientificCruise.getDepartureDateTime());
}
- vesselUseFeature.setEndDate(target.getEndDateTime());
- vesselUseFeature.setVessel(target.getVessel());
- vesselUseFeature.setProgram(scientificCruise.getProgram());
- vesselUseFeature.setIsActive(isActive.ACTIVE.getValue());
- if (vesselUseFeature.getCreationDate() == null) {
+ vesselUseFeatures.setEndDate(target.getEndDateTime());
+ vesselUseFeatures.setVessel(target.getVessel());
+ vesselUseFeatures.setProgram(scientificCruise.getProgram());
+ vesselUseFeatures.setIsActive(isActive.ACTIVE.getValue());
+ if (vesselUseFeatures.getCreationDate() == null) {
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
- vesselUseFeature.setCreationDate(calendar.getTime());
+ vesselUseFeatures.setCreationDate(calendar.getTime());
}
- if (vesselUseFeature.getQualityFlag() == null) {
- vesselUseFeature.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ if (vesselUseFeatures.getQualityFlag() == null) {
+ vesselUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
}
// GearUseFeatures :
- gearUseFeature.setStartDate(target.getStartDateTime());
- if (gearUseFeature.getStartDate() == null) {
- gearUseFeature.setStartDate(scientificCruise.getDepartureDateTime());
+ gearUseFeatures.setStartDate(target.getStartDateTime());
+ if (gearUseFeatures.getStartDate() == null) {
+ gearUseFeatures.setStartDate(scientificCruise.getDepartureDateTime());
}
- gearUseFeature.setEndDate(target.getEndDateTime());
- gearUseFeature.setVessel(target.getVessel());
- gearUseFeature.setProgram(scientificCruise.getProgram());
- if (gearUseFeature.getCreationDate() == null) {
+ gearUseFeatures.setEndDate(target.getEndDateTime());
+ gearUseFeatures.setVessel(target.getVessel());
+ gearUseFeatures.setProgram(scientificCruise.getProgram());
+ if (gearUseFeatures.getCreationDate() == null) {
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
- gearUseFeature.setCreationDate(calendar.getTime());
+ gearUseFeatures.setCreationDate(calendar.getTime());
}
- if (gearUseFeature.getQualityFlag() == null) {
- gearUseFeature.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ if (gearUseFeatures.getQualityFlag() == null) {
+ gearUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
}
// GearUseFeatures.Gear
if (copyIfNull && source.getGear() == null) {
- gearUseFeature.setGear(null);
+ gearUseFeatures.setGear(null);
} else if (source.getGear() != null && source.getGear().getId() != null) {
Gear gear = gearDao.load(Integer.valueOf(source.getGear().getId()));
- gearUseFeature.setGear(gear);
+ gearUseFeatures.setGear(gear);
}
// Start position :
@@ -581,11 +626,7 @@
return DEFAULT_EMPTY_LONGITUDE.equals(databaseValue)?null:databaseValue;
}
- protected Integer getPmfmId() {
- // TODO BLA
- return null;
- }
-
+
protected VesselUseMeasurement getVesselUseMeasurement(ScientificCruise scientificCruise, VesselUseFeatures vesselUseFeatures,
Integer pmfmId, boolean createIfNotExists) {
VesselUseMeasurement vesselUseMeasurement = null;
@@ -647,4 +688,67 @@
return vesselUseMeasurement;
}
+
+ protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures,
+ Integer pmfmId,
+ Float numericalValue,
+ String alphanumericalValue,
+ Integer qualitativevalueId) {
+ GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, pmfmId, true);
+
+ if (alphanumericalValue != null) {
+ gearUseMeasurement.setAlphanumericalValue(alphanumericalValue);
+ }
+ else if (numericalValue != null) {
+ gearUseMeasurement.setNumericalValue(numericalValue);
+ }
+ else if (qualitativevalueId != null) {
+ gearUseMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId));
+ }
+
+ return gearUseMeasurement;
+ }
+
+ protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures,
+ Integer pmfmId, boolean createIfNotExists) {
+ GearUseMeasurement gearUseMeasurement = null;
+ if (gearUseFeatures.getGearUseMeasurements() != null) {
+ for (Iterator iterator = gearUseFeatures.getGearUseMeasurements().iterator(); iterator.hasNext();) {
+ GearUseMeasurement vum = (GearUseMeasurement) iterator.next();
+ if (pmfmId.equals(vum.getPmfm().getId())) {
+ gearUseMeasurement = vum;
+ break;
+ }
+ }
+ }
+ if (gearUseMeasurement == null) {
+ if (!createIfNotExists) {
+ return null;
+ }
+ gearUseMeasurement = GearUseMeasurement.Factory.newInstance();
+ gearUseMeasurement.setGearUseFeatures(gearUseFeatures);
+ if (gearUseFeatures.getGearUseMeasurements() == null) {
+ gearUseFeatures.setGearUseMeasurements(Lists.newArrayList(gearUseMeasurement));
+ }
+ else {
+ gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement);
+ }
+ gearUseMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED));
+ gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment());
+ gearUseMeasurement.setPmfm(pmfmDao.load(pmfmId));
+ }
+
+ return gearUseMeasurement;
+ }
+
+ protected void removeGearUseMeasurement(GearUseFeatures gearUseFeatures,
+ Integer pmfmId) {
+ GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(null, gearUseFeatures, pmfmId, false);
+ if (gearUseMeasurement == null) {
+ return;
+ }
+ gearUseFeatures.getGearUseMeasurements().remove(gearUseMeasurement);
+ // TOBO BLa : vÊrifier qu'il ne faut pas dao.delete() en plus
+ }
+
}
Added: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java (rev 0)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -0,0 +1,13 @@
+package fr.ifremer.tutti.persistence.service;
+
+import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement;
+import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip;
+import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures;
+
+public interface MeasurementService {
+
+ GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId);
+
+ GearPhysicalMeasurement getGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures, Integer pmfmId);
+
+}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -157,6 +157,12 @@
@Value("${QualitativeValueId.HAUL_VALID_NO}")
public final Integer QUALITATIVE_HAUL_VALID_NO = null;
+
+ @Value("${PmfmId.TRAWL_NET}")
+ public final Integer PMFM_ID_TRAWL_NET = null;
+
+ @Value("${PmfmId.TRAWL_NET_NUMBER}")
+ public final Integer PMFM_ID_TRAWL_NET_NUMBER = null;
public void init() {
Modified: trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-21 15:08:12 UTC (rev 238)
@@ -174,7 +174,8 @@
(select vp_end from VesselPositionImpl vp_end where vp_end.operation.id = o.id and vp_end.dateTime = o.endDateTime) as endVesselPosition,
(select vum.numericalValue from VesselUseMeasurementImpl vum where vum.vesselUseFeatures.id=vuf.id and vum.pmfm.id=:pmfmIdTrawlDistance) as trawlDistance,
(select vum2.qualitativeValue.id from VesselUseMeasurementImpl vum2 where vum2.vesselUseFeatures.id=vuf.id and vum2.pmfm.id=:pmfmIdRectilinearOperation) as rectilinearQualitativeId,
- (select vum3.qualitativeValue.id from VesselUseMeasurementImpl vum3 where vum3.vesselUseFeatures.id=vuf.id and vum3.pmfm.id=:pmfmIdHaulValid) as haulValidQualitativeId
+ (select vum3.qualitativeValue.id from VesselUseMeasurementImpl vum3 where vum3.vesselUseFeatures.id=vuf.id and vum3.pmfm.id=:pmfmIdHaulValid) as haulValidQualitativeId,
+ (select gum.numericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id=guf.id and gum.pmfm.id=:pmfmTrawlNetNumber) as trawlNetNumber
FROM
FishingOperationImpl o
INNER JOIN o.gearUseFeatures guf
@@ -186,6 +187,7 @@
<query-param name="pmfmIdTrawlDistance" type="java.lang.Integer"/>
<query-param name="pmfmIdRectilinearOperation" type="java.lang.Integer"/>
<query-param name="pmfmIdHaulValid" type="java.lang.Integer"/>
+ <query-param name="pmfmTrawlNetNumber" type="java.lang.Integer"/>
</query>
Modified: trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-21 15:08:12 UTC (rev 238)
@@ -340,6 +340,15 @@
# TODO A creer (dans les enumerations Allegro)
QualitativeValueId.RECTILINEAR_OPERATION_NO=278
+# TODO A creer (dans les enumerations Allegro)
+# PSFM "Nombre de poche" d'un chalut (Êcran campagne)
+PmfmId.TRAWL_NET=953
+
+# TODO A creer (dans les enumerations Allegro)
+# PSFM "Numero de la poche" (Êcran opÊration)
+## ATTENTION : à modifier quand Vincent aura crÊÊ le PSFM
+PmfmId.TRAWL_NET_NUMBER=953
+
#TODO A creer (dans les enumerations Allegro)
# (20=observateur volant, 95=Administrateur SIH) -> L'avantage du 20 est qu'il est inactif (=20), donc plus facilement detectable
PersonId.UNKNOWN_RECORDER_PERSON=20
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -93,6 +93,9 @@
String programCode = dbResource.getFixtures().programCode();
Cruise cruise = new Cruise();
+ // -----------------------------------------------------------------------------
+ // 1. Test with all properties filled
+ // -----------------------------------------------------------------------------
cruise.setId(null);
cruise.setName("Unit-test-" + System.currentTimeMillis());
@@ -133,7 +136,10 @@
vessels.add(fishingVessel);
cruise.setVessel(vessels);
+
+ cruise.setTrawlNet(new Integer(2));
+ // Create cruise in database
Cruise createdCruise = service.createCruise(cruise);
assertNotNull(createdCruise);
assertNotNull(createdCruise.getId());
@@ -143,9 +149,8 @@
log.info("Created cruise: " + createdCruise.getId());
}
- // Reload cruise :
+ // Then reload cruise and compare
Cruise reloadedCruise = service.getCruise(createdCruise.getId());
-
calendar.setTime(createdCruise.getBeginDate());
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
@@ -154,19 +159,25 @@
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
assertEquals(calendar.getTime(), reloadedCruise.getEndDate());
+ assertEquals(cruise.getTrawlNet(), reloadedCruise.getTrawlNet());
- // New cruise, with empty optional values
+ // -----------------------------------------------------------------------------
+ // 2. Test with only mandatory properties
+ // -----------------------------------------------------------------------------
createdCruise.setId(null);
createdCruise.setHeadOfMission(null);
createdCruise.setBeginDate(null);
createdCruise.setEndDate(null);
createdCruise.setComment(null);
createdCruise.setTrawlNet(null);
+
+ // Save cruise
createdCruise = service.createCruise(cruise);
assertNotNull(createdCruise);
assertNotNull(createdCruise.getId());
assertEquals(cruise.getName(), createdCruise.getName());
+ // Reload to compare
reloadedCruise = service.getCruise(createdCruise.getId());
assertEquals(createdCruise.getBeginDate(), reloadedCruise.getBeginDate());
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-21 10:58:40 UTC (rev 237)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-21 15:08:12 UTC (rev 238)
@@ -27,6 +27,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.Iterator;
import java.util.List;
import fr.ifremer.tutti.persistence.DatabaseResource;
@@ -38,6 +39,10 @@
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.dao.DataIntegrityViolationException;
+
+import com.google.common.collect.Lists;
+
import static org.junit.Assert.*;
/**
@@ -94,8 +99,18 @@
cruise.setName("Unit-test-" + System.currentTimeMillis());
cruise.setBeginDate(new Date());
cruise.setEndDate(null);
+ cruise.setTrawlNet(new Integer(2));
+ // Keep only one gear in the cruise : (need for case n°4)
+ List<Gear> cruiseGears = cruise.getGear();
+ assertNotNull(cruiseGears);
+ assertTrue(cruiseGears.size() > 0);
+ Gear cruiseGear = cruiseGears.get(0);
+ assertNotNull(cruiseGear.getId());
+ cruise.setGear(Lists.newArrayList(cruiseGear));
+
cruise = cruiseService.createCruise(cruise);
assertNotNull(cruise.getId());
+
// Create new fishing operation :
FishingOperation fishingOperation = new FishingOperation();
@@ -120,7 +135,7 @@
assertNotNull("Fishing operation ID must not be null after creation in database", createdFishingOperation);
assertNotNull(createdFishingOperation.getId());
- // Trying to relaod this fishing operation
+ // Trying to reload this fishing operation
reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId());
assertNotNull(reloadedFishingOperation);
assertNull(reloadedFishingOperation.getGearShootingStartDate());
@@ -133,7 +148,7 @@
fishingOperation.setId(null);
fishingOperation.setStationNumber("STA2");
fishingOperation.setFishingOperationNumber(new Integer(2));
- fishingOperation.setTrawlNetNumber(new Integer(2));
+ fishingOperation.setTrawlNetNumber(new Integer(1));
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 1);
calendar.set(Calendar.MILLISECOND, 99);
@@ -154,10 +169,7 @@
fishingOperation.setComment("Unit test createFishingOperation() - Part n°2 : All properties set");
- List<Gear> gears = referentialService.getAllFishingGear();
- assertNotNull(gears);
- assertTrue(gears.size() > 0);
- fishingOperation.setGear(gears.get(0));
+ fishingOperation.setGear(cruiseGear);
// Store fishing operation into database :
createdFishingOperation = service.createFishingOperation(fishingOperation);
@@ -197,7 +209,7 @@
fishingOperation.setId(null);
fishingOperation.setStationNumber("STA3");
fishingOperation.setFishingOperationNumber(new Integer(3));
- fishingOperation.setTrawlNetNumber(new Integer(3));
+ fishingOperation.setTrawlNetNumber(new Integer(2));
fishingOperation.setGearShootingStartLongitude(null);
fishingOperation.setGearShootingEndDate(null);
fishingOperation.setTrawlDistance(null);
@@ -217,10 +229,39 @@
// -----------------------------------------------------------------------------
// 4. Test :
- // -
+ // - try to save a operation using a gear not declared uin the cruise
+ // - try to save a operation using a trawl net number bigger than the cruise trawl net
// -----------------------------------------------------------------------------
fishingOperation.setId(null);
- //createdFishingOperation = service.createFishingOperation(fishingOperation);
+
+ // Find and set a gear not used in the cruise
+ List<Gear> gears = referentialService.getAllFishingGear();
+ assertNotNull(gears);
+ assertTrue(gears.size() > 0);
+ for (Iterator iterator = gears.iterator(); iterator.hasNext();) {
+ Gear gear = (Gear) iterator.next();
+ if (cruiseGear.getId().equals(gear.getId()) == false) {
+ fishingOperation.setGear(gear);
+ break;
+ }
+ }
+
+ try {
+ createdFishingOperation = service.createFishingOperation(fishingOperation);
+ fail("A fishing operation must not be saved if the gear is not declared in the cruise.");
+ }
+ catch(DataIntegrityViolationException dive) {
+ assertNotNull(dive);
+ }
+
+ fishingOperation.setTrawlNetNumber(new Integer(3));
+ try {
+ createdFishingOperation = service.createFishingOperation(fishingOperation);
+ fail("A fishing operation must not be saved if the 'trawl net number' > 'cruise trawl net'.");
+ }
+ catch(DataIntegrityViolationException dive) {
+ assertNotNull(dive);
+ }
//reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId());
//assertEquals(fishingOperation.getGearShootingStartLatitude(), reloadedFishingOperation.getGearShootingStartLatitude());
//assertEquals(fishingOperation.getGearShootingStartLongitude(), reloadedFishingOperation.getGearShootingStartLongitude());
1
0
r237 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: . catches
by kmorinīŧ users.forge.codelutin.com 21 Jan '13
by kmorinīŧ users.forge.codelutin.com 21 Jan '13
21 Jan '13
Author: kmorin
Date: 2013-01-21 11:58:40 +0100 (Mon, 21 Jan 2013)
New Revision: 237
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/237
Log:
prevent from reloading the fishing operation after saving it
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/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 2013-01-20 17:41:41 UTC (rev 236)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-01-21 10:58:40 UTC (rev 237)
@@ -45,12 +45,9 @@
import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
-import fr.ifremer.tutti.ui.swing.util.CustomTab;
-import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -340,67 +337,69 @@
boolean empty = bean == null;
EditFishingOperationUIModel model = getModel();
+
+ if (empty || !bean.equals(model.getFishingOperation()) || fishingOperationMonitor.wasModified()) {
+ if (empty) {
+ bean = new FishingOperation();
+ }
- if (empty) {
- bean = new FishingOperation();
- }
+ FishingOperationLocation strata = bean.getStrata();
+ FishingOperationLocation subStrata = bean.getSubStrata();
+ FishingOperationLocation location = bean.getLocation();
- FishingOperationLocation strata = bean.getStrata();
- FishingOperationLocation subStrata = bean.getSubStrata();
- FishingOperationLocation location = bean.getLocation();
+ Cruise cruise = bean.getCruise();
+ if (cruise != null) {
+ // update gear universe
+ ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
- Cruise cruise = bean.getCruise();
- if (cruise != null) {
- // update gear universe
- ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
+ // update vessel universe
+ ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
+ }
- // update vessel universe
- ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
- }
+ model.fromBean(bean);
- model.fromBean(bean);
+ // to be sure combo list will be reloaded
+ model.setStrata(null);
+ model.setSubStrata(null);
+ model.setLocation(null);
+ model.convertGearShootingCoordinatesDDToDMS();
- // to be sure combo list will be reloaded
- model.setStrata(null);
- model.setSubStrata(null);
- model.setLocation(null);
- model.convertGearShootingCoordinatesDDToDMS();
+ if (strata != null) {
+ ui.getStrataComboBox().setSelectedItem(strata);
+ }
- if (strata != null) {
- ui.getStrataComboBox().setSelectedItem(strata);
- }
+ if (subStrata != null) {
+ ui.getSubStrataComboBox().setSelectedItem(subStrata);
+ }
- if (subStrata != null) {
- ui.getSubStrataComboBox().setSelectedItem(subStrata);
- }
+ if (location != null) {
+ ui.getLocationComboBox().setSelectedItem(location);
+ }
- if (location != null) {
- ui.getLocationComboBox().setSelectedItem(location);
- }
+ model.setFishingOperation(bean);
- model.setFishingOperation(bean);
+ // update saisissuer selection
+ List<Person> saisisseur = model.getSaisisseur();
+ ui.getSaisisseurList().getModel().setSelected(saisisseur);
- // update saisissuer selection
- List<Person> saisisseur = model.getSaisisseur();
- ui.getSaisisseurList().getModel().setSelected(saisisseur);
+ // update model empty property
+ model.setEmpty(empty);
- // update model empty property
- model.setEmpty(empty);
+ //reset gear shooting
+ GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
+ gearShootingTab.getHandler().reset(bean);
- //reset gear shooting
- GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
- gearShootingTab.getHandler().reset(bean);
+ //reset environment
+ EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
+ environmentTab.getHandler().reset(bean);
- //reset environment
- EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
- environmentTab.getHandler().reset(bean);
+ //reset hydrology
+ HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
+ hydrologyTab.getHandler().reset(bean);
- //reset hydrology
- HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
- hydrologyTab.getHandler().reset(bean);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
+ model.setModify(false);
+ fishingOperationMonitor.clearModified();
+ }
}
public void cancel() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-01-20 17:41:41 UTC (rev 236)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-01-21 10:58:40 UTC (rev 237)
@@ -27,8 +27,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
@@ -176,42 +174,44 @@
EditCatchesUIModel model = getModel();
- if (empty) {
- bean = new FishingOperation();
- model.setFishingOperation(null);
- } else {
+ if (empty || !bean.equals(model.getFishingOperation()) || fishingOperationMonitor.wasModified()) {
+ if (empty) {
+ bean = new FishingOperation();
+ model.setFishingOperation(null);
+ } else {
- if (log.isInfoEnabled()) {
- log.info("Get species batch for fishingOperation: " +
- bean.getId() + " - " + fishingOperationText);
+ if (log.isInfoEnabled()) {
+ log.info("Get species batch for fishingOperation: " +
+ bean.getId() + " - " + fishingOperationText);
+ }
+
+ model.setFishingOperation(bean);
}
- model.setFishingOperation(bean);
- }
+ model.fromBean(bean);
- model.fromBean(bean);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
+ model.setModify(false);
+ fishingOperationMonitor.clearModified();
- // 3) Propagate title to others tabs
+ // 3) Propagate title to others tabs
- ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
- ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
+ ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+ ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- // 4) Propagate new selected fishingoperation to others tabs
+ // 4) Propagate new selected fishingoperation to others tabs
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
- ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
- ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
- ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
- ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+ ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
+ ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
+ ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
+ ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
- ui.getTabPane().repaint();
+ ui.getTabPane().repaint();
+ }
}
protected void save() {
1
0
r236 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro
by tchemitīŧ users.forge.codelutin.com 20 Jan '13
by tchemitīŧ users.forge.codelutin.com 20 Jan '13
20 Jan '13
Author: tchemit
Date: 2013-01-20 18:41:41 +0100 (Sun, 20 Jan 2013)
New Revision: 236
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/236
Log:
refs #1874: [IMP/EXP] - Synchronisation de r?\195?\169f?\195?\169rentiel (continue, nearly done)
Modified:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java 2013-01-20 15:57:06 UTC (rev 235)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java 2013-01-20 17:41:41 UTC (rev 236)
@@ -29,9 +29,10 @@
import org.springframework.transaction.annotation.Transactional;
import java.sql.Connection;
-import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
+import java.util.List;
+import java.util.Set;
/**
* Servide to synchronize referential.
@@ -76,7 +77,7 @@
* {@link DataRetrievalFailureException} exception will be thrown.
*
* @param schema1 schema 1 to check
- * @param schema2 shcema 2 to check
+ * @param schema2 schema 2 to check
*/
void checkSchemas(TuttiDatabaseMetadata schema1,
TuttiDatabaseMetadata schema2);
@@ -89,6 +90,28 @@
Dialect getInternalDialect();
/**
+ * Gets the min updateDate for the internal datasource.
+ *
+ * @param schema the db schema
+ * @return the last update date of the given table, or {@code null}
+ * if table does not use a updateDate columns or if there
+ * is no data in table.
+ */
+ Date getMinUpdateDate(TuttiDatabaseMetadata schema) throws SQLException;
+
+ /**
+ * Gets the min updateDate for the given datasource.
+ *
+ * @param connection connection to data source to query
+ * @param schema the db schema
+ * @return the last update date of the given table, or {@code null}
+ * if table does not use a updateDate columns or if there
+ * is no data in table.
+ */
+ Date getMinUpdateDate(Connection connection,
+ TuttiDatabaseMetadata schema) throws SQLException;
+
+ /**
* Gets the last updateDate for the given {@code table} of the internal datasource.
*
* @param table the table to query
@@ -97,6 +120,7 @@
* if table does not use a updateDate columns or if there
* is no data in table.
*/
+ //TODO Make sure a new transaction is not created at each invoaction
Date getLastUpdateDate(TableToSynchronize table,
TuttiDatabaseMetadata schema) throws SQLException;
@@ -115,6 +139,27 @@
TableToSynchronize table,
TuttiDatabaseMetadata schema) throws SQLException;
- ResultSet getDataToUpdate(TableToSynchronize table,
- TuttiDatabaseMetadata schema, Date fromDate);
+ List<Object[]> getDataToUpdate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema, Date fromDate) throws SQLException;
+
+ List<Object[]> getDataToUpdate(Connection connection, TableToSynchronize table,
+ TuttiDatabaseMetadata schema, Date fromDate) throws SQLException;
+
+ Set<String> getExistingIds(TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException;
+
+ Set<String> getExistingIds(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException;
+
+ void updateTable(TableToSynchronize table,
+ TuttiDatabaseMetadata schema,
+ Set<String> existingIds,
+ List<Object[]> incomingData ) throws SQLException;
+
+ void updateTable(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema,
+ Set<String> existingIds,
+ List<Object[]> incomingData ) throws SQLException;
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-01-20 15:57:06 UTC (rev 235)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-01-20 17:41:41 UTC (rev 236)
@@ -39,7 +39,7 @@
AGGREGATION_LEVEL,
PARAMETER_GROUP,
QUALITATIVE_VALUE(false),
- PARAMETER,
+ PARAMETER(TableToSynchronize.newCode("PARAMETER")),
MATRIX,
FRACTION,
METHOD,
@@ -58,12 +58,12 @@
//TODO Association LOCATIONHierarchyException(TableToSynchronize.newId("LOCATIONHierarchyException")),
// TAXON
- TAXONOMIC_LEVEL,
+ TAXONOMIC_LEVEL(TableToSynchronize.newCode("TAXONOMIC_LEVEL")),
REFERENCE_TAXON,
TAXON_NAME,
// TAXON GROUP
- TAXON_GROUP_TYPE,
+ TAXON_GROUP_TYPE(TableToSynchronize.newCode("TAXON_GROUP_TYPE")),
TAXON_GROUP,
// CONVERSION
@@ -74,7 +74,7 @@
VESSEL_TYPE,
//TODO Association VESSEL_REGISTRATION_PERIOD(false),
// VESSEL_FLEET_EVENT,
- VESSEL,
+ VESSEL(TableToSynchronize.newCode("VESSEL")),
// FEATURES
GEAR_PHYSICAL_FEATURES,
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java 2013-01-20 15:57:06 UTC (rev 235)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java 2013-01-20 17:41:41 UTC (rev 236)
@@ -34,7 +34,7 @@
import java.lang.reflect.Field;
import java.util.Map;
-import java.util.Set;
+import java.util.SortedSet;
/**
* TODO
@@ -66,8 +66,8 @@
return columns.size();
}
- public Set<String> getColumnNames() {
- return Sets.newHashSet(columns.keySet());
+ public SortedSet<String> getColumnNames() {
+ return Sets.newTreeSet(columns.keySet());
}
public String getName() {
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java 2013-01-20 15:57:06 UTC (rev 235)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java 2013-01-20 17:41:41 UTC (rev 236)
@@ -24,6 +24,8 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.service.AbstractPersistenceService;
import org.apache.commons.logging.Log;
@@ -40,7 +42,9 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
+import java.util.List;
import java.util.Set;
+import java.util.SortedSet;
/**
* TODO
@@ -57,6 +61,13 @@
public static final String QUERY_SELECT_MAX_UPDATE = "SELECT max(update_date) FROM %s";
+ public static final String QUERY_SELECT_IDS = "SELECT %s FROM %s";
+
+ public static final String QUERY_INSERT = "INSERT INTO %s (%s) VALUES (%s)";
+
+ public static final String QUERY_UPDATE = "UPDATE INTO %s (%s) VALUES (%s) WHERE %s = ?";
+
+
protected Dialect dialect;
@Override
@@ -162,9 +173,195 @@
}
@Override
- public ResultSet getDataToUpdate(TableToSynchronize table,
- TuttiDatabaseMetadata schema, Date fromDate) {
- return null;
+ public Date getMinUpdateDate(TuttiDatabaseMetadata schema) throws SQLException {
+ return getMinUpdateDate(getConnection(), schema);
}
+ @Override
+ public Date getMinUpdateDate(Connection connection,
+ TuttiDatabaseMetadata schema) throws SQLException {
+ Date result = null;
+ for (TuttiTable tuttiTable : TuttiTable.values()) {
+ Date lastUpdateDate = getLastUpdateDate(connection, tuttiTable.getMeta(), schema);
+ if (result == null || (lastUpdateDate != null && lastUpdateDate.before(result))) {
+ result = lastUpdateDate;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public List<Object[]> getDataToUpdate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema, Date fromDate) throws SQLException {
+ return getDataToUpdate(getConnection(), table, schema, fromDate);
+ }
+
+ @Override
+ public List<Object[]> getDataToUpdate(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema,
+ Date fromDate) throws SQLException {
+
+ TuttiTableMetadata tableMeta = schema.getTable(table.getTableName());
+ SortedSet<String> columnNames = tableMeta.getColumnNames();
+ StringBuilder queryParams = new StringBuilder("");
+ for (String columnName : columnNames) {
+ queryParams.append(", ").append(columnName);
+ }
+ StringBuilder query = new StringBuilder("SELECT ");
+ query.append(queryParams.substring(2));
+ query.append(" FROM ").append(tableMeta.getName());
+
+ if (table.isWithUpdateColumn()) {
+
+ // add a filter
+ query.append(" WHERE update_date >= ?");
+ }
+ String sql = query.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query: " + sql);
+ }
+ PreparedStatement statement = connection.prepareStatement(sql);
+ if (table.isWithUpdateColumn()) {
+ statement.setDate(1, new java.sql.Date(fromDate.getTime()));
+ }
+
+ List<Object[]> result = Lists.newArrayList();
+ try {
+ ResultSet resultSet = statement.executeQuery();
+ int columnCount = resultSet.getMetaData().getColumnCount();
+ while (resultSet.next()) {
+ Object[] row = new Object[columnCount];
+ for (int i = 0; i < columnCount; i++) {
+ row[i] = resultSet.getObject(i + 1);
+ }
+ result.add(row);
+ }
+ statement.close();
+ return result;
+ } finally {
+ TuttiEntities.closeSilently(statement);
+ }
+ }
+
+ @Override
+ public Set<String> getExistingIds(TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException {
+ return getExistingIds(getConnection(), table, schema);
+ }
+
+ @Override
+ public Set<String> getExistingIds(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException {
+
+ String sql = String.format(QUERY_SELECT_IDS,
+ table.getPkColumnName(),
+ table.getTableName());
+
+ PreparedStatement statement = connection.prepareStatement(sql);
+
+ Set<String> result = Sets.newHashSet();
+ try {
+ ResultSet resultSet = statement.executeQuery();
+ while (resultSet.next()) {
+ result.add(String.valueOf(resultSet.getObject(1)));
+ }
+ statement.close();
+ return result;
+ } finally {
+ TuttiEntities.closeSilently(statement);
+ }
+ }
+
+ @Override
+ public void updateTable(TableToSynchronize table,
+ TuttiDatabaseMetadata schema,
+ Set<String> existingIds,
+ List<Object[]> incomingData) throws SQLException {
+
+ updateTable(getConnection(),
+ table,
+ schema,
+ existingIds,
+ incomingData);
+ }
+
+ @Override
+ public void updateTable(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema,
+ Set<String> existingIds,
+ List<Object[]> incomingData) throws SQLException {
+
+ TuttiTableMetadata tableMeta = schema.getTable(table.getTableName());
+ ColumnMetadata pkColumn = tableMeta.getColumnMetadata(table.getPkColumnName());
+ String pkColumnName = pkColumn.getName();
+ int pkIndex = 0;
+ SortedSet<String> columnNames = tableMeta.getColumnNames();
+ int columnCount = tableMeta.getColumnsCount();
+
+ StringBuilder queryParams = new StringBuilder("");
+ StringBuilder valueParams = new StringBuilder("");
+ int i = 0;
+
+ for (String columnName : columnNames) {
+ queryParams.append(", ").append(columnName);
+ valueParams.append(", ?");
+ if (pkColumnName.equals(columnName)) {
+ pkIndex = i;
+ } else {
+ i++;
+ }
+ }
+
+ String tableName = tableMeta.getName();
+
+ String insertSql = String.format(QUERY_INSERT, tableName, queryParams.substring(2), valueParams.substring(2));
+ String updateSql = String.format(QUERY_UPDATE, tableName, queryParams.substring(2), valueParams.substring(2), pkColumnName);
+
+ PreparedStatement insertStatement = connection.prepareStatement(insertSql);
+ PreparedStatement updateStatement = connection.prepareStatement(updateSql);
+
+ int nbInsert = 0;
+ int nbUpdate = 0;
+ for (Object[] row : incomingData) {
+
+ Object pk = row[pkIndex];
+
+ PreparedStatement statement;
+
+ boolean doUpdate = existingIds.contains(String.valueOf(pk));
+ if (doUpdate) {
+
+ // use update query
+ statement = updateStatement;
+ nbUpdate++;
+ } else {
+
+ // use insert query
+ statement = insertStatement;
+ nbInsert++;
+ }
+
+ for (int c = 0; c < columnCount; c++) {
+ statement.setObject(c + 1, row[c]);
+ }
+
+ if (doUpdate) {
+ statement.setObject(columnCount + 1, pk);
+ }
+
+ statement.executeUpdate();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("[" + tableName + "] INSERT count: " + nbInsert);
+ log.info("[" + tableName + "] UPDATE count: " + nbUpdate);
+ }
+
+// connection.commit();
+ }
+
}
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java 2013-01-20 15:57:06 UTC (rev 235)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java 2013-01-20 17:41:41 UTC (rev 236)
@@ -34,15 +34,17 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.DataRetrievalFailureException;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
+import java.util.List;
+import java.util.Set;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -170,18 +172,188 @@
}
}
- @Ignore
@Test
- public void getDataToUpdate() throws SQLException {
+ public void getMinUpdateDate() throws Exception {
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+
+ Date minUpdateDate = service.getMinUpdateDate(internalDb);
+ Assert.assertNotNull(minUpdateDate);
+
+ if (log.isInfoEnabled()) {
+ log.info("Min update date: " + minUpdateDate);
+ }
+
+ assertDate(getSqlDate(2009, 6, 18), minUpdateDate);
+
+ // try it on a empty db (no min update_date since no data)
+
+ // create a external empty db
+ externalConnection = dbResource.createEmptyDb("getMinUpdateDate", "newDb");
+ Assert.assertNotNull(externalConnection);
+
+ TuttiDatabaseMetadata externalDb =
+ service.loadExternalDb(externalConnection);
+
+ Date minUpdateDate2 = service.getMinUpdateDate(externalConnection,
+ internalDb);
+ Assert.assertNull(minUpdateDate2);
+ }
+
+ @Test
+ public void getDataToUpdate() throws SQLException, IOException {
+
Date fromDate = getDate(2012, 1, 1);
TuttiDatabaseMetadata internalDb = service.loadInternalDb();
Assert.assertNotNull(internalDb);
+ getDataToUpdate(TuttiTable.STATUS, internalDb, fromDate, 4);
+ getDataToUpdate(TuttiTable.QUALITY_FLAG, internalDb, fromDate, 8);
+ getDataToUpdate(TuttiTable.UNIT, internalDb, fromDate, 2);
+ getDataToUpdate(TuttiTable.AGGREGATION_LEVEL, internalDb, fromDate, 0);
+ getDataToUpdate(TuttiTable.PARAMETER_GROUP, internalDb, fromDate, 6);
+ getDataToUpdate(TuttiTable.QUALITATIVE_VALUE, internalDb, fromDate, 1162);
+ getDataToUpdate(TuttiTable.PARAMETER, internalDb, fromDate, 36);
+ getDataToUpdate(TuttiTable.MATRIX, internalDb, fromDate, 1);
+ getDataToUpdate(TuttiTable.FRACTION, internalDb, fromDate, 0);
+ getDataToUpdate(TuttiTable.METHOD, internalDb, fromDate, 5);
+ getDataToUpdate(TuttiTable.PMFM, internalDb, fromDate, 51);
+ getDataToUpdate(TuttiTable.GEAR_CLASSIFICATION, internalDb, fromDate, 1);
+ getDataToUpdate(TuttiTable.GEAR, internalDb, fromDate, 94);
+ getDataToUpdate(TuttiTable.LOCATION_CLASSIFICATION, internalDb, fromDate, 0);
+ getDataToUpdate(TuttiTable.LOCATION_LEVEL, internalDb, fromDate, 23);
+ getDataToUpdate(TuttiTable.LOCATION, internalDb, fromDate, 5333);
+ getDataToUpdate(TuttiTable.TAXONOMIC_LEVEL, internalDb, fromDate, 28);
+ getDataToUpdate(TuttiTable.REFERENCE_TAXON, internalDb, fromDate, 781);
+ getDataToUpdate(TuttiTable.TAXON_NAME, internalDb, fromDate, 2393);
+ getDataToUpdate(TuttiTable.TAXON_GROUP_TYPE, internalDb, fromDate, 1);
+ getDataToUpdate(TuttiTable.TAXON_GROUP, internalDb, fromDate, 1149);
+ getDataToUpdate(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, fromDate, 3518);
+ getDataToUpdate(TuttiTable.WEIGHT_LENGTH_CONVERSION, internalDb, fromDate, 83);
+ getDataToUpdate(TuttiTable.VESSEL_TYPE, internalDb, fromDate, 2);
+ getDataToUpdate(TuttiTable.VESSEL, internalDb, fromDate, 181608);
+ getDataToUpdate(TuttiTable.GEAR_PHYSICAL_FEATURES, internalDb, fromDate, 1);
+ getDataToUpdate(TuttiTable.VESSEL_PHYSICAL_FEATURES, internalDb, fromDate, 0);
+ getDataToUpdate(TuttiTable.USER_PROFIL, internalDb, fromDate, 0);
+ getDataToUpdate(TuttiTable.DEPARTMENT, internalDb, fromDate, 25);
+ getDataToUpdate(TuttiTable.PERSON, internalDb, fromDate, 194);
+ // try it on a empty db (nothing to synch)
+
+ // create a external empty db
+ externalConnection = dbResource.createEmptyDb("getDataToUpdate", "newDb");
+ Assert.assertNotNull(externalConnection);
+
+ TuttiDatabaseMetadata externalDb =
+ service.loadExternalDb(externalConnection);
+
+ for (TuttiTable tuttiTable : TuttiTable.values()) {
+ getDataToUpdate(tuttiTable, externalDb, true, fromDate, 0);
+ }
}
+ @Test
+ public void getExistingIds() throws SQLException, IOException {
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+
+ getExistingIds(TuttiTable.STATUS, internalDb, 4);
+ getExistingIds(TuttiTable.QUALITY_FLAG, internalDb, 8);
+ getExistingIds(TuttiTable.UNIT, internalDb, 30);
+ getExistingIds(TuttiTable.AGGREGATION_LEVEL, internalDb, 8);
+ getExistingIds(TuttiTable.PARAMETER_GROUP, internalDb, 11);
+ getExistingIds(TuttiTable.QUALITATIVE_VALUE, internalDb, 1162);
+ getExistingIds(TuttiTable.PARAMETER, internalDb, 294);
+ getExistingIds(TuttiTable.MATRIX, internalDb, 16);
+ getExistingIds(TuttiTable.FRACTION, internalDb, 52);
+ getExistingIds(TuttiTable.METHOD, internalDb, 39);
+ getExistingIds(TuttiTable.PMFM, internalDb, 538);
+ getExistingIds(TuttiTable.GEAR_CLASSIFICATION, internalDb, 5);
+ getExistingIds(TuttiTable.GEAR, internalDb, 185);
+ getExistingIds(TuttiTable.LOCATION_CLASSIFICATION, internalDb, 3);
+ getExistingIds(TuttiTable.LOCATION_LEVEL, internalDb, 78);
+ getExistingIds(TuttiTable.LOCATION, internalDb, 17887);
+ getExistingIds(TuttiTable.TAXONOMIC_LEVEL, internalDb, 30);
+ getExistingIds(TuttiTable.REFERENCE_TAXON, internalDb, 8609);
+ getExistingIds(TuttiTable.TAXON_NAME, internalDb, 16821);
+ getExistingIds(TuttiTable.TAXON_GROUP_TYPE, internalDb, 4);
+ getExistingIds(TuttiTable.TAXON_GROUP, internalDb, 13353);
+ getExistingIds(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, 3518);
+ getExistingIds(TuttiTable.WEIGHT_LENGTH_CONVERSION, internalDb, 2579);
+ getExistingIds(TuttiTable.VESSEL_TYPE, internalDb, 10);
+ getExistingIds(TuttiTable.VESSEL, internalDb, 199299);
+ getExistingIds(TuttiTable.GEAR_PHYSICAL_FEATURES, internalDb, 1);
+ getExistingIds(TuttiTable.VESSEL_PHYSICAL_FEATURES, internalDb, 0);
+ getExistingIds(TuttiTable.USER_PROFIL, internalDb, 4);
+ getExistingIds(TuttiTable.DEPARTMENT, internalDb, 76);
+ getExistingIds(TuttiTable.PERSON, internalDb, 417);
+
+ // try it on a empty db (nothing to synch)
+
+ // create a external empty db
+ externalConnection = dbResource.createEmptyDb("getExistingIds", "newDb");
+ Assert.assertNotNull(externalConnection);
+
+ TuttiDatabaseMetadata externalDb =
+ service.loadExternalDb(externalConnection);
+
+ for (TuttiTable tuttiTable : TuttiTable.values()) {
+ getExistingIds(tuttiTable, externalDb, true, 0);
+ }
+ }
+
+ protected void getExistingIds(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ int expectedResult) throws SQLException {
+ getExistingIds(tuttiTable, db, false, expectedResult);
+ }
+
+ protected void getExistingIds(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ boolean external,
+ int expectedResult) throws SQLException {
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+ Set<String> actual;
+ if (external) {
+ actual = service.getExistingIds(externalConnection,
+ tuttiTable.getMeta(), db);
+ } else {
+ actual = service.getExistingIds(tuttiTable.getMeta(), db);
+ }
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(expectedResult, actual.size());
+ }
+
+ protected void getDataToUpdate(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ Date fromDate,
+ int expectedResult) throws SQLException {
+ getDataToUpdate(tuttiTable, db, false, fromDate, expectedResult);
+ }
+
+ protected void getDataToUpdate(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ boolean external,
+ Date fromDate, int expectedResult) throws SQLException {
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+ List<Object[]> actual;
+ if (external) {
+ actual = service.getDataToUpdate(externalConnection,
+ tuttiTable.getMeta(), db, fromDate);
+ } else {
+ actual = service.getDataToUpdate(tuttiTable.getMeta(), db, fromDate);
+ }
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(expectedResult, actual.size());
+ }
+
protected void getLastUpdateDate(TuttiTable tuttiTable,
TuttiDatabaseMetadata db,
Date expected) throws SQLException {
@@ -206,16 +378,20 @@
Assert.assertNull(actual);
} else {
- Calendar expectedCal = Calendar.getInstance();
- expectedCal.setTime(expected);
- Calendar actualCal = Calendar.getInstance();
- actualCal.setTime(actual);
- Assert.assertEquals(expectedCal.get(Calendar.YEAR), actualCal.get(Calendar.YEAR));
- Assert.assertEquals(expectedCal.get(Calendar.MONTH), actualCal.get(Calendar.MONTH));
- Assert.assertEquals(expectedCal.get(Calendar.DAY_OF_MONTH), actualCal.get(Calendar.DAY_OF_MONTH));
+ assertDate(expected, actual);
}
}
+ protected void assertDate(Date expected, Date actual) {
+ Calendar expectedCal = Calendar.getInstance();
+ expectedCal.setTime(expected);
+ Calendar actualCal = Calendar.getInstance();
+ actualCal.setTime(actual);
+ Assert.assertEquals(expectedCal.get(Calendar.YEAR), actualCal.get(Calendar.YEAR));
+ Assert.assertEquals(expectedCal.get(Calendar.MONTH), actualCal.get(Calendar.MONTH));
+ Assert.assertEquals(expectedCal.get(Calendar.DAY_OF_MONTH), actualCal.get(Calendar.DAY_OF_MONTH));
+ }
+
protected Date getSqlDate(int year, int month, int day) {
return getDate(year, month - 1, day);
}
1
0
20 Jan '13
Author: tchemit
Date: 2013-01-20 16:57:06 +0100 (Sun, 20 Jan 2013)
New Revision: 235
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/235
Log:
refs #1874: [IMP/EXP] - Synchronisation de r?\195?\169f?\195?\169rentiel (debut)
Added:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java
trunk/tutti-persistence-adagio/src/test/startServerNew.sh
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TableToSynchronize.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiDatabaseMetadata.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
Modified:
trunk/pom.xml
trunk/tutti-persistence-adagio/pom.xml
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceAdagioProvider.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java
trunk/tutti-persistence-adagio/src/test/resources/tutti-test.properties
trunk/tutti-persistence-adagio/src/test/startServer.sh
trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/config/TopiaPersistenceDevConfigProvider.java
trunk/tutti-persistence/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/pom.xml 2013-01-20 15:57:06 UTC (rev 235)
@@ -160,6 +160,7 @@
<slf4j.version>1.6.1</slf4j.version>
<ehcache.version>2.3.0</ehcache.version>
<javassist.version>3.12.1.GA</javassist.version>
+ <hsqldb.version>2.2.9</hsqldb.version>
<jdbc.hsqldb.version>1.8.0.7</jdbc.hsqldb.version>
</properties>
@@ -396,6 +397,12 @@
</dependency>
<dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>${hsqldb.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>com.esotericsoftware.yamlbeans</groupId>
<artifactId>yamlbeans</artifactId>
<version>1.06</version>
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence/pom.xml 2013-01-20 15:57:06 UTC (rev 235)
@@ -66,8 +66,15 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -33,7 +33,12 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperationAware;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -47,6 +52,9 @@
*/
public class TuttiEntities {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TuttiEntities.class);
+
protected TuttiEntities() {
// helper class does not instanciate
}
@@ -96,6 +104,37 @@
return result;
}
+ public static void closeSilently(Statement statement) {
+ try {
+ if (statement != null && !statement.isClosed()) {
+
+ statement.close();
+ }
+ } catch (AbstractMethodError e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Fix this linkage error, damned spring :(");
+ }
+ } catch (SQLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close statement, but do not care", e);
+ }
+ }
+ }
+
+ public static void closeSilently(Connection connection) {
+ try {
+ if (connection != null && !connection.isClosed()) {
+
+ connection.close();
+
+ }
+ } catch (SQLException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close connection, but do not care", e);
+ }
+ }
+ }
+
protected static class IdPredicate<B extends IdAware> implements Predicate<B> {
private final String id;
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,120 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence API
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.hibernate.dialect.Dialect;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+
+/**
+ * Servide to synchronize referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+@Transactional(readOnly = true)
+public interface ReferentialSynchronizeService {
+
+ /**
+ * Load the internal datasource schema to synchronize.
+ *
+ * @return the internal datasource schema
+ * @see TuttiTableMetadata
+ */
+ TuttiDatabaseMetadata loadInternalDb();
+
+ /**
+ * Load the datasource schema for the given connectionand internla dialect.
+ *
+ * @param connection connection of the data source
+ * @return the datasource schema
+ */
+ TuttiDatabaseMetadata loadExternalDb(Connection connection);
+
+ /**
+ * Load the datasource schema for the given connection and dialect.
+ *
+ * @param connection connection of the data source
+ * @param dialect dialect to use
+ * @return the datasource schema
+ */
+ TuttiDatabaseMetadata loadExternalDb(Connection connection,
+ Dialect dialect);
+
+ /**
+ * Check that the tow given datasource shemas are compatible for a
+ * synchronize operation (same tables with same columns).
+ * <p/>
+ * If schemas are incompatible, then a
+ * {@link DataRetrievalFailureException} exception will be thrown.
+ *
+ * @param schema1 schema 1 to check
+ * @param schema2 shcema 2 to check
+ */
+ void checkSchemas(TuttiDatabaseMetadata schema1,
+ TuttiDatabaseMetadata schema2);
+
+ /**
+ * Gets the internal data source dialect.
+ *
+ * @return the dialect used by internal datasource.
+ */
+ Dialect getInternalDialect();
+
+ /**
+ * Gets the last updateDate for the given {@code table} of the internal datasource.
+ *
+ * @param table the table to query
+ * @param schema the db schema
+ * @return the last update date of the given table, or {@code null}
+ * if table does not use a updateDate columns or if there
+ * is no data in table.
+ */
+ Date getLastUpdateDate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException;
+
+ /**
+ * Gets the last updateDate for the given {@code table} using
+ * the given datasource
+ *
+ * @param connection connection to data source to query
+ * @param table the table to query
+ * @param schema the db schema
+ * @return the last update date of the given table, or {@code null}
+ * if table does not use a updateDate columns or if there
+ * is no data in table.
+ */
+ Date getLastUpdateDate(Connection connection,
+ TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException;
+
+ ResultSet getDataToUpdate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema, Date fromDate);
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TableToSynchronize.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TableToSynchronize.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TableToSynchronize.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,118 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence API
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.hibernate.tool.hbm2ddl.ColumnMetadata;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Date;
+
+/**
+ * Define a table to synch.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class TableToSynchronize implements Serializable {
+
+ public static final String PK_ID = "id";
+
+ public static final String PK_CODE = "code";
+
+ public static final String UPDATE_DATE = "updateDate";
+
+ private static final long serialVersionUID = 1L;
+
+ public static TableToSynchronize newCode(String tableName) {
+ return newCode(tableName, true);
+ }
+
+ public static TableToSynchronize newCode(String tableName, boolean updatable) {
+ return new TableToSynchronize(tableName, PK_CODE, updatable);
+ }
+
+ public static TableToSynchronize newId(String tableName) {
+ return newId(tableName, true);
+ }
+
+ public static TableToSynchronize newId(String tableName, boolean updatable) {
+ return new TableToSynchronize(tableName, PK_ID, updatable);
+ }
+
+ /**
+ * Name of the table.
+ *
+ * @since 1.0
+ */
+ protected final String tableName;
+
+ /**
+ * Name of the column which acts as primary key.
+ *
+ * @since 1.0
+ */
+ protected final String pkColumnName;
+
+ /**
+ * Optional restrict condition to add on query to select data to synchronize.
+ *
+ * @since 1.0
+ */
+ protected final boolean withUpdateColumn;
+
+ public TableToSynchronize(String tableName,
+ String pkColumnName,
+ boolean withUpdateColumn) {
+ this.tableName = tableName;
+ this.pkColumnName = pkColumnName;
+ this.withUpdateColumn = withUpdateColumn;
+ }
+
+ public void addRestrictFilter(PreparedStatement statement,
+ TuttiTableMetadata meta,
+ Date date) throws SQLException {
+ ColumnMetadata updateDate = meta.getColumnMetadata(UPDATE_DATE);
+ if (updateDate != null) {
+
+ // can add a filteron updateDate column
+ int columnsCount = meta.getColumnsCount();
+ statement.setDate(columnsCount + 1, new java.sql.Date(date.getTime()));
+ }
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public String getPkColumnName() {
+ return pkColumnName;
+ }
+
+ public boolean isWithUpdateColumn() {
+ return withUpdateColumn;
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TableToSynchronize.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiDatabaseMetadata.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiDatabaseMetadata.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiDatabaseMetadata.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,100 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence API
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.mapping.Table;
+import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+import org.hibernate.tool.hbm2ddl.TableMetadata;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class TuttiDatabaseMetadata {
+
+ protected final DatabaseMetadata delegate;
+
+ protected Map<String, TuttiTableMetadata> tables;
+
+ public TuttiDatabaseMetadata(Connection connection, Dialect dialect) {
+ Preconditions.checkNotNull(connection);
+ Preconditions.checkNotNull(dialect);
+ try {
+ this.delegate = new DatabaseMetadata(connection, dialect, true);
+ } catch (SQLException e) {
+ throw new RuntimeException(
+ "Could not init database meta on connection " + connection, e);
+ }
+ tables = Maps.newTreeMap();
+ }
+
+ public TuttiTableMetadata getTable(String name) throws HibernateException {
+ return getTable(name, "PUBLIC", null, false);
+ }
+
+ public int getTableCount() {
+ return tables.size();
+ }
+
+ public Set<String> getTableNames() {
+ HashSet<String> result = Sets.newHashSet();
+ for (TuttiTableMetadata tableMetadata : tables.values()) {
+ result.add(tableMetadata.getName());
+ }
+ return result;
+ }
+
+ protected TuttiTableMetadata getTable(String name,
+ String schema,
+ String catalog,
+ boolean isQuoted) throws HibernateException {
+ String key = Table.qualify(catalog, schema, name);
+ TuttiTableMetadata tuttiTableMetadata = tables.get(key);
+ if (tuttiTableMetadata == null) {
+
+ TableMetadata tableMetadata = delegate.getTableMetadata(name, schema, catalog, isQuoted);
+ Preconditions.checkNotNull(tableMetadata,
+ "Could not find db table " + name);
+ tuttiTableMetadata = new TuttiTableMetadata(tableMetadata);
+ Preconditions.checkNotNull(tuttiTableMetadata,
+ "Could not find db table " + name);
+ tables.put(key, tuttiTableMetadata);
+ }
+ return tuttiTableMetadata;
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiDatabaseMetadata.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence API
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public enum TuttiTable {
+ STATUS(TableToSynchronize.newCode("STATUS", false)),
+ QUALITY_FLAG(TableToSynchronize.newCode("QUALITY_FLAG", false)),
+
+ // PMFM
+ UNIT,
+ AGGREGATION_LEVEL,
+ PARAMETER_GROUP,
+ QUALITATIVE_VALUE(false),
+ PARAMETER,
+ MATRIX,
+ FRACTION,
+ METHOD,
+ PMFM,
+
+ // GEAR
+ GEAR_CLASSIFICATION,
+ GEAR,
+
+ // LOCATION
+ LOCATION_CLASSIFICATION,
+ LOCATION_LEVEL,
+ //TODO Association LOCATIONAssociation(TableToSynchronize.newId("LOCATIONAssociation")),
+ LOCATION,
+//TODO Association LOCATIONHierarchy(TableToSynchronize.newId("LOCATIONHierarchy")),
+//TODO Association LOCATIONHierarchyException(TableToSynchronize.newId("LOCATIONHierarchyException")),
+
+ // TAXON
+ TAXONOMIC_LEVEL,
+ REFERENCE_TAXON,
+ TAXON_NAME,
+
+ // TAXON GROUP
+ TAXON_GROUP_TYPE,
+ TAXON_GROUP,
+
+ // CONVERSION
+ ROUND_WEIGHT_CONVERSION,
+ WEIGHT_LENGTH_CONVERSION,
+
+ // VESSEL
+ VESSEL_TYPE,
+ //TODO Association VESSEL_REGISTRATION_PERIOD(false),
+// VESSEL_FLEET_EVENT,
+ VESSEL,
+
+ // FEATURES
+ GEAR_PHYSICAL_FEATURES,
+ VESSEL_PHYSICAL_FEATURES,
+
+ USER_PROFIL,
+ DEPARTMENT,
+ PERSON,
+ ;
+
+ private final TableToSynchronize meta;
+
+ private TuttiTable() {
+ this(true);
+ }
+
+ private TuttiTable(boolean updatable) {
+ this.meta = TableToSynchronize.newId(name(), updatable);
+ }
+
+ private TuttiTable(TableToSynchronize meta) {
+ this.meta = meta;
+ }
+
+ public TableToSynchronize getMeta() {
+ return meta;
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,100 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence API
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.tool.hbm2ddl.ColumnMetadata;
+import org.hibernate.tool.hbm2ddl.ForeignKeyMetadata;
+import org.hibernate.tool.hbm2ddl.IndexMetadata;
+import org.hibernate.tool.hbm2ddl.TableMetadata;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class TuttiTableMetadata {
+
+ protected final TableMetadata delegate;
+
+ protected Map<String, ColumnMetadata> columns;
+
+ public TuttiTableMetadata(TableMetadata delegate) {
+
+ Preconditions.checkNotNull(delegate);
+ this.delegate = delegate;
+
+ try {
+ Field field = TableMetadata.class.getDeclaredField("columns");
+ field.setAccessible(true);
+ columns = (Map) field.get(delegate);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not init " + this, e);
+ }
+ }
+
+ public int getColumnsCount() {
+ return columns.size();
+ }
+
+ public Set<String> getColumnNames() {
+ return Sets.newHashSet(columns.keySet());
+ }
+
+ public String getName() {
+ return delegate.getName();
+ }
+
+ public ForeignKeyMetadata getForeignKeyMetadata(ForeignKey fk) {
+ return delegate.getForeignKeyMetadata(fk);
+ }
+
+ public ColumnMetadata getColumnMetadata(String columnName) {
+ return delegate.getColumnMetadata(columnName);
+ }
+
+ public String getSchema() {
+ return delegate.getSchema();
+ }
+
+ public String getCatalog() {
+ return delegate.getCatalog();
+ }
+
+ public ForeignKeyMetadata getForeignKeyMetadata(String keyName) {
+ return delegate.getForeignKeyMetadata(keyName);
+ }
+
+ public IndexMetadata getIndexMetadata(String indexName) {
+ return delegate.getIndexMetadata(indexName);
+ }
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTableMetadata.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence-adagio/pom.xml
===================================================================
--- trunk/tutti-persistence-adagio/pom.xml 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/pom.xml 2013-01-20 15:57:06 UTC (rev 235)
@@ -156,6 +156,11 @@
<artifactId>spring-test</artifactId>
</dependency>
+ <!--dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency-->
+
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceAdagioProvider.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceAdagioProvider.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceAdagioProvider.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -39,12 +39,12 @@
@Override
public String getName() {
- return "tutti-adagio-persistence";
+ return "tutti-persistence-adagio";
}
@Override
public String getDescription(Locale locale) {
- return "Configuration de la persistence de Tutti (Adagio implantation).";
+ return "Configuration de la persistence de Tutti (implantation via Adagio).";
}
@Override
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -26,6 +26,7 @@
import fr.ifremer.adagio.core.service.ServiceLocator;
import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeService;
/**
* To obtain services from spring context.
@@ -111,4 +112,9 @@
public static void close() {
instance().shutdown();
}
+
+ public static ReferentialSynchronizeService getReferentialSynchronizeService() {
+ return instance().getService("referentialSynchronizeService",
+ ReferentialSynchronizeService.class);
+ }
}
Added: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java (rev 0)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,170 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence Adagio (impl)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.service.AbstractPersistenceService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.classic.Session;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.tool.hbm2ddl.ColumnMetadata;
+import org.springframework.dao.DataRetrievalFailureException;
+import org.springframework.stereotype.Service;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+@Service("referentialSynchronizeService")
+public class ReferentialSynchronizeServiceImpl extends AbstractPersistenceService implements ReferentialSynchronizeService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ReferentialSynchronizeServiceImpl.class);
+
+ public static final String QUERY_SELECT_MAX_UPDATE = "SELECT max(update_date) FROM %s";
+
+ protected Dialect dialect;
+
+ @Override
+ public TuttiDatabaseMetadata loadInternalDb() {
+ Connection connection = getConnection();
+
+ return loadExternalDb(connection, getInternalDialect());
+ }
+
+ private Connection getConnection() {
+ Session session = getCurrentSession();
+ return session.connection();
+ }
+
+ @Override
+ public TuttiDatabaseMetadata loadExternalDb(Connection connection) {
+ return loadExternalDb(connection, getInternalDialect());
+ }
+
+ @Override
+ public TuttiDatabaseMetadata loadExternalDb(Connection connection,
+ Dialect dialect) {
+ TuttiDatabaseMetadata result = new TuttiDatabaseMetadata(connection, dialect);
+ for (TuttiTable tuttiTable : TuttiTable.values()) {
+
+ TableToSynchronize meta = tuttiTable.getMeta();
+ String tableName = meta.getTableName();
+ if (log.isDebugEnabled()) {
+ log.debug("Load metas of table: " + tableName);
+ }
+ result.getTable(tableName);
+ }
+ return result;
+ }
+
+ @Override
+ public void checkSchemas(TuttiDatabaseMetadata schema1,
+ TuttiDatabaseMetadata schema2) {
+ Set<String> internalSchemaTableNames = schema1.getTableNames();
+ Set<String> externalSchemaTableNames = schema2.getTableNames();
+ if (!internalSchemaTableNames.equals(externalSchemaTableNames)) {
+ throw new DataRetrievalFailureException("Incompatible schemas");
+ }
+ for (String tableName : internalSchemaTableNames) {
+ TuttiTableMetadata internalTable = schema1.getTable(tableName);
+ TuttiTableMetadata externalTable = schema2.getTable(tableName);
+ Set<String> internalColumnNames = internalTable.getColumnNames();
+ Set<String> externalColumnNames = externalTable.getColumnNames();
+ if (!internalColumnNames.equals(externalColumnNames)) {
+ throw new DataRetrievalFailureException("Incompatible schema of table: " + tableName);
+ }
+ for (String columnName : internalColumnNames) {
+ ColumnMetadata internalColumn = internalTable.getColumnMetadata(columnName);
+ ColumnMetadata externalColumn = externalTable.getColumnMetadata(columnName);
+ String internalColumnTypeName = internalColumn.getTypeName();
+ String externalColumnTypeName = externalColumn.getTypeName();
+ if (!internalColumnTypeName.equals(externalColumnTypeName)) {
+ throw new DataRetrievalFailureException("Incompatible column type of table / column: " + tableName + " / " + columnName);
+ }
+ }
+ }
+ }
+
+ @Override
+ public Dialect getInternalDialect() {
+ if (dialect == null) {
+ dialect = ((SessionFactoryImplementor) sessionFactory).getSettings().getDialect();
+ }
+ return dialect;
+ }
+
+ @Override
+ public Date getLastUpdateDate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException {
+
+ Date result = getLastUpdateDate(getConnection(), table, schema);
+ return result;
+ }
+
+ @Override
+ public Date getLastUpdateDate(Connection connection, TableToSynchronize table,
+ TuttiDatabaseMetadata schema) throws SQLException {
+ Date result = null;
+
+ if (table.isWithUpdateColumn()) {
+
+ TuttiTableMetadata tableMeta = schema.getTable(table.getTableName());
+
+ String sql = String.format(QUERY_SELECT_MAX_UPDATE, tableMeta.getName());
+
+ PreparedStatement statement = connection.prepareStatement(sql);
+ try {
+ ResultSet resultSet = statement.executeQuery();
+ if (resultSet.next()) {
+ result = resultSet.getDate(1);
+ }
+ statement.close();
+ } finally {
+ TuttiEntities.closeSilently(statement);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public ResultSet getDataToUpdate(TableToSynchronize table,
+ TuttiDatabaseMetadata schema, Date fromDate) {
+ return null;
+ }
+
+}
Property changes on: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -24,6 +24,12 @@
* #L%
*/
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.common.io.Files;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfigOption;
import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
@@ -38,6 +44,12 @@
import java.io.File;
import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Set;
/**
* To box the persistence service as a test resource.
@@ -50,14 +62,18 @@
/** Logger. */
private static final Log log = LogFactory.getLog(DatabaseResource.class);
+ public static final String TUTTI_PERSISTENCE_JDBC_CREATE_SCRIPT = "tutti.persistence.jdbc.createScript";
+
public static long BUILD_TIMESTAMP = System.nanoTime();
private static ClassLoader oldClassLoader;
- protected TuttiPersistenceAdagioConfig config;
+ private File resourceDirectory;
- protected DatabaseFixtures fixtures;
+ private TuttiPersistenceAdagioConfig config;
+ private DatabaseFixtures fixtures;
+
private final String beanFactoryReferenceLocation;
private final String beanRefFactoryReferenceId;
@@ -80,6 +96,10 @@
return fixtures;
}
+ public File getResourceDirectory(String name) {
+ return new File(resourceDirectory, name);
+ }
+
@Override
public Statement apply(final Statement base, final Description description) {
@@ -115,7 +135,7 @@
fixtures = new DatabaseFixtures();
- File resourceDirectory = getTestSpecificDirectory(testClass, "");
+ resourceDirectory = getTestSpecificDirectory(testClass, "");
RessourceClassLoader loader =
new RessourceClassLoader(testClass.getClassLoader());
@@ -165,6 +185,12 @@
}
}
+ public Connection createEmptyDb(String dbDirectory,
+ String dbName) throws IOException, SQLException {
+ File externalDbFile = getResourceDirectory(dbDirectory);
+ return createEmptyDb(externalDbFile, dbName);
+ }
+
public static File getTestSpecificDirectory(Class<?> testClass,
String name) throws IOException {
// Trying to look for the temporary folder to store data for the test
@@ -189,4 +215,70 @@
return databaseFile;
}
+
+ public Connection createEmptyDb(File directory,
+ String dbName) throws SQLException, IOException {
+
+ if (log.isInfoEnabled()) {
+ log.info("Create new db at " + directory);
+ }
+ String jdbcUrl = "jdbc:hsqldb:file:" + directory.getAbsolutePath() + "/" + dbName;
+ String user = "SA";
+ String password = "";
+
+ File scriptFile = config.getConfig().getOptionAsFile(TUTTI_PERSISTENCE_JDBC_CREATE_SCRIPT);
+
+ Preconditions.checkNotNull("Could not find db script in configuration with key " + TUTTI_PERSISTENCE_JDBC_CREATE_SCRIPT);
+ Preconditions.checkState(scriptFile.exists(), "Could not find db script at " + scriptFile);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will use create script: " + scriptFile);
+ }
+ Connection connection = DriverManager.getConnection(jdbcUrl, user, password);
+
+ if (log.isInfoEnabled()) {
+ log.info("Created connection at " + connection.getMetaData().getURL());
+ }
+
+ List<String> importScriptSql = getImportScriptSql(scriptFile);
+ for (String sql : importScriptSql) {
+ PreparedStatement statement = connection.prepareStatement(sql);
+ statement.execute();
+ }
+ connection.commit();
+ return connection;
+ }
+
+ protected List<String> getImportScriptSql(File scriptFile) throws IOException {
+ List<String> lines = Files.readLines(scriptFile, Charsets.UTF_8);
+
+ List<String> result = Lists.newArrayListWithCapacity(lines.size());
+
+ Predicate<String> predicate = new Predicate<String>() {
+
+ Set<String> forbiddenStarts = Sets.newHashSet(
+ "SET ",
+ "CREATE USER ",
+ "CREATE SCHEMA ",
+ "GRANT DBA TO ");
+
+ @Override
+ public boolean apply(String input) {
+ boolean accept = true;
+ for (String forbiddenStart : forbiddenStarts) {
+ if (input.startsWith(forbiddenStart)) {
+ accept = false;
+ break;
+ }
+ }
+ return accept;
+ }
+ };
+ for (String line : lines) {
+ if (predicate.apply(line.trim().toUpperCase())) {
+ result.add(line);
+ }
+ }
+ return result;
+ }
}
Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java (rev 0)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,232 @@
+package fr.ifremer.tutti.persistence.service.synchro;
+
+/*
+ * #%L
+ * Tutti :: Persistence Adagio (impl)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.dialect.Dialect;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.dao.DataRetrievalFailureException;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ReferentialSynchronizeServiceImplTest {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ReferentialSynchronizeServiceImplTest.class);
+
+ @ClassRule
+ public static final DatabaseResource dbResource = new DatabaseResource();
+
+ protected ReferentialSynchronizeService service;
+
+ protected Connection externalConnection;
+
+ @Before
+ public void setUp() throws Exception {
+ service = TuttiPersistenceServiceLocator.getReferentialSynchronizeService();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ service = null;
+ if (externalConnection != null) {
+ if (!externalConnection.isClosed()) {
+ externalConnection.close();
+ }
+ externalConnection = null;
+ }
+ }
+
+ @Test
+ public void loadInternalDb() throws Exception {
+
+ Dialect dialect = service.getInternalDialect();
+ Assert.assertNotNull(dialect);
+
+ TuttiDatabaseMetadata tuttiDatabaseMetadata = service.loadInternalDb();
+ Assert.assertNotNull(tuttiDatabaseMetadata);
+ }
+
+ @Test
+ public void checkSchemas() throws Exception {
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+ service.checkSchemas(internalDb, internalDb);
+
+ // create a external empty db
+ externalConnection = dbResource.createEmptyDb("checkSchemas", "newDb");
+ Assert.assertNotNull(externalConnection);
+
+ TuttiDatabaseMetadata externalDb = service.loadExternalDb(externalConnection);
+ Assert.assertNotNull(externalDb);
+ service.checkSchemas(internalDb, externalDb);
+
+ // add a column in a table and recheck schemas
+ PreparedStatement statement = externalConnection.prepareStatement("ALTER TABLE PUBLIC.LOCATION ADD newColumn" + System.nanoTime() + " int NOT NULL;");
+ statement.execute();
+ externalConnection.commit();
+
+ try {
+ // reload external schema, it has changed
+ externalDb = service.loadExternalDb(externalConnection);
+
+ service.checkSchemas(internalDb, externalDb);
+ Assert.fail();
+ } catch (DataRetrievalFailureException e) {
+
+ Assert.assertTrue(true);
+ }
+ }
+
+ @Test
+ public void getLastUpdateDate() throws Exception {
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+
+ getLastUpdateDate(TuttiTable.STATUS, internalDb, null);
+ getLastUpdateDate(TuttiTable.QUALITY_FLAG, internalDb, null);
+ getLastUpdateDate(TuttiTable.UNIT, internalDb, getSqlDate(2012, 8, 17));
+ getLastUpdateDate(TuttiTable.AGGREGATION_LEVEL, internalDb, getSqlDate(2011, 6, 9));
+ getLastUpdateDate(TuttiTable.PARAMETER_GROUP, internalDb, getSqlDate(2012, 10, 5));
+ getLastUpdateDate(TuttiTable.QUALITATIVE_VALUE, internalDb, null);
+ getLastUpdateDate(TuttiTable.PARAMETER, internalDb, getSqlDate(2012, 11, 13));
+ getLastUpdateDate(TuttiTable.MATRIX, internalDb, getSqlDate(2012, 8, 13));
+ getLastUpdateDate(TuttiTable.FRACTION, internalDb, getSqlDate(2011, 12, 21));
+ getLastUpdateDate(TuttiTable.METHOD, internalDb, getSqlDate(2012, 9, 28));
+ getLastUpdateDate(TuttiTable.PMFM, internalDb, getSqlDate(2012, 11, 13));
+ getLastUpdateDate(TuttiTable.GEAR_CLASSIFICATION, internalDb, getSqlDate(2012, 11, 15));
+ getLastUpdateDate(TuttiTable.GEAR, internalDb, getSqlDate(2012, 11, 22));
+ getLastUpdateDate(TuttiTable.LOCATION_CLASSIFICATION, internalDb, getSqlDate(2010, 10, 26));
+ getLastUpdateDate(TuttiTable.LOCATION_LEVEL, internalDb, getSqlDate(2012, 11, 22));
+ getLastUpdateDate(TuttiTable.LOCATION, internalDb, getSqlDate(2012, 11, 22));
+ getLastUpdateDate(TuttiTable.TAXONOMIC_LEVEL, internalDb, getSqlDate(2012, 4, 18));
+ getLastUpdateDate(TuttiTable.REFERENCE_TAXON, internalDb, getSqlDate(2012, 11, 15));
+ getLastUpdateDate(TuttiTable.TAXON_NAME, internalDb, getSqlDate(2012, 11, 15));
+ getLastUpdateDate(TuttiTable.TAXON_GROUP_TYPE, internalDb, getSqlDate(2012, 5, 24));
+ getLastUpdateDate(TuttiTable.TAXON_GROUP, internalDb, getSqlDate(2012, 9, 12));
+ getLastUpdateDate(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, getSqlDate(2012, 10, 4));
+ getLastUpdateDate(TuttiTable.WEIGHT_LENGTH_CONVERSION, internalDb, getSqlDate(2012, 10, 23));
+ getLastUpdateDate(TuttiTable.VESSEL_TYPE, internalDb, getSqlDate(2012, 4, 25));
+ getLastUpdateDate(TuttiTable.VESSEL, internalDb, getSqlDate(2012, 11, 22));
+ getLastUpdateDate(TuttiTable.GEAR_PHYSICAL_FEATURES, internalDb, getSqlDate(2012, 11, 22));
+ getLastUpdateDate(TuttiTable.VESSEL_PHYSICAL_FEATURES, internalDb, null);
+ getLastUpdateDate(TuttiTable.USER_PROFIL, internalDb, getSqlDate(2009, 6, 18));
+ getLastUpdateDate(TuttiTable.DEPARTMENT, internalDb, getSqlDate(2012, 11, 15));
+ getLastUpdateDate(TuttiTable.PERSON, internalDb, getSqlDate(2012, 11, 30));
+
+ // try it on a empty db (all values are to null)
+
+ // create a external empty db
+ externalConnection = dbResource.createEmptyDb("getLastUpdateDate", "newDb");
+ Assert.assertNotNull(externalConnection);
+
+ TuttiDatabaseMetadata externalDb =
+ service.loadExternalDb(externalConnection);
+
+ for (TuttiTable tuttiTable : TuttiTable.values()) {
+ getLastUpdateDate(tuttiTable, externalDb, true, null);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void getDataToUpdate() throws SQLException {
+
+ Date fromDate = getDate(2012, 1, 1);
+
+ TuttiDatabaseMetadata internalDb = service.loadInternalDb();
+ Assert.assertNotNull(internalDb);
+
+
+ }
+
+ protected void getLastUpdateDate(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ Date expected) throws SQLException {
+ getLastUpdateDate(tuttiTable, db, false, expected);
+ }
+
+ protected void getLastUpdateDate(TuttiTable tuttiTable,
+ TuttiDatabaseMetadata db,
+ boolean external,
+ Date expected) throws SQLException {
+
+ Date actual;
+ if (external) {
+ actual = service.getLastUpdateDate(externalConnection,
+ tuttiTable.getMeta(), db);
+ } else {
+ actual = service.getLastUpdateDate(tuttiTable.getMeta(), db);
+
+ }
+ if (expected == null) {
+
+ Assert.assertNull(actual);
+ } else {
+
+ Calendar expectedCal = Calendar.getInstance();
+ expectedCal.setTime(expected);
+ Calendar actualCal = Calendar.getInstance();
+ actualCal.setTime(actual);
+ Assert.assertEquals(expectedCal.get(Calendar.YEAR), actualCal.get(Calendar.YEAR));
+ Assert.assertEquals(expectedCal.get(Calendar.MONTH), actualCal.get(Calendar.MONTH));
+ Assert.assertEquals(expectedCal.get(Calendar.DAY_OF_MONTH), actualCal.get(Calendar.DAY_OF_MONTH));
+ }
+ }
+
+ protected Date getSqlDate(int year, int month, int day) {
+ return getDate(year, month - 1, day);
+ }
+
+ protected Date getDate(int year, int month, int day) {
+ Date fromDate = DateUtils.setYears(
+ DateUtils.setMonths(
+ DateUtils.setDays(new Date(), day),
+ month),
+ year);
+ return fromDate;
+ }
+
+}
Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeServiceImplTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence-adagio/src/test/resources/tutti-test.properties
===================================================================
--- trunk/tutti-persistence-adagio/src/test/resources/tutti-test.properties 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/src/test/resources/tutti-test.properties 2013-01-20 15:57:06 UTC (rev 235)
@@ -22,4 +22,5 @@
# #L%
###
#tutti.persistence.jdbc.url=jdbc:hsqldb:file:src/test/db/allegro
-tutti.persistence.jdbc.url=jdbc:hsqldb:hsql://localhost/allegro
\ No newline at end of file
+tutti.persistence.jdbc.url=jdbc:hsqldb:hsql://localhost/allegro
+tutti.persistence.jdbc.createScript=src/test/db/allegro.script
Modified: trunk/tutti-persistence-adagio/src/test/startServer.sh
===================================================================
--- trunk/tutti-persistence-adagio/src/test/startServer.sh 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-adagio/src/test/startServer.sh 2013-01-20 15:57:06 UTC (rev 235)
@@ -1,3 +1,3 @@
#! /bin/sh
-java -classpath ~/.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar org.hsqldb.Server --database.0 file:db/allegro --dbname.0 allegro
\ No newline at end of file
+java -classpath ~/.m2/repository/hsqldb/hsqldb/1.8.0.7/hsqldb-1.8.0.7.jar org.hsqldb.Server --database.0 file:db/allegro --dbname.0 allegro
Copied: trunk/tutti-persistence-adagio/src/test/startServerNew.sh (from rev 231, trunk/tutti-persistence-adagio/src/test/startServer.sh)
===================================================================
--- trunk/tutti-persistence-adagio/src/test/startServerNew.sh (rev 0)
+++ trunk/tutti-persistence-adagio/src/test/startServerNew.sh 2013-01-20 15:57:06 UTC (rev 235)
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+java -classpath ~/.m2/repository/org/hsqldb/hsqldb/2.2.9/hsqldb-2.2.9.jar org.hsqldb.Server --database.0 file:db/allegro --dbname.0 allegro
\ No newline at end of file
Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/config/TopiaPersistenceDevConfigProvider.java
===================================================================
--- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/config/TopiaPersistenceDevConfigProvider.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/config/TopiaPersistenceDevConfigProvider.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -39,12 +39,12 @@
@Override
public String getName() {
- return "tutti-persistence";
+ return "tutti-persistence-dev";
}
@Override
public String getDescription(Locale locale) {
- return "Configuration de la persistence de Tutti";
+ return "Configuration de la persistence de Tutti (implantation par serialisation)";
}
@Override
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-01-19 11:46:29 UTC (rev 234)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-01-20 15:57:06 UTC (rev 235)
@@ -39,11 +39,13 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
-import java.io.Serializable;
-import static org.nuiton.i18n.I18n.n_;
import org.nuiton.util.decorator.Decorator;
import org.nuiton.util.decorator.DecoratorProvider;
+import java.io.Serializable;
+
+import static org.nuiton.i18n.I18n.n_;
+
/**
* Tutti decorator service.
*
@@ -65,7 +67,7 @@
public static final String SPECIES_BY_CODE = "byCode";
public static final String SPECIES_BY_GENUS = "byGenus";
-
+
public static final String CARACTERISTIC_WITH_UNIT = "withUnit";
public static final String BY_NAME = "byName";
1
0
19 Jan '13
Author: tchemit
Date: 2013-01-19 12:46:29 +0100 (Sat, 19 Jan 2013)
New Revision: 234
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/234
Log:
- improve spring usage (use only one service locator instance + clean xml configuration)
- improve TuttiEnumerationFile (everything is checked by it self, no more need to add a test for each field)
- add missing header + svn properties
Added:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java
trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml
trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml
Removed:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java
Modified:
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml
trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml
trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java
Deleted: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -1,202 +0,0 @@
-package fr.ifremer.tutti.persistence;
-
-/*
- * #%L
- * Tutti :: Persistence Adagio (impl)
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import org.springframework.beans.factory.annotation.Value;
-
-/**
- * Contains all constants usable via the enumeration file.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class TuttiEnumerationFile {
-
- @Value("${GearClassificationId.SCIENTIFIC_CRUISE}")
- public final Integer GEAR_CLASSIFICIATION_ID_SCIENTIFIC = null;
-
- @Value("${GearClassificationId.FAO}")
- public final Integer GEAR_CLASSIFICIATION_ID_FISHING = null;
-
- @Value("${LocationLevelId.PAYS_ISO3}")
- public final Integer LOCATION_LEVEL_ID_COUNTRY = null;
-
- @Value("${LocationLevelId.LOCALITE}")
- public final Integer LOCATION_LEVEL_ID_LOCALITE = null;
-
- @Value("${LocationLevelId.PROGRAM}")
- public final Integer LOCATION_LEVEL_ID_PROGRAMM = null;
-
- @Value("${LocationLevelId.STRATA}")
- public final Integer LOCATION_LEVEL_ID_STRATA = null;
-
- @Value("${LocationLevelId.SUBSTRATA}")
- public final Integer LOCATION_LEVEL_ID_SUB_STRATA = null;
-
- @Value("${MatrixId.GEAR}")
- public final Integer MATRIX_ID_GEAR = null;
-
- @Value("${MatrixId.INDIVIDUAL}")
- public final Integer MATRIX_ID_INDIVIDUAL = null;
-
- @Value("${MethodId.DECLARATION}")
- public final Integer METHOD_ID_DECLARATION = null;
-
- @Value("${ParameterCode.AGE}")
- public final String PARAMETER_CODE_AGE = null;
-
- @Value("${ParameterCode.WEIGHT}")
- public final String PARAMETER_CODE_WEIGHT = null;
-
- @Value("${ParameterGroupId.ENVIRONEMENT_MEASUREMENT}")
- public final Integer PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT = null;
-
- @Value("${ParameterGroupId.HYDROLOGIC_MEASUREMENT}")
- public final Integer PARAMETER_GROUP_HYDROLOGIC = null;
-
- @Value("${PmfmId.SIZE_CATEGORY}")
- public final Integer PMFM_ID_SIZE_CATEGORY = null;
-
- @Value("${PmfmId.SEX}")
- public final Integer PMFM_ID_SEX = null;
-
- @Value("${PmfmId.SORTED_UNSORTED}")
- public final Integer PMFM_ID_SORTED_UNSORTED = null;
-
- @Value("${PmfmId.MATURITY}")
- public final Integer PMFM_ID_MATURITY = null;
-
- @Value("${PmfmId.MACRO_WASTE_CATEGORY}")
- public final Integer PMFM_ID_MACRO_WASTE_CATEGORY = null;
-
- @Value("${PmfmId.MACRO_WASTE_SIZE_CATEGORY}")
- public final Integer PMFM_ID_MACRO_WASTE_SIZE_CATEGORY = null;
-
- @Value("${UnitId.NONE}")
- public final Integer UNIT_ID_NONE = null;
-
- @Value("${UserProfilId.OBSERVER}")
- public final Integer USER_PROFIL_ID_OBSERVER = null;
-
- @Value("${UserProfilId.PROJECT_MEMBER}")
- public final Integer USER_PROFIL_ID_PROJECT_MEMBER = null;
-
- @Value("${UserProfilId.USER}")
- public final Integer USER_PROFIL_ID_USER = null;
-
- @Value("${VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL}")
- public final Integer VESSEL_TYPE_ID_SCIENTIFIC = null;
-
- @Value("${VesselTypeId.FISHING_VESSEL}")
- public final Integer VESSEL_TYPE_ID_FISHING = null;
-
- @Value("${LocationLevelId.RECTANGLE_STATISTIQUE_MED}")
- public final Integer RECTANGLE_STATISTIQUE_MED = null;
-
- @Value("${QualitativeValueId.VRAC}")
- public final Integer QUALITATIVE_VRAC_ID = null;
-
- @Value("${StatusCode.ENABLE}")
- public final String STATUS_VALID_CODE = null;
-
- @Value("${StatusCode.TEMPORARY}")
- public final String STATUS_TEMPORARY_CODE = null;
-
- @Value("${PersonId.UNKNOWN_RECORDER_PERSON}")
- public final Integer PERSON_ID_UNKNOWN_RECORDER_PERSON = null;
-
- @Value("${QualityFlagCode.NOTQUALIFIED}")
- public final String QUALITY_FLAG_CODE_NOT_QUALIFIED = null;
-
- @Value("${PmfmId.STATION_NUMBER}")
- public final Integer PMFM_ID_STATION_NUMBER = null;
-
- @Value("${PmfmId.TRAWL_DISTANCE}")
- public final Integer PMFM_ID_TRAWL_DISTANCE = null;
-
- @Value("${PmfmId.RECTILINEAR_OPERATION}")
- public final Integer PMFM_ID_RECTILINEAR_OPERATION = null;
-
- @Value("${QualitativeValueId.RECTILINEAR_OPERATION_YES}")
- public final Integer QUALITATIVE_RECTILINEAR_OPERATION_YES = null;
-
- @Value("${QualitativeValueId.RECTILINEAR_OPERATION_NO}")
- public final Integer QUALITATIVE_RECTILINEAR_OPERATION_NO = null;
-
- @Value("${PmfmId.HAUL_VALID}")
- public final Integer PMFM_ID_HAUL_VALID = null;
-
- @Value("${QualitativeValueId.HAUL_VALID_YES}")
- public final Integer QUALITATIVE_HAUL_VALID_YES = null;
-
- @Value("${QualitativeValueId.HAUL_VALID_NO}")
- public final Integer QUALITATIVE_HAUL_VALID_NO = null;
-
-
- public void init() {
- Preconditions.checkNotNull(GEAR_CLASSIFICIATION_ID_SCIENTIFIC, "GEAR_CLASSIFICIATION_ID_SCIENTIFIC constant not found");
- Preconditions.checkNotNull(GEAR_CLASSIFICIATION_ID_FISHING, "GEAR_CLASSIFICIATION_ID_FISHING constant not found");
- Preconditions.checkNotNull(LOCATION_LEVEL_ID_COUNTRY, "LOCATION_LEVEL_ID_COUNTRY constant not found");
- Preconditions.checkNotNull(LOCATION_LEVEL_ID_LOCALITE, "LOCATION_LEVEL_ID_LOCALITE constant not found");
- Preconditions.checkNotNull(LOCATION_LEVEL_ID_PROGRAMM, "LOCATION_LEVEL_ID_PROGRAMM constant not found");
- Preconditions.checkNotNull(LOCATION_LEVEL_ID_STRATA, "LOCATION_LEVEL_ID_STRATA constant not found");
- Preconditions.checkNotNull(LOCATION_LEVEL_ID_SUB_STRATA, "LOCATION_LEVEL_ID_SUB_STRATA constant not found");
- Preconditions.checkNotNull(MATRIX_ID_GEAR, "MATRIX_ID_GEAR constant not found");
- Preconditions.checkNotNull(MATRIX_ID_INDIVIDUAL, "MATRIX_ID_INDIVIDUAL constant not found");
- Preconditions.checkNotNull(METHOD_ID_DECLARATION, "METHOD_ID_DECLARATION constant not found");
- Preconditions.checkNotNull(PARAMETER_CODE_AGE, "PARAMETER_CODE_AGE constant not found");
- Preconditions.checkNotNull(PARAMETER_CODE_WEIGHT, "PARAMETER_CODE_WEIGHT constant not found");
- Preconditions.checkNotNull(PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT, "PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT constant not found");
- Preconditions.checkNotNull(PARAMETER_GROUP_HYDROLOGIC, "PARAMETER_GROUP_HYDROLOGIC constant not found");
- Preconditions.checkNotNull(PERSON_ID_UNKNOWN_RECORDER_PERSON, "PERSON_ID_UNKNOWN_RECORDER_PERSON constant not found");
- Preconditions.checkNotNull(PMFM_ID_SIZE_CATEGORY, "PMFM_ID_SIZE_CATEGORY constant not found");
- Preconditions.checkNotNull(PMFM_ID_SEX, "PMFM_ID_SEX constant not found");
- Preconditions.checkNotNull(PMFM_ID_SORTED_UNSORTED, "PMFM_ID_SORTED_UNSORTED constant not found");
- Preconditions.checkNotNull(PMFM_ID_MATURITY, "PMFM_ID_MATURITY constant not found");
- Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_CATEGORY, "PMFM_ID_MACRO_WASTE_CATEGORY constant not found");
- Preconditions.checkNotNull(PMFM_ID_MACRO_WASTE_SIZE_CATEGORY, "PMFM_ID_MACRO_WASTE_SIZE_CATEGORY constant not found");
- Preconditions.checkNotNull(PMFM_ID_STATION_NUMBER, "PMFM_ID_STATION_NUMBER constant not found");
- Preconditions.checkNotNull(PMFM_ID_TRAWL_DISTANCE, "PMFM_ID_TRAWL_DISTANCE constant not found");
- Preconditions.checkNotNull(PMFM_ID_RECTILINEAR_OPERATION, "PMFM_ID_RECTILINEAR_OPERATION constant not found");
- Preconditions.checkNotNull(PMFM_ID_HAUL_VALID, "PMFM_ID_HAUL_VALID constant not found");
- Preconditions.checkNotNull(QUALITY_FLAG_CODE_NOT_QUALIFIED, "QUALITY_FLAG_CODE_NOT_QUALIFIED constant not found");
- Preconditions.checkNotNull(UNIT_ID_NONE, "UNIT_ID_NONE constant not found");
- Preconditions.checkNotNull(USER_PROFIL_ID_OBSERVER, "USER_PROFIL_ID_OBSERVER constant not found");
- Preconditions.checkNotNull(USER_PROFIL_ID_PROJECT_MEMBER, "USER_PROFIL_ID_PROJECT_MEMBER constant not found");
- Preconditions.checkNotNull(USER_PROFIL_ID_USER, "USER_PROFIL_ID_USER constant not found");
- Preconditions.checkNotNull(VESSEL_TYPE_ID_SCIENTIFIC, "VESSEL_TYPE_ID_SCIENTIFIC constant not found");
- Preconditions.checkNotNull(VESSEL_TYPE_ID_FISHING, "VESSEL_TYPE_ID_FISHING constant not found");
- Preconditions.checkNotNull(RECTANGLE_STATISTIQUE_MED, "LocationLevelId.RECTANGLE_STATISTIQUE_MED constant not found");
- Preconditions.checkNotNull(STATUS_VALID_CODE, "StatusCode.ENABLE constant not found");
- Preconditions.checkNotNull(STATUS_TEMPORARY_CODE, "StatusCode.TEMPORARY constant not found");
- Preconditions.checkNotNull(QUALITATIVE_VRAC_ID, "QualitativeValueId.VRAC constant not found");
- Preconditions.checkNotNull(QUALITATIVE_RECTILINEAR_OPERATION_YES, "QualitativeValueId.RECTILINEAR_OPERATION_YES constant not found");
- Preconditions.checkNotNull(QUALITATIVE_RECTILINEAR_OPERATION_NO, "QualitativeValueId.RECTILINEAR_OPERATION_NO constant not found");
- Preconditions.checkNotNull(QUALITATIVE_HAUL_VALID_YES, "QualitativeValueId.HAUL_VALID_YES constant not found");
- Preconditions.checkNotNull(QUALITATIVE_HAUL_VALID_NO, "QualitativeValueId.HAUL_VALID_NO constant not found");
-
- }
-}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -26,7 +26,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao;
-import fr.ifremer.tutti.persistence.TuttiEnumerationFile;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -33,7 +33,6 @@
import fr.ifremer.adagio.core.dao.referential.QualityFlagDao;
import fr.ifremer.adagio.core.dao.referential.location.Location;
import fr.ifremer.adagio.core.dao.referential.location.LocationDao;
-import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao;
import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao;
import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
Copied: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java (from rev 231, trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiEnumerationFile.java)
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java (rev 0)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -0,0 +1,177 @@
+package fr.ifremer.tutti.persistence.service;
+
+/*
+ * #%L
+ * Tutti :: Persistence Adagio (impl)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.ReflectionUtils;
+
+import java.lang.reflect.Field;
+
+/**
+ * Contains all constants usable via the enumeration file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class TuttiEnumerationFile {
+
+ @Value("${GearClassificationId.SCIENTIFIC_CRUISE}")
+ public final Integer GEAR_CLASSIFICIATION_ID_SCIENTIFIC = null;
+
+ @Value("${GearClassificationId.FAO}")
+ public final Integer GEAR_CLASSIFICIATION_ID_FISHING = null;
+
+ @Value("${LocationLevelId.PAYS_ISO3}")
+ public final Integer LOCATION_LEVEL_ID_COUNTRY = null;
+
+ @Value("${LocationLevelId.LOCALITE}")
+ public final Integer LOCATION_LEVEL_ID_LOCALITE = null;
+
+ @Value("${LocationLevelId.PROGRAM}")
+ public final Integer LOCATION_LEVEL_ID_PROGRAMM = null;
+
+ @Value("${LocationLevelId.STRATA}")
+ public final Integer LOCATION_LEVEL_ID_STRATA = null;
+
+ @Value("${LocationLevelId.SUBSTRATA}")
+ public final Integer LOCATION_LEVEL_ID_SUB_STRATA = null;
+
+ @Value("${MatrixId.GEAR}")
+ public final Integer MATRIX_ID_GEAR = null;
+
+ @Value("${MatrixId.INDIVIDUAL}")
+ public final Integer MATRIX_ID_INDIVIDUAL = null;
+
+ @Value("${MethodId.DECLARATION}")
+ public final Integer METHOD_ID_DECLARATION = null;
+
+ @Value("${ParameterCode.AGE}")
+ public final String PARAMETER_CODE_AGE = null;
+
+ @Value("${ParameterCode.WEIGHT}")
+ public final String PARAMETER_CODE_WEIGHT = null;
+
+ @Value("${ParameterGroupId.ENVIRONEMENT_MEASUREMENT}")
+ public final Integer PARAMETER_GROUP_ENVIRONEMENT_MEASUREMENT = null;
+
+ @Value("${ParameterGroupId.HYDROLOGIC_MEASUREMENT}")
+ public final Integer PARAMETER_GROUP_HYDROLOGIC = null;
+
+ @Value("${PmfmId.SIZE_CATEGORY}")
+ public final Integer PMFM_ID_SIZE_CATEGORY = null;
+
+ @Value("${PmfmId.SEX}")
+ public final Integer PMFM_ID_SEX = null;
+
+ @Value("${PmfmId.SORTED_UNSORTED}")
+ public final Integer PMFM_ID_SORTED_UNSORTED = null;
+
+ @Value("${PmfmId.MATURITY}")
+ public final Integer PMFM_ID_MATURITY = null;
+
+ @Value("${PmfmId.MACRO_WASTE_CATEGORY}")
+ public final Integer PMFM_ID_MACRO_WASTE_CATEGORY = null;
+
+ @Value("${PmfmId.MACRO_WASTE_SIZE_CATEGORY}")
+ public final Integer PMFM_ID_MACRO_WASTE_SIZE_CATEGORY = null;
+
+ @Value("${UnitId.NONE}")
+ public final Integer UNIT_ID_NONE = null;
+
+ @Value("${UserProfilId.OBSERVER}")
+ public final Integer USER_PROFIL_ID_OBSERVER = null;
+
+ @Value("${UserProfilId.PROJECT_MEMBER}")
+ public final Integer USER_PROFIL_ID_PROJECT_MEMBER = null;
+
+ @Value("${UserProfilId.USER}")
+ public final Integer USER_PROFIL_ID_USER = null;
+
+ @Value("${VesselTypeId.SCIENTIFIC_RESEARCH_VESSEL}")
+ public final Integer VESSEL_TYPE_ID_SCIENTIFIC = null;
+
+ @Value("${VesselTypeId.FISHING_VESSEL}")
+ public final Integer VESSEL_TYPE_ID_FISHING = null;
+
+ @Value("${LocationLevelId.RECTANGLE_STATISTIQUE_MED}")
+ public final Integer RECTANGLE_STATISTIQUE_MED = null;
+
+ @Value("${QualitativeValueId.VRAC}")
+ public final Integer QUALITATIVE_VRAC_ID = null;
+
+ @Value("${StatusCode.ENABLE}")
+ public final String STATUS_VALID_CODE = null;
+
+ @Value("${StatusCode.TEMPORARY}")
+ public final String STATUS_TEMPORARY_CODE = null;
+
+ @Value("${PersonId.UNKNOWN_RECORDER_PERSON}")
+ public final Integer PERSON_ID_UNKNOWN_RECORDER_PERSON = null;
+
+ @Value("${QualityFlagCode.NOTQUALIFIED}")
+ public final String QUALITY_FLAG_CODE_NOT_QUALIFIED = null;
+
+ @Value("${PmfmId.STATION_NUMBER}")
+ public final Integer PMFM_ID_STATION_NUMBER = null;
+
+ @Value("${PmfmId.TRAWL_DISTANCE}")
+ public final Integer PMFM_ID_TRAWL_DISTANCE = null;
+
+ @Value("${PmfmId.RECTILINEAR_OPERATION}")
+ public final Integer PMFM_ID_RECTILINEAR_OPERATION = null;
+
+ @Value("${QualitativeValueId.RECTILINEAR_OPERATION_YES}")
+ public final Integer QUALITATIVE_RECTILINEAR_OPERATION_YES = null;
+
+ @Value("${QualitativeValueId.RECTILINEAR_OPERATION_NO}")
+ public final Integer QUALITATIVE_RECTILINEAR_OPERATION_NO = null;
+
+ @Value("${PmfmId.HAUL_VALID}")
+ public final Integer PMFM_ID_HAUL_VALID = null;
+
+ @Value("${QualitativeValueId.HAUL_VALID_YES}")
+ public final Integer QUALITATIVE_HAUL_VALID_YES = null;
+
+ @Value("${QualitativeValueId.HAUL_VALID_NO}")
+ public final Integer QUALITATIVE_HAUL_VALID_NO = null;
+
+ public void init() {
+
+ Field[] declaredFields = getClass().getDeclaredFields();
+ for (Field declaredField : declaredFields) {
+ Value annotation = declaredField.getAnnotation(Value.class);
+ if (annotation != null) {
+
+ // check on that field that his value is here
+ Object fieldValue = ReflectionUtils.getField(declaredField, this);
+ Preconditions.checkNotNull(
+ fieldValue,
+ annotation.value() + " constant not found (field " +
+ declaredField.getName() + ")");
+ }
+ }
+ }
+}
Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -35,69 +35,80 @@
*/
public class TuttiPersistenceServiceLocator extends ServiceLocator {
- protected static final TuttiPersistenceServiceLocator INSTANCE =
- new TuttiPersistenceServiceLocator();
+ static {
+ initTuttiDefault();
+ }
- protected TuttiPersistenceServiceLocator() {
- super("beanRefFactory.xml", "TuttiBeanRefFactory");
+ public static void initTuttiDefault() {
+ instance().init("beanRefFactory.xml", "TuttiBeanRefFactory");
}
+ public static void initTutti(String beanFactoryReferenceLocation,
+ String beanRefFactoryReferenceId) {
+ instance().init(beanFactoryReferenceLocation, beanRefFactoryReferenceId);
+ }
+
+ public static TuttiEnumerationFile getTuttiEnumerationFile() {
+ return instance().getService("tuttiEnumerationFile",
+ TuttiEnumerationFile.class);
+ }
+
public static TuttiPersistence getPersistenceService() {
- return INSTANCE.getService("tuttiPersistence",
- TuttiPersistence.class);
+ return instance().getService("tuttiPersistence",
+ TuttiPersistence.class);
}
public static ReferentialPersistenceService getReferentialPersistenceService() {
- return INSTANCE.getService("referentialPersistenceService",
- ReferentialPersistenceService.class);
+ return instance().getService("referentialPersistenceService",
+ ReferentialPersistenceService.class);
}
public static ProgramPersistenceService getProgramPersistenceService() {
- return INSTANCE.getService("programPersistenceService",
- ProgramPersistenceService.class);
+ return instance().getService("programPersistenceService",
+ ProgramPersistenceService.class);
}
public static CruisePersistenceService getCruisePersistenceService() {
- return INSTANCE.getService("cruisePersistenceService",
- CruisePersistenceService.class);
+ return instance().getService("cruisePersistenceService",
+ CruisePersistenceService.class);
}
public static FishingOperationPersistenceService getFishingOperationPersistenceService() {
- return INSTANCE.getService("fishingOperationPersistenceService",
- FishingOperationPersistenceService.class);
+ return instance().getService("fishingOperationPersistenceService",
+ FishingOperationPersistenceService.class);
}
public static SpeciesBatchPersistenceService getSpeciesBatchPersistenceService() {
- return INSTANCE.getService("speciesBatchPersistenceService",
- SpeciesBatchPersistenceService.class);
+ return instance().getService("speciesBatchPersistenceService",
+ SpeciesBatchPersistenceService.class);
}
public static BenthosBatchPersistenceService getBenthosBatchPersistenceService() {
- return INSTANCE.getService("benthosBatchPersistenceService",
- BenthosBatchPersistenceService.class);
+ return instance().getService("benthosBatchPersistenceService",
+ BenthosBatchPersistenceService.class);
}
public static PlanktonBatchPersistenceService getPlanktonBatchPersistenceService() {
- return INSTANCE.getService("planktonBatchPersistenceService",
- PlanktonBatchPersistenceService.class);
+ return instance().getService("planktonBatchPersistenceService",
+ PlanktonBatchPersistenceService.class);
}
public static MacroWasteBatchPersistenceService getMacroWasteBatchPersistenceService() {
- return INSTANCE.getService("macroWasteBatchPersistenceService",
- MacroWasteBatchPersistenceService.class);
+ return instance().getService("macroWasteBatchPersistenceService",
+ MacroWasteBatchPersistenceService.class);
}
public static AccidentalBatchPersistenceService getAccidentalBatchPersistenceService() {
- return INSTANCE.getService("accidentalBatchPersistenceService",
- AccidentalBatchPersistenceService.class);
+ return instance().getService("accidentalBatchPersistenceService",
+ AccidentalBatchPersistenceService.class);
}
public static ProtocolPersistenceService getProtocolPersistenceService() {
- return INSTANCE.getService("protocolPersistenceService",
- ProtocolPersistenceService.class);
+ return instance().getService("protocolPersistenceService",
+ ProtocolPersistenceService.class);
}
public static void close() {
- INSTANCE.shutdown();
+ instance().shutdown();
}
}
Modified: trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/resources/applicationContext-service-tutti.xml 2013-01-19 11:46:29 UTC (rev 234)
@@ -34,7 +34,7 @@
<bean id="tuttiPersistence" init-method="open" destroy-method="close"
class="fr.ifremer.tutti.persistence.TuttiPersistenceAdagioImpl"/>
- <bean init-method="init"
- class="fr.ifremer.tutti.persistence.TuttiEnumerationFile"/>
+ <bean id="tuttiEnumerationFile" init-method="init"
+ class="fr.ifremer.tutti.persistence.service.TuttiEnumerationFile"/>
</beans>
\ No newline at end of file
Modified: trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml
===================================================================
--- trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml 2013-01-19 11:46:29 UTC (rev 234)
@@ -29,8 +29,6 @@
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
- <import resource="classpath:applicationContext-conf.xml"/>
-
<bean id="TuttiBeanRefFactory"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -58,11 +58,24 @@
protected DatabaseFixtures fixtures;
+ private final String beanFactoryReferenceLocation;
+
+ private final String beanRefFactoryReferenceId;
+
+ public DatabaseResource() {
+ this(null, null);
+ }
+
+ public DatabaseResource(String beanFactoryReferenceLocation,
+ String beanRefFactoryReferenceId) {
+ this.beanFactoryReferenceLocation = beanFactoryReferenceLocation;
+ this.beanRefFactoryReferenceId = beanRefFactoryReferenceId;
+ }
+
public TuttiPersistenceAdagioConfig getConfig() {
return config;
}
-
public DatabaseFixtures getFixtures() {
return fixtures;
}
@@ -125,6 +138,12 @@
if (log.isDebugEnabled()) {
log.debug("Use conf.properties at " + config.getDbConfigurationPath());
}
+
+ if (beanFactoryReferenceLocation != null) {
+ TuttiPersistenceServiceLocator.initTutti(
+ beanFactoryReferenceLocation,
+ beanRefFactoryReferenceId);
+ }
}
protected void after(Description description) throws IOException {
@@ -138,6 +157,12 @@
}
TuttiPersistenceServiceLocator.close();
+
+ if (beanFactoryReferenceLocation != null) {
+
+ // push back default tutti configuration
+ TuttiPersistenceServiceLocator.initTuttiDefault();
+ }
}
public static File getTestSpecificDirectory(Class<?> testClass,
Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java
===================================================================
--- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java (rev 0)
+++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -0,0 +1,54 @@
+package fr.ifremer.tutti.persistence.service;
+
+/*
+ * #%L
+ * Tutti :: Persistence Adagio (impl)
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.DatabaseResource;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/**
+ * This test load the {@link TuttiEnumerationFile} via Spring and then
+ * validates that we miss not constant.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @see TuttiEnumerationFile#init()
+ * @since 1.0
+ */
+public class TuttiEnumerationFileTest {
+
+ @ClassRule
+ public static final DatabaseResource dbResource = new DatabaseResource(
+ "beanRefFactoryWitNoDb.xml", "TuttiBeanRefFactoryWithNoDb");
+
+ @Test
+ public void init() {
+
+ TuttiEnumerationFile file =
+ TuttiPersistenceServiceLocator.getTuttiEnumerationFile();
+ Assert.assertNotNull(file);
+ }
+
+}
Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFileTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml
===================================================================
--- trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml (rev 0)
+++ trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml 2013-01-19 11:46:29 UTC (rev 234)
@@ -0,0 +1,37 @@
+<!--
+ #%L
+ Tutti :: Persistence Adagio (impl)
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <!-- needed to load @Value on tuttiEnumerationFile -->
+ <context:annotation-config/>
+
+ <bean id="tuttiEnumerationFile" init-method="init" lazy-init="true"
+ class="fr.ifremer.tutti.persistence.service.TuttiEnumerationFile"/>
+
+</beans>
\ No newline at end of file
Property changes on: trunk/tutti-persistence-adagio/src/test/resources/applicationContext-service-resources.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml (from rev 231, trunk/tutti-persistence-adagio/src/main/resources/beanRefFactory.xml)
===================================================================
--- trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml (rev 0)
+++ trunk/tutti-persistence-adagio/src/test/resources/beanRefFactoryWitNoDb.xml 2013-01-19 11:46:29 UTC (rev 234)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Tutti :: Persistence Adagio (impl)
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <bean id="TuttiBeanRefFactoryWithNoDb"
+ class="org.springframework.context.support.ClassPathXmlApplicationContext">
+ <constructor-arg>
+ <list>
+ <value>applicationContext-conf.xml</value>
+ <value>applicationContext-service-resources.xml</value>
+ </list>
+ </constructor-arg>
+ </bean>
+
+</beans>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.cruise;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/CancelEditCruiseAction.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.program;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/CancelEditProgramAction.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java 2013-01-19 07:26:53 UTC (rev 233)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java 2013-01-19 11:46:29 UTC (rev 234)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.protocol;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/CancelEditProtocolAction.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0