View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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 org.kuali.ole.module.cg.document.validation.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.cg.businessobject.Award;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.rice.krad.service.BusinessObjectService;
22  import org.kuali.rice.krad.util.ObjectUtils;
23  
24  /**
25   * Rules for the Award maintenance document.
26   */
27  public class AwardRuleUtil {
28      /**
29       * Determines if a proposal has already been awarded
30       * 
31       * @param award the award to check the proposal for
32       * @return true if the award's proposal has already been awarded
33       */
34      public static boolean isProposalAwarded(Award award) {
35          if (ObjectUtils.isNull(award)) {
36              return false;
37          }
38  
39          Award result = (Award) SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(Award.class, award.getProposalNumber());
40  
41          // Make sure it exists and is not the same object
42          return ObjectUtils.isNotNull(result) && !StringUtils.equals(award.getObjectId(), result.getObjectId());
43      }
44  
45  
46      /**
47       * Per KULCG-315 - Proposals should not be designated as inactive. This functionality is not yet implemented and this rule
48       * should not be applied at this time. I'm leaving this code here in case the functionality gets added down the road.
49       */
50      // /**
51      // * determines if a proposal is inactive
52      // *
53      // * @param award the award to check the proposal for
54      // * @return true if the award's proposal has already been set to inactive
55      // */
56      // public static boolean isProposalInactive(Award award) {
57      // if (ObjectUtils.isNull(award)) {
58      // return false;
59      // }
60      //
61      // Long proposalNumber = award.getProposalNumber();
62      // Map<String, Object> awardPrimaryKeys = new HashMap<String, Object>();
63      // awardPrimaryKeys.put(OLEPropertyConstants.PROPOSAL_NUMBER, proposalNumber);
64      // Award result = (Award) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(Award.class, awardPrimaryKeys);
65      //
66      // boolean inactive = ObjectUtils.isNotNull(result) && !result.isActive();
67      //
68      // return inactive;
69      // }
70  }