Clover Coverage Report - Kuali Student 1.2-M2-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Apr 22 2011 04:03:20 EST
../../../../../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
52   145   21   4.73
8   108   0.4   11
11     1.91  
1    
 
  CourseRpcGwtServlet       Line # 34 52 0% 21 71 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 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   
16    package org.kuali.student.lum.lu.ui.course.server.gwt;
17   
18    import java.util.Date;
19    import java.util.HashMap;
20    import java.util.List;
21    import java.util.Map;
22   
23    import org.kuali.student.common.dto.StatusInfo;
24    import org.kuali.student.common.ui.server.gwt.DataGwtServlet;
25    import org.kuali.student.core.statement.dto.ReqComponentInfo;
26    import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
27    import org.kuali.student.core.statement.service.StatementService;
28    import org.kuali.student.core.statement.ui.client.widgets.rules.ReqComponentInfoUi;
29    import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil;
30    import org.kuali.student.lum.course.service.CourseService;
31    import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsDataModel;
32    import org.kuali.student.lum.lu.ui.course.client.service.CourseRpcService;
33   
 
34    public class CourseRpcGwtServlet extends DataGwtServlet implements CourseRpcService {
35   
36    private static final long serialVersionUID = 1L;
37   
38    private CourseService courseService;
39    private StatementService statementService;
40    private CourseStateChangeServiceImpl stateChangeService;
41   
 
42  0 toggle @Override
43    public List<StatementTreeViewInfo> getCourseStatements(String courseId, String nlUsageTypeKey, String language) throws Exception {
44  0 List<StatementTreeViewInfo> rules = courseService.getCourseStatements(courseId, nlUsageTypeKey, language);
45  0 if (rules != null) {
46  0 for (StatementTreeViewInfo rule : rules) {
47  0 setReqCompNL(rule);
48    }
49    }
50  0 return rules;
51    }
52   
 
53  0 toggle public Map<Integer, StatementTreeViewInfo> storeCourseStatements(String courseId, String courseState, Map<Integer, CourseRequirementsDataModel.requirementState> states,
54    Map<Integer, StatementTreeViewInfo> rules) throws Exception {
55   
56  0 Map<Integer, StatementTreeViewInfo> storedRules = new HashMap<Integer, StatementTreeViewInfo>();
57   
58  0 for (Integer key : rules.keySet()) {
59  0 StatementTreeViewInfo rule = rules.get(key);
60  0 switch (states.get(key)) {
61  0 case STORED:
62    //rule was not changed so continue
63  0 storedRules.put(key, null);
64  0 break;
65  0 case ADDED:
66  0 storedRules.put(key, createCourseStatement(courseId, courseState, rule));
67  0 break;
68  0 case EDITED:
69  0 storedRules.put(key, updateCourseStatement(courseId, courseState, rule));
70  0 break;
71  0 case DELETED:
72  0 storedRules.put(key, null);
73  0 deleteCourseStatement(courseId, rule);
74  0 break;
75  0 default:
76  0 break;
77    }
78    }
79  0 return storedRules;
80    }
81   
 
82  0 toggle @Override
83    public StatementTreeViewInfo createCourseStatement(String courseId, String courseState, StatementTreeViewInfo statementTreeViewInfo) throws Exception {
84  0 CourseStateUtil.updateStatementTreeViewInfoState(courseState, statementTreeViewInfo);
85  0 CourseRequirementsDataModel.stripStatementIds(statementTreeViewInfo);
86  0 StatementTreeViewInfo rule = courseService.createCourseStatement(courseId, statementTreeViewInfo);
87  0 setReqCompNL(rule);
88  0 return rule;
89    }
90   
 
91  0 toggle @Override
92    public StatusInfo deleteCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws Exception {
93  0 return courseService.deleteCourseStatement(courseId, statementTreeViewInfo);
94    }
95   
 
96  0 toggle @Override
97    public StatementTreeViewInfo updateCourseStatement(String courseId, String courseState, StatementTreeViewInfo statementTreeViewInfo) throws Exception {
98  0 CourseStateUtil.updateStatementTreeViewInfoState(courseState, statementTreeViewInfo);
99  0 CourseRequirementsDataModel.stripStatementIds(statementTreeViewInfo);
100  0 StatementTreeViewInfo rule = courseService.updateCourseStatement(courseId, statementTreeViewInfo);
101  0 setReqCompNL(rule);
102  0 return rule;
103    }
104   
 
105  0 toggle public StatusInfo changeState(String courseId, String newState) throws Exception {
106  0 return changeState(courseId, newState, null);
107    }
108   
 
109  0 toggle public StatusInfo changeState(String courseId, String newState, Date currentVersionStart) throws Exception {
110  0 return stateChangeService.changeState(courseId, newState, currentVersionStart);
111    }
112   
 
113  0 toggle private void setReqCompNL(StatementTreeViewInfo tree) throws Exception {
114  0 List<StatementTreeViewInfo> statements = tree.getStatements();
115  0 List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents();
116   
117  0 if ((statements != null) && (statements.size() > 0)) {
118    // retrieve all statements
119  0 for (StatementTreeViewInfo statement : statements) {
120  0 setReqCompNL(statement); // inside set the children of this statementTreeViewInfo
121    }
122  0 } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
123    // retrieve all req. component LEAFS
124  0 for (int i = 0; i < reqComponentInfos.size(); i++) {
125  0 ReqComponentInfoUi reqUi = RulesUtil.clone(reqComponentInfos.get(i));
126  0 reqUi.setNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE", "en"));
127  0 reqUi.setPreviewNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE.PREVIEW", "en"));
128  0 reqComponentInfos.set(i, reqUi);
129    }
130    }
131    }
132   
 
133  0 toggle public void setCourseService(CourseService courseService) {
134  0 this.courseService = courseService;
135    }
136   
 
137  0 toggle public void setStatementService(StatementService statementService) {
138  0 this.statementService = statementService;
139    }
140   
 
141  0 toggle public void setStateChangeService(
142    CourseStateChangeServiceImpl stateChangeService) {
143  0 this.stateChangeService = stateChangeService;
144    }
145    }