/** * This method set parameter for sql query * * Version: OEP 2.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 20-September-2015 ThongDV Create new * @param action * @param fromDate * @param toDate */ private void setParam(long companyId,long groupId,QueryPos queryPos,String action, Date fromDate, Date toDate ){ queryPos.add(companyId); queryPos.add(groupId); if(action!=null && !("").equals(action)){ queryPos.add(action); } if(fromDate!=null){ Timestamp fromDateTS= CalendarUtil.getTimestamp(fromDate); queryPos.add(fromDateTS); } if(toDate!=null){ Timestamp toDateTS= CalendarUtil.getTimestamp(toDate); queryPos.add(toDateTS); } }
/** * This is method set parameter for sql query * * Version: OEP 2.0 * * History: * DATE AUTHOR DESCRIPTION * ------------------------------------------------- * 20-September-2015 ThongDV Create new * @param keyWord * @param isUsername * @param isEmail * @param fromDate * @param toDate */ private void setParam(long companyId, long groupId,QueryPos queryPos,String keyWord,boolean isUsername, boolean isEmail, Date fromDate, Date toDate ){ queryPos.add(companyId); queryPos.add(groupId); if(fromDate != null) { Timestamp fromDateTS= CalendarUtil.getTimestamp(fromDate); queryPos.add(fromDateTS); } if(toDate != null) { Timestamp toDateTS= CalendarUtil.getTimestamp(toDate); queryPos.add(toDateTS); } if(!"".equals(keyWord)) { if(isUsername){ queryPos.add("%" + keyWord + "%"); } if(isEmail){ queryPos.add("%" + keyWord + "%"); } } }
private Map<String, Integer> buscaQuantidadePorData(long companyId, TimeZone tz, Date inicio, Date fim, String sql) { DataSource dataSource = InfrastructureUtil.getDataSource(); // Corrige as datas de início e fim Calendar cal = Calendar.getInstance(tz); cal.setTime(inicio); inicio = CalendarUtil.getGTDate(cal); cal.setTime(fim); fim = CalendarUtil.getLTDate(cal); Map<String, Integer> retorno = new LinkedHashMap<String, Integer>(); MappingSqlQuery<Date> mensagens = MappingSqlQueryFactoryUtil.getMappingSqlQuery(dataSource, sql, new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.BIGINT }, new RowMapper<Date>() { @Override public Date mapRow(ResultSet rs, int rowNumber) throws SQLException { return rs.getTimestamp(1); } }); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); sdf.setTimeZone(tz); for (Date data : mensagens.execute(inicio, fim, companyId)) { String dia = sdf.format(data); if (!retorno.containsKey(dia)) retorno.put(dia, 1); else retorno.put(dia, retorno.get(dia) + 1); } return retorno; }
public EDemocraciaGraphByDate(long companyId, TimeZone tz, Date inicio, Date fim) { super(companyId); this.tz = tz; Calendar cal = Calendar.getInstance(tz); cal.setTime(inicio); this.inicio = CalendarUtil.getGTDate(cal); cal.setTime(fim); this.fim = CalendarUtil.getLTDate(cal); }
/** * Returns the number of user syncs where applicationId = ? and checkpoint > ?. * * @param applicationId the application ID * @param checkpoint the checkpoint * @return the number of matching user syncs * @throws SystemException if a system exception occurred */ @Override public int countByA_GtCP(long applicationId, Date checkpoint) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_GTCP; Object[] finderArgs = new Object[] { applicationId, checkpoint }; Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_USERSYNC_WHERE); query.append(_FINDER_COLUMN_A_GTCP_APPLICATIONID_2); boolean bindCheckpoint = false; if (checkpoint == null) { query.append(_FINDER_COLUMN_A_GTCP_CHECKPOINT_1); } else { bindCheckpoint = true; query.append(_FINDER_COLUMN_A_GTCP_CHECKPOINT_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(applicationId); if (bindCheckpoint) { qPos.add(CalendarUtil.getTimestamp(checkpoint)); } count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
/** * Returns the number of applications where modifiedDate ≥ ? and lifeCycleStatus = ?. * * @param modifiedDate the modified date * @param lifeCycleStatus the life cycle status * @return the number of matching applications * @throws SystemException if a system exception occurred */ public int countByml(Date modifiedDate, int lifeCycleStatus) throws SystemException { Object[] finderArgs = new Object[] { modifiedDate, lifeCycleStatus }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ML, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_APPLICATION_WHERE); if (modifiedDate == null) { query.append(_FINDER_COLUMN_ML_MODIFIEDDATE_1); } else { query.append(_FINDER_COLUMN_ML_MODIFIEDDATE_2); } query.append(_FINDER_COLUMN_ML_LIFECYCLESTATUS_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (modifiedDate != null) { qPos.add(CalendarUtil.getTimestamp(modifiedDate)); } qPos.add(lifeCycleStatus); count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ML, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of applications where modifiedDate ≥ ?. * * @param modifiedDate the modified date * @return the number of matching applications * @throws SystemException if a system exception occurred */ public int countBym(Date modifiedDate) throws SystemException { Object[] finderArgs = new Object[] { modifiedDate }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_M, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_APPLICATION_WHERE); if (modifiedDate == null) { query.append(_FINDER_COLUMN_M_MODIFIEDDATE_1); } else { query.append(_FINDER_COLUMN_M_MODIFIEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (modifiedDate != null) { qPos.add(CalendarUtil.getTimestamp(modifiedDate)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_M, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of applications where modifiedDate < ?. * * @param modifiedDate the modified date * @return the number of matching applications * @throws SystemException if a system exception occurred */ public int countBym2(Date modifiedDate) throws SystemException { Object[] finderArgs = new Object[] { modifiedDate }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_M2, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_APPLICATION_WHERE); if (modifiedDate == null) { query.append(_FINDER_COLUMN_M2_MODIFIEDDATE_1); } else { query.append(_FINDER_COLUMN_M2_MODIFIEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (modifiedDate != null) { qPos.add(CalendarUtil.getTimestamp(modifiedDate)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_M2, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of learning activity results where actId = ? and passed = ? and endDate = ?. * * @param actId the act ID * @param passed the passed * @param endDate the end date * @return the number of matching learning activity results * @throws SystemException if a system exception occurred */ public int countByapd(long actId, boolean passed, Date endDate) throws SystemException { Object[] finderArgs = new Object[] { actId, passed, endDate }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_APD, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_LEARNINGACTIVITYRESULT_WHERE); query.append(_FINDER_COLUMN_APD_ACTID_2); query.append(_FINDER_COLUMN_APD_PASSED_2); if (endDate == null) { query.append(_FINDER_COLUMN_APD_ENDDATE_1); } else { query.append(_FINDER_COLUMN_APD_ENDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(actId); qPos.add(passed); if (endDate != null) { qPos.add(CalendarUtil.getTimestamp(endDate)); } count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_APD, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passedDate IS NOT ? and userId = ?. * * @param courseId the course ID * @param passedDate the passed date * @param userId the user ID * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdMultipleUserIdFinished(long courseId, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { courseId, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDMULTIPLEUSERIDFINISHED_COURSEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_COURSEIDMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passedDate IS NOT ?. * * @param courseId the course ID * @param passedDate the passed date * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdFinished(long courseId, Date passedDate) throws SystemException { Object[] finderArgs = new Object[] { courseId, passedDate }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDFINISHED_COURSEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDFINISHED_PASSEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passed = ? and passedDate IS NOT ? and userId = ?. * * @param courseId the course ID * @param passed the passed * @param passedDate the passed date * @param userId the user ID * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdPassedMultipleUserIdFinished(long courseId, boolean passed, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { courseId, passed, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDPASSEDMULTIPLEUSERIDFINISHED_COURSEID_2); query.append(_FINDER_COLUMN_COURSEIDPASSEDMULTIPLEUSERIDFINISHED_PASSED_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDPASSEDMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDPASSEDMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_COURSEIDPASSEDMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); qPos.add(passed); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passed = ? and passedDate IS NOT ?. * * @param courseId the course ID * @param passed the passed * @param passedDate the passed date * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdPassedFinished(long courseId, boolean passed, Date passedDate) throws SystemException { Object[] finderArgs = new Object[] { courseId, passed, passedDate }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDPASSEDFINISHED_COURSEID_2); query.append(_FINDER_COLUMN_COURSEIDPASSEDFINISHED_PASSED_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDPASSEDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDPASSEDFINISHED_PASSEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); qPos.add(passed); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passedDate IS NOT ? and userId ≠ ?. * * @param courseId the course ID * @param passedDate the passed date * @param userId the user ID * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdNotMultipleUserIdFinished(long courseId, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { courseId, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDNOTMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDNOTMULTIPLEUSERIDFINISHED_COURSEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_COURSEIDNOTMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDNOTMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of course results where courseId = ? and passed = ? and passedDate IS NOT ? and userId ≠ ?. * * @param courseId the course ID * @param passed the passed * @param passedDate the passed date * @param userId the user ID * @return the number of matching course results * @throws SystemException if a system exception occurred */ public int countByCourseIdPassedNotMultipleUserIdFinished(long courseId, boolean passed, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { courseId, passed, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_COURSERESULT_WHERE); query.append(_FINDER_COLUMN_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED_COURSEID_2); query.append(_FINDER_COLUMN_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSED_2); if (passedDate == null) { query.append(_FINDER_COLUMN_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(courseId); qPos.add(passed); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_COURSEIDPASSEDNOTMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of module results where moduleId = ? and passedDate IS NOT ? and userId = ?. * * @param moduleId the module ID * @param passedDate the passed date * @param userId the user ID * @return the number of matching module results * @throws SystemException if a system exception occurred */ public int countByModuleIdMultipleUserIdFinished(long moduleId, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { moduleId, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MODULERESULT_WHERE); query.append(_FINDER_COLUMN_MODULEIDMULTIPLEUSERIDFINISHED_MODULEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_MODULEIDMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_MODULEIDMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_MODULEIDMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(moduleId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of module results where moduleId = ? and passedDate IS NOT ?. * * @param moduleId the module ID * @param passedDate the passed date * @return the number of matching module results * @throws SystemException if a system exception occurred */ public int countByModuleIdFinished(long moduleId, Date passedDate) throws SystemException { Object[] finderArgs = new Object[] { moduleId, passedDate }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_MODULERESULT_WHERE); query.append(_FINDER_COLUMN_MODULEIDFINISHED_MODULEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_MODULEIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_MODULEIDFINISHED_PASSEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(moduleId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of module results where moduleId = ? and passed = ? and passedDate IS NOT ?. * * @param moduleId the module ID * @param passed the passed * @param passedDate the passed date * @return the number of matching module results * @throws SystemException if a system exception occurred */ public int countByModuleIdPassedFinished(long moduleId, boolean passed, Date passedDate) throws SystemException { Object[] finderArgs = new Object[] { moduleId, passed, passedDate }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDPASSEDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MODULERESULT_WHERE); query.append(_FINDER_COLUMN_MODULEIDPASSEDFINISHED_MODULEID_2); query.append(_FINDER_COLUMN_MODULEIDPASSEDFINISHED_PASSED_2); if (passedDate == null) { query.append(_FINDER_COLUMN_MODULEIDPASSEDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_MODULEIDPASSEDFINISHED_PASSEDDATE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(moduleId); qPos.add(passed); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDPASSEDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of module results where moduleId = ? and passedDate IS NOT ? and userId ≠ ?. * * @param moduleId the module ID * @param passedDate the passed date * @param userId the user ID * @return the number of matching module results * @throws SystemException if a system exception occurred */ public int countByModuleIdNotMultipleUserIdFinished(long moduleId, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { moduleId, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDNOTMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_MODULERESULT_WHERE); query.append(_FINDER_COLUMN_MODULEIDNOTMULTIPLEUSERIDFINISHED_MODULEID_2); if (passedDate == null) { query.append(_FINDER_COLUMN_MODULEIDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_MODULEIDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_MODULEIDNOTMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(moduleId); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDNOTMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of module results where moduleId = ? and passed = ? and passedDate IS NOT ? and userId ≠ ?. * * @param moduleId the module ID * @param passed the passed * @param passedDate the passed date * @param userId the user ID * @return the number of matching module results * @throws SystemException if a system exception occurred */ public int countByModuleIdPassedNotMultipleUserIdFinished(long moduleId, boolean passed, Date passedDate, long userId) throws SystemException { Object[] finderArgs = new Object[] { moduleId, passed, passedDate, userId }; Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_MODULERESULT_WHERE); query.append(_FINDER_COLUMN_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED_MODULEID_2); query.append(_FINDER_COLUMN_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSED_2); if (passedDate == null) { query.append(_FINDER_COLUMN_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_1); } else { query.append(_FINDER_COLUMN_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED_PASSEDDATE_2); } query.append(_FINDER_COLUMN_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED_USERID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(moduleId); qPos.add(passed); if (passedDate != null) { qPos.add(CalendarUtil.getTimestamp(passedDate)); } qPos.add(userId); count = (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_MODULEIDPASSEDNOTMULTIPLEUSERIDFINISHED, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of chat room messages where messagePublic = ? and messageTS = ?. * * @param messagePublic the message public * @param messageTS the message t s * @return the number of matching chat room messages * @throws SystemException if a system exception occurred */ public int countByPublic(boolean messagePublic, Date messageTS) throws SystemException { Object[] finderArgs = new Object[] { messagePublic, messageTS }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PUBLIC, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_CHATROOMMESSAGE_WHERE); query.append(_FINDER_COLUMN_PUBLIC_MESSAGEPUBLIC_2); if (messageTS == null) { query.append(_FINDER_COLUMN_PUBLIC_MESSAGETS_1); } else { query.append(_FINDER_COLUMN_PUBLIC_MESSAGETS_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(messagePublic); if (messageTS != null) { qPos.add(CalendarUtil.getTimestamp(messageTS)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PUBLIC, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of chat room messages where messagePublic = ? and recipientUserId = ? and messageTS = ?. * * @param messagePublic the message public * @param recipientUserId the recipient user ID * @param messageTS the message t s * @return the number of matching chat room messages * @throws SystemException if a system exception occurred */ public int countByPrivateUser(boolean messagePublic, long recipientUserId, Date messageTS) throws SystemException { Object[] finderArgs = new Object[] { messagePublic, recipientUserId, messageTS }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PRIVATEUSER, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_CHATROOMMESSAGE_WHERE); query.append(_FINDER_COLUMN_PRIVATEUSER_MESSAGEPUBLIC_2); query.append(_FINDER_COLUMN_PRIVATEUSER_RECIPIENTUSERID_2); if (messageTS == null) { query.append(_FINDER_COLUMN_PRIVATEUSER_MESSAGETS_1); } else { query.append(_FINDER_COLUMN_PRIVATEUSER_MESSAGETS_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(messagePublic); qPos.add(recipientUserId); if (messageTS != null) { qPos.add(CalendarUtil.getTimestamp(messageTS)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PRIVATEUSER, finderArgs, count); closeSession(session); } } return count.intValue(); }
/** * Returns the number of contador acessos where companyId = ? and data = ?. * * @param companyId the company ID * @param data the data * @return the number of matching contador acessos * @throws SystemException if a system exception occurred */ public int countByC_D(long companyId, Date data) throws SystemException { Object[] finderArgs = new Object[] { companyId, data }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_D, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_CONTADORACESSO_WHERE); query.append(_FINDER_COLUMN_C_D_COMPANYID_2); if (data == null) { query.append(_FINDER_COLUMN_C_D_DATA_1); } else { query.append(_FINDER_COLUMN_C_D_DATA_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (data != null) { qPos.add(CalendarUtil.getTimestamp(data)); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_D, finderArgs, count); closeSession(session); } } return count.intValue(); }
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletPreferences pp = renderRequest.getPreferences(); Integer tipoGrafico = Integer.parseInt(pp.getValue("tipoGrafico", "1")); EDemocraciaGraph report; ThemeDisplay td = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); df.setTimeZone(td.getTimeZone()); // Pega a data inicial e final Date end = CalendarUtil.getLTDate(Calendar.getInstance(td.getTimeZone())); Calendar cal = Calendar.getInstance(td.getTimeZone()); cal.setTime(end); cal.add(Calendar.MONTH, -1); Date start = CalendarUtil.getGTDate(cal); String paramStart = ParamUtil.getString(renderRequest, "start"); String paramEnd = ParamUtil.getString(renderRequest, "end"); Date pStart, pEnd; try { pStart = df.parse(paramStart); pEnd = df.parse(paramEnd); } catch (ParseException e) { pStart = start; pEnd = end; } // Verifica se o há mais que um mês entre data inicial e final cal.setTime(pEnd); cal.add(Calendar.MONTH, -1); if(pStart.before(cal.getTime())) { pStart = cal.getTime(); } boolean showTimeRange = true; switch(tipoGrafico) { case 2: showTimeRange = false; report = new UsersByUFGraph(td.getCompanyId()); break; case 3: report = new UsageGraph(td.getCompanyId(), td.getTimeZone(), pStart, pEnd); break; default: // case 1 report = new UsersByDateGraph(td.getCompanyId(), td.getTimeZone(), pStart, pEnd); break; } renderRequest.setAttribute("start", df.format(pStart)); renderRequest.setAttribute("end", df.format(pEnd)); renderRequest.setAttribute("url", report.getURL()); renderRequest.setAttribute("showTimeRange", showTimeRange); super.doView(renderRequest, renderResponse); }