From cfd20aa0abe6ee7702cfaccf12e5d25c955451ec Mon Sep 17 00:00:00 2001 From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com> Date: Wed, 15 May 2024 15:39:06 +0200 Subject: [PATCH] feat: add paramter "resolvedepth" in UI when downloading data via WFS Add in the dialog for the WFS GetCapability the possibility to choose if you want to add a resolveDepth for a request and how much would that be. Has been added a spinner to choose a number above 0 or the '*' for all the possible depths to be resolved. ING-4129 Closes #1085 --- .../ui/getfeature/GetFeatureParamsPage.java | 76 +++++++++++++++++++ .../ui/getfeature/WFSGetFeatureConfig.groovy | 1 + .../ui/getfeature/WFSGetFeatureSource.java | 4 + 3 files changed, 81 insertions(+) diff --git a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/GetFeatureParamsPage.java b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/GetFeatureParamsPage.java index 3650a2ce78..bc757159d0 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/GetFeatureParamsPage.java +++ b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/GetFeatureParamsPage.java @@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; import eu.esdihumboldt.hale.ui.util.wizard.ConfigurationWizard; @@ -35,8 +36,14 @@ */ public class GetFeatureParamsPage extends ConfigurationWizardPage { + private final String RESOLVE_DEPTH_ALL = "*"; + private Button maxFeaturesEnabled; private Spinner maxFeatures; + private Button resolveLinks; + private Button resolveLinksRadioValue; + private Spinner resolveLinksValueSpinner; + private Button resolveLinksRadioAllValues; /** * Create a new wizard page. @@ -60,6 +67,21 @@ public boolean updateConfiguration(WFSGetFeatureConfig configuration) { else { configuration.setMaxFeatures(null); } + + if (resolveLinks.getSelection()) { + if (resolveLinksRadioValue.getSelection()) { + // Set resolve depth based on the value from the spinner + int selectedDepth = resolveLinksValueSpinner.getSelection(); + configuration.setResolveDepth(String.valueOf(selectedDepth)); + } + else if (resolveLinksRadioAllValues.getSelection()) { + // Set resolve depth to a predefined value for all values + configuration.setResolveDepth(RESOLVE_DEPTH_ALL); + } + } + else { + configuration.setResolveDepth(null); + } return true; } @@ -93,6 +115,60 @@ public void widgetSelected(SelectionEvent e) { } }); + Group resolveLinksGroup = new Group(page, SWT.NONE); + resolveLinksGroup.setText("Resolve nested references (resolve depth)"); + GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).applyTo(resolveLinksGroup); + GridDataFactory.fillDefaults().grab(true, false).applyTo(resolveLinksGroup); + + resolveLinks = new Button(resolveLinksGroup, SWT.CHECK); + resolveLinks.setText("Resolve nested references"); + resolveLinks.setSelection(false); + + // Add an empty string in the second column + Label emptyLabel = new Label(resolveLinksGroup, SWT.NONE); + emptyLabel.setText(""); // Set an empty string + + resolveLinksRadioValue = new Button(resolveLinksGroup, SWT.RADIO); + resolveLinksRadioValue.setText("Resolve nested references to a depth of"); + resolveLinksRadioValue.setSelection(true); + resolveLinksRadioValue.setEnabled(false); + + resolveLinksValueSpinner = new Spinner(resolveLinksGroup, SWT.BORDER); + resolveLinksValueSpinner.setMinimum(1); + resolveLinksValueSpinner.setMaximum(10); + resolveLinksValueSpinner.setIncrement(1); + resolveLinksValueSpinner.setPageIncrement(1); + resolveLinksValueSpinner.setSelection(1); + resolveLinksValueSpinner.setEnabled(false); + + resolveLinksRadioAllValues = new Button(resolveLinksGroup, SWT.RADIO); + resolveLinksRadioAllValues.setText("Resolve all immediate and nested references ('*')"); + resolveLinksRadioAllValues.setEnabled(false); + + // Add an empty string in the second column + Label emptyLabelAll = new Label(resolveLinksGroup, SWT.NONE); + emptyLabelAll.setText(""); // Set an empty string + + resolveLinks.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + resolveLinksRadioValue.setEnabled(resolveLinks.getSelection()); + if (resolveLinks.getSelection() && resolveLinksRadioValue.getSelection()) { + resolveLinksValueSpinner.setEnabled(resolveLinks.getSelection()); + } + resolveLinksRadioAllValues.setEnabled(resolveLinks.getSelection()); + } + }); + + resolveLinksRadioValue.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + resolveLinksValueSpinner.setEnabled(resolveLinksRadioValue.getSelection()); + } + }); + setControl(page); } diff --git a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureConfig.groovy b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureConfig.groovy index 1375c04a08..320b9d4340 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureConfig.groovy +++ b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureConfig.groovy @@ -34,4 +34,5 @@ class WFSGetFeatureConfig { BBox bbox String bboxCrsUri Integer maxFeatures + String resolveDepth } diff --git a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureSource.java b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureSource.java index 5827477fe5..b9095ec0c6 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureSource.java +++ b/io/plugins/eu.esdihumboldt.hale.io.wfs.ui/src/eu/esdihumboldt/hale/io/wfs/ui/getfeature/WFSGetFeatureSource.java @@ -105,6 +105,10 @@ protected void determineSource(URIFieldEditor sourceURL) { } } + if (result.getResolveDepth() != null && !result.getResolveDepth().isEmpty()) { + builder.addParameter("resolveDepth", result.getResolveDepth()); + } + try { sourceURL.setStringValue(builder.build().toString()); getPage().setErrorMessage(null);