1 package org.collectionspace.services.common.storage.jpa;
\r
3 import java.util.List;
\r
5 import org.collectionspace.services.common.api.RefName;
\r
6 import org.collectionspace.services.common.document.AbstractDocumentHandlerImpl;
\r
7 import org.collectionspace.services.common.document.DocumentFilter;
\r
8 import org.collectionspace.services.common.document.DocumentWrapper;
\r
9 import org.collectionspace.services.jaxb.AbstractCommonList;
\r
10 import org.collectionspace.services.lifecycle.Lifecycle;
\r
11 import org.collectionspace.services.lifecycle.TransitionDef;
\r
12 import org.nuxeo.ecm.core.api.DocumentModel;
\r
14 public abstract class JpaDocumentHandler<T, TL, WT, WLT>
\r
15 extends AbstractDocumentHandlerImpl<T, TL, WT, WLT>{
\r
18 protected String getRefnameDisplayName(DocumentWrapper<WT> wrapDoc) {
\r
19 return ""; // Empty string since we don't yet support this feature in JPA documents
\r
23 public RefName.RefNameInterface getRefName(DocumentWrapper<WT> docWrapper, String tenantName, String serviceName) {
\r
31 * Extract paging info.
\r
33 * @param commonsList the commons list
\r
35 * @throws Exception the exception
\r
37 public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WLT> wrapDoc)
\r
39 AbstractCommonList commonList = (AbstractCommonList) theCommonList;
\r
41 DocumentFilter docFilter = this.getDocumentFilter();
\r
42 long pageSize = docFilter.getPageSize();
\r
43 long pageNum = pageSize != 0 ? docFilter.getOffset() / pageSize : pageSize;
\r
44 // set the page size and page number
\r
45 commonList.setPageNum(pageNum);
\r
46 commonList.setPageSize(pageSize);
\r
47 List docList = (List)wrapDoc.getWrappedObject();
\r
48 // Set num of items in list. this is useful to our testing framework.
\r
49 commonList.setItemsInPage(docList.size());
\r
50 // set the total result size
\r
51 commonList.setTotalItems(docList.size());
\r
53 return (TL) commonList;
\r
56 public Lifecycle getLifecycle(String docTypeName) {
\r
57 Lifecycle result = new Lifecycle();
\r
58 result.setName("Life cycles are not supported by the JPA-based services.");
\r
59 return result; // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
\r
63 public Lifecycle getLifecycle() {
\r
64 return getLifecycle(null); // NOTE: As of 3/2012, none of the JPA-based services support a life cycle type.
\r
68 public void handleWorkflowTransition(
\r
69 DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef)
\r
71 // Do nothing. JPA document handlers do not support workflow transitions yet.
\r