1 package org.collectionspace.services.common.storage.jpa;
\r
3 import java.util.List;
\r
5 import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
\r
6 import org.collectionspace.services.common.document.DocumentFilter;
\r
7 import org.collectionspace.services.common.document.DocumentWrapper;
\r
8 import org.collectionspace.services.jaxb.AbstractCommonList;
\r
9 import org.collectionspace.services.lifecycle.Lifecycle;
\r
10 import org.collectionspace.services.lifecycle.TransitionDef;
\r
11 import org.nuxeo.ecm.core.api.DocumentModel;
\r
13 public abstract class JpaDocumentHandler<T, TL, WT, WLT>
\r
14 extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{
\r
17 * Extract paging info.
\r
19 * @param commonsList the commons list
\r
21 * @throws Exception the exception
\r
23 public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
\r
25 AbstractCommonList commonList = (AbstractCommonList) theCommonList;
\r
27 DocumentFilter docFilter = this.getDocumentFilter();
\r
28 long pageSize = docFilter.getPageSize();
\r
29 long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
\r
30 // set the page size and page number
\r
31 commonList.setPageNum(pageNum);
\r
32 commonList.setPageSize(pageSize);
\r
33 List docList = (List)wrapDoc.getWrappedObject();
\r
34 // Set num of items in list. this is useful to our testing framework.
\r
35 commonList.setItemsInPage(docList.size());
\r
36 // set the total result size
\r
37 commonList.setTotalItems(docList.size());
\r
39 return (TL) commonList;
\r
42 public Lifecycle getLifecycle(String docTypeName) {
\r
43 Lifecycle result = new Lifecycle();
\r
44 result.setName("Life cycles are not supported by the JPA-based services.");
\r
45 return result; // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
\r
49 public Lifecycle getLifecycle() {
\r
50 return getLifecycle(null); // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
\r
54 public void handleWorkflowTransition(
\r
55 DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)
\r
57 // Do nothing. JPA document handlers do not support workflow transitions yet.
\r