001/*
002 * Copyright 2012 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 1.0 (the
005 * "License"); 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/ecl1.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, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016package org.kuali.student.class3.krms.termresolver;
017
018import java.util.Date;
019import java.util.Map;
020import java.util.Set;
021
022import org.kuali.rice.krms.api.engine.TermResolutionException;
023import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
024import org.kuali.student.r2.core.atp.dto.AtpInfo;
025import org.slf4j.Logger;
026import org.slf4j.LoggerFactory;
027
028/**
029 *
030 * @author Kuali Student Team 
031 *
032 */
033public class AtpEndDateFieldTermResolver extends AbstractKSTermResolver<Date>  {
034    private static final Logger log = LoggerFactory
035            .getLogger(AtpEndDateFieldTermResolver.class);
036    
037    /**
038     * @param termName
039     */
040    public AtpEndDateFieldTermResolver(String termName, String principalId) {
041        super(termName, principalId);
042    }
043    
044    
045
046
047    @Override
048    public Set<String> getPrerequisites() {
049        Set<String> prereq = super.getPrerequisites();
050        
051        prereq.add(KSKRMSServiceConstants.TERM_TYPE_CURRENT_TERM_ID);
052        
053        return prereq;
054    }
055
056
057
058    @Override
059    public Date resolve(Map<String, Object> resolvedPrereqs,
060            Map<String, String> parameters) throws TermResolutionException {
061        
062        AtpInfo atp = (AtpInfo) resolvedPrereqs.get(KSKRMSServiceConstants.TERM_TYPE_CURRENT_TERM_ID);
063        
064        if (atp == null)
065           throw new TermResolutionException("atp undefined for term = " + KSKRMSServiceConstants.TERM_TYPE_CURRENT_TERM_ID, this, parameters);
066        
067        return atp.getEndDate();
068            
069        
070    }
071
072   
073    
074}