Coverage Report - org.kuali.student.lum.program.server.StatementRpcServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
StatementRpcServlet
0%
0/58
0%
0/28
2.6
 
 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  0
 public class StatementRpcServlet extends BaseRpcGwtServletAbstract<LuService> implements StatementRpcService {
 38  
 
 39  0
     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  
     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  0
                         }
 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  0
                         }
 96  
                     }
 97  
                 }
 98  
             }            
 99  0
         }
 100  
         
 101  0
         return statementTypesSorted;
 102  
     }
 103  
     
 104  
     @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  
     public List<ReqComponentTypeInfo> getReqComponentTypesForStatementType(String luStatementTypeKey) throws Exception {
 115  
 
 116  
         List<ReqComponentTypeInfo> reqComponentTypeInfoList;
 117  
         try { 
 118  0
             reqComponentTypeInfoList = statementService.getReqComponentTypesForStatementType(luStatementTypeKey);
 119  0
         } 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  0
         }
 123  
         
 124  0
         return reqComponentTypeInfoList;
 125  
     }
 126  
 
 127  
     @Override
 128  
     public String translateStatementTreeViewToNL(StatementTreeViewInfo statementTreeViewInfo, String nlUsageTypeKey, String language) throws Exception {
 129  0
         return statementService.translateStatementTreeViewToNL(statementTreeViewInfo, nlUsageTypeKey, language);
 130  
     }
 131  
 
 132  
     @Override
 133  
     public String translateReqComponentToNL(ReqComponentInfo reqComponentInfo, String nlUsageTypeKey, String language) throws Exception {
 134  0
         return statementService.translateReqComponentToNL(reqComponentInfo, nlUsageTypeKey, language);
 135  
     }
 136  
 
 137  
     @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  
     @Override
 147  
     public CluInfo getClu(String cluId) throws Exception {
 148  0
         return luService.getClu(cluId);
 149  
     }
 150  
 
 151  
     @Override
 152  
     public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws Exception {
 153  0
         return luService.getCurrentVersion(refObjectTypeURI, refObjectId);
 154  
     }
 155  
 
 156  
     public void setStatementService(StatementService statementService) {
 157  0
         this.statementService = statementService;
 158  0
     }
 159  
 
 160  
     public void setLuService(LuService luService) {
 161  0
         this.luService = luService;
 162  0
     }
 163  
 }