Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
a6cb4f97
by Tony CHEMIT at 2018-09-14T08:09:22Z
24 changed files:
- client/src/main/java/fr/ird/observe/client/ui/content/ObserveFocusManager.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUI.jaxx
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUI.jcss
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUIHandler.java
- + client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookSampleUIModel.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/tree/navigation/nodes/longline/logbook/ActivityLonglineSampleLogbookNavigationTreeNode.java
- client/src/main/resources/i18n/client_en_GB.properties
- client/src/main/resources/i18n/client_es_ES.properties
- client/src/main/resources/i18n/client_fr_FR.properties
- persistence/src/main/java/fr/ird/observe/binder/data/longline/SampleLogbookEntityDtoBinder.java
- persistence/src/main/java/fr/ird/observe/entities/longline/ActivityLonglineLogbookTopiaDao.java
- persistence/src/main/models/Observe-06-data-longline-logbook.model
- server/src/main/filtered-resources/mapping
- services-local/src/main/java/fr/ird/observe/services/local/service/data/longline/ActivityLonglineLogbookSampleServiceLocal.java
- services-local/src/main/java/fr/ird/observe/services/local/service/data/longline/ActivityLonglineLogbookServiceLocal.java
- services-local/src/main/java/fr/ird/observe/services/local/service/data/longline/SetLonglineLogbookCatchServiceLocal.java
- services/src/main/java/fr/ird/observe/services/service/data/longline/ActivityLonglineLogbookSampleService.java
- services/src/main/java/fr/ird/observe/services/service/data/longline/SetLonglineLogbookCatchService.java
- test/src/main/resources/db/8.2/dataForTestLongline.sql.gz
- test/src/main/resources/db/8.2/dataForTestSeine.sql.gz
- test/src/main/resources/db/8.2/empty_h2.sql.gz
- test/src/main/resources/db/8.2/empty_pg.sql.gz
- test/src/main/resources/db/8.2/referentiel.sql.gz
Changes:
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.ui.content.data.longline.GearUseFeaturesLonglineUI; |
| 27 | 27 |
import fr.ird.observe.client.ui.content.data.longline.TripLonglineListUI;
|
| 28 | 28 |
import fr.ird.observe.client.ui.content.data.longline.TripLonglineUI;
|
| 29 | 29 |
import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookListUI;
|
| 30 |
+import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookSampleUI;
|
|
| 30 | 31 |
import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookUI;
|
| 31 | 32 |
import fr.ird.observe.client.ui.content.data.longline.logbook.BaitsCompositionLogbookUI;
|
| 32 | 33 |
import fr.ird.observe.client.ui.content.data.longline.logbook.BranchlinesCompositionLogbookUI;
|
| ... | ... | @@ -387,6 +388,32 @@ public class ObserveFocusManager { |
| 387 | 388 |
|
| 388 | 389 |
});
|
| 389 | 390 |
|
| 391 |
+ builder.put(ActivityLonglineLogbookSampleUI.class, new ObserveLayoutFocusTraversalPolicy<ActivityLonglineLogbookSampleUI>() {
|
|
| 392 |
+ |
|
| 393 |
+ @Override
|
|
| 394 |
+ protected Component getFirstComponentForEdit(Container aContainer) {
|
|
| 395 |
+ ActivityLonglineLogbookSampleUI ui = getUi();
|
|
| 396 |
+ if (ui.getTableModel().isEmpty()) {
|
|
| 397 |
+ return ui.getNewEntry();
|
|
| 398 |
+ }
|
|
| 399 |
+ return ui.getSpecies();
|
|
| 400 |
+ }
|
|
| 401 |
+ |
|
| 402 |
+ @Override
|
|
| 403 |
+ protected Component getLastComponentForEdit(Container aContainer) {
|
|
| 404 |
+ ActivityLonglineLogbookSampleUI ui = getUi();
|
|
| 405 |
+ if (ui.getSave().isEnabled()) {
|
|
| 406 |
+ return ui.getSave();
|
|
| 407 |
+ }
|
|
| 408 |
+ if (ui.getReset().isEnabled()) {
|
|
| 409 |
+ return ui.getReset();
|
|
| 410 |
+ }
|
|
| 411 |
+ return null;
|
|
| 412 |
+ }
|
|
| 413 |
+ |
|
| 414 |
+ });
|
|
| 415 |
+ |
|
| 416 |
+ |
|
| 390 | 417 |
builder.put(LonglineDetailCompositionObsUI.class, new ObserveLayoutFocusTraversalPolicy<LonglineDetailCompositionObsUI>() {
|
| 391 | 418 |
|
| 392 | 419 |
@Override
|
| ... | ... | @@ -8,116 +8,194 @@ |
| 8 | 8 |
it under the terms of the GNU General Public License as
|
| 9 | 9 |
published by the Free Software Foundation, either version 3 of the
|
| 10 | 10 |
License, or (at your option) any later version.
|
| 11 |
+ |
|
| 11 | 12 |
This program is distributed in the hope that it will be useful,
|
| 12 | 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 | 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 | 15 |
GNU General Public License for more details.
|
| 16 |
+ |
|
| 15 | 17 |
You should have received a copy of the GNU General Public
|
| 16 | 18 |
License along with this program. If not, see
|
| 17 | 19 |
<http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 18 | 20 |
#L%
|
| 19 | 21 |
-->
|
| 20 |
-<fr.ird.observe.client.ui.content.ContentUI
|
|
| 21 |
- i18nFormat="observe.common.SampleLogbookDto.%s"
|
|
| 22 |
- superGenericType='SampleLogbookDto, ActivityLonglineLogbookSampleUI'
|
|
| 23 |
- contentTitle='{n("observe.common.SampleLogbookDto.title")}'>
|
|
| 22 |
+ |
|
| 23 |
+<fr.ird.observe.client.ui.content.table.ContentTableUI
|
|
| 24 |
+ i18nFormat="observe.common.SamplePartLogbookDto.%s"
|
|
| 25 |
+ superGenericType='SampleLogbookDto, SamplePartLogbookDto, ActivityLonglineLogbookSampleUI'
|
|
| 26 |
+ contentTitle='{n("observe.common.SampleLogbookDto.title")}'
|
|
| 27 |
+ saveNewEntryText='{n("observe.common.SampleLogbookDto.action.create")}'
|
|
| 28 |
+ saveNewEntryTip='{n("observe.common.SampleLogbookDto.action.create.tip")}'>
|
|
| 24 | 29 |
|
| 25 | 30 |
<style source="../../../Common.jcss"/>
|
| 31 |
+ <style source="../../CommonTable.jcss"/>
|
|
| 26 | 32 |
|
| 27 | 33 |
<import>
|
| 28 |
- fr.ird.observe.dto.data.longline.SampleLogbookDto
|
|
| 34 |
+ fr.ird.observe.dto.referential.SexReference
|
|
| 35 |
+ fr.ird.observe.dto.referential.SizeMeasureTypeReference
|
|
| 36 |
+ fr.ird.observe.dto.referential.LengthMeasureMethodReference
|
|
| 37 |
+ fr.ird.observe.dto.referential.WeightMeasureTypeReference
|
|
| 38 |
+ fr.ird.observe.dto.referential.WeightMeasureMethodReference
|
|
| 39 |
+ fr.ird.observe.dto.referential.SpeciesReference
|
|
| 29 | 40 |
fr.ird.observe.dto.data.longline.SamplePartLogbookDto
|
| 30 |
- fr.ird.observe.dto.referential.DataQualityReference
|
|
| 31 |
- |
|
| 41 |
+ fr.ird.observe.dto.data.longline.SampleLogbookDto
|
|
| 42 |
+ fr.ird.observe.client.constants.AcquisitionMode
|
|
| 43 |
+ fr.ird.observe.client.ui.content.table.*
|
|
| 44 |
+ fr.ird.observe.client.ui.util.JComment
|
|
| 32 | 45 |
fr.ird.observe.client.ui.actions.content.ResetEditUIAction
|
| 33 | 46 |
fr.ird.observe.client.ui.actions.content.SaveEditUIAction
|
| 34 | 47 |
fr.ird.observe.client.ui.actions.main.global.ResetDataGlobalUIAction
|
| 35 | 48 |
fr.ird.observe.client.ui.actions.main.global.SaveDataGlobalUIAction
|
| 36 |
- fr.ird.observe.client.ObserveSwingApplicationContext
|
|
| 37 | 49 |
|
| 38 |
- org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor
|
|
| 39 |
- org.nuiton.jaxx.widgets.datetime.DateTimeEditor
|
|
| 50 |
+ org.nuiton.jaxx.widgets.number.NumberEditor
|
|
| 51 |
+ org.nuiton.jaxx.widgets.select.BeanFilterableComboBox
|
|
| 40 | 52 |
|
| 41 |
- java.util.Collection
|
|
| 53 |
+ java.awt.Dimension
|
|
| 42 | 54 |
|
| 43 | 55 |
static fr.ird.observe.client.ui.util.UIHelper.getStringValue
|
| 44 | 56 |
static org.nuiton.i18n.I18n.n
|
| 45 | 57 |
</import>
|
| 46 | 58 |
|
| 47 | 59 |
<!-- model -->
|
| 48 |
- <SampleLogbookUIModel id='model'/>
|
|
| 60 |
+ <ActivityLonglineLogbookSampleUIModel id='model' constructorParams='this'/>
|
|
| 49 | 61 |
|
| 50 | 62 |
<!-- edit bean -->
|
| 51 | 63 |
<SampleLogbookDto id='bean'/>
|
| 52 | 64 |
|
| 65 |
+ <!-- table edit bean -->
|
|
| 66 |
+ <SamplePartLogbookDto id='tableEditBean'/>
|
|
| 67 |
+ |
|
| 68 |
+ <!-- table model -->
|
|
| 69 |
+ <ContentTableModel id='tableModel'/>
|
|
| 70 |
+ |
|
| 53 | 71 |
<!-- le validateur de l'écran -->
|
| 54 |
- <BeanValidator id='validator' context='update'
|
|
| 55 |
- beanClass='fr.ird.observe.dto.data.longline.SampleLogbookDto'
|
|
| 56 |
- errorTableModel='{getErrorTableModel()}'>
|
|
| 57 |
- <field name='timeStamp' component='timeStamp'/>
|
|
| 58 |
- <field name='longitude' component='coordinates'/>
|
|
| 59 |
- <field name='latitude' component='coordinates'/>
|
|
| 60 |
- <field name='quadrant' component='coordinates'/>
|
|
| 61 |
- <field name='samplePartLogbook' component='samplePartLogbookPanel'/>
|
|
| 72 |
+ <BeanValidator id='validator' beanClass='fr.ird.observe.dto.data.longline.SampleLogbookDto'
|
|
| 73 |
+ errorTableModel='{getErrorTableModel()}' context='update'>
|
|
| 62 | 74 |
</BeanValidator>
|
| 63 | 75 |
|
| 64 |
- <JPanel id="body" layout='{new BorderLayout()}'>
|
|
| 65 |
- <Table insets="0" fill="both" constraints='BorderLayout.CENTER'>
|
|
| 66 |
- <row>
|
|
| 67 |
- <cell weightx="1" weighty="1">
|
|
| 68 |
- |
|
| 69 |
- <JTabbedPane id='mainTabbedPane'>
|
|
| 70 |
- |
|
| 71 |
- <tab id='caracteristicsTab' computeI18n="">
|
|
| 72 |
- |
|
| 73 |
- <JPanel layout='{new BorderLayout()}'>
|
|
| 74 |
- <Table fill='both' constraints='BorderLayout.NORTH' insets="0">
|
|
| 75 |
- |
|
| 76 |
- <!-- timeStamp -->
|
|
| 77 |
- <row>
|
|
| 78 |
- <cell weightx="1">
|
|
| 79 |
- <DateTimeEditor id='timeStamp' constructorParams='this'/>
|
|
| 80 |
- </cell>
|
|
| 81 |
- </row>
|
|
| 82 |
- |
|
| 83 |
- <!-- latitude - longitude - quadrant -->
|
|
| 84 |
- <row>
|
|
| 85 |
- <cell anchor="east">
|
|
| 86 |
- <CoordinatesEditor id='coordinates' constructorParams='this'/>
|
|
| 87 |
- </cell>
|
|
| 88 |
- </row>
|
|
| 89 |
- </Table>
|
|
| 90 |
- </JPanel>
|
|
| 91 |
- </tab>
|
|
| 92 |
- |
|
| 93 |
- <tab id='samplePartLogbookTab' computeI18n="">
|
|
| 94 |
- <JPanel id="samplePartLogbookPanel" layout='{new BorderLayout()}'>
|
|
| 95 |
- <SamplePartLogbookUI id="samplePartLogbookUI" constructorParams="ObserveSwingApplicationContext.get().getMainUI()"/>
|
|
| 96 |
- </JPanel>
|
|
| 97 |
- </tab>
|
|
| 98 |
- </JTabbedPane>
|
|
| 99 |
- </cell>
|
|
| 100 |
- </row>
|
|
| 101 |
- </Table>
|
|
| 102 |
- </JPanel>
|
|
| 103 |
- |
|
| 104 |
- <SamplePartLogbookUIModel id="samplePartLogbookModel" initializer="samplePartLogbookUI.getModel()"/>
|
|
| 105 |
- |
|
| 106 |
- <!-- actions -->
|
|
| 107 |
- <Table id="actions" fill='both' weightx='1' insets='0'>
|
|
| 76 |
+ <!-- le validateur d'une entrée de tableau -->
|
|
| 77 |
+ <BeanValidator id='validatorTable' autoField='true' beanClass='fr.ird.observe.dto.data.longline.SamplePartLogbookDto'
|
|
| 78 |
+ errorTableModel='{getErrorTableModel()}' context='update' parentValidator='{validator}'/>
|
|
| 79 |
+ |
|
| 80 |
+ <ButtonGroup id='acquisitionModeGroup'
|
|
| 81 |
+ onStateChanged='getHandler().updateAcquisitionMode((AcquisitionMode) acquisitionModeGroup.getSelectedValue())'/>
|
|
| 82 |
+ |
|
| 83 |
+ <JLabel id='hideFormInformation' styleClass="skipI18n"/>
|
|
| 84 |
+ |
|
| 85 |
+ <Table id='editorPanel' fill='both' insets='1'>
|
|
| 86 |
+ |
|
| 87 |
+ <!-- mode de saisie -->
|
|
| 108 | 88 |
<row>
|
| 109 |
- <cell columns="2">
|
|
| 110 |
- <JButton id='move'/>
|
|
| 89 |
+ <cell columns="3">
|
|
| 90 |
+ <JPanel id="modeAndCodePanel" layout='{new BorderLayout()}'>
|
|
| 91 |
+ <JPanel id='acquisitionModePanel' constraints="BorderLayout.CENTER" layout="{new GridLayout(0, 1)}">
|
|
| 92 |
+ <JRadioButton id='acquisitionModeEffectif'/>
|
|
| 93 |
+ <JRadioButton id='acquisitionModeIndividu'/>
|
|
| 94 |
+ </JPanel>
|
|
| 95 |
+ <Table id='sizeMeasureTypePanel' fill='both' insets='1' constraints="BorderLayout.EAST">
|
|
| 96 |
+ <row>
|
|
| 97 |
+ <cell>
|
|
| 98 |
+ <JLabel id='speciesLabel' styleClass="i18n"/>
|
|
| 99 |
+ </cell>
|
|
| 100 |
+ <cell weightx='1' anchor='east'>
|
|
| 101 |
+ <BeanFilterableComboBox id='species' genericType='SpeciesReference' constructorParams='this'/>
|
|
| 102 |
+ </cell>
|
|
| 103 |
+ </row>
|
|
| 104 |
+ <row>
|
|
| 105 |
+ <cell>
|
|
| 106 |
+ <JLabel id='sizeMeasureTypeLabel' styleClass="i18n"/>
|
|
| 107 |
+ </cell>
|
|
| 108 |
+ <cell>
|
|
| 109 |
+ <JPanel layout='{new BorderLayout()}'>
|
|
| 110 |
+ <BeanFilterableComboBox id='sizeMeasureType' genericType='SizeMeasureTypeReference'
|
|
| 111 |
+ constructorParams='this' constraints="BorderLayout.CENTER"/>
|
|
| 112 |
+ <JButton id="defaultSizeMeasureType" constraints="BorderLayout.EAST"
|
|
| 113 |
+ onActionPerformed="getHandler().resetDefaultSizeMeasureType()"/>
|
|
| 114 |
+ </JPanel>
|
|
| 115 |
+ </cell>
|
|
| 116 |
+ </row>
|
|
| 117 |
+ </Table>
|
|
| 118 |
+ </JPanel>
|
|
| 111 | 119 |
</cell>
|
| 112 | 120 |
</row>
|
| 121 |
+ |
|
| 122 |
+ <!-- count -->
|
|
| 123 |
+ <row>
|
|
| 124 |
+ <cell>
|
|
| 125 |
+ <JLabel id='countLabel'/>
|
|
| 126 |
+ </cell>
|
|
| 127 |
+ <cell weightx='1' anchor='east'>
|
|
| 128 |
+ <NumberEditor id='count' constructorParams='this' styleClass="int6"/>
|
|
| 129 |
+ </cell>
|
|
| 130 |
+ </row>
|
|
| 131 |
+ |
|
| 132 |
+ <!-- length -->
|
|
| 113 | 133 |
<row>
|
| 114 |
- <cell weightx="0.5">
|
|
| 115 |
- <JButton id='reset'/>
|
|
| 134 |
+ <cell>
|
|
| 135 |
+ <JLabel id='lengthLabel'/>
|
|
| 116 | 136 |
</cell>
|
| 117 |
- <cell weightx="0.5">
|
|
| 118 |
- <JButton id='save'/>
|
|
| 137 |
+ <cell weightx='1' anchor='east'>
|
|
| 138 |
+ <NumberEditor id='length' constructorParams='this' styleClass="float1"/>
|
|
| 119 | 139 |
</cell>
|
| 120 | 140 |
</row>
|
| 141 |
+ |
|
| 142 |
+ <!-- sizeMeasureMethod -->
|
|
| 143 |
+ <row>
|
|
| 144 |
+ <cell>
|
|
| 145 |
+ <JLabel id='lengthMeasureMethodLabel'/>
|
|
| 146 |
+ </cell>
|
|
| 147 |
+ <cell weightx='1' anchor='east'>
|
|
| 148 |
+ <BeanFilterableComboBox id='lengthMeasureMethod' constructorParams='this' genericType='LengthMeasureMethodReference'/>
|
|
| 149 |
+ </cell>
|
|
| 150 |
+ </row>
|
|
| 151 |
+ |
|
| 152 |
+ <!-- weightMeasureType -->
|
|
| 153 |
+ <row>
|
|
| 154 |
+ <cell>
|
|
| 155 |
+ <JLabel id='weightMeasureTypeLabel'/>
|
|
| 156 |
+ </cell>
|
|
| 157 |
+ <cell weightx='1' anchor='east'>
|
|
| 158 |
+ <BeanFilterableComboBox id='weightMeasureType' constructorParams='this' genericType='WeightMeasureTypeReference'/>
|
|
| 159 |
+ </cell>
|
|
| 160 |
+ </row>
|
|
| 161 |
+ <!-- weightMeasureMethod -->
|
|
| 162 |
+ <row>
|
|
| 163 |
+ <cell>
|
|
| 164 |
+ <JLabel id='weightMeasureMethodLabel'/>
|
|
| 165 |
+ </cell>
|
|
| 166 |
+ <cell weightx='1' anchor='east'>
|
|
| 167 |
+ <BeanFilterableComboBox id='weightMeasureMethod' constructorParams='this' genericType='WeightMeasureMethodReference'/>
|
|
| 168 |
+ </cell>
|
|
| 169 |
+ </row>
|
|
| 170 |
+ |
|
| 171 |
+ <!-- weight -->
|
|
| 172 |
+ <row>
|
|
| 173 |
+ <cell>
|
|
| 174 |
+ <JLabel id='weightLabel'/>
|
|
| 175 |
+ </cell>
|
|
| 176 |
+ <cell weightx='1' anchor='east'>
|
|
| 177 |
+ <NumberEditor id='weight' constructorParams='this' styleClass="float2"/>
|
|
| 178 |
+ </cell>
|
|
| 179 |
+ </row>
|
|
| 180 |
+ |
|
| 181 |
+ <!-- sex -->
|
|
| 182 |
+ <row>
|
|
| 183 |
+ <cell>
|
|
| 184 |
+ <JLabel id='sexLabel'/>
|
|
| 185 |
+ </cell>
|
|
| 186 |
+ <cell weightx='1' anchor='east'>
|
|
| 187 |
+ <BeanFilterableComboBox id='sex' genericType='SexReference' constructorParams='this'/>
|
|
| 188 |
+ </cell>
|
|
| 189 |
+ </row>
|
|
| 190 |
+ |
|
| 121 | 191 |
</Table>
|
| 122 | 192 |
|
| 123 |
-</fr.ird.observe.client.ui.content.ContentUI>
|
|
| 193 |
+ <!--FIXME Voir comment juste ajouter des actions à la table parent-->
|
|
| 194 |
+ <Table id="actions" fill='both' weightx='1' insets='0'>
|
|
| 195 |
+ <row>
|
|
| 196 |
+ <cell columns="2">
|
|
| 197 |
+ <JButton id='move'/>
|
|
| 198 |
+ </cell>
|
|
| 199 |
+ </row>
|
|
| 200 |
+ </Table>
|
|
| 201 |
+</fr.ird.observe.client.ui.content.table.ContentTableUI>
|
| ... | ... | @@ -20,56 +20,84 @@ |
| 20 | 20 |
* #L%
|
| 21 | 21 |
*/
|
| 22 | 22 |
|
| 23 |
-#model {
|
|
| 24 |
- editable:true;
|
|
| 25 |
- modified:{validator.isChanged() || samplePartLogbookModel.isModified()};
|
|
| 26 |
- valid:{validator.isValid() && samplePartLogbookModel.isValid()};
|
|
| 27 |
- enabled:{!model.isReadingMode()};
|
|
| 23 |
+#species {
|
|
| 24 |
+ selectedItem:{tableEditBean.getSpecies()};
|
|
| 28 | 25 |
}
|
| 29 | 26 |
|
| 30 |
-/* ***************************************************************************** */
|
|
| 31 |
-/* CARACTERISTICS TAB ********************************************************* */
|
|
| 32 |
-/* ***************************************************************************** */
|
|
| 27 |
+#lengthMeasureMethod {
|
|
| 28 |
+ selectedItem:{tableEditBean.getLengthMeasureMethod()};
|
|
| 29 |
+}
|
|
| 30 |
+ |
|
| 31 |
+#weightMeasureType {
|
|
| 32 |
+ selectedItem:{tableEditBean.getWeightMeasureType()};
|
|
| 33 |
+}
|
|
| 34 |
+ |
|
| 35 |
+#weightMeasureMethod {
|
|
| 36 |
+ selectedItem:{tableEditBean.getWeightMeasureMethod()};
|
|
| 37 |
+}
|
|
| 38 |
+ |
|
| 39 |
+#sex {
|
|
| 40 |
+ selectedItem:{tableEditBean.getSex()};
|
|
| 41 |
+}
|
|
| 33 | 42 |
|
| 34 |
-#caracteristicsTab {
|
|
| 35 |
- icon:{handler.getErrorIconIfFalse(model.isCaracteristicsTabValid())};
|
|
| 43 |
+#count {
|
|
| 44 |
+ property:{SamplePartLogbookDto.PROPERTY_COUNT};
|
|
| 45 |
+ numberValue:{tableEditBean.getCount()};
|
|
| 36 | 46 |
}
|
| 37 | 47 |
|
| 38 |
-#timeStamp {
|
|
| 39 |
- date:{bean.getTimeStamp()};
|
|
| 40 |
- propertyDate: {SampleLogbookDto.PROPERTY_TIME_STAMP};
|
|
| 41 |
- propertyDayDate: {SampleLogbookDto.PROPERTY_DATE};
|
|
| 42 |
- propertyTimeDate: {SampleLogbookDto.PROPERTY_TIME};
|
|
| 48 |
+#length {
|
|
| 49 |
+ numberValue:{tableEditBean.getLength()};
|
|
| 43 | 50 |
}
|
| 44 | 51 |
|
| 45 |
-#coordinates {
|
|
| 46 |
- propertyLatitude:{SampleLogbookDto.PROPERTY_LATITUDE};
|
|
| 47 |
- propertyLongitude:{SampleLogbookDto.PROPERTY_LONGITUDE};
|
|
| 48 |
- propertyQuadrant:{SampleLogbookDto.PROPERTY_QUADRANT};
|
|
| 49 |
- latitude:{bean.getLatitude()};
|
|
| 50 |
- longitude:{bean.getLongitude()};
|
|
| 51 |
- quadrant:{bean.getQuadrant()};
|
|
| 52 |
+#weight {
|
|
| 53 |
+ numberValue:{tableEditBean.getWeight()};
|
|
| 52 | 54 |
}
|
| 53 | 55 |
|
| 54 |
-/* ***************************************************************************** */
|
|
| 55 |
-/* SAMPLE PART TAB ************************************************************ */
|
|
| 56 |
-/* ***************************************************************************** */
|
|
| 56 |
+#acquisitionModeGroup {
|
|
| 57 |
+ selectedValue:{AcquisitionMode.valueOf(tableEditBean.getAcquisitionMode())};
|
|
| 58 |
+}
|
|
| 59 |
+ |
|
| 60 |
+#acquisitionModePanel {
|
|
| 61 |
+ border:{new TitledBorder(t("observe.common.acquisitionMode"))};
|
|
| 62 |
+}
|
|
| 63 |
+ |
|
| 64 |
+#acquisitionModeEffectif {
|
|
| 65 |
+ buttonGroup:"acquisitionModeGroup";
|
|
| 66 |
+ value:{AcquisitionMode.byEffectif};
|
|
| 67 |
+ text:{AcquisitionMode.byEffectif.toString()};
|
|
| 68 |
+ selected:{tableEditBean.getAcquisitionMode() == 0};
|
|
| 69 |
+ enabled:{!tableModel.isEditable() || tableModel.isCreate()};
|
|
| 70 |
+}
|
|
| 71 |
+ |
|
| 72 |
+#acquisitionModeIndividu {
|
|
| 73 |
+ buttonGroup:"acquisitionModeGroup";
|
|
| 74 |
+ value:{AcquisitionMode.byIndividu};
|
|
| 75 |
+ text:{AcquisitionMode.byIndividu.toString()};
|
|
| 76 |
+ selected:{tableEditBean.getAcquisitionMode() == 1};
|
|
| 77 |
+ enabled:{!tableModel.isEditable() || tableModel.isCreate()};
|
|
| 78 |
+}
|
|
| 57 | 79 |
|
| 58 |
-#samplePartLogbookTab {
|
|
| 59 |
- icon:{handler.getErrorIconIfFalse(model.isSamplePartLogbookTabValid())};
|
|
| 80 |
+#sizeMeasureTypePanel {
|
|
| 81 |
+ border:{new TitledBorder(t("observe.common.speciesAndSizeMeasure"))};
|
|
| 60 | 82 |
}
|
| 61 | 83 |
|
| 62 |
-#save {
|
|
| 63 |
- _globalAction:{SaveDataGlobalUIAction.ACTION_NAME};
|
|
| 84 |
+#sizeMeasureType {
|
|
| 85 |
+ property:sizeMeasureType;
|
|
| 86 |
+ _tablePropertyName:{"sizeMeasureType"};
|
|
| 87 |
+ selectedItem:{tableEditBean.getSizeMeasureType()};
|
|
| 88 |
+ enabled:{tableEditBean.getSpecies() != null};
|
|
| 64 | 89 |
}
|
| 65 | 90 |
|
| 66 |
-#reset {
|
|
| 67 |
- _globalAction:{ResetDataGlobalUIAction.ACTION_NAME};
|
|
| 91 |
+#defaultSizeMeasureType {
|
|
| 92 |
+ actionIcon:combobox-reset2;
|
|
| 93 |
+ toolTipText:"observe.common.Sample.action.resetDefaultSizeMeasureType.tip";
|
|
| 94 |
+ enabled:{model.getDefaultSizeMeasureType() != null};
|
|
| 68 | 95 |
}
|
| 69 | 96 |
|
| 70 | 97 |
#move {
|
| 71 | 98 |
text:"observe.common.SampleLogbookDto.move";
|
| 72 | 99 |
actionIcon:"move-activities";
|
| 73 | 100 |
mnemonic:A;
|
| 74 |
- enabled:{model.isUpdatingMode() && model.isValid() && !model.isModified()};
|
|
| 101 |
+ visible:{model.isUpdatingMode()};
|
|
| 102 |
+ enabled:{model.isValid() && !model.isModified()};
|
|
| 75 | 103 |
}
|
| ... | ... | @@ -10,23 +10,25 @@ package fr.ird.observe.client.ui.content.data.longline.logbook; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.Lists;
|
|
| 25 | 26 |
import fr.ird.observe.client.ObserveSwingApplicationContext;
|
| 26 |
-import fr.ird.observe.client.db.ObserveSwingDataSource;
|
|
| 27 |
+import fr.ird.observe.client.constants.AcquisitionMode;
|
|
| 27 | 28 |
import fr.ird.observe.client.ui.content.ContentMode;
|
| 28 |
-import fr.ird.observe.client.ui.content.ContentUIHandler;
|
|
| 29 |
-import fr.ird.observe.client.validation.ClientValidationContext;
|
|
| 29 |
+import fr.ird.observe.client.ui.content.table.ContentTableModel;
|
|
| 30 |
+import fr.ird.observe.client.ui.content.table.ContentTableUIHandler;
|
|
| 31 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 30 | 32 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookDto;
|
| 31 | 33 |
import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
| 32 | 34 |
import fr.ird.observe.dto.data.longline.SampleLogbookHelper;
|
| ... | ... | @@ -34,22 +36,30 @@ import fr.ird.observe.dto.data.longline.SamplePartLogbookDto; |
| 34 | 36 |
import fr.ird.observe.dto.form.Form;
|
| 35 | 37 |
import fr.ird.observe.dto.form.FormDefinition;
|
| 36 | 38 |
import fr.ird.observe.dto.navigation.edit.node.ObserveLonglineLogbookActivityEditNode;
|
| 37 |
-import fr.ird.observe.dto.navigation.select.node.ObserveLonglineLogbookActivitySampleSelectNode;
|
|
| 39 |
+import fr.ird.observe.dto.navigation.select.node.ObserveLonglineLogbookActivitySelectNode;
|
|
| 40 |
+import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
|
| 41 |
+import fr.ird.observe.dto.referential.SexReference;
|
|
| 42 |
+import fr.ird.observe.dto.referential.SizeMeasureTypeReference;
|
|
| 43 |
+import fr.ird.observe.dto.referential.SpeciesReference;
|
|
| 44 |
+import fr.ird.observe.dto.referential.WeightMeasureTypeReference;
|
|
| 38 | 45 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 39 | 46 |
import fr.ird.observe.spi.DtoModelHelper;
|
| 40 |
-import org.apache.logging.log4j.Logger;
|
|
| 41 | 47 |
import org.apache.logging.log4j.LogManager;
|
| 48 |
+import org.apache.logging.log4j.Logger;
|
|
| 42 | 49 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 43 |
-import org.nuiton.jaxx.validator.swing.SwingValidatorMessage;
|
|
| 44 |
-import org.nuiton.jaxx.validator.swing.SwingValidatorMessageTableModel;
|
|
| 45 | 50 |
import org.nuiton.validator.NuitonValidatorScope;
|
| 46 | 51 |
|
| 47 |
-import javax.swing.event.TableModelListener;
|
|
| 48 |
-import java.util.Date;
|
|
| 49 |
-import java.util.HashSet;
|
|
| 52 |
+import javax.swing.JComponent;
|
|
| 53 |
+import javax.swing.JTable;
|
|
| 54 |
+import javax.swing.table.DefaultTableCellRenderer;
|
|
| 55 |
+import java.awt.GridBagConstraints;
|
|
| 56 |
+import java.awt.Insets;
|
|
| 57 |
+import java.beans.PropertyChangeListener;
|
|
| 58 |
+import java.util.LinkedList;
|
|
| 59 |
+import java.util.List;
|
|
| 50 | 60 |
import java.util.Optional;
|
| 51 |
-import java.util.Set;
|
|
| 52 | 61 |
|
| 62 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 53 | 63 |
import static org.nuiton.i18n.I18n.t;
|
| 54 | 64 |
|
| 55 | 65 |
/**
|
| ... | ... | @@ -58,214 +68,239 @@ import static org.nuiton.i18n.I18n.t; |
| 58 | 68 |
* @author Tony Chemit - dev@tchemit.fr
|
| 59 | 69 |
* @since 3.8
|
| 60 | 70 |
*/
|
| 61 |
-public class ActivityLonglineLogbookSampleUIHandler extends ContentUIHandler<SampleLogbookDto, ActivityLonglineLogbookSampleUI> implements UIHandler<ActivityLonglineLogbookSampleUI> {
|
|
| 71 |
+public class ActivityLonglineLogbookSampleUIHandler extends ContentTableUIHandler<SampleLogbookDto, SamplePartLogbookDto, ActivityLonglineLogbookSampleUI> implements UIHandler<ActivityLonglineLogbookSampleUI> {
|
|
| 62 | 72 |
|
| 63 |
- private static final Logger log = LogManager.getLogger(ActivityLonglineLogbookSampleUIHandler.class);
|
|
| 64 |
- protected final TableModelListener computeTabValidStateListener;
|
|
| 73 |
+ private static final Logger log = LogManager.getLogger(SamplePartLogbookUIHandler.class);
|
|
| 74 |
+ private final PropertyChangeListener speciesChanged;
|
|
| 65 | 75 |
|
| 66 | 76 |
ActivityLonglineLogbookSampleUIHandler() {
|
| 67 |
- super(ObserveLonglineLogbookActivitySampleSelectNode.class, ObserveLonglineLogbookActivityEditNode.class);
|
|
| 68 |
- computeTabValidStateListener = e -> {
|
|
| 69 |
- SwingValidatorMessageTableModel source = (SwingValidatorMessageTableModel) e.getSource();
|
|
| 70 |
- computeTabValidState(source);
|
|
| 71 |
- };
|
|
| 72 |
- }
|
|
| 73 |
- |
|
| 74 |
- @Override
|
|
| 75 |
- protected void installFocusTraversalPolicy() {
|
|
| 76 |
- // rien a installer
|
|
| 77 |
- }
|
|
| 77 |
+ super(ObserveLonglineLogbookActivitySelectNode.class, ObserveLonglineLogbookActivityEditNode.class);
|
|
| 78 |
+ addReferentialFilter(SamplePartLogbookDto.PROPERTY_SPECIES, incomingReferences -> {
|
|
| 79 |
+ String setId = ObserveSwingApplicationContext.get().getNavigationEdit().getLongline().getSetLogbook().getId();
|
|
| 80 |
+ if (setId == null) {
|
|
| 81 |
+ return new LinkedList<>();
|
|
| 82 |
+ }
|
|
| 83 |
+ ReferentialDtoReferenceSet<SpeciesReference> sampleSpecies = getSetLonglineLogbookCatchService().getSampleSpecies(setId);
|
|
| 84 |
+ return new LinkedList<>(sampleSpecies.toSet());
|
|
| 85 |
+ });
|
|
| 78 | 86 |
|
| 79 |
- @Override
|
|
| 80 |
- protected boolean computeCanWrite(ObserveSwingDataSource dataSource) {
|
|
| 81 |
- return dataSource.canWriteData();
|
|
| 87 |
+ speciesChanged = evt -> onSpeciesChanged((SpeciesReference) evt.getNewValue());
|
|
| 82 | 88 |
}
|
| 83 | 89 |
|
| 84 | 90 |
@Override
|
| 85 | 91 |
protected ContentMode getContentMode() {
|
| 86 |
- String selectedId = getSelectedId();
|
|
| 87 |
- if (selectedId == null) {
|
|
| 88 |
- return ContentMode.CREATE;
|
|
| 89 |
- }
|
|
| 90 |
- if (selectedId.equals(getEditNode().getId())) {
|
|
| 91 |
- return ContentMode.UPDATE;
|
|
| 92 |
+ ContentMode contentMode = super.getContentMode();
|
|
| 93 |
+ if (ContentMode.READ == contentMode) {
|
|
| 94 |
+ addMessage(getUi(),
|
|
| 95 |
+ NuitonValidatorScope.INFO,
|
|
| 96 |
+ getTypeI18nKey(ActivityLonglineLogbookDto.class),
|
|
| 97 |
+ t("observe.common.ActivityLonglineObsDto.message.not.open"));
|
|
| 92 | 98 |
}
|
| 93 |
- addMessage(getUi(),
|
|
| 94 |
- NuitonValidatorScope.INFO,
|
|
| 95 |
- getTypeI18nKey(ActivityLonglineLogbookDto.class),
|
|
| 96 |
- t("observe.common.ActivityLonglineLogbookDto.message.not.open"));
|
|
| 97 |
- return ContentMode.READ;
|
|
| 99 |
+ return contentMode;
|
|
| 98 | 100 |
}
|
| 99 | 101 |
|
| 102 |
+ @SuppressWarnings("unchecked")
|
|
| 100 | 103 |
@Override
|
| 101 |
- public void afterInit(ActivityLonglineLogbookSampleUI ui) {
|
|
| 102 |
- super.afterInit(ui);
|
|
| 103 |
- {
|
|
| 104 |
- // init floatlinesComposition tab
|
|
| 105 |
- SamplePartLogbookUI compositionUI = ui.getSamplePartLogbookUI();
|
|
| 106 |
- ui.getSamplePartLogbookPanel().remove(compositionUI);
|
|
| 107 |
- ui.getSamplePartLogbookPanel().add(compositionUI.getBody());
|
|
| 108 |
- }
|
|
| 109 |
- getModel().addPropertyChangeListener(SampleLogbookUIModel.PROPERTY_MODE, evt -> {
|
|
| 110 |
- showIndividualTabs(evt.getNewValue() != ContentMode.CREATE);
|
|
| 111 |
- });
|
|
| 112 |
- }
|
|
| 104 |
+ protected void onSelectedRowChanged(int editingRow,
|
|
| 105 |
+ SamplePartLogbookDto bean,
|
|
| 106 |
+ boolean create) {
|
|
| 107 |
+ ContentTableModel<SampleLogbookDto, SamplePartLogbookDto> model = getTableModel();
|
|
| 113 | 108 |
|
| 114 |
- @Override
|
|
| 115 |
- public void openUI() {
|
|
| 116 |
- |
|
| 117 |
- getUi().getCoordinates().resetModel();
|
|
| 118 |
- |
|
| 119 |
- super.openUI();
|
|
| 120 |
- |
|
| 121 |
- String activityId = getSelectedParentId();
|
|
| 122 |
- String setId = getSelectedId();
|
|
| 123 |
- |
|
| 124 |
- if (log.isInfoEnabled()) {
|
|
| 125 |
- log.info("tripId = " + activityId);
|
|
| 126 |
- log.info("setId = " + setId);
|
|
| 109 |
+ if (!model.isEditable()) {
|
|
| 110 |
+ return;
|
|
| 127 | 111 |
}
|
| 128 |
- ContentMode mode = computeContentMode();
|
|
| 129 | 112 |
|
| 130 |
- // update mode
|
|
| 131 |
- Form<SampleLogbookDto> form;
|
|
| 132 |
- if (setId == null) {
|
|
| 133 |
- // create mode
|
|
| 134 |
- form = getTripLonglineSampleLogbookService().preCreate(activityId);
|
|
| 135 |
- } else {
|
|
| 136 |
- // update mode
|
|
| 137 |
- form = getTripLonglineSampleLogbookService().loadForm(setId);
|
|
| 138 |
- }
|
|
| 139 |
- |
|
| 140 |
- loadReferentialReferenceSetsInModel(form);
|
|
| 113 |
+ SamplePartLogbookDto tableEditBean = getTableEditBean();
|
|
| 114 |
+ tableEditBean.removePropertyChangeListener(SamplePartLogbookDto.PROPERTY_SPECIES, speciesChanged);
|
|
| 141 | 115 |
|
| 142 |
- getModel().setForm(form);
|
|
| 143 |
- SampleLogbookHelper.copySampleLogbookDto(form.getObject(), getBean());
|
|
| 116 |
+ SpeciesReference species = bean.getSpecies();
|
|
| 117 |
+ ActivityLonglineLogbookSampleUI ui = getUi();
|
|
| 118 |
+ if (log.isDebugEnabled()) {
|
|
| 119 |
+ log.debug("selected species " + species);
|
|
| 120 |
+ }
|
|
| 121 |
+ List<SpeciesReference> availableSpecies;
|
|
| 122 |
+ JComponent requestFocus;
|
|
| 123 |
+ Optional<SizeMeasureTypeReference> sizeMeasureType = getSpeciesDefaultSizeMeasureType(species);
|
|
| 124 |
+ getUi().getModel().setDefaultSizeMeasureType(sizeMeasureType.orElse(null));
|
|
| 144 | 125 |
|
| 145 |
- SampleLogbookDto bean = getBean();
|
|
| 146 |
- bean.setTimeStamp(new Date());
|
|
| 126 |
+ if (create) {
|
|
| 147 | 127 |
|
| 148 |
- // utilisation du mode requis
|
|
| 149 |
- setContentMode(mode);
|
|
| 128 |
+ if (model.isCreate()) {
|
|
| 150 | 129 |
|
| 130 |
+ // on passe le mode de saisie en count
|
|
| 131 |
+ ui.getAcquisitionModeGroup().setSelectedValue(null);
|
|
| 132 |
+ ui.getAcquisitionModeGroup().setSelectedValue(AcquisitionMode.byEffectif);
|
|
| 133 |
+ }
|
|
| 151 | 134 |
|
| 152 |
- // 1. Mise à jour latitude/longitude:
|
|
| 153 |
- getUi().getCoordinates().setLatitudeAndLongitude(bean.getLatitude(), bean.getLongitude());
|
|
| 154 |
- // 2. Mise à jour du quadrant :
|
|
| 155 |
- // Si le bean de données contient un quadrant, on met simplement à jour le composant de coordonnées pour sélectionner le quadrant voulu
|
|
| 156 |
- // sinon, on réinitialise les quadrants du composant afin qu'aucun d'eux ne soit sélectionné (par exemple dans le cas de la création de la première activité d'une route)
|
|
| 157 |
- if (bean.getQuadrant() == null) {
|
|
| 158 |
- getUi().getCoordinates().resetQuadrant();
|
|
| 135 |
+ availableSpecies = getModel().getReferentialReferences(SamplePartLogbookDto.PROPERTY_SPECIES);
|
|
| 136 |
+ requestFocus = ui.getSpecies();
|
|
| 159 | 137 |
} else {
|
| 160 |
- getUi().getCoordinates().setQuadrant(bean.getQuadrant());
|
|
| 161 |
- }
|
|
| 162 |
- |
|
| 163 |
- {
|
|
| 164 |
- // open floatlinesComposition tab
|
|
| 165 |
- SamplePartLogbookUIModel floatlinesCompositionModel = getUi().getSamplePartLogbookModel();
|
|
| 166 |
- floatlinesCompositionModel.setReferentialReferenceSets(getModel().getReferentialReferenceSets());
|
|
| 167 | 138 |
|
| 168 |
- Optional<FormDefinition<SamplePartLogbookDto>> optionalFormDefinition = DtoModelHelper.getOptionalFormDefinition(SamplePartLogbookDto.class);
|
|
| 169 |
- optionalFormDefinition.ifPresent(getUi().getSamplePartLogbookUI().getHandler()::loadReferentialReferenceSetsInModel);
|
|
| 139 |
+ requestFocus = ui.getCount();
|
|
| 170 | 140 |
|
| 171 |
- floatlinesCompositionModel.setForm(form);
|
|
| 172 |
- SampleLogbookHelper.copySampleLogbookDto(form.getObject(), floatlinesCompositionModel.getBean());
|
|
| 141 |
+ // on passe le mode de saisie
|
|
| 142 |
+ int acquisitionMode = bean.getAcquisitionMode();
|
|
| 143 |
+ AcquisitionMode enumValue = AcquisitionMode.valueOf(acquisitionMode);
|
|
| 144 |
+ ui.getAcquisitionModeGroup().setSelectedValue(null);
|
|
| 145 |
+ ui.getAcquisitionModeGroup().setSelectedValue(enumValue);
|
|
| 173 | 146 |
|
| 174 |
- SamplePartLogbookUI compositionUI = getUi().getSamplePartLogbookUI();
|
|
| 175 |
- compositionUI.open();
|
|
| 176 |
- compositionUI.getValidator().setBean(null);
|
|
| 147 |
+ availableSpecies = Lists.newArrayList(species);
|
|
| 148 |
+ sizeMeasureType = Optional.ofNullable(bean.getSizeMeasureType());
|
|
| 177 | 149 |
|
| 178 | 150 |
}
|
| 179 |
- if (mode != ContentMode.READ) {
|
|
| 180 |
- getUi().startEdit(null);
|
|
| 181 |
- }
|
|
| 182 | 151 |
|
| 183 |
- // To be sure always remove listener (could prevent some leaks)
|
|
| 184 |
- getUi().getErrorTableModel().removeTableModelListener(computeTabValidStateListener);
|
|
| 185 |
- // listen messages to see if required to add
|
|
| 186 |
- getUi().getErrorTableModel().addTableModelListener(computeTabValidStateListener);
|
|
| 152 |
+ ui.getSizeMeasureType().setSelectedItem(null);
|
|
| 153 |
+ sizeMeasureType.ifPresent(sizeMeasureTypeDtoReferentialReference -> ui.getSizeMeasureType().setSelectedItem(sizeMeasureTypeDtoReferentialReference));
|
|
| 154 |
+ |
|
| 155 |
+ ui.getSpecies().setData(availableSpecies);
|
|
| 156 |
+ UIHelper.askFocus(requestFocus);
|
|
| 187 | 157 |
|
| 188 |
- SwingValidatorMessageTableModel errorTableModel = getUi().getErrorTableModel();
|
|
| 189 |
- computeTabValidState(errorTableModel);
|
|
| 158 |
+ tableEditBean.addPropertyChangeListener(SamplePartLogbookDto.PROPERTY_SPECIES, speciesChanged);
|
|
| 190 | 159 |
|
| 191 | 160 |
}
|
| 192 | 161 |
|
| 193 | 162 |
@Override
|
| 194 |
- protected void prepareValidationContext() {
|
|
| 195 |
- super.prepareValidationContext();
|
|
| 196 |
- ClientValidationContext validationContext = ObserveSwingApplicationContext.get().getValidationContext();
|
|
| 197 |
- validationContext.setCoordinatesEditor("coordinate", getUi().getCoordinates());
|
|
| 163 |
+ public void afterInit(ActivityLonglineLogbookSampleUI ui) {
|
|
| 164 |
+ super.afterInit(ui);
|
|
| 165 |
+ getUi().getActions().add(getUi().getReset(), new GridBagConstraints(0, 1, 1, 1, 0.5, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
|
|
| 166 |
+ getUi().getActions().add(getUi().getSave(), new GridBagConstraints(1, 1, 1, 1, 0.5, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
|
|
| 198 | 167 |
}
|
| 199 | 168 |
|
| 200 |
- |
|
| 201 | 169 |
@Override
|
| 202 |
- public void startEditUI(String... binding) {
|
|
| 203 |
- SampleLogbookUIModel model = getModel();
|
|
| 204 |
- boolean create = model.getMode() == ContentMode.CREATE;
|
|
| 205 |
- String contextName = getValidatorContextName(model.getMode());
|
|
| 206 |
- getUi().getValidator().setContext(contextName);
|
|
| 207 |
- if (create) {
|
|
| 208 |
- addInfoMessage(t("observe.common.SampleLogbook.message.creating"));
|
|
| 209 |
- } else {
|
|
| 210 |
- addInfoMessage(t("observe.common.SampleLogbook.message.updating"));
|
|
| 211 |
- }
|
|
| 212 |
- super.startEditUI(SampleLogbookDto.PROPERTY_TIME_STAMP,
|
|
| 213 |
- SampleLogbookDto.PROPERTY_LATITUDE,
|
|
| 214 |
- SampleLogbookDto.PROPERTY_LONGITUDE,
|
|
| 215 |
- SampleLogbookDto.PROPERTY_QUADRANT);
|
|
| 216 |
- model.setModified(false);
|
|
| 170 |
+ protected void initTableUI(DefaultTableCellRenderer renderer) {
|
|
| 171 |
+ JTable table = getUi().getTable();
|
|
| 172 |
+ |
|
| 173 |
+ UIHelper.setI18nTableHeaderRenderer(table,
|
|
| 174 |
+ n("observe.common.SamplePartLogbookDto.table.species"),
|
|
| 175 |
+ n("observe.common.SamplePartLogbookDto.table.species.tip"),
|
|
| 176 |
+ n("observe.common.SamplePartLogbookDto.table.count"),
|
|
| 177 |
+ n("observe.common.SamplePartLogbookDto.table.count.tip"),
|
|
| 178 |
+ n("observe.common.SamplePartLogbookDto.table.sizeMeasureType"),
|
|
| 179 |
+ n("observe.common.SamplePartLogbookDto.table.sizeMeasureType.tip"),
|
|
| 180 |
+ n("observe.common.SamplePartLogbookDto.table.length"),
|
|
| 181 |
+ n("observe.common.SamplePartLogbookDto.table.length.tip"),
|
|
| 182 |
+ n("observe.common.SamplePartLogbookDto.table.weightMeasureType"),
|
|
| 183 |
+ n("observe.common.SamplePartLogbookDto.table.weightMeasureType.tip"),
|
|
| 184 |
+ n("observe.common.SamplePartLogbookDto.table.weight"),
|
|
| 185 |
+ n("observe.common.SamplePartLogbookDto.table.weight.tip"),
|
|
| 186 |
+ n("observe.common.SamplePartLogbookDto.table.sex"),
|
|
| 187 |
+ n("observe.common.SamplePartLogbookDto.table.sex.tip"));
|
|
| 188 |
+ |
|
| 189 |
+ UIHelper.setTableColumnRenderer(table, 0, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SpeciesReference.class));
|
|
| 190 |
+ UIHelper.setTableColumnRenderer(table, 1, UIHelper.newEmptyNumberTableCellRenderer(renderer));
|
|
| 191 |
+ UIHelper.setTableColumnRenderer(table, 2, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SizeMeasureTypeReference.class));
|
|
| 192 |
+ UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer));
|
|
| 193 |
+ UIHelper.setTableColumnRenderer(table, 4, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, WeightMeasureTypeReference.class));
|
|
| 194 |
+ UIHelper.setTableColumnRenderer(table, 5, UIHelper.newEmptyNumberTableCellRenderer(renderer));
|
|
| 195 |
+ UIHelper.setTableColumnRenderer(table, 6, UIHelper.newReferentialReferenceDecorateTableCellRenderer(renderer, SexReference.class));
|
|
| 217 | 196 |
}
|
| 218 | 197 |
|
| 219 | 198 |
@Override
|
| 220 |
- protected boolean doSave(SampleLogbookDto bean) {
|
|
| 221 |
- bean.setSamplePartLogbook(getUi().getSamplePartLogbookModel().getBean().getSamplePartLogbook());
|
|
| 222 |
- SaveResultDto saveResult = getActivityLonglineLogbookSampleService().save(getSelectedId(), bean);
|
|
| 199 |
+ protected void doPersist(SampleLogbookDto bean) {
|
|
| 200 |
+ SaveResultDto saveResult = getActivityLonglineLogbookSampleService().save(bean);
|
|
| 223 | 201 |
saveResult.toDto(bean);
|
| 224 |
- return true;
|
|
| 225 | 202 |
}
|
| 226 | 203 |
|
| 227 | 204 |
@Override
|
| 228 |
- protected void afterSave(boolean refresh) {
|
|
| 229 |
- if (getModel().isCreatingMode()) {
|
|
| 230 |
- getModel().setMode(ContentMode.UPDATE);
|
|
| 231 |
- restartEditUI();
|
|
| 232 |
- } else {
|
|
| 233 |
- super.afterSave(refresh);
|
|
| 234 |
- getUi().getSamplePartLogbookUI().getHandler().afterSave(refresh);
|
|
| 205 |
+ protected void loadEditBean(String beanId) {
|
|
| 206 |
+ Form<SampleLogbookDto> form = getActivityLonglineLogbookSampleService().loadForm(beanId);
|
|
| 207 |
+ loadReferentialReferenceSetsInModel(form);
|
|
| 208 |
+ |
|
| 209 |
+ Optional<FormDefinition<SamplePartLogbookDto>> optionalFormDefinition = DtoModelHelper.getOptionalFormDefinition(SamplePartLogbookDto.class);
|
|
| 210 |
+ optionalFormDefinition.ifPresent(this::loadReferentialReferenceSetsInModel);
|
|
| 211 |
+ getModel().setForm(form);
|
|
| 212 |
+ |
|
| 213 |
+ SampleLogbookHelper.copySampleLogbookDto(form.getObject(), getBean());
|
|
| 214 |
+ |
|
| 215 |
+ }
|
|
| 216 |
+ |
|
| 217 |
+ private Optional<SizeMeasureTypeReference> getSpeciesDefaultSizeMeasureType(SpeciesReference species) {
|
|
| 218 |
+ Optional<SizeMeasureTypeReference> result = Optional.empty();
|
|
| 219 |
+ if (species != null) {
|
|
| 220 |
+ |
|
| 221 |
+ String sizeMeasureId = species.getSizeMeasureTypeId();
|
|
| 222 |
+ result = getUi().getSizeMeasureType().getData().stream()
|
|
| 223 |
+ .filter(s -> s.getId().equals(sizeMeasureId)).findFirst();
|
|
| 235 | 224 |
}
|
| 225 |
+ return result;
|
|
| 236 | 226 |
}
|
| 237 | 227 |
|
| 238 |
- protected void computeTabValidState(SwingValidatorMessageTableModel errorTableModel) {
|
|
| 228 |
+ /**
|
|
| 229 |
+ * Le mode de saisie a été mis à jour.
|
|
| 230 |
+ *
|
|
| 231 |
+ * @param newMode le nouveau de mode de saisie à utiliser
|
|
| 232 |
+ * @since 3.0
|
|
| 233 |
+ */
|
|
| 234 |
+ void updateAcquisitionMode(AcquisitionMode newMode) {
|
|
| 239 | 235 |
|
| 240 |
- Set<String> errorProperties = new HashSet<>();
|
|
| 241 |
- int rowCount = errorTableModel.getRowCount();
|
|
| 242 |
- for (int i = 0; i < rowCount; i++) {
|
|
| 236 |
+ if (log.isDebugEnabled()) {
|
|
| 237 |
+ log.debug(String.format("Change acquisition mode to %s", newMode));
|
|
| 238 |
+ }
|
|
| 239 |
+ if (newMode == null) {
|
|
| 243 | 240 |
|
| 244 |
- SwingValidatorMessage row = errorTableModel.getRow(i);
|
|
| 245 |
- if (NuitonValidatorScope.ERROR.equals(row.getScope())) {
|
|
| 246 |
- errorProperties.add(row.getField());
|
|
| 247 |
- }
|
|
| 241 |
+ // mode null (cela peut arriver avec les bindings)
|
|
| 242 |
+ return;
|
|
| 248 | 243 |
}
|
| 249 | 244 |
|
| 250 |
- boolean caracteristicsTabValid = !errorProperties.removeAll(SampleLogbookUIModel.CARACTERISTICS_TAB_PROPERTIES);
|
|
| 251 |
- boolean samplePartLogbookTabValid = !errorProperties.removeAll(SampleLogbookUIModel.SAMPLE_PART_TAB_PROPERTIES);
|
|
| 245 |
+ ActivityLonglineLogbookSampleUI ui = getUi();
|
|
| 252 | 246 |
|
| 253 |
- SampleLogbookUIModel model = getModel();
|
|
| 254 |
- model.setCaracteristicsTabValid(caracteristicsTabValid);
|
|
| 255 |
- model.setSamplePartLogbookTabValid(samplePartLogbookTabValid);
|
|
| 247 |
+ boolean createMode = ui.getTableModel().isCreate();
|
|
| 256 | 248 |
|
| 249 |
+ SamplePartLogbookDto editBean = ui.getTableEditBean();
|
|
| 250 |
+ switch (newMode) {
|
|
| 251 |
+ |
|
| 252 |
+ case byEffectif:
|
|
| 253 |
+ |
|
| 254 |
+ // le weight n'est pas modifiable
|
|
| 255 |
+ ui.getWeight().setEnabled(false);
|
|
| 256 |
+ ui.getWeightMeasureType().setEnabled(false);
|
|
| 257 |
+ |
|
| 258 |
+ // l'count est modifiable
|
|
| 259 |
+ ui.getCount().setEnabled(true);
|
|
| 260 |
+ |
|
| 261 |
+ if (createMode) {
|
|
| 262 |
+ |
|
| 263 |
+ // on supprime le weight (si il a été saisie)
|
|
| 264 |
+ editBean.setWeight(null);
|
|
| 265 |
+ editBean.setWeightMeasureType(null);
|
|
| 266 |
+ // on supprime aussi l'count (pour forcer la saisie)
|
|
| 267 |
+ editBean.setCount(null);
|
|
| 268 |
+ }
|
|
| 269 |
+ break;
|
|
| 270 |
+ |
|
| 271 |
+ case byIndividu:
|
|
| 272 |
+ |
|
| 273 |
+ // le weight est pas modifiable
|
|
| 274 |
+ ui.getWeight().setEnabled(true);
|
|
| 275 |
+ ui.getWeightMeasureType().setEnabled(true);
|
|
| 276 |
+ |
|
| 277 |
+ // l'count n'est pas modifiable et est toujours de 1
|
|
| 278 |
+ ui.getCount().setEnabled(false);
|
|
| 279 |
+ |
|
| 280 |
+ if (createMode) {
|
|
| 281 |
+ |
|
| 282 |
+ // on positionne l'count à 1 (seule valeur possible)
|
|
| 283 |
+ editBean.setCount(1);
|
|
| 284 |
+ }
|
|
| 285 |
+ break;
|
|
| 286 |
+ }
|
|
| 287 |
+ |
|
| 288 |
+ if (createMode) {
|
|
| 289 |
+ |
|
| 290 |
+ // on propage le mode de saisie dans le bean
|
|
| 291 |
+ editBean.setAcquisitionMode(newMode.ordinal());
|
|
| 292 |
+ }
|
|
| 257 | 293 |
}
|
| 258 | 294 |
|
| 259 |
- @Override
|
|
| 260 |
- public SampleLogbookUIModel getModel() {
|
|
| 261 |
- return (SampleLogbookUIModel) super.getModel();
|
|
| 295 |
+ private void onSpeciesChanged(SpeciesReference species) {
|
|
| 296 |
+ Optional<SizeMeasureTypeReference> sizeMeasureType = getSpeciesDefaultSizeMeasureType(species);
|
|
| 297 |
+ getUi().getModel().setDefaultSizeMeasureType(sizeMeasureType.orElse(null));
|
|
| 298 |
+ resetDefaultSizeMeasureType();
|
|
| 262 | 299 |
}
|
| 263 | 300 |
|
| 264 |
- private void showIndividualTabs(boolean newValue) {
|
|
| 265 |
- getUi().getSamplePartLogbookTab().setEnabled(newValue);
|
|
| 266 |
- if (!newValue && getUi().getMainTabbedPane().getSelectedIndex() > 2) {
|
|
| 267 |
- // go back to first tab
|
|
| 268 |
- getUi().getMainTabbedPane().setSelectedIndex(0);
|
|
| 269 |
- }
|
|
| 301 |
+ public void resetDefaultSizeMeasureType() {
|
|
| 302 |
+ getUi().getSizeMeasureType().setSelectedItem(null);
|
|
| 303 |
+ getUi().getSizeMeasureType().setSelectedItem(getUi().getModel().getDefaultSizeMeasureType());
|
|
| 270 | 304 |
}
|
| 305 |
+ |
|
| 271 | 306 |
}
|
| 1 |
+package fr.ird.observe.client.ui.content.data.longline.logbook;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.ui.content.table.ContentTableMeta;
|
|
| 26 |
+import fr.ird.observe.client.ui.content.table.ContentTableModel;
|
|
| 27 |
+import fr.ird.observe.client.ui.content.table.ContentTableUIModel;
|
|
| 28 |
+import fr.ird.observe.client.ui.content.table.ObserveContentTableUI;
|
|
| 29 |
+import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
|
| 30 |
+import fr.ird.observe.dto.data.longline.SamplePartLogbookDto;
|
|
| 31 |
+import fr.ird.observe.dto.data.longline.SamplePartLogbookHelper;
|
|
| 32 |
+import fr.ird.observe.dto.referential.SizeMeasureTypeReference;
|
|
| 33 |
+ |
|
| 34 |
+import java.util.Arrays;
|
|
| 35 |
+import java.util.Collection;
|
|
| 36 |
+import java.util.LinkedList;
|
|
| 37 |
+import java.util.List;
|
|
| 38 |
+ |
|
| 39 |
+/**
|
|
| 40 |
+ * Created by tchemit on 13/09/2018.
|
|
| 41 |
+ *
|
|
| 42 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 43 |
+ */
|
|
| 44 |
+public class ActivityLonglineLogbookSampleUIModel extends ContentTableUIModel<SampleLogbookDto, SamplePartLogbookDto> {
|
|
| 45 |
+ |
|
| 46 |
+ public static final String PROPERTY_DEFAULT_SIZE_MEASURE_TYPE = "defaultSizeMeasureType";
|
|
| 47 |
+ private static final long serialVersionUID = 1L;
|
|
| 48 |
+ private SizeMeasureTypeReference defaultSizeMeasureType;
|
|
| 49 |
+ |
|
| 50 |
+ public ActivityLonglineLogbookSampleUIModel(ActivityLonglineLogbookSampleUI ui) {
|
|
| 51 |
+ |
|
| 52 |
+ super(SampleLogbookDto.class,
|
|
| 53 |
+ SamplePartLogbookDto.class,
|
|
| 54 |
+ new String[]{
|
|
| 55 |
+ SampleLogbookDto.PROPERTY_SAMPLE_PART_LOGBOOK,
|
|
| 56 |
+ SampleLogbookDto.PROPERTY_DATE,
|
|
| 57 |
+ SampleLogbookDto.PROPERTY_LATITUDE,
|
|
| 58 |
+ SampleLogbookDto.PROPERTY_LONGITUDE,
|
|
| 59 |
+ SampleLogbookDto.PROPERTY_QUADRANT},
|
|
| 60 |
+ new String[]{SamplePartLogbookDto.PROPERTY_SPECIES,
|
|
| 61 |
+ SamplePartLogbookDto.PROPERTY_ACQUISITION_MODE,
|
|
| 62 |
+ SamplePartLogbookDto.PROPERTY_SIZE_MEASURE_TYPE,
|
|
| 63 |
+ SamplePartLogbookDto.PROPERTY_LENGTH_MEASURE_METHOD,
|
|
| 64 |
+ SamplePartLogbookDto.PROPERTY_WEIGHT_MEASURE_TYPE,
|
|
| 65 |
+ SamplePartLogbookDto.PROPERTY_SEX,
|
|
| 66 |
+ SamplePartLogbookDto.PROPERTY_COUNT,
|
|
| 67 |
+ SamplePartLogbookDto.PROPERTY_LENGTH,
|
|
| 68 |
+ SamplePartLogbookDto.PROPERTY_WEIGHT});
|
|
| 69 |
+ |
|
| 70 |
+ List<ContentTableMeta<SamplePartLogbookDto>> metas = Arrays.asList(
|
|
| 71 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_SPECIES, false),
|
|
| 72 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_COUNT, false),
|
|
| 73 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_SIZE_MEASURE_TYPE, false),
|
|
| 74 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_LENGTH, false),
|
|
| 75 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_WEIGHT_MEASURE_TYPE, false),
|
|
| 76 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_WEIGHT, false),
|
|
| 77 |
+ ContentTableModel.newTableMeta(SamplePartLogbookDto.class, SamplePartLogbookDto.PROPERTY_SEX, false));
|
|
| 78 |
+ |
|
| 79 |
+ initModel(ui, metas);
|
|
| 80 |
+ }
|
|
| 81 |
+ |
|
| 82 |
+ @Override
|
|
| 83 |
+ protected ContentTableModel<SampleLogbookDto, SamplePartLogbookDto> createTableModel(
|
|
| 84 |
+ ObserveContentTableUI<SampleLogbookDto, SamplePartLogbookDto, ?> ui,
|
|
| 85 |
+ List<ContentTableMeta<SamplePartLogbookDto>> contentTableMetas) {
|
|
| 86 |
+ |
|
| 87 |
+ return new ContentTableModel<SampleLogbookDto, SamplePartLogbookDto>(ui, contentTableMetas) {
|
|
| 88 |
+ private static final long serialVersionUID = 1L;
|
|
| 89 |
+ |
|
| 90 |
+ @Override
|
|
| 91 |
+ protected Collection<SamplePartLogbookDto> getChilds(SampleLogbookDto bean) {
|
|
| 92 |
+ return bean.getSamplePartLogbook();
|
|
| 93 |
+ }
|
|
| 94 |
+ |
|
| 95 |
+ @Override
|
|
| 96 |
+ protected void load(SamplePartLogbookDto source, SamplePartLogbookDto target) {
|
|
| 97 |
+ SamplePartLogbookHelper.copySamplePartLogbookDto(source, target);
|
|
| 98 |
+ }
|
|
| 99 |
+ |
|
| 100 |
+ @Override
|
|
| 101 |
+ protected void setChilds(SampleLogbookDto parent, List<SamplePartLogbookDto> childs) {
|
|
| 102 |
+ parent.setSamplePartLogbook(new LinkedList<>(childs));
|
|
| 103 |
+ }
|
|
| 104 |
+ };
|
|
| 105 |
+ }
|
|
| 106 |
+ |
|
| 107 |
+ |
|
| 108 |
+ public SizeMeasureTypeReference getDefaultSizeMeasureType() {
|
|
| 109 |
+ return defaultSizeMeasureType;
|
|
| 110 |
+ }
|
|
| 111 |
+ |
|
| 112 |
+ public void setDefaultSizeMeasureType(SizeMeasureTypeReference defaultSizeMeasureType) {
|
|
| 113 |
+ SizeMeasureTypeReference oldValue = getDefaultSizeMeasureType();
|
|
| 114 |
+ this.defaultSizeMeasureType = defaultSizeMeasureType;
|
|
| 115 |
+ firePropertyChange(PROPERTY_DEFAULT_SIZE_MEASURE_TYPE, oldValue, defaultSizeMeasureType);
|
|
| 116 |
+ }
|
|
| 117 |
+ |
|
| 118 |
+}
|
| ... | ... | @@ -215,6 +215,9 @@ class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<Activity |
| 215 | 215 |
if (notPersisted) {
|
| 216 | 216 |
// ouverture de l'activité après création
|
| 217 | 217 |
getEditNode().setId(bean.getId());
|
| 218 |
+ // on doit recharger le bean car on y a ajoute son sample
|
|
| 219 |
+ ActivityLonglineLogbookDto newBean = getActivityLonglineLogbookService().loadDto(bean.getId());
|
|
| 220 |
+ getModel().setBean(newBean);
|
|
| 218 | 221 |
}
|
| 219 | 222 |
|
| 220 | 223 |
addSet = notPersisted && ActivityLonglineLogbookHelper.FISHING_OPERATION_ID.equals(bean.getVesselActivityLongline().getId());
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.tree.navigation.nodes.longline.logbook; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -23,10 +23,12 @@ package fr.ird.observe.client.ui.tree.navigation.nodes.longline.logbook; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookSampleUI;
|
| 26 |
-import fr.ird.observe.client.ui.tree.navigation.nodes.ReferenceNavigationTreeNodeSupport;
|
|
| 26 |
+import fr.ird.observe.client.ui.tree.navigation.nodes.ClassNavigationTreeNode;
|
|
| 27 |
+import fr.ird.observe.dto.IdHelper;
|
|
| 27 | 28 |
import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
| 28 | 29 |
import fr.ird.observe.dto.data.longline.SampleLogbookReference;
|
| 29 |
-import fr.ird.observe.dto.navigation.select.node.ObserveLonglineLogbookActivitySampleSelectNode;
|
|
| 30 |
+ |
|
| 31 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 30 | 32 |
|
| 31 | 33 |
/**
|
| 32 | 34 |
* Created on 14/11/16.
|
| ... | ... | @@ -34,16 +36,10 @@ import fr.ird.observe.dto.navigation.select.node.ObserveLonglineLogbookActivityS |
| 34 | 36 |
* @author Tony Chemit - dev@tchemit.fr
|
| 35 | 37 |
* @since 6.0
|
| 36 | 38 |
*/
|
| 37 |
-public class ActivityLonglineSampleLogbookNavigationTreeNode extends ReferenceNavigationTreeNodeSupport<SampleLogbookDto, SampleLogbookReference> {
|
|
| 39 |
+public class ActivityLonglineSampleLogbookNavigationTreeNode extends ClassNavigationTreeNode<SampleLogbookDto> {
|
|
| 38 | 40 |
|
| 39 |
- public ActivityLonglineSampleLogbookNavigationTreeNode(SampleLogbookReference data) {
|
|
| 40 |
- super(data, ObserveLonglineLogbookActivitySampleSelectNode.class, null, false);
|
|
| 41 |
- }
|
|
| 42 |
- |
|
| 43 |
- @Override
|
|
| 44 |
- public void reload() {
|
|
| 45 |
- SampleLogbookReference data = getServicesProvider().getActivityLonglineLogbookSampleService().loadReferenceToRead(getId());
|
|
| 46 |
- setData(data);
|
|
| 41 |
+ ActivityLonglineSampleLogbookNavigationTreeNode(SampleLogbookReference data) {
|
|
| 42 |
+ super(SampleLogbookDto.class, t("observe.ui.tree.longline.sample"));
|
|
| 47 | 43 |
}
|
| 48 | 44 |
|
| 49 | 45 |
@Override
|
| ... | ... | @@ -54,4 +50,9 @@ public class ActivityLonglineSampleLogbookNavigationTreeNode extends ReferenceNa |
| 54 | 50 |
public boolean isLeaf() {
|
| 55 | 51 |
return true;
|
| 56 | 52 |
}
|
| 53 |
+ |
|
| 54 |
+ @Override
|
|
| 55 |
+ public String getIconPath() {
|
|
| 56 |
+ return "navigation." + IdHelper.getDtoSimplifiedName(getData());
|
|
| 57 |
+ }
|
|
| 57 | 58 |
}
|
| ... | ... | @@ -1746,6 +1746,7 @@ observe.ui.tree.longline.obs.activity.list=Observations |
| 1746 | 1746 |
observe.ui.tree.longline.obs.activity.unsaved=New activity
|
| 1747 | 1747 |
observe.ui.tree.longline.obs.set.unsaved=New fishing operation
|
| 1748 | 1748 |
observe.ui.tree.longline.obs.tdr=Tdrs
|
| 1749 |
+observe.ui.tree.longline.sample=Samples
|
|
| 1749 | 1750 |
observe.ui.tree.longline.sensorUsed=Sensors used
|
| 1750 | 1751 |
observe.ui.tree.longline.setDetailComposition=Detailed compositions
|
| 1751 | 1752 |
observe.ui.tree.longline.setGlobalComposition=Global compositions
|
| ... | ... | @@ -1746,6 +1746,7 @@ observe.ui.tree.longline.obs.activity.list=Observations \#TODO |
| 1746 | 1746 |
observe.ui.tree.longline.obs.activity.unsaved=Nueva actividad
|
| 1747 | 1747 |
observe.ui.tree.longline.obs.set.unsaved=Nuevo lance
|
| 1748 | 1748 |
observe.ui.tree.longline.obs.tdr=Registradores de profundidad
|
| 1749 |
+observe.ui.tree.longline.sample=Muestreos
|
|
| 1749 | 1750 |
observe.ui.tree.longline.sensorUsed=Sensores utilizados
|
| 1750 | 1751 |
observe.ui.tree.longline.setDetailComposition=Composiciones detalladas
|
| 1751 | 1752 |
observe.ui.tree.longline.setGlobalComposition=Composiciones globales
|
| ... | ... | @@ -1746,6 +1746,7 @@ observe.ui.tree.longline.obs.activity.list=Observations |
| 1746 | 1746 |
observe.ui.tree.longline.obs.activity.unsaved=Nouvelle activité
|
| 1747 | 1747 |
observe.ui.tree.longline.obs.set.unsaved=Nouvelle opération de pêche
|
| 1748 | 1748 |
observe.ui.tree.longline.obs.tdr=Enregistreurs de profondeur
|
| 1749 |
+observe.ui.tree.longline.sample=Échantillons
|
|
| 1749 | 1750 |
observe.ui.tree.longline.sensorUsed=Capteurs utilisés
|
| 1750 | 1751 |
observe.ui.tree.longline.setDetailComposition=Compositions détaillées
|
| 1751 | 1752 |
observe.ui.tree.longline.setGlobalComposition=Compositions globales
|
| ... | ... | @@ -23,6 +23,7 @@ package fr.ird.observe.binder.data.longline; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.binder.data.DataEntityDtoBinderSupport;
|
| 26 |
+import fr.ird.observe.dto.CoordinateHelper;
|
|
| 26 | 27 |
import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
| 27 | 28 |
import fr.ird.observe.dto.referential.ReferentialLocale;
|
| 28 | 29 |
import fr.ird.observe.entities.longline.SampleLogbook;
|
| ... | ... | @@ -54,6 +55,7 @@ public class SampleLogbookEntityDtoBinder extends DataEntityDtoBinderSupport<Sam |
| 54 | 55 |
dto.setLatitude(entity.getLatitude());
|
| 55 | 56 |
dto.setLongitude(entity.getLongitude());
|
| 56 | 57 |
dto.setTimeStamp(entity.getTimeStamp());
|
| 58 |
+ dto.setQuadrant(CoordinateHelper.getQuadrant(dto.getLongitude(), dto.getLatitude()));
|
|
| 57 | 59 |
dto.setSamplePartLogbook(toListData(referentialLocale, entity.getSamplePartLogbook()));
|
| 58 | 60 |
}
|
| 59 | 61 |
|
| ... | ... | @@ -62,6 +62,7 @@ public class ActivityLonglineLogbookTopiaDao extends AbstractActivityLonglineLog |
| 62 | 62 |
" a.topiaId," +
|
| 63 | 63 |
" a.timestamp," +
|
| 64 | 64 |
" a.set," +
|
| 65 |
+ " a.sample," +
|
|
| 65 | 66 |
" va.topiaId," +
|
| 66 | 67 |
" va." + I18nReferenceEntities.getPropertyName(referenceLocale) +
|
| 67 | 68 |
" FROM observe_longline.activityLogbook a, observe_longline.vesselActivity va" +
|
| ... | ... | @@ -80,6 +81,7 @@ public class ActivityLonglineLogbookTopiaDao extends AbstractActivityLonglineLog |
| 80 | 81 |
" a.topiaId," +
|
| 81 | 82 |
" a.timestamp," +
|
| 82 | 83 |
" a.set," +
|
| 84 |
+ " a.sample," +
|
|
| 83 | 85 |
" va.topiaId," +
|
| 84 | 86 |
" va." + I18nReferenceEntities.getPropertyName(referenceLocale) +
|
| 85 | 87 |
" FROM observe_longline.activityLogbook a, observe_longline.vesselActivity va" +
|
| ... | ... | @@ -108,16 +110,20 @@ public class ActivityLonglineLogbookTopiaDao extends AbstractActivityLonglineLog |
| 108 | 110 |
|
| 109 | 111 |
String setId = set.getString(3);
|
| 110 | 112 |
if (setId != null) {
|
| 111 |
- |
|
| 112 | 113 |
SetLonglineLogbookImpl setLongline = new SetLonglineLogbookImpl();
|
| 113 | 114 |
setLongline.setTopiaId(setId);
|
| 114 | 115 |
activity.setSetLongline(setLongline);
|
| 115 |
- |
|
| 116 |
+ }
|
|
| 117 |
+ String sampleId = set.getString(4);
|
|
| 118 |
+ if (sampleId != null) {
|
|
| 119 |
+ SampleLogbook sample = new SampleLogbookImpl();
|
|
| 120 |
+ sample.setTopiaId(sampleId);
|
|
| 121 |
+ activity.setSample(sample);
|
|
| 116 | 122 |
}
|
| 117 | 123 |
VesselActivityLongline vesselActivity = new VesselActivityLonglineImpl();
|
| 118 |
- String vesselActivityId = set.getString(4);
|
|
| 124 |
+ String vesselActivityId = set.getString(5);
|
|
| 119 | 125 |
vesselActivity.setTopiaId(vesselActivityId);
|
| 120 |
- String label = set.getString(5);
|
|
| 126 |
+ String label = set.getString(6);
|
|
| 121 | 127 |
I18nReferenceEntities.setLabel(referenceLocale, vesselActivity, label);
|
| 122 | 128 |
activity.setVesselActivityLongline(vesselActivity);
|
| 123 | 129 |
return activity;
|
| ... | ... | @@ -195,5 +195,4 @@ longline.SampleLogbook > ObserveDataEntity | entity |
| 195 | 195 |
timeStamp + {*:1} Date
|
| 196 | 196 |
latitude + {*:1} Float | sqlType=numeric
|
| 197 | 197 |
longitude + {*:1} Float | sqlType=numeric
|
| 198 |
-quadrant + {*:1} Integer
|
|
| 199 | 198 |
samplePartLogbook + {*} longline.SamplePartLogbook | ordered reverseDbName=sample
|
| ... | ... | @@ -95,12 +95,7 @@ POST /api/v1/data/longline/ActivityLongLineObsEncounterService/save |
| 95 | 95 |
GET /api/v1/data/longline/ActivityLongLineObsSensorUsedService/getDataFile v1.data.longline.ActivityLongLineObsSensorUsedServiceRestApi.getDataFile
|
| 96 | 96 |
GET /api/v1/data/longline/ActivityLongLineObsSensorUsedService/loadForm v1.data.longline.ActivityLongLineObsSensorUsedServiceRestApi.loadForm
|
| 97 | 97 |
POST /api/v1/data/longline/ActivityLongLineObsSensorUsedService/save v1.data.longline.ActivityLongLineObsSensorUsedServiceRestApi.save
|
| 98 |
-DELETE /api/v1/data/longline/ActivityLonglineLogbookSampleService/delete v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.delete
|
|
| 99 |
-GET /api/v1/data/longline/ActivityLonglineLogbookSampleService/exists v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.exists
|
|
| 100 |
-GET /api/v1/data/longline/ActivityLonglineLogbookSampleService/loadDto v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.loadDto
|
|
| 101 | 98 |
GET /api/v1/data/longline/ActivityLonglineLogbookSampleService/loadForm v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.loadForm
|
| 102 |
-GET /api/v1/data/longline/ActivityLonglineLogbookSampleService/loadReferenceToRead v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.loadReferenceToRead
|
|
| 103 |
-GET /api/v1/data/longline/ActivityLonglineLogbookSampleService/preCreate v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.preCreate
|
|
| 104 | 99 |
POST /api/v1/data/longline/ActivityLonglineLogbookSampleService/save v1.data.longline.ActivityLonglineLogbookSampleServiceRestApi.save
|
| 105 | 100 |
DELETE /api/v1/data/longline/ActivityLonglineLogbookService/delete v1.data.longline.ActivityLonglineLogbookServiceRestApi.delete
|
| 106 | 101 |
GET /api/v1/data/longline/ActivityLonglineLogbookService/exists v1.data.longline.ActivityLonglineLogbookServiceRestApi.exists
|
| ... | ... | @@ -137,6 +132,7 @@ POST /api/v1/data/longline/LandingLogbookService/moveLandingLogbookToTripLongl |
| 137 | 132 |
POST /api/v1/data/longline/LandingLogbookService/moveLandingLogbooksToTripLongline v1.data.longline.LandingLogbookServiceRestApi.moveLandingLogbooksToTripLongline
|
| 138 | 133 |
GET /api/v1/data/longline/LandingLogbookService/preCreate v1.data.longline.LandingLogbookServiceRestApi.preCreate
|
| 139 | 134 |
POST /api/v1/data/longline/LandingLogbookService/save v1.data.longline.LandingLogbookServiceRestApi.save
|
| 135 |
+GET /api/v1/data/longline/SetLonglineLogbookCatchService/getSampleSpecies v1.data.longline.SetLonglineLogbookCatchServiceRestApi.getSampleSpecies
|
|
| 140 | 136 |
GET /api/v1/data/longline/SetLonglineLogbookCatchService/loadForm v1.data.longline.SetLonglineLogbookCatchServiceRestApi.loadForm
|
| 141 | 137 |
POST /api/v1/data/longline/SetLonglineLogbookCatchService/save v1.data.longline.SetLonglineLogbookCatchServiceRestApi.save
|
| 142 | 138 |
GET /api/v1/data/longline/SetLonglineLogbookGlobalCompositionService/loadForm v1.data.longline.SetLonglineLogbookGlobalCompositionServiceRestApi.loadForm
|
| ... | ... | @@ -10,21 +10,19 @@ package fr.ird.observe.services.local.service.data.longline; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import fr.ird.observe.dto.DataNotFoundException;
|
|
| 26 | 25 |
import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
| 27 |
-import fr.ird.observe.dto.data.longline.SampleLogbookReference;
|
|
| 28 | 26 |
import fr.ird.observe.dto.form.Form;
|
| 29 | 27 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 30 | 28 |
import fr.ird.observe.entities.longline.ActivityLonglineLogbook;
|
| ... | ... | @@ -38,65 +36,23 @@ import fr.ird.observe.services.service.data.longline.ActivityLonglineLogbookSamp |
| 38 | 36 |
public class ActivityLonglineLogbookSampleServiceLocal extends ObserveServiceLocal implements ActivityLonglineLogbookSampleService {
|
| 39 | 37 |
|
| 40 | 38 |
@Override
|
| 41 |
- public SampleLogbookReference loadReferenceToRead(String sampleLogbookId) {
|
|
| 42 |
- return SAMPLE_LOGBOOK_SPI.loadEntityToDataReferenceDto(getTopiaPersistenceContext(), sampleLogbookId, getReferentialLocale());
|
|
| 43 |
- }
|
|
| 44 |
- |
|
| 45 |
- @Override
|
|
| 46 |
- public SampleLogbookDto loadDto(String sampleLogbookId) {
|
|
| 47 |
- return SAMPLE_LOGBOOK_SPI.loadEntityToDataDto(getTopiaPersistenceContext(), sampleLogbookId, getReferentialLocale());
|
|
| 48 |
- }
|
|
| 49 |
- |
|
| 50 |
- @Override
|
|
| 51 |
- public boolean exists(String sampleLogbookId) {
|
|
| 52 |
- return SAMPLE_LOGBOOK_SPI.existsEntity(getTopiaPersistenceContext(), sampleLogbookId);
|
|
| 53 |
- }
|
|
| 54 |
- |
|
| 55 |
- @Override
|
|
| 56 |
- public Form<SampleLogbookDto> loadForm(String sampleLogbookId) {
|
|
| 57 |
- SampleLogbook sampleLogbook = SAMPLE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), sampleLogbookId);
|
|
| 58 |
- return SAMPLE_LOGBOOK_SPI.dataEntityToForm(sampleLogbook, getReferentialLocale());
|
|
| 59 |
- }
|
|
| 60 |
- |
|
| 61 |
- @Override
|
|
| 62 |
- public Form<SampleLogbookDto> preCreate(String activityLonglineId) {
|
|
| 39 |
+ public Form<SampleLogbookDto> loadForm(String activityLonglineId) {
|
|
| 63 | 40 |
ActivityLonglineLogbook activity = ACTIVITY_LONGLINE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), activityLonglineId);
|
| 64 |
- SampleLogbook preCreated = SAMPLE_LOGBOOK_SPI.newEntity();
|
|
| 65 |
-// SampleLogbook lastSampleLogbook = Iterables.getLast(tripLongline.getSample(), null);
|
|
| 66 |
-// Date timestamp;
|
|
| 67 |
-// if (lastSampleLogbook == null) {
|
|
| 68 |
-// // première activité, on utilise la date de début de marée (voir http://forge.codelutin.com/issues/6777)
|
|
| 69 |
-// Calendar calendar = Calendar.getInstance();
|
|
| 70 |
-// calendar.setTime(tripLongline.getStartDate());
|
|
| 71 |
-// timestamp = calendar.getTime();
|
|
| 72 |
-// } else {
|
|
| 73 |
-// // on reprend la date et l'heure de la dernière activité
|
|
| 74 |
-// timestamp = lastSampleLogbook.getStartDate();
|
|
| 75 |
-// }
|
|
| 76 |
-// preCreated.setStartDate(timestamp);
|
|
| 77 |
- return SAMPLE_LOGBOOK_SPI.dataEntityToForm(preCreated, getReferentialLocale());
|
|
| 41 |
+ SampleLogbook sampleLogbook = activity.getSample();
|
|
| 42 |
+ return SAMPLE_LOGBOOK_SPI.dataEntityToForm(sampleLogbook, getReferentialLocale());
|
|
| 78 | 43 |
}
|
| 79 | 44 |
|
| 80 | 45 |
@Override
|
| 81 |
- public SaveResultDto save(String activityLonglineId, SampleLogbookDto dto) {
|
|
| 82 |
- ActivityLonglineLogbook activity = ACTIVITY_LONGLINE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), activityLonglineId);
|
|
| 46 |
+ public SaveResultDto save(SampleLogbookDto dto) {
|
|
| 47 |
+// ActivityLonglineLogbook activity = ACTIVITY_LONGLINE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), activityLonglineId);
|
|
| 83 | 48 |
SampleLogbook entity = SAMPLE_LOGBOOK_SPI.loadOrCreateEntityFromDataDto(getTopiaPersistenceContext(), dto);
|
| 84 | 49 |
checkLastUpdateDate(entity, dto);
|
| 85 | 50 |
SAMPLE_LOGBOOK_SPI.copyDataDtoToEntity(dto, entity, getReferentialLocale());
|
| 86 | 51 |
SaveResultDto result = saveEntity(entity);
|
| 87 |
- if (dto.isNotPersisted()) {
|
|
| 88 |
- activity.setSample(entity);
|
|
| 89 |
- }
|
|
| 52 |
+// if (dto.isNotPersisted()) {
|
|
| 53 |
+// activity.setSample(entity);
|
|
| 54 |
+// }
|
|
| 90 | 55 |
return result;
|
| 91 | 56 |
}
|
| 92 | 57 |
|
| 93 |
- @Override
|
|
| 94 |
- public void delete(String activityLonglineId, String sampleLogbookId) {
|
|
| 95 |
- ActivityLonglineLogbook activity = ACTIVITY_LONGLINE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), activityLonglineId);
|
|
| 96 |
- if (activity.getSample() == null || sampleLogbookId.equals(activity.getSample().getTopiaId())) {
|
|
| 97 |
- throw new DataNotFoundException(SampleLogbookDto.class, sampleLogbookId);
|
|
| 98 |
- }
|
|
| 99 |
- activity.setSample(null);
|
|
| 100 |
- }
|
|
| 101 |
- |
|
| 102 | 58 |
}
|
| ... | ... | @@ -36,8 +36,11 @@ import fr.ird.observe.dto.result.TripChildSaveResultHelper; |
| 36 | 36 |
import fr.ird.observe.entities.longline.ActivityLonglineLogbook;
|
| 37 | 37 |
import fr.ird.observe.entities.longline.ActivityLonglineLogbookTopiaDao;
|
| 38 | 38 |
import fr.ird.observe.entities.longline.ActivityLonglineLogbooks;
|
| 39 |
+import fr.ird.observe.entities.longline.SampleLogbook;
|
|
| 39 | 40 |
import fr.ird.observe.entities.longline.TripLongline;
|
| 41 |
+import fr.ird.observe.services.local.ObserveServiceContextLocal;
|
|
| 40 | 42 |
import fr.ird.observe.services.local.service.ObserveServiceLocal;
|
| 43 |
+import fr.ird.observe.services.service.data.longline.ActivityLonglineLogbookSampleService;
|
|
| 41 | 44 |
import fr.ird.observe.services.service.data.longline.ActivityLonglineLogbookService;
|
| 42 | 45 |
|
| 43 | 46 |
import java.util.ArrayList;
|
| ... | ... | @@ -50,6 +53,14 @@ import java.util.List; |
| 50 | 53 |
*/
|
| 51 | 54 |
public class ActivityLonglineLogbookServiceLocal extends ObserveServiceLocal implements ActivityLonglineLogbookService {
|
| 52 | 55 |
|
| 56 |
+ private ActivityLonglineLogbookSampleService sampleService;
|
|
| 57 |
+ |
|
| 58 |
+ @Override
|
|
| 59 |
+ public void setServiceContext(ObserveServiceContextLocal serviceContext) {
|
|
| 60 |
+ super.setServiceContext(serviceContext);
|
|
| 61 |
+ sampleService = serviceContext.newService(ActivityLonglineLogbookSampleService.class);
|
|
| 62 |
+ }
|
|
| 63 |
+ |
|
| 53 | 64 |
@Override
|
| 54 | 65 |
public DataDtoReferenceSet<ActivityLonglineLogbookReference> getActivityLonglineByTripLongline(String tripLonglineId) {
|
| 55 | 66 |
ActivityLonglineLogbookTopiaDao dao = ACTIVITY_LONGLINE_LOGBOOK_SPI.getDao(getTopiaPersistenceContext());
|
| ... | ... | @@ -110,10 +121,22 @@ public class ActivityLonglineLogbookServiceLocal extends ObserveServiceLocal imp |
| 110 | 121 |
ActivityLonglineLogbook entity = ACTIVITY_LONGLINE_LOGBOOK_SPI.loadOrCreateEntityFromDataDto(getTopiaPersistenceContext(), dto);
|
| 111 | 122 |
checkLastUpdateDate(entity, dto);
|
| 112 | 123 |
ACTIVITY_LONGLINE_LOGBOOK_SPI.copyDataDtoToEntity(dto, entity, getReferentialLocale());
|
| 124 |
+ boolean notPersisted = dto.isNotPersisted();
|
|
| 125 |
+ if (notPersisted) {
|
|
| 126 |
+ // create a unique sample
|
|
| 127 |
+ SampleLogbook preCreated = SAMPLE_LOGBOOK_SPI.newEntity();
|
|
| 128 |
+ preCreated.setLatitude(entity.getLatitude());
|
|
| 129 |
+ preCreated.setLongitude(entity.getLongitude());
|
|
| 130 |
+ preCreated.setTimeStamp(entity.getTimeStamp());
|
|
| 131 |
+ saveEntity(preCreated);
|
|
| 132 |
+ entity.setSample(preCreated);
|
|
| 133 |
+ }
|
|
| 113 | 134 |
SaveResultDto saveResultDto = saveEntity(entity);
|
| 135 |
+ |
|
| 114 | 136 |
TripChildSaveResultDto result = TripChildSaveResultHelper.of(saveResultDto);
|
| 115 |
- if (dto.isNotPersisted()) {
|
|
| 137 |
+ if (notPersisted) {
|
|
| 116 | 138 |
tripLongline.addActivityLonglineLogbook(entity);
|
| 139 |
+ |
|
| 117 | 140 |
}
|
| 118 | 141 |
boolean wasEndDateUpdated = TRIP_LONGLINE_SPI.getDao(getTopiaPersistenceContext()).updateEndDate(tripLongline);
|
| 119 | 142 |
result.setTripEndDateUpdated(wasEndDateUpdated);
|
| ... | ... | @@ -24,11 +24,16 @@ package fr.ird.observe.services.local.service.data.longline; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.dto.data.longline.SetLonglineLogbookCatchDto;
|
| 26 | 26 |
import fr.ird.observe.dto.form.Form;
|
| 27 |
+import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
|
| 28 |
+import fr.ird.observe.dto.referential.SpeciesReference;
|
|
| 27 | 29 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 30 |
+import fr.ird.observe.entities.longline.CatchLonglineLogbook;
|
|
| 28 | 31 |
import fr.ird.observe.entities.longline.SetLonglineLogbook;
|
| 29 | 32 |
import fr.ird.observe.services.local.service.ObserveServiceLocal;
|
| 30 | 33 |
import fr.ird.observe.services.service.data.longline.SetLonglineLogbookCatchService;
|
| 31 | 34 |
|
| 35 |
+import java.util.stream.Collectors;
|
|
| 36 |
+ |
|
| 32 | 37 |
/**
|
| 33 | 38 |
* @author Tony Chemit - dev@tchemit.fr
|
| 34 | 39 |
*/
|
| ... | ... | @@ -48,4 +53,14 @@ public class SetLonglineLogbookCatchServiceLocal extends ObserveServiceLocal imp |
| 48 | 53 |
return saveEntity(entity);
|
| 49 | 54 |
}
|
| 50 | 55 |
|
| 56 |
+ @Override
|
|
| 57 |
+ public ReferentialDtoReferenceSet<SpeciesReference> getSampleSpecies(String setLonglineId) {
|
|
| 58 |
+ SetLonglineLogbook set = SET_LONGLINE_LOGBOOK_SPI.loadEntity(getTopiaPersistenceContext(), setLonglineId);
|
|
| 59 |
+ return SPECIES_SPI.toReferentialReferenceSet(set.getCatchLongline().stream()
|
|
| 60 |
+ .map(CatchLonglineLogbook::getSpeciesCatch)
|
|
| 61 |
+ .distinct()
|
|
| 62 |
+ .collect(Collectors.toList()),
|
|
| 63 |
+ getReferentialLocale(), null);
|
|
| 64 |
+ }
|
|
| 65 |
+ |
|
| 51 | 66 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.services.service.data.longline; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -23,14 +23,12 @@ package fr.ird.observe.services.service.data.longline; |
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.dto.data.longline.SampleLogbookDto;
|
| 26 |
-import fr.ird.observe.dto.data.longline.SampleLogbookReference;
|
|
| 27 | 26 |
import fr.ird.observe.dto.form.Form;
|
| 28 | 27 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 29 | 28 |
import fr.ird.observe.services.service.ObserveService;
|
| 30 | 29 |
import fr.ird.observe.services.spi.ReadDataPermission;
|
| 31 | 30 |
import fr.ird.observe.services.spi.Write;
|
| 32 | 31 |
import fr.ird.observe.services.spi.WriteDataPermission;
|
| 33 |
-import io.ultreia.java4all.http.spi.Delete;
|
|
| 34 | 32 |
import io.ultreia.java4all.http.spi.Get;
|
| 35 | 33 |
import io.ultreia.java4all.http.spi.Post;
|
| 36 | 34 |
|
| ... | ... | @@ -41,32 +39,11 @@ public interface ActivityLonglineLogbookSampleService extends ObserveService { |
| 41 | 39 |
|
| 42 | 40 |
@Get
|
| 43 | 41 |
@ReadDataPermission
|
| 44 |
- Form<SampleLogbookDto> loadForm(String sampleLogbookId);
|
|
| 45 |
- |
|
| 46 |
- @Get
|
|
| 47 |
- @ReadDataPermission
|
|
| 48 |
- SampleLogbookDto loadDto(String sampleLogbookId);
|
|
| 49 |
- |
|
| 50 |
- @Get
|
|
| 51 |
- @ReadDataPermission
|
|
| 52 |
- SampleLogbookReference loadReferenceToRead(String sampleLogbookId);
|
|
| 53 |
- |
|
| 54 |
- @Get
|
|
| 55 |
- @ReadDataPermission
|
|
| 56 |
- boolean exists(String sampleLogbookId);
|
|
| 57 |
- |
|
| 58 |
- @Get
|
|
| 59 |
- @WriteDataPermission
|
|
| 60 |
- Form<SampleLogbookDto> preCreate(String activityLonglineId);
|
|
| 42 |
+ Form<SampleLogbookDto> loadForm(String activityLonglineId);
|
|
| 61 | 43 |
|
| 62 | 44 |
@WriteDataPermission
|
| 63 | 45 |
@Write
|
| 64 | 46 |
@Post
|
| 65 |
- SaveResultDto save(String activityLonglineId, SampleLogbookDto dto);
|
|
| 66 |
- |
|
| 67 |
- @Write
|
|
| 68 |
- @WriteDataPermission
|
|
| 69 |
- @Delete
|
|
| 70 |
- void delete(String activityLonglineId, String sampleLogbookId);
|
|
| 47 |
+ SaveResultDto save(SampleLogbookDto dto);
|
|
| 71 | 48 |
|
| 72 | 49 |
}
|
| ... | ... | @@ -24,6 +24,8 @@ package fr.ird.observe.services.service.data.longline; |
| 24 | 24 |
|
| 25 | 25 |
import fr.ird.observe.dto.data.longline.SetLonglineLogbookCatchDto;
|
| 26 | 26 |
import fr.ird.observe.dto.form.Form;
|
| 27 |
+import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
|
| 28 |
+import fr.ird.observe.dto.referential.SpeciesReference;
|
|
| 27 | 29 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 28 | 30 |
import fr.ird.observe.services.service.ObserveService;
|
| 29 | 31 |
import fr.ird.observe.services.spi.ReadDataPermission;
|
| ... | ... | @@ -46,4 +48,8 @@ public interface SetLonglineLogbookCatchService extends ObserveService { |
| 46 | 48 |
@Post
|
| 47 | 49 |
SaveResultDto save(SetLonglineLogbookCatchDto dto);
|
| 48 | 50 |
|
| 51 |
+ @Get
|
|
| 52 |
+ @ReadDataPermission
|
|
| 53 |
+ ReferentialDtoReferenceSet<SpeciesReference> getSampleSpecies(String setLonglineId);
|
|
| 54 |
+ |
|
| 49 | 55 |
}
|
| ... | ... | @@ -78,7 +78,7 @@ create table OBSERVE_LONGLINE.mitigationtype_setlogbook (set varchar(255), mitig |
| 78 | 78 |
create table OBSERVE_LONGLINE.mitigationtype_setobs (set varchar(255), mitigationType varchar(255) not null);
|
| 79 | 79 |
create table OBSERVE_LONGLINE.observationTripType (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status integer, label1 varchar(255), label2 varchar(255), label3 varchar(255), label4 varchar(255), label5 varchar(255), label6 varchar(255), label7 varchar(255), label8 varchar(255), primary key (topiaId));
|
| 80 | 80 |
create table OBSERVE_LONGLINE.onBoardProcessing (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status integer, label1 varchar(255), label2 varchar(255), label3 varchar(255), label4 varchar(255), label5 varchar(255), label6 varchar(255), label7 varchar(255), label8 varchar(255), primary key (topiaId));
|
| 81 |
-create table OBSERVE_LONGLINE.sampleLogbook (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, timeStamp timestamp, latitude numeric, longitude numeric, quadrant integer, trip varchar(255), primary key (topiaId));
|
|
| 81 |
+create table OBSERVE_LONGLINE.sampleLogbook (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, timeStamp timestamp, latitude numeric, longitude numeric, trip varchar(255), primary key (topiaId));
|
|
| 82 | 82 |
create table OBSERVE_LONGLINE.samplePartLogbook (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, length numeric, weight numeric, count integer, acquisitionMode integer, tagNumber varchar(255), species varchar(255), sex varchar(255), sizeMeasureType varchar(255), lengthMeasureMethod varchar(255), weightMeasureType varchar(255), weightMeasureMethod varchar(255), sample varchar(255), sample_idx integer, primary key (topiaId));
|
| 83 | 83 |
create table OBSERVE_LONGLINE.sectionObs (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, settingIdentifier integer not null, haulingIdentifier integer, set varchar(255), primary key (topiaId));
|
| 84 | 84 |
create table OBSERVE_LONGLINE.sensorBrand (topiaId varchar(255) not null, topiaVersion bigint not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status integer, brandName varchar(255), primary key (topiaId));
|
| ... | ... | @@ -78,7 +78,7 @@ create table OBSERVE_LONGLINE.mitigationtype_setlogbook (set varchar(255), mitig |
| 78 | 78 |
create table OBSERVE_LONGLINE.mitigationtype_setobs (set varchar(255), mitigationType varchar(255) not null);
|
| 79 | 79 |
create table OBSERVE_LONGLINE.observationTripType (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status int4, label1 varchar(255), label2 varchar(255), label3 varchar(255), label4 varchar(255), label5 varchar(255), label6 varchar(255), label7 varchar(255), label8 varchar(255), primary key (topiaId));
|
| 80 | 80 |
create table OBSERVE_LONGLINE.onBoardProcessing (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status int4, label1 varchar(255), label2 varchar(255), label3 varchar(255), label4 varchar(255), label5 varchar(255), label6 varchar(255), label7 varchar(255), label8 varchar(255), primary key (topiaId));
|
| 81 |
-create table OBSERVE_LONGLINE.sampleLogbook (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, timeStamp timestamp, latitude numeric, longitude numeric, quadrant int4, trip varchar(255), primary key (topiaId));
|
|
| 81 |
+create table OBSERVE_LONGLINE.sampleLogbook (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, timeStamp timestamp, latitude numeric, longitude numeric, trip varchar(255), primary key (topiaId));
|
|
| 82 | 82 |
create table OBSERVE_LONGLINE.samplePartLogbook (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, length numeric, weight numeric, count int4, acquisitionMode int4, tagNumber varchar(255), species varchar(255), sex varchar(255), sizeMeasureType varchar(255), lengthMeasureMethod varchar(255), weightMeasureType varchar(255), weightMeasureMethod varchar(255), sample varchar(255), sample_idx int4, primary key (topiaId));
|
| 83 | 83 |
create table OBSERVE_LONGLINE.sectionObs (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, settingIdentifier int4 not null, haulingIdentifier int4, set varchar(255), primary key (topiaId));
|
| 84 | 84 |
create table OBSERVE_LONGLINE.sensorBrand (topiaId varchar(255) not null, topiaVersion int8 not null, topiaCreateDate timestamp, lastUpdateDate timestamp not null, code varchar(255), uri varchar(255), needComment boolean not null, status int4, brandName varchar(255), primary key (topiaId));
|