List of usage examples for org.apache.ibatis.session RowBounds RowBounds
public RowBounds(int offset, int limit)
From source file:org.alfresco.repo.domain.activities.ibatis.ActivityPostDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ActivityPostEntity> selectPosts(ActivityPostEntity activityPost, int maxItems) throws SQLException { int rowLimit = maxItems < 0 ? RowBounds.NO_ROW_LIMIT : maxItems; RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit); if ((activityPost.getJobTaskNode() != -1) && (activityPost.getMinId() != -1) && (activityPost.getMaxId() != -1) && (activityPost.getStatus() != null)) { return template.selectList("alfresco.activities.select_activity_posts_by_params", activityPost, rowBounds);/*from ww w . j a v a 2 s.c om*/ } else if (activityPost.getStatus() != null) { return template.selectList("alfresco.activities.select_activity_posts_by_status", activityPost, rowBounds); } else { return new ArrayList<ActivityPostEntity>(0); } }
From source file:org.alfresco.repo.domain.audit.ibatis.AuditDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from w w w .j a va2 s .co m protected void findAuditEntries(final AuditQueryRowHandler rowHandler, boolean forward, String appName, String user, Long fromId, Long toId, Long fromTime, Long toTime, int maxResults, String searchKey, Serializable searchValue) { AuditQueryParameters params = new AuditQueryParameters(); if (appName != null) { // Look up the application's ID (this is unique) Pair<Long, Serializable> appNamePair = propertyValueDAO.getPropertyValue(appName); if (appNamePair == null) { // No such value return; } params.setAuditAppNameId(appNamePair.getFirst()); } if (user != null) { // Look up the application's ID (this is unique) Pair<Long, Serializable> userPair = propertyValueDAO.getPropertyValue(user); if (userPair == null) { // No such value return; } params.setAuditUserId(userPair.getFirst()); } params.setAuditFromId(fromId); params.setAuditToId(toId); params.setAuditFromTime(fromTime); params.setAuditToTime(toTime); if (searchKey != null) { // Look up the ID of the search key Pair<Long, Serializable> searchKeyPair = propertyValueDAO.getPropertyValue(searchKey); if (searchKeyPair == null) { // No such value return; } params.setSearchKeyId(searchKeyPair.getFirst()); } if (searchValue != null) { // Look up the ID of the search key Pair<Long, Serializable> searchValuePair = propertyValueDAO.getPropertyValue(searchValue); if (searchValuePair == null) { // No such value return; } params.setSearchValueId(searchValuePair.getFirst()); } params.setForward(forward); if (maxResults > 0) { // Query without getting the values. We gather all the results and batch-fetch the audited // values afterwards. final Map<Long, AuditQueryResult> resultsByValueId = new HashMap<Long, AuditQueryResult>(173); PropertyFinderCallback propertyFinderCallback = new PropertyFinderCallback() { public void handleProperty(Long id, Serializable value) { // get the row AuditQueryResult row = resultsByValueId.get(id); try { row.setAuditValue((Map<String, Serializable>) value); } catch (ClassCastException e) { // The handler will deal with the entry } } }; List<AuditQueryResult> rows = template.selectList(SELECT_ENTRIES_WITHOUT_VALUES, params, new RowBounds(0, maxResults)); for (AuditQueryResult row : rows) { resultsByValueId.put(row.getAuditValuesId(), row); if (resultsByValueId.size() >= 100) { // Fetch values for the results. The treemap is ordered. List<Long> valueIds = new ArrayList<Long>(resultsByValueId.keySet()); propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback); // Clear and continue resultsByValueId.clear(); } } // Process any remaining results if (resultsByValueId.size() > 0) { // Fetch values for the results. The treemap is ordered. List<Long> valueIds = new ArrayList<Long>(resultsByValueId.keySet()); propertyValueDAO.getPropertiesByIds(valueIds, propertyFinderCallback); } // Now pass the filled-out results to the row handler (order-preserved) for (AuditQueryResult row : rows) { rowHandler.processResult(row); } } else { throw new IllegalArgumentException("maxResults must be greater than 0"); } }
From source file:org.alfresco.repo.domain.contentdata.ibatis.ContentDataDAOImpl.java
License:Open Source License
@Override public void getContentUrlsOrphaned(final ContentUrlHandler contentUrlHandler, final Long maxOrphanTimeExclusive, final int maxResults) { ParameterCheck.mandatory("maxOrphanTimeExclusive", maxOrphanTimeExclusive); ContentUrlOrphanQuery query = new ContentUrlOrphanQuery(); query.setMaxOrphanTimeExclusive(maxOrphanTimeExclusive); List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_ORPHANED, query, new RowBounds(0, maxResults)); // Pass the result to the callback for (ContentUrlEntity result : results) { contentUrlHandler.handle(result.getId(), result.getContentUrl(), result.getOrphanTime()); }// ww w. j a v a 2 s .co m }
From source file:org.alfresco.repo.domain.contentdata.ibatis.ContentDataDAOImpl.java
License:Open Source License
@Override public void getContentUrlsKeepOrphaned(final ContentUrlHandler contentUrlHandler, final int maxResults) { List<ContentUrlEntity> results = template.selectList(SELECT_CONTENT_URLS_KEEP_ORPHANED, new RowBounds(0, maxResults)); // Pass the result to the callback for (ContentUrlEntity result : results) { contentUrlHandler.handle(result.getId(), result.getContentUrl(), result.getOrphanTime()); }// w w w . jav a2 s.c o m }
From source file:org.alfresco.repo.domain.contentdata.ibatis.ContentDataDAOImpl.java
License:Open Source License
@Override public List<ContentUrlKeyEntity> getSymmetricKeysByMasterKeyAlias(String masterKeyAlias, long fromId, int maxResults) { ContentUrlKeyEntity entity = new ContentUrlKeyEntity(); entity.setMasterKeyAlias(masterKeyAlias); entity.setId(fromId);// www . j a v a2 s. co m List<ContentUrlKeyEntity> results = template.selectList(SELECT_SYMMETRIC_KEYS_BY_MASTER_KEY, entity, new RowBounds(0, maxResults)); return results; }
From source file:org.alfresco.repo.domain.node.ibatis.NodeDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w w w. j a v a 2s.c o m*/ protected List<ChildAssocEntity> selectChildNodeIds(Long nodeId, Boolean isPrimary, Long minChildNodeIdInclusive, int maxResults) { ChildAssocEntity assoc = new ChildAssocEntity(); NodeEntity parentNode = new NodeEntity(); parentNode.setId(nodeId); NodeEntity childNode = new NodeEntity(); childNode.setId(minChildNodeIdInclusive); assoc.setParentNode(parentNode); assoc.setPrimary(isPrimary); assoc.setChildNode(childNode); RowBounds rowBounds = new RowBounds(0, maxResults); return template.selectList(SELECT_CHILD_NODE_IDS, assoc, rowBounds); }
From source file:org.alfresco.repo.domain.node.ibatis.NodeDAOImpl.java
License:Open Source License
@Override public void selectChildAssocs(Long parentNodeId, QName assocTypeQName, QName assocQName, final int maxResults, ChildAssocRefQueryCallback resultsCallback) { ChildAssocEntity assoc = new ChildAssocEntity(); // Parent//from w w w .j a va 2 s .co m NodeEntity parentNode = new NodeEntity(); parentNode.setId(parentNodeId); assoc.setParentNode(parentNode); // Type QName if (assocTypeQName != null) { if (!assoc.setTypeQNameAll(qnameDAO, assocTypeQName, false)) { resultsCallback.done(); return; // Shortcut } } // QName if (assocQName != null) { if (!assoc.setQNameAll(qnameDAO, assocQName, false)) { resultsCallback.done(); return; // Shortcut } } // Order assoc.setOrdered(resultsCallback.orderResults()); ChildAssocResultHandler resultHandler = new ChildAssocResultHandler(resultsCallback); RowBounds rowBounds = new RowBounds(0, maxResults); List<?> entities = template.selectList(SELECT_CHILD_ASSOCS_OF_PARENT_LIMITED, assoc, rowBounds); final DefaultResultContext resultContext = new DefaultResultContext(); for (Object entity : entities) { resultContext.nextResultObject(entity); resultHandler.handleResult(resultContext); } resultsCallback.done(); }
From source file:org.alfresco.repo.domain.node.ibatis.NodeDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w .j a va2 s .c o m protected Transaction selectLastTxnBeforeCommitTime(Long maxCommitTime) { Assert.notNull(maxCommitTime, "maxCommitTime"); TransactionQueryEntity query = new TransactionQueryEntity(); query.setMaxCommitTime(maxCommitTime); List<Transaction> txns = template.selectList(SELECT_TXN_LAST, query, new RowBounds(0, 1)); if (txns.size() > 0) { return txns.get(0); } else { return null; } }
From source file:org.alfresco.repo.domain.node.ibatis.NodeDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/* w w w . j a v a 2 s .com*/ protected List<Transaction> selectTxns(Long fromTimeInclusive, Long toTimeExclusive, Integer count, List<Long> includeTxnIds, List<Long> excludeTxnIds, Long excludeServerId, Boolean ascending) { TransactionQueryEntity query = new TransactionQueryEntity(); query.setMinCommitTime(fromTimeInclusive); query.setMaxCommitTime(toTimeExclusive); if ((includeTxnIds != null) && (includeTxnIds.size() > 0)) { query.setIncludeTxnIds(includeTxnIds); } if ((excludeTxnIds != null) && (excludeTxnIds.size() > 0)) { query.setExcludeTxnIds(excludeTxnIds); } query.setExcludeServerId(excludeServerId); query.setAscending(ascending); if (count == null) { return template.selectList(SELECT_TXNS, query); } else { return template.selectList(SELECT_TXNS, query, new RowBounds(0, count)); } }
From source file:org.alfresco.repo.domain.node.ibatis.NodeDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//w ww. j a v a 2s . c o m protected List<Long> selectTxnsUnused(Long minTxnId, Long maxCommitTime, Integer count) { TransactionQueryEntity query = new TransactionQueryEntity(); query.setMinId(minTxnId); query.setMaxCommitTime(maxCommitTime); if (count == null) { return template.selectList(SELECT_TXNS_UNUSED, query); } else { return template.selectList(SELECT_TXNS_UNUSED, query, new RowBounds(0, count)); } }