Package org.openqreg.bean

Examples of org.openqreg.bean.SettingBean


* @return A populated SettingBean
*
* @throws SQLException
*/
protected static SettingBean populate(ResultSet rs) throws SQLException {
SettingBean valueObject = new SettingBean();
valueObject.setId((String)rs.getObject(1));
valueObject.setType((String)rs.getObject(2));
valueObject.setSetting((String)rs.getObject(3));
return valueObject;
}
View Full Code Here


* @throws SQLException
*/
public static Collection<SettingBean> findAll(Connection con) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
SettingBean valueObject = null;
Collection<SettingBean> col = Collections.synchronizedList(new ArrayList<SettingBean>());
try{
pStmt = con.prepareStatement(FIND_ALL_STATEMENT);
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
col.add(valueObject);
}
return col;
}finally{
if(null!=rs){
View Full Code Here

* @throws SQLException
*/
public static Object findByPrimaryKey(Connection con, PrimaryKey key) throws SQLException {
PreparedStatement pStmt = null;
ResultSet rs = null;
SettingBean valueObject = null;
SettingKey primaryKey = (SettingKey) key;
try{
pStmt = con.prepareStatement(SettingBeanBase.SELECT_STATEMENT);
pStmt.setObject(1, primaryKey.getId());
rs = pStmt.executeQuery();
while (rs.next()){
valueObject = populate(rs);
valueObject.afterPopulate(con);
}
return valueObject;
}finally{
if(null!=rs){
rs.close();
View Full Code Here

   * Writes the system setting from the database
   */
  public void writeSettingsToDB() {

    try {
      SettingBean setBean = null;

      // sets the loginwaittimeout to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_LOGINWAITTIMEOUT");
      setBean.setSetting(Integer.valueOf(this.getLoginWaitTimeOut())
          .toString());
      setBean.store();

      // sets the maxloginwait to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_MAXLOGINWAIT");
      setBean.setSetting(Integer.valueOf(this.getMaxLoginWait())
          .toString());
      setBean.store();

      // sets the maxinactivetime to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_MAXINACTIVETIME");
      setBean.setSetting(Integer.valueOf(this.getMaxInactiveTime())
          .toString());
      setBean.store();

      // sets the maxinactivetimebeforeremoval to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_MAXINACTIVETIMEBEFOREREMOVAL");
      setBean.setSetting(Integer.valueOf(
          this.getMaxInactiveTimeBeforeRemoval()).toString());
      setBean.store();

      // sets the shutdowntime to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_SHUTDOWNTIME");
      if (this.getShutDownTime() != null) {
        setBean.setSetting(Long.valueOf(
            this.getShutDownTime().getTimeInMillis()).toString());
      } else {
        setBean.setSetting(null);
      }
      setBean.store();

      // sets the SHOWSHUTDOWNMESSAGETIME to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_SHOWSHUTDOWNMESSAGETIME");
      setBean.setSetting(Integer.valueOf(
          this.getShowShutDownMessageTime()).toString());
      setBean.store();

      // sets the DEFAULTLANGUAGE to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_DEFAULTLANGUAGE");
      setBean.setSetting(getDefaultLanguage());
      setBean.store();

      // sets the passWordLifeLength to the one in the database
      setBean = new SettingBean();
      setBean.setId("DISPATCHER_PASSWORDLIFELENGTH");
      setBean.setSetting(Integer.valueOf(this.getPasswordLifeLength())
          .toString());
      setBean.store();

      // sets the patientlogLogPatientlists to the one in the database
      setBean = new SettingBean();
      setBean.setId("PATIENTLOG_LOG_PATIENTLISTS");
      setBean.setSetting(new Boolean(this.isPatientlogLogPatientlists())
          .toString());
      setBean.store();

    } catch (Exception e) {
      logger.log(Level.ERROR,
          "writeSettingsToDB() error writing settings:", e);
    }
View Full Code Here

  public void readSettingsFromDB() {
    if (logger.isDebugEnabled()) {
      logger.log(Level.INFO, "readSettingsFromDB  read");
    }
    try {
      SettingBean setBean = null;
      // sets the loginwaittimeout to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_LOGINWAITTIMEOUT"));
      this.setLoginWaitTimeOut(new Integer(setBean.getSetting())
          .intValue());

      // sets the maxloginwait to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey("DISPATCHER_MAXLOGINWAIT"));
      this.setMaxLoginWait(new Integer(setBean.getSetting()).intValue());

      // sets the maxinactivetime to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_MAXINACTIVETIME"));
      this.setMaxInactiveTime(new Integer(setBean.getSetting())
          .intValue());

      // sets the maxinactivetimebeforeremoval to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_MAXINACTIVETIMEBEFOREREMOVAL"));
      this.setMaxInactiveTimeBeforeRemoval(new Integer(setBean
          .getSetting()).intValue());

      // sets the shutdowntime to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey("DISPATCHER_SHUTDOWNTIME"));
      GregorianCalendar GC = new GregorianCalendar();
      if (setBean.getSetting() != null) {
        GC.setTimeInMillis(new Long(setBean.getSetting()).longValue());
        this.setShutDownTime(GC);
      } else {
        this.setShutDownTime(null);
      }

      // sets the SHOWSHUTDOWNMESSAGETIME to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_SHOWSHUTDOWNMESSAGETIME"));
      this.setShowShutDownMessageTime(new Integer(setBean.getSetting())
          .intValue());

      // sets the DEFAULTLANGUAGE to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_DEFAULTLANGUAGE"));
      this.setDefaultLanguage(setBean.getSetting());

      // sets the PASSWORDLIFELENGTH to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "DISPATCHER_PASSWORDLIFELENGTH"));
      this.setPasswordLifeLength(new Integer(setBean.getSetting())
          .intValue());

      // sets the PATIENTLOG_LOG_PATIENTLISTS to the one in the database
      setBean = (SettingBean) SettingFinderBase
          .findByPrimaryKey(new SettingKey(
              "PATIENTLOG_LOG_PATIENTLISTS"));
      this.setPatientlogLogPatientlists(new Boolean(setBean.getSetting())
          .booleanValue());

    } catch (Exception e) {
      logger.log(Level.ERROR,
          "readSettingsFromDB() error reading settings:", e);
View Full Code Here

TOP

Related Classes of org.openqreg.bean.SettingBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.