Esempio n. 1
0
 /**
  * Checks for duplicate report group based on title of report group.
  *
  * @return
  */
 public int checkForDuplicate() {
   lastAccessed = System.currentTimeMillis();
   String sqlQuery = null;
   int retStatus = -1;
   ResultSetWrapper rsw = null;
   SqlReader sqlReader = null;
   try {
     sqlReader = new SqlReader(false);
     sqlQuery =
         "select count(*) as count from tblreportgroup where title="
             + StringMaker.makeString(getTitle());
     rsw = sqlReader.getInstanceResultSetWrapper(sqlQuery, 120);
     if (rsw.next() && rsw.getInt("count") > 0) {
       retStatus = -4;
     }
     CyberoamLogger.appLog.error(
         "Exception->checkForDuplicate()->ReportGroupBean->retStatus: " + retStatus);
   } catch (Exception e) {
     CyberoamLogger.appLog.error("Exception->checkForDuplicate()->ReportGroupBean->: " + e);
     return -4;
   } finally {
     try {
       rsw.close();
       sqlReader.close();
     } catch (Exception e) {
     }
   }
   return retStatus;
 }
Esempio n. 2
0
  /**
   * Obtains instance of report group by primary key from database table tblreportgroup.
   *
   * @param primaryKey
   * @return
   */
  public static ReportGroupBean getSQLRecordByPrimaryKey(int primaryKey) {
    lastAccessed = System.currentTimeMillis();
    ReportGroupBean reportGroupBean = null;
    ResultSetWrapper rsw = null;
    SqlReader sqlReader = new SqlReader(false);
    try {
      // String sqlQuery = "select reportgroupid,title,description,inputparams,grouptype,menuorder
      // from tblreportgroup where reportgroupid="+ primaryKey ;
      String sqlQuery =
          "select a.reportgroupid,title,description,inputparams,grouptype,menuorder,categoryid from tblreportgroup a,tblreportgroup_category b where a.reportgroupid="
              + primaryKey
              + " and a.reportgroupid=b.reportgroupid";
      rsw = sqlReader.getInstanceResultSetWrapper(sqlQuery);

      if (rsw.next()) {
        reportGroupBean = getBeanByResultSetWrapper(rsw);
      }
    } catch (SQLException se) {
      CyberoamLogger.repLog.error(
          "SQLException ->getSQLRecordByPrimaryKey() -> ReportGroupBean: " + primaryKey + se, se);
    } catch (Exception e) {
      CyberoamLogger.repLog.error(
          "Exception ->getSQLRecordByPrimaryKey() -> ReportGroupBean: " + primaryKey + e, e);
    } finally {
      try {
        sqlReader.close();
        rsw.close();
      } catch (Exception e) {
      }
    }
    return reportGroupBean;
  }
Esempio n. 3
0
  /**
   * Obtains report group Id of dashboard from database.
   *
   * @return
   */
  public static int getDashboardReportGroupID() {
    lastAccessed = System.currentTimeMillis();
    ResultSetWrapper rsw = null;
    SqlReader sqlReader = new SqlReader(false);
    int reportGroupID = -1;
    try {
      String sqlQuery = "select reportgroupid from tblreportgroup where description = 'Dashboard'";
      rsw = sqlReader.getInstanceResultSetWrapper(sqlQuery);

      if (rsw.next()) {
        reportGroupID = rsw.getInt("reportgroupid");
      }
    } catch (SQLException se) {
      CyberoamLogger.repLog.error(
          "SQLException ->getDashboardGroupID() -> ReportGroupBean: " + se, se);
    } catch (Exception e) {
      CyberoamLogger.repLog.error("Exception ->getDashboardGroupID() -> ReportGroupBean: " + e, e);
    } finally {
      try {
        sqlReader.close();
        rsw.close();
      } catch (Exception e) {
      }
    }
    return reportGroupID;
  }
Esempio n. 4
0
 /**
  * Loads all instances of report group in {@link TreeMap}.
  *
  * @return
  */
 public static synchronized boolean loadAll() {
   lastAccessed = System.currentTimeMillis();
   if (reportGroupBeanMap != null) {
     return true;
   }
   boolean retStatus = false;
   ResultSetWrapper rsw = null;
   SqlReader sqlReader = new SqlReader(false);
   ReportGroupBean reportGroupBean = null;
   String strQuery = null;
   try {
     reportGroupBeanMap = new TreeMap();
     // strQuery="select reportgroupid,title,description,inputparams,grouptype,menuorder from
     // tblreportgroup order by reportgroupid";
     strQuery =
         "select tblreportgroup.*,categoryid from tblreportgroup left join tblreportgroup_category on (tblreportgroup.reportgroupid = tblreportgroup_category.reportgroupid)";
     rsw = sqlReader.getInstanceResultSetWrapper(strQuery);
     while (rsw.next()) {
       reportGroupBean = ReportGroupBean.getBeanByResultSetWrapper(rsw);
       if (reportGroupBean != null) {
         reportGroupBeanMap.put(new Integer(reportGroupBean.getReportGroupId()), reportGroupBean);
       }
     }
     retStatus = true;
   } catch (SQLException e) {
     CyberoamLogger.repLog.error("Sqlexception->loadAll()->ReportGroupBean : " + e, e);
     retStatus = false;
   } catch (Exception e) {
     CyberoamLogger.repLog.error("Exception->loadAll()->ReportGroupBean : " + e, e);
     retStatus = false;
   } finally {
     try {
       rsw.close();
       sqlReader.close();
     } catch (Exception e) {
     }
   }
   return retStatus;
 }
Esempio n. 5
0
 /**
  * Obtains instance of report group by {@link ResultSetWrapper}.
  *
  * @param rsw
  * @return
  */
 public static ReportGroupBean getBeanByResultSetWrapper(ResultSetWrapper rsw) {
   ReportGroupBean reportGroupBean = new ReportGroupBean();
   try {
     reportGroupBean.setReportGroupId(rsw.getInt("reportgroupid"));
     reportGroupBean.setTitle(rsw.getString("title"));
     reportGroupBean.setDescription(rsw.getString("description"));
     reportGroupBean.setInputParams(rsw.getString("inputparams"));
     reportGroupBean.setGroupType(rsw.getInt("grouptype"));
     reportGroupBean.setMenuOrder(rsw.getDouble("menuorder"));
     reportGroupBean.setCategoryId(rsw.getInt("categoryid"));
   } catch (Exception e) {
     CyberoamLogger.repLog.error(
         "Exception->getBeanByResultSetWrapper()->ReportGroupBean: " + e, e);
   }
   return reportGroupBean;
 }