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