View Javadoc

1   /**
2    * Copyright 2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by venkat on 11/27/12
16   */
17  package org.kuali.student.enrollment.class1.state.impl;
18  
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
21  import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
22  import org.kuali.student.enrollment.examoffering.dto.ExamOfferingInfo;
23  import org.kuali.student.enrollment.examoffering.dto.ExamOfferingRelationInfo;
24  import org.kuali.student.enrollment.examoffering.service.ExamOfferingService;
25  import org.kuali.student.r2.common.dto.ContextInfo;
26  import org.kuali.student.r2.common.exceptions.DoesNotExistException;
27  import org.kuali.student.r2.common.exceptions.InvalidParameterException;
28  import org.kuali.student.r2.common.exceptions.MissingParameterException;
29  import org.kuali.student.r2.common.exceptions.OperationFailedException;
30  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
31  import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
32  import org.kuali.student.r2.common.util.constants.ExamOfferingServiceConstants;
33  import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
34  
35  import javax.xml.namespace.QName;
36  import java.util.HashMap;
37  import java.util.List;
38  import java.util.Map;
39  
40  /**
41   * This class implements RelatedObjectHelper to provide relation logic for Format Offerings and Activity Offerings
42   *
43   * @author Kuali Student Team
44   */
45  public class RelatedObjectHelperFOtoEOImpl implements RelatedObjectHelper {
46  
47      private ExamOfferingService examOfferingService;
48  
49      @Override
50      public Map<String, String> getRelatedObjectsIdAndState(String formatOfferingId, ContextInfo contextInfo)
51              throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
52  
53          Map<String, String> idsAndStatesMap = new HashMap<String, String>();
54  
55          List<ExamOfferingRelationInfo> eoRelations = this.getExamOfferingService().getExamOfferingRelationsByFormatOffering(formatOfferingId, contextInfo);
56          for(ExamOfferingRelationInfo eoRelation : eoRelations){
57              ExamOfferingInfo examOffering = this.getExamOfferingService().getExamOffering(eoRelation.getExamOfferingId(), contextInfo);
58              idsAndStatesMap.put(examOffering.getId(), examOffering.getStateKey());
59          }
60  
61          return idsAndStatesMap;
62      }
63  
64      protected ExamOfferingService getExamOfferingService(){
65          if (examOfferingService == null){
66              examOfferingService = (ExamOfferingService) GlobalResourceLoader.getService(new QName(ExamOfferingServiceConstants.NAMESPACE, ExamOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
67          }
68          return  examOfferingService;
69      }
70  
71  }