1 /** 2 * Copyright 2005-2015 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krad.document; 17 18 import javax.persistence.Embeddable; 19 import javax.persistence.MappedSuperclass; 20 import javax.persistence.Transient; 21 22 import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 23 24 /** 25 * Base class for transactional documents 26 * 27 * @author Kuali Rice Team (rice.collab@kuali.org) 28 */ 29 @MappedSuperclass 30 public abstract class TransactionalDocumentBase extends DocumentBase implements TransactionalDocument, SessionDocument { 31 private static final long serialVersionUID = 1L; 32 33 /** 34 * EclipseLink static weaving does not weave MappedSuperclass unless an Entity or Embedded is 35 * weaved which uses it, hence this class. 36 */ 37 @Embeddable 38 private static final class WeaveMe extends TransactionalDocumentBase {} 39 40 // EclipseLink chokes with an NPE if a mapped superclass does not have any attributes. This keeps it happy. 41 @Transient 42 transient private String eclipseLinkBugHackAttribute; 43 44 /** 45 * @see org.kuali.rice.krad.document.TransactionalDocument#getAllowsCopy() 46 * Checks if copy is set to true in data dictionary and the document instance implements 47 * Copyable. 48 */ 49 @Override 50 public boolean getAllowsCopy() { 51 return this instanceof Copyable 52 && KRADServiceLocatorWeb.getDocumentDictionaryService().getAllowsCopy(this).booleanValue(); 53 } 54 55 /** 56 * This method to check whether the document class implements SessionDocument 57 * 58 * @return true if the document is a session document 59 */ 60 public boolean isSessionDocument() { 61 return SessionDocument.class.isAssignableFrom(this.getClass()); 62 } 63 }