Clover Coverage Report - Kuali Student 1.1.0-M10-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Dec 17 2010 05:04:51 EST
../../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
51   163   19   5.1
14   119   0.37   10
10     1.9  
1    
 
  StatementRpcServlet       Line # 37 51 0% 19 75 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.program.server;
17   
18    import java.util.ArrayList;
19    import java.util.Iterator;
20    import java.util.List;
21   
22    import org.kuali.student.common.ui.client.widgets.rules.ReqComponentInfoUi;
23    import org.kuali.student.common.ui.server.gwt.BaseRpcGwtServletAbstract;
24    import org.kuali.student.core.statement.dto.ReqComponentInfo;
25    import org.kuali.student.core.statement.dto.ReqComponentTypeInfo;
26    import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
27    import org.kuali.student.core.statement.dto.StatementTypeInfo;
28    import org.kuali.student.core.statement.service.StatementService;
29    import org.kuali.student.core.versionmanagement.dto.VersionDisplayInfo;
30    import org.kuali.student.lum.lu.dto.CluInfo;
31    import org.kuali.student.lum.lu.service.LuService;
32    import org.kuali.student.lum.program.client.rpc.StatementRpcService;
33   
34    import com.google.gwt.user.client.rpc.AsyncCallback;
35    import org.apache.log4j.Logger;
36   
 
37    public class StatementRpcServlet extends BaseRpcGwtServletAbstract<LuService> implements StatementRpcService {
38   
39    final static Logger LOG = Logger.getLogger(StatementRpcServlet.class);
40   
41    private StatementService statementService;
42    private LuService luService;
43   
44    private static final long serialVersionUID = 822326113643828855L;
45   
 
46  0 toggle public List<StatementTypeInfo> getStatementTypesForStatementTypeForCourse(String statementTypeKey) throws Exception {
47   
48   
49  0 String[] desiredSequenceEnrollmentElig = {"kuali.statement.type.course.academicReadiness.studentEligibilityPrereq",
50    "kuali.statement.type.course.academicReadiness.coreq",
51    "kuali.statement.type.course.recommendedPreparation",
52    "kuali.statement.type.course.academicReadiness.antireq"};
53   
54  0 String[] desiredSequenceCreditConstraints = {"kuali.statement.type.course.credit.restriction",
55    "kuali.statement.type.course.credit.repeatable"};
56   
57  0 List<StatementTypeInfo> statementTypesSorted = new ArrayList<StatementTypeInfo>();
58   
59  0 List<String> statementTypeNames = statementService.getStatementTypesForStatementType(statementTypeKey);
60   
61  0 for (String statementTypeName : statementTypeNames) {
62  0 StatementTypeInfo stmtInfo = statementService.getStatementType(statementTypeName);
63   
64  0 statementTypesSorted.add(statementService.getStatementType(statementTypeName));
65   
66    //true if we found sub statement type
67  0 List<String> subStmtInfos = stmtInfo.getAllowedStatementTypes();
68  0 List<StatementTypeInfo> statementTypesOrig = new ArrayList<StatementTypeInfo>();
69  0 if ((subStmtInfos != null) && !subStmtInfos.isEmpty()) {
70  0 List<String> subStatementTypeNames = statementService.getStatementTypesForStatementType(statementTypeName);
71  0 for (String subStatementTypeName : subStatementTypeNames) {
72  0 statementTypesOrig.add(statementService.getStatementType(subStatementTypeName));
73    }
74  0 if (statementTypeName.contains("kuali.statement.type.course.enrollmentEligibility")) {
75  0 for (String stmtType : desiredSequenceEnrollmentElig) {
76  0 Iterator<StatementTypeInfo> iter = statementTypesOrig.iterator();
77  0 while (iter.hasNext()) {
78  0 StatementTypeInfo stmtT = iter.next();
79  0 if (stmtT.getId().equals(stmtType)) {
80  0 statementTypesSorted.add(stmtT);
81  0 break;
82    }
83    }
84    }
85    }
86  0 if (statementTypeName.contains("kuali.statement.type.course.creditConstraints")) {
87  0 for (String stmtType : desiredSequenceCreditConstraints) {
88  0 Iterator<StatementTypeInfo> iter = statementTypesOrig.iterator();
89  0 while (iter.hasNext()) {
90  0 StatementTypeInfo stmtT = iter.next();
91  0 if (stmtT.getId().equals(stmtType)) {
92  0 statementTypesSorted.add(stmtT);
93  0 break;
94    }
95    }
96    }
97    }
98    }
99    }
100   
101  0 return statementTypesSorted;
102    }
103   
 
104  0 toggle @Override
105    public List<StatementTypeInfo> getStatementTypesForStatementType(String statementTypeKey) throws Exception {
106  0 List<String> statementTypeNames = statementService.getStatementTypesForStatementType(statementTypeKey);
107  0 List<StatementTypeInfo> statementTypes = new ArrayList<StatementTypeInfo>();
108  0 for (String statementTypeName : statementTypeNames) {
109  0 statementTypes.add(statementService.getStatementType(statementTypeName));
110    }
111  0 return statementTypes;
112    }
113   
 
114  0 toggle public List<ReqComponentTypeInfo> getReqComponentTypesForStatementType(String luStatementTypeKey) throws Exception {
115   
116  0 List<ReqComponentTypeInfo> reqComponentTypeInfoList;
117  0 try {
118  0 reqComponentTypeInfoList = statementService.getReqComponentTypesForStatementType(luStatementTypeKey);
119    } catch (Exception ex) {
120  0 LOG.error(ex);
121  0 throw new Exception("Unable to find Requirement Component Types based on LU Statement Type Key:" + luStatementTypeKey, ex);
122    }
123   
124  0 return reqComponentTypeInfoList;
125    }
126   
 
127  0 toggle @Override
128    public String translateStatementTreeViewToNL(StatementTreeViewInfo statementTreeViewInfo, String nlUsageTypeKey, String language) throws Exception {
129  0 return statementService.translateStatementTreeViewToNL(statementTreeViewInfo, nlUsageTypeKey, language);
130    }
131   
 
132  0 toggle @Override
133    public String translateReqComponentToNL(ReqComponentInfo reqComponentInfo, String nlUsageTypeKey, String language) throws Exception {
134  0 return statementService.translateReqComponentToNL(reqComponentInfo, nlUsageTypeKey, language);
135    }
136   
 
137  0 toggle @Override
138    public List<String> translateReqComponentToNLs(ReqComponentInfoUi reqComponentInfo, String[] nlUsageTypeKeys, String language) throws Exception {
139  0 List<String> nls = new ArrayList<String>(nlUsageTypeKeys.length);
140  0 for (String typeKey : nlUsageTypeKeys) {
141  0 nls.add(statementService.translateReqComponentToNL(reqComponentInfo, typeKey, language));
142    }
143  0 return nls;
144    }
145   
 
146  0 toggle @Override
147    public CluInfo getClu(String cluId) throws Exception {
148  0 return luService.getClu(cluId);
149    }
150   
 
151  0 toggle @Override
152    public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws Exception {
153  0 return luService.getCurrentVersion(refObjectTypeURI, refObjectId);
154    }
155   
 
156  0 toggle public void setStatementService(StatementService statementService) {
157  0 this.statementService = statementService;
158    }
159   
 
160  0 toggle public void setLuService(LuService luService) {
161  0 this.luService = luService;
162    }
163    }