Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
f2f85a78
by Tony CHEMIT at 2018-10-16T16:36:40Z
23 changed files:
- client/src/main/java/fr/ird/observe/client/ui/ObserveKeyStrokes.java
- + client/src/main/java/fr/ird/observe/client/ui/actions/content/data/longline/ChooseRelatedObservedActivityUIAction.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jaxx
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUI.jcss
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/content/data/longline/logbook/ActivityLonglineLogbookUIModel.java
- client/src/main/resources/i18n/client_en_GB.properties
- client/src/main/resources/i18n/client_es_ES.properties
- client/src/main/resources/i18n/client_fr_FR.properties
- dto/src/main/java/fr/ird/observe/dto/data/longline/ActivityLonglineAware.java
- dto/src/main/java/fr/ird/observe/dto/data/longline/ActivityLonglineLogbookDto.java
- dto/src/main/java/fr/ird/observe/dto/data/longline/ActivityLonglineObsDto.java
- dto/src/main/java/fr/ird/observe/dto/decoration/DecoratorService.java
- dto/src/main/resources/i18n/dto_en_GB.properties
- dto/src/main/resources/i18n/dto_es_ES.properties
- dto/src/main/resources/i18n/dto_fr_FR.properties
- services/pom.xml
- services/src/main/java/fr/ird/observe/services/service/actions/pairing/ActivityLonglinePairingEngine.java
- services/src/main/java/fr/ird/observe/services/service/actions/pairing/TripLonglinePairingContext.java
- dto/src/main/java/fr/ird/observe/dto/data/pairing/ActivityLonglinePairingResult.java → services/src/main/java/fr/ird/observe/services/service/data/longline/pairing/ActivityLonglinePairingResult.java
- dto/src/main/java/fr/ird/observe/dto/data/pairing/ActivityLonglinePairingResultItem.java → services/src/main/java/fr/ird/observe/services/service/data/longline/pairing/ActivityLonglinePairingResultItem.java
- + services/src/main/java/fr/ird/observe/services/service/data/longline/pairing/ActivityLonglinePairingResultItemDecorator.java
- dto/src/main/java/fr/ird/observe/dto/data/pairing/TripLonglinePairingResult.java → services/src/main/java/fr/ird/observe/services/service/data/longline/pairing/TripLonglinePairingResult.java
Changes:
| ... | ... | @@ -75,6 +75,7 @@ public abstract class ObserveKeyStrokes { |
| 75 | 75 |
public static final KeyStroke KEY_STROKE_CONFIGURE_SYNCHRO_FROM_BOTH = KeyStroke.getKeyStroke("ctrl pressed C");
|
| 76 | 76 |
|
| 77 | 77 |
public static final KeyStroke KEY_STROKE_COPY_VALUES_AND_SAVE = KeyStroke.getKeyStroke("ctrl pressed T");
|
| 78 |
+ public static final KeyStroke KEY_STROKE_CHOOSE_RELATED_OBSERVATION_ACTIVITY = KeyStroke.getKeyStroke("ctrl pressed T");
|
|
| 78 | 79 |
public static final KeyStroke KEY_STROKE_SELECT_TRANSSHIPMENT = KeyStroke.getKeyStroke("ctrl pressed T");
|
| 79 | 80 |
public static final KeyStroke KEY_STROKE_SAVE_TABLE_ENTRY = KeyStroke.getKeyStroke("ctrl pressed S");
|
| 80 | 81 |
public static final KeyStroke KEY_STROKE_PRESSED_ENTER = KeyStroke.getKeyStroke("pressed ENTER");
|
| 1 |
+package fr.ird.observe.client.ui.actions.content.data.longline;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Client
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.client.ObserveSwingApplicationContext;
|
|
| 26 |
+import fr.ird.observe.client.ui.ObserveKeyStrokes;
|
|
| 27 |
+import fr.ird.observe.client.ui.ObserveMainUI;
|
|
| 28 |
+import fr.ird.observe.client.ui.actions.content.api.AbstractContentUIAction;
|
|
| 29 |
+import fr.ird.observe.client.ui.content.api.ContentUI;
|
|
| 30 |
+import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookUI;
|
|
| 31 |
+import fr.ird.observe.client.ui.content.data.longline.logbook.ActivityLonglineLogbookUIModel;
|
|
| 32 |
+import fr.ird.observe.client.ui.content.ref.usage.UsageUIHandlerSupport;
|
|
| 33 |
+import fr.ird.observe.client.ui.util.UIHelper;
|
|
| 34 |
+import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookDto;
|
|
| 35 |
+import fr.ird.observe.dto.data.longline.ActivityLonglineObsDto;
|
|
| 36 |
+import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
|
| 37 |
+import fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResult;
|
|
| 38 |
+import fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResultItem;
|
|
| 39 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 40 |
+import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder;
|
|
| 41 |
+import fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResultItemDecorator;
|
|
| 42 |
+import fr.ird.observe.services.service.actions.pairing.ActivityLonglinePairingConfig;
|
|
| 43 |
+import fr.ird.observe.services.service.actions.pairing.ActivityLonglinePairingEngine;
|
|
| 44 |
+import fr.ird.observe.services.service.actions.pairing.TripLonglinePairingContext;
|
|
| 45 |
+import org.apache.logging.log4j.LogManager;
|
|
| 46 |
+import org.apache.logging.log4j.Logger;
|
|
| 47 |
+import org.nuiton.jaxx.widgets.select.BeanFilterableComboBox;
|
|
| 48 |
+ |
|
| 49 |
+import javax.swing.JButton;
|
|
| 50 |
+import javax.swing.JLabel;
|
|
| 51 |
+import javax.swing.JOptionPane;
|
|
| 52 |
+import javax.swing.JPanel;
|
|
| 53 |
+import java.awt.BorderLayout;
|
|
| 54 |
+import java.util.ArrayList;
|
|
| 55 |
+import java.util.List;
|
|
| 56 |
+import java.util.Objects;
|
|
| 57 |
+import java.util.Optional;
|
|
| 58 |
+ |
|
| 59 |
+import static org.nuiton.i18n.I18n.n;
|
|
| 60 |
+import static org.nuiton.i18n.I18n.t;
|
|
| 61 |
+ |
|
| 62 |
+/**
|
|
| 63 |
+ * Created by tchemit on 16/10/2018.
|
|
| 64 |
+ *
|
|
| 65 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 66 |
+ */
|
|
| 67 |
+public class ChooseRelatedObservedActivityUIAction extends AbstractContentUIAction {
|
|
| 68 |
+ |
|
| 69 |
+ public static final String ACTION_NAME = ChooseRelatedObservedActivityUIAction.class.getName();
|
|
| 70 |
+ private static final Logger log = LogManager.getLogger(ChooseRelatedObservedActivityUIAction.class);
|
|
| 71 |
+ private final ActivityLonglinePairingResultItemDecorator decorator;
|
|
| 72 |
+ |
|
| 73 |
+ public ChooseRelatedObservedActivityUIAction(ObserveMainUI mainUI) {
|
|
| 74 |
+ super(mainUI, ACTION_NAME, n("observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity"), n("observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity"), "data-calcule", ObserveKeyStrokes.KEY_STROKE_CHOOSE_RELATED_OBSERVATION_ACTIVITY);
|
|
| 75 |
+ ObserveSwingApplicationContext applicationContext = ObserveSwingApplicationContext.get();
|
|
| 76 |
+ DecoratorService decoratorService = applicationContext.getDecoratorService();
|
|
| 77 |
+ decorator = new ActivityLonglinePairingResultItemDecorator(decoratorService, applicationContext.getConfig().getLocale());
|
|
| 78 |
+ }
|
|
| 79 |
+ |
|
| 80 |
+ @Override
|
|
| 81 |
+ protected void actionPerformed(ContentUI contentUI) {
|
|
| 82 |
+ |
|
| 83 |
+ ActivityLonglineLogbookUI ui = (ActivityLonglineLogbookUI) contentUI;
|
|
| 84 |
+ ActivityLonglineLogbookUIModel model = ui.getModel();
|
|
| 85 |
+ |
|
| 86 |
+ ActivityLonglinePairingEngine pairingEngine = new ActivityLonglinePairingEngine(getServicesProvider(), ui.getConfig());
|
|
| 87 |
+ |
|
| 88 |
+ ActivityLonglineLogbookDto bean = model.getBean();
|
|
| 89 |
+ |
|
| 90 |
+ TripLonglinePairingContext pairingContext = pairingEngine.newTripContext(model.getSelectedParentId(), model.getAllActivityObs());
|
|
| 91 |
+ |
|
| 92 |
+ ActivityLonglinePairingResult activityLonglinePairingResult = pairingEngine.computeForActivityLogbook(pairingContext, bean);
|
|
| 93 |
+ |
|
| 94 |
+ Optional<ActivityLonglineObsReference> optionalActivityLonglineObs = askNewParent(activityLonglinePairingResult.getItems(), pairingEngine.getConfig());
|
|
| 95 |
+ |
|
| 96 |
+ if (optionalActivityLonglineObs.isPresent()) {
|
|
| 97 |
+ ActivityLonglineObsReference activityLonglineObs = optionalActivityLonglineObs.get();
|
|
| 98 |
+ log.info("will use new related activity obs: " + activityLonglineObs);
|
|
| 99 |
+ bean.setRelatedObservedActivity(activityLonglineObs);
|
|
| 100 |
+ }
|
|
| 101 |
+ }
|
|
| 102 |
+ |
|
| 103 |
+ private Optional<ActivityLonglineObsReference> askNewParent(List<ActivityLonglinePairingResultItem> pairingResult, ActivityLonglinePairingConfig pairingConfig) {
|
|
| 104 |
+ |
|
| 105 |
+ BeanFilterableComboBox<ActivityLonglinePairingResultItem> editor = new BeanFilterableComboBox<>();
|
|
| 106 |
+ editor.setI18nPrefix("observe.common.");
|
|
| 107 |
+ editor.setBeanType(ActivityLonglinePairingResultItem.class);
|
|
| 108 |
+ editor.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(ActivityLonglineObsDto.class));
|
|
| 109 |
+ |
|
| 110 |
+ editor.init(decorator, new ArrayList<>(pairingResult));
|
|
| 111 |
+ |
|
| 112 |
+// JComboBox combobox = editor.getCombobox();
|
|
| 113 |
+// @SuppressWarnings("unchecked") ListCellRenderer toolTipRenderer = new ComboBoxListCellRenderer(combobox.getRenderer());
|
|
| 114 |
+// combobox.setRenderer(toolTipRenderer);
|
|
| 115 |
+ |
|
| 116 |
+ String continueActionText = t("observe.choice.continue");
|
|
| 117 |
+ Object[] options = {continueActionText, t("observe.choice.cancel")};
|
|
| 118 |
+ JPanel panel = new JPanel(new BorderLayout());
|
|
| 119 |
+ panel.add(BorderLayout.NORTH, new JLabel(t("observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.message",
|
|
| 120 |
+ pairingConfig.getLonglineActivityPairingMaxTime(), pairingConfig.getLonglineActivityPairingMaxDistance())));
|
|
| 121 |
+ panel.add(BorderLayout.CENTER, editor);
|
|
| 122 |
+ |
|
| 123 |
+ JOptionPane pane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]);
|
|
| 124 |
+ |
|
| 125 |
+ JButton jButton = UsageUIHandlerSupport.findButton(pane, continueActionText);
|
|
| 126 |
+ Objects.requireNonNull(jButton);
|
|
| 127 |
+ jButton.setEnabled(false);
|
|
| 128 |
+ editor.addPropertyChangeListener("selectedItem", evt -> jButton.setEnabled(evt.getNewValue() != null));
|
|
| 129 |
+ |
|
| 130 |
+ int response = UIHelper.askUser(ObserveSwingApplicationContext.get().getMainUI(), pane, t("observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.title"), options);
|
|
| 131 |
+ |
|
| 132 |
+ ActivityLonglinePairingResultItem newActivityLonglineObs = null;
|
|
| 133 |
+ switch (response) {
|
|
| 134 |
+ case 0:
|
|
| 135 |
+ newActivityLonglineObs = editor.getComboBoxModel().getSelectedItem();
|
|
| 136 |
+ log.info(String.format("Selected new related observed activity id: %s", newActivityLonglineObs));
|
|
| 137 |
+ break;
|
|
| 138 |
+ default:
|
|
| 139 |
+ log.info("Use cancel choice of related observed activity");
|
|
| 140 |
+ }
|
|
| 141 |
+ return Optional.ofNullable(newActivityLonglineObs).map(ActivityLonglinePairingResultItem::getObservationActivity);
|
|
| 142 |
+ }
|
|
| 143 |
+ |
|
| 144 |
+}
|
|
| 145 |
+ |
| ... | ... | @@ -41,8 +41,9 @@ |
| 41 | 41 |
fr.ird.observe.client.ui.actions.content.data.longline.delete.DeleteActivityLonglineLogbookUIAction
|
| 42 | 42 |
fr.ird.observe.client.ui.actions.content.data.longline.move.MoveSingleActivityLonglineLogbookUIAction
|
| 43 | 43 |
fr.ird.observe.client.ui.actions.content.data.longline.save.SaveActivityLonglineLogbookUIAction
|
| 44 |
+ fr.ird.observe.client.ui.actions.content.data.longline.ChooseRelatedObservedActivityUIAction
|
|
| 44 | 45 |
|
| 45 |
- fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResultItem
|
|
| 46 |
+ fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResultItem
|
|
| 46 | 47 |
|
| 47 | 48 |
fr.ird.observe.client.ui.util.JComment
|
| 48 | 49 |
|
| ... | ... | @@ -190,7 +191,10 @@ |
| 190 | 191 |
<JLabel id='relatedObservedActivityLabel'/>
|
| 191 | 192 |
</cell>
|
| 192 | 193 |
<cell anchor='east' fill="both">
|
| 193 |
- <BeanFilterableComboBox id='relatedObservedActivity' genericType='ActivityLonglinePairingResultItem' constructorParams='this'/>
|
|
| 194 |
+ <JPanel layout="{new BorderLayout()}">
|
|
| 195 |
+ <BeanFilterableComboBox id='relatedObservedActivity' genericType='ActivityLonglineObsReference' constructorParams='this' constraints='BorderLayout.CENTER'/>
|
|
| 196 |
+ <JButton id='chooseRelatedObservedActivity' constraints='BorderLayout.EAST'/>
|
|
| 197 |
+ </JPanel>
|
|
| 194 | 198 |
</cell>
|
| 195 | 199 |
</row>
|
| 196 | 200 |
|
| ... | ... | @@ -84,10 +84,8 @@ |
| 84 | 84 |
|
| 85 | 85 |
#relatedObservedActivity {
|
| 86 | 86 |
_listNoLoad:true;
|
| 87 |
- bean:{model};
|
|
| 88 |
- property:activityObs;
|
|
| 89 |
- data:{model.getActivityObsCandidates()};
|
|
| 90 |
- selectedItem:{model.getActivityObs()};
|
|
| 87 |
+ data:{model.getActivityObs()};
|
|
| 88 |
+ selectedItem:{bean.getRelatedObservedActivity()};
|
|
| 91 | 89 |
}
|
| 92 | 90 |
|
| 93 | 91 |
#reopen {
|
| ... | ... | @@ -119,3 +117,9 @@ |
| 119 | 117 |
enabled:{!model.isModified() && model.isValid() && model.isSetOperation() && ! bean.isHasSetLongline()};
|
| 120 | 118 |
_observeAction:{AddActivityLonglineLogbookSetUIAction.ACTION_NAME};
|
| 121 | 119 |
}
|
| 120 |
+ |
|
| 121 |
+#chooseRelatedObservedActivity {
|
|
| 122 |
+ visible:{!model.isReadingMode()};
|
|
| 123 |
+ enabled:{model.isValid()};
|
|
| 124 |
+ _observeAction:{ChooseRelatedObservedActivityUIAction.ACTION_NAME};
|
|
| 125 |
+}
|
|
| \ No newline at end of file |
| ... | ... | @@ -22,44 +22,19 @@ package fr.ird.observe.client.ui.content.data.longline.logbook; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import com.google.common.collect.ImmutableSet;
|
|
| 26 | 25 |
import fr.ird.observe.client.ui.content.api.data.open.ContentOpenableUIHandler;
|
| 27 |
-import fr.ird.observe.client.ui.content.api.data.open.ContentOpenableUIInitializer;
|
|
| 28 | 26 |
import fr.ird.observe.client.ui.content.api.ui.ObserveLayoutFocusTraversalPolicy;
|
| 29 | 27 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookDto;
|
| 30 | 28 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookReference;
|
| 31 |
-import fr.ird.observe.dto.data.longline.ActivityLonglineObsDto;
|
|
| 32 | 29 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 33 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResult;
|
|
| 34 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResultItem;
|
|
| 35 |
-import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper;
|
|
| 36 |
-import fr.ird.observe.dto.decoration.ObserveI18nLabelsBuilder;
|
|
| 37 | 30 |
import fr.ird.observe.dto.form.Form;
|
| 38 |
-import fr.ird.observe.services.service.actions.pairing.ActivityLonglinePairingEngine;
|
|
| 39 |
-import fr.ird.observe.services.service.actions.pairing.TripLonglinePairingContext;
|
|
| 40 |
-import org.apache.commons.lang3.StringUtils;
|
|
| 41 | 31 |
import org.apache.logging.log4j.LogManager;
|
| 42 | 32 |
import org.apache.logging.log4j.Logger;
|
| 43 |
-import org.nuiton.decorator.Decorator;
|
|
| 44 |
-import org.nuiton.decorator.JXPathDecorator;
|
|
| 45 | 33 |
import org.nuiton.jaxx.runtime.spi.UIHandler;
|
| 46 |
-import org.nuiton.jaxx.widgets.select.BeanFilterableComboBox;
|
|
| 47 | 34 |
|
| 48 |
-import javax.swing.JComboBox;
|
|
| 49 |
-import javax.swing.JComponent;
|
|
| 50 |
-import javax.swing.JLabel;
|
|
| 51 |
-import javax.swing.JList;
|
|
| 52 |
-import javax.swing.KeyStroke;
|
|
| 53 |
-import javax.swing.ListCellRenderer;
|
|
| 54 | 35 |
import java.awt.Component;
|
| 55 | 36 |
import java.awt.Container;
|
| 56 |
-import java.awt.Dimension;
|
|
| 57 |
-import java.awt.event.KeyEvent;
|
|
| 58 |
-import java.beans.PropertyChangeListener;
|
|
| 59 |
-import java.util.Collections;
|
|
| 60 |
-import java.util.Optional;
|
|
| 61 |
- |
|
| 62 |
-import static org.nuiton.i18n.I18n.t;
|
|
| 37 |
+import java.util.List;
|
|
| 63 | 38 |
|
| 64 | 39 |
/**
|
| 65 | 40 |
* Created on 8/29/14.
|
| ... | ... | @@ -69,65 +44,13 @@ import static org.nuiton.i18n.I18n.t; |
| 69 | 44 |
*/
|
| 70 | 45 |
class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<ActivityLonglineLogbookDto, ActivityLonglineLogbookReference, ActivityLonglineLogbookUI> implements UIHandler<ActivityLonglineLogbookUI> {
|
| 71 | 46 |
|
| 72 |
- private static final ImmutableSet<String> PAIRING_PROPERTIES = ImmutableSet.of(
|
|
| 73 |
- ActivityLonglineLogbookDto.PROPERTY_LATITUDE,
|
|
| 74 |
- ActivityLonglineLogbookDto.PROPERTY_LONGITUDE,
|
|
| 75 |
- ActivityLonglineLogbookDto.PROPERTY_TIME_STAMP,
|
|
| 76 |
- ActivityLonglineLogbookUIModel.PROPERTY_VALID);
|
|
| 77 |
- |
|
| 78 | 47 |
private static final Logger log = LogManager.getLogger(ActivityLonglineLogbookUIHandler.class);
|
| 79 |
- private final PropertyChangeListener onRecomputePairing;
|
|
| 80 |
- private final PropertyChangeListener onActivityObsChanged;
|
|
| 81 |
- private ActivityLonglinePairingEngine pairingEngine;
|
|
| 82 |
- private boolean adjusting;
|
|
| 83 |
- |
|
| 84 |
- ActivityLonglineLogbookUIHandler() {
|
|
| 85 |
- onRecomputePairing = e -> onRecomputePairing(e.getPropertyName());
|
|
| 86 |
- onActivityObsChanged = e -> onActivityObsChanged();
|
|
| 87 |
- }
|
|
| 88 | 48 |
|
| 89 | 49 |
@Override
|
| 90 | 50 |
public ActivityLonglineLogbookUIModel getModel() {
|
| 91 | 51 |
return ui.getModel();
|
| 92 | 52 |
}
|
| 93 | 53 |
|
| 94 |
- @Override
|
|
| 95 |
- protected ContentOpenableUIInitializer<ActivityLonglineLogbookUI> createContentUIInitializer(ActivityLonglineLogbookUI ui) {
|
|
| 96 |
- return new ContentOpenableUIInitializer<ActivityLonglineLogbookUI>(ui) {
|
|
| 97 |
- |
|
| 98 |
- @SuppressWarnings("unchecked")
|
|
| 99 |
- protected void init(BeanFilterableComboBox comboBox) {
|
|
| 100 |
- if (!"relatedObservedActivity".equals(comboBox.getName())) {
|
|
| 101 |
- super.init(comboBox);
|
|
| 102 |
- return;
|
|
| 103 |
- }
|
|
| 104 |
- |
|
| 105 |
- comboBox.getCombobox().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0), "none");
|
|
| 106 |
- Class referenceType = comboBox.getBeanType();
|
|
| 107 |
- comboBox.setI18nLabelBuilder(ObserveI18nLabelsBuilder.createFromReferenceType(ActivityLonglineObsDto.class));
|
|
| 108 |
- comboBox.setI18nPrefix("observe.common.");
|
|
| 109 |
- comboBox.setMinimumSize(new Dimension(0, 24));
|
|
| 110 |
- |
|
| 111 |
- if (StringUtils.isEmpty(comboBox.getProperty())) {
|
|
| 112 |
- comboBox.setProperty(comboBox.getName());
|
|
| 113 |
- }
|
|
| 114 |
- |
|
| 115 |
- log.info("Init relatedObservedActivity comboBox");
|
|
| 116 |
- Decorator decorator = decoratorService.getDecoratorByType(referenceType);
|
|
| 117 |
- |
|
| 118 |
- String entityLabel = t(ObserveI18nDecoratorHelper.getTypeI18nKey(ActivityLonglineObsDto.class));
|
|
| 119 |
- comboBox.setPopupTitleText(t("observe.common.DataDto.type", entityLabel));
|
|
| 120 |
- |
|
| 121 |
- comboBox.init((JXPathDecorator) decorator, Collections.emptyList());
|
|
| 122 |
- |
|
| 123 |
- JComboBox combobox = comboBox.getCombobox();
|
|
| 124 |
- |
|
| 125 |
- @SuppressWarnings("unchecked") ListCellRenderer toolTipRenderer = new ComboBoxListCellRenderer(combobox.getRenderer());
|
|
| 126 |
- combobox.setRenderer(toolTipRenderer);
|
|
| 127 |
- }
|
|
| 128 |
- };
|
|
| 129 |
- }
|
|
| 130 |
- |
|
| 131 | 54 |
@Override
|
| 132 | 55 |
protected ObserveLayoutFocusTraversalPolicy<ActivityLonglineLogbookUI> createFocusTraversalPolicy() {
|
| 133 | 56 |
return new ObserveLayoutFocusTraversalPolicy<ActivityLonglineLogbookUI>() {
|
| ... | ... | @@ -148,101 +71,6 @@ class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<Activity |
| 148 | 71 |
};
|
| 149 | 72 |
}
|
| 150 | 73 |
|
| 151 |
- @Override
|
|
| 152 |
- public void afterInit(ActivityLonglineLogbookUI ui) {
|
|
| 153 |
- super.afterInit(ui);
|
|
| 154 |
- pairingEngine = getDataSource().newActivityLonglinePairingEngine(ui.getConfig());
|
|
| 155 |
- }
|
|
| 156 |
- |
|
| 157 |
- private void onRecomputePairing(String propertyName) {
|
|
| 158 |
- if (adjusting || !PAIRING_PROPERTIES.contains(propertyName)) {
|
|
| 159 |
- return;
|
|
| 160 |
- }
|
|
| 161 |
- log.info(prefix + "Need to recompute pairing data.");
|
|
| 162 |
- ActivityLonglineLogbookUIModel model = getModel();
|
|
| 163 |
- if (!model.isValid()) {
|
|
| 164 |
- log.info(prefix + "Reject: model is not valid.");
|
|
| 165 |
- return;
|
|
| 166 |
- }
|
|
| 167 |
- adjusting = true;
|
|
| 168 |
- try {
|
|
| 169 |
- ActivityLonglineLogbookDto bean = model.getBean();
|
|
| 170 |
- ActivityLonglinePairingResult activityLonglinePairingResult = pairingEngine.computeForActivityLogbook(model.getPairingContext(), bean);
|
|
| 171 |
- ActivityLonglinePairingResultItem pairingActivityObs = model.getActivityObs();
|
|
| 172 |
- ActivityLonglineObsReference relatedObservedActivity = model.getBean().getRelatedObservedActivity();
|
|
| 173 |
- |
|
| 174 |
- model.setActivityObsCandidates(activityLonglinePairingResult.getItems());
|
|
| 175 |
- |
|
| 176 |
- if (pairingActivityObs == null) {
|
|
| 177 |
- |
|
| 178 |
- if (relatedObservedActivity != null) {
|
|
| 179 |
- // use dto value
|
|
| 180 |
- Optional<ActivityLonglinePairingResultItem> first = model.getActivityObsCandidates().stream().filter(e -> e.getObservationActivity().equals(relatedObservedActivity)).findFirst();
|
|
| 181 |
- if (!first.isPresent()) {
|
|
| 182 |
- // Should never occurs ?
|
|
| 183 |
- bean.setRelatedObservedActivity(null);
|
|
| 184 |
- } else {
|
|
| 185 |
- pairingActivityObs = first.get();
|
|
| 186 |
- model.setActivityObs(pairingActivityObs);
|
|
| 187 |
- bean.setRelatedObservedActivity(pairingActivityObs.getObservationActivity());
|
|
| 188 |
- }
|
|
| 189 |
- }
|
|
| 190 |
- } else {
|
|
| 191 |
- if (!model.getActivityObsCandidates().contains(pairingActivityObs)) {
|
|
| 192 |
- // can not keep this pairing,
|
|
| 193 |
- model.setActivityObs(null);
|
|
| 194 |
- bean.setRelatedObservedActivity(null);
|
|
| 195 |
- } else {
|
|
| 196 |
- // keep this pairing
|
|
| 197 |
- // use pairing value
|
|
| 198 |
- bean.setRelatedObservedActivity(pairingActivityObs.getObservationActivity());
|
|
| 199 |
- }
|
|
| 200 |
- }
|
|
| 201 |
- } finally {
|
|
| 202 |
- adjusting = false;
|
|
| 203 |
- }
|
|
| 204 |
- }
|
|
| 205 |
- |
|
| 206 |
- private void onActivityObsChanged() {
|
|
| 207 |
- if (adjusting) {
|
|
| 208 |
- return;
|
|
| 209 |
- }
|
|
| 210 |
- adjusting = true;
|
|
| 211 |
- try {
|
|
| 212 |
- ActivityLonglineLogbookUIModel model = getModel();
|
|
| 213 |
- ActivityLonglinePairingResultItem activityObs = model.getActivityObs();
|
|
| 214 |
- model.getBean().setRelatedObservedActivity(activityObs == null ? null : activityObs.getObservationActivity());
|
|
| 215 |
- } finally {
|
|
| 216 |
- adjusting = false;
|
|
| 217 |
- }
|
|
| 218 |
- }
|
|
| 219 |
- |
|
| 220 |
- @Override
|
|
| 221 |
- protected void onOpenBeforeOpenModel() {
|
|
| 222 |
- ActivityLonglineLogbookUIModel model = getModel();
|
|
| 223 |
- ActivityLonglineLogbookDto bean = model.getBean();
|
|
| 224 |
- model.removePropertyChangeListener(ActivityLonglineLogbookUIModel.PROPERTY_VALID, onRecomputePairing);
|
|
| 225 |
- bean.removePropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_LATITUDE, onRecomputePairing);
|
|
| 226 |
- bean.removePropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_LONGITUDE, onRecomputePairing);
|
|
| 227 |
- bean.removePropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_TIME_STAMP, onRecomputePairing);
|
|
| 228 |
- bean.removePropertyChangeListener("activityObs", onActivityObsChanged);
|
|
| 229 |
- |
|
| 230 |
- super.onOpenBeforeOpenModel();
|
|
| 231 |
- }
|
|
| 232 |
- |
|
| 233 |
- @Override
|
|
| 234 |
- protected void onOpenAfterOpenModel() {
|
|
| 235 |
- super.onOpenAfterOpenModel();
|
|
| 236 |
- ActivityLonglineLogbookUIModel model = getModel();
|
|
| 237 |
- ActivityLonglineLogbookDto bean = model.getBean();
|
|
| 238 |
- model.addPropertyChangeListener(ActivityLonglineLogbookUIModel.PROPERTY_VALID, onRecomputePairing);
|
|
| 239 |
- bean.addPropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_LATITUDE, onRecomputePairing);
|
|
| 240 |
- bean.addPropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_LONGITUDE, onRecomputePairing);
|
|
| 241 |
- bean.addPropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_TIME_STAMP, onRecomputePairing);
|
|
| 242 |
- bean.addPropertyChangeListener("activityObs", onActivityObsChanged);
|
|
| 243 |
- onRecomputePairing(ActivityLonglineLogbookUIModel.PROPERTY_VALID);
|
|
| 244 |
- }
|
|
| 245 |
- |
|
| 246 | 74 |
@Override
|
| 247 | 75 |
protected void onOpenModel() {
|
| 248 | 76 |
super.onOpenModel();
|
| ... | ... | @@ -260,37 +88,8 @@ class ActivityLonglineLogbookUIHandler extends ContentOpenableUIHandler<Activity |
| 260 | 88 |
form = getActivityLonglineLogbookService().loadForm(activityId);
|
| 261 | 89 |
}
|
| 262 | 90 |
|
| 263 |
- TripLonglinePairingContext pairingContext = pairingEngine.newTripContext(tripId);
|
|
| 264 |
- model.openForm(form, pairingContext);
|
|
| 91 |
+ List<ActivityLonglineObsReference> allActivityLonglineObs = getActivityLonglineObsService().getActivityLonglineByTripLongline(tripId).toList();
|
|
| 92 |
+ model.openForm(form, allActivityLonglineObs);
|
|
| 265 | 93 |
}
|
| 266 | 94 |
|
| 267 |
- |
|
| 268 |
- private static class ComboBoxListCellRenderer<E extends ActivityLonglinePairingResultItem> implements ListCellRenderer<E> {
|
|
| 269 |
- |
|
| 270 |
- private final ListCellRenderer<? super E> renderer;
|
|
| 271 |
- |
|
| 272 |
- ComboBoxListCellRenderer(ListCellRenderer<? super E> renderer) {
|
|
| 273 |
- this.renderer = renderer;
|
|
| 274 |
- }
|
|
| 275 |
- |
|
| 276 |
- @Override
|
|
| 277 |
- public Component getListCellRendererComponent(JList<? extends E> list,
|
|
| 278 |
- E value,
|
|
| 279 |
- int index,
|
|
| 280 |
- boolean isSelected,
|
|
| 281 |
- boolean cellHasFocus) {
|
|
| 282 |
- Component comp = renderer.getListCellRendererComponent(
|
|
| 283 |
- list,
|
|
| 284 |
- value,
|
|
| 285 |
- index,
|
|
| 286 |
- isSelected,
|
|
| 287 |
- cellHasFocus
|
|
| 288 |
- );
|
|
| 289 |
- if (comp instanceof JLabel) {
|
|
| 290 |
- JLabel jcomp = (JLabel) comp;
|
|
| 291 |
- jcomp.setToolTipText(jcomp.getText());
|
|
| 292 |
- }
|
|
| 293 |
- return comp;
|
|
| 294 |
- }
|
|
| 295 |
- }
|
|
| 296 | 95 |
}
|
| ... | ... | @@ -22,20 +22,23 @@ package fr.ird.observe.client.ui.content.data.longline.logbook; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import com.google.common.collect.ImmutableList;
|
|
| 25 | 26 |
import fr.ird.observe.client.ui.content.api.data.open.ContentOpenableUIModel;
|
| 26 | 27 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookDto;
|
| 27 | 28 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookReference;
|
| 28 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResultItem;
|
|
| 29 |
+import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
|
| 29 | 30 |
import fr.ird.observe.dto.form.Form;
|
| 30 | 31 |
import fr.ird.observe.dto.referential.longline.VesselActivityLonglineHelper;
|
| 31 | 32 |
import fr.ird.observe.dto.referential.longline.VesselActivityLonglineReference;
|
| 32 |
-import fr.ird.observe.services.service.actions.pairing.TripLonglinePairingContext;
|
|
| 33 |
+import org.apache.logging.log4j.LogManager;
|
|
| 34 |
+import org.apache.logging.log4j.Logger;
|
|
| 33 | 35 |
import org.nuiton.i18n.I18n;
|
| 34 | 36 |
import org.nuiton.util.DateUtil;
|
| 35 | 37 |
|
| 36 |
-import java.util.ArrayList;
|
|
| 38 |
+import java.util.Collections;
|
|
| 37 | 39 |
import java.util.Date;
|
| 38 | 40 |
import java.util.List;
|
| 41 |
+import java.util.stream.Collectors;
|
|
| 39 | 42 |
|
| 40 | 43 |
/**
|
| 41 | 44 |
* Created on 9/26/14.
|
| ... | ... | @@ -45,22 +48,26 @@ import java.util.List; |
| 45 | 48 |
*/
|
| 46 | 49 |
public class ActivityLonglineLogbookUIModel extends ContentOpenableUIModel<ActivityLonglineLogbookDto, ActivityLonglineLogbookReference> {
|
| 47 | 50 |
|
| 48 |
- public static final String PROPERTY_SET_OPERATION = "setOperation";
|
|
| 49 | 51 |
public static final String PROPERTY_DATE = "date";
|
| 50 | 52 |
public static final String PROPERTY_TIME = "time";
|
| 53 |
+ private static final String PROPERTY_SET_OPERATION = "setOperation";
|
|
| 51 | 54 |
private static final long serialVersionUID = 1L;
|
| 52 |
- |
|
| 53 |
- private TripLonglinePairingContext pairingContext;
|
|
| 54 |
- private List<ActivityLonglinePairingResultItem> activityObsCandidates;
|
|
| 55 |
- private ActivityLonglinePairingResultItem activityObs;
|
|
| 55 |
+ private static final Logger log = LogManager.getLogger(ActivityLonglineLogbookUIModel.class);
|
|
| 56 |
+ private List<ActivityLonglineObsReference> allActivityObs;
|
|
| 57 |
+ private List<ActivityLonglineObsReference> activityObs;
|
|
| 58 |
+ private boolean opening = false;
|
|
| 56 | 59 |
|
| 57 | 60 |
public ActivityLonglineLogbookUIModel() {
|
| 58 | 61 |
super(ActivityLonglineLogbookDto.class, I18n.n("observe.common.ActivityLonglineLogbookDto.message.not.open"));
|
| 59 | 62 |
|
| 60 | 63 |
getBean().addPropertyChangeListener(ActivityLonglineLogbookDto.PROPERTY_VESSEL_ACTIVITY_LONGLINE, evt -> {
|
| 61 | 64 |
boolean oldValue = VesselActivityLonglineHelper.isSetOperation((VesselActivityLonglineReference) evt.getOldValue());
|
| 62 |
- boolean newValue = VesselActivityLonglineHelper.isSetOperation((VesselActivityLonglineReference) evt.getNewValue());
|
|
| 65 |
+ VesselActivityLonglineReference vesselActivityLonglineReference = (VesselActivityLonglineReference) evt.getNewValue();
|
|
| 66 |
+ boolean newValue = VesselActivityLonglineHelper.isSetOperation(vesselActivityLonglineReference);
|
|
| 63 | 67 |
firePropertyChange(PROPERTY_SET_OPERATION, oldValue, newValue);
|
| 68 |
+ if (!opening) {
|
|
| 69 |
+ updateActivityObs();
|
|
| 70 |
+ }
|
|
| 64 | 71 |
});
|
| 65 | 72 |
}
|
| 66 | 73 |
|
| ... | ... | @@ -94,31 +101,45 @@ public class ActivityLonglineLogbookUIModel extends ContentOpenableUIModel<Activ |
| 94 | 101 |
}
|
| 95 | 102 |
}
|
| 96 | 103 |
|
| 97 |
- public void openForm(Form<ActivityLonglineLogbookDto> form, TripLonglinePairingContext pairingContext) {
|
|
| 98 |
- this.pairingContext = pairingContext;
|
|
| 99 |
- super.openForm(form);
|
|
| 100 |
- }
|
|
| 101 |
- |
|
| 102 |
- public TripLonglinePairingContext getPairingContext() {
|
|
| 103 |
- return pairingContext;
|
|
| 104 |
+ public void openForm(Form<ActivityLonglineLogbookDto> form, List<ActivityLonglineObsReference> allActivityObs) {
|
|
| 105 |
+ this.allActivityObs = ImmutableList.copyOf(allActivityObs);
|
|
| 106 |
+ opening = true;
|
|
| 107 |
+ try {
|
|
| 108 |
+ super.openForm(form);
|
|
| 109 |
+ } finally {
|
|
| 110 |
+ opening = false;
|
|
| 111 |
+ }
|
|
| 112 |
+ updateActivityObs();
|
|
| 104 | 113 |
}
|
| 105 | 114 |
|
| 106 |
- public List<ActivityLonglinePairingResultItem> getActivityObsCandidates() {
|
|
| 107 |
- return activityObsCandidates;
|
|
| 115 |
+ public List<ActivityLonglineObsReference> getActivityObs() {
|
|
| 116 |
+ return activityObs;
|
|
| 108 | 117 |
}
|
| 109 | 118 |
|
| 110 |
- public void setActivityObsCandidates(List<ActivityLonglinePairingResultItem> activityObsCandidates) {
|
|
| 111 |
- this.activityObsCandidates = activityObsCandidates == null ? null : new ArrayList<>(activityObsCandidates);
|
|
| 112 |
- firePropertyChange("activityObsCandidates", null, this.activityObsCandidates);
|
|
| 119 |
+ public void setActivityObs(List<ActivityLonglineObsReference> activityObs) {
|
|
| 120 |
+ // only used for jaxx binding
|
|
| 113 | 121 |
}
|
| 114 | 122 |
|
| 115 |
- public ActivityLonglinePairingResultItem getActivityObs() {
|
|
| 116 |
- return activityObs;
|
|
| 123 |
+ public List<ActivityLonglineObsReference> getAllActivityObs() {
|
|
| 124 |
+ return allActivityObs;
|
|
| 117 | 125 |
}
|
| 118 | 126 |
|
| 119 |
- public void setActivityObs(ActivityLonglinePairingResultItem activityObs) {
|
|
| 120 |
- ActivityLonglinePairingResultItem oldValue = getActivityObs();
|
|
| 121 |
- this.activityObs = activityObs;
|
|
| 122 |
- firePropertyChange("activityObs", oldValue, activityObs);
|
|
| 127 |
+ private void updateActivityObs() {
|
|
| 128 |
+ log.info(getPrefix() + "Will update release observed actities...");
|
|
| 129 |
+ ActivityLonglineLogbookDto bean = getBean();
|
|
| 130 |
+ if (allActivityObs == null || bean.getVesselActivityLonglineId() == null) {
|
|
| 131 |
+ activityObs = Collections.emptyList();
|
|
| 132 |
+ } else {
|
|
| 133 |
+ String vesselActivityLonglineId = bean.getVesselActivityLonglineId();
|
|
| 134 |
+ activityObs = allActivityObs.stream().filter(e -> vesselActivityLonglineId.equals(e.getVesselActivityLonglineId())).collect(Collectors.toList());
|
|
| 135 |
+ }
|
|
| 136 |
+ log.info(getPrefix() + "Found " + activityObs.size() + " related observed activities.");
|
|
| 137 |
+ ActivityLonglineObsReference relatedObservedActivity = bean.getRelatedObservedActivity();
|
|
| 138 |
+ boolean removeRelatedObservedActivity = !opening && relatedObservedActivity != null && !activityObs.contains(relatedObservedActivity);
|
|
| 139 |
+ firePropertyChange("activityObs", null, activityObs);
|
|
| 140 |
+ if (removeRelatedObservedActivity) {
|
|
| 141 |
+ log.info(getPrefix() + "Removed not matching related observed activity: " + relatedObservedActivity);
|
|
| 142 |
+ bean.setRelatedObservedActivity(null);
|
|
| 143 |
+ }
|
|
| 123 | 144 |
}
|
| 124 | 145 |
}
|
| ... | ... | @@ -363,6 +363,9 @@ observe.common.ActivityLogbookDto.action.goToOpen.short=Logbook - Open activity |
| 363 | 363 |
observe.common.ActivityLogbookDto.action.goToOpen.tip=Go to open activity (Logbook)
|
| 364 | 364 |
observe.common.ActivityLonglineLogbookDto.action.addSet=Add the fishing operation
|
| 365 | 365 |
observe.common.ActivityLonglineLogbookDto.action.addSet.tip=Add the fishing operation associated with this activity
|
| 366 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity=Choose activity
|
|
| 367 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.message=Choose an activity beyoung the universe of possible ones (time minus than %s (minutes) and distance minus than %s (km))\:
|
|
| 368 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.title=Choose the related observed activity
|
|
| 366 | 369 |
observe.common.ActivityLonglineLogbookDto.action.moves=Change trip
|
| 367 | 370 |
observe.common.ActivityLonglineLogbookDto.action.moves.tip=Change trip of activities
|
| 368 | 371 |
observe.common.ActivityLonglineLogbookDto.list.message.none=< No activity for current trip >
|
| ... | ... | @@ -363,6 +363,9 @@ observe.common.ActivityLogbookDto.action.goToOpen.short=Logbook - Open activity |
| 363 | 363 |
observe.common.ActivityLogbookDto.action.goToOpen.tip=Go to open activity (Logbook) \#TODO
|
| 364 | 364 |
observe.common.ActivityLonglineLogbookDto.action.addSet=Añadir la operación de pesca
|
| 365 | 365 |
observe.common.ActivityLonglineLogbookDto.action.addSet.tip=Añadir la operación de pesca asociada a esta actividad
|
| 366 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity=Choose activity \#TODO
|
|
| 367 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.message=Choose an activity beyoung the universe of possible ones (time minus than %s (minutes) and distance minus than %s (km))\: \#TODO
|
|
| 368 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.title=Choose the related observed activity \#TODO
|
|
| 366 | 369 |
observe.common.ActivityLonglineLogbookDto.action.moves=Cambiar de marea
|
| 367 | 370 |
observe.common.ActivityLonglineLogbookDto.action.moves.tip=Cambiar la marea de las actividades seleccionas
|
| 368 | 371 |
observe.common.ActivityLonglineLogbookDto.list.message.none=< Ninguna actividad por la marea actual >
|
| ... | ... | @@ -363,6 +363,9 @@ observe.common.ActivityLogbookDto.action.goToOpen.short=Livre de bord - Activit |
| 363 | 363 |
observe.common.ActivityLogbookDto.action.goToOpen.tip=Accéder à l'activité ouverte (Livre de bord)
|
| 364 | 364 |
observe.common.ActivityLonglineLogbookDto.action.addSet=Ajouter l'opération de pêche
|
| 365 | 365 |
observe.common.ActivityLonglineLogbookDto.action.addSet.tip=Ajouter l'opération de pêche associée à cette activité
|
| 366 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity=Choisir l'activité
|
|
| 367 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.message=Veuillez choisir une activité parmis celles possible (durée de moins de %s minutes et distance moins de %s kms) \:
|
|
| 368 |
+observe.common.ActivityLonglineLogbookDto.action.chooseRelatedObservedActivity.title=Choisir l'activité d'observation associée
|
|
| 366 | 369 |
observe.common.ActivityLonglineLogbookDto.action.moves=Changer de marée
|
| 367 | 370 |
observe.common.ActivityLonglineLogbookDto.action.moves.tip=Changer la marée des activités sélectionnées
|
| 368 | 371 |
observe.common.ActivityLonglineLogbookDto.list.message.none=< Aucune activité pour la marée courante >
|
| ... | ... | @@ -51,4 +51,6 @@ public interface ActivityLonglineAware extends ObserveDto { |
| 51 | 51 |
Float getLatitude();
|
| 52 | 52 |
|
| 53 | 53 |
Float getLongitude();
|
| 54 |
+ |
|
| 55 |
+ String getVesselActivityLonglineId();
|
|
| 54 | 56 |
}
|
| ... | ... | @@ -70,4 +70,8 @@ public class ActivityLonglineLogbookDto extends GeneratedActivityLonglineLogbook |
| 70 | 70 |
return ActivityLonglineAware.newGPSPoint(this);
|
| 71 | 71 |
}
|
| 72 | 72 |
|
| 73 |
+ @Override
|
|
| 74 |
+ public String getVesselActivityLonglineId() {
|
|
| 75 |
+ return vesselActivityLongline == null ? null : vesselActivityLongline.getId();
|
|
| 76 |
+ }
|
|
| 73 | 77 |
}
|
| ... | ... | @@ -69,4 +69,9 @@ public class ActivityLonglineObsDto extends GeneratedActivityLonglineObsDto impl |
| 69 | 69 |
public GPSPoint getGPSPoint() {
|
| 70 | 70 |
return ActivityLonglineAware.newGPSPoint(this);
|
| 71 | 71 |
}
|
| 72 |
+ |
|
| 73 |
+ @Override
|
|
| 74 |
+ public String getVesselActivityLonglineId() {
|
|
| 75 |
+ return vesselActivityLongline == null ? null : vesselActivityLongline.getId();
|
|
| 76 |
+ }
|
|
| 72 | 77 |
}
|
| ... | ... | @@ -83,7 +83,6 @@ import fr.ird.observe.dto.data.longline.TripLonglineActivityObsDto; |
| 83 | 83 |
import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
| 84 | 84 |
import fr.ird.observe.dto.data.longline.WeightMeasureObsDto;
|
| 85 | 85 |
import fr.ird.observe.dto.data.longline.WeightMeasureObsReference;
|
| 86 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResultItem;
|
|
| 87 | 86 |
import fr.ird.observe.dto.data.seine.ActivitySeineDto;
|
| 88 | 87 |
import fr.ird.observe.dto.data.seine.ActivitySeineReference;
|
| 89 | 88 |
import fr.ird.observe.dto.data.seine.ActivitySeineStubDto;
|
| ... | ... | @@ -306,8 +305,6 @@ public class DecoratorService extends DecoratorProvider { |
| 306 | 305 |
|
| 307 | 306 |
private String haulingIdentifier;
|
| 308 | 307 |
private String settingIdentifier;
|
| 309 |
- private String pairingTime;
|
|
| 310 |
- private String pairingDistance;
|
|
| 311 | 308 |
private String libelle;
|
| 312 | 309 |
private Locale locale;
|
| 313 | 310 |
|
| ... | ... | @@ -317,8 +314,6 @@ public class DecoratorService extends DecoratorProvider { |
| 317 | 314 |
libelle = referentialLocale.getLibelle();
|
| 318 | 315 |
settingIdentifier = l(locale, "observe.common.settingIdentifier");
|
| 319 | 316 |
haulingIdentifier = l(locale, "observe.common.haulingIdentifier");
|
| 320 |
- pairingTime = l(locale, "observe.common.pairingTime");
|
|
| 321 |
- pairingDistance = l(locale, "observe.common.pairingDistance");
|
|
| 322 | 317 |
}
|
| 323 | 318 |
|
| 324 | 319 |
@Override
|
| ... | ... | @@ -346,10 +341,6 @@ public class DecoratorService extends DecoratorProvider { |
| 346 | 341 |
registerObserveDecorator(ServerDataSourceConfiguration.class, "${name}$s", " ");
|
| 347 | 342 |
registerObserveDecorator(WITH_URL, ServerDataSourceConfiguration.class, "${name}$s##${url}$s");
|
| 348 | 343 |
registerObserveDecorator(FloatingObjectPreset.class, "${name}$s", " ");
|
| 349 |
- |
|
| 350 |
- registerObserveDecorator(ActivityLonglinePairingResultItem.class,
|
|
| 351 |
- "${observationActivity/timeStamp}$td/%1$tm/%1$tY %1$tH:%1$tM##${observationActivity/vesselActivityLonglineLabel}$s##" + pairingTime + " ${computedTime}$s##" + pairingDistance + " ${computedDistance}$s", " ");
|
|
| 352 |
- |
|
| 353 | 344 |
}
|
| 354 | 345 |
|
| 355 | 346 |
|
| ... | ... | @@ -298,8 +298,8 @@ observe.common.lengthWeightFormula=Length weight formula |
| 298 | 298 |
observe.common.no.unit=No unit
|
| 299 | 299 |
observe.common.nocode=Nocode
|
| 300 | 300 |
observe.common.none=None
|
| 301 |
-observe.common.pairingDistance=Distance (km)
|
|
| 302 |
-observe.common.pairingTime=Time (minutes)
|
|
| 301 |
+observe.common.pairingDistance=Distance (in kms)
|
|
| 302 |
+observe.common.pairingTime=Time (in minutes)
|
|
| 303 | 303 |
observe.common.program=Program
|
| 304 | 304 |
observe.common.scientificLabel=Scientific label
|
| 305 | 305 |
observe.common.settingIdentifier=Setting
|
| ... | ... | @@ -296,8 +296,8 @@ observe.common.lengthWeightFormula=Relación de peso |
| 296 | 296 |
observe.common.no.unit=No unit \#TODO
|
| 297 | 297 |
observe.common.nocode=codigo ausente
|
| 298 | 298 |
observe.common.none=Ninguno
|
| 299 |
-observe.common.pairingDistance=Distance (km) \#TODO
|
|
| 300 |
-observe.common.pairingTime=Time (minutes) \#TODO
|
|
| 299 |
+observe.common.pairingDistance=Distance (in kms) \#TODO
|
|
| 300 |
+observe.common.pairingTime=Time (in minutes) \#TODO
|
|
| 301 | 301 |
observe.common.program=Programa
|
| 302 | 302 |
observe.common.scientificLabel=Texto científico
|
| 303 | 303 |
observe.common.settingIdentifier=Calada
|
| ... | ... | @@ -298,8 +298,8 @@ observe.common.lengthWeightFormula=Relation Poids |
| 298 | 298 |
observe.common.no.unit=Pas d'unité
|
| 299 | 299 |
observe.common.nocode=code absent
|
| 300 | 300 |
observe.common.none=Aucun
|
| 301 |
-observe.common.pairingDistance=Distance (km)
|
|
| 302 |
-observe.common.pairingTime=Temps (mn)
|
|
| 301 |
+observe.common.pairingDistance=Distance (en kms)
|
|
| 302 |
+observe.common.pairingTime=Temps (en minutes)
|
|
| 303 | 303 |
observe.common.program=Programme
|
| 304 | 304 |
observe.common.scientificLabel=Libellé scientifique
|
| 305 | 305 |
observe.common.settingIdentifier=Filage
|
| ... | ... | @@ -118,6 +118,10 @@ |
| 118 | 118 |
<groupId>org.apache.commons</groupId>
|
| 119 | 119 |
<artifactId>commons-collections4</artifactId>
|
| 120 | 120 |
</dependency>
|
| 121 |
+ <dependency>
|
|
| 122 |
+ <groupId>commons-jxpath</groupId>
|
|
| 123 |
+ <artifactId>commons-jxpath</artifactId>
|
|
| 124 |
+ </dependency>
|
|
| 121 | 125 |
|
| 122 | 126 |
<dependency>
|
| 123 | 127 |
<groupId>com.google.guava</groupId>
|
| ... | ... | @@ -27,12 +27,13 @@ import com.google.common.collect.ImmutableMap; |
| 27 | 27 |
import fr.ird.observe.dto.data.longline.ActivityLonglineAware;
|
| 28 | 28 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookReference;
|
| 29 | 29 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 30 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResult;
|
|
| 31 |
-import fr.ird.observe.dto.data.pairing.ActivityLonglinePairingResultItem;
|
|
| 32 |
-import fr.ird.observe.dto.data.pairing.TripLonglinePairingResult;
|
|
| 30 |
+import fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResult;
|
|
| 31 |
+import fr.ird.observe.services.service.data.longline.pairing.ActivityLonglinePairingResultItem;
|
|
| 32 |
+import fr.ird.observe.services.service.data.longline.pairing.TripLonglinePairingResult;
|
|
| 33 | 33 |
import fr.ird.observe.services.ObserveServicesProvider;
|
| 34 | 34 |
|
| 35 | 35 |
import java.util.ArrayList;
|
| 36 |
+import java.util.Collection;
|
|
| 36 | 37 |
import java.util.Date;
|
| 37 | 38 |
import java.util.List;
|
| 38 | 39 |
import java.util.Set;
|
| ... | ... | @@ -53,11 +54,13 @@ public class ActivityLonglinePairingEngine { |
| 53 | 54 |
this.config = config;
|
| 54 | 55 |
}
|
| 55 | 56 |
|
| 56 |
- public TripLonglinePairingContext newTripContext(String tripLonglineId) {
|
|
| 57 |
- Set<ActivityLonglineObsReference> activityLonglineObsReferenceSet = servicesProvider.getActivityLonglineObsService().getActivityLonglineByTripLongline(tripLonglineId).toSet();
|
|
| 58 |
- return new TripLonglinePairingContext(config, tripLonglineId, ImmutableList.copyOf(activityLonglineObsReferenceSet));
|
|
| 57 |
+ public ActivityLonglinePairingConfig getConfig() {
|
|
| 58 |
+ return config;
|
|
| 59 | 59 |
}
|
| 60 | 60 |
|
| 61 |
+ public TripLonglinePairingContext newTripContext(String tripLonglineId, Collection<ActivityLonglineObsReference> allActivityLonglineObs) {
|
|
| 62 |
+ return new TripLonglinePairingContext(config, tripLonglineId, ImmutableList.copyOf(allActivityLonglineObs));
|
|
| 63 |
+ }
|
|
| 61 | 64 |
|
| 62 | 65 |
public TripLonglinePairingResult computeForTrip(TripLonglinePairingContext context) {
|
| 63 | 66 |
ImmutableMap.Builder<ActivityLonglineLogbookReference, ActivityLonglinePairingResult> resultBuilder = ImmutableMap.builder();
|
| ... | ... | @@ -70,7 +73,7 @@ public class ActivityLonglinePairingEngine { |
| 70 | 73 |
}
|
| 71 | 74 |
|
| 72 | 75 |
public ActivityLonglinePairingResult computeForActivityLogbook(TripLonglinePairingContext context, ActivityLonglineAware activityLonglineLogbook) {
|
| 73 |
- ImmutableList<ActivityLonglineObsReference> activityLonglineObsList = context.getActivityLonglineObsList();
|
|
| 76 |
+ ImmutableList<ActivityLonglineObsReference> activityLonglineObsList = context.getActivityLonglineObsList(activityLonglineLogbook.getVesselActivityLonglineId());
|
|
| 74 | 77 |
List<ActivityLonglinePairingResultItem> itemBuilder = new ArrayList<>(activityLonglineObsList.size());
|
| 75 | 78 |
long longlineActivityPairingMaxTime = context.getConfig().getLonglineActivityPairingMaxTime();
|
| 76 | 79 |
long longlineActivityPairingMaxDistance = context.getConfig().getLonglineActivityPairingMaxDistance();
|
| ... | ... | @@ -84,7 +87,7 @@ public class ActivityLonglinePairingEngine { |
| 84 | 87 |
private ActivityLonglinePairingResultItem toActivityResultItem(ActivityLonglineAware activityLonglineLogbook, ActivityLonglineObsReference activityLonglineObsReference, double maxTime, double maxDistance) {
|
| 85 | 88 |
Date logbookTimeStamp = activityLonglineLogbook.getTimeStamp();
|
| 86 | 89 |
Date obsTimeStamp = activityLonglineObsReference.getTimeStamp();
|
| 87 |
- double computedTime = Math.abs(TimeUnit.MINUTES.convert(logbookTimeStamp.getTime() - obsTimeStamp.getTime(), TimeUnit.MILLISECONDS));
|
|
| 90 |
+ long computedTime = Math.abs(TimeUnit.MINUTES.convert(logbookTimeStamp.getTime() - obsTimeStamp.getTime(), TimeUnit.MILLISECONDS));
|
|
| 88 | 91 |
double computedDistance = activityLonglineLogbook.getGPSPoint().getDistanceInKm(activityLonglineObsReference.getGPSPoint());
|
| 89 | 92 |
return new ActivityLonglinePairingResultItem(activityLonglineObsReference, computedTime, computedDistance, computedTime < maxTime, computedDistance < maxDistance);
|
| 90 | 93 |
}
|
| ... | ... | @@ -26,6 +26,8 @@ import com.google.common.collect.ImmutableList; |
| 26 | 26 |
import fr.ird.observe.dto.ObserveDto;
|
| 27 | 27 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 28 | 28 |
|
| 29 |
+import java.util.stream.Collectors;
|
|
| 30 |
+ |
|
| 29 | 31 |
/**
|
| 30 | 32 |
* Created by tchemit on 15/10/2018.
|
| 31 | 33 |
*
|
| ... | ... | @@ -35,28 +37,24 @@ public class TripLonglinePairingContext implements ObserveDto { |
| 35 | 37 |
|
| 36 | 38 |
private final ActivityLonglinePairingConfig config;
|
| 37 | 39 |
private final String tripLonglineId;
|
| 38 |
- private final ImmutableList<ActivityLonglineObsReference> activityLonglineObsList;
|
|
| 40 |
+ private final ImmutableList<ActivityLonglineObsReference> allActivityLonglineObs;
|
|
| 39 | 41 |
|
| 40 |
- public TripLonglinePairingContext(ActivityLonglinePairingConfig config, String tripLonglineId, ImmutableList<ActivityLonglineObsReference> activityLonglineObsList) {
|
|
| 42 |
+ public TripLonglinePairingContext(ActivityLonglinePairingConfig config, String tripLonglineId, ImmutableList<ActivityLonglineObsReference> allActivityLonglineObs) {
|
|
| 41 | 43 |
this.config = config;
|
| 42 | 44 |
this.tripLonglineId = tripLonglineId;
|
| 43 |
- this.activityLonglineObsList = activityLonglineObsList;
|
|
| 45 |
+ this.allActivityLonglineObs = allActivityLonglineObs;
|
|
| 44 | 46 |
}
|
| 45 | 47 |
|
| 46 | 48 |
public ActivityLonglinePairingConfig getConfig() {
|
| 47 | 49 |
return config;
|
| 48 | 50 |
}
|
| 49 | 51 |
|
| 50 |
- |
|
| 51 |
- public ImmutableList<ActivityLonglineObsReference> getActivityLonglineObsList() {
|
|
| 52 |
- return activityLonglineObsList;
|
|
| 52 |
+ public ImmutableList<ActivityLonglineObsReference> getActivityLonglineObsList(String vesselActivityLonglineId) {
|
|
| 53 |
+ return ImmutableList.copyOf(allActivityLonglineObs.stream().filter(e -> vesselActivityLonglineId.equals(e.getVesselActivityLonglineId())).collect(Collectors.toList()));
|
|
| 53 | 54 |
}
|
| 54 | 55 |
|
| 55 | 56 |
public String getTripLonglineId() {
|
| 56 | 57 |
return tripLonglineId;
|
| 57 | 58 |
}
|
| 58 | 59 |
|
| 59 |
- public boolean isEnabled() {
|
|
| 60 |
- return !activityLonglineObsList.isEmpty();
|
|
| 61 |
- }
|
|
| 62 | 60 |
}
|
| 1 |
-package fr.ird.observe.dto.data.pairing;
|
|
| 1 |
+package fr.ird.observe.services.service.data.longline.pairing;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe :: Dto
|
|
| 5 |
+ * ObServe :: Services API
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -10,19 +10,18 @@ package fr.ird.observe.dto.data.pairing; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
- |
|
| 26 | 25 |
import com.google.common.collect.ImmutableList;
|
| 27 | 26 |
import fr.ird.observe.dto.ObserveDto;
|
| 28 | 27 |
|
| 1 |
-package fr.ird.observe.dto.data.pairing;
|
|
| 1 |
+package fr.ird.observe.services.service.data.longline.pairing;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe :: Dto
|
|
| 5 |
+ * ObServe :: Services API
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -10,21 +10,21 @@ package fr.ird.observe.dto.data.pairing; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
- |
|
| 26 | 25 |
import fr.ird.observe.dto.ObserveDto;
|
| 27 | 26 |
import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
| 27 |
+import io.ultreia.java4all.lang.Numbers;
|
|
| 28 | 28 |
|
| 29 | 29 |
import java.util.Objects;
|
| 30 | 30 |
|
| ... | ... | @@ -36,15 +36,15 @@ import java.util.Objects; |
| 36 | 36 |
public class ActivityLonglinePairingResultItem implements ObserveDto {
|
| 37 | 37 |
|
| 38 | 38 |
private final ActivityLonglineObsReference observationActivity;
|
| 39 |
- private final double computedTime;
|
|
| 39 |
+ private final long computedTime;
|
|
| 40 | 40 |
private final double computedDistance;
|
| 41 | 41 |
private final boolean timeValid;
|
| 42 | 42 |
private final boolean distanceValid;
|
| 43 | 43 |
|
| 44 |
- public ActivityLonglinePairingResultItem(ActivityLonglineObsReference observationActivity, double computedTime, double computedDistance, boolean timeValid, boolean distanceValid) {
|
|
| 44 |
+ public ActivityLonglinePairingResultItem(ActivityLonglineObsReference observationActivity, long computedTime, double computedDistance, boolean timeValid, boolean distanceValid) {
|
|
| 45 | 45 |
this.observationActivity = observationActivity;
|
| 46 | 46 |
this.computedTime = computedTime;
|
| 47 |
- this.computedDistance = computedDistance;
|
|
| 47 |
+ this.computedDistance = Numbers.roundOneDigit((float) computedDistance);
|
|
| 48 | 48 |
this.timeValid = timeValid;
|
| 49 | 49 |
this.distanceValid = distanceValid;
|
| 50 | 50 |
}
|
| ... | ... | @@ -53,7 +53,7 @@ public class ActivityLonglinePairingResultItem implements ObserveDto { |
| 53 | 53 |
return observationActivity;
|
| 54 | 54 |
}
|
| 55 | 55 |
|
| 56 |
- public double getComputedTime() {
|
|
| 56 |
+ public long getComputedTime() {
|
|
| 57 | 57 |
return computedTime;
|
| 58 | 58 |
}
|
| 59 | 59 |
|
| 1 |
+package fr.ird.observe.services.service.data.longline.pairing;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Services API
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import fr.ird.observe.dto.data.longline.ActivityLonglineObsReference;
|
|
| 26 |
+import fr.ird.observe.dto.decoration.DecoratorService;
|
|
| 27 |
+import fr.ird.observe.dto.decoration.decorators.DataReferenceDecorator;
|
|
| 28 |
+import fr.ird.observe.dto.decoration.decorators.ObserveDecorator;
|
|
| 29 |
+import org.apache.commons.jxpath.JXPathContext;
|
|
| 30 |
+ |
|
| 31 |
+import java.util.Locale;
|
|
| 32 |
+ |
|
| 33 |
+import static org.nuiton.i18n.I18n.l;
|
|
| 34 |
+ |
|
| 35 |
+/**
|
|
| 36 |
+ * Created by tchemit on 16/10/2018.
|
|
| 37 |
+ *
|
|
| 38 |
+ * @author Tony Chemit - dev@tchemit.fr
|
|
| 39 |
+ */
|
|
| 40 |
+public class ActivityLonglinePairingResultItemDecorator extends ObserveDecorator<ActivityLonglinePairingResultItem> {
|
|
| 41 |
+ |
|
| 42 |
+ private final Locale locale;
|
|
| 43 |
+ private final DataReferenceDecorator<ActivityLonglineObsReference> activityDecorator;
|
|
| 44 |
+ |
|
| 45 |
+ public ActivityLonglinePairingResultItemDecorator(DecoratorService decoratorService, Locale locale) {
|
|
| 46 |
+ super(ActivityLonglinePairingResultItem.class, "${observationActivity}$s##${computedTime}$s##${computedDistance}$s");
|
|
| 47 |
+ this.locale = locale;
|
|
| 48 |
+ activityDecorator = decoratorService.getDataReferenceDecorator(ActivityLonglineObsReference.class);
|
|
| 49 |
+ }
|
|
| 50 |
+ |
|
| 51 |
+ @SuppressWarnings("unchecked")
|
|
| 52 |
+ @Override
|
|
| 53 |
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
|
|
| 54 |
+ Object value0 = jxcontext.getValue(token);
|
|
| 55 |
+ switch (token) {
|
|
| 56 |
+ case "computedTime":
|
|
| 57 |
+ return (Comparable) l(locale, "observe.common.pairingTime", value0);
|
|
| 58 |
+ case "computedDistance":
|
|
| 59 |
+ return (Comparable) l(locale, "observe.common.pairingDistance", value0);
|
|
| 60 |
+ case "observationActivity":
|
|
| 61 |
+ return (Comparable) activityDecorator.toString(value0);
|
|
| 62 |
+ }
|
|
| 63 |
+ return super.getTokenValue(jxcontext, token);
|
|
| 64 |
+ }
|
|
| 65 |
+}
|
| 1 |
-package fr.ird.observe.dto.data.pairing;
|
|
| 1 |
+package fr.ird.observe.services.service.data.longline.pairing;
|
|
| 2 | 2 |
|
| 3 | 3 |
/*-
|
| 4 | 4 |
* #%L
|
| 5 |
- * ObServe :: Dto
|
|
| 5 |
+ * ObServe :: Services API
|
|
| 6 | 6 |
* %%
|
| 7 | 7 |
* Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io
|
| 8 | 8 |
* %%
|
| ... | ... | @@ -10,19 +10,18 @@ package fr.ird.observe.dto.data.pairing; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
- |
|
| 26 | 25 |
import com.google.common.collect.ImmutableMap;
|
| 27 | 26 |
import fr.ird.observe.dto.ObserveDto;
|
| 28 | 27 |
import fr.ird.observe.dto.data.longline.ActivityLonglineLogbookReference;
|