Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add paramter "resolvedepth" in UI when downloading data via WFS #1174

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
emanuelaepure10 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading