Observe-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- 7338 discussions
02 Sep '24
Tony CHEMIT deleted branch feature/issue-2734 at ultreiaio / ird-observe
--
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][feature/issue-2734] 9 commits: Fix WithIndex generation - See #1203
by Tony CHEMIT (@tchemit) 02 Sep '24
by Tony CHEMIT (@tchemit) 02 Sep '24
02 Sep '24
Tony CHEMIT pushed to branch feature/issue-2734 at ultreiaio / ird-observe
Commits:
d7d59ba3 by Tony Chemit at 2024-09-02T09:57:04+02:00
Fix WithIndex generation - See #1203
- - - - -
fb92220f by Tony Chemit at 2024-09-02T11:14:27+02:00
Fix onRemoveRow method (we already are using the modelRow) - See #1203
- - - - -
92243249 by Tony Chemit at 2024-09-02T11:14:36+02:00
Add new queries in TripDao
- - - - -
8b5e5e8d by Tony Chemit at 2024-09-02T11:14:36+02:00
Add new methods in TripService
- - - - -
090661ff by Tony Chemit at 2024-09-02T11:14:36+02:00
Add new labels (will be used for ui for new actions)
- - - - -
1c2c4ae4 by Tony Chemit at 2024-09-02T11:14:36+02:00
Open API (to hack to order of configuration actions)
- - - - -
29a53618 by Tony Chemit at 2024-09-02T11:14:36+02:00
Add ContentTableUITableModel.addNewEntry(bean) method to be able to create a new row from a given bean
- - - - -
76e86dd5 by Tony Chemit at 2024-09-02T11:14:36+02:00
Implements action AddActivitiesFromSample on Well form
- - - - -
cebcab9b by Tony Chemit at 2024-09-02T11:14:36+02:00
Implements action AddActivitiesFromSample on Sample form
- - - - -
28 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
- client/datasource/editor/ps/src/main/i18n/getters/java.getter
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleActivityTableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIHandler.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIModelStates.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellActivityUITableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUIHandler.java
- + client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromSample.java
- + client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromWell.java
- core/api/dto-decoration/src/main/i18n/getters/labels.getter
- core/api/services/src/main/java/fr/ird/observe/services/service/data/ps/common/TripService.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java
- core/persistence/java/src/main/resources/fr/ird/observe/entities/data/ps/common/TripImpl.hbm.xml
- core/persistence/test/src/test/java/fr/ird/observe/entities/data/ps/common/TripTopiaDaoTest.java
- core/services/i18n/src/main/i18n/translations/services_en_GB.properties
- core/services/i18n/src/main/i18n/translations/services_es_ES.properties
- core/services/i18n/src/main/i18n/translations/services_fr_FR.properties
- core/services/local/src/main/java/fr/ird/observe/services/local/service/data/ps/common/TripServiceLocalSupport.java
- core/services/test/src/main/java/fr/ird/observe/services/service/data/ps/common/TripServiceFixtures.java
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/data/ps/common/TripService.properties
- model/src/main/models/Observe/dto/class/i18nLabels.properties
- model/src/main/resources/META-INF/persistence/fr/ird/observe/entities/data/ps/common/Trip-sql-queries.properties
- server/core/src/main/filtered-resources/META-INF/mapping-api-client.wm
- toolkit/templates/src/main/java/fr/ird/observe/toolkit/templates/dto/DtoTransformer.java
Changes:
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
=====================================
@@ -484,6 +484,10 @@ public class ContentOpen<U extends ContentUI> {
}
}
+ public ArrayListMultimap<ContentUI, JComponent> getConfigureActions() {
+ return configureActions;
+ }
+
public final <D extends DataDto, C extends ContainerChildDto, SubUi extends ContentTableUI<D, C, SubUi>> void initTabUI(SubUi subUi, JPanel subUiPane, int tabIndex, Consumer<D> dataConsumer) {
subUiMap.put(subUi, subUiPane);
subUiPane.remove(subUi);
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
=====================================
@@ -226,8 +226,7 @@ public abstract class ContentTableUITableModel<D extends DataDto, C extends Cont
// do nothing by default
}
- protected void onRemovedRow(int row) {
- int modelRow = getModelRow(row);
+ protected void onRemovedRow(int modelRow) {
inlineModels.keySet().forEach(inlineModel -> inlineModel.removeRow(modelRow));
}
@@ -377,6 +376,48 @@ public abstract class ContentTableUITableModel<D extends DataDto, C extends Cont
changeSelectedRow(viewRow);
}
+ public final void addNewEntry(C bean) {
+ ensureEditable();
+
+ int selectedRow = getSelectedRow();
+ if (selectedRow > -1) {
+ // il y avait une ligne précédemment sélectionnée,
+ // on doit verifier que l'on peut changer d'entrée
+ if (!isCanQuitEditingRow()) {
+ // on ne peut pas quitter la ligne en cours d'édition
+ // on annule donc l'opération
+ return;
+ }
+ }
+ // on est autorise a ajouter une nouvelle entrée
+ // hook before changing row
+ // FIXME I am not quite sure of this flow, should not it be managed another way, somewhere else?
+ onBeforeAddNewEntry(selectedRow);
+
+ int row = getRowCount();
+
+ data.add(bean);
+ if (getModel().getStates().isWithIndex()) {
+ ((WithIndex) bean).setIndex(getRowCount());
+ }
+
+ updateBeanList(false);
+
+ this.create = true;
+ fireTableRowsInserted(row, row);
+ this.create = false;
+
+ int viewRow = getContext().getTable().convertRowIndexToView(row);
+
+ updateEmpty();
+
+ // on est en mode creation
+ setCreate(true);
+
+ // la nouvelle ligne est celle en cours d'édition
+ changeSelectedRow(viewRow);
+ }
+
protected String getDeleteExtraMessage(C bean) {
return null;
}
=====================================
client/datasource/editor/ps/src/main/i18n/getters/java.getter
=====================================
@@ -21,10 +21,14 @@ observe.data.ps.dcp.FloatingObjectPreset.reloadDefaultConfiguration.title
observe.data.ps.localmarket.Batch.weight.computed.tip
observe.data.ps.localmarket.Batch.weight.observed.tip
observe.data.ps.logbook.Activity.create.title
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip
observe.data.ps.logbook.Sample.notSuperSample.with.moreThanOne.sampleSpecies.message
observe.data.ps.logbook.Sample.notSuperSample.with.moreThanOne.sampleSpecies.title
observe.data.ps.logbook.SampleActivity.weightedWeightComputed.computed.tip
observe.data.ps.logbook.SampleActivity.weightedWeightComputed.observed.tip
+observe.data.ps.logbook.Well.action.addActivitiesFromSample
+observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip
observe.data.ps.logbook.WellPlan.create.activity.tip
observe.data.ps.observation.Catch.catchWeightComputed.computed.tip
observe.data.ps.observation.Catch.catchWeightComputed.observed.tip
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleActivityTableModel.java
=====================================
@@ -189,7 +189,7 @@ public class SampleActivityTableModel extends EditableTableModel<SampleActivityD
}
@Override
- protected SampleActivityDto createNewRow() {
+ public SampleActivityDto createNewRow() {
return SampleActivityDto.newDto(new Date());
}
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUI.jaxx
=====================================
@@ -167,4 +167,5 @@
</JTabbedPane>
</JPanel>
<JMenuItem id='addSampleSpecies'/>
+ <JMenuItem id='fillActivitiesFromWell'/>
</fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI>
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIHandler.java
=====================================
@@ -23,8 +23,10 @@ package fr.ird.observe.client.datasource.editor.ps.data.logbook;
*/
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.actions.AddActivitiesFromWell;
import fr.ird.observe.client.util.UIHelper;
import fr.ird.observe.dto.data.ps.logbook.SampleDto;
+import fr.ird.observe.dto.form.Form;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
@@ -59,6 +61,13 @@ public class SampleUIHandler extends GeneratedSampleUIHandler {
super.startEditUI();
}
+ @Override
+ protected void installMoveAction() {
+ super.installMoveAction();
+ // We install the action here to be at proper order in configure menu
+ AddActivitiesFromWell.installAction(ui);
+ }
+
private void onSuperSampleChanged(PropertyChangeEvent event) throws PropertyVetoException {
boolean oldValue = (boolean) event.getOldValue();
boolean newValue = (boolean) event.getNewValue();
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleUIModelStates.java
=====================================
@@ -36,21 +36,29 @@ import io.ultreia.java4all.bean.spi.GenerateJavaBeanDefinition;
import java.beans.PropertyVetoException;
import java.util.List;
+import java.util.Set;
@GenerateJavaBeanDefinition
public class SampleUIModelStates extends GeneratedSampleUIModelStates {
private final SampleActivityTableModel sampleActivityTableModel;
+ private final Set<String> availableWellInTrip;
public SampleUIModelStates(GeneratedSampleUIModel model) {
super(model);
this.sampleActivityTableModel = new SampleActivityTableModel(this);
+ String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
+ this.availableWellInTrip = getReferenceCache().getDataSource().getPsCommonTripService().getLogbookWellIdsFromWellPlan(tripId);
}
public SampleActivityTableModel getSampleActivityTableModel() {
return sampleActivityTableModel;
}
+ public boolean isWellInTrip(String well) {
+ return availableWellInTrip.contains(well);
+ }
+
public boolean isSuperSample() {
return getBean().isSuperSample();
}
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellActivityUITableModel.java
=====================================
@@ -103,4 +103,5 @@ public class WellActivityUITableModel extends GeneratedWellActivityUITableModel
values.removeAll(columnValues);
editor.setData(values);
}
+
}
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUI.jaxx
=====================================
@@ -115,4 +115,5 @@
<Object id="delegateContentUI" initializer="mainTabbedPane"/>
<WellActivityUIModelStates id='wellActivityStates' initializer="wellActivityUI.getModel().getStates()"/>
<JButton id='save'/>
+ <JMenuItem id='fillActivitiesFromSample'/>
</fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUI>
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/WellUIHandler.java
=====================================
@@ -33,6 +33,7 @@ import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.Sav
import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTree;
import fr.ird.observe.client.datasource.editor.ps.data.common.TripLogbookUINavigationNode;
import fr.ird.observe.client.datasource.editor.ps.data.common.TripUINavigationNode;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.actions.AddActivitiesFromSample;
import fr.ird.observe.client.datasource.validation.ClientValidationContext;
import fr.ird.observe.client.util.init.DefaultUIInitializerResult;
import fr.ird.observe.datasource.security.ConcurrentModificationException;
@@ -80,14 +81,21 @@ public class WellUIHandler extends GeneratedWellUIHandler {
InputMap inputMap = ui.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = ui.getActionMap();
+ AddActivitiesFromSample.installAction(ui);
prefixAction(ui.getWellActivityUI().getDeleteEntry(), type);
prefixAction(ui.getWellActivityUI().getShowTechnicalInformations(), type);
+ prefixAction(ui.getFillActivitiesFromSample(), type);
registerInnerAction(ui.getWellActivityUI().getResetEntry(), inputMap, actionMap);
registerInnerAction(ui.getWellActivityUI().getSaveEntry(), inputMap, actionMap);
registerInnerAction(ui.getWellActivityUI().getSaveAndNewEntry(), inputMap, actionMap);
addConfigureActions(ui, false);
initTabUI(ui.getWellActivityUI(), ui.getWellActivityPanel(), 1, d -> ui.getModel().getStates().getBean().setWellActivity(d.getWellActivity()));
+ getConfigureActions().remove(ui, ui.getFillActivitiesFromSample());
+ // Big hack to put at the good place the ui.getFillActivitiesFromSample() action in the menu
+ getConfigureActions().get(ui.getWellActivityUI()).remove(ui.getWellActivityUI().getShowTechnicalInformations());
+ getConfigureActions().put(ui.getWellActivityUI(), ui.getFillActivitiesFromSample());
+ getConfigureActions().put(ui.getWellActivityUI(), ui.getWellActivityUI().getShowTechnicalInformations());
return result;
}
};
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromSample.java
=====================================
@@ -0,0 +1,106 @@
+package fr.ird.observe.client.datasource.editor.ps.data.logbook.actions;
+
+/*-
+ * #%L
+ * ObServe Client :: DataSource :: Editor :: PS
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Maps;
+import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
+import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
+import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIModelStates;
+import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.ContentOpenableUIActionSupport;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUI;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUIModel;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellActivityUITableModel;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellUI;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.WellUIModelStates;
+import fr.ird.observe.dto.data.ps.logbook.ActivityStubDto;
+import fr.ird.observe.dto.data.ps.logbook.WellActivityDto;
+import fr.ird.observe.dto.data.ps.logbook.WellDto;
+import io.ultreia.java4all.i18n.I18n;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Created at 01/09/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ */
+public class AddActivitiesFromSample extends ContentOpenableUIActionSupport<WellDto, WellUI> implements ConfigureMenuAction<WellUI> {
+
+ private static final Logger log = LogManager.getLogger(AddActivitiesFromSample.class);
+
+ public AddActivitiesFromSample() {
+ super(WellDto.class, I18n.n("observe.data.ps.logbook.Well.action.addActivitiesFromSample"), I18n.n("observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip"), "generate", ObserveKeyStrokesEditorApi.KEY_STROKE_GENERATE);
+ }
+
+ public static void installAction(WellUI ui) {
+ AddActivitiesFromSample action = new AddActivitiesFromSample();
+ ui.getModel().getStates().addPropertyChangeListener(ContentOpenableUIModelStates.PROPERTY_MODE, action::updateEnableState);
+ ui.getModel().getStates().getBean().addPropertyChangeListener(WellDto.PROPERTY_WELL, action::updateEnableState);
+ ui.getModel().getStates().getBean().addPropertyChangeListener(WellDto.PROPERTY_WELL_ACTIVITY, action::updateEnableState);
+ AddActivitiesFromSample.init(ui, ui.getFillActivitiesFromSample(), action);
+ }
+
+ @Override
+ protected void doActionPerformed(ActionEvent e, WellUI ui) {
+ WellUIModelStates states = ui.getModel().getStates();
+ WellDto bean = states.getBean();
+ String well = bean.getWell();
+ log.info("Will seek from activities for sample: {}", well);
+ WellActivityUI wellActivityUI = ui.getWellActivityUI();
+ WellActivityUITableModel tableModel = wellActivityUI.getTableModel();
+ WellActivityUIModel model = wellActivityUI.getModel();
+ List<ActivityStubDto> availableActivities = wellActivityUI.getModel().getStates().getActivity();
+ Map<String, ActivityStubDto> activitiesCache = new TreeMap<>(Maps.uniqueIndex(availableActivities, ActivityStubDto::getTopiaId));
+ String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
+ Set<String> logbookWellActivityFromSample = getServicesProvider().getPsCommonTripService().createLogbookWellActivityFromSample(tripId, well);
+ for (String activityId : logbookWellActivityFromSample) {
+ log.info("Create Well activity for activity: {}", activityId);
+ ActivityStubDto activity = activitiesCache.get(activityId);
+ WellActivityDto wellActivityDto = model.newTableEditBean();
+ wellActivityDto.setActivity(activity);
+ tableModel.addNewEntry(wellActivityDto);
+ wellActivityUI.getSaveEntry().setEnabled(true);
+ try {
+ wellActivityUI.getSaveEntry().doClick();
+ } finally {
+ wellActivityUI.getSaveEntry().setEnabled(false);
+ }
+ }
+ }
+
+ private void updateEnableState(PropertyChangeEvent evt) {
+ WellUIModelStates states = ui.getModel().getStates();
+ boolean readingMode = states.isReadingMode();
+ String well = states.getBean().getWell();
+ List<WellActivityDto> wellActivity = states.getBean().getWellActivity();
+ setEnabled(!readingMode && well != null && !well.isEmpty() && wellActivity.isEmpty());
+ }
+}
=====================================
client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/actions/AddActivitiesFromWell.java
=====================================
@@ -0,0 +1,102 @@
+package fr.ird.observe.client.datasource.editor.ps.data.logbook.actions;
+
+/*-
+ * #%L
+ * ObServe Client :: DataSource :: Editor :: PS
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Maps;
+import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
+import fr.ird.observe.client.datasource.editor.api.content.actions.ConfigureMenuAction;
+import fr.ird.observe.client.datasource.editor.api.content.data.open.ContentOpenableUIModelStates;
+import fr.ird.observe.client.datasource.editor.api.content.data.open.actions.ContentOpenableUIActionSupport;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleActivityTableModel;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleUI;
+import fr.ird.observe.client.datasource.editor.ps.data.logbook.SampleUIModelStates;
+import fr.ird.observe.dto.data.ps.logbook.ActivityStubDto;
+import fr.ird.observe.dto.data.ps.logbook.SampleActivityDto;
+import fr.ird.observe.dto.data.ps.logbook.SampleDto;
+import io.ultreia.java4all.i18n.I18n;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Created at 01/09/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ */
+public class AddActivitiesFromWell extends ContentOpenableUIActionSupport<SampleDto, SampleUI> implements ConfigureMenuAction<SampleUI> {
+
+ private static final Logger log = LogManager.getLogger(AddActivitiesFromWell.class);
+
+ public AddActivitiesFromWell() {
+ super(SampleDto.class, I18n.n("observe.data.ps.logbook.Sample.action.addActivitiesFromWell"), I18n.n("observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip"), "generate", ObserveKeyStrokesEditorApi.KEY_STROKE_GENERATE);
+ }
+
+ public static void installAction(SampleUI ui) {
+ AddActivitiesFromWell action = new AddActivitiesFromWell();
+ ui.getModel().getStates().addPropertyChangeListener(ContentOpenableUIModelStates.PROPERTY_MODE, action::updateEnableState);
+ ui.getModel().getStates().getBean().addPropertyChangeListener(SampleDto.PROPERTY_WELL, action::updateEnableState);
+ ui.getModel().getStates().getBean().addPropertyChangeListener(SampleDto.PROPERTY_SAMPLE_ACTIVITY, action::updateEnableState);
+ AddActivitiesFromWell.init(ui, ui.getFillActivitiesFromWell(), action);
+ }
+
+ @Override
+ protected void doActionPerformed(ActionEvent e, SampleUI ui) {
+ SampleUIModelStates states = ui.getModel().getStates();
+ SampleDto bean = states.getBean();
+ String well = bean.getWell();
+ log.info("Will seek from activities from well: {}", well);
+ SampleActivityTableModel tableModel = states.getSampleActivityTableModel();
+ List<ActivityStubDto> availableActivities = tableModel.getActivities();
+ Map<String, ActivityStubDto> activitiesCache = new TreeMap<>(Maps.uniqueIndex(availableActivities, ActivityStubDto::getTopiaId));
+ String tripId = getClientValidationContext().getSelectModel().getPs().getCommonTrip().getId();
+ Set<String> logbookSampleActivityFromWellPlan = getServicesProvider().getPsCommonTripService().createLogbookSampleActivityFromWellPlan(tripId, well);
+ List<SampleActivityDto> sampleActivities = new LinkedList<>();
+ for (String activityId : logbookSampleActivityFromWellPlan) {
+ log.info("Create Sample activity for activity: {}", activityId);
+ ActivityStubDto activity = activitiesCache.get(activityId);
+ SampleActivityDto sampleActivityDto = tableModel.createNewRow();
+ sampleActivityDto.setActivity(activity);
+ sampleActivityDto.setWeightedWeight(null);
+ sampleActivityDto.setWeightedWeightComputed(false);
+ sampleActivities.add(sampleActivityDto);
+ }
+ bean.setSampleActivity(sampleActivities);
+ tableModel.setData(sampleActivities);
+ }
+
+ private void updateEnableState(PropertyChangeEvent evt) {
+ SampleUIModelStates states = ui.getModel().getStates();
+ boolean readingMode = states.isReadingMode();
+ String well = states.getBean().getWell();
+ List<SampleActivityDto> sampleActivity = states.getBean().getSampleActivity();
+ setEnabled(!readingMode && well != null && !well.isEmpty() && states.isWellInTrip(well.trim()) && sampleActivity.isEmpty());
+ }
+}
=====================================
core/api/dto-decoration/src/main/i18n/getters/labels.getter
=====================================
@@ -977,6 +977,8 @@ observe.data.ps.logbook.Route.navigation.unsaved
observe.data.ps.logbook.Route.timeAtSea
observe.data.ps.logbook.Route.title
observe.data.ps.logbook.Route.type
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip
observe.data.ps.logbook.Sample.action.create
observe.data.ps.logbook.Sample.action.move
observe.data.ps.logbook.Sample.action.move.choose.parent.message
@@ -1026,6 +1028,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type
observe.data.ps.logbook.TransmittingBuoy.code
observe.data.ps.logbook.TransmittingBuoy.country
observe.data.ps.logbook.TransmittingBuoy.type
+observe.data.ps.logbook.Well.action.addActivitiesFromSample
+observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip
observe.data.ps.logbook.Well.action.create
observe.data.ps.logbook.Well.action.move
observe.data.ps.logbook.Well.action.move.choose.parent.message
=====================================
core/api/services/src/main/java/fr/ird/observe/services/service/data/ps/common/TripService.java
=====================================
@@ -32,9 +32,11 @@ import fr.ird.observe.services.service.MethodCredential;
import fr.ird.observe.services.service.data.TripAwareService;
import io.ultreia.java4all.http.spi.Get;
import io.ultreia.java4all.http.spi.Nullable;
+import io.ultreia.java4all.http.spi.Post;
import io.ultreia.java4all.http.spi.Service;
import java.util.List;
+import java.util.Set;
/**
* Created on 26/07/2021.
@@ -57,6 +59,40 @@ public interface TripService extends TripAwareService {
@MethodCredential(Permission.READ_DATA)
List<ActivityStubDto> getLogbookWellPlanActivities(String tripId);
+ /**
+ * @param tripId selected trip id
+ * @return the set of {@code Well#well} used in the well plan of selected trip
+ */
+ @Get
+ @MethodCredential(Permission.READ_DATA)
+ Set<String> getLogbookWellIdsFromWellPlan(String tripId);
+
+ /**
+ * @param tripId selected trip id
+ * @param wellId selected well id
+ * @return the set of activity ids found in well plan for selected trip and well
+ */
+ @Post
+ @MethodCredential(Permission.READ_DATA)
+ Set<String> createLogbookSampleActivityFromWellPlan(String tripId, String wellId);
+
+ /**
+ * @param tripId selected trip id
+ * @return the set of {@code Well#well} used in the sample of the selected trip
+ */
+ @Get
+ @MethodCredential(Permission.READ_DATA)
+ Set<String> getLogbookWellIdsFromSample(String tripId);
+
+ /**
+ * @param tripId selected trip id
+ * @param wellId selected well id
+ * @return the set of activity ids found in sample for selected trip and well
+ */
+ @Post
+ @MethodCredential(Permission.READ_DATA)
+ Set<String> createLogbookWellActivityFromSample(String tripId, String wellId);
+
@Get
@MethodCredential(Permission.READ_DATA)
boolean isActivityEndOfSearchFound(String routeId);
=====================================
core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripSpi.java
=====================================
@@ -42,6 +42,10 @@ import fr.ird.observe.entities.data.DataEntity;
import fr.ird.observe.entities.data.ps.landing.Landing;
import fr.ird.observe.entities.data.ps.logbook.Activity;
import fr.ird.observe.entities.data.ps.logbook.Route;
+import fr.ird.observe.entities.data.ps.logbook.Sample;
+import fr.ird.observe.entities.data.ps.logbook.SampleActivity;
+import fr.ird.observe.entities.data.ps.logbook.Well;
+import fr.ird.observe.entities.data.ps.logbook.WellActivity;
import fr.ird.observe.entities.referential.common.DataQuality;
import fr.ird.observe.entities.referential.common.Ocean;
import fr.ird.observe.entities.referential.common.Species;
@@ -62,6 +66,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;
@@ -380,4 +385,41 @@ public class TripSpi extends GeneratedTripSpi {
lastUpdateDates.add(fr.ird.observe.entities.data.ps.localmarket.SurveyPart.class);
}
+ public Set<String> getLogbookWellIdsFromWellPlan(ServiceContext context, String tripId) {
+ return Trip.getDao(context).getLogbookWellIdsFromWellPlan(tripId);
+ }
+
+ public Set<String> getLogbookWellIdsFromSample(ServiceContext context, String tripId) {
+ return Trip.getDao(context).getLogbookWellIdsFromSample(tripId);
+ }
+
+ public Set<String> createLogbookSampleActivityFromWellPlan(ServiceContext context, String tripId, String wellId) {
+ Trip trip = loadEntity(context, tripId);
+ Set<String> result = new LinkedHashSet<>();
+ for (Well well : trip.getWell()) {
+ if (!well.getWell().equals(wellId)) {
+ continue;
+ }
+ for (WellActivity wellActivity : well.getWellActivity()) {
+ Activity activity = wellActivity.getActivity();
+ result.add(activity.getId());
+ }
+ }
+ return result;
+ }
+
+ public Set<String> createLogbookWellActivityFromSample(ServiceContext context, String tripId, String wellId) {
+ Set<String> result = new LinkedHashSet<>();
+ Trip trip = loadEntity(context, tripId);
+ for (Sample sample : trip.getSample()) {
+ if (!sample.getWell().equals(wellId)) {
+ continue;
+ }
+ for (SampleActivity sampleActivity : sample.getSampleActivity()) {
+ result.add(sampleActivity.getActivity().getId());
+ }
+ }
+
+ return result;
+ }
}
=====================================
core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripTopiaDao.java
=====================================
@@ -44,6 +44,7 @@ import java.sql.Timestamp;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -68,6 +69,22 @@ public class TripTopiaDao extends AbstractTripTopiaDao<Trip> {
return findMultipleResultBySqlQuery(queryLogbookWellPlanActivities(tripId), s -> toActivityStubDto(s, vesselActivities));
}
+ public Set<String> getLogbookWellIdsFromWellPlan(String tripId) {
+ return Set.copyOf(findMultipleResultBySqlQuery(queryLogbookWellIdsFromWellPlan(tripId)));
+ }
+
+ public Set<String> getLogbookActivityIdsFromWellPlan(String tripId, String wellId) {
+ return new LinkedHashSet<>(findMultipleResultBySqlQuery(queryLogbookActivityIdsFromWellPlan(tripId, wellId)));
+ }
+
+ public Set<String> getLogbookWellIdsFromSample(String tripId) {
+ return Set.copyOf(findMultipleResultBySqlQuery(queryLogbookWellIdsFromSample(tripId)));
+ }
+
+ public Set<String> getLogbookActivityIdsFromSample(String tripId, String wellId) {
+ return new LinkedHashSet<>(findMultipleResultBySqlQuery(queryLogbookActivityIdsFromSample(tripId, wellId)));
+ }
+
public boolean isActivitiesAcquisitionModeByTimeEnabled(String tripId) {
return this.<Number>findSingleResultBySqlQuery(queryIsActivitiesAcquisitionModeByTimeEnabled(tripId)).intValue() == 0;
}
=====================================
core/persistence/java/src/main/resources/fr/ird/observe/entities/data/ps/common/TripImpl.hbm.xml
=====================================
@@ -228,6 +228,26 @@
FROM ps_logbook.Route r
INNER JOIN ps_logbook.Activity a ON a.route = r.topiaId
WHERE r.trip = ? AND a.time IS NULL
+]]></sql-query>
+ <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityIdsFromSample" read-only="true"
+ comment="Get all logbook activity ids from samples filtered on a Sample.well">
+ <query-param name="tripId" type="java.lang.String"/>
+ <query-param name="wellId" type="java.lang.String"/><![CDATA[
+ SELECT
+ DISTINCT(sa.activity)
+ FROM ps_logbook.Sample s
+ INNER JOIN ps_logbook.sampleActivity sa ON sa.sample = s.topiaId
+ WHERE s.trip = ? AND s.well = ?
+]]></sql-query>
+ <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityIdsFromWellPlan" read-only="true"
+ comment="Get all logbook activity ids from well plan filtered on a trip and a Well.well">
+ <query-param name="tripId" type="java.lang.String"/>
+ <query-param name="wellId" type="java.lang.String"/><![CDATA[
+ SELECT
+ DISTINCT(wa.activity)
+ FROM ps_logbook.well w
+ INNER JOIN ps_logbook.wellActivity wa ON wa.well = w.topiaId
+ WHERE w.trip = ? AND w.well = ?
]]></sql-query>
<sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookActivityPoint" read-only="true"
comment="Get logbook activity points">
@@ -274,6 +294,22 @@
INNER JOIN ps_logbook.transmittingBuoy t ON t.floatingObject = f.topiaId
WHERE r.trip = ? AND t.latitude IS NOT NULL AND t.longitude IS NOT NULL
ORDER BY r.date, a.time
+]]></sql-query>
+ <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellIdsFromSample" read-only="true"
+ comment="Get all logbook well ids from samples">
+ <query-param name="tripId" type="java.lang.String"/><![CDATA[
+ SELECT
+ DISTINCT(s.well)
+ FROM ps_logbook.Sample s
+ WHERE s.trip = ?
+]]></sql-query>
+ <sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellIdsFromWellPlan" read-only="true"
+ comment="Get all logbook well ids from well plan">
+ <query-param name="tripId" type="java.lang.String"/><![CDATA[
+ SELECT
+ DISTINCT(w.well)
+ FROM ps_logbook.well w
+ WHERE w.trip = ?
]]></sql-query>
<sql-query name="fr.ird.observe.entities.data.ps.common.Trip::LogbookWellPlanActivities" read-only="true"
comment="Get all logbook well plan activities for the given trip">
=====================================
core/persistence/test/src/test/java/fr/ird/observe/entities/data/ps/common/TripTopiaDaoTest.java
=====================================
@@ -42,6 +42,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -64,7 +65,7 @@ public class TripTopiaDaoTest extends PersistenceTestSupportRead {
@Test
public void loadSqlQueries() {
- ObservePersistenceFixtures.assertSqlQueries(Trip.class, 19);
+ ObservePersistenceFixtures.assertSqlQueries(Trip.class, 23);
}
@Test
@@ -122,6 +123,42 @@ public class TripTopiaDaoTest extends PersistenceTestSupportRead {
}
}
+ @Test
+ public void getLogbookWellIdsFromSample() {
+ try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
+ Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookWellIdsFromSample(tripId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ }
+ }
+
+ @Test
+ public void getLogbookWellIdsFromWellPlan() {
+ try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
+ Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookWellIdsFromWellPlan(tripId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ }
+ }
+
+ @Test
+ public void getLogbookActivityIdsFromWellPlan() {
+ try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
+ Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookActivityIdsFromWellPlan(tripId, "3T");
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ }
+ }
+
+ @Test
+ public void getLogbookActivityIdsFromSample() {
+ try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
+ Set<String> actual = Trip.SPI.getDao(persistenceContext).getLogbookActivityIdsFromSample(tripId, "3T");
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(1, actual.size());
+ }
+ }
+
@Test
public void buildMap() {
try (ObserveTopiaPersistenceContext persistenceContext = localTestMethodResource.newPersistenceContext()) {
=====================================
core/services/i18n/src/main/i18n/translations/services_en_GB.properties
=====================================
@@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Route
observe.data.ps.logbook.Route.type=Route
observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=Date (%2$s) must be after trip start date (%1$s).
observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=Date (%1$s) must be before trip end date (%2$s).
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Add activities from well
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Add activities from well
observe.data.ps.logbook.Sample.action.create=Next sample
observe.data.ps.logbook.Sample.action.move=Change trip
observe.data.ps.logbook.Sample.action.move.choose.parent.message=Select target trip
@@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Sample species measure
observe.data.ps.logbook.TransmittingBuoy.code=Code
observe.data.ps.logbook.TransmittingBuoy.country=Flag country
observe.data.ps.logbook.TransmittingBuoy.type=Transmitting buoy
+observe.data.ps.logbook.Well.action.addActivitiesFromSample=Add activities from samples
+observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Add activities from samples
observe.data.ps.logbook.Well.action.create=Next well
observe.data.ps.logbook.Well.action.move=Change trip
observe.data.ps.logbook.Well.action.move.choose.parent.message=Select target trip
=====================================
core/services/i18n/src/main/i18n/translations/services_es_ES.properties
=====================================
@@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Ruta
observe.data.ps.logbook.Route.type=Ruta
observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=El día de observación (%2$s) debe ser superior o igual a la fecha de comienzo de marea (%1$s).
observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=Date (%1$s) must be before trip end date (%2$s).
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Add activities from well \#TODO
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Add activities from well \#TODO
observe.data.ps.logbook.Sample.action.create=Next sample \#TODO
observe.data.ps.logbook.Sample.action.move=Change trip
observe.data.ps.logbook.Sample.action.move.choose.parent.message=Select target trip
@@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Sample species measure
observe.data.ps.logbook.TransmittingBuoy.code=Identificación
observe.data.ps.logbook.TransmittingBuoy.country=Bandera
observe.data.ps.logbook.TransmittingBuoy.type=TransmittingBuoy
+observe.data.ps.logbook.Well.action.addActivitiesFromSample=Add activities from samples \#TODO
+observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Add activities from samples \#TODO
observe.data.ps.logbook.Well.action.create=Next well
observe.data.ps.logbook.Well.action.move=Change trip
observe.data.ps.logbook.Well.action.move.choose.parent.message=Select target trip
=====================================
core/services/i18n/src/main/i18n/translations/services_fr_FR.properties
=====================================
@@ -1205,6 +1205,8 @@ observe.data.ps.logbook.Route.title=Route
observe.data.ps.logbook.Route.type=Route
observe.data.ps.logbook.Route.validation.date.after.currentPsCommonTrip.startDate=Le jour d'observation (%2$s) doit être supérieure ou égale à la date de début de la marée (%1$s).
observe.data.ps.logbook.Route.validation.date.before.currentPsCommonTrip.endDate=La date (%1$s) doit être inférieure ou égale à la date de fin de marée (%2$s).
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell=Récupérer les activités
+observe.data.ps.logbook.Sample.action.addActivitiesFromWell.tip=Récupérer les activités depuis le plan de cuve
observe.data.ps.logbook.Sample.action.create=Échantillon suivant
observe.data.ps.logbook.Sample.action.move=Changer de marée
observe.data.ps.logbook.Sample.action.move.choose.parent.message=À quelle marée voulez-vous associer les échantillons sélectionnés ?
@@ -1263,6 +1265,8 @@ observe.data.ps.logbook.SampleSpeciesMeasure.type=Mesure d'un échantillon espè
observe.data.ps.logbook.TransmittingBuoy.code=Identifiant
observe.data.ps.logbook.TransmittingBuoy.country=Pavillon
observe.data.ps.logbook.TransmittingBuoy.type=Balise émettrice
+observe.data.ps.logbook.Well.action.addActivitiesFromSample=Déduire les activités
+observe.data.ps.logbook.Well.action.addActivitiesFromSample.tip=Déduire les activités depuis les échantillons
observe.data.ps.logbook.Well.action.create=Cuve suivante
observe.data.ps.logbook.Well.action.move=Changer de marée
observe.data.ps.logbook.Well.action.move.choose.parent.message=À quelle marée voulez-vous associer les cuves sélectionnées ?
=====================================
core/services/local/src/main/java/fr/ird/observe/services/local/service/data/ps/common/TripServiceLocalSupport.java
=====================================
@@ -38,6 +38,7 @@ import fr.ird.observe.services.service.data.ps.common.TripService;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
/**
* Created on 26/07/2021.
@@ -82,6 +83,26 @@ public abstract class TripServiceLocalSupport extends ObserveServiceLocal implem
return Trip.SPI.getLogbookWellPlanActivities(this, tripId);
}
+ @Override
+ public Set<String> getLogbookWellIdsFromWellPlan(String tripId) {
+ return Trip.SPI.getLogbookWellIdsFromWellPlan(this, tripId);
+ }
+
+ @Override
+ public Set<String> createLogbookSampleActivityFromWellPlan(String tripId, String wellId) {
+ return Trip.SPI.createLogbookSampleActivityFromWellPlan(this, tripId, wellId);
+ }
+
+ @Override
+ public Set<String> createLogbookWellActivityFromSample(String tripId, String wellId) {
+ return Trip.SPI.createLogbookWellActivityFromSample(this, tripId, wellId);
+ }
+
+ @Override
+ public Set<String> getLogbookWellIdsFromSample(String tripId) {
+ return Trip.SPI.getLogbookWellIdsFromSample(this, tripId);
+ }
+
@Override
public boolean isActivityEndOfSearchFound(String routeId) {
return Trip.SPI.isActivityEndOfSearchFound(this, routeId);
=====================================
core/services/test/src/main/java/fr/ird/observe/services/service/data/ps/common/TripServiceFixtures.java
=====================================
@@ -41,6 +41,7 @@ import fr.ird.observe.services.service.data.RootOpenableServiceFixtures;
import org.junit.Assert;
import java.util.List;
+import java.util.Map;
import java.util.Set;
public class TripServiceFixtures extends GeneratedTripServiceFixtures {
@@ -170,4 +171,38 @@ public class TripServiceFixtures extends GeneratedTripServiceFixtures {
Assert.assertNotNull(actual.getObject().getId());
Assert.assertEquals(tripId, actual.getObject().getId());
}
+
+ @Override
+ public void getLogbookWellIdsFromSample(ObserveServicesProvider servicesProvider, TripService service) {
+ String tripId = getProperty("getLogbookWellIdsFromSample.tripId");
+ Set<String> actual = service.getLogbookWellIdsFromSample(tripId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(getIntegerProperty("getLogbookWellIdsFromSample.count"), actual.size());
+ }
+
+ @Override
+ public void getLogbookWellIdsFromWellPlan(ObserveServicesProvider servicesProvider, TripService service) {
+ String tripId = getProperty("getLogbookWellIdsFromWellPlan.tripId");
+ Set<String> actual = service.getLogbookWellIdsFromWellPlan(tripId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(getIntegerProperty("getLogbookWellIdsFromWellPlan.count"), actual.size());
+ }
+
+ @Override
+ public void createLogbookSampleActivityFromWellPlan(ObserveServicesProvider servicesProvider, TripService service) {
+ String tripId = getProperty("createLogbookSampleActivityFromWellPlan.tripId");
+ String wellId = getProperty("createLogbookSampleActivityFromWellPlan.wellId");
+ Set<String> actual = service.createLogbookSampleActivityFromWellPlan(tripId, wellId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(getIntegerProperty("createLogbookSampleActivityFromWellPlan.count"), actual.size());
+ }
+
+ @Override
+ public void createLogbookWellActivityFromSample(ObserveServicesProvider servicesProvider, TripService service) {
+ String tripId = getProperty("createLogbookWellActivityFromSample.tripId");
+ String wellId = getProperty("createLogbookWellActivityFromSample.wellId");
+ Set<String> actual = service.createLogbookWellActivityFromSample(tripId, wellId);
+ Assert.assertNotNull(actual);
+ Assert.assertEquals(getIntegerProperty("createLogbookWellActivityFromSample.count"), actual.size());
+ }
}
=====================================
core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/data/ps/common/TripService.properties
=====================================
@@ -19,6 +19,12 @@
# <http://www.gnu.org/licenses/gpl-3.0.html>.
# #L%
###
+createLogbookSampleActivityFromWellPlan.count=1
+createLogbookSampleActivityFromWellPlan.tripId=${defaultTripId}
+createLogbookSampleActivityFromWellPlan.wellId=${defaultWellId}
+createLogbookWellActivityFromSample.count=1
+createLogbookWellActivityFromSample.tripId=${defaultTripId}
+createLogbookWellActivityFromSample.wellId=${defaultWellId}
defaultActivityId=FIXME
defaultId=${PS_COMMON_TRIP}
defaultNewParentId=${REFERENTIAL_PS_COMMON_PROGRAM_MOVE}
@@ -28,6 +34,7 @@ defaultRouteId=FIXME
defaultSpeciesListId=fr.ird.referential.common.SpeciesList#1239832675370#0.1
defaultTripId=${PS_COMMON_TRIP}
defaultVesselId=fr.ird.referential.common.Vessel#1239832679425#0.9136908731720471
+defaultWellId=3T
delete.id=${defaultId}
exists.id=${defaultId}
getAllTrip.count=4
@@ -36,6 +43,10 @@ getChildren.count=1
getChildren.parentId=${defaultParentId}
getChildrenUpdate.count=1
getChildrenUpdate.parentId=${defaultParentId}
+getLogbookWellIdsFromSample.count=1
+getLogbookWellIdsFromSample.tripId=${defaultTripId}
+getLogbookWellIdsFromWellPlan.count=1
+getLogbookWellIdsFromWellPlan.tripId=${defaultTripId}
getLogbookWellPlanActivities.count=3
getLogbookWellPlanActivities.tripId=${defaultTripId}
getMatchingTripsVesselWithinDateRange.count=0
=====================================
model/src/main/models/Observe/dto/class/i18nLabels.properties
=====================================
@@ -75,13 +75,13 @@ data.ps.logbook.Catch=comment,species,speciesFate,weight,weightCategory,weightMe
data.ps.logbook.FloatingObject=materialsValid,objectOperation,quadrant,supportVesselName,country,vessel,computedBiodegradable,computedNonEntangling,computedSimplifiedObjectType,computedValues,generalTab,buoysTab,materialsTab,notComputed,type.short,computedWhenArrivingBiodegradable,computedWhenLeavingBiodegradable,computedWhenArrivingNonEntangling,computedWhenLeavingNonEntangling,computedWhenArrivingSimplifiedObjectType,computedWhenLeavingSimplifiedObjectType
data.ps.logbook.FloatingObjectPart=whenArriving,whenLeaving
data.ps.logbook.Route=activity,comment,date,fishingTime,timeAtSea
-data.ps.logbook.Sample=number,activity,bigsWeight,comment,person,sampleQuality,sampleType,smallsWeight,superSample,totalWeight,well,generalTab,activityTab,notSuperSample.with.moreThanOne.sampleSpecies.message,notSuperSample.with.moreThanOne.sampleSpecies.title,personTab,psSampler.available,psSampler.selected
+data.ps.logbook.Sample=number,activity,bigsWeight,comment,person,sampleQuality,sampleType,smallsWeight,superSample,totalWeight,well,generalTab,activityTab,notSuperSample.with.moreThanOne.sampleSpecies.message,notSuperSample.with.moreThanOne.sampleSpecies.title,personTab,psSampler.available,psSampler.selected,action.addActivitiesFromWell,action.addActivitiesFromWell.tip
data.ps.logbook.SampleActivity=activity,weightedWeight,weightedWeightComputed,weightedWeightComputed.short,weightedWeightComputed.computed.tip,weightedWeightComputed.observed.tip
data.ps.logbook.SampleSampleSpecies=superSample,sampleSpecies,species
data.ps.logbook.SampleSpecies=comment,measuredCount,sampleSpeciesMeasure,sizeMeasureType,species,subSampleNumber,totalCount,startTime,endTime,startTime.short,endTime.short,generalTab
data.ps.logbook.SampleSpeciesMeasure=count,sizeClass
data.ps.logbook.TransmittingBuoy=comment,code,transmittingBuoyOwnership,transmittingBuoyType,transmittingBuoyOperation,country,vessel,latitude,longitude,quadrant
-data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamplingStatus,generalTab,wellActivityTab,action.save,action.save.tip,wellVessel.short,wellFactory.short,wellAlternativeNumbering
+data.ps.logbook.Well=well,wellVessel,wellFactory,wellSamplingConformity,wellSamplingStatus,generalTab,wellActivityTab,action.save,action.save.tip,wellVessel.short,wellFactory.short,wellAlternativeNumbering,action.addActivitiesFromSample,action.addActivitiesFromSample.tip
data.ps.logbook.WellActivity=activity,wellActivitySpecies,computedTotalWeight,computedTotalWeight.short
data.ps.logbook.WellActivitySpecies=species,weight,weightCategory,count,setSpeciesNumber
data.ps.observation.Activity=date,coordinate,observedSystem.available,observedSystem.selected,comment,currentFpaZone,dataQuality,detectionMode,ersId,floatingObjectEmpty,latitude,longitude,nextFpaZone,nonTargetCatchSpecies,observedSystem,observedSystemDistance,previousFpaZone,quadrant,reasonForNoFishing,seaSurfaceTemperature,surroundingActivity,time,vesselActivity,vesselSpeed,wind,generalTab,error.no.activity.6,measurementsTab,observedSystemTab
=====================================
model/src/main/resources/META-INF/persistence/fr/ird/observe/entities/data/ps/common/Trip-sql-queries.properties
=====================================
@@ -93,6 +93,34 @@ INNER JOIN ps_logbook.activity a ON a.route = r.topiaId\
INNER JOIN ps_common.vesselActivity va ON a.vesselActivity = va.topiaId\
WHERE r.trip = ? AND va.allowSet = TRUE OR va.topiaId = 'fr.ird.referential.ps.common.VesselActivity#1464000000000#32'\
ORDER BY r.date,a.time
+LogbookWellIdsFromWellPlan.comment=Get all logbook well ids from well plan
+LogbookWellIdsFromWellPlan.parameter.1=tripId|java.lang.String
+LogbookWellIdsFromWellPlan=SELECT\
+DISTINCT(w.well)\
+FROM ps_logbook.well w\
+WHERE w.trip = ?
+LogbookActivityIdsFromWellPlan.comment=Get all logbook activity ids from well plan filtered on a trip and a Well.well
+LogbookActivityIdsFromWellPlan.parameter.1=tripId|java.lang.String
+LogbookActivityIdsFromWellPlan.parameter.2=wellId|java.lang.String
+LogbookActivityIdsFromWellPlan=SELECT\
+DISTINCT(wa.activity)\
+FROM ps_logbook.well w\
+INNER JOIN ps_logbook.wellActivity wa ON wa.well = w.topiaId\
+WHERE w.trip = ? AND w.well = ?
+LogbookWellIdsFromSample.comment=Get all logbook well ids from samples
+LogbookWellIdsFromSample.parameter.1=tripId|java.lang.String
+LogbookWellIdsFromSample=SELECT\
+DISTINCT(s.well)\
+FROM ps_logbook.Sample s\
+WHERE s.trip = ?
+LogbookActivityIdsFromSample.comment=Get all logbook activity ids from samples filtered on a Sample.well
+LogbookActivityIdsFromSample.parameter.1=tripId|java.lang.String
+LogbookActivityIdsFromSample.parameter.2=wellId|java.lang.String
+LogbookActivityIdsFromSample=SELECT\
+DISTINCT(sa.activity)\
+FROM ps_logbook.Sample s\
+INNER JOIN ps_logbook.sampleActivity sa ON sa.sample = s.topiaId\
+WHERE s.trip = ? AND s.well = ?
UpdateVersion.comment=Update trip version
UpdateVersion.parameter.1=lastUpdateDate|java.sql.Timestamp
UpdateVersion.parameter.2=tripId|java.lang.String
=====================================
server/core/src/main/filtered-resources/META-INF/mapping-api-client.wm
=====================================
@@ -141,7 +141,11 @@ GET /data/ps/AvdthService/importData data
POST /data/ps/ConsolidateDataService/consolidateLocalmarketBatch data.ps.ConsolidateDataServiceRestApi.consolidateLocalmarketBatch
POST /data/ps/ConsolidateDataService/consolidateTrip data.ps.ConsolidateDataServiceRestApi.consolidateTrip
GET /data/ps/ConsolidateDataService/newSimplifiedObjectTypeManager data.ps.ConsolidateDataServiceRestApi.newSimplifiedObjectTypeManager
+POST /data/ps/common/TripService/createLogbookSampleActivityFromWellPlan data.ps.common.TripServiceRestApi.createLogbookSampleActivityFromWellPlan
+POST /data/ps/common/TripService/createLogbookWellActivityFromSample data.ps.common.TripServiceRestApi.createLogbookWellActivityFromSample
GET /data/ps/common/TripService/getAllTripIds data.ps.common.TripServiceRestApi.getAllTripIds
+GET /data/ps/common/TripService/getLogbookWellIdsFromSample data.ps.common.TripServiceRestApi.getLogbookWellIdsFromSample
+GET /data/ps/common/TripService/getLogbookWellIdsFromWellPlan data.ps.common.TripServiceRestApi.getLogbookWellIdsFromWellPlan
GET /data/ps/common/TripService/getLogbookWellPlanActivities data.ps.common.TripServiceRestApi.getLogbookWellPlanActivities
GET /data/ps/common/TripService/getMatchingTripsVesselWithinDateRange data.ps.common.TripServiceRestApi.getMatchingTripsVesselWithinDateRange
GET /data/ps/common/TripService/getSpeciesByListAndTrip data.ps.common.TripServiceRestApi.getSpeciesByListAndTrip
=====================================
toolkit/templates/src/main/java/fr/ird/observe/toolkit/templates/dto/DtoTransformer.java
=====================================
@@ -737,7 +737,7 @@ public class DtoTransformer extends BeanTransformer implements TemplateContract
}
super.createProperty(output, attr, usePCS, generateBooleanGetMethods, generateNotEmptyCollections);
boolean multiple = JavaGeneratorUtil.isNMultiplicity(attr);
- if (multiple && JavaGeneratorUtil.isOrdered(attr)) {
+ if (multiple) {
// check out if we are using a WithIndex type
if (attrType.endsWith("Dto")) {
attrType = attrType.substring(0, attrType.length() - "Dto".length());
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/a8286844ccfb8f04e8bf6d24…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/a8286844ccfb8f04e8bf6d24…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] Fix onRemoveRow method (we already are using the modelRow) - See #1203
by Tony CHEMIT (@tchemit) 02 Sep '24
by Tony CHEMIT (@tchemit) 02 Sep '24
02 Sep '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
fb92220f by Tony Chemit at 2024-09-02T11:14:27+02:00
Fix onRemoveRow method (we already are using the modelRow) - See #1203
- - - - -
1 changed file:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
Changes:
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
=====================================
@@ -226,8 +226,7 @@ public abstract class ContentTableUITableModel<D extends DataDto, C extends Cont
// do nothing by default
}
- protected void onRemovedRow(int row) {
- int modelRow = getModelRow(row);
+ protected void onRemovedRow(int modelRow) {
inlineModels.keySet().forEach(inlineModel -> inlineModel.removeRow(modelRow));
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/fb92220ff621d9321d0e50c0d…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/fb92220ff621d9321d0e50c0d…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] Fix WithIndex generation - See #1203
by Tony CHEMIT (@tchemit) 02 Sep '24
by Tony CHEMIT (@tchemit) 02 Sep '24
02 Sep '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
d7d59ba3 by Tony Chemit at 2024-09-02T09:57:04+02:00
Fix WithIndex generation - See #1203
- - - - -
1 changed file:
- toolkit/templates/src/main/java/fr/ird/observe/toolkit/templates/dto/DtoTransformer.java
Changes:
=====================================
toolkit/templates/src/main/java/fr/ird/observe/toolkit/templates/dto/DtoTransformer.java
=====================================
@@ -737,7 +737,7 @@ public class DtoTransformer extends BeanTransformer implements TemplateContract
}
super.createProperty(output, attr, usePCS, generateBooleanGetMethods, generateNotEmptyCollections);
boolean multiple = JavaGeneratorUtil.isNMultiplicity(attr);
- if (multiple && JavaGeneratorUtil.isOrdered(attr)) {
+ if (multiple) {
// check out if we are using a WithIndex type
if (attrType.endsWith("Dto")) {
attrType = attrType.substring(0, attrType.length() - "Dto".length());
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/d7d59ba3cda3837494ae0120a…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/d7d59ba3cda3837494ae0120a…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe] Pushed new branch feature/issue-2734
by Tony CHEMIT (@tchemit) 01 Sep '24
by Tony CHEMIT (@tchemit) 01 Sep '24
01 Sep '24
Tony CHEMIT pushed new branch feature/issue-2734 at ultreiaio / ird-observe
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/tree/feature/issue-2734
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] 2 commits: Add more SwingSession states for some widgets - Closes ultreiaio/jaxx#849
by Tony CHEMIT (@tchemit) 31 Aug '24
by Tony CHEMIT (@tchemit) 31 Aug '24
31 Aug '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
631e84a7 by Tony Chemit at 2024-08-31T10:30:23+02:00
Add more SwingSession states for some widgets - Closes ultreiaio/jaxx#849
- - - - -
6e294852 by Tony Chemit at 2024-08-31T13:25:04+02:00
Update jaxx version - Closes #2928
- - - - -
7 changed files:
- − client/configuration/src/main/java/fr/ird/observe/client/CoordinatesEditorState.java
- − client/configuration/src/main/java/fr/ird/observe/client/FilterableComboBoxState.java
- − client/configuration/src/main/java/fr/ird/observe/client/ListHeaderState.java
- − client/configuration/src/main/java/fr/ird/observe/client/NauticalLengthEditorState.java
- client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
- − client/configuration/src/main/java/fr/ird/observe/client/TemperatureEditorState.java
- pom.xml
Changes:
=====================================
client/configuration/src/main/java/fr/ird/observe/client/CoordinatesEditorState.java deleted
=====================================
@@ -1,83 +0,0 @@
-package fr.ird.observe.client;
-
-/*-
- * #%L
- * ObServe Client :: Configuration
- * %%
- * Copyright (C) 2008 - 2024 IRD, Ultreia.io
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.jaxx.runtime.swing.session.State;
-import org.nuiton.jaxx.widgets.gis.CoordinateFormat;
-import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor;
-
-/**
- * All states to persist on a {@link CoordinatesEditor}.
- * <p>
- * Created at 30/08/2024.
- *
- * @author Tony Chemit - dev(a)tchemit.fr
- * @since 9.3.7
- * <p>
- * FIXME Move this back to JAXX
- */
-public class CoordinatesEditorState implements State {
-
- protected CoordinateFormat format;
-
- public CoordinatesEditorState() {
- }
-
- public CoordinatesEditorState(CoordinateFormat format) {
- this.format = format;
- }
-
- public CoordinateFormat getFormat() {
- return format;
- }
-
- public void setFormat(CoordinateFormat format) {
- this.format = format;
- }
-
- protected CoordinatesEditor checkComponent(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("null component");
- }
- if (!(o instanceof CoordinatesEditor)) {
- throw new IllegalArgumentException("invalid component");
- }
- return (CoordinatesEditor) o;
- }
-
- @Override
- public State getState(Object o) {
- CoordinatesEditor ui = checkComponent(o);
- return new CoordinatesEditorState(ui.getModel().getFormat());
- }
-
- @Override
- public void setState(Object o, State state) {
- if (!(state instanceof CoordinatesEditorState)) {
- throw new IllegalArgumentException("invalid state");
- }
- CoordinatesEditor ui = checkComponent(o);
- CoordinatesEditorState typedState = (CoordinatesEditorState) state;
- ui.getModel().setFormat(typedState.getFormat());
- }
-}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/FilterableComboBoxState.java deleted
=====================================
@@ -1,97 +0,0 @@
-package fr.ird.observe.client;
-
-/*-
- * #%L
- * ObServe Client :: Configuration
- * %%
- * Copyright (C) 2008 - 2024 IRD, Ultreia.io
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
-import org.nuiton.jaxx.runtime.swing.session.State;
-
-/**
- * All states to persist on a {@link FilterableComboBox}.
- * <p>
- * Created at 30/08/2024.
- *
- * @author Tony Chemit - dev(a)tchemit.fr
- * @since 9.3.7
- * <p>
- * FIXME Move this back to JAXX
- */
-public class FilterableComboBoxState implements State {
-
- protected int index = 0;
-
- protected boolean reverseSort = false;
-
- public FilterableComboBoxState() {
- }
-
- public FilterableComboBoxState(int index, boolean reverseSort) {
- this.index = index;
- this.reverseSort = reverseSort;
- }
-
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- public boolean isReverseSort() {
- return reverseSort;
- }
-
- public void setReverseSort(boolean reverseSort) {
- this.reverseSort = reverseSort;
- }
-
- protected FilterableComboBox<?> checkComponent(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("null component");
- }
- if (!(o instanceof FilterableComboBox)) {
- throw new IllegalArgumentException("invalid component");
- }
- return (FilterableComboBox<?>) o;
- }
-
- @Override
- public State getState(Object o) {
- FilterableComboBox<?> combo = checkComponent(o);
- return new FilterableComboBoxState(combo.getModel().getIndex(), combo.getModel().getReverseSort());
- }
-
- @Override
- public void setState(Object o, State state) {
- if (!(state instanceof FilterableComboBoxState)) {
- throw new IllegalArgumentException("invalid state");
- }
- FilterableComboBox<?> ui = checkComponent(o);
- FilterableComboBoxState typedState = (FilterableComboBoxState) state;
- ui.getModel().setIndex(typedState.getIndex());
- ui.getModel().setReverseSort(typedState.isReverseSort());
- }
-
-
-}
-
=====================================
client/configuration/src/main/java/fr/ird/observe/client/ListHeaderState.java deleted
=====================================
@@ -1,99 +0,0 @@
-package fr.ird.observe.client;
-
-/*-
- * #%L
- * ObServe Client :: Configuration
- * %%
- * Copyright (C) 2008 - 2024 IRD, Ultreia.io
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
-import org.nuiton.jaxx.runtime.swing.JAXXButtonGroup;
-import org.nuiton.jaxx.runtime.swing.session.State;
-
-/**
- * All states to persist on a {@link ListHeader}.
- * <p>
- * Created at 30/08/2024.
- *
- * @author Tony Chemit - dev(a)tchemit.fr
- * @since 9.3.7
- * <p>
- * FIXME Move this back to JAXX
- */
-public class ListHeaderState implements State {
-
- protected int index = 0;
-
- protected boolean reverseSort = false;
-
- public ListHeaderState() {
- }
-
- public ListHeaderState(int index, boolean reverseSort) {
- this.index = index;
- this.reverseSort = reverseSort;
- }
-
- public int getIndex() {
- return index;
- }
-
- public void setIndex(int index) {
- this.index = index;
- }
-
- public boolean isReverseSort() {
- return reverseSort;
- }
-
- public void setReverseSort(boolean reverseSort) {
- this.reverseSort = reverseSort;
- }
-
- protected ListHeader<?> checkComponent(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("null component");
- }
- if (!(o instanceof ListHeader)) {
- throw new IllegalArgumentException("invalid component");
- }
- return (ListHeader<?>) o;
- }
-
- @Override
- public State getState(Object o) {
- ListHeader<?> combo = checkComponent(o);
- return new ListHeaderState(combo.getIndex(), combo.getReverseSort());
- }
-
- @Override
- public void setState(Object o, State state) {
- if (!(state instanceof ListHeaderState)) {
- throw new IllegalArgumentException("invalid state");
- }
- ListHeader<?> ui = checkComponent(o);
- ListHeaderState typedState = (ListHeaderState) state;
- ui.setIndex(typedState.getIndex());
- ui.setReverseSort(typedState.isReverseSort());
- //FIXME Move this back to JListHeader.setIndex method
- JAXXButtonGroup indexes = ui.getIndexes();
- indexes.setSelectedButton(ui.getIndex());
- }
-
-}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/NauticalLengthEditorState.java deleted
=====================================
@@ -1,83 +0,0 @@
-package fr.ird.observe.client;
-
-/*-
- * #%L
- * ObServe Client :: Configuration
- * %%
- * Copyright (C) 2008 - 2024 IRD, Ultreia.io
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
-import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthFormat;
-import org.nuiton.jaxx.runtime.swing.session.State;
-
-/**
- * All states to persist on a {@link NauticalLengthEditor}.
- * <p>
- * Created at 30/08/2024.
- *
- * @author Tony Chemit - dev(a)tchemit.fr
- * @since 9.3.7
- * <p>
- * FIXME Move this back to JAXX
- */
-public class NauticalLengthEditorState implements State {
-
- protected NauticalLengthFormat format;
-
- public NauticalLengthEditorState() {
- }
-
- public NauticalLengthEditorState(NauticalLengthFormat format) {
- this.format = format;
- }
-
- public NauticalLengthFormat getFormat() {
- return format;
- }
-
- public void setFormat(NauticalLengthFormat format) {
- this.format = format;
- }
-
- protected NauticalLengthEditor checkComponent(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("null component");
- }
- if (!(o instanceof NauticalLengthEditor)) {
- throw new IllegalArgumentException("invalid component");
- }
- return (NauticalLengthEditor) o;
- }
-
- @Override
- public State getState(Object o) {
- NauticalLengthEditor ui = checkComponent(o);
- return new NauticalLengthEditorState(ui.getModel().getFormat());
- }
-
- @Override
- public void setState(Object o, State state) {
- if (!(state instanceof NauticalLengthEditorState)) {
- throw new IllegalArgumentException("invalid state");
- }
- NauticalLengthEditor ui = checkComponent(o);
- NauticalLengthEditorState typedState = (NauticalLengthEditorState) state;
- ui.getModel().setFormat(typedState.getFormat());
- }
-}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
=====================================
@@ -23,15 +23,20 @@ package fr.ird.observe.client;
*/
import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
+import io.ultreia.java4all.jaxx.widgets.combobox.session.FilterableComboBoxState;
import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
+import io.ultreia.java4all.jaxx.widgets.length.nautical.session.NauticalLengthEditorState;
import io.ultreia.java4all.jaxx.widgets.list.DoubleList;
import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
import io.ultreia.java4all.jaxx.widgets.list.session.DoubleListState;
+import io.ultreia.java4all.jaxx.widgets.list.session.ListHeaderState;
import io.ultreia.java4all.util.SortedProperties;
import org.nuiton.jaxx.runtime.swing.session.State;
import org.nuiton.jaxx.runtime.swing.session.SwingSession;
import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor;
+import org.nuiton.jaxx.widgets.gis.absolute.session.CoordinatesEditorState;
import org.nuiton.jaxx.widgets.temperature.TemperatureEditor;
+import org.nuiton.jaxx.widgets.temperature.session.TemperatureEditorState;
import java.io.BufferedReader;
import java.io.File;
=====================================
client/configuration/src/main/java/fr/ird/observe/client/TemperatureEditorState.java deleted
=====================================
@@ -1,83 +0,0 @@
-package fr.ird.observe.client;
-
-/*-
- * #%L
- * ObServe Client :: Configuration
- * %%
- * Copyright (C) 2008 - 2024 IRD, Ultreia.io
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.nuiton.jaxx.runtime.swing.session.State;
-import org.nuiton.jaxx.widgets.temperature.TemperatureEditor;
-import org.nuiton.jaxx.widgets.temperature.TemperatureFormat;
-
-/**
- * All states to persist on a {@link TemperatureEditor}.
- * <p>
- * Created at 30/08/2024.
- *
- * @author Tony Chemit - dev(a)tchemit.fr
- * @since 9.3.7
- * <p>
- * FIXME Move this back to JAXX
- */
-public class TemperatureEditorState implements State {
-
- protected TemperatureFormat format;
-
- public TemperatureEditorState() {
- }
-
- public TemperatureEditorState(TemperatureFormat format) {
- this.format = format;
- }
-
- public TemperatureFormat getFormat() {
- return format;
- }
-
- public void setFormat(TemperatureFormat format) {
- this.format = format;
- }
-
- protected TemperatureEditor checkComponent(Object o) {
- if (o == null) {
- throw new IllegalArgumentException("null component");
- }
- if (!(o instanceof TemperatureEditor)) {
- throw new IllegalArgumentException("invalid component");
- }
- return (TemperatureEditor) o;
- }
-
- @Override
- public State getState(Object o) {
- TemperatureEditor ui = checkComponent(o);
- return new TemperatureEditorState(ui.getModel().getFormat());
- }
-
- @Override
- public void setState(Object o, State state) {
- if (!(state instanceof TemperatureEditorState)) {
- throw new IllegalArgumentException("invalid state");
- }
- TemperatureEditor ui = checkComponent(o);
- TemperatureEditorState typedState = (TemperatureEditorState) state;
- ui.getModel().setFormat(typedState.getFormat());
- }
-}
=====================================
pom.xml
=====================================
@@ -113,7 +113,7 @@
<buildDate>${maven.build.timestamp}</buildDate>
<!-- >>> Sealed version -->
<plugin.version.site>4.0.0-M13</plugin.version.site>
- <lib.version.java4all.jaxx>3.0.25</lib.version.java4all.jaxx>
+ <lib.version.java4all.jaxx>3.0.26</lib.version.java4all.jaxx>
<lib.version.java4all.validation>1.0.3</lib.version.java4all.validation>
<lib.version.java4all.i18n>4.0-beta-26</lib.version.java4all.i18n>
<lib.version.ognl>3.1.29</lib.version.ognl>
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/df95fe00ec265cd24c6ef9fd…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/df95fe00ec265cd24c6ef9fd…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] 8 commits: Make sure form is never modified on opening in updating mode - See #2928
by Tony CHEMIT (@tchemit) 30 Aug '24
by Tony CHEMIT (@tchemit) 30 Aug '24
30 Aug '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
585e7e3c by Tony Chemit at 2024-08-30T13:13:46+02:00
Make sure form is never modified on opening in updating mode - See #2928
- - - - -
338b09b9 by Tony Chemit at 2024-08-30T13:13:46+02:00
Never alter modified state when changing format (this code is actually not working, but will soon...) - See #2928
- - - - -
fb1673ec by Tony Chemit at 2024-08-30T13:14:02+02:00
Le changement de format des éditeurs de température ou de longueur altère l'état «modifié» du formulaire - Closes #2927
- - - - -
7e46fe94 by Tony Chemit at 2024-08-30T13:14:02+02:00
Add TemperatureEditorState state
- - - - -
f6dc862f by Tony Chemit at 2024-08-30T13:14:02+02:00
Add NauticalLengthEditorState state
- - - - -
b0b52a85 by Tony Chemit at 2024-08-30T13:14:02+02:00
Add CoordinatesEditorState state
- - - - -
bd320372 by Tony Chemit at 2024-08-30T13:14:02+02:00
use new states in ObserveSwingSession
- - - - -
df95fe00 by Tony Chemit at 2024-08-30T13:14:10+02:00
Merge branch 'feature/issue-2901' into develop
Permettre à l’utilisateur de sauvegarder les unités choisies (longueur, température et coordonnées)
- Closes #2901
- - - - -
8 changed files:
- + client/configuration/src/main/java/fr/ird/observe/client/CoordinatesEditorState.java
- + client/configuration/src/main/java/fr/ird/observe/client/NauticalLengthEditorState.java
- client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
- + client/configuration/src/main/java/fr/ird/observe/client/TemperatureEditorState.java
- client/core/src/main/java/fr/ird/observe/client/util/init/UIInitHelper.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
Changes:
=====================================
client/configuration/src/main/java/fr/ird/observe/client/CoordinatesEditorState.java
=====================================
@@ -0,0 +1,83 @@
+package fr.ird.observe.client;
+
+/*-
+ * #%L
+ * ObServe Client :: Configuration
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.nuiton.jaxx.runtime.swing.session.State;
+import org.nuiton.jaxx.widgets.gis.CoordinateFormat;
+import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor;
+
+/**
+ * All states to persist on a {@link CoordinatesEditor}.
+ * <p>
+ * Created at 30/08/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ * <p>
+ * FIXME Move this back to JAXX
+ */
+public class CoordinatesEditorState implements State {
+
+ protected CoordinateFormat format;
+
+ public CoordinatesEditorState() {
+ }
+
+ public CoordinatesEditorState(CoordinateFormat format) {
+ this.format = format;
+ }
+
+ public CoordinateFormat getFormat() {
+ return format;
+ }
+
+ public void setFormat(CoordinateFormat format) {
+ this.format = format;
+ }
+
+ protected CoordinatesEditor checkComponent(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("null component");
+ }
+ if (!(o instanceof CoordinatesEditor)) {
+ throw new IllegalArgumentException("invalid component");
+ }
+ return (CoordinatesEditor) o;
+ }
+
+ @Override
+ public State getState(Object o) {
+ CoordinatesEditor ui = checkComponent(o);
+ return new CoordinatesEditorState(ui.getModel().getFormat());
+ }
+
+ @Override
+ public void setState(Object o, State state) {
+ if (!(state instanceof CoordinatesEditorState)) {
+ throw new IllegalArgumentException("invalid state");
+ }
+ CoordinatesEditor ui = checkComponent(o);
+ CoordinatesEditorState typedState = (CoordinatesEditorState) state;
+ ui.getModel().setFormat(typedState.getFormat());
+ }
+}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/NauticalLengthEditorState.java
=====================================
@@ -0,0 +1,83 @@
+package fr.ird.observe.client;
+
+/*-
+ * #%L
+ * ObServe Client :: Configuration
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
+import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthFormat;
+import org.nuiton.jaxx.runtime.swing.session.State;
+
+/**
+ * All states to persist on a {@link NauticalLengthEditor}.
+ * <p>
+ * Created at 30/08/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ * <p>
+ * FIXME Move this back to JAXX
+ */
+public class NauticalLengthEditorState implements State {
+
+ protected NauticalLengthFormat format;
+
+ public NauticalLengthEditorState() {
+ }
+
+ public NauticalLengthEditorState(NauticalLengthFormat format) {
+ this.format = format;
+ }
+
+ public NauticalLengthFormat getFormat() {
+ return format;
+ }
+
+ public void setFormat(NauticalLengthFormat format) {
+ this.format = format;
+ }
+
+ protected NauticalLengthEditor checkComponent(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("null component");
+ }
+ if (!(o instanceof NauticalLengthEditor)) {
+ throw new IllegalArgumentException("invalid component");
+ }
+ return (NauticalLengthEditor) o;
+ }
+
+ @Override
+ public State getState(Object o) {
+ NauticalLengthEditor ui = checkComponent(o);
+ return new NauticalLengthEditorState(ui.getModel().getFormat());
+ }
+
+ @Override
+ public void setState(Object o, State state) {
+ if (!(state instanceof NauticalLengthEditorState)) {
+ throw new IllegalArgumentException("invalid state");
+ }
+ NauticalLengthEditor ui = checkComponent(o);
+ NauticalLengthEditorState typedState = (NauticalLengthEditorState) state;
+ ui.getModel().setFormat(typedState.getFormat());
+ }
+}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
=====================================
@@ -23,12 +23,15 @@ package fr.ird.observe.client;
*/
import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
+import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
import io.ultreia.java4all.jaxx.widgets.list.DoubleList;
import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
import io.ultreia.java4all.jaxx.widgets.list.session.DoubleListState;
import io.ultreia.java4all.util.SortedProperties;
import org.nuiton.jaxx.runtime.swing.session.State;
import org.nuiton.jaxx.runtime.swing.session.SwingSession;
+import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor;
+import org.nuiton.jaxx.widgets.temperature.TemperatureEditor;
import java.io.BufferedReader;
import java.io.File;
@@ -54,7 +57,10 @@ public class ObserveSwingSession extends SwingSession {
public ObserveSwingSession(File file, boolean autoSave, File preferencesFile) {
super(file, autoSave, Map.of(FilterableComboBox.class, new FilterableComboBoxState(),
DoubleList.class, new DoubleListState(),
- ListHeader.class, new ListHeaderState()
+ ListHeader.class, new ListHeaderState(),
+ TemperatureEditor.class, new TemperatureEditorState(),
+ NauticalLengthEditor.class, new NauticalLengthEditorState(),
+ CoordinatesEditor.class, new CoordinatesEditorState()
));
this.preferencesFile = preferencesFile;
this.preferences = new SortedProperties();
=====================================
client/configuration/src/main/java/fr/ird/observe/client/TemperatureEditorState.java
=====================================
@@ -0,0 +1,83 @@
+package fr.ird.observe.client;
+
+/*-
+ * #%L
+ * ObServe Client :: Configuration
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.nuiton.jaxx.runtime.swing.session.State;
+import org.nuiton.jaxx.widgets.temperature.TemperatureEditor;
+import org.nuiton.jaxx.widgets.temperature.TemperatureFormat;
+
+/**
+ * All states to persist on a {@link TemperatureEditor}.
+ * <p>
+ * Created at 30/08/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ * <p>
+ * FIXME Move this back to JAXX
+ */
+public class TemperatureEditorState implements State {
+
+ protected TemperatureFormat format;
+
+ public TemperatureEditorState() {
+ }
+
+ public TemperatureEditorState(TemperatureFormat format) {
+ this.format = format;
+ }
+
+ public TemperatureFormat getFormat() {
+ return format;
+ }
+
+ public void setFormat(TemperatureFormat format) {
+ this.format = format;
+ }
+
+ protected TemperatureEditor checkComponent(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("null component");
+ }
+ if (!(o instanceof TemperatureEditor)) {
+ throw new IllegalArgumentException("invalid component");
+ }
+ return (TemperatureEditor) o;
+ }
+
+ @Override
+ public State getState(Object o) {
+ TemperatureEditor ui = checkComponent(o);
+ return new TemperatureEditorState(ui.getModel().getFormat());
+ }
+
+ @Override
+ public void setState(Object o, State state) {
+ if (!(state instanceof TemperatureEditorState)) {
+ throw new IllegalArgumentException("invalid state");
+ }
+ TemperatureEditor ui = checkComponent(o);
+ TemperatureEditorState typedState = (TemperatureEditorState) state;
+ ui.getModel().setFormat(typedState.getFormat());
+ }
+}
=====================================
client/core/src/main/java/fr/ird/observe/client/util/init/UIInitHelper.java
=====================================
@@ -23,13 +23,11 @@ package fr.ird.observe.client.util.init;
*/
import fr.ird.observe.client.datasource.validation.ContentMessageTableRenderer;
-import fr.ird.observe.client.datasource.validation.ObserveSwingValidator;
import fr.ird.observe.client.datasource.validation.ObserveValidatorMessageMouseListener;
import io.ultreia.java4all.jaxx.widgets.combobox.BeanEnumEditor;
import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditorConfig;
-import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditorModel;
import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthFormat;
import io.ultreia.java4all.jaxx.widgets.list.DoubleList;
import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
@@ -197,7 +195,7 @@ public class UIInitHelper {
editor.init();
}
- public static void init(JAXXObject ui, ObserveSwingValidator<?> validator, TemperatureEditor editor, boolean autoPopupNumberEditor, boolean showPopupButton, TemperatureFormat defaultFormat) {
+ public static void init(JAXXObject ui, TemperatureEditor editor, boolean autoPopupNumberEditor, boolean showPopupButton, TemperatureFormat defaultFormat) {
NumberEditor numberEditor = editor.getEditor();
numberEditor.setShowReset(true);
numberEditor.setAutoPopup(autoPopupNumberEditor);
@@ -207,14 +205,9 @@ public class UIInitHelper {
Objects.requireNonNull(label, "can't find label for temperature editor " + editor);
editor.setConfig(new TemperatureEditorConfig(defaultFormat, label.getText(), propertyName));
editor.init(label);
- editor.getModel().addPropertyChangeListener("format", e -> {
- if (validator.getBean() != null) {
- validator.doValidate();
- }
- });
}
- public static void init(JAXXObject ui, ObserveSwingValidator<?> validator, NauticalLengthEditor editor, boolean autoPopupNumberEditor, boolean showPopupButton,NauticalLengthFormat defaultFormat) {
+ public static void init(JAXXObject ui, NauticalLengthEditor editor, boolean autoPopupNumberEditor, boolean showPopupButton, NauticalLengthFormat defaultFormat) {
NumberEditor numberEditor = editor.getEditor();
numberEditor.setShowReset(true);
numberEditor.setAutoPopup(autoPopupNumberEditor);
@@ -224,11 +217,7 @@ public class UIInitHelper {
Objects.requireNonNull(label, "can't find label for nautical length editor " + editor);
editor.setConfig(new NauticalLengthEditorConfig(defaultFormat, label.getText(), propertyName));
editor.init(label);
- editor.getModel().addPropertyChangeListener(NauticalLengthEditorModel.PROPERTY_FORMAT, e -> {
- if (validator.getBean() != null) {
- validator.doValidate();
- }
- });
+
}
public static void init(NumberEditor editor, boolean autoPopupNumberEditor, boolean showPopupButton) {
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
=====================================
@@ -257,6 +257,11 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe
}
public void onEndOpenUI() {
+ //FIXME We should remove this code when issue #2928 is fixed
+ ContentUIModelStates states = ui.getModel().getStates();
+ if (!states.isReadingMode()) {
+ states.setModified(states.isCreatingMode());
+ }
}
public void startEditUI() {
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIInitializer.java
=====================================
@@ -44,6 +44,7 @@ import io.ultreia.java4all.jaxx.widgets.choice.BooleanEditor;
import io.ultreia.java4all.jaxx.widgets.combobox.BeanEnumEditor;
import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditor;
+import io.ultreia.java4all.jaxx.widgets.length.nautical.NauticalLengthEditorModel;
import io.ultreia.java4all.jaxx.widgets.list.DoubleList;
import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
import org.jdesktop.swingx.JXTable;
@@ -234,20 +235,41 @@ public class ContentUIInitializer<UI extends ContentUI> extends UIInitializerSup
protected void init(TemperatureEditor editor) {
initializerContext.checkFirstPass();
- ObserveSwingValidator<?> validator = null;
+ ObserveSwingValidator<?> validator;
if (ui instanceof EditableContentUI) {
validator = ((EditableContentUI<?>) ui).getValidator();
+ } else {
+ validator = null;
+ }
+ UIInitHelper.init(ui, editor, getClientConfig().isAutoPopupNumberEditor(), getClientConfig().isShowNumberEditorButton(), getClientConfig().getTemperatureFormat());
+ if (validator != null) {
+ editor.getModel().addPropertyChangeListener("format"/*FIXME make TemperatureEditorModel.PROPERTY_FORMAT public*/, e -> onFormatChanged(validator));
}
- UIInitHelper.init(ui, validator, editor, getClientConfig().isAutoPopupNumberEditor(), getClientConfig().isShowNumberEditorButton(), getClientConfig().getTemperatureFormat());
}
protected void init(NauticalLengthEditor editor) {
initializerContext.checkFirstPass();
- ObserveSwingValidator<?> validator = null;
+ ObserveSwingValidator<?> validator;
if (ui instanceof EditableContentUI) {
validator = ((EditableContentUI<?>) ui).getValidator();
+ } else {
+ validator = null;
+ }
+ UIInitHelper.init(ui, editor, getClientConfig().isAutoPopupNumberEditor(), getClientConfig().isShowNumberEditorButton(), getClientConfig().getNauticalLengthFormat());
+ if (validator != null) {
+ editor.getModel().addPropertyChangeListener(NauticalLengthEditorModel.PROPERTY_FORMAT, e -> onFormatChanged(validator));
+ }
+ }
+
+ private void onFormatChanged(ObserveSwingValidator<?> validator) {
+ if (validator.getBean() != null) {
+ ContentUIModelStates states = ui.getModel().getStates();
+ boolean modified = states.isModified();
+ validator.doValidate();
+ if (!modified) {
+ states.setModified(false);
+ }
}
- UIInitHelper.init(ui, validator, editor, getClientConfig().isAutoPopupNumberEditor(), getClientConfig().isShowNumberEditorButton(), getClientConfig().getNauticalLengthFormat());
}
protected void init(JToolBar editor) {
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/actions/open/ContentOpen.java
=====================================
@@ -655,10 +655,14 @@ public class ContentOpen<U extends ContentUI> {
private synchronized void onCoordinateFormatChanged(CoordinateFormat newValue) {
if (!coordinateFormatChangedIsChanging) {
coordinateFormatChangedIsChanging = true;
+ boolean modified = ui.getModel().getStates().isModified();
try {
coordinateEditors.forEach(e -> e.setFormat(newValue));
} finally {
coordinateFormatChangedIsChanging = false;
+ if (!modified) {
+ ui.getModel().getStates().setModified(false);
+ }
}
}
}
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8d17f01ceffa8a653baeb1e9…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/8d17f01ceffa8a653baeb1e9…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] 4 commits: Add FilterableComboBoxState state
by Tony CHEMIT (@tchemit) 30 Aug '24
by Tony CHEMIT (@tchemit) 30 Aug '24
30 Aug '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
6a093710 by Tony Chemit at 2024-08-30T11:34:21+02:00
Add FilterableComboBoxState state
- - - - -
21265de1 by Tony Chemit at 2024-08-30T11:34:28+02:00
Add ListHeaderState state
- - - - -
c1d72929 by Tony Chemit at 2024-08-30T11:35:12+02:00
use new states in ObserveSwingSession
- - - - -
8d17f01c by Tony Chemit at 2024-08-30T11:48:45+02:00
Merge branch 'feature/issue-2834' into develop
Sauvegarde des préférences utilisateur sur le classement des listes : gestion dans l'UI
- Closes #2834
- - - - -
3 changed files:
- + client/configuration/src/main/java/fr/ird/observe/client/FilterableComboBoxState.java
- + client/configuration/src/main/java/fr/ird/observe/client/ListHeaderState.java
- client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
Changes:
=====================================
client/configuration/src/main/java/fr/ird/observe/client/FilterableComboBoxState.java
=====================================
@@ -0,0 +1,97 @@
+package fr.ird.observe.client;
+
+/*-
+ * #%L
+ * ObServe Client :: Configuration
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
+import org.nuiton.jaxx.runtime.swing.session.State;
+
+/**
+ * All states to persist on a {@link FilterableComboBox}.
+ * <p>
+ * Created at 30/08/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ * <p>
+ * FIXME Move this back to JAXX
+ */
+public class FilterableComboBoxState implements State {
+
+ protected int index = 0;
+
+ protected boolean reverseSort = false;
+
+ public FilterableComboBoxState() {
+ }
+
+ public FilterableComboBoxState(int index, boolean reverseSort) {
+ this.index = index;
+ this.reverseSort = reverseSort;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public boolean isReverseSort() {
+ return reverseSort;
+ }
+
+ public void setReverseSort(boolean reverseSort) {
+ this.reverseSort = reverseSort;
+ }
+
+ protected FilterableComboBox<?> checkComponent(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("null component");
+ }
+ if (!(o instanceof FilterableComboBox)) {
+ throw new IllegalArgumentException("invalid component");
+ }
+ return (FilterableComboBox<?>) o;
+ }
+
+ @Override
+ public State getState(Object o) {
+ FilterableComboBox<?> combo = checkComponent(o);
+ return new FilterableComboBoxState(combo.getModel().getIndex(), combo.getModel().getReverseSort());
+ }
+
+ @Override
+ public void setState(Object o, State state) {
+ if (!(state instanceof FilterableComboBoxState)) {
+ throw new IllegalArgumentException("invalid state");
+ }
+ FilterableComboBox<?> ui = checkComponent(o);
+ FilterableComboBoxState typedState = (FilterableComboBoxState) state;
+ ui.getModel().setIndex(typedState.getIndex());
+ ui.getModel().setReverseSort(typedState.isReverseSort());
+ }
+
+
+}
+
=====================================
client/configuration/src/main/java/fr/ird/observe/client/ListHeaderState.java
=====================================
@@ -0,0 +1,99 @@
+package fr.ird.observe.client;
+
+/*-
+ * #%L
+ * ObServe Client :: Configuration
+ * %%
+ * Copyright (C) 2008 - 2024 IRD, Ultreia.io
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
+import org.nuiton.jaxx.runtime.swing.JAXXButtonGroup;
+import org.nuiton.jaxx.runtime.swing.session.State;
+
+/**
+ * All states to persist on a {@link ListHeader}.
+ * <p>
+ * Created at 30/08/2024.
+ *
+ * @author Tony Chemit - dev(a)tchemit.fr
+ * @since 9.3.7
+ * <p>
+ * FIXME Move this back to JAXX
+ */
+public class ListHeaderState implements State {
+
+ protected int index = 0;
+
+ protected boolean reverseSort = false;
+
+ public ListHeaderState() {
+ }
+
+ public ListHeaderState(int index, boolean reverseSort) {
+ this.index = index;
+ this.reverseSort = reverseSort;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public boolean isReverseSort() {
+ return reverseSort;
+ }
+
+ public void setReverseSort(boolean reverseSort) {
+ this.reverseSort = reverseSort;
+ }
+
+ protected ListHeader<?> checkComponent(Object o) {
+ if (o == null) {
+ throw new IllegalArgumentException("null component");
+ }
+ if (!(o instanceof ListHeader)) {
+ throw new IllegalArgumentException("invalid component");
+ }
+ return (ListHeader<?>) o;
+ }
+
+ @Override
+ public State getState(Object o) {
+ ListHeader<?> combo = checkComponent(o);
+ return new ListHeaderState(combo.getIndex(), combo.getReverseSort());
+ }
+
+ @Override
+ public void setState(Object o, State state) {
+ if (!(state instanceof ListHeaderState)) {
+ throw new IllegalArgumentException("invalid state");
+ }
+ ListHeader<?> ui = checkComponent(o);
+ ListHeaderState typedState = (ListHeaderState) state;
+ ui.setIndex(typedState.getIndex());
+ ui.setReverseSort(typedState.isReverseSort());
+ //FIXME Move this back to JListHeader.setIndex method
+ JAXXButtonGroup indexes = ui.getIndexes();
+ indexes.setSelectedButton(ui.getIndex());
+ }
+
+}
=====================================
client/configuration/src/main/java/fr/ird/observe/client/ObserveSwingSession.java
=====================================
@@ -22,6 +22,10 @@ package fr.ird.observe.client;
* #L%
*/
+import io.ultreia.java4all.jaxx.widgets.combobox.FilterableComboBox;
+import io.ultreia.java4all.jaxx.widgets.list.DoubleList;
+import io.ultreia.java4all.jaxx.widgets.list.ListHeader;
+import io.ultreia.java4all.jaxx.widgets.list.session.DoubleListState;
import io.ultreia.java4all.util.SortedProperties;
import org.nuiton.jaxx.runtime.swing.session.State;
import org.nuiton.jaxx.runtime.swing.session.SwingSession;
@@ -46,8 +50,12 @@ public class ObserveSwingSession extends SwingSession {
private final File preferencesFile;
private final Properties preferences;
+
public ObserveSwingSession(File file, boolean autoSave, File preferencesFile) {
- super(file, autoSave);
+ super(file, autoSave, Map.of(FilterableComboBox.class, new FilterableComboBoxState(),
+ DoubleList.class, new DoubleListState(),
+ ListHeader.class, new ListHeaderState()
+ ));
this.preferencesFile = preferencesFile;
this.preferences = new SortedProperties();
loadPreferences(preferencesFile);
@@ -68,8 +76,8 @@ public class ObserveSwingSession extends SwingSession {
return preferences;
}
- private void loadPreferences(File preferencesFile) {
- if(preferencesFile.exists()) {
+ private void loadPreferences(File preferencesFile) {
+ if (preferencesFile.exists()) {
try (BufferedReader reader = Files.newBufferedReader(preferencesFile.toPath(), StandardCharsets.UTF_8)) {
preferences.load(reader);
} catch (IOException e) {
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b1408eb4a1930e47d445b203…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b1408eb4a1930e47d445b203…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] 7 commits: Introduce WithIndex and ContainerChildWithIndexDto API
by Tony CHEMIT (@tchemit) 29 Aug '24
by Tony CHEMIT (@tchemit) 29 Aug '24
29 Aug '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
f0d6b167 by Tony Chemit at 2024-08-29T16:05:48+02:00
Introduce WithIndex and ContainerChildWithIndexDto API
- - - - -
6b65e1ec by Tony Chemit at 2024-08-29T16:05:48+02:00
use ContainerChildWithIndexDto in ObServe model
- - - - -
16de6a08 by Tony Chemit at 2024-08-29T16:05:48+02:00
Be able to do actions on JXTableHeader (for the sort actions on reading form)
- - - - -
ebd1998a by Tony Chemit at 2024-08-29T16:05:48+02:00
Improve JXTableUtil to display index column with a specific renderer
- - - - -
5688aded by Tony Chemit at 2024-08-29T16:06:54+02:00
Review ContentTableUI API to use WithIndex objects, review also move actions
- - - - -
161fab9d by Tony Chemit at 2024-08-29T16:07:01+02:00
Adapt forms using WithIndex objects
- - - - -
b1408eb4 by Tony Chemit at 2024-08-29T16:07:54+02:00
Merge branch 'feature/issue-1203' into develop
Tableaux de saisie (captures, échantillons, équipements...) - Classement en cliquant sur les en-têtes de colonnes
- Closes #1203
- - - - -
30 changed files:
- client/core/src/main/java/fr/ird/observe/client/main/focus/MainUIFocusModel.java
- client/core/src/main/java/fr/ird/observe/client/util/table/JXTableUtil.java
- client/datasource/editor/api/src/main/i18n/getters/java.getter
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/sample/SampleContentTableUIModelStates.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/simple/ContentSimpleUIModel.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/simple/ContentSimpleUIModelStatesSupport.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUIModelStates.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/ContentTableUITableModel.java
- + client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/move/MoveAbstractAction.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/move/MoveBottom.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/move/MoveDown.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/move/MoveTop.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/data/table/actions/entry/move/MoveUp.java
- client/datasource/editor/ll/src/main/i18n/getters/navigation.getter
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/SamplePartUI.jaxx
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/SamplePartUITableModel.java
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/logbook/SetCatchUI.jaxx
- client/datasource/editor/ll/src/main/java/fr/ird/observe/client/datasource/editor/ll/data/observation/SetCatchUI.jaxx
- client/datasource/editor/ps/src/main/i18n/getters/navigation.getter
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/landing/TripLandingUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/landing/TripLandingUITableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/localmarket/TripBatchUITableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/ActivityCatchUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/ActivityCatchUITableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleSpeciesUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/logbook/SampleSpeciesUITableModel.java
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUI.jaxx
- client/datasource/editor/ps/src/main/java/fr/ird/observe/client/datasource/editor/ps/data/observation/SampleUITableModel.java
The diff was not included because it is too large.
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b34346edd609c825bf687206…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/compare/b34346edd609c825bf687206…
You're receiving this email because of your account on gitlab.com.
1
0
[Git][ultreiaio/ird-observe][develop] Amélioration de la conservation du paramétrage des UI - Closes #2926
by Tony CHEMIT (@tchemit) 29 Aug '24
by Tony CHEMIT (@tchemit) 29 Aug '24
29 Aug '24
Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
b34346ed by Tony Chemit at 2024-08-29T16:05:04+02:00
Amélioration de la conservation du paramétrage des UI - Closes #2926
- - - - -
2 changed files:
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/DataSourceEditorHandler.java
- client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
Changes:
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/DataSourceEditorHandler.java
=====================================
@@ -88,6 +88,7 @@ public class DataSourceEditorHandler implements UIHandler<DataSourceEditor>, Wit
contentAdjusting = true;
try {
log.info(String.format("Content ui changed from: %s to %s", previousContentUI == null ? null : previousContentUI.getModel().getPrefix(), contentUI == null ? null : contentUI.getModel().getPrefix()));
+ swingSessionHelper.save();
if (previousContentUI != null) {
log.info(String.format("[%s] Will destroy previous content ui", previousContentUI.getClass().getSimpleName()));
previousContentUI.destroy();
@@ -131,7 +132,6 @@ public class DataSourceEditorHandler implements UIHandler<DataSourceEditor>, Wit
log.info(String.format("%sWill open ui", contentUI.getModel().getPrefix()));
contentUI.open();
swingSessionHelper.addComponent(contentUI, true);
- swingSessionHelper.save();
contentUI.onOpened();
updateContentSize();
log.info(String.format("%s opened", contentUI.getModel().getPrefix()));
=====================================
client/datasource/editor/api/src/main/java/fr/ird/observe/client/datasource/editor/api/content/ContentUIHandler.java
=====================================
@@ -149,6 +149,9 @@ public abstract class ContentUIHandler<U extends ContentUI> implements ObserveSe
throw new IllegalStateException("Can't init twice " + this);
}
init = true;
+ // always set the class name as name of the top component, otherwise when saving via SwingSession we can not
+ // distinguish the UI from another one
+ ui.setName(ui.getClass().getName());
this.contentOpen = Objects.requireNonNull(createContentOpen(ui));
ContentUIModel model = ui.getModel();
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/b34346edd609c825bf6872065…
--
View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/-/commit/b34346edd609c825bf6872065…
You're receiving this email because of your account on gitlab.com.
1
0