Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341256 - validate parameters
Summary: validate parameters
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ruo Yin CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard: Obsolete
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-29 12:39 EDT by Pico CLA
Modified: 2011-10-31 22:54 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pico CLA 2011-03-29 12:39:27 EDT
Build Identifier: BIRT 2.6.0

Hello!

I am working with BIRT 2.6.0 and a use RunAndRenderTask validateParameters(), and i know that the validation fails, but i need to know which parameter makes the validations fails and why.

Is it possible ? Could i make a loop to validate the parameters one to one ? any workaround? could I get the ParameterValidationException list ? 

Thanks in advanced.

Pico

Reproducible: Always

Steps to Reproduce:
1.validate parameters with  RunAndRenderTask.validateParameters()
2.validation fails
3.we know that validations fails but not why
Comment 1 Jun Ouyang CLA 2011-03-29 22:02:44 EDT
Actually, there is a log message telling the invalid parameter and its desired type.

Another way to locate invalid parameter is to check parameter values one by one.

For example:
    task.setParameterValue( "p1", "v1");
    task.validateParameterValues();
    task.setParameterValue( "p2", "v2");
    task.validateParameterValues();
Comment 2 Pico CLA 2011-03-30 03:22:00 EDT
Hi, 

I know the log message but i`d need it at runtime to show to de user.

where is  the method validateParametersValues() ? 
I only know validateParameters() and if i use it to check parameters one to one, always give me false because it check all the parameters not only the parameter set.

In your example if p2 is required the first validateParameters return false although p1 is ok.

    task.setParameterValue( "p1", "v1");
    task.validateParameters();  ->> False because p2 is required and p1 is ok     
    task.setParameterValue( "p2", "v2");
    task.validateParameters();

another way ? 

Thanks a lot.
Comment 3 Jun Ouyang CLA 2011-03-30 03:50:27 EDT
Oh, sorry, it's my typo, I mean validateParameters() by validateParameterValues().

There is no API to get detail result of validation at render time. We need to add a new method like:
   boolean validateParameters( boolean verbose ) throw EngineException;
to throw exception with detail failure information.

There are 2 workarounds for now:
1. In EngineTask, method doValidateParameters(), which does the actual validation, does throw out the exception. You can manage to create a dynamic proxy of the class and catch the exception.

2. If above solution is too tricky for you, you'd better use same logic in EngineTask to validate parameters by yourself. It's not difficult.
Comment 4 Ruo Yin CLA 2011-10-31 22:12:28 EDT
After calling task.validateParameters, you can call task.getErrors() to retrieve the error
Comment 5 Xiaoying Gu CLA 2011-10-31 22:54:25 EDT
Verified.