public void parametersAreDefined ( Report report ) throws ParameterNotFoundException { String [ ] paramNames ; String sql = report . getSql ( ) ; if ( sql == null ) { sql = report . getQuery ( ) . toString ( ) ; } Query query = new Query ( sql ) ; paramNames = query . getParameterNames ( ) ; List < QueryParameter > parameters = report . getParameters ( ) ; for ( String paramName : paramNames ) { QueryParameter param = null ; for ( QueryParameter p : parameters ) { if ( paramName . equals ( p . getName ( ) ) ) { param = p ; } } if ( param == null ) { throw new ParameterNotFoundException ( paramName ) ; } } }
Test if all parameters used in the report are defined