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

Fix bug in WPS client: LiteralInputType is missing DefaultValue property #810

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -55,6 +55,8 @@ public class LiteralInputType extends InputType {

private ValueWithRef dataType;

private String defaultValue;

private ValueWithRef defaultUom;

private ValueWithRef[] supportedUoms;
Expand All @@ -69,7 +71,7 @@ public class LiteralInputType extends InputType {

private boolean anyValue;

private ValueWithRef reference;
private ValueWithRef valuesReference;

/**
* Creates a new {@link LiteralInputType} instance.
Expand All @@ -85,20 +87,21 @@ public class LiteralInputType extends InputType {
* @param allowedValues
* @param range
* @param anyValue
* @param reference
* @param valuesReference
*/
public LiteralInputType( CodeType id, LanguageString inputTitle, LanguageString inputAbstract, String minOccurs,
String maxOccurs, ValueWithRef dataType, ValueWithRef defaultUom,
String maxOccurs, ValueWithRef dataType, String defaultValue, ValueWithRef defaultUom,
ValueWithRef[] supportedUoms, String[] allowedValues, Range[] range, boolean anyValue,
ValueWithRef reference ) {
super( id, inputTitle, inputAbstract, minOccurs, maxOccurs );
this.dataType = dataType;
this.defaultValue = defaultValue;
this.defaultUom = defaultUom;
this.supportedUoms = supportedUoms;
this.allowedValues = allowedValues;
this.range = range;
this.anyValue = anyValue;
this.reference = reference;
this.valuesReference = reference;
}

@Override
Expand Down Expand Up @@ -160,4 +163,23 @@ public ValueWithRef[] getSupportedUoms() {
public boolean isAnyValue() {
return anyValue;
}

/**
* Returns the default value for the literal input as a String.
*
* @return Default value for the literal input.
*/
public String getDefaultValue() {
return defaultValue;
}

/**
* Returns the values reference that references an externally defined finite set of values and ranges for the
* literal input.
*
* @return Values reference for the literal input.
*/
public ValueWithRef getValuesReference() {
return valuesReference;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ private LiteralInputType parseLiteralData( OMElement input, CodeType id, Languag
String dataTypeRefStr = omDataType.getAttributeValue( new QName( owsNS, "reference" ) );
ValueWithRef dataType = new ValueWithRef( dataTypeStr, dataTypeRefStr );

OMElement omDefaultValue = input.getFirstChildWithName( new QName( null, "DefaultValue" ) );
String defaultValue = omDefaultValue == null ? null : omDefaultValue.getText();

XPath xpath = new XPath( "UOMs/Default/ows:UOM", nsContext );
OMElement omDefaultUom = omResponse.getElement( input, xpath );
ValueWithRef defaultUom = null;
Expand Down Expand Up @@ -382,8 +385,8 @@ private LiteralInputType parseLiteralData( OMElement input, CodeType id, Languag
if ( rangeList != null ) {
rangeArray = rangeList.toArray( new Range[rangeList.size()] );
}
return new LiteralInputType( id, inputTitle, inputAbstract, minOccurs, maxOccurs, dataType, defaultUom,
supportedUom, valuesArray, rangeArray, anyValue, valuesRef );
return new LiteralInputType( id, inputTitle, inputAbstract, minOccurs, maxOccurs, dataType, defaultValue,
defaultUom, supportedUom, valuesArray, rangeArray, anyValue, valuesRef );
}

private InputType parseComplexData( OMElement input, CodeType id, LanguageString inputTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,32 @@ public void testFailedExecute_2()
execution.executeAsync();
Assert.assertTrue(execution.getState() != ExecutionState.SUCCEEDED); // we shouldn't arrive here
}

@Test
public void testProcessDescriptionWithDefaultValue()
throws OWSExceptionReport, IOException {

String demoWPSURL = TestProperties.getProperty( "demo_wps_url2" );
String demoWPSProcessorName = TestProperties.getProperty( "demo_wps_def_processor" );
Assume.assumeNotNull( demoWPSURL );
Assume.assumeNotNull( demoWPSProcessorName );

WPSClient wpsClient = new WPSClient( new URL( demoWPSURL ) );

org.deegree.protocol.wps.client.process.Process p1 = wpsClient.getProcess( demoWPSProcessorName );

Assert.assertNotNull( p1 );

boolean foundDefaultValue = false;

for ( InputType inputType : p1.getInputTypes() ) {
if ( inputType instanceof LiteralInputType ) {
LiteralInputType literal = (LiteralInputType) inputType;
if ( literal.getDefaultValue() != null )
foundDefaultValue = true;
}
}

Assert.assertTrue( "Could not find default value for any of the literal inputs", foundDefaultValue );
}
}