Andrea,

Funny you bring this up, very timely as I've been looking at processes the
past few days.


On Fri, Jun 8, 2012 at 6:06 AM, Andrea Aime <andrea.a...@geo-solutions.it>wrote:

> Hi,
> 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).
>
> 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
>
> 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)
>
> I would really hate to have to roll our own in this case, there is
> plenty of validation packages
> around on the web, but all seem to be focusing quite specifically on a
> particular use case,
> e.g., validating forms, validating a Swing GUI, or carrying around a
> lot of extras. Sigh...
> I guess we could roll our own built on top of commons-validator
> routines, to avoid duplicating
> really everything? 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
>
> Moving on to something WPS specific, we need to be able to declare
> what mime types the input files/streams
> we are going to accept, and which ones we are going to produce.
> Normally we avoid this issue in GeoServer by trading objects (e.g.,
> RenderedImage, Coverage, FeatureCollection)
> that specialized utility classes (ProcessParameterIO) turn into a
> serialized format with a specific mime type.
> But there are processes around that really do trade files, and
> specific formats of them for what is worth.
>
> For files that are inputs we could have something like:
>
> @DescribeBinaryInput(..., mimeTypes = new String[] {image/png,
> image/jpeg, ...} ...)
>
> The mimeType would have then to be carried around by Parameter, which
> has a metadata map
> that we cannot read... can we add a getMetadata(key) method in there
> to access some random
> metadata?
>
> Dealing with the output formats instead is going to be loads of fun.
> We can have a
> @DescribeBinaryResult( ... mimeTypes = new String[] {image/png,
> image/jpeg, ...}
> and that would allow us to run DescribeProcess, but when it comes to
> executing the fun starts,
> since the user will choose one of the output formats as part of the
> _output_, not as part of
> the input:
>
> <wps:RawDataOutput mimeType="image/png">
> <ows:Identifier>theImage</ows:Identifier>
> </wps:RawDataOutput>
> </wps:ResponseForm>
>
> How is the process going to know that the user requested image/png as
> the output format, since
> that's not part of the inputs?
> All I can think if being explicit about which of the input params is
> going to be mapped to such choice,
> and avoid exposing such param in the DescribeProcess:
>
> @DescribeBinaryResult( ... mapToInput = "outputFormat")
> @DescribeParameter(name="outputFormat") String outputFormat
>
> Any better idea?
>

 This one doesn't look terrible, from an implementer point of view it's
quite clear what it does.


>
> One final thing that happened to me while writing processes is
> realizing that  a process
> will take long, that it cannot be written in a streaming manner for
> some reason, and thus
> really wanting the process to be only run in asynch mode.
> Ideally it would be nice to have the following:
>
> @DescribeProcess(... synch=false, asynch=true)
>

I really like this idea, and had been wondering about it. I'm not sure if
you want synch and asynch, perhaps only keep asynch with a default value of
false?


>
> However I don't see a way to expose this from ProcessFactory, and it's
> indeed something
> that would be pretty WPS specific. Maybe we should augment the
> ProcessFactory
> to return a open ended metadata map about the process?
>
> Map<String, Object> getProcessMetadata(Name process)
>
> Feedback welcomed.
>
> Cheers
> Andrea
>
>
> --
> Ing. Andrea Aime
> GeoSolutions S.A.S.
> Tech lead
>
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
>
> phone: +39 0584 962313
> fax:      +39 0584 962313
> mob:    +39 339 8844549
>
> http://www.geo-solutions.it
> http://geo-solutions.blogspot.com/
> http://www.youtube.com/user/GeoSolutionsIT
> http://www.linkedin.com/in/andreaaime
> http://twitter.com/geowolf
>
>
> ------------------------------------------------------------------------------
> 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
>



-- 
Juan Marín Otero
GIS Consultant

-------Visita mi blog en---------------------
http://guachintoneando.blogspot.com
---------------------------------------------------
------------------------------------------------------------------------------
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

Reply via email to