]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
27a1c3a6d64cf2a6b293c8b7ff820501b49f20ec
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.common.storage.jpa;\r
2 \r
3 import java.util.List;\r
4 \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
10 \r
11 public abstract class JpaDocumentHandler<T, TL, WT, WLT>\r
12         extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{\r
13 \r
14     /**\r
15      * Extract paging info.\r
16      *\r
17      * @param commonsList the commons list\r
18      * @return the tL\r
19      * @throws Exception the exception\r
20      */\r
21     public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)\r
22             throws Exception {\r
23         AbstractCommonList commonList = (AbstractCommonList) theCommonList;\r
24 \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
36 \r
37         return (TL) commonList;\r
38     }\r
39     \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
42     }\r
43 }\r