Exemple #1
0
  @Override
  public List<ResourcePermission> findByR_S(long roleId, int[] scopes, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_R_S);

      sql = StringUtil.replace(sql, "[$SCOPE$]", getScopes(scopes));

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("ResourcePermission", ResourcePermissionImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(roleId);
      qPos.add(scopes);

      return (List<ResourcePermission>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<MicroblogsEntry> findByU_T_MU(
      long userId, int type, long microblogsEntryUserId, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_U_MU);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MicroblogsEntry", MicroblogsEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(MicroblogsEntryConstants.TYPE_EVERYONE);
      qPos.add(userId);
      qPos.add(type);
      qPos.add(microblogsEntryUserId);

      return (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #3
0
  @Override
  public List<MBThread> filterFindByG_C(long groupId, long categoryId, int start, int end)
      throws SystemException {

    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
      return MBThreadUtil.findByG_C(groupId, categoryId, start, end);
    }

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_C);

      sql =
          InlineSQLHelperUtil.replacePermissionCheck(
              sql, MBMessage.class.getName(), "MBThread.rootMessageId", groupId);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(categoryId);

      return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public int countByS_G_U(long groupId, long userId) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_S_G_U);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBCategory.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      Iterator<Long> itr = q.list().iterator();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<JIRAAction> findByCD_P(Date createDate, long projectId, int start, int end)
      throws SystemException {

    Timestamp createDate_TS = CalendarUtil.getTimestamp(createDate);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_CD_P);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("jiraaction", JIRAActionImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(projectId);
      qPos.add(createDate_TS);

      return (List<JIRAAction>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #6
0
  @Override
  public int countByG_U_C_A(
      long groupId,
      long userId,
      long[] categoryIds,
      boolean anonymous,
      QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G_U_C);

      if (ArrayUtil.isEmpty(categoryIds)) {
        sql = StringUtil.replace(sql, "(MBThread.categoryId = ?) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql,
                "MBThread.categoryId = ?",
                "MBThread.categoryId = "
                    + StringUtil.merge(categoryIds, " OR MBThread.categoryId = "));
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(userId);
      qPos.add(anonymous);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<WallEntry> findByG1_G2_U1_U2(
      long groupId1, long groupId2, long userId1, long userId2, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G1_G2_U1_U2);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("SN_WallEntry", WallEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId1);
      qPos.add(groupId2);
      qPos.add(userId1);
      qPos.add(userId2);

      return (List<WallEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #8
0
  @Override
  public List<MBThread> findByS_G_U(long groupId, long userId, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_S_G_U);

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBThread.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<MBCategory> findByS_G_U(long groupId, long userId, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_S_G_U);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBCategory", MBCategoryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBCategory.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      return (List<MBCategory>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<NotificationEntry> getNotificationEntryByUserId(
      long usreId, String typeNotification, int start, int end) throws SystemException {

    List list = null;
    // / This stuff is basic set up
    Session session = null;

    try {
      session = openSession();
      // Here ends the basic set up;x`
      String sql = "";
      // now we build the query. Note that we use the name of the tables
      // from the database!
      if (typeNotification.equals("NOTIFICATIONUSERIDFROM")) {
        sql = CustomSQLUtil.get(SQL_getNotificationEntryByUserIdFrom);
      } else {
        sql = CustomSQLUtil.get(SQL_getNotificationEntryByUserIdTo);
      }

      SQLQuery query = session.createSQLQuery(sql);
      query.addEntity("NotificationEntry", NotificationEntryImpl.class);
      QueryPos qPos = QueryPos.getInstance(query);
      qPos.add(usreId);
      list = QueryUtil.list(query, getDialect(), start, end);

    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();

    } finally {
      closeSession(session);
    }

    return list;
  }
  public int getNotificationEntryByUserIdCount(long usreId, String typeNotification)
      throws SystemException {

    Session session = null;
    int count = 0;
    try {
      session = openSession();
      String sql = "";
      if (typeNotification.equals("NOTIFICATIONUSERIDFROM")) {
        sql = CustomSQLUtil.get(SQL_getNotificationEntryByUserIdCountFrom);
      } else {
        sql = CustomSQLUtil.get(SQL_getNotificationEntryByUserIdCountTo);
      }
      SQLQuery query = session.createSQLQuery(sql);
      // query.addEntity("vrbt_service", ServiceImpl.class);
      QueryPos qPos = QueryPos.getInstance(query);

      qPos.add(usreId);

      Object obj = query.uniqueResult();
      count = Integer.valueOf(obj.toString());
    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
      throw processException(e);
    } finally {
      closeSession(session);
    }

    return count;
  }
  public List<MicroblogsEntry> findByUserId(long userId, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_USER_ID);

      sql = StringUtil.replace(sql, "[$JOIN_BY_SOCIAL_RELATION$]", _joinBySocialRelationSQL);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MicroblogsEntry", MicroblogsEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(MicroblogsEntryConstants.TYPE_EVERYONE);
      qPos.add(userId);
      qPos.add(userId);
      qPos.add(userId);

      return (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #13
0
  protected int doCountByG_C(
      long groupId, long categoryId, QueryDefinition queryDefinition, boolean inlineSQLHelper)
      throws SystemException {

    if (!inlineSQLHelper || !InlineSQLHelperUtil.isEnabled(groupId)) {
      if (queryDefinition.isExcludeStatus()) {
        return MBThreadUtil.countByG_C_NotS(groupId, categoryId, queryDefinition.getStatus());
      } else {
        if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {

          return MBThreadUtil.countByG_C_S(groupId, categoryId, queryDefinition.getStatus());
        } else {
          return MBThreadUtil.countByG_C(groupId, categoryId);
        }
      }
    }

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G_C);

      sql = updateSQL(sql, queryDefinition);

      sql =
          InlineSQLHelperUtil.replacePermissionCheck(
              sql, MBMessage.class.getName(), "MBThread.rootMessageId", groupId);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(categoryId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #14
0
  @Override
  public List<ResourcePermission> findByResource(
      long companyId, long groupId, String name, String primKey) throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_RESOURCE);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("ResourcePermission", ResourcePermissionImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(companyId);
      qPos.add(name);
      qPos.add(primKey);
      qPos.add(String.valueOf(groupId));

      return (List<ResourcePermission>)
          QueryUtil.list(q, getDialect(), QueryUtil.ALL_POS, QueryUtil.ALL_POS);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public int countByGroupId(long groupId) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_GROUP_ID);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<SocialActivity> findByUserOrganizations(long userId, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_USER_ORGANIZATIONS);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("SocialActivity", SocialActivityImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(userId);

      return (List<SocialActivity>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
 public int countByParents(String listParent) throws SystemException {
   Session session = null;
   try {
     session = openSession();
     StringBuffer query = new StringBuffer();
     query.append("SELECT COUNT(*) as total FROM Vlookupprice WHERE listParent LIKE ?");
     SQLQuery q = session.createSQLQuery(query.toString());
     q.addScalar("total", Type.LONG);
     int queryPos = 0;
     q.setString(queryPos++, "%" + listParent + "%");
     Long count = null;
     Iterator ite = q.list().iterator();
     while (ite.hasNext()) {
       count = (Long) ite.next();
     }
     if (count == null) {
       count = new Long(0);
     }
     return count.intValue();
   } catch (Exception e) {
     throw new SystemException(e);
   } finally {
     closeSession(session);
   }
 }
Exemple #18
0
  @Override
  public List<CalEvent> findByFutureReminders() throws SystemException {
    Calendar calendar = Calendar.getInstance();

    calendar.add(Calendar.HOUR, -24);

    Timestamp calendar_TS = CalendarUtil.getTimestamp(calendar.getTime());

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_FUTURE_REMINDERS);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("CalEvent", CalEventImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(CalEventConstants.REMIND_BY_NONE);
      qPos.add(calendar_TS);
      qPos.add(calendar_TS);

      return q.list(true);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected List<Long> countByC_FN_MN_LN_SN_EA_S(
      Session session,
      long companyId,
      String[] firstNames,
      String[] middleNames,
      String[] lastNames,
      String[] screenNames,
      String[] emailAddresses,
      int status,
      LinkedHashMap<String, Object> params,
      boolean andOperator) {

    String sql = CustomSQLUtil.get(COUNT_BY_C_FN_MN_LN_SN_EA_S);

    sql =
        CustomSQLUtil.replaceKeywords(
            sql, "lower(User_.firstName)", StringPool.LIKE, false, firstNames);
    sql =
        CustomSQLUtil.replaceKeywords(
            sql, "lower(User_.middleName)", StringPool.LIKE, false, middleNames);
    sql =
        CustomSQLUtil.replaceKeywords(
            sql, "lower(User_.lastName)", StringPool.LIKE, false, lastNames);
    sql =
        CustomSQLUtil.replaceKeywords(
            sql, "lower(User_.screenName)", StringPool.LIKE, false, screenNames);
    sql =
        CustomSQLUtil.replaceKeywords(
            sql, "lower(User_.emailAddress)", StringPool.LIKE, true, emailAddresses);

    if (status == WorkflowConstants.STATUS_ANY) {
      sql = StringUtil.replace(sql, _STATUS_SQL, StringPool.BLANK);
    }

    sql = replaceJoinAndWhere(sql, params);
    sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

    SQLQuery q = session.createSQLQuery(sql);

    q.addScalar("userId", Type.LONG);

    QueryPos qPos = QueryPos.getInstance(q);

    setJoin(qPos, params);

    qPos.add(companyId);
    qPos.add(false);
    qPos.add(firstNames, 2);
    qPos.add(middleNames, 2);
    qPos.add(lastNames, 2);
    qPos.add(screenNames, 2);
    qPos.add(emailAddresses, 2);

    if (status != WorkflowConstants.STATUS_ANY) {
      qPos.add(status);
    }

    return q.list(true);
  }
Exemple #20
0
  protected List<MBThread> doFindByS_G_U_C(
      long groupId,
      long userId,
      long[] categoryIds,
      QueryDefinition queryDefinition,
      boolean inlineSQLHelper)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_S_G_U_C);

      if (ArrayUtil.isEmpty(categoryIds)) {
        sql = StringUtil.replace(sql, "(MBThread.categoryId = ?) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql,
                "MBThread.categoryId = ?",
                "MBThread.categoryId = "
                    + StringUtil.merge(categoryIds, " OR MBThread.categoryId = "));
      }

      sql = updateSQL(sql, queryDefinition);

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, MBMessage.class.getName(), "MBThread.rootMessageId", groupId);
      }

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBThread.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #21
0
  @Override
  public int countByG_SD_T(
      long groupId, Date startDateGT, Date startDateLT, boolean timeZoneSensitive, String[] types)
      throws SystemException {

    Timestamp startDateGT_TS = CalendarUtil.getTimestamp(startDateGT);
    Timestamp startDateLT_TS = CalendarUtil.getTimestamp(startDateLT);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G_SD_T);

      sql = StringUtil.replace(sql, "[$TYPE$]", getTypes(types));

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("CalEvent", CalEventImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(startDateGT_TS);
      qPos.add(startDateLT_TS);
      qPos.add(timeZoneSensitive);
      qPos.add(false);

      if ((types != null)
          && (types.length > 0)
          && ((types.length > 1) || Validator.isNotNull(types[0]))) {

        for (String type : types) {
          qPos.add(type);
        }
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #22
0
  @Override
  public int countByG_U_LPD(
      long groupId, long userId, Date lastPostDate, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G_U_LPD);

      if (userId <= 0) {
        sql = StringUtil.replace(sql, _INNER_JOIN_SQL, StringPool.BLANK);
        sql = StringUtil.replace(sql, _USER_ID_SQL, StringPool.BLANK);
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(lastPostDate);

      if (userId > 0) {
        qPos.add(userId);
      }

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #23
0
  @Override
  public List<MBThread> findByG_U_C_A(
      long groupId,
      long userId,
      long[] categoryIds,
      boolean anonymous,
      QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_U_C_A);

      if (ArrayUtil.isEmpty(categoryIds)) {
        sql = StringUtil.replace(sql, "(MBThread.categoryId = ?) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql,
                "MBThread.categoryId = ?",
                "MBThread.categoryId = "
                    + StringUtil.merge(categoryIds, " OR MBThread.categoryId = "));
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(userId);
      qPos.add(anonymous);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Returns an ordered range of all the h r holidaies associated with the h r office.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set.
   *
   * @param pk the primary key of the h r office
   * @param start the lower bound of the range of h r offices
   * @param end the upper bound of the range of h r offices (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of h r holidaies associated with the h r office
   * @throws SystemException if a system exception occurred
   */
  public List<com.liferay.hr.model.HRHoliday> getHRHolidaies(
      long pk, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    Object[] finderArgs =
        new Object[] {
          pk, String.valueOf(start), String.valueOf(end), String.valueOf(orderByComparator)
        };

    List<com.liferay.hr.model.HRHoliday> list =
        (List<com.liferay.hr.model.HRHoliday>)
            FinderCacheUtil.getResult(FINDER_PATH_GET_HRHOLIDAIES, finderArgs, this);

    if (list == null) {
      Session session = null;

      try {
        session = openSession();

        String sql = null;

        if (orderByComparator != null) {
          sql = _SQL_GETHRHOLIDAIES.concat(ORDER_BY_CLAUSE).concat(orderByComparator.getOrderBy());
        } else {
          sql = _SQL_GETHRHOLIDAIES;
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("HRHoliday", com.liferay.hr.model.impl.HRHolidayImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(pk);

        list = (List<com.liferay.hr.model.HRHoliday>) QueryUtil.list(q, getDialect(), start, end);
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (list == null) {
          FinderCacheUtil.removeResult(FINDER_PATH_GET_HRHOLIDAIES, finderArgs);
        } else {
          hrHolidayPersistence.cacheResult(list);

          FinderCacheUtil.putResult(FINDER_PATH_GET_HRHOLIDAIES, finderArgs, list);
        }

        closeSession(session);
      }
    }

    return list;
  }
Exemple #25
0
  @Override
  public List<CalEvent> findByG_SD_T(
      long groupId,
      Date startDateGT,
      Date startDateLT,
      boolean timeZoneSensitive,
      String[] types,
      int start,
      int end)
      throws SystemException {

    Timestamp startDateGT_TS = CalendarUtil.getTimestamp(startDateGT);
    Timestamp startDateLT_TS = CalendarUtil.getTimestamp(startDateLT);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_SD_T);

      sql = StringUtil.replace(sql, "[$TYPE$]", getTypes(types));

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("CalEvent", CalEventImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(startDateGT_TS);
      qPos.add(startDateLT_TS);
      qPos.add(timeZoneSensitive);
      qPos.add(false);

      if ((types != null)
          && (types.length > 0)
          && ((types.length > 1) || Validator.isNotNull(types[0]))) {

        for (String type : types) {
          qPos.add(type);
        }
      }

      return (List<CalEvent>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  public List<PaymentPlugin> findByTransactionAndPaymentMethod(
      long transactionId,
      long paymentMethodId,
      Boolean configured,
      int start,
      int end,
      OrderByComparator obc)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_TRANSACTIONID_AND_PAYMENTMETHODID);

      if (configured == null) {
        sql = StringUtil.replace(sql, "(Payment_PaymentPlugin.configured = ?) AND", "");
        sql = StringUtil.replace(sql, "(Payment_PaymentPluginConfig.configured = ?) AND", "");
      }

      CustomSQLUtil.replaceOrderBy(sql, obc);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("Payment_PaymentPlugin", PaymentPluginImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(transactionId);
      qPos.add(paymentMethodId);
      if (configured != null) {
        qPos.add(configured);
        qPos.add(configured);
      }

      List<PaymentPlugin> results =
          (List<PaymentPlugin>) QueryUtil.list(q, getDialect(), start, end);

      return results;

    } catch (Exception e) {
      throw new SystemException(e);

    } finally {
      closeSession(session);
    }
  }
 public List findByParents(String listParent, int start, int end) throws SystemException {
   Session session = null;
   try {
     session = openSession();
     StringBuffer query = new StringBuffer();
     query.append("SELECT * FROM Vlookupprice WHERE listParent LIKE ?");
     SQLQuery q = session.createSQLQuery(query.toString());
     q.addEntity("Vlookupprice", VlookuppriceImpl.class);
     int queryPos = 0;
     q.setString(queryPos++, "%" + listParent + "%");
     return QueryUtil.list(q, getDialect(), start, end);
   } catch (Exception e) {
     throw new SystemException(e);
   } finally {
     closeSession(session);
   }
 }
  public int countByTransactionAndPaymentMethod(
      long transactionId, long paymentMethodId, Boolean configured) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_TRANSACTIONID_AND_PAYMENTMETHODID);

      if (configured == null) {
        sql = StringUtil.replace(sql, "(Payment_PaymentPlugin.configured = ?) AND", "");
        sql = StringUtil.replace(sql, "(Payment_PaymentPluginConfig.configured = ?) AND", "");
      }

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(transactionId);
      qPos.add(paymentMethodId);
      if (configured != null) {
        qPos.add(configured);
        qPos.add(configured);
      }

      Iterator<Long> itr = q.list().iterator();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;

    } catch (Exception e) {
      throw new SystemException(e);

    } finally {
      closeSession(session);
    }
  }
Exemple #29
0
  @Override
  public int countByG_U_A(
      long groupId, long userId, boolean anonymous, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_G_U_A);

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(userId);
      qPos.add(anonymous);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #30
0
  @Override
  public List<MBThread> findByG_U_LPD(
      long groupId, long userId, Date lastPostDate, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_U_LPD);

      if (userId <= 0) {
        sql = StringUtil.replace(sql, _INNER_JOIN_SQL, StringPool.BLANK);
        sql = StringUtil.replace(sql, _USER_ID_SQL, StringPool.BLANK);
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(lastPostDate);

      if (userId > 0) {
        qPos.add(userId);
      }

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }