Skip to content

Commit

Permalink
feat: add paramter "resolvedepth" in UI when downloading data via WFS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emanuelaepure10 committed May 24, 2024
1 parent 247bc7c commit 05be80d
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,8 +36,14 @@
*/
public class GetFeatureParamsPage extends ConfigurationWizardPage<WFSGetFeatureConfig> {

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.
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ class WFSGetFeatureConfig {
BBox bbox
String bboxCrsUri
Integer maxFeatures
String resolveDepth
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 05be80d

Please sign in to comment.