Exemplo n.º 1
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<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;
  }
Exemplo n.º 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);
    }
  }
Exemplo n.º 4
0
  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);
    }
  }
  @Override
  public List<CalEvent> findByFutureReminders() {
    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.createSynchronizedSQLQuery(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);
    }
  }
  @Override
  public List<JournalArticle> findByReviewDate(
      long classNameId, Date reviewDateLT, Date reviewDateGT) {

    Timestamp reviewDateLT_TS = CalendarUtil.getTimestamp(reviewDateLT);
    Timestamp reviewDateGT_TS = CalendarUtil.getTimestamp(reviewDateGT);

    Session session = null;
    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_REVIEW_DATE);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(classNameId);
      qPos.add(reviewDateGT_TS);
      qPos.add(reviewDateLT_TS);

      return q.list(true);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  public List<Layout> findByNoPermissions(long roleId) {
    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_NO_PERMISSIONS);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("Layout", LayoutImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(ResourceConstants.SCOPE_INDIVIDUAL);
      qPos.add(roleId);

      return q.list(true);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  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);
    }
  }
Exemplo n.º 9
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<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.createSynchronizedSQLQuery(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);
    }
  }
  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);
    }
  }
Exemplo n.º 12
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 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);
    }
  }
  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);
    }
  }
Exemplo n.º 15
0
  @Override
  public List<Layout> findByScopeGroup(long groupId, boolean privateLayout) {
    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_SCOPE_GROUP);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("Layout", LayoutImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(privateLayout);

      return q.list(true);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  public List<JournalArticle> findByExpirationDate(
      long classNameId, Date expirationDateLT, QueryDefinition<JournalArticle> queryDefinition) {

    Timestamp expirationDateLT_TS = CalendarUtil.getTimestamp(expirationDateLT);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_EXPIRATION_DATE, queryDefinition);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(classNameId);
      qPos.add(queryDefinition.getStatus());
      qPos.add(expirationDateLT_TS);

      return q.list(true);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemplo n.º 17
0
  @Override
  public List<ShoppingItem> findByKeywords(
      long groupId, long[] categoryIds, String keywords, int start, int end)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      StringBundler query = new StringBundler();

      query.append("SELECT {ShoppingItem.*} FROM ShoppingItem ");
      query.append("WHERE ");
      query.append("ShoppingItem.groupId = ? AND (");

      if (ArrayUtil.isNotEmpty(categoryIds)) {
        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < categoryIds.length; i++) {
          query.append("ShoppingItem.categoryId = ? ");

          if ((i + 1) < categoryIds.length) {
            query.append("OR ");
          }
        }

        query.append(") AND ");
      }

      query.append("(ShoppingItem.name LIKE ? OR ");
      query.append("ShoppingItem.description LIKE ? OR ");
      query.append("ShoppingItem.properties LIKE ?))");

      keywords = '%' + keywords + '%';

      SQLQuery q = session.createSynchronizedSQLQuery(query.toString());

      q.addEntity("ShoppingItem", ShoppingItemImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);

      for (long categoryId : categoryIds) {
        qPos.add(categoryId);
      }

      qPos.add(keywords);
      qPos.add(keywords);
      qPos.add(keywords);

      return (List<ShoppingItem>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemplo n.º 18
0
  @Override
  public List<ShoppingItem> findByFeatured(long groupId, long[] categoryIds, int numOfItems)
      throws SystemException {

    int countByFeatured = countByFeatured(groupId, categoryIds);

    Session session = null;

    try {
      session = openSession();

      StringBundler query = new StringBundler();

      query.append("SELECT {ShoppingItem.*} FROM ShoppingItem ");
      query.append("WHERE ");
      query.append("ShoppingItem.groupId = ? AND (");

      if (ArrayUtil.isNotEmpty(categoryIds)) {
        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < categoryIds.length; i++) {
          query.append("ShoppingItem.categoryId = ? ");

          if ((i + 1) < categoryIds.length) {
            query.append("OR ");
          }
        }

        query.append(") AND ");
      }

      query.append("ShoppingItem.featured = ? AND ");
      query.append("ShoppingItem.smallImage = ?");

      SQLQuery q = session.createSynchronizedSQLQuery(query.toString());

      q.addEntity("ShoppingItem", ShoppingItemImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);

      for (long categoryId : categoryIds) {
        qPos.add(categoryId);
      }

      qPos.add(true);
      qPos.add(true);

      return (List<ShoppingItem>)
          QueryUtil.randomList(q, getDialect(), countByFeatured, numOfItems);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemplo n.º 19
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);
    }
  }
Exemplo n.º 20
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);
    }
  }
  @Override
  public List<SyncDLObject> findByModifiedTime(
      long modifiedTime, long repositoryId, long parentFolderId, String type, int start, int end) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(getClass(), FIND_BY_MODIFIED_TIME);

      if (modifiedTime <= 0) {
        sql = StringUtil.replace(sql, "(SyncDLObject.modifiedTime > ?) AND", StringPool.BLANK);
      }

      if (parentFolderId == 0) {
        sql = StringUtil.replace(sql, "AND (SyncDLObject.treePath LIKE ?)", StringPool.BLANK);
      }

      if (type == null) {
        sql = StringUtil.replace(sql, "AND (SyncDLObject.type_ = ?)", StringPool.BLANK);
      }

      if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS)) {
        sql = CustomSQLUtil.removeOrderBy(sql);
      }

      SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);

      sqlQuery.addEntity("SyncDLObject", SyncDLObjectImpl.class);

      QueryPos qPos = QueryPos.getInstance(sqlQuery);

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

      qPos.add(repositoryId);

      if (parentFolderId != 0) {
        qPos.add("%/" + parentFolderId + "/%");
      }

      if (type != null) {
        qPos.add(type);
      }

      return (List<SyncDLObject>) QueryUtil.list(sqlQuery, getDialect(), start, end);
    } 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;
  }
Exemplo n.º 23
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);
    }
  }
  protected List<JournalArticle> doFindByG_F(
      long groupId,
      List<Long> folderIds,
      QueryDefinition<JournalArticle> queryDefinition,
      boolean inlineSQLHelper) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_F, queryDefinition, "JournalArticle");

      sql = replaceStatusJoin(sql, queryDefinition);

      sql =
          CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator("JournalArticle"));

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId);
      }

      sql =
          StringUtil.replace(
              sql, "[$FOLDER_ID$]", getFolderIds(folderIds, JournalArticleImpl.TABLE_NAME));

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(queryDefinition.getStatus());

      for (int i = 0; i < folderIds.size(); i++) {
        Long folderId = folderIds.get(i);

        qPos.add(folderId);
      }

      return (List<JournalArticle>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemplo n.º 25
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);
    }
  }
  @Override
  public List<BlogsEntry> findByOrganizationIds(
      List<Long> organizationIds, Date displayDate, QueryDefinition<BlogsEntry> queryDefinition) {

    Timestamp displayDate_TS = CalendarUtil.getTimestamp(displayDate);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_ORGANIZATION_IDS);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        if (queryDefinition.isExcludeStatus()) {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status != ?)");
        } else {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status = ?)");
        }
      }

      sql = StringUtil.replace(sql, "[$ORGANIZATION_ID$]", getOrganizationIds(organizationIds));
      sql = CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator());

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("BlogsEntry", BlogsEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      for (int i = 0; i < organizationIds.size(); i++) {
        Long organizationId = organizationIds.get(i);

        qPos.add(organizationId);
      }

      qPos.add(displayDate_TS);

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

      return (List<BlogsEntry>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Exemplo n.º 27
0
  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);
    }
  }
Exemplo n.º 28
0
 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);
   }
 }
Exemplo n.º 29
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);
    }
  }
  @Override
  public JournalArticle findByR_D(long resourcePrimKey, Date displayDate)
      throws NoSuchArticleException {

    Timestamp displayDate_TS = CalendarUtil.getTimestamp(displayDate);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_R_D);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(resourcePrimKey);
      qPos.add(displayDate_TS);

      List<JournalArticle> articles = q.list();

      if (!articles.isEmpty()) {
        return articles.get(0);
      }
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }

    StringBundler sb = new StringBundler(6);

    sb.append("No JournalArticle exists with the key ");
    sb.append("{resourcePrimKey=");
    sb.append(resourcePrimKey);
    sb.append(", displayDate=");
    sb.append(displayDate);
    sb.append("}");

    throw new NoSuchArticleException(sb.toString());
  }