@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); } }
@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 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 int countByRelationType(long userId, int type) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_RELATION_TYPE); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); 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); } }
public List<SocialActivity> findByRelationType(long userId, int type, int start, int end) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_RELATION_TYPE); SQLQuery q = session.createSQLQuery(sql); q.addEntity("SocialActivity", SocialActivityImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(type); return (List<SocialActivity>) QueryUtil.list(q, getDialect(), start, end); } 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); } }
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<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); } }
@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); } }
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); } }
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); } }
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); } }
@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); } }
@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); } }
@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<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> 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); } }
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<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); } }
/** * Returns the number of entries where userId = ? and emailAddress = ?. * * @param userId the user ID * @param emailAddress the email address * @return the number of matching entries * @throws SystemException if a system exception occurred */ @Override public int countByU_EA(long userId, String emailAddress) throws SystemException { FinderPath finderPath = FINDER_PATH_COUNT_BY_U_EA; Object[] finderArgs = new Object[] {userId, emailAddress}; Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ENTRY_WHERE); query.append(_FINDER_COLUMN_U_EA_USERID_2); boolean bindEmailAddress = false; if (emailAddress == null) { query.append(_FINDER_COLUMN_U_EA_EMAILADDRESS_1); } else if (emailAddress.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_U_EA_EMAILADDRESS_3); } else { bindEmailAddress = true; query.append(_FINDER_COLUMN_U_EA_EMAILADDRESS_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); if (bindEmailAddress) { qPos.add(emailAddress); } 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(); }
@Override public int countByOrganizationIds( List<Long> organizationIds, Date displayDate, QueryDefinition<BlogsEntry> queryDefinition) { Timestamp displayDate_TS = CalendarUtil.getTimestamp(displayDate); Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_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)); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); 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()); } 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<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); } }
protected int doCountByG_F( long groupId, List<Long> folderIds, QueryDefinition<JournalArticle> queryDefinition, boolean inlineSQLHelper) { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_G_F, queryDefinition, "JournalArticle"); sql = replaceStatusJoin(sql, queryDefinition); 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.addScalar(COUNT_COLUMN_NAME, Type.LONG); 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); } 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); } }
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); } }
@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); } }
@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); } }
@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<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); } }