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