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:com.liferay.document.library.repository.cmis.search.CMISConjunction.java
License:Open Source License
@Override public String toQueryFragment() { if (isEmpty()) { return StringPool.BLANK; }//from w w w.j a va 2 s . c o m List<CMISCriterion> cmisCriterions = list(); StringBundler sb = new StringBundler(cmisCriterions.size() * 2 + 1); if (cmisCriterions.size() > 1) { sb.append(StringPool.OPEN_PARENTHESIS); } for (int i = 0; i < cmisCriterions.size(); i++) { CMISCriterion cmisCriterion = cmisCriterions.get(i); if (i != 0) { sb.append(" AND "); } sb.append(cmisCriterion.toQueryFragment()); } if (cmisCriterions.size() > 1) { sb.append(StringPool.CLOSE_PARENTHESIS); } return sb.toString(); }
From source file:com.liferay.document.library.repository.cmis.search.CMISDisjunction.java
License:Open Source License
@Override public String toQueryFragment() { if (isEmpty()) { return StringPool.BLANK; }/*from w w w .j a v a 2 s .co m*/ List<CMISCriterion> cmisCriterions = list(); StringBundler sb = new StringBundler(cmisCriterions.size() * 2 + 1); if (cmisCriterions.size() > 1) { sb.append(StringPool.OPEN_PARENTHESIS); } for (int i = 0; i < cmisCriterions.size(); i++) { CMISCriterion cmisCriterion = cmisCriterions.get(i); if (i != 0) { sb.append(" OR "); } sb.append(cmisCriterion.toQueryFragment()); } if (cmisCriterions.size() > 1) { sb.append(StringPool.CLOSE_PARENTHESIS); } return sb.toString(); }
From source file:com.liferay.document.library.repository.cmis.search.CMISFullTextConjunction.java
License:Open Source License
@Override public String toQueryFragment() { if (isEmpty()) { return StringPool.BLANK; }//from ww w .jav a 2 s .com List<CMISCriterion> cmisCriterions = list(); StringBundler sb = new StringBundler(cmisCriterions.size() * 2 + 1); if (cmisCriterions.size() > 1) { sb.append(StringPool.OPEN_PARENTHESIS); } for (int i = 0; i < cmisCriterions.size(); i++) { CMISCriterion cmisCriterion = cmisCriterions.get(i); if (i != 0) { sb.append(" "); } sb.append(cmisCriterion.toQueryFragment()); } if (cmisCriterions.size() > 1) { sb.append(StringPool.CLOSE_PARENTHESIS); } return sb.toString(); }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DDLRecord> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from ww w. j a v a2 s . c o m*/ Map<Serializable, DDLRecord> map = new HashMap<Serializable, DDLRecord>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DDLRecord ddlRecord = fetchByPrimaryKey(primaryKey); if (ddlRecord != null) { map.put(primaryKey, ddlRecord); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(DDLRecordModelImpl.ENTITY_CACHE_ENABLED, DDLRecordImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (DDLRecord) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DDLRECORD_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 (DDLRecord ddlRecord : (List<DDLRecord>) q.list()) { map.put(ddlRecord.getPrimaryKeyObj(), ddlRecord); cacheResult(ddlRecord); uncachedPrimaryKeys.remove(ddlRecord.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DDLRecordModelImpl.ENTITY_CACHE_ENABLED, DDLRecordImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the ddl record sets that the user has permission to view where groupId = any ?. * * <p>// w w w . j a v a 2 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDLRecordSetModelImpl}. 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 groupIds the group IDs * @param start the lower bound of the range of ddl record sets * @param end the upper bound of the range of ddl record sets (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching ddl record sets that the user has permission to view */ @Override public List<DDLRecordSet> filterFindByGroupId(long[] groupIds, int start, int end, OrderByComparator<DDLRecordSet> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return findByGroupId(groupIds, start, end, orderByComparator); } if (groupIds == null) { groupIds = new long[0]; } else if (groupIds.length > 1) { groupIds = ArrayUtil.unique(groupIds); Arrays.sort(groupIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_DDLRECORDSET_WHERE); } else { query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_1); } if (groupIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_GROUPID_GROUPID_7); query.append(StringUtil.merge(groupIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_DDLRECORDSET_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(DDLRecordSetModelImpl.ORDER_BY_JPQL); } else { query.append(DDLRecordSetModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DDLRecordSet.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, DDLRecordSetImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, DDLRecordSetImpl.class); } return (List<DDLRecordSet>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the ddl record sets where groupId = ?, optionally using the finder cache. * * <p>// w w w.j ava 2 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DDLRecordSetModelImpl}. 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 groupId the group ID * @param start the lower bound of the range of ddl record sets * @param end the upper bound of the range of ddl record sets (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching ddl record sets */ @Override public List<DDLRecordSet> findByGroupId(long[] groupIds, int start, int end, OrderByComparator<DDLRecordSet> orderByComparator, boolean retrieveFromCache) { if (groupIds == null) { groupIds = new long[0]; } else if (groupIds.length > 1) { groupIds = ArrayUtil.unique(groupIds); Arrays.sort(groupIds); } if (groupIds.length == 1) { return findByGroupId(groupIds[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[] { StringUtil.merge(groupIds) }; } else { finderArgs = new Object[] { StringUtil.merge(groupIds), start, end, orderByComparator }; } List<DDLRecordSet> list = null; if (retrieveFromCache) { list = (List<DDLRecordSet>) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (DDLRecordSet ddlRecordSet : list) { if (!ArrayUtil.contains(groupIds, ddlRecordSet.getGroupId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_DDLRECORDSET_WHERE); if (groupIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_GROUPID_GROUPID_7); query.append(StringUtil.merge(groupIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(DDLRecordSetModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<DDLRecordSet>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<DDLRecordSet>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java
License:Open Source License
/** * Returns the number of ddl record sets where groupId = any ?. * * @param groupIds the group IDs//from w ww .j a va 2s . c om * @return the number of matching ddl record sets */ @Override public int countByGroupId(long[] groupIds) { if (groupIds == null) { groupIds = new long[0]; } else if (groupIds.length > 1) { groupIds = ArrayUtil.unique(groupIds); Arrays.sort(groupIds); } Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) }; Long count = (Long) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_DDLRECORDSET_WHERE); if (groupIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_GROUPID_GROUPID_7); query.append(StringUtil.merge(groupIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); count = (Long) q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java
License:Open Source License
/** * Returns the number of ddl record sets that the user has permission to view where groupId = any ?. * * @param groupIds the group IDs//from w ww . j av a 2s. c om * @return the number of matching ddl record sets that the user has permission to view */ @Override public int filterCountByGroupId(long[] groupIds) { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return countByGroupId(groupIds); } if (groupIds == null) { groupIds = new long[0]; } else if (groupIds.length > 1) { groupIds = ArrayUtil.unique(groupIds); Arrays.sort(groupIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_DDLRECORDSET_WHERE); if (groupIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_GROUPID_GROUPID_7); query.append(StringUtil.merge(groupIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DDLRecordSet.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DDLRecordSet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w w w . ja v a 2 s.com Map<Serializable, DDLRecordSet> map = new HashMap<Serializable, DDLRecordSet>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DDLRecordSet ddlRecordSet = fetchByPrimaryKey(primaryKey); if (ddlRecordSet != null) { map.put(primaryKey, ddlRecordSet); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED, DDLRecordSetImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (DDLRecordSet) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DDLRECORDSET_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 (DDLRecordSet ddlRecordSet : (List<DDLRecordSet>) q.list()) { map.put(ddlRecordSet.getPrimaryKeyObj(), ddlRecordSet); cacheResult(ddlRecordSet); uncachedPrimaryKeys.remove(ddlRecordSet.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DDLRecordSetModelImpl.ENTITY_CACHE_ENABLED, DDLRecordSetImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordSetVersionPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DDLRecordSetVersion> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w .j a v a 2 s .com Map<Serializable, DDLRecordSetVersion> map = new HashMap<Serializable, DDLRecordSetVersion>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DDLRecordSetVersion ddlRecordSetVersion = fetchByPrimaryKey(primaryKey); if (ddlRecordSetVersion != null) { map.put(primaryKey, ddlRecordSetVersion); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(DDLRecordSetVersionModelImpl.ENTITY_CACHE_ENABLED, DDLRecordSetVersionImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (DDLRecordSetVersion) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DDLRECORDSETVERSION_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long) 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 (DDLRecordSetVersion ddlRecordSetVersion : (List<DDLRecordSetVersion>) q.list()) { map.put(ddlRecordSetVersion.getPrimaryKeyObj(), ddlRecordSetVersion); cacheResult(ddlRecordSetVersion); uncachedPrimaryKeys.remove(ddlRecordSetVersion.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DDLRecordSetVersionModelImpl.ENTITY_CACHE_ENABLED, DDLRecordSetVersionImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }