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