1 package org.collectionspace.services.common.storage.jpa;
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;
14 public abstract class JpaDocumentHandler<T, TL, WT, WLT>
15 extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{
18 protected String getRefnameDisplayName(DocumentWrapper<WT> wrapDoc) {
19 return ""; // Empty string since we don't yet support this feature in JPA documents
23 public RefName.RefNameInterface getRefName(DocumentWrapper<WT> docWrapper, String tenantName, String serviceName) {
31 * Extract paging info.
33 * @param commonsList the commons list
35 * @throws Exception the exception
37 public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
39 AbstractCommonList commonList = (AbstractCommonList) theCommonList;
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());
53 return (TL) commonList;
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.
63 public Lifecycle getLifecycle() {
64 return getLifecycle(null); // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
68 public void handleWorkflowTransition(
69 DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)
71 // Do nothing. JPA document handlers do not support workflow transitions yet.