All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ibs.ebf.db.EbfQuery

java.lang.Object
   |
   +----ibs.ebf.db.EbfQuery

public class EbfQuery
extends Object
implements IQuery
This class is responsible for parsing, loading and saving the query file in the format required by the ebf query.

Query files are loaded from or written into the 'InstanceRoot/queries/' directory as 'query_id.ebq' - where ebq is an abbreviation of 'Electronic Business Query'.

Syntax:
* All query parameters must be enclosed within << and >> delimiters.
* Parameter name $$TODAY is replaced by current date in YYYY-MM-DD format
* Parameter name $$DATE is replaced by current date in DD/MMM/YYYY format
* Parameter name $$TIME is replaced by current time in 'hh:mm:ss a' format
* Parameter name $$

See Also:
EbfGlobal

Constructor Index

 o EbfQuery(String)
Constructor for class EbfQuery.
 o EbfQuery(String, boolean)
Constructor for class EbfQuery.
 o EbfQuery(String, String)
Note: Use this constructor ONLY if you need to access query file from a different instance.
 o EbfQuery(String, String, boolean)
Note: Use this constructor ONLY if you need to access query file from a different instance.

Method Index

 o getComments()
Returns value assigned to 'COMMENTS::' in the query file.
 o getQueryFilePath()
Returns path for the query files where queries are stored.
 o getQueryName()
Returns value assigned to 'QUERY_NAME::' in the query file.
 o getQueryString()
Returns formatted query string.
 o getQueryString(EbfQueryParameters)
Returns formatted query string.
 o getRawQuery()
Returns raw query string (unparsed, unformatted).
 o main(String[])
Main method is included in here for DIGNOSTICS PURPOSE ONLY.
 o save()
Saves query file to the queries directory.
 o setComments(String)
Assign a value to 'COMMENTS::' in the query file.
 o setQueryName(String)
Assign a value to 'QUERY_NAME::' in the query file.
 o setRawQuery(String)
Set Raw Query for the given EbfQuery object.

Constructors

 o EbfQuery
 public EbfQuery(String query_id) throws FileNotFoundException, IOException
Constructor for class EbfQuery. This constructor takes a query_id as a parameter and loads the query file ( query_id.ebq ) from the 'CurrentAppInstanceRoot/queries/' directory.

Parameters:
query_id - Query ID of the query file to be loaded.
Throws: FileNotFoundException
Thrown if query file for given query_id was not found in the queries directory.
Throws: IOException
Throws if a query file is not accessible or any other IO error
 o EbfQuery
 public EbfQuery(String instance_root,
                 String query_id) throws FileNotFoundException, IOException
Note: Use this constructor ONLY if you need to access query file from a different instance.

Constructor for class EbfQuery. This constructor takes a query_id as a parameter and loads the query file ( query_id.ebq ) from the 'SuppliedInstanceRoot/queries/' directory.

Parameters:
instance_root - Path for instance's root directory from where a query file should be accessed.
query_id - Query ID of the query file to be loaded.
Throws: FileNotFoundException
Thrown if query file for given query_id was not found in the queries directory and create_new_if_not_found flag is set to false.
Throws: IOException
Throws if a query file is not accessible or any other IO error
 o EbfQuery
 public EbfQuery(String query_id,
                 boolean create_new_if_not_found) throws FileNotFoundException, IOException
Constructor for class EbfQuery. This constructor takes two parameters and allows you to create an empty query file in the 'CurrentAppInstanceRoot/queries' directory if query file didn't already exist for the given query_id.

Parameters:
query_id - Query ID of the query file to be loaded.
create_new_if_not_found - Boolean value indicating whether you wish to create a new query file if it didn't exist.
Throws: FileNotFoundException
Thrown if query file for given query_id was not found in the queries directory and create_new_if_not_found flag is set to false.
Throws: IOException
Throws if a query file is not accessible or any other IO error
 o EbfQuery
 public EbfQuery(String instance_root,
                 String query_id,
                 boolean create_new_if_not_found) throws FileNotFoundException, IOException
Note: Use this constructor ONLY if you need to access query file from a different instance.

Constructor for class EbfQuery. This constructor takes three parameters and allows you to create an empty query file in the 'SuppliedInstanceRoot/queries' directory if query file didn't already exist for the given query_id.

Parameters:
instance_root - Path for instance's root directory from where a query file should be accessed.
query_id - Query ID of the query file to be loaded.
create_new_if_not_found - Boolean value indicating whether you wish to create a new query file if it didn't exist.
Throws: FileNotFoundException
Thrown if query file for given query_id was not found in the queries directory and create_new_if_not_found flag is set to false.
Throws: IOException
Throws if a query file is not accessible or any other IO error

Methods

 o getQueryFilePath
 public String getQueryFilePath()
Returns path for the query files where queries are stored.

Returns:
File path for the query files.
 o setComments
 public void setComments(String comments)
Assign a value to 'COMMENTS::' in the query file.

Parameters:
comments - A string containing comments for the query file.
 o getComments
 public String getComments()
Returns value assigned to 'COMMENTS::' in the query file.

Returns:
A string contains comments about the query.
 o setQueryName
 public void setQueryName(String query_name)
Assign a value to 'QUERY_NAME::' in the query file.

Parameters:
query_name - A string containing value for QUERY_NAME:: in the query file.
 o getQueryName
 public String getQueryName()
Returns value assigned to 'QUERY_NAME::' in the query file.

Returns:
A string containing value QUERY_NAME:: in the query file.
 o getRawQuery
 public String getRawQuery()
Returns raw query string (unparsed, unformatted). This string is exactly same as what was assigned to 'QUERY::' in the query file.

Returns:
A string containg unparsed, unformatted query string from the query file.
 o setRawQuery
 public void setRawQuery(String query_string)
Set Raw Query for the given EbfQuery object. This value of this string is assigned to 'QUERY::' in the query file.

Note: If you are using query variables, each query variable must be enclosed within << and >> delimiters.
For example: SELECT employee_id, name, title FROM employee WHERE id = '<>'

You are also allowed to use some of the global tokens available in the EbfServer. These tokens should be prefixed with a '$$' sign. i.e. $$token_name -- For further details, see EbfGlobal javadoc.

Parameters:
query_string - A raw query string. Raw query string may or may not contain any query variables. Raw query string may be just a simple SQL query or it can be a very complex SQL query that contains one or more query variables.
See Also:
EbfGlobal
 o getQueryString
 public String getQueryString()
Returns formatted query string. This method takes no arguments and formats the raw query string by replacing query variables (if any) with empty strings.

Returns:
A string containg formatted query string from the query file.
 o getQueryString
 public String getQueryString(EbfQueryParameters QueryParameters)
Returns formatted query string. This method takes an EbfQueryParameters object as an argument and formats the raw query string by replacing query variables(if any) with values from the supplied QueryParameters object.

If for any of the query variables, there was no reference found in the QueryParameters object, that particular query variable is replaced with an empty string( "" ).

Parameters:
QueryParameters - An EbfQueryParameters object containg
Returns:
A string containg formatted query string from the query file.
 o save
 public void save() throws IOException
Saves query file to the queries directory. If you created a new queries file and didn't set query name, and raw query string, it will assign query_id to the QUERY_NAME:: and an empty string to the QUERY::

Throws: IOExcpetion
Thrown in case of any IO errors.
 o main
 public static void main(String args[])
Main method is included in here for DIGNOSTICS PURPOSE ONLY.

Usage: java EbfQuery new_file_flag file_name p1 p2
If new_file_flag is 'true', p1 value should be QUERY_NAME value, and p2 value should be QUERY value
If new_file_flag is 'false', p1 value should be parameter and p2 should be the parameter_value to be used in replacing query variables (if any)


All Packages  Class Hierarchy  This Package  Previous  Next  Index