]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
152e12a494b43dba7425a0ce16ba8e0e9e49a7c8
[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     @Override
39         public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
40             throws Exception {
41         AbstractCommonList commonList = (AbstractCommonList) theCommonList;
42
43         DocumentFilter docFilter = this.getDocumentFilter();
44         long pageSize = docFilter.getPageSize();
45         long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
46         // set the page size and page number
47         commonList.setPageNum(pageNum);
48         commonList.setPageSize(pageSize);
49         List docList = (List)wrapDoc.getWrappedObject();
50         // Set num of items in list. this is useful to our testing framework.
51         commonList.setItemsInPage(docList.size());
52         // set the total result size
53         commonList.setTotalItems(docFilter.getTotalItemsResult());
54
55         return (TL) commonList;
56     }
57     
58     @Override
59         public Lifecycle getLifecycle(String docTypeName) {
60         Lifecycle result = new Lifecycle();
61         result.setName("Life cycles are not supported by the JPA-based services.");
62         return result; // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
63     }
64     
65     @Override
66     public Lifecycle getLifecycle() {
67         return getLifecycle(null); // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
68     }
69     
70         @Override
71         public void handleWorkflowTransition(ServiceContext ctx, DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)
72                         throws Exception {
73                 // Do nothing.  JPA document handlers do not support workflow transitions yet.
74         }
75     
76 }