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

Commits:

18 changed files:

Changes:

  • client-datasource-editor-ll/src/main/i18n/getters/java.getter
    ... ... @@ -68,9 +68,6 @@ observe.data.ll.logbook.Activity.action.addSample
    68 68
     observe.data.ll.logbook.Activity.action.addSample.tip
    
    69 69
     observe.data.ll.logbook.Activity.action.addSet
    
    70 70
     observe.data.ll.logbook.Activity.action.addSet.tip
    
    71
    -observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity
    
    72
    -observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity.message
    
    73
    -observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity.title
    
    74 71
     observe.data.ll.logbook.Activity.action.moves
    
    75 72
     observe.data.ll.logbook.Activity.action.moves.tip
    
    76 73
     observe.data.ll.logbook.Activity.message.not.open
    

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/logbook/ActivityUI.jaxx
    ... ... @@ -39,7 +39,6 @@
    39 39
         fr.ird.observe.client.datasource.editor.content.data.ll.logbook.actions.ActivityUIAddSample
    
    40 40
         fr.ird.observe.client.datasource.editor.content.data.ll.logbook.actions.ActivityUIDelete
    
    41 41
         fr.ird.observe.client.datasource.editor.content.data.ll.logbook.actions.ActivityUISave
    
    42
    -    fr.ird.observe.client.datasource.editor.content.data.ll.logbook.actions.ActivityUIChooseRelatedObservedActivity
    
    43 42
     
    
    44 43
         fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingResultItem
    
    45 44
     
    
    ... ... @@ -110,8 +109,7 @@
    110 109
               <JLabel id='vesselActivityLabel'/>
    
    111 110
             </cell>
    
    112 111
             <cell anchor='east' fill="both">
    
    113
    -          <JaxxComboBox id='vesselActivity' genericType='VesselActivityReference'
    
    114
    -                                  constructorParams='this'/>
    
    112
    +          <JaxxComboBox id='vesselActivity' genericType='VesselActivityReference' constructorParams='this'/>
    
    115 113
             </cell>
    
    116 114
           </row>
    
    117 115
     
    
    ... ... @@ -190,11 +188,7 @@
    190 188
               <JLabel id='relatedObservedActivityLabel'/>
    
    191 189
             </cell>
    
    192 190
             <cell anchor='east' fill="both">
    
    193
    -          <JPanel layout="{new BorderLayout()}">
    
    194
    -            <JaxxComboBox id='relatedObservedActivity' genericType='fr.ird.observe.dto.data.ll.observation.ActivityReference' constructorParams='this'
    
    195
    -                                    constraints='BorderLayout.CENTER'/>
    
    196
    -            <JButton id='chooseRelatedObservedActivity' constraints='BorderLayout.EAST'/>
    
    197
    -          </JPanel>
    
    191
    +          <JaxxComboBox id='relatedObservedActivity' genericType='fr.ird.observe.dto.data.ll.observation.ActivityReference' constructorParams='this'/>
    
    198 192
             </cell>
    
    199 193
           </row>
    
    200 194
     
    

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/logbook/ActivityUI.jcss
    ... ... @@ -33,13 +33,13 @@ DateTimeEditor {
    33 33
     }
    
    34 34
     
    
    35 35
     #startTimeStamp {
    
    36
    -  propertyDayDate:{ActivityUIModel.PROPERTY_START_DATE};
    
    37
    -  propertyTimeDate:{ActivityUIModel.PROPERTY_START_TIME};
    
    36
    +  propertyDayDate:{ActivityDto.PROPERTY_START_DATE};
    
    37
    +  propertyTimeDate:{ActivityDto.PROPERTY_START_TIME};
    
    38 38
     }
    
    39 39
     
    
    40 40
     #endTimeStamp {
    
    41
    -  propertyDayDate:{ActivityUIModel.PROPERTY_END_DATE};
    
    42
    -  propertyTimeDate:{ActivityUIModel.PROPERTY_END_TIME};
    
    41
    +  propertyDayDate:{ActivityDto.PROPERTY_END_DATE};
    
    42
    +  propertyTimeDate:{ActivityDto.PROPERTY_END_TIME};
    
    43 43
     }
    
    44 44
     
    
    45 45
     #coordinate {
    
    ... ... @@ -71,14 +71,9 @@ DateTimeEditor {
    71 71
     }
    
    72 72
     
    
    73 73
     #addSet {
    
    74
    -  enabled:{!model.isModified() && model.isValid() && model.isSetOperation() && ! bean.isHasSet()};
    
    74
    +  enabled:{!model.isModified() && model.isValid() && bean.isSetOperation() && ! bean.isHasSet()};
    
    75 75
     }
    
    76 76
     
    
    77 77
     #addSample {
    
    78 78
       enabled:{!model.isModified() && model.isValid() && !bean.isHasSample()};
    
    79 79
     }
    80
    -
    
    81
    -#chooseRelatedObservedActivity {
    
    82
    -  visible:{!model.isReadingMode()};
    
    83
    -  enabled:{model.isValid() && bean.getLatitude() != null && bean.getLongitude() != null && bean.getQuadrant() != null};
    
    84
    -}

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/logbook/ActivityUIHandler.java
    ... ... @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.editor.content.data.open.ContentOpenable
    27 27
     import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    28 28
     import fr.ird.observe.dto.data.ll.observation.ActivityReference;
    
    29 29
     import fr.ird.observe.dto.form.Form;
    
    30
    +import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingEngine;
    
    30 31
     import org.apache.logging.log4j.LogManager;
    
    31 32
     import org.apache.logging.log4j.Logger;
    
    32 33
     import org.nuiton.jaxx.runtime.spi.UIHandler;
    
    ... ... @@ -44,6 +45,7 @@ import java.util.List;
    44 45
     class ActivityUIHandler extends ContentOpenableUIHandler<ActivityDto, fr.ird.observe.dto.data.ll.logbook.ActivityReference, ActivityUI> implements UIHandler<ActivityUI> {
    
    45 46
     
    
    46 47
         private static final Logger log = LogManager.getLogger(ActivityUIHandler.class);
    
    48
    +    private ActivityLonglinePairingEngine pairingEngine;
    
    47 49
     
    
    48 50
         @Override
    
    49 51
         public ActivityUIModel getModel() {
    
    ... ... @@ -74,6 +76,7 @@ class ActivityUIHandler extends ContentOpenableUIHandler<ActivityDto, fr.ird.obs
    74 76
         public void afterInit(ActivityUI ui) {
    
    75 77
             ui.getRelatedObservedActivity().setBeanType(ActivityReference.class);
    
    76 78
             super.afterInit(ui);
    
    79
    +        pairingEngine = new ActivityLonglinePairingEngine(getClientConfig().getReferentialLocale(), getLlCommonTripService(), getLlLogbookActivityService());
    
    77 80
         }
    
    78 81
     
    
    79 82
         @Override
    
    ... ... @@ -94,7 +97,7 @@ class ActivityUIHandler extends ContentOpenableUIHandler<ActivityDto, fr.ird.obs
    94 97
             }
    
    95 98
     
    
    96 99
             List<ActivityReference> allActivityLonglineObs = getLlObservationActivityService().getActivityLonglineByTripLongline(tripId).toList();
    
    97
    -        model.openForm(form, allActivityLonglineObs);
    
    100
    +        model.openForm(form, allActivityLonglineObs, pairingEngine);
    
    98 101
         }
    
    99 102
     
    
    100 103
     }

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/logbook/ActivityUIModel.java
    ... ... @@ -23,21 +23,20 @@ package fr.ird.observe.client.datasource.editor.content.data.ll.logbook;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableList;
    
    26
    +import com.google.common.collect.ImmutableSet;
    
    26 27
     import fr.ird.observe.client.datasource.editor.content.data.open.ContentOpenableUIModel;
    
    27 28
     import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    28 29
     import fr.ird.observe.dto.data.ll.observation.ActivityReference;
    
    29 30
     import fr.ird.observe.dto.form.Form;
    
    30
    -import fr.ird.observe.dto.referential.ll.common.VesselActivityHelper;
    
    31
    -import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    31
    +import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingEngine;
    
    32
    +import fr.ird.observe.services.service.data.ll.pairing.TripLonglinePairingContext;
    
    32 33
     import io.ultreia.java4all.i18n.I18n;
    
    33 34
     import org.apache.logging.log4j.LogManager;
    
    34 35
     import org.apache.logging.log4j.Logger;
    
    35
    -import org.nuiton.util.DateUtil;
    
    36 36
     
    
    37 37
     import java.util.Collections;
    
    38
    -import java.util.Date;
    
    39 38
     import java.util.List;
    
    40
    -import java.util.stream.Collectors;
    
    39
    +import java.util.Objects;
    
    41 40
     
    
    42 41
     /**
    
    43 42
      * Created on 9/26/14.
    
    ... ... @@ -47,95 +46,46 @@ import java.util.stream.Collectors;
    47 46
      */
    
    48 47
     public class ActivityUIModel extends ContentOpenableUIModel<ActivityDto, fr.ird.observe.dto.data.ll.logbook.ActivityReference> {
    
    49 48
     
    
    50
    -    public static final String PROPERTY_START_DATE = "startDate";
    
    51
    -    public static final String PROPERTY_START_TIME = "startTime";
    
    52
    -    public static final String PROPERTY_END_DATE = "endDate";
    
    53
    -    public static final String PROPERTY_END_TIME = "endTime";
    
    54
    -    private static final String PROPERTY_SET_OPERATION = "setOperation";
    
    49
    +    public static final String PROPERTY_ACTIVITY_OBS = "activityObs";
    
    50
    +    public static final ImmutableSet<String> PROPERTIES_FOR_UPDATE_ACTIVITIES_OBS_LIST = ImmutableSet.of(
    
    51
    +            ActivityDto.PROPERTY_VESSEL_ACTIVITY,
    
    52
    +            ActivityDto.PROPERTY_LATITUDE,
    
    53
    +            ActivityDto.PROPERTY_LONGITUDE,
    
    54
    +            ActivityDto.PROPERTY_QUADRANT,
    
    55
    +            ActivityDto.PROPERTY_START_DATE,
    
    56
    +            ActivityDto.PROPERTY_START_TIME,
    
    57
    +            ActivityDto.PROPERTY_START_TIME_STAMP,
    
    58
    +            ActivityDto.PROPERTY_END_DATE,
    
    59
    +            ActivityDto.PROPERTY_END_TIME,
    
    60
    +            ActivityDto.PROPERTY_END_TIME_STAMP);
    
    61
    +
    
    55 62
         private static final Logger log = LogManager.getLogger(ActivityUIModel.class);
    
    56
    -    private List<ActivityReference> allActivityObs;
    
    57
    -    private List<ActivityReference> activityObs;
    
    63
    +
    
    58 64
         private boolean opening = false;
    
    65
    +    private List<ActivityReference> activityObs;
    
    66
    +    private TripLonglinePairingContext pairingContext;
    
    59 67
     
    
    60 68
         public ActivityUIModel() {
    
    61 69
             super(ActivityDto.class, I18n.n("observe.data.ll.logbook.Activity.message.not.open"));
    
    62
    -
    
    63
    -        getBean().addPropertyChangeListener(ActivityDto.PROPERTY_VESSEL_ACTIVITY, evt -> {
    
    64
    -            boolean oldValue = VesselActivityHelper.isSetOperation((VesselActivityReference) evt.getOldValue());
    
    65
    -            VesselActivityReference VesselActivityReference = (VesselActivityReference) evt.getNewValue();
    
    66
    -            boolean newValue = VesselActivityHelper.isSetOperation(VesselActivityReference);
    
    67
    -            firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue);
    
    68
    -            if (!opening) {
    
    69
    -                updateActivityObs();
    
    70
    +        getBean().attachSetOperationListener();
    
    71
    +        getBean().addPropertyChangeListener(evt -> {
    
    72
    +            String propertyName = evt.getPropertyName();
    
    73
    +            if (opening || !PROPERTIES_FOR_UPDATE_ACTIVITIES_OBS_LIST.contains(propertyName)) {
    
    74
    +                return;
    
    70 75
                 }
    
    76
    +            updateActivityObsCandidates();
    
    71 77
             });
    
    72 78
         }
    
    73 79
     
    
    74
    -    public boolean isSetOperation() {
    
    75
    -        return VesselActivityHelper.isSetOperation(getBean().getVesselActivity());
    
    76
    -    }
    
    77
    -
    
    78
    -    public Date getStartDate() {
    
    79
    -        Date timeStamp = getBean().getStartTimeStamp();
    
    80
    -        return timeStamp == null ? null : DateUtil.getDay(timeStamp);
    
    81
    -    }
    
    82
    -
    
    83
    -    public void setStartDate(Date date) {
    
    84
    -        Date timeStamp = getBean().getStartTimeStamp();
    
    85
    -        if (timeStamp != null) {
    
    86
    -            Date dateAndTime = date == null ? timeStamp : DateUtil.getDateAndTime(date, timeStamp, true, false);
    
    87
    -            getBean().setStartTimeStamp(dateAndTime);
    
    88
    -        }
    
    89
    -    }
    
    90
    -
    
    91
    -    public Date getStartTime() {
    
    92
    -        Date timeStamp = getBean().getStartTimeStamp();
    
    93
    -        return timeStamp == null ? null : DateUtil.getTime(timeStamp, false, false);
    
    94
    -    }
    
    95
    -
    
    96
    -    public void setStartTime(Date time) {
    
    97
    -        Date timeStamp = getBean().getStartTimeStamp();
    
    98
    -        if (timeStamp != null) {
    
    99
    -            Date dateAndTime = time == null ? timeStamp : DateUtil.getDateAndTime(timeStamp, time, false, false);
    
    100
    -            getBean().setStartTimeStamp(dateAndTime);
    
    101
    -        }
    
    102
    -    }
    
    103
    -
    
    104
    -    public Date getEndDate() {
    
    105
    -        Date timeStamp = getBean().getEndTimeStamp();
    
    106
    -        return timeStamp == null ? null : DateUtil.getDay(timeStamp);
    
    107
    -    }
    
    108
    -
    
    109
    -    public void setEndDate(Date date) {
    
    110
    -        Date timeStamp = getBean().getEndTimeStamp();
    
    111
    -        if (timeStamp != null) {
    
    112
    -            Date dateAndTime = date == null ? timeStamp : DateUtil.getDateAndTime(date, timeStamp, true, false);
    
    113
    -            getBean().setEndTimeStamp(dateAndTime);
    
    114
    -        }
    
    115
    -    }
    
    116
    -
    
    117
    -    public Date getEndTime() {
    
    118
    -        Date timeStamp = getBean().getEndTimeStamp();
    
    119
    -        return timeStamp == null ? null : DateUtil.getTime(timeStamp, false, false);
    
    120
    -    }
    
    121
    -
    
    122
    -    public void setEndTime(Date time) {
    
    123
    -        Date timeStamp = getBean().getEndTimeStamp();
    
    124
    -        if (timeStamp != null) {
    
    125
    -            Date dateAndTime = time == null ? timeStamp : DateUtil.getDateAndTime(timeStamp, time, false, false);
    
    126
    -            getBean().setEndTimeStamp(dateAndTime);
    
    127
    -        }
    
    128
    -    }
    
    129
    -
    
    130
    -    public void openForm(Form<ActivityDto> form, List<ActivityReference> allActivityObs) {
    
    131
    -        this.allActivityObs = ImmutableList.copyOf(allActivityObs);
    
    80
    +    public void openForm(Form<ActivityDto> form, List<ActivityReference> allActivityObs, ActivityLonglinePairingEngine pairingEngine) {
    
    81
    +        this.pairingContext = pairingEngine.newTripContext(getSelectedParentId(), ImmutableList.copyOf(allActivityObs));
    
    132 82
             opening = true;
    
    133 83
             try {
    
    134 84
                 super.openForm(form);
    
    135 85
             } finally {
    
    136 86
                 opening = false;
    
    137 87
             }
    
    138
    -        updateActivityObs();
    
    88
    +        updateActivityObsCandidates();
    
    139 89
         }
    
    140 90
     
    
    141 91
         public List<ActivityReference> getActivityObs() {
    
    ... ... @@ -143,29 +93,29 @@ public class ActivityUIModel extends ContentOpenableUIModel<ActivityDto, fr.ird.
    143 93
         }
    
    144 94
     
    
    145 95
         public void setActivityObs(List<ActivityReference> activityObs) {
    
    146
    -        // only used for jaxx binding
    
    147
    -    }
    
    148
    -
    
    149
    -    public List<ActivityReference> getAllActivityObs() {
    
    150
    -        return allActivityObs;
    
    96
    +        ActivityReference relatedObservedActivity = getBean().getRelatedObservedActivity();
    
    97
    +        this.activityObs = Objects.requireNonNull(activityObs);
    
    98
    +        boolean removeRelatedObservedActivity = relatedObservedActivity != null && !activityObs.contains(relatedObservedActivity);
    
    99
    +        firePropertyChange(PROPERTY_ACTIVITY_OBS, null, activityObs);
    
    100
    +        if (removeRelatedObservedActivity) {
    
    101
    +            log.info(String.format("%s Removed not matching related observed activity: %s", getPrefix(), relatedObservedActivity));
    
    102
    +            getBean().setRelatedObservedActivity(null);
    
    103
    +        }
    
    151 104
         }
    
    152 105
     
    
    153
    -    private void updateActivityObs() {
    
    154
    -        log.info(getPrefix() + "Will update release observed actities...");
    
    106
    +    private void updateActivityObsCandidates() {
    
    107
    +        if (opening) {
    
    108
    +            return;
    
    109
    +        }
    
    110
    +        log.info(String.format("%s Will update release observed activities...", getPrefix()));
    
    155 111
             ActivityDto bean = getBean();
    
    156
    -        if (allActivityObs == null || bean.getVesselActivityId() == null) {
    
    112
    +        String vesselActivityId = bean.getVesselActivityId();
    
    113
    +        if (pairingContext == null || vesselActivityId == null) {
    
    157 114
                 activityObs = Collections.emptyList();
    
    158 115
             } else {
    
    159
    -            String VesselActivityId = bean.getVesselActivityId();
    
    160
    -            activityObs = allActivityObs.stream().filter(e -> VesselActivityId.equals(e.getVesselActivityId())).collect(Collectors.toList());
    
    161
    -        }
    
    162
    -        log.info(getPrefix() + "Found " + activityObs.size() + " related observed activities.");
    
    163
    -        ActivityReference relatedObservedActivity = bean.getRelatedObservedActivity();
    
    164
    -        boolean removeRelatedObservedActivity = !opening && relatedObservedActivity != null && !activityObs.contains(relatedObservedActivity);
    
    165
    -        firePropertyChange("activityObs", null, activityObs);
    
    166
    -        if (removeRelatedObservedActivity) {
    
    167
    -            log.info(getPrefix() + "Removed not matching related observed activity: " + relatedObservedActivity);
    
    168
    -            bean.setRelatedObservedActivity(null);
    
    116
    +            activityObs = pairingContext.getActivityLonglineObsList(bean);
    
    169 117
             }
    
    118
    +        log.info(String.format("%s Found %d related observed activities.", getPrefix(), activityObs.size()));
    
    119
    +        setActivityObs(activityObs);
    
    170 120
         }
    
    171 121
     }

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/logbook/actions/ActivityUIChooseRelatedObservedActivity.java deleted
    1
    -package fr.ird.observe.client.datasource.editor.content.data.ll.logbook.actions;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Client DataSource Editor LL
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2020 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.ClientUIContextApplicationComponent;
    
    26
    -import fr.ird.observe.client.datasource.editor.content.ObserveLLKeyStrokes;
    
    27
    -import fr.ird.observe.client.datasource.editor.content.actions.ContentUIActionSupport;
    
    28
    -import fr.ird.observe.client.datasource.editor.content.data.ll.logbook.ActivityUI;
    
    29
    -import fr.ird.observe.client.datasource.editor.content.data.ll.logbook.ActivityUIModel;
    
    30
    -import fr.ird.observe.client.datasource.editor.content.ref.usage.UsageUIHandlerSupport;
    
    31
    -import fr.ird.observe.client.util.UIHelper;
    
    32
    -import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    33
    -import fr.ird.observe.dto.data.ll.observation.ActivityReference;
    
    34
    -import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingEngine;
    
    35
    -import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingResult;
    
    36
    -import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingResultItem;
    
    37
    -import fr.ird.observe.services.service.data.ll.pairing.ActivityLonglinePairingResultItemDecorator;
    
    38
    -import fr.ird.observe.services.service.data.ll.pairing.TripLonglinePairingContext;
    
    39
    -import io.ultreia.java4all.jaxx.widgets.combobox.JaxxComboBox;
    
    40
    -import org.apache.logging.log4j.LogManager;
    
    41
    -import org.apache.logging.log4j.Logger;
    
    42
    -
    
    43
    -import javax.swing.JButton;
    
    44
    -import javax.swing.JLabel;
    
    45
    -import javax.swing.JOptionPane;
    
    46
    -import javax.swing.JPanel;
    
    47
    -import java.awt.BorderLayout;
    
    48
    -import java.awt.event.ActionEvent;
    
    49
    -import java.util.ArrayList;
    
    50
    -import java.util.List;
    
    51
    -import java.util.Objects;
    
    52
    -import java.util.Optional;
    
    53
    -
    
    54
    -import static io.ultreia.java4all.i18n.I18n.n;
    
    55
    -import static io.ultreia.java4all.i18n.I18n.t;
    
    56
    -
    
    57
    -/**
    
    58
    - * Created by tchemit on 16/10/2018.
    
    59
    - *
    
    60
    - * @author Tony Chemit - dev@tchemit.fr
    
    61
    - */
    
    62
    -public class ActivityUIChooseRelatedObservedActivity extends ContentUIActionSupport<ActivityUI> {
    
    63
    -
    
    64
    -    private static final Logger log = LogManager.getLogger(ActivityUIChooseRelatedObservedActivity.class);
    
    65
    -    private final ActivityLonglinePairingResultItemDecorator decorator;
    
    66
    -
    
    67
    -    public ActivityUIChooseRelatedObservedActivity() {
    
    68
    -        super(n("observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity"), n("observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity"), "data-calcule", ObserveLLKeyStrokes.KEY_STROKE_CHOOSE_RELATED_OBSERVATION_ACTIVITY);
    
    69
    -        decorator = new ActivityLonglinePairingResultItemDecorator(getDecoratorService(), getClientConfig().getLocale());
    
    70
    -    }
    
    71
    -
    
    72
    -    @Override
    
    73
    -    protected void doActionPerformed(ActionEvent e, ActivityUI ui) {
    
    74
    -
    
    75
    -        ActivityUIModel model = ui.getModel();
    
    76
    -
    
    77
    -        ActivityLonglinePairingEngine pairingEngine = new ActivityLonglinePairingEngine(getClientConfig().getReferentialLocale(), getServicesProvider().getLlCommonTripService(), getServicesProvider().getLlLogbookActivityService());
    
    78
    -
    
    79
    -        ActivityDto bean = model.getBean();
    
    80
    -
    
    81
    -        TripLonglinePairingContext pairingContext = pairingEngine.newTripContext(model.getSelectedParentId(), model.getAllActivityObs());
    
    82
    -
    
    83
    -        ActivityLonglinePairingResult activityLonglinePairingResult = pairingEngine.computeForActivityLogbook(pairingContext, bean);
    
    84
    -
    
    85
    -        Optional<ActivityReference> optionalActivityLonglineObs = askNewParent(activityLonglinePairingResult.getItems());
    
    86
    -
    
    87
    -        if (optionalActivityLonglineObs.isPresent()) {
    
    88
    -            ActivityReference activityLonglineObs = optionalActivityLonglineObs.get();
    
    89
    -            log.info("will use new related activity observation: " + activityLonglineObs);
    
    90
    -            bean.setRelatedObservedActivity(activityLonglineObs);
    
    91
    -        }
    
    92
    -    }
    
    93
    -
    
    94
    -    private Optional<ActivityReference> askNewParent(List<ActivityLonglinePairingResultItem> pairingResult) {
    
    95
    -
    
    96
    -        JaxxComboBox<ActivityLonglinePairingResultItem> editor = UIHelper.newJaxxComboBox(
    
    97
    -                ActivityLonglinePairingResultItem.class,
    
    98
    -                decorator,
    
    99
    -                new ArrayList<>(pairingResult));
    
    100
    -
    
    101
    -        String continueActionText = t("observe.choice.continue");
    
    102
    -        Object[] options = {continueActionText, t("observe.choice.cancel")};
    
    103
    -        JPanel panel = new JPanel(new BorderLayout());
    
    104
    -        panel.add(BorderLayout.NORTH, new JLabel(t("observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity.message")));
    
    105
    -        panel.add(BorderLayout.CENTER, editor);
    
    106
    -
    
    107
    -        JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]) {
    
    108
    -            @Override
    
    109
    -            public void selectInitialValue() {
    
    110
    -                if (editor.getModel().getData().size() == 1) {
    
    111
    -                    editor.setSelectedItem(editor.getModel().getData().get(0));
    
    112
    -                }
    
    113
    -                editor.requestFocusInWindow();
    
    114
    -            }
    
    115
    -        };
    
    116
    -
    
    117
    -        JButton jButton = UsageUIHandlerSupport.findButton(pane, continueActionText);
    
    118
    -        Objects.requireNonNull(jButton);
    
    119
    -        jButton.setEnabled(false);
    
    120
    -        editor.addPropertyChangeListener("selectedItem", evt -> jButton.setEnabled(evt.getNewValue() != null));
    
    121
    -
    
    122
    -        int response = UIHelper.askUser(ClientUIContextApplicationComponent.value().getMainUI(), pane, t("observe.data.ll.logbook.Activity.action.chooseRelatedObservedActivity.title"), options);
    
    123
    -
    
    124
    -        ActivityLonglinePairingResultItem newActivityLonglineObs = null;
    
    125
    -        if (response == 0) {
    
    126
    -            newActivityLonglineObs = editor.getComboBoxModel().getSelectedItem();
    
    127
    -            log.info(String.format("Selected new related observed activity id: %s", newActivityLonglineObs));
    
    128
    -        } else {
    
    129
    -            log.info("Use cancel choice of related observed activity");
    
    130
    -        }
    
    131
    -        return Optional.ofNullable(newActivityLonglineObs).map(ActivityLonglinePairingResultItem::getObservationActivity);
    
    132
    -    }
    
    133
    -
    
    134
    -}
    
    135
    -

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/ActivityUI.jcss
    ... ... @@ -29,8 +29,8 @@
    29 29
     }
    
    30 30
     
    
    31 31
     #timeStamp {
    
    32
    -  propertyDayDate:{ActivityUIModel.PROPERTY_DATE};
    
    33
    -  propertyTimeDate:{ActivityUIModel.PROPERTY_TIME};
    
    32
    +  propertyDayDate:{ActivityDto.PROPERTY_DATE};
    
    33
    +  propertyTimeDate:{ActivityDto.PROPERTY_TIME};
    
    34 34
     }
    
    35 35
     
    
    36 36
     #vesselActivity {
    
    ... ... @@ -51,5 +51,5 @@
    51 51
     }
    
    52 52
     
    
    53 53
     #addSet {
    
    54
    -  enabled:{!model.isModified() && model.isValid() && model.isSetOperation() && ! bean.isHasSet()};
    
    54
    +  enabled:{!model.isModified() && model.isValid() && bean.isSetOperation() && ! bean.isHasSet()};
    
    55 55
     }

  • client-datasource-editor-ll/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ll/observation/ActivityUIModel.java
    ... ... @@ -25,12 +25,7 @@ package fr.ird.observe.client.datasource.editor.content.data.ll.observation;
    25 25
     import fr.ird.observe.client.datasource.editor.content.data.open.ContentOpenableUIModel;
    
    26 26
     import fr.ird.observe.dto.data.ll.observation.ActivityDto;
    
    27 27
     import fr.ird.observe.dto.data.ll.observation.ActivityReference;
    
    28
    -import fr.ird.observe.dto.referential.ll.common.VesselActivityHelper;
    
    29
    -import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    30 28
     import io.ultreia.java4all.i18n.I18n;
    
    31
    -import org.nuiton.util.DateUtil;
    
    32
    -
    
    33
    -import java.util.Date;
    
    34 29
     
    
    35 30
     /**
    
    36 31
      * Created on 9/26/14.
    
    ... ... @@ -40,47 +35,8 @@ import java.util.Date;
    40 35
      */
    
    41 36
     public class ActivityUIModel extends ContentOpenableUIModel<ActivityDto, ActivityReference> {
    
    42 37
     
    
    43
    -    public static final String PROPERTY_SET_OPERATION = "setOperation";
    
    44
    -    public static final String PROPERTY_DATE = "date";
    
    45
    -    public static final String PROPERTY_TIME = "time";
    
    46
    -
    
    47 38
         public ActivityUIModel() {
    
    48 39
             super(ActivityDto.class, I18n.n("observe.data.ll.observation.Activity.message.not.open"));
    
    49
    -
    
    50
    -        getBean().addPropertyChangeListener(ActivityDto.PROPERTY_VESSEL_ACTIVITY, evt -> {
    
    51
    -            boolean oldValue = VesselActivityHelper.isSetOperation((VesselActivityReference) evt.getOldValue());
    
    52
    -            boolean newValue = VesselActivityHelper.isSetOperation((VesselActivityReference) evt.getNewValue());
    
    53
    -            firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue);
    
    54
    -        });
    
    55
    -    }
    
    56
    -
    
    57
    -    public boolean isSetOperation() {
    
    58
    -        return VesselActivityHelper.isSetOperation(getBean().getVesselActivity());
    
    59
    -    }
    
    60
    -
    
    61
    -    public Date getDate() {
    
    62
    -        Date timeStamp = getBean().getTimeStamp();
    
    63
    -        return timeStamp == null ? null : DateUtil.getDay(timeStamp);
    
    64
    -    }
    
    65
    -
    
    66
    -    public void setDate(Date date) {
    
    67
    -        Date timeStamp = getBean().getTimeStamp();
    
    68
    -        if (timeStamp != null) {
    
    69
    -            Date dateAndTime = date == null ? timeStamp : DateUtil.getDateAndTime(date, timeStamp, true, false);
    
    70
    -            getBean().setTimeStamp(dateAndTime);
    
    71
    -        }
    
    72
    -    }
    
    73
    -
    
    74
    -    public Date getTime() {
    
    75
    -        Date timeStamp = getBean().getTimeStamp();
    
    76
    -        return timeStamp == null ? null : DateUtil.getTime(timeStamp, false, false);
    
    77
    -    }
    
    78
    -
    
    79
    -    public void setTime(Date time) {
    
    80
    -        Date timeStamp = getBean().getTimeStamp();
    
    81
    -        if (timeStamp != null) {
    
    82
    -            Date dateAndTime = time == null ? timeStamp : DateUtil.getDateAndTime(timeStamp, time, false, false);
    
    83
    -            getBean().setTimeStamp(dateAndTime);
    
    84
    -        }
    
    40
    +        getBean().attachSetOperationListener();
    
    85 41
         }
    
    86 42
     }

  • dto/src/main/java/fr/ird/observe/dto/data/ActivityAware.java
    ... ... @@ -24,16 +24,21 @@ package fr.ird.observe.dto.data;
    24 24
     
    
    25 25
     import fr.ird.observe.dto.DtoAndReferenceAware;
    
    26 26
     import fr.ird.observe.dto.GPSPoint;
    
    27
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    28
    +import io.ultreia.java4all.bean.JavaBean;
    
    27 29
     import org.nuiton.util.DateUtil;
    
    28 30
     
    
    29 31
     import java.util.Date;
    
    32
    +import java.util.Optional;
    
    30 33
     
    
    31 34
     /**
    
    32 35
      * Created by tchemit on 15/10/2018.
    
    33 36
      *
    
    34 37
      * @author Tony Chemit - dev@tchemit.fr
    
    35 38
      */
    
    36
    -public interface ActivityAware extends DtoAndReferenceAware {
    
    39
    +public interface ActivityAware extends DtoAndReferenceAware, JavaBean {
    
    40
    +
    
    41
    +    String PROPERTY_SET_OPERATION = "setOperation";
    
    37 42
     
    
    38 43
         static GPSPoint newGPSPoint(ActivityAware a) {
    
    39 44
             GPSPoint gpsPoint = new GPSPoint();
    
    ... ... @@ -57,5 +62,23 @@ public interface ActivityAware extends DtoAndReferenceAware {
    57 62
     
    
    58 63
         Float getLongitude();
    
    59 64
     
    
    60
    -    String getVesselActivityId();
    
    65
    +    VesselActivityReference getVesselActivity();
    
    66
    +
    
    67
    +    default String getVesselActivityId() {
    
    68
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getId).orElse(null);
    
    69
    +    }
    
    70
    +    default String getVesselActivityLabel() {
    
    71
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getLabel).orElse(null);
    
    72
    +    }
    
    73
    +
    
    74
    +    boolean isSetOperation();
    
    75
    +
    
    76
    +
    
    77
    +    static boolean isSetOperation(ActivityAware activity) {
    
    78
    +        return isSetOperation(activity.getVesselActivity());
    
    79
    +    }
    
    80
    +
    
    81
    +    static boolean isSetOperation(VesselActivityReference activity) {
    
    82
    +        return Optional.ofNullable(activity).map(VesselActivityReference::isSetOperation).orElse(false);
    
    83
    +    }
    
    61 84
     }

  • dto/src/main/java/fr/ird/observe/dto/data/ll/logbook/ActivityDto.java
    ... ... @@ -24,10 +24,14 @@ package fr.ird.observe.dto.data.ll.logbook;
    24 24
     
    
    25 25
     import fr.ird.observe.dto.GPSPoint;
    
    26 26
     import fr.ird.observe.dto.data.ActivityAware;
    
    27
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    27 28
     import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    28 29
     import org.nuiton.util.DateUtil;
    
    29 30
     
    
    31
    +import java.beans.PropertyChangeEvent;
    
    32
    +import java.beans.PropertyChangeListener;
    
    30 33
     import java.util.Date;
    
    34
    +import java.util.Optional;
    
    31 35
     
    
    32 36
     @GenerateJavaBeanDefinition
    
    33 37
     public class ActivityDto extends GeneratedActivityDto {
    
    ... ... @@ -37,6 +41,7 @@ public class ActivityDto extends GeneratedActivityDto {
    37 41
         public static final String PROPERTY_END_DATE = "endDate";
    
    38 42
         public static final String PROPERTY_END_TIME = "endTime";
    
    39 43
         private static final long serialVersionUID = 1L;
    
    44
    +    private PropertyChangeListener setOperationListener;
    
    40 45
     
    
    41 46
         public Date getStartDate() {
    
    42 47
             return startTimeStamp == null ? null : DateUtil.getDay(startTimeStamp);
    
    ... ... @@ -110,13 +115,42 @@ public class ActivityDto extends GeneratedActivityDto {
    110 115
             return ActivityAware.newGPSPoint(this);
    
    111 116
         }
    
    112 117
     
    
    118
    +    public boolean isHasSample() {
    
    119
    +        return sample != null;
    
    120
    +    }
    
    121
    +
    
    113 122
         @Override
    
    114
    -    public String getVesselActivityId() {
    
    115
    -        return vesselActivity == null ? null : vesselActivity.getId();
    
    123
    +    public boolean isSetOperation() {
    
    124
    +        return ActivityAware.isSetOperation(this);
    
    116 125
         }
    
    117 126
     
    
    118
    -    public boolean isHasSample() {
    
    119
    -        return sample != null;
    
    127
    +    public void attachSetOperationListener() {
    
    128
    +        if (setOperationListener == null) {
    
    129
    +            setOperationListener = new SetOperationListener(this);
    
    130
    +        }
    
    131
    +        removePropertyChangeListener(PROPERTY_VESSEL_ACTIVITY, setOperationListener);
    
    132
    +        addPropertyChangeListener(PROPERTY_VESSEL_ACTIVITY, setOperationListener);
    
    133
    +        fireSetOperation(false);
    
    134
    +    }
    
    135
    +
    
    136
    +    public void fireSetOperation(boolean oldValue) {
    
    137
    +        firePropertyChange(PROPERTY_SET_OPERATION, oldValue, isSetOperation());
    
    120 138
         }
    
    121 139
     
    
    140
    +
    
    141
    +    static class SetOperationListener implements PropertyChangeListener {
    
    142
    +
    
    143
    +        private final ActivityDto activity;
    
    144
    +
    
    145
    +        SetOperationListener(ActivityDto activity) {
    
    146
    +            this.activity = activity;
    
    147
    +        }
    
    148
    +
    
    149
    +        @Override
    
    150
    +        public void propertyChange(PropertyChangeEvent evt) {
    
    151
    +            Optional<VesselActivityReference> oldVesselActivity = Optional.ofNullable((VesselActivityReference) evt.getOldValue());
    
    152
    +            boolean oldValue = oldVesselActivity.map(VesselActivityReference::isSetOperation).orElse(false);
    
    153
    +            activity.fireSetOperation(oldValue);
    
    154
    +        }
    
    155
    +    }
    
    122 156
     }

  • dto/src/main/java/fr/ird/observe/dto/data/ll/logbook/ActivityReference.java
    ... ... @@ -25,21 +25,23 @@ package fr.ird.observe.dto.data.ll.logbook;
    25 25
     import fr.ird.observe.dto.GPSPoint;
    
    26 26
     import fr.ird.observe.dto.data.ActivityAware;
    
    27 27
     import fr.ird.observe.dto.reference.DtoReferenceAware;
    
    28
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    28 29
     import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    29 30
     
    
    30 31
     import java.util.Date;
    
    32
    +import java.util.Optional;
    
    31 33
     
    
    32 34
     @GenerateJavaBeanDefinition
    
    33 35
     public class ActivityReference extends GeneratedActivityReference {
    
    34 36
     
    
    35 37
         private transient GPSPoint gpsPoint;
    
    36 38
     
    
    37
    -    public ActivityReference(DtoReferenceAware dto, Date startTimeStamp, Date endTimeStamp, Float latitude, Float longitude, String vesselActivityId, String vesselActivityLabel, SetReference set, SampleReference sample, fr.ird.observe.dto.data.ll.observation.ActivityReference activity) {
    
    38
    -        super(dto, startTimeStamp, endTimeStamp, latitude, longitude, vesselActivityId, vesselActivityLabel, set, sample, activity);
    
    39
    +    public ActivityReference(DtoReferenceAware dto, Date startTimeStamp, Date endTimeStamp, Float latitude, Float longitude, VesselActivityReference vesselActivity, SetReference set, SampleReference sample, fr.ird.observe.dto.data.ll.observation.ActivityReference activity) {
    
    40
    +        super(dto, startTimeStamp, endTimeStamp, latitude, longitude, vesselActivity, set, sample, activity);
    
    39 41
         }
    
    40 42
     
    
    41 43
         public ActivityReference(DtoReferenceAware dto) {
    
    42
    -        this(dto, null, null, null, null, null, null, null, null, null);
    
    44
    +        this(dto, null, null, null, null, null, null, null, null);
    
    43 45
         }
    
    44 46
     
    
    45 47
         @Override
    
    ... ... @@ -47,6 +49,21 @@ public class ActivityReference extends GeneratedActivityReference {
    47 49
             return getStartTimeStamp();
    
    48 50
         }
    
    49 51
     
    
    52
    +    @Override
    
    53
    +    public boolean isSetOperation() {
    
    54
    +        return ActivityAware.isSetOperation(this);
    
    55
    +    }
    
    56
    +
    
    57
    +    @Override
    
    58
    +    public String getVesselActivityId() {
    
    59
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getId).orElse(null);
    
    60
    +    }
    
    61
    +
    
    62
    +    @Override
    
    63
    +    public String getVesselActivityLabel() {
    
    64
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getLabel).orElse(null);
    
    65
    +    }
    
    66
    +
    
    50 67
         @Override
    
    51 68
         public GPSPoint getGPSPoint() {
    
    52 69
             if (gpsPoint == null) {
    

  • dto/src/main/java/fr/ird/observe/dto/data/ll/observation/ActivityDto.java
    ... ... @@ -24,10 +24,14 @@ package fr.ird.observe.dto.data.ll.observation;
    24 24
     
    
    25 25
     import fr.ird.observe.dto.GPSPoint;
    
    26 26
     import fr.ird.observe.dto.data.ActivityAware;
    
    27
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    27 28
     import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    28 29
     import org.nuiton.util.DateUtil;
    
    29 30
     
    
    31
    +import java.beans.PropertyChangeEvent;
    
    32
    +import java.beans.PropertyChangeListener;
    
    30 33
     import java.util.Date;
    
    34
    +import java.util.Optional;
    
    31 35
     
    
    32 36
     @GenerateJavaBeanDefinition
    
    33 37
     public class ActivityDto extends GeneratedActivityDto {
    
    ... ... @@ -35,6 +39,7 @@ public class ActivityDto extends GeneratedActivityDto {
    35 39
         public static final String PROPERTY_DATE = "date";
    
    36 40
         public static final String PROPERTY_TIME = "time";
    
    37 41
         private static final long serialVersionUID = 1L;
    
    42
    +    private ActivityDto.SetOperationListener setOperationListener;
    
    38 43
     
    
    39 44
         public Date getDate() {
    
    40 45
             return timeStamp == null ? null : DateUtil.getDay(timeStamp);
    
    ... ... @@ -73,7 +78,36 @@ public class ActivityDto extends GeneratedActivityDto {
    73 78
         }
    
    74 79
     
    
    75 80
         @Override
    
    76
    -    public String getVesselActivityId() {
    
    77
    -        return vesselActivity == null ? null : vesselActivity.getId();
    
    81
    +    public boolean isSetOperation() {
    
    82
    +        return ActivityAware.isSetOperation(this);
    
    83
    +    }
    
    84
    +
    
    85
    +    public void attachSetOperationListener() {
    
    86
    +        if (setOperationListener == null) {
    
    87
    +            setOperationListener = new SetOperationListener(this);
    
    88
    +        }
    
    89
    +        removePropertyChangeListener(PROPERTY_VESSEL_ACTIVITY, setOperationListener);
    
    90
    +        addPropertyChangeListener(PROPERTY_VESSEL_ACTIVITY, setOperationListener);
    
    91
    +        fireSetOperation(false);
    
    92
    +    }
    
    93
    +
    
    94
    +    public void fireSetOperation(boolean oldValue) {
    
    95
    +        firePropertyChange(PROPERTY_SET_OPERATION, oldValue, isSetOperation());
    
    96
    +    }
    
    97
    +
    
    98
    +    static class SetOperationListener implements PropertyChangeListener {
    
    99
    +
    
    100
    +        private final ActivityDto activity;
    
    101
    +
    
    102
    +        SetOperationListener(ActivityDto activity) {
    
    103
    +            this.activity = activity;
    
    104
    +        }
    
    105
    +
    
    106
    +        @Override
    
    107
    +        public void propertyChange(PropertyChangeEvent evt) {
    
    108
    +            Optional<VesselActivityReference> oldVesselActivity = Optional.ofNullable((VesselActivityReference) evt.getOldValue());
    
    109
    +            boolean oldValue = oldVesselActivity.map(VesselActivityReference::isSetOperation).orElse(false);
    
    110
    +            activity.fireSetOperation(oldValue);
    
    111
    +        }
    
    78 112
         }
    
    79 113
     }

  • dto/src/main/java/fr/ird/observe/dto/data/ll/observation/ActivityReference.java
    ... ... @@ -25,21 +25,23 @@ package fr.ird.observe.dto.data.ll.observation;
    25 25
     import fr.ird.observe.dto.GPSPoint;
    
    26 26
     import fr.ird.observe.dto.data.ActivityAware;
    
    27 27
     import fr.ird.observe.dto.reference.DtoReferenceAware;
    
    28
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityReference;
    
    28 29
     import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    29 30
     
    
    30 31
     import java.util.Date;
    
    32
    +import java.util.Optional;
    
    31 33
     
    
    32 34
     @GenerateJavaBeanDefinition
    
    33 35
     public class ActivityReference extends GeneratedActivityReference {
    
    34 36
     
    
    35 37
         private transient GPSPoint gpsPoint;
    
    36 38
     
    
    37
    -    public ActivityReference(DtoReferenceAware dto, Date timeStamp, Float latitude, Float longitude, String vesselActivityId, String vesselActivityLabel, SetReference set) {
    
    38
    -        super(dto, timeStamp, latitude, longitude, vesselActivityId, vesselActivityLabel, set);
    
    39
    +    public ActivityReference(DtoReferenceAware dto, Date timeStamp, Float latitude, Float longitude, VesselActivityReference vesselActivity, SetReference set) {
    
    40
    +        super(dto, timeStamp, latitude, longitude, vesselActivity, set);
    
    39 41
         }
    
    40 42
     
    
    41 43
         public ActivityReference(DtoReferenceAware dto) {
    
    42
    -        this(dto, null, null, null, null, null, null);
    
    44
    +        this(dto, null, null, null, null, null);
    
    43 45
         }
    
    44 46
     
    
    45 47
         @Override
    
    ... ... @@ -49,4 +51,19 @@ public class ActivityReference extends GeneratedActivityReference {
    49 51
             }
    
    50 52
             return gpsPoint;
    
    51 53
         }
    
    54
    +
    
    55
    +    @Override
    
    56
    +    public String getVesselActivityId() {
    
    57
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getId).orElse(null);
    
    58
    +    }
    
    59
    +
    
    60
    +    @Override
    
    61
    +    public String getVesselActivityLabel() {
    
    62
    +        return Optional.ofNullable(getVesselActivity()).map(VesselActivityReference::getLabel).orElse(null);
    
    63
    +    }
    
    64
    +
    
    65
    +    @Override
    
    66
    +    public boolean isSetOperation() {
    
    67
    +        return ActivityAware.isSetOperation(this);
    
    68
    +    }
    
    52 69
     }

  • dto/src/main/java/fr/ird/observe/dto/referential/ll/common/VesselActivityHelper.javadto/src/main/java/fr/ird/observe/dto/referential/ll/common/VesselActivityReference.java
    ... ... @@ -23,16 +23,21 @@ package fr.ird.observe.dto.referential.ll.common;
    23 23
      */
    
    24 24
     
    
    25 25
     import fr.ird.observe.dto.ProtectedIds;
    
    26
    +import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
    
    26 27
     
    
    27
    -public class VesselActivityHelper extends GeneratedVesselActivityHelper {
    
    28
    +@GenerateJavaBeanDefinition
    
    29
    +public class VesselActivityReference extends GeneratedVesselActivityReference {
    
    30
    +
    
    31
    +    public VesselActivityReference(fr.ird.observe.dto.reference.ReferentialDtoReferenceAware dto, java.lang.String code, String label, java.lang.String uri) {
    
    32
    +        super(dto, code, label, uri);
    
    33
    +    }
    
    28 34
     
    
    29 35
         public static boolean isSetOperation(String id) {
    
    30 36
             return ProtectedIds.LL_COMMON_VESSEL_ACTIVITY_ID_FOR_SET.equals(id);
    
    31 37
         }
    
    32 38
     
    
    33
    -    public static boolean isSetOperation(VesselActivityReference reference) {
    
    34
    -        return reference != null && isSetOperation(reference.getId());
    
    39
    +    public boolean isSetOperation() {
    
    40
    +        return isSetOperation(getId());
    
    35 41
         }
    
    36 42
     
    
    37
    -
    
    38
    -} //VesselActivityLonglineHelper
    43
    +}

  • dto/src/main/models/Observe-30-data-ll-observation.model
    ... ... @@ -6,7 +6,7 @@ interface data.ll.observation.LonglinePositionAwareDto
    6 6
     
    
    7 7
     interface data.ll.observation.LonglinePositionSetDto
    
    8 8
     
    
    9
    -data.ll.observation.Activity > data.Openable >> data.ActivityAware | references=timeStamp,latitude,longitude,vesselActivityId,vesselActivityLabel,set
    
    9
    +data.ll.observation.Activity > data.Openable >> data.ActivityAware | references=timeStamp,latitude,longitude,vesselActivity,set
    
    10 10
     timeStamp + {*:1} Date
    
    11 11
     latitude + {*:1} Float | notNull
    
    12 12
     longitude + {*:1} Float | notNull
    

  • dto/src/main/models/Observe-31-data-ll-logbook.model
    ... ... @@ -20,7 +20,7 @@ longitude + {*:1} Float
    20 20
     quadrant + {*:1} Integer
    
    21 21
     samplePart + {*} fr.ird.observe.dto.data.ll.logbook.SamplePartDto | ordered
    
    22 22
     
    
    23
    -data.ll.logbook.Activity > data.Openable >> data.ActivityAware | references=startTimeStamp,endTimeStamp,latitude,longitude,vesselActivityId,vesselActivityLabel,set,sample,relatedObservedActivity
    
    23
    +data.ll.logbook.Activity > data.Openable >> data.ActivityAware | references=startTimeStamp,endTimeStamp,latitude,longitude,vesselActivity,set,sample,relatedObservedActivity
    
    24 24
     startTimeStamp + {*:1} Date | notNull
    
    25 25
     endTimeStamp + {*:1} Date | mayNotNull
    
    26 26
     latitude + {*:1} Float | mayNotNull
    

  • persistence/src/main/java/fr/ird/observe/entities/data/ll/common/TripImpl.java
    ... ... @@ -25,7 +25,7 @@ package fr.ird.observe.entities.data.ll.common;
    25 25
     import fr.ird.observe.dto.data.DataDto;
    
    26 26
     import fr.ird.observe.dto.data.ll.common.TripDto;
    
    27 27
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    28
    -import fr.ird.observe.dto.referential.ll.common.VesselActivityHelper;
    
    28
    +import fr.ird.observe.entities.data.ActivityAware;
    
    29 29
     
    
    30 30
     /**
    
    31 31
      * Created on 8/27/14.
    
    ... ... @@ -93,10 +93,10 @@ public class TripImpl extends TripAbstract {
    93 93
         private int computeTotalFishingOperationsNumber() {
    
    94 94
             int result = 0;
    
    95 95
             if (isActivityLogbookNotEmpty()) {
    
    96
    -            result += activityLogbook.stream().filter(f -> VesselActivityHelper.isSetOperation(f.getVesselActivity().getTopiaId())).count();
    
    96
    +            result += activityLogbook.stream().filter(ActivityAware::isSetOperation).count();
    
    97 97
             }
    
    98 98
             if (isActivityObsNotEmpty()) {
    
    99
    -            result += activityObs.stream().filter(f -> VesselActivityHelper.isSetOperation(f.getVesselActivity().getTopiaId())).count();
    
    99
    +            result += activityObs.stream().filter(ActivityAware::isSetOperation).count();
    
    100 100
             }
    
    101 101
             return result;
    
    102 102
         }
    

  • persistence/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivityImpl.java
    ... ... @@ -29,6 +29,7 @@ import fr.ird.observe.dto.data.DataDto;
    29 29
     import fr.ird.observe.dto.data.ll.logbook.ActivityDto;
    
    30 30
     import fr.ird.observe.dto.data.ll.logbook.ActivityStubDto;
    
    31 31
     import fr.ird.observe.dto.referential.ReferentialLocale;
    
    32
    +import fr.ird.observe.dto.referential.ll.common.VesselActivityDto;
    
    32 33
     import fr.ird.observe.entities.referential.ll.common.VesselActivity;
    
    33 34
     import org.nuiton.util.DateUtil;
    
    34 35
     
    
    ... ... @@ -85,10 +86,8 @@ public class ActivityImpl extends ActivityAbstract {
    85 86
     
    
    86 87
         @Override
    
    87 88
         public void setVesselActivity(VesselActivity vesselActivity) {
    
    88
    -
    
    89 89
             super.setVesselActivity(vesselActivity);
    
    90 90
             fireOnPostWrite("setOperation", null, isSetOperation());
    
    91
    -
    
    92 91
         }
    
    93 92
     
    
    94 93
         @Override