View Javadoc
1   /**
2    * Copyright 2005-2014 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.bo;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.persistence.Transient;
22  
23  import org.kuali.rice.krad.service.KRADServiceLocator;
24  import org.kuali.rice.krad.service.LegacyDataAppAdapter;
25  
26  
27  /**
28   * Adapter class to provide some of the parent methods expected of persistable business objects
29   * This is a temporary class to use in place of PBOB (moved to the KNS module) to facilitate
30   * code-level compatibility with existing business objects and documents.
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class PersistableBusinessObjectBaseAdapter extends DataObjectBase {
35      private static final long serialVersionUID = 1L;
36      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PersistableBusinessObjectBaseAdapter.class);
37  
38      @Transient protected boolean newCollectionRecord;
39      @Transient protected Object extension;
40  
41      /**
42       * getService Refreshes the reference objects from the primitive values.
43       *
44       * @see org.kuali.rice.krad.bo.BusinessObject#refresh()
45       */
46      public void refresh() {
47          // do nothing
48      }
49  
50      public void refreshNonUpdateableReferences() {
51          getLegacyDataAdapter().refreshAllNonUpdatingReferences(this);
52      }
53  
54      public void refreshReferenceObject(String referenceObjectName) {
55          getLegacyDataAdapter().refreshReferenceObject(this, referenceObjectName);
56      }
57  
58      /**
59       * Returns the legacy data adapter for handling legacy KNS and KRAD data and metadata.
60       *
61       * @return the legacy data adapter
62       * @deprecated application code should never use this! Always use KRAD code directly.
63       */
64      @Deprecated
65      protected LegacyDataAppAdapter getLegacyDataAdapter() {
66          return KRADServiceLocator.getLegacyDataAdapter();
67      }
68  
69      public List buildListOfDeletionAwareLists() {
70          return new ArrayList();
71      }
72  
73      public void linkEditableUserFields() {
74          // do nothing
75      }
76  
77      public Object getExtension() {
78          if ( extension == null
79                  && getLegacyDataAdapter().isPersistable(this.getClass())) {
80              try {
81                  extension = getLegacyDataAdapter().getExtension(this.getClass());
82              } catch ( Exception ex ) {
83                  LOG.error( "unable to create extension object", ex );
84              }
85          }
86          return extension;
87      }
88  
89      public void setExtension(Object extension) {
90          this.extension = extension;
91      }
92  
93      public boolean isNewCollectionRecord() {
94          return newCollectionRecord;
95      }
96  
97      public void setNewCollectionRecord(boolean isNewCollectionRecord) {
98          this.newCollectionRecord = isNewCollectionRecord;
99      }
100 }