001 /**
002 * Copyright 2005-2012 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 */
016 package edu.sampleu.travel.service;
017
018 import java.util.Map;
019
020 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
021 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
022 import org.kuali.rice.krad.maintenance.MaintainableImpl;
023 import org.kuali.rice.krad.util.KRADConstants;
024
025 import edu.sampleu.travel.dto.FiscalOfficerInfo;
026
027 /**
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030 public class FiscalOfficerInfoMaintainableImpl extends MaintainableImpl {
031
032 private transient FiscalOfficerService fiscalOfficerService;
033
034
035 @Override
036 public void saveDataObject() {
037 if(getMaintenanceAction().equals(KRADConstants.MAINTENANCE_NEW_ACTION) ||
038 getMaintenanceAction().equals(KRADConstants.MAINTENANCE_COPY_ACTION)) {
039 getFiscalOfficerService().createFiscalOfficer((FiscalOfficerInfo)getDataObject());
040 }
041 else {
042 getFiscalOfficerService().updateFiscalOfficer((FiscalOfficerInfo)getDataObject());
043 }
044 }
045
046 @Override
047 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
048 return getFiscalOfficerService().retrieveFiscalOfficer(new Long(dataObjectKeys.get("id")));
049 }
050
051 protected FiscalOfficerService getFiscalOfficerService() {
052 if(fiscalOfficerService == null) {
053 fiscalOfficerService = GlobalResourceLoader.getService("fiscalOfficerService");
054 }
055 return this.fiscalOfficerService;
056 }
057
058 public void setFiscalOfficerService(FiscalOfficerService fiscalOfficerService) {
059 this.fiscalOfficerService = fiscalOfficerService;
060 }
061
062 }