Example usage for com.liferay.portal.kernel.util StringPool LIKE

List of usage examples for com.liferay.portal.kernel.util StringPool LIKE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool LIKE.

Prototype

String LIKE

To view the source code for com.liferay.portal.kernel.util StringPool LIKE.

Click Source Link

Usage

From source file:com.liferay.calendar.service.persistence.impl.CalendarResourceFinderImpl.java

License:Open Source License

protected int doCountByC_G_C_C_N_D_A(long companyId, long[] groupIds, long[] classNameIds, String[] codes,
        String[] names, String[] descriptions, boolean active, boolean andOperator, boolean inlineSQLHelper) {

    codes = CustomSQLUtil.keywords(codes);
    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;/*from   w w w  . j  a v  a2 s  .  c o m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_C_G_C_C_N_D_A);

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, CalendarResource.class.getName(),
                    "CalendarResource.calendarResourceId", groupIds);
        }

        sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds));
        sql = StringUtil.replace(sql, "[$CLASS_NAME_ID$]", getClassNameIds(classNameIds));
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(code_)", StringPool.LIKE, false, codes);
        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.createSynchronizedSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);
        qPos.add(groupIds);

        if (ArrayUtil.isNotEmpty(classNameIds)) {
            qPos.add(classNameIds);
        }

        qPos.add(codes, 2);
        qPos.add(names, 2);
        qPos.add(descriptions, 2);
        qPos.add(active);

        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.calendar.service.persistence.impl.CalendarResourceFinderImpl.java

License:Open Source License

protected List<CalendarResource> doFindByC_G_C_C_N_D_A(long companyId, long[] groupIds, long[] classNameIds,
        String[] codes, String[] names, String[] descriptions, boolean active, boolean andOperator, int start,
        int end, OrderByComparator<CalendarResource> orderByComparator, boolean inlineSQLHelper) {

    codes = CustomSQLUtil.keywords(codes);
    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;/*from   w  w  w  .ja va 2s  . c  o  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_C_G_C_C_N_D_A);

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, CalendarResource.class.getName(),
                    "CalendarResource.calendarResourceId", groupIds);
        }

        sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds));
        sql = StringUtil.replace(sql, "[$CLASS_NAME_ID$]", getClassNameIds(classNameIds));
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(code_)", StringPool.LIKE, false, codes);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names);
        sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, true, descriptions);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        StringBundler sb = new StringBundler();

        if (orderByComparator != null) {
            appendOrderByComparator(sb, "CalendarResource.", orderByComparator);
        }

        sql = StringUtil.replace(sql, "[$ORDER_BY$]", sb.toString());

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        q.addEntity("CalendarResource", CalendarResourceImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);
        qPos.add(groupIds);

        if (ArrayUtil.isNotEmpty(classNameIds)) {
            qPos.add(classNameIds);
        }

        qPos.add(codes, 2);
        qPos.add(names, 2);
        qPos.add(descriptions, 2);
        qPos.add(active);

        return (List<CalendarResource>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.contacts.service.persistence.EntryFinderImpl.java

License:Open Source License

public int countByU_FN_EA(long userId, String[] fullNames, String[] emailAddresses, boolean andOperator)
        throws SystemException {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;//w  w w .  j  a v  a  2  s  .  com

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(fullName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(emailAddress)", StringPool.LIKE, true, emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 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.contacts.service.persistence.EntryFinderImpl.java

License:Open Source License

public int countByC_U_FN_EA(long companyId, long userId, String[] fullNames, String[] emailAddresses,
        boolean andOperator) throws SystemException {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;//w  ww .  j  a  v  a 2s . com

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_C_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.firstName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.middleName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.lastName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.screenName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.emailAddress)", StringPool.LIKE, true,
                emailAddresses);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(Contacts_Entry.fullName)", StringPool.LIKE, false,
                fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(Contacts_Entry.emailAddress)", StringPool.LIKE, true,
                emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);
        qPos.add(fullNames, 8);
        qPos.add(emailAddresses, 2);
        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 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.contacts.service.persistence.EntryFinderImpl.java

License:Open Source License

public List<Entry> findByU_FN_EA(long userId, String[] fullNames, String[] emailAddresses, boolean andOperator,
        int start, int end) throws SystemException {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;//from www.  j  a v a2s.  c  om

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(fullName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(emailAddress)", StringPool.LIKE, true, emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("Contacts_Entry", EntryImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 2);

        return (List<Entry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.contacts.service.persistence.EntryFinderImpl.java

License:Open Source License

public List<BaseModel<?>> findByC_U_FN_EA(long companyId, long userId, String[] fullNames,
        String[] emailAddresses, boolean andOperator, int start, int end) throws SystemException {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;/*from ww  w. ja  v  a  2s  .com*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_C_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.firstName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.middleName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.lastName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.screenName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(User_.emailAddress)", StringPool.LIKE, true,
                emailAddresses);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(Contacts_Entry.fullName)", StringPool.LIKE, false,
                fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(Contacts_Entry.emailAddress)", StringPool.LIKE, true,
                emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar("id", Type.LONG);
        q.addScalar("name", Type.STRING);
        q.addScalar("portalUser", Type.INTEGER);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);
        qPos.add(fullNames, 8);
        qPos.add(emailAddresses, 2);
        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 2);

        List<BaseModel<?>> models = new ArrayList<BaseModel<?>>();

        Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end);

        while (itr.hasNext()) {
            Object[] array = itr.next();

            long id = (Long) array[0];
            //String name = (String)array[1];
            int portalUser = (Integer) array[2];

            BaseModel<?> model = null;

            if (portalUser == 1) {
                model = UserLocalServiceUtil.getUser(id);
            } else {
                model = EntryLocalServiceUtil.getEntry(id);
            }

            models.add(model);
        }

        return models;
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.contacts.service.persistence.impl.EntryFinderImpl.java

License:Open Source License

protected int countByU_FN_EA(long userId, String[] fullNames, String[] emailAddresses) {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;/*from  w  w  w.j ava 2  s.  co m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(fullName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(emailAddress)", StringPool.LIKE, true, emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, false);

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 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.contacts.service.persistence.impl.EntryFinderImpl.java

License:Open Source License

protected List<Entry> findByU_FN_EA(long userId, String[] fullNames, String[] emailAddresses, int start,
        int end) {

    fullNames = CustomSQLUtil.keywords(fullNames, true);
    emailAddresses = CustomSQLUtil.keywords(emailAddresses, true);

    Session session = null;/*from w  w w .  ja  va 2 s . c om*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_U_FN_EA);

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(fullName)", StringPool.LIKE, false, fullNames);
        sql = CustomSQLUtil.replaceKeywords(sql, "lower(emailAddress)", StringPool.LIKE, true, emailAddresses);
        sql = CustomSQLUtil.replaceAndOperator(sql, false);

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        q.addEntity("Contacts_Entry", EntryImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);
        qPos.add(fullNames, 2);
        qPos.add(emailAddresses, 2);

        return (List<Entry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetFinderImpl.java

License:Open Source License

protected int doCountByC_G_N_D_S(long companyId, long groupId, String[] names, String[] descriptions, int scope,
        boolean andOperator, boolean inlineSQLHelper) {

    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;/*from ww w.j  a  v  a2s  . c o m*/

    try {
        session = openSession();

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

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

        if (groupId <= 0) {
            sql = StringUtil.replace(sql, "(DDLRecordSet.groupId = ?) AND", StringPool.BLANK);
        }

        if (scope == DDLRecordSetConstants.SCOPE_ANY) {
            sql = StringUtil.replace(sql, "(DDLRecordSet.scope = ?) AND", StringPool.BLANK);
        }

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(DDLRecordSet.name)", StringPool.LIKE, false, names);
        sql = CustomSQLUtil.replaceKeywords(sql, "DDLRecordSet.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 (groupId > 0) {
            qPos.add(groupId);
        }

        if (scope != DDLRecordSetConstants.SCOPE_ANY) {
            qPos.add(scope);
        }

        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.dynamic.data.lists.service.persistence.impl.DDLRecordSetFinderImpl.java

License:Open Source License

protected List<DDLRecordSet> doFindByC_G_N_D_S(long companyId, long groupId, String[] names,
        String[] descriptions, int scope, boolean andOperator, int start, int end,
        OrderByComparator<DDLRecordSet> orderByComparator, boolean inlineSQLHelper) {

    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;/*from w  w  w . java 2  s.  co m*/

    try {
        session = openSession();

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

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

        if (groupId <= 0) {
            sql = StringUtil.replace(sql, "(DDLRecordSet.groupId = ?) AND", StringPool.BLANK);
        }

        if (scope == DDLRecordSetConstants.SCOPE_ANY) {
            sql = StringUtil.replace(sql, "(DDLRecordSet.scope = ?) AND", StringPool.BLANK);
        }

        sql = CustomSQLUtil.replaceKeywords(sql, "lower(DDLRecordSet.name)", StringPool.LIKE, false, names);
        sql = CustomSQLUtil.replaceKeywords(sql, "DDLRecordSet.description", StringPool.LIKE, true,
                descriptions);
        sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);
        sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator);

        SQLQuery q = session.createSynchronizedSQLQuery(sql);

        q.addEntity("DDLRecordSet", DDLRecordSetImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(companyId);

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

        if (scope != DDLRecordSetConstants.SCOPE_ANY) {
            qPos.add(scope);
        }

        qPos.add(names, 2);
        qPos.add(descriptions, 2);

        return (List<DDLRecordSet>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}