List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS
String OPEN_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.
Click Source Link
From source file:com.liferay.calendar.service.persistence.impl.CalendarResourcePersistenceImpl.java
License:Open Source License
/** * Returns the number of calendar resources that the user has permission to view where groupId = any ? and code = ?. * * @param groupIds the group IDs// w w w . j a v a 2 s .c o m * @param code the code * @return the number of matching calendar resources that the user has permission to view */ @Override public int filterCountByG_C(long[] groupIds, String code) { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return countByG_C(groupIds, code); } if (groupIds == null) { groupIds = new long[0]; } else { groupIds = ArrayUtil.unique(groupIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_CALENDARRESOURCE_WHERE); if (groupIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_C_GROUPID_7); query.append(StringUtil.merge(groupIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } boolean bindCode = false; if (code == null) { query.append(_FINDER_COLUMN_G_C_CODE_1); } else if (code.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_C_CODE_3); } else { bindCode = true; query.append(_FINDER_COLUMN_G_C_CODE_2); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), CalendarResource.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupIds); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindCode) { qPos.add(code); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.content.targeting.analytics.service.persistence.AnalyticsReferrerPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the analytics referrers where analyticsEventId = any ? and referrerClassName = ? and referrerClassPK = ?. * * <p>/*from ww w. j a v a 2 s. c o m*/ * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.content.targeting.analytics.model.impl.AnalyticsReferrerModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param analyticsEventIds the analytics event IDs * @param referrerClassName the referrer class name * @param referrerClassPK the referrer class p k * @param start the lower bound of the range of analytics referrers * @param end the upper bound of the range of analytics referrers (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching analytics referrers * @throws SystemException if a system exception occurred */ @Override public List<AnalyticsReferrer> findByA_R_R(long[] analyticsEventIds, String referrerClassName, long referrerClassPK, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((analyticsEventIds != null) && (analyticsEventIds.length == 1)) { return findByA_R_R(analyticsEventIds[0], referrerClassName, referrerClassPK, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { StringUtil.merge(analyticsEventIds), referrerClassName, referrerClassPK }; } else { finderArgs = new Object[] { StringUtil.merge(analyticsEventIds), referrerClassName, referrerClassPK, start, end, orderByComparator }; } List<AnalyticsReferrer> list = (List<AnalyticsReferrer>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R_R, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AnalyticsReferrer analyticsReferrer : list) { if (!ArrayUtil.contains(analyticsEventIds, analyticsReferrer.getAnalyticsEventId()) || !Validator.equals(referrerClassName, analyticsReferrer.getReferrerClassName()) || (referrerClassPK != analyticsReferrer.getReferrerClassPK())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_ANALYTICSREFERRER_WHERE); boolean conjunctionable = false; if ((analyticsEventIds == null) || (analyticsEventIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < analyticsEventIds.length; i++) { query.append(_FINDER_COLUMN_A_R_R_ANALYTICSEVENTID_5); if ((i + 1) < analyticsEventIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } boolean bindReferrerClassName = false; if (referrerClassName == null) { query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_4); } else if (referrerClassName.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_6); } else { bindReferrerClassName = true; query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_5); } conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSPK_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AnalyticsReferrerModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (analyticsEventIds != null) { qPos.add(analyticsEventIds); } if (bindReferrerClassName) { qPos.add(referrerClassName); } qPos.add(referrerClassPK); if (!pagination) { list = (List<AnalyticsReferrer>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<AnalyticsReferrer>(list); } else { list = (List<AnalyticsReferrer>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R_R, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_R_R, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.content.targeting.analytics.service.persistence.AnalyticsReferrerPersistenceImpl.java
License:Open Source License
/** * Returns the number of analytics referrers where analyticsEventId = any ? and referrerClassName = ? and referrerClassPK = ?. * * @param analyticsEventIds the analytics event IDs * @param referrerClassName the referrer class name * @param referrerClassPK the referrer class p k * @return the number of matching analytics referrers * @throws SystemException if a system exception occurred *///w w w. j av a2s .c o m @Override public int countByA_R_R(long[] analyticsEventIds, String referrerClassName, long referrerClassPK) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(analyticsEventIds), referrerClassName, referrerClassPK }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_R_R, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_ANALYTICSREFERRER_WHERE); boolean conjunctionable = false; if ((analyticsEventIds == null) || (analyticsEventIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < analyticsEventIds.length; i++) { query.append(_FINDER_COLUMN_A_R_R_ANALYTICSEVENTID_5); if ((i + 1) < analyticsEventIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } boolean bindReferrerClassName = false; if (referrerClassName == null) { query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_4); } else if (referrerClassName.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_6); } else { bindReferrerClassName = true; query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSNAME_5); } conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_A_R_R_REFERRERCLASSPK_5); conjunctionable = true; String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (analyticsEventIds != null) { qPos.add(analyticsEventIds); } if (bindReferrerClassName) { qPos.add(referrerClassName); } qPos.add(referrerClassPK); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_R_R, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_R_R, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.content.targeting.hook.CTAssetVocabularyServiceImpl.java
License:Open Source License
@Override public List<AssetVocabulary> getVocabularies(long[] vocabularyIds) throws PortalException, SystemException { List<AssetVocabulary> vocabularies = super.getVocabularies(vocabularyIds); if (vocabularies.size() <= 1) { return vocabularies; }/*from w ww . j a va 2s . co m*/ List<AssetVocabulary> unambiguousVocabularies = new ArrayList<AssetVocabulary>(); Locale locale = LocaleThreadLocal.getThemeDisplayLocale(); for (AssetVocabulary vocabulary : vocabularies) { String vocabularyTitle = vocabulary.getTitle(locale); if (vocabularyTitle.equals(UserSegmentUtil.getAssetVocabularyName())) { Group vocabularyGroup = GroupLocalServiceUtil.getGroup(vocabulary.getGroupId()); if (!vocabularyGroup.isCompany()) { StringBundler sb = new StringBundler(5); sb.append(vocabularyTitle); sb.append(StringPool.SPACE); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(vocabularyGroup.getDescriptiveName(locale)); sb.append(StringPool.CLOSE_PARENTHESIS); vocabulary.setTitle(sb.toString(), locale); } } unambiguousVocabularies.add(vocabulary); } return unambiguousVocabularies; }
From source file:com.liferay.content.targeting.model.impl.CampaignImpl.java
License:Open Source License
public String getNameWithGroupName(Locale locale, long groupId) { String name = getName(locale); if (groupId != getGroupId()) { try {// www . ja va 2s. c om Group group = GroupLocalServiceUtil.getGroup(getGroupId()); StringBundler sb = new StringBundler(5); sb.append(name); sb.append(StringPool.SPACE); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(group.getDescriptiveName(locale)); sb.append(StringPool.CLOSE_PARENTHESIS); name = sb.toString(); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Group can not be found for groupId " + getGroupId()); } } } return name; }
From source file:com.liferay.content.targeting.model.impl.UserSegmentImpl.java
License:Open Source License
public String getNameWithGroupName(Locale locale, long groupId) { String name = getName(locale); try {//from w w w.j a v a 2 s . com Group group = GroupLocalServiceUtil.getGroup(getGroupId()); if ((groupId != getGroupId()) && (!group.hasStagingGroup() || (group.getStagingGroup().getGroupId() != groupId))) { StringBundler sb = new StringBundler(5); sb.append(name); sb.append(StringPool.SPACE); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(group.getDescriptiveName(locale)); sb.append(StringPool.CLOSE_PARENTHESIS); name = sb.toString(); } } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Group can not be found for groupId " + getGroupId()); } } return name; }
From source file:com.liferay.content.targeting.service.persistence.CampaignFinderImpl.java
License:Open Source License
protected String getGroupIds(long[] groupIds) { if (groupIds.length == 0) { return StringPool.BLANK; }/*w w w.jav a 2 s. co m*/ StringBundler sb = new StringBundler(groupIds.length * 2); sb.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { sb.append("groupId = ?"); if ((i + 1) < groupIds.length) { sb.append(" OR "); } } sb.append(") AND"); return sb.toString(); }
From source file:com.liferay.content.targeting.service.persistence.CampaignPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the campaigns that the user has permission to view where groupId = any ?. * * <p>//w w w . jav a 2 s. c o m * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.content.targeting.model.impl.CampaignModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupIds the group IDs * @param start the lower bound of the range of campaigns * @param end the upper bound of the range of campaigns (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching campaigns that the user has permission to view * @throws SystemException if a system exception occurred */ @Override public List<Campaign> filterFindByGroupId(long[] groupIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return findByGroupId(groupIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CAMPAIGN_WHERE); } else { query.append(_FILTER_SQL_SELECT_CAMPAIGN_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CAMPAIGN_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(CampaignModelImpl.ORDER_BY_JPQL); } else { query.append(CampaignModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Campaign.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, CampaignImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, CampaignImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (groupIds != null) { qPos.add(groupIds); } return (List<Campaign>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.content.targeting.service.persistence.CampaignPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the campaigns where groupId = any ?. * * <p>//from ww w . j av a2 s .c o m * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.content.targeting.model.impl.CampaignModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupIds the group IDs * @param start the lower bound of the range of campaigns * @param end the upper bound of the range of campaigns (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching campaigns * @throws SystemException if a system exception occurred */ @Override public List<Campaign> findByGroupId(long[] groupIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((groupIds != null) && (groupIds.length == 1)) { return findByGroupId(groupIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { StringUtil.merge(groupIds) }; } else { finderArgs = new Object[] { StringUtil.merge(groupIds), start, end, orderByComparator }; } List<Campaign> list = (List<Campaign>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Campaign campaign : list) { if (!ArrayUtil.contains(groupIds, campaign.getGroupId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_CAMPAIGN_WHERE); boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(CampaignModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (groupIds != null) { qPos.add(groupIds); } if (!pagination) { list = (List<Campaign>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Campaign>(list); } else { list = (List<Campaign>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.content.targeting.service.persistence.CampaignPersistenceImpl.java
License:Open Source License
/** * Returns the number of campaigns where groupId = any ?. * * @param groupIds the group IDs/*from w ww. jav a 2 s . c o m*/ * @return the number of matching campaigns * @throws SystemException if a system exception occurred */ @Override public int countByGroupId(long[] groupIds) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_CAMPAIGN_WHERE); boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (groupIds != null) { qPos.add(groupIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }