001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.document; 017 018import javax.persistence.Embeddable; 019import javax.persistence.MappedSuperclass; 020import javax.persistence.Transient; 021 022import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 023 024/** 025 * Base class for transactional documents 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029@MappedSuperclass 030public abstract class TransactionalDocumentBase extends DocumentBase implements TransactionalDocument, SessionDocument { 031 private static final long serialVersionUID = 1L; 032 033 /** 034 * EclipseLink static weaving does not weave MappedSuperclass unless an Entity or Embedded is 035 * weaved which uses it, hence this class. 036 */ 037 @Embeddable 038 private static final class WeaveMe extends TransactionalDocumentBase {} 039 040 // EclipseLink chokes with an NPE if a mapped superclass does not have any attributes. This keeps it happy. 041 @Transient 042 transient private String eclipseLinkBugHackAttribute; 043 044 /** 045 * @see org.kuali.rice.krad.document.TransactionalDocument#getAllowsCopy() 046 * Checks if copy is set to true in data dictionary and the document instance implements 047 * Copyable. 048 */ 049 @Override 050 public boolean getAllowsCopy() { 051 return this instanceof Copyable 052 && KRADServiceLocatorWeb.getDocumentDictionaryService().getAllowsCopy(this).booleanValue(); 053 } 054 055 /** 056 * This method to check whether the document class implements SessionDocument 057 * 058 * @return true if the document is a session document 059 */ 060 public boolean isSessionDocument() { 061 return SessionDocument.class.isAssignableFrom(this.getClass()); 062 } 063}