001 /* 002 * Copyright 2011 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 org.kuali.kfs.module.endow.document.service.impl; 017 018 import java.util.HashMap; 019 import java.util.Map; 020 021 import org.kuali.kfs.module.endow.EndowPropertyConstants; 022 import org.kuali.kfs.module.endow.businessobject.KemidCurrentCash; 023 import org.kuali.kfs.module.endow.document.service.KemidCurrentCashService; 024 import org.kuali.rice.kns.service.BusinessObjectService; 025 import org.kuali.rice.kns.util.ObjectUtils; 026 027 /** 028 * This KemidCurrentCashServiceImpl class provides the implementation for the method to test whether a KEMID has open records in 029 * Current Cash: records with values greater or less than zero. 030 */ 031 public class KemidCurrentCashServiceImpl implements KemidCurrentCashService { 032 033 private BusinessObjectService businessObjectService; 034 035 /** 036 * @see org.kuali.kfs.module.endow.document.service.KemidCurrentCashService#hasKemidOpenRecordsInCurrentCash(java.lang.String) 037 */ 038 public boolean hasKemidOpenRecordsInCurrentCash(String kemid) { 039 boolean hasOpenRecords = false; 040 041 Map pkMap = new HashMap(); 042 pkMap.put(EndowPropertyConstants.KEMID, kemid); 043 KemidCurrentCash kemidCurrentCash = (KemidCurrentCash) businessObjectService.findByPrimaryKey(KemidCurrentCash.class, pkMap); 044 045 if (ObjectUtils.isNotNull(kemidCurrentCash)) { 046 // if the record has values greater or less than zero than return true 047 if (kemidCurrentCash.getCurrentIncomeCash().isNonZero() || kemidCurrentCash.getCurrentPrincipalCash().isNonZero()) { 048 hasOpenRecords = true; 049 } 050 } 051 return hasOpenRecords; 052 } 053 054 /** 055 * @see org.kuali.kfs.module.endow.document.service.KemidCurrentCashService#getByPrimaryKey(String) Gets the current cash record 056 * for the given kemId 057 * @param kemId 058 * @return KemidCurrentCash the record with the given kemId 059 */ 060 public KemidCurrentCash getByPrimaryKey(String kemId) { 061 Map<String, String> primaryKey = new HashMap<String, String>(); 062 063 primaryKey.put(EndowPropertyConstants.KEMID, kemId); 064 065 return (KemidCurrentCash) businessObjectService.findByPrimaryKey(KemidCurrentCash.class, primaryKey); 066 } 067 068 /** 069 * Gets the businessObjectService. 070 * 071 * @return businessObjectService 072 */ 073 public BusinessObjectService getBusinessObjectService() { 074 return businessObjectService; 075 } 076 077 /** 078 * Sets the businessObjectService. 079 * 080 * @param businessObjectService 081 */ 082 public void setBusinessObjectService(BusinessObjectService businessObjectService) { 083 this.businessObjectService = businessObjectService; 084 } 085 086 }