List of usage examples for com.liferay.portal.kernel.util StringPool LIKE
String LIKE
To view the source code for com.liferay.portal.kernel.util StringPool LIKE.
Click Source Link
From source file:com.liferay.newsletter.service.persistence.NewsletterContactFinderImpl.java
License:Open Source License
protected List<NewsletterContact> doFindByC_G_C_E_N_S(long companyId, long groupId, long campaignId, String[] emails, String[] names, boolean sent, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); emails = CustomSQLUtil.keywords(emails); Session session = null;//from w ww . java 2s . c o m try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_C_E_N_S); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(email)", StringPool.LIKE, false, emails); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContact", NewsletterContactImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(campaignId); qPos.add(emails, 2); qPos.add(names, 2); qPos.add(sent); return (List<NewsletterContact>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.newsletter.service.persistence.NewsletterContactFinderImpl.java
License:Open Source License
protected List<NewsletterContact> doFindByC_G_N_E(long companyId, long groupId, String[] names, String[] emails, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); emails = CustomSQLUtil.keywords(emails); Session session = null;/* www.j a va2 s .c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_N_E); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(email)", StringPool.LIKE, false, emails); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContact", NewsletterContactImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(emails); qPos.add(names); return (List<NewsletterContact>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.newsletter.service.persistence.NewsletterContactFinderImpl.java
License:Open Source License
protected List<NewsletterContact> dofindByEmail(long companyId, long groupId, String[] emails, int start, int end, OrderByComparator orderByComparator) throws SystemException { emails = CustomSQLUtil.keywords(emails); Session session = null;/*www.ja va2 s .c om*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_EMAIL); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(email)", StringPool.LIKE, false, emails); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContact", NewsletterContactImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(emails, 2); return (List<NewsletterContact>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.newsletter.service.persistence.NewsletterContactFinderImpl.java
License:Open Source License
protected List<NewsletterContact> doFindByNameAndCampaign(long companyId, long groupId, String[] names, long campaignId, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); Session session = null;/*from w w w. j a v a2 s.c om*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_NAME_CAMPAIGN); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContact", NewsletterContact.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(names, 2); qPos.add(campaignId); return (List<NewsletterContact>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.newsletter.service.persistence.NewsletterContentFinderImpl.java
License:Open Source License
protected List<NewsletterContent> doFindByT_C(long companyId, long groupId, String[] titles, String[] contents, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { titles = CustomSQLUtil.keywords(titles); contents = CustomSQLUtil.keywords(contents); Session session = null;/*from www .j a va2s. c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_T_C); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceKeywords(sql, "lower(content)", StringPool.LIKE, false, contents); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContent", NewsletterContentImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(titles); qPos.add(contents); return (List<NewsletterContent>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.newsletter.service.persistence.NewsletterContentFinderImpl.java
License:Open Source License
protected List<NewsletterContent> doFindByTitle(long companyId, long groupId, String[] titles, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { titles = CustomSQLUtil.keywords(titles); Session session = null;//from w ww . j a v a2 s .c o m try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_TITLE); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("NewsletterContent", NewsletterContentImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(titles, 2); return (List<NewsletterContent>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.polls.service.persistence.impl.PollsQuestionFinderImpl.java
License:Open Source License
protected int doCountByC_G_T_D(long companyId, long[] groupIds, String[] titles, String[] descriptions, boolean andOperator, boolean inlineSQLHelper) { titles = CustomSQLUtil.keywords(titles); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;/*from w w w .j a v a 2 s . co m*/ try { session = openSession(); String sql = CustomSQLUtil.get(getClass(), COUNT_BY_C_G_T_D); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, PollsQuestion.class.getName(), "PollsQuestion.questionId", groupIds); } sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "lower(PollsQuestion.title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceKeywords(sql, "PollsQuestion.description", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupIds != null) { qPos.add(groupIds); } qPos.add(titles, 2); qPos.add(descriptions, 2); 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); } }
From source file:com.liferay.polls.service.persistence.impl.PollsQuestionFinderImpl.java
License:Open Source License
protected List<PollsQuestion> doFindByC_G_T_D(long companyId, long[] groupIds, String[] titles, String[] descriptions, boolean andOperator, int start, int end, OrderByComparator<PollsQuestion> orderByComparator, boolean inlineSQLHelper) { titles = CustomSQLUtil.keywords(titles); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;//from w w w.j a v a 2 s . c o m try { session = openSession(); String sql = CustomSQLUtil.get(getClass(), FIND_BY_C_G_T_D); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, PollsQuestion.class.getName(), "PollsQuestion.questionId", groupIds); } sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "lower(PollsQuestion.title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceKeywords(sql, "PollsQuestion.description", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addEntity("PollsQuestion", PollsQuestionImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupIds != null) { qPos.add(groupIds); } qPos.add(titles, 2); qPos.add(descriptions, 2); return (List<PollsQuestion>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypeFinderImpl.java
License:Open Source License
protected int countByC_G_N_D_S(long companyId, long[] groupIds, String[] names, String[] descriptions, boolean andOperator, boolean includeBasicFileEntryType) throws SystemException { names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;/*w ww . j a v a2 s . com*/ try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_C_G_N_D_S); sql = StringUtil.replace(sql, "[$WHERE$]", getWhere(includeBasicFileEntryType)); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (includeBasicFileEntryType) { qPos.add(names, 2); qPos.add(descriptions, 2); } qPos.add(companyId); qPos.add(groupIds); qPos.add(names, 2); qPos.add(descriptions, 2); 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); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypeFinderImpl.java
License:Open Source License
protected List<DLFileEntryType> findByC_G_N_D_S(long companyId, long[] groupIds, String[] names, String[] descriptions, boolean andOperator, boolean includeBasicFileEntryType, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;/*from w w w .j a va 2s .c om*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_N_D_S); sql = StringUtil.replace(sql, "[$WHERE$]", getWhere(includeBasicFileEntryType)); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if (orderByComparator != null) { String orderByFields = StringUtil.merge(orderByComparator.getOrderByFields(), StringPool.COMMA); sql = StringUtil.replace(sql, "name ASC", orderByFields.concat(" DESC")); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("DLFileEntryType", DLFileEntryTypeImpl.class); QueryPos qPos = QueryPos.getInstance(q); if (includeBasicFileEntryType) { qPos.add(names, 2); qPos.add(descriptions, 2); } qPos.add(companyId); qPos.add(groupIds); qPos.add(names, 2); qPos.add(descriptions, 2); return (List<DLFileEntryType>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }