01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.cg.rules;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.apache.commons.lang.StringUtils;
22: import org.kuali.core.service.BusinessObjectService;
23: import org.kuali.core.util.ObjectUtils;
24: import org.kuali.kfs.KFSPropertyConstants;
25: import org.kuali.kfs.context.SpringContext;
26: import org.kuali.module.cg.bo.Award;
27:
28: /**
29: * Rules for the Award maintenance document.
30: */
31: public class AwardRuleUtil {
32: /**
33: * Determines if a proposal has already been awarded
34: *
35: * @param award the award to check the proposal for
36: * @return true if the award's proposal has already been awarded
37: */
38: public static boolean isProposalAwarded(Award award) {
39: if (ObjectUtils.isNull(award)) {
40: return false;
41: }
42:
43: Long proposalNumber = award.getProposalNumber();
44: Map<String, Object> awardPrimaryKeys = new HashMap<String, Object>();
45: awardPrimaryKeys.put(KFSPropertyConstants.PROPOSAL_NUMBER,
46: proposalNumber);
47: Award result = (Award) SpringContext.getBean(
48: BusinessObjectService.class).findByPrimaryKey(
49: Award.class, awardPrimaryKeys);
50:
51: boolean awarded = ObjectUtils.isNotNull(result)
52: && !StringUtils.equals(award.getObjectId(), result
53: .getObjectId());
54:
55: return awarded;
56: }
57:
58: /**
59: * Per KULCG-315 - Proposals should not be designated as inactive. This functionality is not yet implemented and this rule
60: * should not be applied at this time. I'm leaving this code here in case the functionality gets added down the road.
61: */
62: // /**
63: // * determines if a proposal is inactive
64: // *
65: // * @param award the award to check the proposal for
66: // * @return true if the award's proposal has already been set to inactive
67: // */
68: // public static boolean isProposalInactive(Award award) {
69: // if (ObjectUtils.isNull(award)) {
70: // return false;
71: // }
72: //
73: // Long proposalNumber = award.getProposalNumber();
74: // Map<String, Object> awardPrimaryKeys = new HashMap<String, Object>();
75: // awardPrimaryKeys.put(KFSPropertyConstants.PROPOSAL_NUMBER, proposalNumber);
76: // Award result = (Award) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Award.class, awardPrimaryKeys);
77: //
78: // boolean inactive = ObjectUtils.isNotNull(result) && !result.isActive();
79: //
80: // return inactive;
81: // }
82: }
|