View Javadoc

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