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