Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

27 changed files:

Changes:

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
    ... ... @@ -484,6 +484,10 @@ public class ContentOpen<U extends ContentUI> {
    484 484
             }
    
    485 485
         }
    
    486 486
     
    
    487
    +    public ArrayListMultimap<ContentUI, JComponent> getConfigureActions() {
    
    488
    +        return configureActions;
    
    489
    +    }
    
    490
    +
    
    487 491
         public final <D extends DataDto, C extends ContainerChildDto, SubUi extends ContentTableUI<D, C, SubUi>> void initTabUI(SubUi subUi, JPanel subUiPane, int tabIndex, Consumer<D> dataConsumer) {
    
    488 492
             subUiMap.put(subUi, subUiPane);
    
    489 493
             subUiPane.remove(subUi);
    

  • client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
    ... ... @@ -376,6 +376,48 @@ public abstract class ContentTableUITableModel<D extends DataDto, C extends Cont
    376 376
             changeSelectedRow(viewRow);
    
    377 377
         }
    
    378 378
     
    
    379
    +    public final void addNewEntry(C bean) {
    
    380
    +        ensureEditable();
    
    381
    +
    
    382
    +        int selectedRow = getSelectedRow();
    
    383
    +        if (selectedRow > -1) {
    
    384
    +            // il y avait une ligne précédemment sélectionnée,
    
    385
    +            // on doit verifier que l'on peut changer d'entrée
    
    386
    +            if (!isCanQuitEditingRow()) {
    
    387
    +                // on ne peut pas quitter la ligne en cours d'édition
    
    388
    +                // on annule donc l'opération
    
    389
    +                return;
    
    390
    +            }
    
    391
    +        }
    
    392
    +        // on est autorise a ajouter une nouvelle entrée
    
    393
    +        // hook before changing row
    
    394
    +        // FIXME I am not quite sure of this flow, should not it be managed another way, somewhere else?
    
    395
    +        onBeforeAddNewEntry(selectedRow);
    
    396
    +
    
    397
    +        int row = getRowCount();
    
    398
    +
    
    399
    +        data.add(bean);
    
    400
    +        if (getModel().getStates().isWithIndex()) {
    
    401
    +            ((WithIndex) bean).setIndex(getRowCount());
    
    402
    +        }
    
    403
    +
    
    404
    +        updateBeanList(false);
    
    405
    +
    
    406
    +        this.create = true;
    
    407
    +        fireTableRowsInserted(row, row);
    
    408
    +        this.create = false;
    
    409
    +
    
    410
    +        int viewRow = getContext().getTable().convertRowIndexToView(row);
    
    411
    +
    
    412
    +        updateEmpty();
    
    413
    +
    
    414
    +        // on est en mode creation
    
    415
    +        setCreate(true);
    
    416
    +
    
    417
    +        // la nouvelle ligne est celle en cours d'édition
    
    418
    +        changeSelectedRow(viewRow);
    
    419
    +    }
    
    420
    +
    
    379 421
         protected String getDeleteExtraMessage(C bean) {
    
    380 422
             return null;
    
    381 423
         }
    

  • client/datasource/editor/ps/src/main/i18n/getters/java.getter
    ... ... @@ -21,10 +21,14 @@ observe.data.ps.dcp.FloatingObjectPreset.reloadDefaultConfiguration.title
    21 21
     observe.data.ps.localmarket.Batch.weight.computed.tip
    
    22 22
     observe.data.ps.localmarket.Batch.weight.observed.tip
    
    23 23
     observe.data.ps.logbook.Activity.create.title
    
    24
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell
    
    25
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip
    
    24 26
     observe.data.ps.logbook.Sample.notSuperSample.with.moreThanOne.sampleSpecies.message
    
    25 27
     observe.data.ps.logbook.Sample.notSuperSample.with.moreThanOne.sampleSpecies.title
    
    26 28
     observe.data.ps.logbook.SampleActivity.weightedWeightComputed.computed.tip
    
    27 29
     observe.data.ps.logbook.SampleActivity.weightedWeightComputed.observed.tip
    
    30
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample
    
    31
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip
    
    28 32
     observe.data.ps.logbook.WellPlan.create.activity.tip
    
    29 33
     observe.data.ps.observation.Catch.catchWeightComputed.computed.tip
    
    30 34
     observe.data.ps.observation.Catch.catchWeightComputed.observed.tip
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleActivityTableModel.java
    ... ... @@ -189,7 +189,7 @@ public class SampleActivityTableModel extends EditableTableModel<SampleActivityD
    189 189
         }
    
    190 190
     
    
    191 191
         @Override
    
    192
    -    protected SampleActivityDto createNewRow() {
    
    192
    +    public SampleActivityDto createNewRow() {
    
    193 193
             return SampleActivityDto.newDto(new Date());
    
    194 194
         }
    
    195 195
     
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUI.jaxx
    ... ... @@ -167,4 +167,5 @@
    167 167
         </JTabbedPane>
    
    168 168
       </JPanel>
    
    169 169
       <JMenuItem id='addSampleSpecies'/>
    
    170
    +  <JMenuItem id='fillActivitiesFromWell'/>
    
    170 171
     </fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI>

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIHandler.java
    ... ... @@ -23,8 +23,10 @@ package fr.ird.observe.client.datasource.editor.ps.data.logbook;
    23 23
      */
    
    24 24
     
    
    25 25
     
    
    26
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.actions.AddActivitiesFromWell;
    
    26 27
     import fr.ird.observe.client.util.UIHelper;
    
    27 28
     import fr.ird.observe.dto.data.ps.logbook.SampleDto;
    
    29
    +import fr.ird.observe.dto.form.Form;
    
    28 30
     
    
    29 31
     import java.beans.PropertyChangeEvent;
    
    30 32
     import java.beans.PropertyVetoException;
    
    ... ... @@ -59,6 +61,13 @@ public class SampleUIHandler extends GeneratedSampleUIHandler {
    59 61
             super.startEditUI();
    
    60 62
         }
    
    61 63
     
    
    64
    +    @Override
    
    65
    +    protected void installMoveAction() {
    
    66
    +        super.installMoveAction();
    
    67
    +        // We install the action here to be at proper order in configure menu
    
    68
    +        AddActivitiesFromWell.installAction(ui);
    
    69
    +    }
    
    70
    +
    
    62 71
         private void onSuperSampleChanged(PropertyChangeEvent event) throws PropertyVetoException {
    
    63 72
             boolean oldValue = (boolean) event.getOldValue();
    
    64 73
             boolean newValue = (boolean) event.getNewValue();
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIModelStates.java
    ... ... @@ -36,21 +36,29 @@ import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    36 36
     
    
    37 37
     import java.beans.PropertyVetoException;
    
    38 38
     import java.util.List;
    
    39
    +import java.util.Set;
    
    39 40
     
    
    40 41
     @GenerateJavaBeanDefinition
    
    41 42
     public class SampleUIModelStates extends GeneratedSampleUIModelStates {
    
    42 43
     
    
    43 44
         private final SampleActivityTableModel sampleActivityTableModel;
    
    45
    +    private final Set<String> availableWellInTrip;
    
    44 46
     
    
    45 47
         public SampleUIModelStates(GeneratedSampleUIModel model) {
    
    46 48
             super(model);
    
    47 49
             this.sampleActivityTableModel = new SampleActivityTableModel(this);
    
    50
    +        String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
    
    51
    +        this.availableWellInTrip = getReferenceCache().getDataSource().getPsCommonTripService().getLogbookWellIdsFromWellPlan(tripId);
    
    48 52
         }
    
    49 53
     
    
    50 54
         public SampleActivityTableModel getSampleActivityTableModel() {
    
    51 55
             return sampleActivityTableModel;
    
    52 56
         }
    
    53 57
     
    
    58
    +    public boolean isWellInTrip(String well) {
    
    59
    +        return availableWellInTrip.contains(well);
    
    60
    +    }
    
    61
    +
    
    54 62
         public boolean isSuperSample() {
    
    55 63
             return getBean().isSuperSample();
    
    56 64
         }
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellActivityUITableModel.java
    ... ... @@ -103,4 +103,5 @@ public class WellActivityUITableModel extends GeneratedWellActivityUITableModel
    103 103
             values.removeAll(columnValues);
    
    104 104
             editor.setData(values);
    
    105 105
         }
    
    106
    +
    
    106 107
     }

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUI.jaxx
    ... ... @@ -115,4 +115,5 @@
    115 115
       <Object id="delegateContentUI" initializer="mainTabbedPane"/>
    
    116 116
       <WellActivityUIModelStates id='wellActivityStates' initializer="wellActivityUI.getModel().getStates()"/>
    
    117 117
       <JButton id='save'/>
    
    118
    +  <JMenuItem id='fillActivitiesFromSample'/>
    
    118 119
     </fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI>

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUIHandler.java
    ... ... @@ -33,6 +33,7 @@ import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.Sav
    33 33
     import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
    
    34 34
     import fr.ird.observe.client.datasource.editor.ps.data.common.TripLogbookUINavigationNode;
    
    35 35
     import fr.ird.observe.client.datasource.editor.ps.data.common.TripUINavigationNode;
    
    36
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.actions.AddActivitiesFromSample;
    
    36 37
     import fr.ird.observe.client.datasource.validation.ClientValidationContext;
    
    37 38
     import fr.ird.observe.client.util.init.DefaultUIInitializerResult;
    
    38 39
     import fr.ird.observe.datasource.security.ConcurrentModificationException;
    
    ... ... @@ -80,14 +81,21 @@ public class WellUIHandler extends GeneratedWellUIHandler {
    80 81
                     InputMap inputMap = ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    
    81 82
                     ActionMap actionMap = ui.getActionMap();
    
    82 83
     
    
    84
    +                AddActivitiesFromSample.installAction(ui);
    
    83 85
                     prefixAction(ui.getWellActivityUI().getDeleteEntry(), type);
    
    84 86
                     prefixAction(ui.getWellActivityUI().getShowTechnicalInformations(), type);
    
    87
    +                prefixAction(ui.getFillActivitiesFromSample(), type);
    
    85 88
                     registerInnerAction(ui.getWellActivityUI().getResetEntry(), inputMap, actionMap);
    
    86 89
                     registerInnerAction(ui.getWellActivityUI().getSaveEntry(), inputMap, actionMap);
    
    87 90
                     registerInnerAction(ui.getWellActivityUI().getSaveAndNewEntry(), inputMap, actionMap);
    
    88 91
     
    
    89 92
                     addConfigureActions(ui, false);
    
    90 93
                     initTabUI(ui.getWellActivityUI(), ui.getWellActivityPanel(), 1, d -> ui.getModel().getStates().getBean().setWellActivity(d.getWellActivity()));
    
    94
    +                getConfigureActions().remove(ui, ui.getFillActivitiesFromSample());
    
    95
    +                // Big hack to put at the good place the ui.getFillActivitiesFromSample() action in the menu
    
    96
    +                getConfigureActions().get(ui.getWellActivityUI()).remove(ui.getWellActivityUI().getShowTechnicalInformations());
    
    97
    +                getConfigureActions().put(ui.getWellActivityUI(), ui.getFillActivitiesFromSample());
    
    98
    +                getConfigureActions().put(ui.getWellActivityUI(), ui.getWellActivityUI().getShowTechnicalInformations());
    
    91 99
                     return result;
    
    92 100
                 }
    
    93 101
             };
    

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromSample.java
    1
    +package fr.ird.observe.client.datasource.editor.ps.data.logbook.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Client :: DataSource :: Editor :: PS
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2024 IRD, 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 com.google.common.collect.Maps;
    
    26
    +import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
    
    27
    +import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
    
    28
    +import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIModelStates;
    
    29
    +import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.ContentOpenableUIActionSupport;
    
    30
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUI;
    
    31
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUIModel;
    
    32
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUITableModel;
    
    33
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellUI;
    
    34
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellUIModelStates;
    
    35
    +import fr.ird.observe.dto.data.ps.logbook.ActivityStubDto;
    
    36
    +import fr.ird.observe.dto.data.ps.logbook.WellActivityDto;
    
    37
    +import fr.ird.observe.dto.data.ps.logbook.WellDto;
    
    38
    +import io.ultreia.java4all.i18n.I18n;
    
    39
    +import org.apache.logging.log4j.LogManager;
    
    40
    +import org.apache.logging.log4j.Logger;
    
    41
    +
    
    42
    +import java.awt.event.ActionEvent;
    
    43
    +import java.beans.PropertyChangeEvent;
    
    44
    +import java.util.List;
    
    45
    +import java.util.Map;
    
    46
    +import java.util.Set;
    
    47
    +import java.util.TreeMap;
    
    48
    +
    
    49
    +/**
    
    50
    + * Created at 01/09/2024.
    
    51
    + *
    
    52
    + * @author Tony Chemit - dev@tchemit.fr
    
    53
    + * @since 9.3.7
    
    54
    + */
    
    55
    +public class AddActivitiesFromSample extends ContentOpenableUIActionSupport<WellDto, WellUI> implements ConfigureMenuAction<WellUI> {
    
    56
    +
    
    57
    +    private static final Logger log = LogManager.getLogger(AddActivitiesFromSample.class);
    
    58
    +
    
    59
    +    public AddActivitiesFromSample() {
    
    60
    +        super(WellDto.class, I18n.n("observe.data.ps.logbook.Well.action.addActivitiesFromSample"), I18n.n("observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip"), "generate", ObserveKeyStrokesEditorApi.KEY_STROKE_GENERATE);
    
    61
    +    }
    
    62
    +
    
    63
    +    public static void installAction(WellUI ui) {
    
    64
    +        AddActivitiesFromSample action = new AddActivitiesFromSample();
    
    65
    +        ui.getModel().getStates().addPropertyChangeListener(ContentOpenableUIModelStates.PROPERTY_MODE, action::updateEnableState);
    
    66
    +        ui.getModel().getStates().getBean().addPropertyChangeListener(WellDto.PROPERTY_WELL, action::updateEnableState);
    
    67
    +        ui.getModel().getStates().getBean().addPropertyChangeListener(WellDto.PROPERTY_WELL_ACTIVITY, action::updateEnableState);
    
    68
    +        AddActivitiesFromSample.init(ui, ui.getFillActivitiesFromSample(), action);
    
    69
    +    }
    
    70
    +
    
    71
    +    @Override
    
    72
    +    protected void doActionPerformed(ActionEvent e, WellUI ui) {
    
    73
    +        WellUIModelStates states = ui.getModel().getStates();
    
    74
    +        WellDto bean = states.getBean();
    
    75
    +        String well = bean.getWell();
    
    76
    +        log.info("Will seek from activities for sample: {}", well);
    
    77
    +        WellActivityUI wellActivityUI = ui.getWellActivityUI();
    
    78
    +        WellActivityUITableModel tableModel = wellActivityUI.getTableModel();
    
    79
    +        WellActivityUIModel model = wellActivityUI.getModel();
    
    80
    +        List<ActivityStubDto> availableActivities = wellActivityUI.getModel().getStates().getActivity();
    
    81
    +        Map<String, ActivityStubDto> activitiesCache = new TreeMap<>(Maps.uniqueIndex(availableActivities, ActivityStubDto::getTopiaId));
    
    82
    +        String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
    
    83
    +        Set<String> logbookWellActivityFromSample = getServicesProvider().getPsCommonTripService().createLogbookWellActivityFromSample(tripId, well);
    
    84
    +        for (String activityId : logbookWellActivityFromSample) {
    
    85
    +            log.info("Create Well activity for activity: {}", activityId);
    
    86
    +            ActivityStubDto activity = activitiesCache.get(activityId);
    
    87
    +            WellActivityDto wellActivityDto = model.newTableEditBean();
    
    88
    +            wellActivityDto.setActivity(activity);
    
    89
    +            tableModel.addNewEntry(wellActivityDto);
    
    90
    +            wellActivityUI.getSaveEntry().setEnabled(true);
    
    91
    +            try {
    
    92
    +                wellActivityUI.getSaveEntry().doClick();
    
    93
    +            } finally {
    
    94
    +                wellActivityUI.getSaveEntry().setEnabled(false);
    
    95
    +            }
    
    96
    +        }
    
    97
    +    }
    
    98
    +
    
    99
    +    private void updateEnableState(PropertyChangeEvent evt) {
    
    100
    +        WellUIModelStates states = ui.getModel().getStates();
    
    101
    +        boolean readingMode = states.isReadingMode();
    
    102
    +        String well = states.getBean().getWell();
    
    103
    +        List<WellActivityDto> wellActivity = states.getBean().getWellActivity();
    
    104
    +        setEnabled(!readingMode && well != null && !well.isEmpty() && wellActivity.isEmpty());
    
    105
    +    }
    
    106
    +}

  • client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromWell.java
    1
    +package fr.ird.observe.client.datasource.editor.ps.data.logbook.actions;
    
    2
    +
    
    3
    +/*-
    
    4
    + * #%L
    
    5
    + * ObServe Client :: DataSource :: Editor :: PS
    
    6
    + * %%
    
    7
    + * Copyright (C) 2008 - 2024 IRD, 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 com.google.common.collect.Maps;
    
    26
    +import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
    
    27
    +import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
    
    28
    +import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIModelStates;
    
    29
    +import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.ContentOpenableUIActionSupport;
    
    30
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleActivityTableModel;
    
    31
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleUI;
    
    32
    +import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleUIModelStates;
    
    33
    +import fr.ird.observe.dto.data.ps.logbook.ActivityStubDto;
    
    34
    +import fr.ird.observe.dto.data.ps.logbook.SampleActivityDto;
    
    35
    +import fr.ird.observe.dto.data.ps.logbook.SampleDto;
    
    36
    +import io.ultreia.java4all.i18n.I18n;
    
    37
    +import org.apache.logging.log4j.LogManager;
    
    38
    +import org.apache.logging.log4j.Logger;
    
    39
    +
    
    40
    +import java.awt.event.ActionEvent;
    
    41
    +import java.beans.PropertyChangeEvent;
    
    42
    +import java.util.LinkedList;
    
    43
    +import java.util.List;
    
    44
    +import java.util.Map;
    
    45
    +import java.util.Set;
    
    46
    +import java.util.TreeMap;
    
    47
    +
    
    48
    +/**
    
    49
    + * Created at 01/09/2024.
    
    50
    + *
    
    51
    + * @author Tony Chemit - dev@tchemit.fr
    
    52
    + * @since 9.3.7
    
    53
    + */
    
    54
    +public class AddActivitiesFromWell extends ContentOpenableUIActionSupport<SampleDto, SampleUI> implements ConfigureMenuAction<SampleUI> {
    
    55
    +
    
    56
    +    private static final Logger log = LogManager.getLogger(AddActivitiesFromWell.class);
    
    57
    +
    
    58
    +    public AddActivitiesFromWell() {
    
    59
    +        super(SampleDto.class, I18n.n("observe.data.ps.logbook.Sample.action.addActivitiesFromWell"), I18n.n("observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip"), "generate", ObserveKeyStrokesEditorApi.KEY_STROKE_GENERATE);
    
    60
    +    }
    
    61
    +
    
    62
    +    public static void installAction(SampleUI ui) {
    
    63
    +        AddActivitiesFromWell action = new AddActivitiesFromWell();
    
    64
    +        ui.getModel().getStates().addPropertyChangeListener(ContentOpenableUIModelStates.PROPERTY_MODE, action::updateEnableState);
    
    65
    +        ui.getModel().getStates().getBean().addPropertyChangeListener(SampleDto.PROPERTY_WELL, action::updateEnableState);
    
    66
    +        ui.getModel().getStates().getBean().addPropertyChangeListener(SampleDto.PROPERTY_SAMPLE_ACTIVITY, action::updateEnableState);
    
    67
    +        AddActivitiesFromWell.init(ui, ui.getFillActivitiesFromWell(), action);
    
    68
    +    }
    
    69
    +
    
    70
    +    @Override
    
    71
    +    protected void doActionPerformed(ActionEvent e, SampleUI ui) {
    
    72
    +        SampleUIModelStates states = ui.getModel().getStates();
    
    73
    +        SampleDto bean = states.getBean();
    
    74
    +        String well = bean.getWell();
    
    75
    +        log.info("Will seek from activities from well: {}", well);
    
    76
    +        SampleActivityTableModel tableModel = states.getSampleActivityTableModel();
    
    77
    +        List<ActivityStubDto> availableActivities = tableModel.getActivities();
    
    78
    +        Map<String, ActivityStubDto> activitiesCache = new TreeMap<>(Maps.uniqueIndex(availableActivities, ActivityStubDto::getTopiaId));
    
    79
    +        String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
    
    80
    +        Set<String> logbookSampleActivityFromWellPlan = getServicesProvider().getPsCommonTripService().createLogbookSampleActivityFromWellPlan(tripId, well);
    
    81
    +        List<SampleActivityDto> sampleActivities = new LinkedList<>();
    
    82
    +        for (String activityId  : logbookSampleActivityFromWellPlan) {
    
    83
    +            log.info("Create Sample activity for activity: {}", activityId);
    
    84
    +            ActivityStubDto activity = activitiesCache.get(activityId);
    
    85
    +            SampleActivityDto sampleActivityDto = tableModel.createNewRow();
    
    86
    +            sampleActivityDto.setActivity(activity);
    
    87
    +            sampleActivityDto.setWeightedWeight(null);
    
    88
    +            sampleActivityDto.setWeightedWeightComputed(false);
    
    89
    +            sampleActivities.add(sampleActivityDto);
    
    90
    +        }
    
    91
    +        bean.setSampleActivity(sampleActivities);
    
    92
    +        tableModel.setData(sampleActivities);
    
    93
    +    }
    
    94
    +
    
    95
    +    private void updateEnableState(PropertyChangeEvent evt) {
    
    96
    +        SampleUIModelStates states = ui.getModel().getStates();
    
    97
    +        boolean readingMode = states.isReadingMode();
    
    98
    +        String well = states.getBean().getWell();
    
    99
    +        List<SampleActivityDto> sampleActivity = states.getBean().getSampleActivity();
    
    100
    +        setEnabled(!readingMode && well != null && !well.isEmpty() && states.isWellInTrip(well.trim()) && sampleActivity.isEmpty());
    
    101
    +    }
    
    102
    +}

  • core/api/dto-decoration/src/main/i18n/getters/labels.getter
    ... ... @@ -977,6 +977,8 @@ observe.data.ps.logbook.Route.navigation.unsaved
    977 977
     observe.data.ps.logbook.Route.timeAtSea
    
    978 978
     observe.data.ps.logbook.Route.title
    
    979 979
     observe.data.ps.logbook.Route.type
    
    980
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell
    
    981
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip
    
    980 982
     observe.data.ps.logbook.Sample.action.create
    
    981 983
     observe.data.ps.logbook.Sample.action.move
    
    982 984
     observe.data.ps.logbook.Sample.action.move.choose.parent.message
    
    ... ... @@ -1026,6 +1028,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type
    1026 1028
     observe.data.ps.logbook.TransmittingBuoy.code
    
    1027 1029
     observe.data.ps.logbook.TransmittingBuoy.country
    
    1028 1030
     observe.data.ps.logbook.TransmittingBuoy.type
    
    1031
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample
    
    1032
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip
    
    1029 1033
     observe.data.ps.logbook.Well.action.create
    
    1030 1034
     observe.data.ps.logbook.Well.action.move
    
    1031 1035
     observe.data.ps.logbook.Well.action.move.choose.parent.message
    

  • core/api/services/src/main/java/fr/ird/observe/services/service/data/ps/common/TripService.java
    ... ... @@ -32,9 +32,11 @@ import fr.ird.observe.services.service.MethodCredential;
    32 32
     import fr.ird.observe.services.service.data.TripAwareService;
    
    33 33
     import io.ultreia.java4all.http.spi.Get;
    
    34 34
     import io.ultreia.java4all.http.spi.Nullable;
    
    35
    +import io.ultreia.java4all.http.spi.Post;
    
    35 36
     import io.ultreia.java4all.http.spi.Service;
    
    36 37
     
    
    37 38
     import java.util.List;
    
    39
    +import java.util.Set;
    
    38 40
     
    
    39 41
     /**
    
    40 42
      * Created on 26/07/2021.
    
    ... ... @@ -57,6 +59,40 @@ public interface TripService extends TripAwareService {
    57 59
         @MethodCredential(Permission.READ_DATA)
    
    58 60
         List<ActivityStubDto> getLogbookWellPlanActivities(String tripId);
    
    59 61
     
    
    62
    +    /**
    
    63
    +     * @param tripId selected trip id
    
    64
    +     * @return the set of {@code Well#well} used in the well plan of selected trip
    
    65
    +     */
    
    66
    +    @Get
    
    67
    +    @MethodCredential(Permission.READ_DATA)
    
    68
    +    Set<String> getLogbookWellIdsFromWellPlan(String tripId);
    
    69
    +
    
    70
    +    /**
    
    71
    +     * @param tripId selected trip id
    
    72
    +     * @param wellId selected well id
    
    73
    +     * @return the set of activity ids found in well plan for selected trip and well
    
    74
    +     */
    
    75
    +    @Post
    
    76
    +    @MethodCredential(Permission.READ_DATA)
    
    77
    +    Set<String> createLogbookSampleActivityFromWellPlan(String tripId, String wellId);
    
    78
    +
    
    79
    +    /**
    
    80
    +     * @param tripId selected trip id
    
    81
    +     * @return the set of {@code Well#well} used in the sample of the selected trip
    
    82
    +     */
    
    83
    +    @Get
    
    84
    +    @MethodCredential(Permission.READ_DATA)
    
    85
    +    Set<String> getLogbookWellIdsFromSample(String tripId);
    
    86
    +
    
    87
    +    /**
    
    88
    +     * @param tripId selected trip id
    
    89
    +     * @param wellId selected well id
    
    90
    +     * @return the set of activity ids found in sample for selected trip and well
    
    91
    +     */
    
    92
    +    @Post
    
    93
    +    @MethodCredential(Permission.READ_DATA)
    
    94
    +    Set<String> createLogbookWellActivityFromSample(String tripId, String wellId);
    
    95
    +
    
    60 96
         @Get
    
    61 97
         @MethodCredential(Permission.READ_DATA)
    
    62 98
         boolean isActivityEndOfSearchFound(String routeId);
    

  • core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java
    ... ... @@ -42,6 +42,10 @@ import fr.ird.observe.entities.data.DataEntity;
    42 42
     import fr.ird.observe.entities.data.ps.landing.Landing;
    
    43 43
     import fr.ird.observe.entities.data.ps.logbook.Activity;
    
    44 44
     import fr.ird.observe.entities.data.ps.logbook.Route;
    
    45
    +import fr.ird.observe.entities.data.ps.logbook.Sample;
    
    46
    +import fr.ird.observe.entities.data.ps.logbook.SampleActivity;
    
    47
    +import fr.ird.observe.entities.data.ps.logbook.Well;
    
    48
    +import fr.ird.observe.entities.data.ps.logbook.WellActivity;
    
    45 49
     import fr.ird.observe.entities.referential.common.DataQuality;
    
    46 50
     import fr.ird.observe.entities.referential.common.Ocean;
    
    47 51
     import fr.ird.observe.entities.referential.common.Species;
    
    ... ... @@ -62,6 +66,7 @@ import java.util.List;
    62 66
     import java.util.Map;
    
    63 67
     import java.util.Objects;
    
    64 68
     import java.util.Set;
    
    69
    +import java.util.function.BiFunction;
    
    65 70
     import java.util.function.Consumer;
    
    66 71
     import java.util.function.Function;
    
    67 72
     import java.util.stream.Stream;
    
    ... ... @@ -380,4 +385,41 @@ public class TripSpi extends GeneratedTripSpi {
    380 385
             lastUpdateDates.add(fr.ird.observe.entities.data.ps.localmarket.SurveyPart.class);
    
    381 386
         }
    
    382 387
     
    
    388
    +    public Set<String> getLogbookWellIdsFromWellPlan(ServiceContext context, String tripId) {
    
    389
    +        return Trip.getDao(context).getLogbookWellIdsFromWellPlan(tripId);
    
    390
    +    }
    
    391
    +
    
    392
    +    public Set<String> getLogbookWellIdsFromSample(ServiceContext context, String tripId) {
    
    393
    +        return Trip.getDao(context).getLogbookWellIdsFromSample(tripId);
    
    394
    +    }
    
    395
    +
    
    396
    +    public Set<String> createLogbookSampleActivityFromWellPlan(ServiceContext context, String tripId, String wellId) {
    
    397
    +        Trip trip = loadEntity(context, tripId);
    
    398
    +        Set<String> result = new LinkedHashSet<>();
    
    399
    +        for (Well well : trip.getWell()) {
    
    400
    +            if (!well.getWell().equals(wellId)) {
    
    401
    +                continue;
    
    402
    +            }
    
    403
    +            for (WellActivity wellActivity : well.getWellActivity()) {
    
    404
    +                Activity activity = wellActivity.getActivity();
    
    405
    +                result.add(activity.getId());
    
    406
    +            }
    
    407
    +        }
    
    408
    +        return result;
    
    409
    +    }
    
    410
    +
    
    411
    +    public Set<String> createLogbookWellActivityFromSample(ServiceContext context, String tripId, String wellId) {
    
    412
    +        Set<String> result = new LinkedHashSet<>();
    
    413
    +        Trip trip = loadEntity(context, tripId);
    
    414
    +        for (Sample sample : trip.getSample()) {
    
    415
    +            if (!sample.getWell().equals(wellId)) {
    
    416
    +                continue;
    
    417
    +            }
    
    418
    +            for (SampleActivity sampleActivity : sample.getSampleActivity()) {
    
    419
    +                result.add(sampleActivity.getActivity().getId());
    
    420
    +            }
    
    421
    +        }
    
    422
    +
    
    423
    +        return result;
    
    424
    +    }
    
    383 425
     }

  • core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java
    ... ... @@ -44,6 +44,7 @@ import java.sql.Timestamp;
    44 44
     import java.util.LinkedHashSet;
    
    45 45
     import java.util.List;
    
    46 46
     import java.util.Map;
    
    47
    +import java.util.Set;
    
    47 48
     import java.util.function.Consumer;
    
    48 49
     import java.util.function.Function;
    
    49 50
     
    
    ... ... @@ -68,6 +69,22 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> {
    68 69
             return findMultipleResultBySqlQuery(queryLogbookWellPlanActivities(tripId), s -> toActivityStubDto(s, vesselActivities));
    
    69 70
         }
    
    70 71
     
    
    72
    +    public Set<String> getLogbookWellIdsFromWellPlan(String tripId) {
    
    73
    +        return Set.copyOf(findMultipleResultBySqlQuery(queryLogbookWellIdsFromWellPlan(tripId)));
    
    74
    +    }
    
    75
    +
    
    76
    +    public Set<String> getLogbookActivityIdsFromWellPlan(String tripId, String wellId) {
    
    77
    +        return new LinkedHashSet<>(findMultipleResultBySqlQuery(queryLogbookActivityIdsFromWellPlan(tripId, wellId)));
    
    78
    +    }
    
    79
    +
    
    80
    +    public Set<String> getLogbookWellIdsFromSample(String tripId) {
    
    81
    +        return Set.copyOf(findMultipleResultBySqlQuery(queryLogbookWellIdsFromSample(tripId)));
    
    82
    +    }
    
    83
    +
    
    84
    +    public Set<String> getLogbookActivityIdsFromSample(String tripId, String wellId) {
    
    85
    +        return new LinkedHashSet<>(findMultipleResultBySqlQuery(queryLogbookActivityIdsFromSample(tripId, wellId)));
    
    86
    +    }
    
    87
    +
    
    71 88
         public boolean isActivitiesAcquisitionModeByTimeEnabled(String tripId) {
    
    72 89
             return this.<Number>findSingleResultBySqlQuery(queryIsActivitiesAcquisitionModeByTimeEnabled(tripId)).intValue() == 0;
    
    73 90
         }
    

  • core/persistence/java/src/main/resources/fr/ird/observe/entities/data/ps/common/TripImpl.hbm.xml
    ... ... @@ -228,6 +228,26 @@
    228 228
         FROM ps_logbook.Route r
    
    229 229
         INNER JOIN ps_logbook.Activity a ON a.route = r.topiaId
    
    230 230
         WHERE r.trip = ? AND a.time IS NULL
    
    231
    +]]></sql-query>
    
    232
    +    <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityIdsFromSample" read-only="true"
    
    233
    +               comment="Get all logbook activity ids from samples filtered on a Sample.well">
    
    234
    +        <query-param name="tripId" type="java.lang.String"/>
    
    235
    +        <query-param name="wellId" type="java.lang.String"/><![CDATA[
    
    236
    +    SELECT
    
    237
    +    DISTINCT(sa.activity)
    
    238
    +    FROM ps_logbook.Sample s
    
    239
    +    INNER JOIN ps_logbook.sampleActivity sa ON sa.sample = s.topiaId
    
    240
    +    WHERE s.trip = ? AND s.well = ?
    
    241
    +]]></sql-query>
    
    242
    +    <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityIdsFromWellPlan" read-only="true"
    
    243
    +               comment="Get all logbook activity ids from well plan filtered on a trip and a Well.well">
    
    244
    +        <query-param name="tripId" type="java.lang.String"/>
    
    245
    +        <query-param name="wellId" type="java.lang.String"/><![CDATA[
    
    246
    +    SELECT
    
    247
    +    DISTINCT(wa.activity)
    
    248
    +    FROM ps_logbook.well w
    
    249
    +    INNER JOIN ps_logbook.wellActivity wa ON wa.well = w.topiaId
    
    250
    +    WHERE w.trip = ? AND w.well = ?
    
    231 251
     ]]></sql-query>
    
    232 252
         <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityPoint" read-only="true"
    
    233 253
                    comment="Get logbook activity points">
    
    ... ... @@ -274,6 +294,22 @@
    274 294
         INNER JOIN ps_logbook.transmittingBuoy t ON t.floatingObject = f.topiaId
    
    275 295
         WHERE r.trip = ? AND t.latitude IS NOT NULL AND t.longitude IS NOT NULL
    
    276 296
         ORDER BY r.date, a.time
    
    297
    +]]></sql-query>
    
    298
    +    <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellIdsFromSample" read-only="true"
    
    299
    +               comment="Get all logbook well ids from samples">
    
    300
    +        <query-param name="tripId" type="java.lang.String"/><![CDATA[
    
    301
    +    SELECT
    
    302
    +    DISTINCT(s.well)
    
    303
    +    FROM ps_logbook.Sample s
    
    304
    +    WHERE s.trip = ?
    
    305
    +]]></sql-query>
    
    306
    +    <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellIdsFromWellPlan" read-only="true"
    
    307
    +               comment="Get all logbook well ids from well plan">
    
    308
    +        <query-param name="tripId" type="java.lang.String"/><![CDATA[
    
    309
    +    SELECT
    
    310
    +    DISTINCT(w.well)
    
    311
    +    FROM ps_logbook.well w
    
    312
    +    WHERE w.trip = ?
    
    277 313
     ]]></sql-query>
    
    278 314
         <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellPlanActivities" read-only="true"
    
    279 315
                    comment="Get all logbook well plan activities for the given trip">
    

  • core/persistence/test/src/test/java/fr/ird/observe/entities/data/ps/common/TripTopiaDaoTest.java
    ... ... @@ -42,6 +42,7 @@ import java.util.LinkedHashSet;
    42 42
     import java.util.List;
    
    43 43
     import java.util.Locale;
    
    44 44
     import java.util.Map;
    
    45
    +import java.util.Set;
    
    45 46
     import java.util.function.Function;
    
    46 47
     import java.util.stream.Collectors;
    
    47 48
     
    
    ... ... @@ -64,7 +65,7 @@ public class TripTopiaDaoTest extends PersistenceTestSupportRead {
    64 65
     
    
    65 66
         @Test
    
    66 67
         public void loadSqlQueries() {
    
    67
    -        ObservePersistenceFixtures.assertSqlQueries(Trip.class, 19);
    
    68
    +        ObservePersistenceFixtures.assertSqlQueries(Trip.class, 23);
    
    68 69
         }
    
    69 70
     
    
    70 71
         @Test
    
    ... ... @@ -122,6 +123,42 @@ public class TripTopiaDaoTest extends PersistenceTestSupportRead {
    122 123
             }
    
    123 124
         }
    
    124 125
     
    
    126
    +    @Test
    
    127
    +    public void getLogbookWellIdsFromSample() {
    
    128
    +        try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
    
    129
    +            Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookWellIdsFromSample(tripId);
    
    130
    +            Assert.assertNotNull(actual);
    
    131
    +            Assert.assertEquals(1, actual.size());
    
    132
    +        }
    
    133
    +    }
    
    134
    +
    
    135
    +    @Test
    
    136
    +    public void getLogbookWellIdsFromWellPlan() {
    
    137
    +        try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
    
    138
    +            Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookWellIdsFromWellPlan(tripId);
    
    139
    +            Assert.assertNotNull(actual);
    
    140
    +            Assert.assertEquals(1, actual.size());
    
    141
    +        }
    
    142
    +    }
    
    143
    +
    
    144
    +    @Test
    
    145
    +    public void getLogbookActivityIdsFromWellPlan() {
    
    146
    +        try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
    
    147
    +            Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookActivityIdsFromWellPlan(tripId, "3T");
    
    148
    +            Assert.assertNotNull(actual);
    
    149
    +            Assert.assertEquals(1, actual.size());
    
    150
    +        }
    
    151
    +    }
    
    152
    +
    
    153
    +    @Test
    
    154
    +    public void getLogbookActivityIdsFromSample() {
    
    155
    +        try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
    
    156
    +            Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookActivityIdsFromSample(tripId, "3T");
    
    157
    +            Assert.assertNotNull(actual);
    
    158
    +            Assert.assertEquals(1, actual.size());
    
    159
    +        }
    
    160
    +    }
    
    161
    +
    
    125 162
         @Test
    
    126 163
         public void buildMap() {
    
    127 164
             try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
    

  • core/services/i18n/src/main/i18n/translations/services_en_GB.properties
    ... ... @@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Route
    1205 1205
     observe.data.ps.logbook.Route.type=Route
    
    1206 1206
     observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=Date (%2$s) must be after trip start date (%1$s).
    
    1207 1207
     observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=Date (%1$s) must be before trip end date (%2$s).
    
    1208
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Add activities from well
    
    1209
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Add activities from well
    
    1208 1210
     observe.data.ps.logbook.Sample.action.create=Next sample
    
    1209 1211
     observe.data.ps.logbook.Sample.action.move=Change trip
    
    1210 1212
     observe.data.ps.logbook.Sample.action.move.choose.parent.message=Select target trip
    
    ... ... @@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Sample species measure
    1263 1265
     observe.data.ps.logbook.TransmittingBuoy.code=Code
    
    1264 1266
     observe.data.ps.logbook.TransmittingBuoy.country=Flag country
    
    1265 1267
     observe.data.ps.logbook.TransmittingBuoy.type=Transmitting buoy
    
    1268
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample=Add activities from samples
    
    1269
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Add activities from samples
    
    1266 1270
     observe.data.ps.logbook.Well.action.create=Next well
    
    1267 1271
     observe.data.ps.logbook.Well.action.move=Change trip
    
    1268 1272
     observe.data.ps.logbook.Well.action.move.choose.parent.message=Select target trip
    

  • core/services/i18n/src/main/i18n/translations/services_es_ES.properties
    ... ... @@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Ruta
    1205 1205
     observe.data.ps.logbook.Route.type=Ruta
    
    1206 1206
     observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=El día de observación (%2$s) debe ser superior o igual a la fecha de comienzo de marea (%1$s).
    
    1207 1207
     observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=Date (%1$s) must be before trip end date (%2$s).
    
    1208
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Add activities from well \#TODO
    
    1209
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Add activities from well \#TODO
    
    1208 1210
     observe.data.ps.logbook.Sample.action.create=Next sample \#TODO
    
    1209 1211
     observe.data.ps.logbook.Sample.action.move=Change trip
    
    1210 1212
     observe.data.ps.logbook.Sample.action.move.choose.parent.message=Select target trip
    
    ... ... @@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Sample species measure
    1263 1265
     observe.data.ps.logbook.TransmittingBuoy.code=Identificación
    
    1264 1266
     observe.data.ps.logbook.TransmittingBuoy.country=Bandera
    
    1265 1267
     observe.data.ps.logbook.TransmittingBuoy.type=TransmittingBuoy
    
    1268
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample=Add activities from samples \#TODO
    
    1269
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Add activities from samples \#TODO
    
    1266 1270
     observe.data.ps.logbook.Well.action.create=Next well
    
    1267 1271
     observe.data.ps.logbook.Well.action.move=Change trip
    
    1268 1272
     observe.data.ps.logbook.Well.action.move.choose.parent.message=Select target trip
    

  • core/services/i18n/src/main/i18n/translations/services_fr_FR.properties
    ... ... @@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Route
    1205 1205
     observe.data.ps.logbook.Route.type=Route
    
    1206 1206
     observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=Le jour d'observation (%2$s) doit être supérieure ou égale à la date de début de la marée (%1$s).
    
    1207 1207
     observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=La date (%1$s) doit être inférieure ou égale à la date de fin de marée (%2$s).
    
    1208
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Récupérer les activités
    
    1209
    +observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Récupérer les activités depuis le plan de cuve
    
    1208 1210
     observe.data.ps.logbook.Sample.action.create=Échantillon suivant
    
    1209 1211
     observe.data.ps.logbook.Sample.action.move=Changer de marée
    
    1210 1212
     observe.data.ps.logbook.Sample.action.move.choose.parent.message=À quelle marée voulez-vous associer les échantillons sélectionnés ?
    
    ... ... @@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Mesure d'un échantillon espè
    1263 1265
     observe.data.ps.logbook.TransmittingBuoy.code=Identifiant
    
    1264 1266
     observe.data.ps.logbook.TransmittingBuoy.country=Pavillon
    
    1265 1267
     observe.data.ps.logbook.TransmittingBuoy.type=Balise émettrice
    
    1268
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample=Déduire les activités
    
    1269
    +observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Déduire les activités depuis les échantillons
    
    1266 1270
     observe.data.ps.logbook.Well.action.create=Cuve suivante
    
    1267 1271
     observe.data.ps.logbook.Well.action.move=Changer de marée
    
    1268 1272
     observe.data.ps.logbook.Well.action.move.choose.parent.message=À quelle marée voulez-vous associer les cuves sélectionnées ?
    

  • core/services/local/src/main/java/fr/ird/observe/services/local/service/data/ps/common/TripServiceLocalSupport.java
    ... ... @@ -38,6 +38,7 @@ import fr.ird.observe.services.service.data.ps.common.TripService;
    38 38
     import java.util.Date;
    
    39 39
     import java.util.LinkedHashSet;
    
    40 40
     import java.util.List;
    
    41
    +import java.util.Set;
    
    41 42
     
    
    42 43
     /**
    
    43 44
      * Created on 26/07/2021.
    
    ... ... @@ -82,6 +83,26 @@ public abstract class TripServiceLocalSupport extends ObserveServiceLocal implem
    82 83
             return Trip.SPI.getLogbookWellPlanActivities(this, tripId);
    
    83 84
         }
    
    84 85
     
    
    86
    +    @Override
    
    87
    +    public Set<String> getLogbookWellIdsFromWellPlan(String tripId) {
    
    88
    +        return Trip.SPI.getLogbookWellIdsFromWellPlan(this, tripId);
    
    89
    +    }
    
    90
    +
    
    91
    +    @Override
    
    92
    +    public Set<String> createLogbookSampleActivityFromWellPlan(String tripId, String wellId) {
    
    93
    +        return Trip.SPI.createLogbookSampleActivityFromWellPlan(this, tripId, wellId);
    
    94
    +    }
    
    95
    +
    
    96
    +    @Override
    
    97
    +    public Set<String> createLogbookWellActivityFromSample(String tripId, String wellId) {
    
    98
    +        return Trip.SPI.createLogbookWellActivityFromSample(this, tripId, wellId);
    
    99
    +    }
    
    100
    +
    
    101
    +    @Override
    
    102
    +    public Set<String> getLogbookWellIdsFromSample(String tripId) {
    
    103
    +        return Trip.SPI.getLogbookWellIdsFromSample(this, tripId);
    
    104
    +    }
    
    105
    +
    
    85 106
         @Override
    
    86 107
         public boolean isActivityEndOfSearchFound(String routeId) {
    
    87 108
             return Trip.SPI.isActivityEndOfSearchFound(this, routeId);
    

  • core/services/test/src/main/java/fr/ird/observe/services/service/data/ps/common/TripServiceFixtures.java
    ... ... @@ -41,6 +41,7 @@ import fr.ird.observe.services.service.data.RootOpenableServiceFixtures;
    41 41
     import org.junit.Assert;
    
    42 42
     
    
    43 43
     import java.util.List;
    
    44
    +import java.util.Map;
    
    44 45
     import java.util.Set;
    
    45 46
     
    
    46 47
     public class TripServiceFixtures extends GeneratedTripServiceFixtures {
    
    ... ... @@ -170,4 +171,38 @@ public class TripServiceFixtures extends GeneratedTripServiceFixtures {
    170 171
             Assert.assertNotNull(actual.getObject().getId());
    
    171 172
             Assert.assertEquals(tripId, actual.getObject().getId());
    
    172 173
         }
    
    174
    +
    
    175
    +    @Override
    
    176
    +    public void getLogbookWellIdsFromSample(ObserveServicesProvider servicesProvider, TripService service) {
    
    177
    +        String tripId = getProperty("getLogbookWellIdsFromSample.tripId");
    
    178
    +        Set<String> actual = service.getLogbookWellIdsFromSample(tripId);
    
    179
    +        Assert.assertNotNull(actual);
    
    180
    +        Assert.assertEquals(getIntegerProperty("getLogbookWellIdsFromSample.count"), actual.size());
    
    181
    +    }
    
    182
    +
    
    183
    +    @Override
    
    184
    +    public void getLogbookWellIdsFromWellPlan(ObserveServicesProvider servicesProvider, TripService service) {
    
    185
    +        String tripId = getProperty("getLogbookWellIdsFromWellPlan.tripId");
    
    186
    +        Set<String> actual = service.getLogbookWellIdsFromWellPlan(tripId);
    
    187
    +        Assert.assertNotNull(actual);
    
    188
    +        Assert.assertEquals(getIntegerProperty("getLogbookWellIdsFromWellPlan.count"), actual.size());
    
    189
    +    }
    
    190
    +
    
    191
    +    @Override
    
    192
    +    public void createLogbookSampleActivityFromWellPlan(ObserveServicesProvider servicesProvider, TripService service) {
    
    193
    +        String tripId = getProperty("createLogbookSampleActivityFromWellPlan.tripId");
    
    194
    +        String wellId = getProperty("createLogbookSampleActivityFromWellPlan.wellId");
    
    195
    +        Set<String> actual = service.createLogbookSampleActivityFromWellPlan(tripId, wellId);
    
    196
    +        Assert.assertNotNull(actual);
    
    197
    +        Assert.assertEquals(getIntegerProperty("createLogbookSampleActivityFromWellPlan.count"), actual.size());
    
    198
    +    }
    
    199
    +
    
    200
    +    @Override
    
    201
    +    public void createLogbookWellActivityFromSample(ObserveServicesProvider servicesProvider, TripService service) {
    
    202
    +        String tripId = getProperty("createLogbookWellActivityFromSample.tripId");
    
    203
    +        String wellId = getProperty("createLogbookWellActivityFromSample.wellId");
    
    204
    +        Set<String> actual = service.createLogbookWellActivityFromSample(tripId, wellId);
    
    205
    +        Assert.assertNotNull(actual);
    
    206
    +        Assert.assertEquals(getIntegerProperty("createLogbookWellActivityFromSample.count"), actual.size());
    
    207
    +    }
    
    173 208
     }

  • core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/data/ps/common/TripService.properties
    ... ... @@ -19,6 +19,12 @@
    19 19
     # <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    20 20
     # #L%
    
    21 21
     ###
    
    22
    +createLogbookSampleActivityFromWellPlan.count=1
    
    23
    +createLogbookSampleActivityFromWellPlan.tripId=${defaultTripId}
    
    24
    +createLogbookSampleActivityFromWellPlan.wellId=${defaultWellId}
    
    25
    +createLogbookWellActivityFromSample.count=1
    
    26
    +createLogbookWellActivityFromSample.tripId=${defaultTripId}
    
    27
    +createLogbookWellActivityFromSample.wellId=${defaultWellId}
    
    22 28
     defaultActivityId=FIXME
    
    23 29
     defaultId=${PS_COMMON_TRIP}
    
    24 30
     defaultNewParentId=${REFERENTIAL_PS_COMMON_PROGRAM_MOVE}
    
    ... ... @@ -28,6 +34,7 @@ defaultRouteId=FIXME
    28 34
     defaultSpeciesListId=fr.ird.referential.common.SpeciesList#1239832675370#0.1
    
    29 35
     defaultTripId=${PS_COMMON_TRIP}
    
    30 36
     defaultVesselId=fr.ird.referential.common.Vessel#1239832679425#0.9136908731720471
    
    37
    +defaultWellId=3T
    
    31 38
     delete.id=${defaultId}
    
    32 39
     exists.id=${defaultId}
    
    33 40
     getAllTrip.count=4
    
    ... ... @@ -36,6 +43,10 @@ getChildren.count=1
    36 43
     getChildren.parentId=${defaultParentId}
    
    37 44
     getChildrenUpdate.count=1
    
    38 45
     getChildrenUpdate.parentId=${defaultParentId}
    
    46
    +getLogbookWellIdsFromSample.count=1
    
    47
    +getLogbookWellIdsFromSample.tripId=${defaultTripId}
    
    48
    +getLogbookWellIdsFromWellPlan.count=1
    
    49
    +getLogbookWellIdsFromWellPlan.tripId=${defaultTripId}
    
    39 50
     getLogbookWellPlanActivities.count=3
    
    40 51
     getLogbookWellPlanActivities.tripId=${defaultTripId}
    
    41 52
     getMatchingTripsVesselWithinDateRange.count=0
    

  • model/src/main/models/Observe/dto/class/i18nLabels.properties
    ... ... @@ -75,13 +75,13 @@ data.ps.logbook.Catch=comment,species,speciesFate,weight,weightCategory,weightMe
    75 75
     data.ps.logbook.FloatingObject=materialsValid,objectOperation,quadrant,supportVesselName,country,vessel,computedBiodegradable,computedNonEntangling,computedSimplifiedObjectType,computedValues,generalTab,buoysTab,materialsTab,notComputed,type.short,computedWhenArrivingBiodegradable,computedWhenLeavingBiodegradable,computedWhenArrivingNonEntangling,computedWhenLeavingNonEntangling,computedWhenArrivingSimplifiedObjectType,computedWhenLeavingSimplifiedObjectType
    
    76 76
     data.ps.logbook.FloatingObjectPart=whenArriving,whenLeaving
    
    77 77
     data.ps.logbook.Route=activity,comment,date,fishingTime,timeAtSea
    
    78
    -data.ps.logbook.Sample=number,activity,bigsWeight,comment,person,sampleQuality,sampleType,smallsWeight,superSample,totalWeight,well,generalTab,activityTab,notSuperSample.with.moreThanOne.sampleSpecies.message,notSuperSample.with.moreThanOne.sampleSpecies.title,personTab,psSampler.available,psSampler.selected
    
    78
    +data.ps.logbook.Sample=number,activity,bigsWeight,comment,person,sampleQuality,sampleType,smallsWeight,superSample,totalWeight,well,generalTab,activityTab,notSuperSample.with.moreThanOne.sampleSpecies.message,notSuperSample.with.moreThanOne.sampleSpecies.title,personTab,psSampler.available,psSampler.selected,action.addActivitiesFromWell,action.addActivitiesFromWell.tip
    
    79 79
     data.ps.logbook.SampleActivity=activity,weightedWeight,weightedWeightComputed,weightedWeightComputed.short,weightedWeightComputed.computed.tip,weightedWeightComputed.observed.tip
    
    80 80
     data.ps.logbook.SampleSampleSpecies=superSample,sampleSpecies,species
    
    81 81
     data.ps.logbook.SampleSpecies=comment,measuredCount,sampleSpeciesMeasure,sizeMeasureType,species,subSampleNumber,totalCount,startTime,endTime,startTime.short,endTime.short,generalTab
    
    82 82
     data.ps.logbook.SampleSpeciesMeasure=count,sizeClass
    
    83 83
     data.ps.logbook.TransmittingBuoy=comment,code,transmittingBuoyOwnership,transmittingBuoyType,transmittingBuoyOperation,country,vessel,latitude,longitude,quadrant
    
    84
    -data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamplingStatus,generalTab,wellActivityTab,action.save,action.save.tip,wellVessel.short,wellFactory.short,wellAlternativeNumbering
    
    84
    +data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamplingStatus,generalTab,wellActivityTab,action.save,action.save.tip,wellVessel.short,wellFactory.short,wellAlternativeNumbering,action.addActivitiesFromSample,action.addActivitiesFromSample.tip
    
    85 85
     data.ps.logbook.WellActivity=activity,wellActivitySpecies,computedTotalWeight,computedTotalWeight.short
    
    86 86
     data.ps.logbook.WellActivitySpecies=species,weight,weightCategory,count,setSpeciesNumber
    
    87 87
     data.ps.observation.Activity=date,coordinate,observedSystem.available,observedSystem.selected,comment,currentFpaZone,dataQuality,detectionMode,ersId,floatingObjectEmpty,latitude,longitude,nextFpaZone,nonTargetCatchSpecies,observedSystem,observedSystemDistance,previousFpaZone,quadrant,reasonForNoFishing,seaSurfaceTemperature,surroundingActivity,time,vesselActivity,vesselSpeed,wind,generalTab,error.no.activity.6,measurementsTab,observedSystemTab
    

  • model/src/main/resources/META-INF/persistence/fr/ird/observe/entities/data/ps/common/Trip-sql-queries.properties
    ... ... @@ -93,6 +93,34 @@ INNER JOIN ps_logbook.activity a ON a.route = r.topiaId\
    93 93
     INNER JOIN ps_common.vesselActivity va ON a.vesselActivity = va.topiaId\
    
    94 94
     WHERE r.trip = ? AND va.allowSet = TRUE OR va.topiaId = 'fr.ird.referential.ps.common.VesselActivity#1464000000000#32'\
    
    95 95
     ORDER BY r.date,a.time
    
    96
    +LogbookWellIdsFromWellPlan.comment=Get all logbook well ids from well plan
    
    97
    +LogbookWellIdsFromWellPlan.parameter.1=tripId|java.lang.String
    
    98
    +LogbookWellIdsFromWellPlan=SELECT\
    
    99
    +DISTINCT(w.well)\
    
    100
    +FROM ps_logbook.well w\
    
    101
    +WHERE w.trip = ?
    
    102
    +LogbookActivityIdsFromWellPlan.comment=Get all logbook activity ids from well plan filtered on a trip and a Well.well
    
    103
    +LogbookActivityIdsFromWellPlan.parameter.1=tripId|java.lang.String
    
    104
    +LogbookActivityIdsFromWellPlan.parameter.2=wellId|java.lang.String
    
    105
    +LogbookActivityIdsFromWellPlan=SELECT\
    
    106
    +DISTINCT(wa.activity)\
    
    107
    +FROM ps_logbook.well w\
    
    108
    +INNER JOIN ps_logbook.wellActivity wa ON wa.well = w.topiaId\
    
    109
    +WHERE w.trip = ? AND w.well = ?
    
    110
    +LogbookWellIdsFromSample.comment=Get all logbook well ids from samples
    
    111
    +LogbookWellIdsFromSample.parameter.1=tripId|java.lang.String
    
    112
    +LogbookWellIdsFromSample=SELECT\
    
    113
    +DISTINCT(s.well)\
    
    114
    +FROM ps_logbook.Sample s\
    
    115
    +WHERE s.trip = ?
    
    116
    +LogbookActivityIdsFromSample.comment=Get all logbook activity ids from samples filtered on a Sample.well
    
    117
    +LogbookActivityIdsFromSample.parameter.1=tripId|java.lang.String
    
    118
    +LogbookActivityIdsFromSample.parameter.2=wellId|java.lang.String
    
    119
    +LogbookActivityIdsFromSample=SELECT\
    
    120
    +DISTINCT(sa.activity)\
    
    121
    +FROM ps_logbook.Sample s\
    
    122
    +INNER JOIN ps_logbook.sampleActivity sa ON sa.sample = s.topiaId\
    
    123
    +WHERE s.trip = ? AND s.well = ?
    
    96 124
     UpdateVersion.comment=Update trip version
    
    97 125
     UpdateVersion.parameter.1=lastUpdateDate|java.sql.Timestamp
    
    98 126
     UpdateVersion.parameter.2=tripId|java.lang.String
    

  • server/core/src/main/filtered-resources/META-INF/mapping-api-client.wm
    ... ... @@ -141,7 +141,11 @@ GET /data/ps/AvdthService/importData data
    141 141
     POST   /data/ps/ConsolidateDataService/consolidateLocalmarketBatch          data.ps.ConsolidateDataServiceRestApi.consolidateLocalmarketBatch
    
    142 142
     POST   /data/ps/ConsolidateDataService/consolidateTrip                      data.ps.ConsolidateDataServiceRestApi.consolidateTrip
    
    143 143
     GET    /data/ps/ConsolidateDataService/newSimplifiedObjectTypeManager       data.ps.ConsolidateDataServiceRestApi.newSimplifiedObjectTypeManager
    
    144
    +POST   /data/ps/common/TripService/createLogbookSampleActivityFromWellPlan  data.ps.common.TripServiceRestApi.createLogbookSampleActivityFromWellPlan
    
    145
    +POST   /data/ps/common/TripService/createLogbookWellActivityFromSample      data.ps.common.TripServiceRestApi.createLogbookWellActivityFromSample
    
    144 146
     GET    /data/ps/common/TripService/getAllTripIds                            data.ps.common.TripServiceRestApi.getAllTripIds
    
    147
    +GET    /data/ps/common/TripService/getLogbookWellIdsFromSample              data.ps.common.TripServiceRestApi.getLogbookWellIdsFromSample
    
    148
    +GET    /data/ps/common/TripService/getLogbookWellIdsFromWellPlan            data.ps.common.TripServiceRestApi.getLogbookWellIdsFromWellPlan
    
    145 149
     GET    /data/ps/common/TripService/getLogbookWellPlanActivities             data.ps.common.TripServiceRestApi.getLogbookWellPlanActivities
    
    146 150
     GET    /data/ps/common/TripService/getMatchingTripsVesselWithinDateRange    data.ps.common.TripServiceRestApi.getMatchingTripsVesselWithinDateRange
    
    147 151
     GET    /data/ps/common/TripService/getSpeciesByListAndTrip                  data.ps.common.TripServiceRestApi.getSpeciesByListAndTrip