So this is what you were talking about with respect to the "process stuff not
being ready".
Okay lets get cracking; I don't want to commit to a stable until you are
sorted….
> writing processes over and over let me to see some deficiencies in the
> WPS annotations that
> I would like to clear out. Some are general to processes, some are WPS
> usage specific
> (that's why I'm cross posting to gs-devevl).
>
>
So if we are mostly talking annotations I will relax a bit, I want to make sure
the process and process factory objects are stable and complete with respect
providing everything WPS service needs for publishing.
> One thing I see I do over and over at the start of a process is value
> defaulting and validation.
>
> For params that are not mandatory but have a default value, it would
> be nice to just stick
> the default value in the annotation:
>
> @DescribeParameter(name = "multiplier", min = 0, default = 1d) double
> multiplier
We may get more milage out of taking a default String and allowing Converters
to have a go at it.
Compare:
- @DescribeParameter(name = "background", min = 0, default = "#23112F") Color
background
- @DescribeParameter(name = "background", min = 0, default = new Color(
35,17,47) Color background
But still point taken; great to document the default value that can be used if
null is passed in.
> For params that need validation it would be nice to have a set of
> common validators so that we don't
> have to roll the validation logic in the process code:
>
> @DescribeParameter(name = "myparam", validator = new
> RangeValidator(100, 200)) double myparam)
>
>
The DescribeParameter information is pulled into a Parameter object; which
contains a metadata map and common keys. The base Parameter implementation
contains methods to perform common validation checks.
Still turning this DescribeParameter annotation into a Parameter object is done
by our Process object; and is not easily available to those quickly writing a
static method. Perhaps we can make a ParameterImpl.valueOf( Class type, String
method, String arg) method so this is accessible?
class Bar {
public static double expand( int @DescribeParameter( name = "scale", min=100,
max=200,defaultValue=100) double scale ){
Parameter scaleParam = ParamImpl.valueOf( Bar.class, "expand", "scale" );
// find annotation and process it down into the Parameter utility class
if( scaleParam.isRequried() && foo == null ){
x = param.getDefaultValue();
}
// most of the validation code is off in gt-swing and udig codebase :(
if( !scaleParam.isValid( scale ) ){
throw new IllegalArgumentException( scaleParam.validationMessage( scale
) );
}
return 1.0 / (scale*100.0);
}
}
> Or use some convention and reflection, something like:
>
> new Validator("double", "isInRange", 0, 100)
>
> to end up calling DoubleValidator.isInRange(value, min, max).
> Hmm... the above could be also done using code generation against all
> the routines to get a
> set of typesafe validation objects, or a factory exposing all the
> validators, Validators.doubleIsInRange(0, 100) -> Validator
>
>
I don't mind how we go about this; I just want to avoid duplication. It is a
good problem to solve as we can use the same solution in our function
implementations.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel