| 1 |  |  package org.kuali.student.lum.program.server; | 
  | 2 |  |   | 
  | 3 |  |  import java.util.ArrayList; | 
  | 4 |  |  import java.util.List; | 
  | 5 |  |   | 
  | 6 |  |  import org.apache.log4j.Logger; | 
  | 7 |  |  import org.kuali.student.common.dictionary.old.dto.ObjectStructure; | 
  | 8 |  |  import org.kuali.student.common.exceptions.DoesNotExistException; | 
  | 9 |  |  import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; | 
  | 10 |  |  import org.kuali.student.common.search.dto.SearchRequest; | 
  | 11 |  |  import org.kuali.student.common.search.dto.SearchResult; | 
  | 12 |  |  import org.kuali.student.common.search.dto.SearchResultTypeInfo; | 
  | 13 |  |  import org.kuali.student.common.search.dto.SearchTypeInfo; | 
  | 14 |  |  import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; | 
  | 15 |  |  import org.kuali.student.core.statement.dto.ReqComponentInfo; | 
  | 16 |  |  import org.kuali.student.core.statement.dto.ReqComponentTypeInfo; | 
  | 17 |  |  import org.kuali.student.core.statement.dto.StatementTreeViewInfo; | 
  | 18 |  |  import org.kuali.student.core.statement.dto.StatementTypeInfo; | 
  | 19 |  |  import org.kuali.student.core.statement.service.StatementService; | 
  | 20 |  |  import org.kuali.student.core.statement.ui.client.widgets.rules.ReqComponentInfoUi; | 
  | 21 |  |  import org.kuali.student.lum.lu.dto.CluInfo; | 
  | 22 |  |  import org.kuali.student.lum.lu.service.LuService; | 
  | 23 |  |  import org.kuali.student.lum.program.client.rpc.StatementRpcService; | 
  | 24 |  |  import org.springframework.transaction.annotation.Transactional; | 
  | 25 |  |   | 
  | 26 | 0 |  public class StatementDataService implements StatementRpcService{ | 
  | 27 | 0 |          final static Logger LOG = Logger.getLogger(StatementDataService.class); | 
  | 28 |  |       | 
  | 29 |  |       | 
  | 30 |  |      private StatementService statementService; | 
  | 31 |  |      private LuService luService; | 
  | 32 |  |       | 
  | 33 |  |      private static final long serialVersionUID = 822326113643828855L; | 
  | 34 |  |      @Override | 
  | 35 |  |      @Transactional(readOnly=true) | 
  | 36 |  |      public List<StatementTypeInfo> getStatementTypesForStatementTypeForCourse(String statementTypeKey) throws Exception { | 
  | 37 |  |       | 
  | 38 | 0 |          List<StatementTypeInfo> allStatementTypes = new ArrayList<StatementTypeInfo>(); | 
  | 39 |  |   | 
  | 40 | 0 |          List<String> topStatementTypes = statementService.getStatementTypesForStatementType(statementTypeKey); | 
  | 41 |  |   | 
  | 42 |  |           | 
  | 43 | 0 |          for (String topStatementType : topStatementTypes) {            | 
  | 44 | 0 |              allStatementTypes.add(statementService.getStatementType(topStatementType)); | 
  | 45 | 0 |              List<String> subStatementTypeNames = statementService.getStatementTypesForStatementType(topStatementType); | 
  | 46 |  |   | 
  | 47 |  |               | 
  | 48 | 0 |              for (String subStatementTypeName : subStatementTypeNames) { | 
  | 49 | 0 |                  allStatementTypes.add(statementService.getStatementType(subStatementTypeName)); | 
  | 50 |  |              } | 
  | 51 | 0 |          } | 
  | 52 |  |           | 
  | 53 | 0 |          return allStatementTypes; | 
  | 54 |  |      } | 
  | 55 |  |       | 
  | 56 |  |      @Override | 
  | 57 |  |      @Transactional(readOnly=true) | 
  | 58 |  |      public List<StatementTypeInfo> getStatementTypesForStatementType(String statementTypeKey) throws Exception { | 
  | 59 | 0 |          List<String> statementTypeNames = statementService.getStatementTypesForStatementType(statementTypeKey); | 
  | 60 | 0 |          List<StatementTypeInfo> statementTypes = new ArrayList<StatementTypeInfo>(); | 
  | 61 | 0 |          for (String statementTypeName : statementTypeNames) { | 
  | 62 | 0 |              statementTypes.add(statementService.getStatementType(statementTypeName)); | 
  | 63 |  |          } | 
  | 64 | 0 |          return statementTypes; | 
  | 65 |  |      } | 
  | 66 |  |      @Override | 
  | 67 |  |      @Transactional(readOnly=true) | 
  | 68 |  |      public List<ReqComponentTypeInfo> getReqComponentTypesForStatementType(String luStatementTypeKey) throws Exception { | 
  | 69 |  |   | 
  | 70 |  |          List<ReqComponentTypeInfo> reqComponentTypeInfoList; | 
  | 71 |  |          try {  | 
  | 72 | 0 |              reqComponentTypeInfoList = statementService.getReqComponentTypesForStatementType(luStatementTypeKey); | 
  | 73 | 0 |          } catch (Exception ex) { | 
  | 74 | 0 |              LOG.error(ex); | 
  | 75 | 0 |              throw new Exception("Unable to find Requirement Component Types based on LU Statement Type Key:" + luStatementTypeKey, ex); | 
  | 76 | 0 |          } | 
  | 77 |  |           | 
  | 78 | 0 |          return reqComponentTypeInfoList; | 
  | 79 |  |      } | 
  | 80 |  |   | 
  | 81 |  |      @Override | 
  | 82 |  |      @Transactional(readOnly=true) | 
  | 83 |  |      public String translateStatementTreeViewToNL(StatementTreeViewInfo statementTreeViewInfo, String nlUsageTypeKey, String language) throws Exception { | 
  | 84 | 0 |          return statementService.translateStatementTreeViewToNL(statementTreeViewInfo, nlUsageTypeKey, language); | 
  | 85 |  |      } | 
  | 86 |  |   | 
  | 87 |  |      @Override | 
  | 88 |  |      @Transactional(readOnly=true) | 
  | 89 |  |      public String translateReqComponentToNL(ReqComponentInfo reqComponentInfo, String nlUsageTypeKey, String language) throws Exception { | 
  | 90 | 0 |          return statementService.translateReqComponentToNL(reqComponentInfo, nlUsageTypeKey, language); | 
  | 91 |  |      } | 
  | 92 |  |   | 
  | 93 |  |      @Override | 
  | 94 |  |      @Transactional(readOnly=true) | 
  | 95 |  |      public List<String> translateReqComponentToNLs(ReqComponentInfoUi reqComponentInfo, String[] nlUsageTypeKeys, String language) throws Exception { | 
  | 96 | 0 |              List<String> nls = new ArrayList<String>(nlUsageTypeKeys.length); | 
  | 97 | 0 |              for (String typeKey : nlUsageTypeKeys) { | 
  | 98 | 0 |                      nls.add(statementService.translateReqComponentToNL(reqComponentInfo, typeKey, language)); | 
  | 99 |  |              } | 
  | 100 | 0 |              return nls; | 
  | 101 |  |      } | 
  | 102 |  |   | 
  | 103 |  |      @Override | 
  | 104 |  |      @Transactional(readOnly=true) | 
  | 105 |  |      public CluInfo getClu(String cluId) throws Exception { | 
  | 106 | 0 |          return luService.getClu(cluId); | 
  | 107 |  |      } | 
  | 108 |  |   | 
  | 109 |  |      @Override | 
  | 110 |  |      @Transactional(readOnly=true) | 
  | 111 |  |      public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws Exception { | 
  | 112 | 0 |          return luService.getCurrentVersion(refObjectTypeURI, refObjectId); | 
  | 113 |  |      } | 
  | 114 |  |   | 
  | 115 |  |      public void setStatementService(StatementService statementService) { | 
  | 116 | 0 |          this.statementService = statementService; | 
  | 117 | 0 |      } | 
  | 118 |  |   | 
  | 119 |  |      public void setLuService(LuService luService) { | 
  | 120 | 0 |          this.luService = luService; | 
  | 121 | 0 |      } | 
  | 122 |  |   | 
  | 123 |  |          @Override | 
  | 124 |  |          public List<String> getObjectTypes() { | 
  | 125 | 0 |                  throw new UnsupportedOperationException(); | 
  | 126 |  |          } | 
  | 127 |  |   | 
  | 128 |  |          @Override | 
  | 129 |  |          public ObjectStructure getObjectStructure(String objectTypeKey) { | 
  | 130 | 0 |                  throw new UnsupportedOperationException(); | 
  | 131 |  |          } | 
  | 132 |  |   | 
  | 133 |  |          @Override | 
  | 134 |  |          public List<SearchTypeInfo> getSearchTypes() { | 
  | 135 | 0 |                  throw new UnsupportedOperationException(); | 
  | 136 |  |          } | 
  | 137 |  |   | 
  | 138 |  |          @Override | 
  | 139 |  |          public SearchTypeInfo getSearchType(String searchTypeKey) { | 
  | 140 | 0 |                  throw new UnsupportedOperationException(); | 
  | 141 |  |          } | 
  | 142 |  |   | 
  | 143 |  |          @Override | 
  | 144 |  |          public List<SearchTypeInfo> getSearchTypesByResult( | 
  | 145 |  |                          String searchResultTypeKey) { | 
  | 146 | 0 |                  throw new UnsupportedOperationException(); | 
  | 147 |  |          } | 
  | 148 |  |   | 
  | 149 |  |          @Override | 
  | 150 |  |          public List<SearchTypeInfo> getSearchTypesByCriteria( | 
  | 151 |  |                          String searchCriteriaTypeKey) { | 
  | 152 | 0 |                  throw new UnsupportedOperationException(); | 
  | 153 |  |          } | 
  | 154 |  |   | 
  | 155 |  |          @Override | 
  | 156 |  |          public List<SearchResultTypeInfo> getSearchResultTypes() { | 
  | 157 | 0 |                  throw new UnsupportedOperationException(); | 
  | 158 |  |          } | 
  | 159 |  |   | 
  | 160 |  |          @Override | 
  | 161 |  |          public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) { | 
  | 162 | 0 |                  throw new UnsupportedOperationException(); | 
  | 163 |  |          } | 
  | 164 |  |   | 
  | 165 |  |          @Override | 
  | 166 |  |          public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() { | 
  | 167 | 0 |                  throw new UnsupportedOperationException(); | 
  | 168 |  |          } | 
  | 169 |  |   | 
  | 170 |  |          @Override | 
  | 171 |  |          public SearchCriteriaTypeInfo getSearchCriteriaType( | 
  | 172 |  |                          String searchCriteriaTypeKey) { | 
  | 173 | 0 |                  throw new UnsupportedOperationException(); | 
  | 174 |  |          } | 
  | 175 |  |   | 
  | 176 |  |          @Override | 
  | 177 |  |          public SearchResult search(SearchRequest searchRequest) { | 
  | 178 | 0 |                  throw new UnsupportedOperationException(); | 
  | 179 |  |          } | 
  | 180 |  |  } |