List of usage examples for org.apache.ibatis.session RowBounds RowBounds
public RowBounds(int offset, int limit)
From source file:org.alfresco.repo.domain.subscriptions.ibatis.SubscriptionsDAOImpl.java
License:Open Source License
@Override public PagingSubscriptionResults selectSubscriptions(String userId, SubscriptionItemTypeEnum type, PagingRequest pagingRequest) {/*w w w .j ava 2s . c om*/ if (userId == null) { throw new IllegalArgumentException("User Id may not be null!"); } if (type == null) { throw new IllegalArgumentException("Type may not be null!"); } NodeRef userNodeRef = getUserNodeRef(userId); if (userNodeRef == null) { throw new IllegalArgumentException("User does not exist!"); } Long dbid = (Long) nodeService.getProperty(userNodeRef, PROP_SYS_NODE_DBID); Map<String, Object> map = new HashMap<String, Object>(); map.put("userNodeId", dbid); int maxItems = (pagingRequest.getMaxItems() < 0 || pagingRequest.getMaxItems() > Integer.MAX_VALUE - 1 ? Integer.MAX_VALUE - 1 : pagingRequest.getMaxItems() + 1); @SuppressWarnings("unchecked") List<SubscriptionNodeEntity> nodeList = template.selectList("alfresco.subscriptions.select_Subscriptions", map, new RowBounds(pagingRequest.getSkipCount(), maxItems + 1)); boolean hasMore = nodeList.size() > maxItems; List<NodeRef> result = new ArrayList<NodeRef>(nodeList.size()); for (SubscriptionNodeEntity sne : nodeList) { result.add(sne.getNodeRef()); if (result.size() == pagingRequest.getMaxItems()) { break; } } Integer totalCount = null; if (pagingRequest.getRequestTotalCountMax() > 0) { totalCount = countSubscriptions(userId, type); } return new PagingSubscriptionResultsImpl(result, hasMore, totalCount); }
From source file:org.alfresco.repo.domain.subscriptions.ibatis.SubscriptionsDAOImpl.java
License:Open Source License
@Override public PagingFollowingResults selectFollowing(String userId, PagingRequest pagingRequest) { if (userId == null) { throw new IllegalArgumentException("User Id may not be null!"); }// ww w . j a va 2 s. c o m NodeRef userNodeRef = getUserNodeRef(userId); if (userNodeRef == null) { throw new IllegalArgumentException("User does not exist!"); } Long dbid = (Long) nodeService.getProperty(userNodeRef, PROP_SYS_NODE_DBID); Map<String, Object> map = new HashMap<String, Object>(); Pair<Long, QName> qNamePair = qnameDAO.getQName(ContentModel.PROP_USERNAME); if (null != qNamePair) { map.put("userIdQname", qNamePair.getFirst()); } map.put("userNodeId", dbid); int maxItems = (pagingRequest.getMaxItems() < 0 || pagingRequest.getMaxItems() > Integer.MAX_VALUE - 1 ? Integer.MAX_VALUE - 1 : pagingRequest.getMaxItems() + 1); @SuppressWarnings("unchecked") List<String> userList = template.selectList("alfresco.subscriptions.select_Following", map, new RowBounds(pagingRequest.getSkipCount(), maxItems + 1)); boolean hasMore = userList.size() > maxItems; if (hasMore && userList.size() > 0) { userList.remove(userList.size() - 1); } Integer totalCount = null; if (pagingRequest.getRequestTotalCountMax() > 0) { totalCount = countSubscriptions(userId, SubscriptionItemTypeEnum.USER); } return new PagingFollowingResultsImpl(userList, hasMore, totalCount); }
From source file:org.alfresco.repo.domain.subscriptions.ibatis.SubscriptionsDAOImpl.java
License:Open Source License
@Override public PagingFollowingResults selectFollowers(String userId, PagingRequest pagingRequest) { if (userId == null) { throw new IllegalArgumentException("User Id may not be null!"); }//from ww w .j a va 2 s . c o m NodeRef userNodeRef = getUserNodeRef(userId); if (userNodeRef == null) { throw new IllegalArgumentException("User does not exist!"); } Long dbid = (Long) nodeService.getProperty(userNodeRef, PROP_SYS_NODE_DBID); Map<String, Object> map = new HashMap<String, Object>(); Pair<Long, QName> qNamePair = qnameDAO.getQName(ContentModel.PROP_USERNAME); if (null != qNamePair) { map.put("userIdQname", qNamePair.getFirst()); } map.put("userNodeId", dbid); int maxItems = (pagingRequest.getMaxItems() < 0 || pagingRequest.getMaxItems() > Integer.MAX_VALUE - 1 ? Integer.MAX_VALUE - 1 : pagingRequest.getMaxItems() + 1); @SuppressWarnings("unchecked") List<String> userList = template.selectList("alfresco.subscriptions.select_Followers", map, new RowBounds(pagingRequest.getSkipCount(), maxItems + 1)); boolean hasMore = userList.size() > maxItems; if (hasMore && userList.size() > 0) { userList.remove(userList.size() - 1); } Integer totalCount = null; if (pagingRequest.getRequestTotalCountMax() > 0) { totalCount = countFollowers(userId); } return new PagingFollowingResultsImpl(userList, hasMore, totalCount); }
From source file:org.camunda.bpm.engine.impl.persistence.entity.TableDataManager.java
License:Apache License
@SuppressWarnings("unchecked") public TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults) { TablePage tablePage = new TablePage(); @SuppressWarnings("rawtypes") List tableData = getDbSqlSession().getSqlSession().selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults)); tablePage.setTableName(tablePageQuery.getTableName()); tablePage.setTotal(getTableCount(tablePageQuery.getTableName())); tablePage.setRows(tableData);// w w w .j a va2 s . com tablePage.setFirstResult(firstResult); return tablePage; }
From source file:org.flowable.engine.impl.persistence.entity.TableDataManagerImpl.java
License:Apache License
@Override @SuppressWarnings("unchecked") public TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults) { TablePage tablePage = new TablePage(); @SuppressWarnings("rawtypes") List tableData = getDbSqlSession().getSqlSession().selectList( "org.flowable.engine.impl.TablePageMap.selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults)); tablePage.setTableName(tablePageQuery.getTableName()); tablePage.setTotal(getTableCount(tablePageQuery.getTableName())); tablePage.setRows((List<Map<String, Object>>) tableData); tablePage.setFirstResult(firstResult); return tablePage; }
From source file:org.focusns.dao.common.impl.MyBatisBaseDao.java
License:Open Source License
public Page<M> fetchPage(String selectId, Page<M> page, Map<String, Object> model) { ///*from w w w. j av a 2s . c om*/ if (page.isAutoCount()) { String countId = selectId.concat("Count"); long totalCount = fetchPageCount(countId, model); page.setTotalCount(totalCount); } // RowBounds rowBounds = new RowBounds(page.getFirst() - 1, page.getPageSize()); List<M> results = getSqlSession().selectList(NAMESPACE.concat(selectId), model, rowBounds); // return page.setResults(results); }
From source file:org.hx.rainbow.common.dao.impl.DaoMybatisImpl.java
License:Open Source License
public List<Map<String, Object>> query(String ds, String namespace, String statement, int limit, int offset) { RowBounds rowBounds = new RowBounds((offset - 1) * limit, limit); List<Map<String, Object>> dataList = getDao(ds) .<Map<String, Object>>selectList(changeStatement(namespace, statement), null, rowBounds); return dataList; }
From source file:org.hx.rainbow.common.dao.impl.DaoMybatisImpl.java
License:Open Source License
public List<Map<String, Object>> query(String ds, String namespace, String statement, Map<String, Object> paramData, int limit, int offset) { RowBounds rowBounds = new RowBounds((offset - 1) * limit, limit); List<Map<String, Object>> dataList = getDao(ds) .<Map<String, Object>>selectList(changeStatement(namespace, statement), paramData, rowBounds); return dataList; }
From source file:org.languagetool.server.DatabaseAccess.java
License:Open Source License
List<UserDictEntry> getWords(Long userId, int offset, int limit) { if (sqlSessionFactory == null) { return new ArrayList<>(); }//from ww w . ja v a2 s . com try (SqlSession session = sqlSessionFactory.openSession(true)) { Map<Object, Object> map = new HashMap<>(); map.put("userId", userId); return session.selectList("org.languagetool.server.UserDictMapper.selectWordList", map, new RowBounds(offset, limit)); } }
From source file:org.nebula.service.admin.GetHistoryEventsProcessor.java
License:Apache License
@Override protected GetHistoryEventsResponse processInternal(GetHistoryEventsRequest request) { String instanceId = request.getInstanceId(); RowBounds rowBounds = new RowBounds((request.getPageNo() - 1) * request.getPageSize(), request.getPageSize());/*from w w w . j a v a 2 s . c om*/ List<Event> pevents = historyEventMapper.findByInstanceIdByPage(rowBounds, instanceId); List<org.nebula.framework.event.Event> events = new ArrayList<org.nebula.framework.event.Event>(); String accessId = request.getAccessId(); if (!checkIfHasPrivilege(accessId, pevents)) { logger.warn("The user " + accessId + " doesn't has the instance " + instanceId); return createGetHistoryEventsResponse(events, request.getPageNo(), 0); } for (Event event : pevents) { org.nebula.framework.event.Event eve = (org.nebula.framework.event.Event) toObject(event.getData(), "org.nebula.framework.event." + event.getEventType()); eve.setEventId(event.getId()); eve.setPrecedingId(event.getPrecedingId()); events.add(eve); } return createGetHistoryEventsResponse(events, request.getPageNo(), historyEventMapper.countByInstanceId(instanceId)); }