com.silverpeas.mydb.control
Class MyDBSessionController

java.lang.Object
  extended by com.stratelia.silverpeas.peasCore.AbstractComponentSessionController
      extended by com.silverpeas.mydb.control.MyDBSessionController
All Implemented Interfaces:
com.stratelia.silverpeas.peasCore.ComponentSessionController

public class MyDBSessionController
extends com.stratelia.silverpeas.peasCore.AbstractComponentSessionController

MyDB session control.

Author:
Antoine HEDIN

Field Summary
 
Fields inherited from class com.stratelia.silverpeas.peasCore.AbstractComponentSessionController
CHARACTER_ENCODING, context
 
Constructor Summary
MyDBSessionController(com.stratelia.silverpeas.peasCore.MainSessionController mainSessionCtrl, com.stratelia.silverpeas.peasCore.ComponentContext componentContext)
          Standard Session Controller Constructor
 
Method Summary
 boolean checkConnection()
           
 boolean checkTableName()
           
 String createDbLine()
           
 boolean createTable()
          Executes the different queries to create the table corresponding to the current informations of the controller.
 String deleteDbData()
           
 boolean dropTable()
          Removes from the database the table corresponding to the current informations of the controller.
 DateFormatter getDateFormatter()
           
 DbFilter getDbFilter()
           
 DbTable getDbTable()
           
 DriverManager getDriverManager()
           
 com.silverpeas.form.Form getForm(boolean consultation, boolean newRecord, String beanName)
           
 String getFormParameter(String key)
           
 IndexList getIndexInfo(String tableName)
           
 com.stratelia.silverpeas.selectionPeas.jdbc.JdbcConnectorSetting getJdbcConnectorSetting()
           
 String getJdbcDriverName()
           
 String getJdbcUrl()
           
 String getLineCreationErrorMessage()
           
 String getLineDeletionErrorMessage()
           
 int getLineIndex()
           
 String getLogin()
           
 String getPassword()
           
 com.silverpeas.form.DataRecord getRecord(boolean newRecord)
           
 com.stratelia.silverpeas.util.ResourcesWrapper getResources()
           
 int getRowLimit()
           
 TableManager getTableManager()
           
 String getTableName()
           
 String[] getTableNames()
           
 boolean hasTableManager()
           
 void initDbFilter()
          Initializes the database filter.
 void initFormParameters(Map<String,String[]> parameterMap)
          Loads in the form's parameters the values contained into the map.
 void initJdbcConnectorSetting()
          Initializes the JDBC connector setting.
 void initTableManager(int mode, String originPage)
          Initializes the table manager.
 void removeLineIndex()
           
 void resetTableManager()
          Reset the table manager.
 void setLineIndex(int lineIndex)
           
 void setTableName(String tableName)
          Update the table's name and the corresponding connection information.
 void updateConnection(String JDBCdriverName, String JDBCurl, String login, String password, int rowLimit)
          Updates the database connection informations.
 String updateDbData()
           
 void updateDbFilter(String column, String compare, String value)
          Update the database filter.
 void updateTableName(String tableName)
          Update the table's name.
 
Methods inherited from class com.stratelia.silverpeas.peasCore.AbstractComponentSessionController
addClipboardSelection, clipboardPasteDone, close, getAlertUser, getClipboardCount, getClipboardErrorMessage, getClipboardExceptionError, getClipboardName, getClipboardObjects, getClipboardSelectedObjects, getClipboardSize, getComponentAccessController, getComponentId, getComponentLabel, getComponentName, getComponentParameters, getComponentParameterValue, getComponentParameterValue, getComponentRootName, getComponentUrl, getFavoriteSpace, getGenericPanel, getHighestSilverpeasUserRole, getIcon, getLanguage, getLastResults, getLook, getMultilang, getOrganisationController, getPersonalization, getRSSUrl, getSelection, getServerNameAndPort, getSettings, getSilverpeasUserRoles, getSpaceId, getSpaceLabel, getString, getSubscriptionContext, getUrlEncodedParameter, getUserAccessLevel, getUserAvailComponentIds, getUserAvailSpaceIds, getUserDetail, getUserDetail, getUserId, getUserManageableGroupIds, getUserManageableSpaceIds, getUserRoleLevel, getUserRoles, isAppInMaintenance, isGroupManager, isPasswordChangeAllowed, isSpaceInMaintenance, removeClipboardElement, setAppModeMaintenance, setClipboardError, setClipboardSelectedElement, setComponentRootName, setFavoriteSpaceToMainSessionController, setGenericPanel, setIconFileName, setLastResults, setMultilangFileName, setResourceFileName, setSpaceModeMaintenance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyDBSessionController

public MyDBSessionController(com.stratelia.silverpeas.peasCore.MainSessionController mainSessionCtrl,
                             com.stratelia.silverpeas.peasCore.ComponentContext componentContext)
Standard Session Controller Constructor

Parameters:
mainSessionCtrl - The user's profile
componentContext - The component's profile
Method Detail

getDriverManager

public DriverManager getDriverManager()

setLineIndex

public void setLineIndex(int lineIndex)

getLineIndex

public int getLineIndex()

removeLineIndex

public void removeLineIndex()

getDbFilter

public DbFilter getDbFilter()

initDbFilter

public void initDbFilter()
Initializes the database filter.


updateDbFilter

public void updateDbFilter(String column,
                           String compare,
                           String value)
Update the database filter.

Parameters:
column - The name of the column.
compare - The symbol which links the column and the value.
value - The value.

updateTableName

public void updateTableName(String tableName)
                     throws MyDBException
Update the table's name.

Parameters:
tableName - The new name of the table.
Throws:
MyDBException

checkTableName

public boolean checkTableName()
Returns:
True if the actual name of the table corresponds to an existing table in database, else return false and reset the table's name.

setTableName

public void setTableName(String tableName)
                  throws MyDBException
Update the table's name and the corresponding connection information.

Parameters:
tableName - The new table's name.
Throws:
MyDBException

getTableManager

public TableManager getTableManager()

initTableManager

public void initTableManager(int mode,
                             String originPage)
Initializes the table manager.

Parameters:
mode - the table mode (creation or modification).
originPage - The origin page. Indeed, table mode can be accessed from the table selection page or the table detail page. This information is also memorized to go back to the origin page when table mode is left.

hasTableManager

public boolean hasTableManager()
Returns:
True if the table manager is initialized.

resetTableManager

public void resetTableManager()
Reset the table manager.


getResources

public com.stratelia.silverpeas.util.ResourcesWrapper getResources()

getDateFormatter

public DateFormatter getDateFormatter()

updateConnection

public void updateConnection(String JDBCdriverName,
                             String JDBCurl,
                             String login,
                             String password,
                             int rowLimit)
                      throws MyDBException
Updates the database connection informations.

Parameters:
JDBCdriverName - The name of the driver.
JDBCurl - The URL to access the database.
login - The login to access the database.
password - The password to access the database.
rowLimit - The maximum number of elements to display in a response to a database request.
Throws:
MyDBException

initJdbcConnectorSetting

public void initJdbcConnectorSetting()
Initializes the JDBC connector setting.


getJdbcConnectorSetting

public com.stratelia.silverpeas.selectionPeas.jdbc.JdbcConnectorSetting getJdbcConnectorSetting()
Returns:
the JDBC connector setting, after having initialized it if needed.

getJdbcDriverName

public String getJdbcDriverName()

getJdbcUrl

public String getJdbcUrl()

getLogin

public String getLogin()

getPassword

public String getPassword()

getTableName

public String getTableName()

getRowLimit

public int getRowLimit()

checkConnection

public boolean checkConnection()
Returns:
True if the database connection is available.

getTableNames

public String[] getTableNames()
Returns:
The list of tables names available in database.

getDbTable

public DbTable getDbTable()
                   throws MyDBException
Returns:
the database table corresponding to the current informations (connection, table's name,...).
Throws:
MyDBException

getIndexInfo

public IndexList getIndexInfo(String tableName)
                       throws MyDBException
Parameters:
tableName - The table's name.
Returns:
The index informations about the table which allow to determinate foreign keys links between the different columns of the table.
Throws:
MyDBException

getLineCreationErrorMessage

public String getLineCreationErrorMessage()
Returns:
An error message if the content of the new line enters in conflict (respect of primary key) with data already present in database. Returns null if no error is detected.

createDbLine

public String createDbLine()
Returns:
An error message caused by the line creation attempt which could not be anticipated by the method getLineCreationErrorMessage. The line is added to the table if no error occurred.

updateDbData

public String updateDbData()
Returns:
An error message caused by the line update attempt. The line is updated if no error occurred.

getLineDeletionErrorMessage

public String getLineDeletionErrorMessage()
Returns:
An error message if the content of the line is linked to others data by foreign keys and makes the deletion impossible (ex : data present in this line and only in this line into the table but referenced by an other one).

deleteDbData

public String deleteDbData()
Returns:
An error message caused by the line deletion attempt which could not be anticipated by the method getLineDeletionErrorMessage. The line is removed if no error occurred.

getForm

public com.silverpeas.form.Form getForm(boolean consultation,
                                        boolean newRecord,
                                        String beanName)
                                 throws MyDBException
Parameters:
consultation - The flag indicating if data have to be displayed as labels or input fields.
newRecord - The flag which indicates if the form describes a new record or a record to update.
beanName - Le bean's name.
Returns:
The form describing the record to create/modify.
Throws:
MyDBException

getRecord

public com.silverpeas.form.DataRecord getRecord(boolean newRecord)
                                         throws com.silverpeas.form.FormException
Parameters:
newRecord - The flag which indicated if the form describes a new record or a record to update.
Returns:
A data record representing the record to create/modify.
Throws:
com.silverpeas.form.FormException

initFormParameters

public void initFormParameters(Map<String,String[]> parameterMap)
Loads in the form's parameters the values contained into the map.

Parameters:
parameterMap - The map which contains the record's describing data.

getFormParameter

public String getFormParameter(String key)
Parameters:
key - The name of the searched parameter.
Returns:
The value associated to the key, null if the key is not found in the form's parameters.

createTable

public boolean createTable()
Executes the different queries to create the table corresponding to the current informations of the controller.

Returns:
True if the creation ended successfully.

dropTable

public boolean dropTable()
Removes from the database the table corresponding to the current informations of the controller.

Returns:
True if the deletion ended successfully.


Copyright © 2016 Silverpeas. All Rights Reserved.