]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
cc495124d86e2bc3e978d1ddf00952d8d8a5913c
[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 import org.collectionspace.services.lifecycle.TransitionDef;\r
11 import org.nuxeo.ecm.core.api.DocumentModel;\r
12 \r
13 public abstract class JpaDocumentHandler<T, TL, WT, WLT>\r
14         extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{\r
15 \r
16     /**\r
17      * Extract paging info.\r
18      *\r
19      * @param commonsList the commons list\r
20      * @return the tL\r
21      * @throws Exception the exception\r
22      */\r
23     public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)\r
24             throws Exception {\r
25         AbstractCommonList commonList = (AbstractCommonList) theCommonList;\r
26 \r
27         DocumentFilter docFilter = this.getDocumentFilter();\r
28         long pageSize = docFilter.getPageSize();\r
29         long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;\r
30         // set the page size and page number\r
31         commonList.setPageNum(pageNum);\r
32         commonList.setPageSize(pageSize);\r
33         List docList = (List)wrapDoc.getWrappedObject();\r
34         // Set num of items in list. this is useful to our testing framework.\r
35         commonList.setItemsInPage(docList.size());\r
36         // set the total result size\r
37         commonList.setTotalItems(docList.size());\r
38 \r
39         return (TL) commonList;\r
40     }\r
41     \r
42     public Lifecycle getLifecycle(String docTypeName) {\r
43         Lifecycle result = new Lifecycle();\r
44         result.setName("Life cycles are not supported by the JPA-based services.");\r
45         return result; // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.\r
46     }\r
47     \r
48     @Override\r
49     public Lifecycle getLifecycle() {\r
50         return getLifecycle(null); // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.\r
51     }\r
52     \r
53         @Override\r
54         public void handleWorkflowTransition(\r
55                         DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)\r
56                         throws Exception {\r
57                 // Do nothing.  JPA document handlers do not support workflow transitions yet.\r
58         }\r
59     \r
60 }\r