List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceContainerPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, ApplicationInstanceContainer> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww . j a v a 2 s. com Map<Serializable, ApplicationInstanceContainer> map = new HashMap<Serializable, ApplicationInstanceContainer>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ApplicationInstanceContainer applicationInstanceContainer = fetchByPrimaryKey(primaryKey); if (applicationInstanceContainer != null) { map.put(primaryKey, applicationInstanceContainer); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { ApplicationInstanceContainer applicationInstanceContainer = (ApplicationInstanceContainer) entityCache .getResult(ApplicationInstanceContainerModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceContainerImpl.class, primaryKey); if (applicationInstanceContainer == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, applicationInstanceContainer); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_APPLICATIONINSTANCECONTAINER_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (ApplicationInstanceContainer applicationInstanceContainer : (List<ApplicationInstanceContainer>) q .list()) { map.put(applicationInstanceContainer.getPrimaryKeyObj(), applicationInstanceContainer); cacheResult(applicationInstanceContainer); uncachedPrimaryKeys.remove(applicationInstanceContainer.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ApplicationInstanceContainerModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceContainerImpl.class, primaryKey, _nullApplicationInstanceContainer); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, ApplicationInstance> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j a va 2s . c om*/ Map<Serializable, ApplicationInstance> map = new HashMap<Serializable, ApplicationInstance>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ApplicationInstance applicationInstance = fetchByPrimaryKey(primaryKey); if (applicationInstance != null) { map.put(primaryKey, applicationInstance); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { ApplicationInstance applicationInstance = (ApplicationInstance) entityCache.getResult( ApplicationInstanceModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceImpl.class, primaryKey); if (applicationInstance == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, applicationInstance); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_APPLICATIONINSTANCE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (ApplicationInstance applicationInstance : (List<ApplicationInstance>) q.list()) { map.put(applicationInstance.getPrimaryKeyObj(), applicationInstance); cacheResult(applicationInstance); uncachedPrimaryKeys.remove(applicationInstance.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ApplicationInstanceModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceImpl.class, primaryKey, _nullApplicationInstance); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePortPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, ApplicationInstancePort> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w. j a v a 2s . c o m Map<Serializable, ApplicationInstancePort> map = new HashMap<Serializable, ApplicationInstancePort>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ApplicationInstancePort applicationInstancePort = fetchByPrimaryKey(primaryKey); if (applicationInstancePort != null) { map.put(primaryKey, applicationInstancePort); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { ApplicationInstancePort applicationInstancePort = (ApplicationInstancePort) entityCache.getResult( ApplicationInstancePortModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstancePortImpl.class, primaryKey); if (applicationInstancePort == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, applicationInstancePort); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_APPLICATIONINSTANCEPORT_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (ApplicationInstancePort applicationInstancePort : (List<ApplicationInstancePort>) q.list()) { map.put(applicationInstancePort.getPrimaryKeyObj(), applicationInstancePort); cacheResult(applicationInstancePort); uncachedPrimaryKeys.remove(applicationInstancePort.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ApplicationInstancePortModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstancePortImpl.class, primaryKey, _nullApplicationInstancePort); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceStatusPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, ApplicationInstanceStatus> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww. j av a2s . c o m*/ Map<Serializable, ApplicationInstanceStatus> map = new HashMap<Serializable, ApplicationInstanceStatus>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ApplicationInstanceStatus applicationInstanceStatus = fetchByPrimaryKey(primaryKey); if (applicationInstanceStatus != null) { map.put(primaryKey, applicationInstanceStatus); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { ApplicationInstanceStatus applicationInstanceStatus = (ApplicationInstanceStatus) entityCache.getResult( ApplicationInstanceStatusModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceStatusImpl.class, primaryKey); if (applicationInstanceStatus == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, applicationInstanceStatus); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_APPLICATIONINSTANCESTATUS_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (ApplicationInstanceStatus applicationInstanceStatus : (List<ApplicationInstanceStatus>) q.list()) { map.put(applicationInstanceStatus.getPrimaryKeyObj(), applicationInstanceStatus); cacheResult(applicationInstanceStatus); uncachedPrimaryKeys.remove(applicationInstanceStatus.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ApplicationInstanceStatusModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceStatusImpl.class, primaryKey, _nullApplicationInstanceStatus); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryDictionaryLinkPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DictionaryDictionaryLink> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*www. ja v a 2s. c o m*/ Map<Serializable, DictionaryDictionaryLink> map = new HashMap<Serializable, DictionaryDictionaryLink>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DictionaryDictionaryLink dictionaryDictionaryLink = fetchByPrimaryKey(primaryKey); if (dictionaryDictionaryLink != null) { map.put(primaryKey, dictionaryDictionaryLink); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { DictionaryDictionaryLink dictionaryDictionaryLink = (DictionaryDictionaryLink) entityCache.getResult( DictionaryDictionaryLinkModelImpl.ENTITY_CACHE_ENABLED, DictionaryDictionaryLinkImpl.class, primaryKey); if (dictionaryDictionaryLink == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, dictionaryDictionaryLink); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DICTIONARYDICTIONARYLINK_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (DictionaryDictionaryLink dictionaryDictionaryLink : (List<DictionaryDictionaryLink>) q.list()) { map.put(dictionaryDictionaryLink.getPrimaryKeyObj(), dictionaryDictionaryLink); cacheResult(dictionaryDictionaryLink); uncachedPrimaryKeys.remove(dictionaryDictionaryLink.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DictionaryDictionaryLinkModelImpl.ENTITY_CACHE_ENABLED, DictionaryDictionaryLinkImpl.class, primaryKey, _nullDictionaryDictionaryLink); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Dictionary> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// www .j a v a2s. com Map<Serializable, Dictionary> map = new HashMap<Serializable, Dictionary>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Dictionary dictionary = fetchByPrimaryKey(primaryKey); if (dictionary != null) { map.put(primaryKey, dictionary); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Dictionary dictionary = (Dictionary) entityCache.getResult(DictionaryModelImpl.ENTITY_CACHE_ENABLED, DictionaryImpl.class, primaryKey); if (dictionary == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, dictionary); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DICTIONARY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Dictionary dictionary : (List<Dictionary>) q.list()) { map.put(dictionary.getPrimaryKeyObj(), dictionary); cacheResult(dictionary); uncachedPrimaryKeys.remove(dictionary.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DictionaryModelImpl.ENTITY_CACHE_ENABLED, DictionaryImpl.class, primaryKey, _nullDictionary); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:blade.servicebuilder.service.persistence.impl.FooPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Foo> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww. ja v a 2 s. c om Map<Serializable, Foo> map = new HashMap<Serializable, Foo>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Foo foo = fetchByPrimaryKey(primaryKey); if (foo != null) { map.put(primaryKey, foo); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Foo foo = (Foo) entityCache.getResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey); if (foo == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, foo); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_FOO_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Foo foo : (List<Foo>) q.list()) { map.put(foo.getPrimaryKeyObj(), foo); cacheResult(foo); uncachedPrimaryKeys.remove(foo.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, primaryKey, _nullFoo); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
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 status = any ?. * * <p>//from w w 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.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 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(long companyId, long groupId, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG(companyId, groupId, 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, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (EventoAgenda eventoAgenda : list) { if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId()) || !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_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_GROUPID_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_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 (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, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG, 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 = ? and groupId = ? and status = any ?. * * @param companyId the company ID//from ww w.j a va2 s. co m * @param groupId the group ID * @param statuses the statuses * @return the number of matching evento agendas * @throws SystemException if a system exception occurred */ @Override public int countByCG(long companyId, long groupId, int[] statuses) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG, 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_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_GROUPID_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_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 (statuses != null) { qPos.add(statuses); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CG, 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 = ? and groupId = ? and dataEvento = ? and status = any ?. * * <p>//from w w w .j av a2 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 dataEvento the data evento * @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_Data(long companyId, long groupId, Date dataEvento, int[] statuses, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((statuses != null) && (statuses.length == 1)) { return findByCG_Data(companyId, groupId, dataEvento, 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, dataEvento, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { companyId, groupId, dataEvento, StringUtil.merge(statuses), start, end, orderByComparator }; } List<EventoAgenda> list = (List<EventoAgenda>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (EventoAgenda eventoAgenda : list) { if ((companyId != eventoAgenda.getCompanyId()) || (groupId != eventoAgenda.getGroupId()) || !Validator.equals(dataEvento, eventoAgenda.getDataEvento()) || !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_DATA_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CG_DATA_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } boolean bindDataEvento = false; if (dataEvento == null) { query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_4); } else { bindDataEvento = true; query.append(_FINDER_COLUMN_CG_DATA_DATAEVENTO_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_DATA_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 (bindDataEvento) { qPos.add(CalendarUtil.getTimestamp(dataEvento)); } 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_DATA, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CG_DATA, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }