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

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

Introduction

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

Prototype

String OPEN_PARENTHESIS

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

Click Source Link

Usage

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = ? and groupId = ? and localNome LIKE ? and status = any ?.
 *
 * <p>/*from   w ww  . jav a 2  s . com*/
 * 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 br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 companyId the company ID
 * @param groupId the group ID
 * @param localNome the local nome
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_LocalNome(long companyId, long groupId, String localNome, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_LocalNome(companyId, groupId, localNome, statuses[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[] { companyId, groupId, localNome, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, localNome, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALNOME, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !StringUtil.wildcardMatches(eventoAgenda.getLocalNome(), localNome, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALNOME_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALNOME_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindLocalNome = false;

        if (localNome == null) {
            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_4);
        } else if (localNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_6);
        } else {
            bindLocalNome = true;

            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_LOCALNOME_STATUS_5);

                if ((i + 1) < statuses.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(EventoAgendaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindLocalNome) {
                qPos.add(localNome);
            }

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

            if (!pagination) {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALNOME, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALNOME, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of evento agendas where companyId = &#63; and groupId = &#63; and localNome LIKE &#63; and status = any &#63;.
 *
 * @param companyId the company ID/*from w ww  .j  av  a  2s .co  m*/
 * @param groupId the group ID
 * @param localNome the local nome
 * @param statuses the statuses
 * @return the number of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCG_LocalNome(long companyId, long groupId, String localNome, int[] statuses)
        throws SystemException {
    Object[] finderArgs = new Object[] { companyId, groupId, localNome, StringUtil.merge(statuses) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALNOME, finderArgs,
            this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALNOME_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALNOME_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindLocalNome = false;

        if (localNome == null) {
            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_4);
        } else if (localNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_6);
        } else {
            bindLocalNome = true;

            query.append(_FINDER_COLUMN_CG_LOCALNOME_LOCALNOME_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_LOCALNOME_STATUS_5);

                if ((i + 1) < statuses.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);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindLocalNome) {
                qPos.add(localNome);
            }

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

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALNOME, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALNOME, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and localId = &#63; and status = any &#63;.
 *
 * <p>//  ww  w. j  ava2s  .  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 br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 companyId the company ID
 * @param groupId the group ID
 * @param localId the local ID
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_LocalID(long companyId, long groupId, long localId, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_LocalID(companyId, groupId, localId, statuses[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[] { companyId, groupId, localId, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, localId, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALID, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (localId != eventoAgenda.getLocalId())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_LOCALID_5);

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_LOCALID_STATUS_5);

                if ((i + 1) < statuses.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(EventoAgendaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            qPos.add(localId);

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

            if (!pagination) {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALID, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_LOCALID, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of evento agendas where companyId = &#63; and groupId = &#63; and localId = &#63; and status = any &#63;.
 *
 * @param companyId the company ID//w w w . j a va2 s  .c  om
 * @param groupId the group ID
 * @param localId the local ID
 * @param statuses the statuses
 * @return the number of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCG_LocalID(long companyId, long groupId, long localId, int[] statuses)
        throws SystemException {
    Object[] finderArgs = new Object[] { companyId, groupId, localId, StringUtil.merge(statuses) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALID, finderArgs,
            this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_LOCALID_LOCALID_5);

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_LOCALID_STATUS_5);

                if ((i + 1) < statuses.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);

            qPos.add(companyId);

            qPos.add(groupId);

            qPos.add(localId);

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

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALID, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_LOCALID, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and userResponsavelNome LIKE &#63; and status = any &#63;.
 *
 * <p>//from ww w.  jav  a2s . 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 br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 companyId the company ID
 * @param groupId the group ID
 * @param userResponsavelNome the user responsavel nome
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_ResponsavelNome(long companyId, long groupId, String userResponsavelNome,
        int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_ResponsavelNome(companyId, groupId, userResponsavelNome, statuses[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[] { companyId, groupId, userResponsavelNome, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, userResponsavelNome, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELNOME, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || !StringUtil.wildcardMatches(eventoAgenda.getUserResponsavelNome(), userResponsavelNome,
                            CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, true)
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindUserResponsavelNome = false;

        if (userResponsavelNome == null) {
            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_4);
        } else if (userResponsavelNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_6);
        } else {
            bindUserResponsavelNome = true;

            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_STATUS_5);

                if ((i + 1) < statuses.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(EventoAgendaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindUserResponsavelNome) {
                qPos.add(userResponsavelNome);
            }

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

            if (!pagination) {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELNOME, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELNOME, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of evento agendas where companyId = &#63; and groupId = &#63; and userResponsavelNome LIKE &#63; and status = any &#63;.
 *
 * @param companyId the company ID//from  www  .  j  av a2  s .c o m
 * @param groupId the group ID
 * @param userResponsavelNome the user responsavel nome
 * @param statuses the statuses
 * @return the number of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCG_ResponsavelNome(long companyId, long groupId, String userResponsavelNome, int[] statuses)
        throws SystemException {
    Object[] finderArgs = new Object[] { companyId, groupId, userResponsavelNome, StringUtil.merge(statuses) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELNOME,
            finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindUserResponsavelNome = false;

        if (userResponsavelNome == null) {
            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_4);
        } else if (userResponsavelNome.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_6);
        } else {
            bindUserResponsavelNome = true;

            query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_USERRESPONSAVELNOME_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RESPONSAVELNOME_STATUS_5);

                if ((i + 1) < statuses.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);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindUserResponsavelNome) {
                qPos.add(userResponsavelNome);
            }

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

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELNOME, finderArgs,
                    count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELNOME, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the evento agendas where companyId = &#63; and groupId = &#63; and userResponsavelId = &#63; and status = any &#63;.
 *
 * <p>//from  w ww .j a va 2  s  .c om
 * 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 br.com.prodevelopment.lapidarios.evento.model.impl.EventoAgendaModelImpl}. 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 companyId the company ID
 * @param groupId the group ID
 * @param userResponsavelId the user responsavel ID
 * @param statuses the statuses
 * @param start the lower bound of the range of evento agendas
 * @param end the upper bound of the range of evento agendas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<EventoAgenda> findByCG_ResponsavelId(long companyId, long groupId, long userResponsavelId,
        int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_ResponsavelId(companyId, groupId, userResponsavelId, statuses[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[] { companyId, groupId, userResponsavelId, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, userResponsavelId, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil
            .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELID, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (EventoAgenda eventoAgenda : list) {
            if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId())
                    || (userResponsavelId != eventoAgenda.getUserResponsavelId())
                    || !ArrayUtil.contains(statuses, eventoAgenda.getStatus())) {
                list = null;

                break;
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_USERRESPONSAVELID_5);

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RESPONSAVELID_STATUS_5);

                if ((i + 1) < statuses.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(EventoAgendaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            qPos.add(userResponsavelId);

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

            if (!pagination) {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = new UnmodifiableList<EventoAgenda>(list);
            } else {
                list = (List<EventoAgenda>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELID, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RESPONSAVELID, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of evento agendas where companyId = &#63; and groupId = &#63; and userResponsavelId = &#63; and status = any &#63;.
 *
 * @param companyId the company ID//from ww  w. j av  a2  s.  com
 * @param groupId the group ID
 * @param userResponsavelId the user responsavel ID
 * @param statuses the statuses
 * @return the number of matching evento agendas
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCG_ResponsavelId(long companyId, long groupId, long userResponsavelId, int[] statuses)
        throws SystemException {
    Object[] finderArgs = new Object[] { companyId, groupId, userResponsavelId, StringUtil.merge(statuses) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELID,
            finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_EVENTOAGENDA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RESPONSAVELID_USERRESPONSAVELID_5);

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RESPONSAVELID_STATUS_5);

                if ((i + 1) < statuses.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);

            qPos.add(companyId);

            qPos.add(groupId);

            qPos.add(userResponsavelId);

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

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELID, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RESPONSAVELID, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the lojas where companyId = &#63; and groupId = &#63; and razaoSocial LIKE &#63; and status = any &#63;.
 *
 * <p>/*from   ww  w.  j  av a2 s. c om*/
 * 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 br.com.prodevelopment.lapidarios.loja.model.impl.LojaModelImpl}. 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 companyId the company ID
 * @param groupId the group ID
 * @param razaoSocial the razao social
 * @param statuses the statuses
 * @param start the lower bound of the range of lojas
 * @param end the upper bound of the range of lojas (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching lojas
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Loja> findByCG_RazaoSocial(long companyId, long groupId, String razaoSocial, int[] statuses,
        int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if ((statuses != null) && (statuses.length == 1)) {
        return findByCG_RazaoSocial(companyId, groupId, razaoSocial, statuses[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[] { companyId, groupId, razaoSocial, StringUtil.merge(statuses) };
    } else {
        finderArgs = new Object[] { companyId, groupId, razaoSocial, StringUtil.merge(statuses),

                start, end, orderByComparator };
    }

    List<Loja> list = (List<Loja>) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RAZAOSOCIAL,
            finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
        for (Loja loja : list) {
            if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId())
                    || !StringUtil.wildcardMatches(loja.getRazaoSocial(), razaoSocial, CharPool.UNDERLINE,
                            CharPool.PERCENT, CharPool.BACK_SLASH, true)
                    || !ArrayUtil.contains(statuses, loja.getStatus())) {
                list = null;

                break;
            }
        }
    }

    if (list == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_SELECT_LOJA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindRazaoSocial = false;

        if (razaoSocial == null) {
            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_4);
        } else if (razaoSocial.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_6);
        } else {
            bindRazaoSocial = true;

            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_STATUS_5);

                if ((i + 1) < statuses.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(LojaModelImpl.ORDER_BY_JPQL);
        }

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindRazaoSocial) {
                qPos.add(razaoSocial);
            }

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

            if (!pagination) {
                list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end, false);

                Collections.sort(list);

                list = new UnmodifiableList<Loja>(list);
            } else {
                list = (List<Loja>) QueryUtil.list(q, getDialect(), start, end);
            }

            cacheResult(list);

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RAZAOSOCIAL, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_RAZAOSOCIAL, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return list;
}

From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of lojas where companyId = &#63; and groupId = &#63; and razaoSocial LIKE &#63; and status = any &#63;.
 *
 * @param companyId the company ID//from  w  w  w  .  j  a va2 s . c  o m
 * @param groupId the group ID
 * @param razaoSocial the razao social
 * @param statuses the statuses
 * @return the number of matching lojas
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByCG_RazaoSocial(long companyId, long groupId, String razaoSocial, int[] statuses)
        throws SystemException {
    Object[] finderArgs = new Object[] { companyId, groupId, razaoSocial, StringUtil.merge(statuses) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RAZAOSOCIAL,
            finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_LOJA_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_COMPANYID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        boolean bindRazaoSocial = false;

        if (razaoSocial == null) {
            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_4);
        } else if (razaoSocial.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_6);
        } else {
            bindRazaoSocial = true;

            query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_RAZAOSOCIAL_5);
        }

        conjunctionable = true;

        if ((statuses == null) || (statuses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < statuses.length; i++) {
                query.append(_FINDER_COLUMN_CG_RAZAOSOCIAL_STATUS_5);

                if ((i + 1) < statuses.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);

            qPos.add(companyId);

            qPos.add(groupId);

            if (bindRazaoSocial) {
                qPos.add(razaoSocial);
            }

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

            count = (Long) q.uniqueResult();

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RAZAOSOCIAL, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_RAZAOSOCIAL, finderArgs);

            throw processException(e);
        } finally {
            closeSession(session);
        }
    }

    return count.intValue();
}