001/* 002 * Copyright 2007 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 */ 016package org.kuali.ole.module.cg.document.validation.impl; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.ole.module.cg.businessobject.Award; 020import org.kuali.ole.sys.context.SpringContext; 021import org.kuali.rice.krad.service.BusinessObjectService; 022import org.kuali.rice.krad.util.ObjectUtils; 023 024/** 025 * Rules for the Award maintenance document. 026 */ 027public class AwardRuleUtil { 028 /** 029 * Determines if a proposal has already been awarded 030 * 031 * @param award the award to check the proposal for 032 * @return true if the award's proposal has already been awarded 033 */ 034 public static boolean isProposalAwarded(Award award) { 035 if (ObjectUtils.isNull(award)) { 036 return false; 037 } 038 039 Award result = (Award) SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(Award.class, award.getProposalNumber()); 040 041 // Make sure it exists and is not the same object 042 return ObjectUtils.isNotNull(result) && !StringUtils.equals(award.getObjectId(), result.getObjectId()); 043 } 044 045 046 /** 047 * Per KULCG-315 - Proposals should not be designated as inactive. This functionality is not yet implemented and this rule 048 * should not be applied at this time. I'm leaving this code here in case the functionality gets added down the road. 049 */ 050 // /** 051 // * determines if a proposal is inactive 052 // * 053 // * @param award the award to check the proposal for 054 // * @return true if the award's proposal has already been set to inactive 055 // */ 056 // public static boolean isProposalInactive(Award award) { 057 // if (ObjectUtils.isNull(award)) { 058 // return false; 059 // } 060 // 061 // Long proposalNumber = award.getProposalNumber(); 062 // Map<String, Object> awardPrimaryKeys = new HashMap<String, Object>(); 063 // awardPrimaryKeys.put(OLEPropertyConstants.PROPOSAL_NUMBER, proposalNumber); 064 // Award result = (Award) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Award.class, awardPrimaryKeys); 065 // 066 // boolean inactive = ObjectUtils.isNotNull(result) && !result.isActive(); 067 // 068 // return inactive; 069 // } 070}