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
9 import org.collectionspace.services.lifecycle.Lifecycle;
\r
11 public abstract class JpaDocumentHandler<T, TL, WT, WLT>
\r
12 extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{
\r
15 * Extract paging info.
\r
17 * @param commonsList the commons list
\r
19 * @throws Exception the exception
\r
21 public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
\r
23 AbstractCommonList commonList = (AbstractCommonList) theCommonList;
\r
25 DocumentFilter docFilter = this.getDocumentFilter();
\r
26 long pageSize = docFilter.getPageSize();
\r
27 long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
\r
28 // set the page size and page number
\r
29 commonList.setPageNum(pageNum);
\r
30 commonList.setPageSize(pageSize);
\r
31 List docList = (List)wrapDoc.getWrappedObject();
\r
32 // Set num of items in list. this is useful to our testing framework.
\r
33 commonList.setItemsInPage(docList.size());
\r
34 // set the total result size
\r
35 commonList.setTotalItems(docList.size());
\r
37 return (TL) commonList;
\r
40 public Lifecycle getLifecycle() {
\r
41 return null; // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
\r