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:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the lojas where companyId = ? and groupId = ? and nomeFantasia LIKE ? and status = any ?. * * <p>//from www . java2 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 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 nomeFantasia the nome fantasia * @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_NomeFantasia(long companyId, long groupId, String nomeFantasia, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_NomeFantasia(companyId, groupId, nomeFantasia, 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, nomeFantasia, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, nomeFantasia, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_NOMEFANTASIA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || !StringUtil.wildcardMatches(loja.getNomeFantasia(), nomeFantasia, 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_NOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_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_NOMEFANTASIA_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 (bindNomeFantasia) { qPos.add(nomeFantasia); } 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_NOMEFANTASIA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_NOMEFANTASIA, 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 = ? and groupId = ? and nomeFantasia LIKE ? and status = any ?. * * @param companyId the company ID// ww w.j a va2 s . c o m * @param groupId the group ID * @param nomeFantasia the nome fantasia * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_NomeFantasia(long companyId, long groupId, String nomeFantasia, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, nomeFantasia, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_NOMEFANTASIA, 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_NOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_NOMEFANTASIA_NOMEFANTASIA_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_NOMEFANTASIA_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 (bindNomeFantasia) { qPos.add(nomeFantasia); } if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_NOMEFANTASIA, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_NOMEFANTASIA, 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 the number of lojas where companyId = ? and groupId = ? and cnpj = ? and status = any ?. * * @param companyId the company ID//from w w w .j a v a 2s . c o m * @param groupId the group ID * @param cnpj the cnpj * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_CNPJ(long companyId, long groupId, String cnpj, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, cnpj, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CNPJ, 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_CNPJ_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CNPJ_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindCnpj = false; if (cnpj == null) { query.append(_FINDER_COLUMN_CG_CNPJ_CNPJ_4); } else if (cnpj.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_CNPJ_CNPJ_6); } else { bindCnpj = true; query.append(_FINDER_COLUMN_CG_CNPJ_CNPJ_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_CNPJ_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 (bindCnpj) { qPos.add(cnpj); } if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CNPJ, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CNPJ, 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 = ? and groupId = ? and ordemIndicada = ? and status = any ?. * * <p>// w ww .j a va2 s .co 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.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 ordemIndicada the ordem indicada * @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_OrdemIndicada(long companyId, long groupId, int ordemIndicada, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_OrdemIndicada(companyId, groupId, ordemIndicada, 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, ordemIndicada, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, ordemIndicada, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_ORDEMINDICADA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (ordemIndicada != loja.getOrdemIndicada()) || !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_ORDEMINDICADA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_ORDEMINDICADA_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_ORDEMINDICADA_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); qPos.add(ordemIndicada); 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_ORDEMINDICADA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_ORDEMINDICADA, 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 = ? and groupId = ? and ordemIndicada = ? and status = any ?. * * @param companyId the company ID/*from w w w . ja v a 2s. co m*/ * @param groupId the group ID * @param ordemIndicada the ordem indicada * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_OrdemIndicada(long companyId, long groupId, int ordemIndicada, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, ordemIndicada, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, 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_ORDEMINDICADA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADA_ORDEMINDICADA_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_ORDEMINDICADA_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(ordemIndicada); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADA, 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 the number of lojas where companyId = ? and groupId = ? and ordemIndicadaAtual = ? and status = any ?. * * @param companyId the company ID/*from w w w . j ava 2 s . co m*/ * @param groupId the group ID * @param ordemIndicadaAtual the ordem indicada atual * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_OrdemIndicadaAtual(long companyId, long groupId, boolean ordemIndicadaAtual, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, ordemIndicadaAtual, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, 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_ORDEMINDICADAATUAL_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_ORDEMINDICADAATUAL_ORDEMINDICADAATUAL_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_ORDEMINDICADAATUAL_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(ordemIndicadaAtual); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_ORDEMINDICADAATUAL, 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 = ? and groupId = ? and classNameId = ? and status = any ?. * * <p>//from ww w .ja va 2s . 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.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 classNameId the class name ID * @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_ClassName(long companyId, long groupId, long classNameId, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_ClassName(companyId, groupId, classNameId, 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, classNameId, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, classNameId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAME, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (classNameId != loja.getClassNameId()) || !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_CLASSNAME_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_CLASSNAMEID_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_CLASSNAME_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); qPos.add(classNameId); 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_CLASSNAME, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAME, 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 = ? and groupId = ? and classNameId = ? and status = any ?. * * @param companyId the company ID//from w ww . ja va2 s . c o m * @param groupId the group ID * @param classNameId the class name ID * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_ClassName(long companyId, long groupId, long classNameId, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, classNameId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, 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_CLASSNAME_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAME_CLASSNAMEID_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_CLASSNAME_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(classNameId); if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAME, 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 = ? and groupId = ? and classNameId = ? and nomeFantasia LIKE ? and status = any ?. * * <p>/* w w w. ja v 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.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 classNameId the class name ID * @param nomeFantasia the nome fantasia * @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_ClassNameNomeFantasia(long companyId, long groupId, long classNameId, String nomeFantasia, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_ClassNameNomeFantasia(companyId, groupId, classNameId, nomeFantasia, 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, classNameId, nomeFantasia, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, classNameId, nomeFantasia, StringUtil.merge(statuses), start, end, orderByComparator }; } List<Loja> list = (List<Loja>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Loja loja : list) { if ((companyId != loja.getCompanyId()) || (groupId != loja.getGroupId()) || (classNameId != loja.getClassNameId()) || !StringUtil.wildcardMatches(loja.getNomeFantasia(), nomeFantasia, 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_CLASSNAMENOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_CLASSNAMEID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_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_CLASSNAMENOMEFANTASIA_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); qPos.add(classNameId); if (bindNomeFantasia) { qPos.add(nomeFantasia); } 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_CLASSNAMENOMEFANTASIA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_CLASSNAMENOMEFANTASIA, 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 = ? and groupId = ? and classNameId = ? and nomeFantasia LIKE ? and status = any ?. * * @param companyId the company ID/*from w w w . j a v a 2s. c o m*/ * @param groupId the group ID * @param classNameId the class name ID * @param nomeFantasia the nome fantasia * @param statuses the statuses * @return the number of matching lojas * @throws SystemException if a system exception occurred */ @Override public int countByCG_ClassNameNomeFantasia(long companyId, long groupId, long classNameId, String nomeFantasia, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, classNameId, nomeFantasia, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, 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_CLASSNAMENOMEFANTASIA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_CLASSNAMEID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindNomeFantasia = false; if (nomeFantasia == null) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_4); } else if (nomeFantasia.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_6); } else { bindNomeFantasia = true; query.append(_FINDER_COLUMN_CG_CLASSNAMENOMEFANTASIA_NOMEFANTASIA_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_CLASSNAMENOMEFANTASIA_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(classNameId); if (bindNomeFantasia) { qPos.add(nomeFantasia); } if (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG_CLASSNAMENOMEFANTASIA, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }