1 package org.collectionspace.services.common.storage.jpa;
\r
3 import java.util.List;
\r
5 import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
\r
6 import org.collectionspace.services.common.document.DocumentFilter;
\r
7 import org.collectionspace.services.common.document.DocumentWrapper;
\r
8 import org.collectionspace.services.jaxb.AbstractCommonList;
\r
10 public abstract class JpaDocumentHandler<T, TL, WT, WLT>
\r
11 extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{
\r
14 * Extract paging info.
\r
16 * @param commonsList the commons list
\r
18 * @throws Exception the exception
\r
20 public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
\r
22 AbstractCommonList commonList = (AbstractCommonList) theCommonList;
\r
24 DocumentFilter docFilter = this.getDocumentFilter();
\r
25 long pageSize = docFilter.getPageSize();
\r
26 long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
\r
27 // set the page size and page number
\r
28 commonList.setPageNum(pageNum);
\r
29 commonList.setPageSize(pageSize);
\r
30 List docList = (List)wrapDoc.getWrappedObject();
\r
31 // Set num of items in list. this is useful to our testing framework.
\r
32 commonList.setItemsInPage(docList.size());
\r
33 // set the total result size
\r
34 commonList.setTotalItems(docList.size());
\r
36 return (TL) commonList;
\r