View Javadoc

1   /*
2    * Copyright 2012 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the
5    * "License"); 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/ecl1.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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.kuali.student.class3.krms.termresolver;
17  
18  import java.util.Date;
19  import java.util.Map;
20  import java.util.Set;
21  
22  import org.kuali.rice.krms.api.engine.TermResolutionException;
23  import org.kuali.student.krms.KRMSConstants;
24  import org.kuali.student.r2.core.atp.dto.AtpInfo;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  /**
29   *
30   * @author Kuali Student Team 
31   *
32   */
33  public class AtpEndDateFieldTermResolver extends AbstractKSTermResolver<Date>  {
34      private static final Logger log = LoggerFactory
35              .getLogger(AtpEndDateFieldTermResolver.class);
36      
37      /**
38       * @param termName
39       */
40      public AtpEndDateFieldTermResolver(String termName, String principalId) {
41          super(termName, principalId);
42      }
43      
44      
45  
46  
47      @Override
48      public Set<String> getPrerequisites() {
49          Set<String> prereq = super.getPrerequisites();
50          
51          prereq.add(KRMSConstants.CURRENT_TERM_ID);
52          
53          return prereq;
54      }
55  
56  
57  
58      @Override
59      public Date resolve(Map<String, Object> resolvedPrereqs,
60              Map<String, String> parameters) throws TermResolutionException {
61          
62          AtpInfo atp = (AtpInfo) resolvedPrereqs.get(KRMSConstants.CURRENT_TERM_ID);
63          
64          if (atp == null)
65             throw new TermResolutionException("atp undefined for term = " + KRMSConstants.CURRENT_TERM_ID, this, parameters);
66          
67          return atp.getEndDate();
68              
69          
70      }
71  
72     
73      
74  }