View Javadoc

1   package org.kuali.student.enrollment.class2.grading.keyvalue;
2   
3   /*
4    * Copyright 2007 The Kuali Foundation
5    *
6    * Licensed under the Educational Community License, Version 1.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.opensource.org/licenses/ecl1.php
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.student.enrollment.class2.grading.util.GradingConstants;
21  import org.kuali.student.enrollment.grading.dto.GradeRosterInfo;
22  import org.kuali.student.enrollment.grading.service.GradingService;
23  import org.kuali.student.r2.common.dto.ContextInfo;
24  import org.kuali.student.r2.common.exceptions.*;
25  import org.kuali.student.r2.common.util.constants.GradingServiceConstants;
26  import org.kuali.student.mock.utilities.TestHelper;
27  
28  import javax.xml.namespace.QName;
29  import java.util.ArrayList;
30  import java.util.List;
31  import org.kuali.rice.core.api.util.ConcreteKeyValue;
32  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
33  import org.kuali.rice.krad.util.GlobalVariables;
34  
35  //Core slice classes, just still around for reference.. needs cleanup
36  @Deprecated
37  public class CourseOfferingForGradingKeyValues extends KeyValuesBase {
38  
39      @Override
40      public List getKeyValues() {
41          List keyValues = new ArrayList();
42  
43          ContextInfo context = TestHelper.getContext1();
44  
45          GradingService gradingService = (GradingService) GlobalResourceLoader.getService(new QName(GradingServiceConstants.NAMESPACE, GradingServiceConstants.SERVICE_NAME_LOCAL_PART));
46  
47          String currentUser = GlobalVariables.getUserSession().getPrincipalId();
48  
49          try {
50              List<GradeRosterInfo> gradeRosterInfoList = gradingService.getGradeRostersByGraderAndTerm(currentUser, GradingConstants.CURRENT_TERM, context);
51              keyValues.add(new ConcreteKeyValue("", ""));
52              if (gradeRosterInfoList != null){
53                  //List courseOfferingList = new ArrayList();
54                  for (GradeRosterInfo rosterInfo : gradeRosterInfoList){
55                      keyValues.add(new ConcreteKeyValue(rosterInfo.getCourseOfferingId(), rosterInfo.getName()));
56                  }
57              }
58          } catch (DoesNotExistException e) {
59              keyValues.add(new ConcreteKeyValue("", ""));
60          } catch (InvalidParameterException e) {
61              throw new RuntimeException(e);
62          } catch (MissingParameterException e) {
63              throw new RuntimeException(e);
64          } catch (OperationFailedException e) {
65              throw new RuntimeException(e);
66          } catch (PermissionDeniedException e) {
67              GlobalVariables.getMessageMap().putError ("test",e.getMessage());
68          }
69  
70          return keyValues;
71      }
72  
73  }