jet.bean
Class JRCatalog

java.lang.Object
  extended by jet.bean.JRCatalog

public class JRCatalog
extends java.lang.Object

This catalog bean provides methods to manipulate and access the catalog object.


Field Summary
static int TYPE_TABLE
          Indicates that the type of table is a table (not a view).
static int TYPE_VIEW
          Indicates that the type of table is a view (not a table).
static int vDebug
          Indicates to open the debug log.
static int vError
          Indicates to open the error log.
static int vOff
          Indicates to close the debug and error log.
 
Constructor Summary
JRCatalog()
          The default construct.
 
Method Summary
 void addConnection(ConnectionDesc connection)
          Adds the specified connection to the catalog.
 void addFileQuery(java.lang.String strName, java.io.File flPath)
          Adds the file query specified by the name and file to a catalog.
 java.util.Vector addTableViews(java.lang.String strCatalogName, java.lang.String schemaPattern, java.lang.String tablePattern, int iType)
          Adds the file query specified by the name and file to a catalog.
 void addWherePortion(java.lang.String strName, java.lang.String strQueryName, java.lang.String strSQL)
          Adds the specified where portion to catalog.
 void addWherePortion(java.lang.String strName, java.lang.String strQueryName, java.util.Vector vecGroups)
          Adds the specified where portion to catalog and save catalog.
 void closeCatalog()
          Closes the catalog and release all resources.
 void deleteConnection()
          Deletes the connection from the catalog.
 void deleteFileQuery(java.lang.String strName)
          Deletes the specified file query in the catalog.
 void deleteWherePortion(java.lang.String strName)
          Removes the where portion by the specified name.
 java.lang.String getCatName()
          Gets the name of the catalog.
 ConnectionDesc getConnectionDesc()
          Gets the connection description.
 java.lang.String getFileQuerySQL(java.lang.String strName)
          Gets the file query SQL string.
 java.lang.String getReportHome()
          Gets the report home path where the report.ini and other JReport system files exist.
 java.lang.String getWherePortionsSQL(java.lang.String strName)
          Gets the where portion by the specified name.
 void loadCatalog()
          Loads the catalog by the specified catalog name.
 void modifyConnection(ConnectionDesc connection)
          Modifies the connection according to the specified connection description.
 void modifyConnection(ConnectionDesc connection, boolean reconnect)
          Modifies the connection according to the specified connection description.
 void modifyUserInfo(java.lang.String strUserName, java.lang.String strPassword)
          Modifies the User and Password information according to the specified connection description.
 void modifyWherePortion(java.lang.String strName, java.lang.String strQueryName, java.lang.String strSQL)
          Modifies the specified where portion.
 void modifyWherePortion(java.lang.String strName, java.lang.String strQueryName, java.util.Vector vecGroups)
          Modifies the specified where portion.
 void newCatalog()
          Creates a new catalog with the catalog name and save the catalog to file.
 boolean removeSFDataSource(java.lang.String strName)
          Removes a user data source for IBM Sanfrancisco.
 void saveCatalog()
          Saves the catalog to a file.
 void saveCatalogAs(java.lang.String strCatName)
          Saves the catalog to specified file.
 void setCatName(java.lang.String catName)
          Sets the name of the catalog.
 void setCurrentDataSource(java.lang.String dataSourceName)
          Sets the current DataSource.
 boolean setLogFile(java.lang.String fileName)
          Sets the log file.
 void setReportHome(java.lang.String reportHome)
          Sets the report home path where the report.ini and other JReport system files exist.
 void setShowInfoLevel(int level)
          Enables/disables output error and debug message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vOff

public static final int vOff
Indicates to close the debug and error log.

See Also:
Constant Field Values

vDebug

public static final int vDebug
Indicates to open the debug log.

See Also:
Constant Field Values

vError

public static final int vError
Indicates to open the error log.

See Also:
Constant Field Values

TYPE_TABLE

public static final int TYPE_TABLE
Indicates that the type of table is a table (not a view).

See Also:
Constant Field Values

TYPE_VIEW

public static final int TYPE_VIEW
Indicates that the type of table is a view (not a table).

See Also:
Constant Field Values
Constructor Detail

JRCatalog

public JRCatalog()
The default construct.

Method Detail

getReportHome

public java.lang.String getReportHome()
Gets the report home path where the report.ini and other JReport system files exist.

Returns:
the report home path where the report.ini and other JReport system files exist.

setReportHome

public void setReportHome(java.lang.String reportHome)
Sets the report home path where the report.ini and other JReport system files exist.

Parameters:
reportHome - the home path where the report.ini and other JReport system files exist.

setCatName

public void setCatName(java.lang.String catName)
Sets the name of the catalog.

Parameters:
catName - the name of the catalog.

getCatName

public java.lang.String getCatName()
Gets the name of the catalog.

Returns:
the name of the catalog.

newCatalog

public void newCatalog()
                throws JRCatalogException
Creates a new catalog with the catalog name and save the catalog to file.

Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.SYSTEM_INITIALIZE_ERROR, JRCatalogException.CAT_NAME_ERROR, JRCatalogException.CREATE_CAT_ERROR, JRCatalogException.SAVE_CAT_ERROR

loadCatalog

public void loadCatalog()
                 throws JRCatalogException
Loads the catalog by the specified catalog name.

Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.SYSTEM_INITIALIZE_ERROR, JRCatalogException.CAT_NAME_ERROR, JRCatalogException.LOAD_CAT_ERROR

saveCatalog

public void saveCatalog()
                 throws JRCatalogException
Saves the catalog to a file. When the catalog is saved successfully, all changes on the catalog have been saved.

Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.SAVE_CAT_ERROR

saveCatalogAs

public void saveCatalogAs(java.lang.String strCatName)
                   throws JRCatalogException
Saves the catalog to specified file.

Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.SAVE_CAT_ERROR

closeCatalog

public void closeCatalog()
Closes the catalog and release all resources. When the catalog is closed, the operation on catalog will be rejected.


addWherePortion

public void addWherePortion(java.lang.String strName,
                            java.lang.String strQueryName,
                            java.lang.String strSQL)
                     throws JRCatalogException
Adds the specified where portion to catalog.

Parameters:
strName, - the name of where portion.
strQueryName, - the query name of where portion.
strSQL, - the where portion string
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHEREPORTION_NAME_ERROR

addWherePortion

public void addWherePortion(java.lang.String strName,
                            java.lang.String strQueryName,
                            java.util.Vector vecGroups)
                     throws JRCatalogException
Adds the specified where portion to catalog and save catalog.

Parameters:
strName, - the name of where portion.
strQueryName, - the query name of where portion.
vecGroups, - the where portion structure.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHEREPORTION_NAME_ERROR

modifyWherePortion

public void modifyWherePortion(java.lang.String strName,
                               java.lang.String strQueryName,
                               java.lang.String strSQL)
                        throws JRCatalogException
Modifies the specified where portion.

Parameters:
strName, - the name of where portion.
strQueryName, - the query name of where portion.
strSQL, - the where portion string
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHERE_PORTION_NOT_EXISTS

modifyWherePortion

public void modifyWherePortion(java.lang.String strName,
                               java.lang.String strQueryName,
                               java.util.Vector vecGroups)
                        throws JRCatalogException
Modifies the specified where portion.

Parameters:
strName, - the name of where portion.
strQueryName, - the query name of where portion.
vecGroups, - the where portion structure.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHERE_PORTION_NOT_EXISTS

deleteWherePortion

public void deleteWherePortion(java.lang.String strName)
                        throws JRCatalogException
Removes the where portion by the specified name.

Parameters:
strName, - the name of where portion.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHERE_PORTION_NOT_EXISTS

getWherePortionsSQL

public java.lang.String getWherePortionsSQL(java.lang.String strName)
                                     throws JRCatalogException
Gets the where portion by the specified name.

Parameters:
nameOfWherePortion, - the name of where portion.
Returns:
the string of where portion if successfully, else null.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.WHERE_PORTION_NOT_EXISTS

addFileQuery

public void addFileQuery(java.lang.String strName,
                         java.io.File flPath)
                  throws JRCatalogException
Adds the file query specified by the name and file to a catalog.

Parameters:
strName, - the name of file query.
flPath, - the sql file.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CREATE_FILEQUERY_FAILED

addTableViews

public java.util.Vector addTableViews(java.lang.String strCatalogName,
                                      java.lang.String schemaPattern,
                                      java.lang.String tablePattern,
                                      int iType)
                               throws JRCatalogException
Adds the file query specified by the name and file to a catalog. In pattern string, wildcard character "%" and "_" are supported.

Parameters:
strCatalogName, - the name of catalog.
schemaPattern, - the pattern of schema.
tablePattern, - the pattern of table.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.INVALID_TABLETYPE, JRCatalogException.UNKNOWN_ERROR, JRCatalogException.CONNECTION_FAILURE_ERROR, JRCatalogException.CLOSE_CONNECTION_ERROR

deleteFileQuery

public void deleteFileQuery(java.lang.String strName)
                     throws JRCatalogException
Deletes the specified file query in the catalog.

Parameters:
strName, - the name of file query.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CREATE_FILEQUERY_FAILED

getFileQuerySQL

public java.lang.String getFileQuerySQL(java.lang.String strName)
                                 throws JRCatalogException
Gets the file query SQL string.

Parameters:
strName, - the name of file query.
Returns:
the SQL string.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.FILEQUERY_NAME_ERROR, JRCatalogException.CREATE_FILEQUERY_FAILED, JRCatalogException.FILEQUERY_NOT_EXISTS

removeSFDataSource

public boolean removeSFDataSource(java.lang.String strName)
                           throws JRCatalogException
Removes a user data source for IBM Sanfrancisco.

Parameters:
strName, - the name of UDS;
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR

addConnection

public void addConnection(ConnectionDesc connection)
                   throws JRCatalogException
Adds the specified connection to the catalog. The program will try to make a connection to the database and fetch connection information.

Parameters:
connection, - the connection description.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.ONE_CONNECTION, JRCatalogException.CONNECTION_FAILURE_ERROR, JRCatalogException.FILEQUERY_NOT_EXISTS

modifyConnection

public void modifyConnection(ConnectionDesc connection)
                      throws JRCatalogException
Modifies the connection according to the specified connection description. Note: A connection contains the tables, views, stored procedures and file queries. The queries, formulas and summaries also depend on the connection. Please be careful when you call this method. The program will try to make a connection to the database and fetch connection information.

Parameters:
connection, - the connection description.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CONNECTION_FAILURE_ERROR

modifyConnection

public void modifyConnection(ConnectionDesc connection,
                             boolean reconnect)
                      throws JRCatalogException
Modifies the connection according to the specified connection description. Note: A connection contains the tables, views, stored procedures and file queries. The queries, formulas and summaries also depend on the connection. Please be careful when you call this method.

Parameters:
connection, - the connection description.
reconnect, - try to make a connection to the database and fetch connection information if it is true.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CONNECTION_FAILURE_ERROR

modifyUserInfo

public void modifyUserInfo(java.lang.String strUserName,
                           java.lang.String strPassword)
                    throws JRCatalogException
Modifies the User and Password information according to the specified connection description. Note: A connection contains the tables, views, stored procedures and file queries. The queries, formulas and summaries also depend on the connection. Please be careful when you call this method.

Parameters:
connection, - the connection description.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CONNECTION_FAILURE_ERROR

deleteConnection

public void deleteConnection()
                      throws JRCatalogException
Deletes the connection from the catalog. Note: A connection contains the tables, views, stored procedures and file queries. The queries, formulas and summaries also depend on the connection. Please be careful when you call this method.

Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR, JRCatalogException.NO_CONNECTION_ERROR, JRCatalogException.CONNECTION_FAILURE_ERROR

getConnectionDesc

public ConnectionDesc getConnectionDesc()
                                 throws JRCatalogException
Gets the connection description.

Returns:
the ConnectionDesc object if there is a connection, otherwise, null.
Throws:
JRCatalogException - if an error occurs
See Also:
JRCatalogException.NO_CAT_ERROR

setShowInfoLevel

public void setShowInfoLevel(int level)
Enables/disables output error and debug message.

Parameters:
level - the debug level, for example: vDebug | vError
See Also:
vOff, vDebug, vError

setLogFile

public boolean setLogFile(java.lang.String fileName)
Sets the log file.

Parameters:
fileName - the log file name

LogFileName specifies where the debug, error and other information will go. LogFileName contains both the path and the file name. If no path is specified, the current path is used. If no file name is specified, the file jreport.log is used

Returns:
true if successful

setCurrentDataSource

public void setCurrentDataSource(java.lang.String dataSourceName)
Sets the current DataSource.

Parameters:
dataSourceName - the DataSource name user can use this method to switch among the data sources. The default data source is named as "".