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.demo.travel.fiscalofficer;
17  
18  import java.util.Map;
19  
20  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
21  import org.kuali.rice.krad.maintenance.MaintenanceDocument;
22  import org.kuali.rice.krad.maintenance.MaintainableImpl;
23  import org.kuali.rice.krad.util.KRADConstants;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class FiscalOfficerInfoMaintainableImpl extends MaintainableImpl {
29      
30      private transient FiscalOfficerService fiscalOfficerService;
31  
32      
33      @Override
34      public void saveDataObject() {
35          if(getMaintenanceAction().equals(KRADConstants.MAINTENANCE_NEW_ACTION) ||
36                  getMaintenanceAction().equals(KRADConstants.MAINTENANCE_COPY_ACTION)) {
37              getFiscalOfficerService().createFiscalOfficer((FiscalOfficerInfo)getDataObject());
38          }
39          else {
40              getFiscalOfficerService().updateFiscalOfficer((FiscalOfficerInfo)getDataObject());
41          }
42      }
43  
44      @Override
45      public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
46          return getFiscalOfficerService().retrieveFiscalOfficer(new Long(dataObjectKeys.get("id")));
47      }
48  
49      protected FiscalOfficerService getFiscalOfficerService() {
50          if(fiscalOfficerService == null) {
51              fiscalOfficerService = GlobalResourceLoader.getService("fiscalOfficerService");
52          }
53          return this.fiscalOfficerService;
54      }
55  
56      public void setFiscalOfficerService(FiscalOfficerService fiscalOfficerService) {
57          this.fiscalOfficerService = fiscalOfficerService;
58      }
59  
60  }