| 1 | package edu.ucsb.cs156.courses.services; | |
| 2 | ||
| 3 | import com.fasterxml.jackson.core.type.TypeReference; | |
| 4 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 5 | import edu.ucsb.cs156.courses.documents.ConvertedSection; | |
| 6 | import edu.ucsb.cs156.courses.documents.CoursePage; | |
| 7 | import edu.ucsb.cs156.courses.documents.GERequirement; | |
| 8 | import edu.ucsb.cs156.courses.documents.Primary; | |
| 9 | import java.time.Duration; | |
| 10 | import java.util.Arrays; | |
| 11 | import java.util.HashMap; | |
| 12 | import java.util.List; | |
| 13 | import java.util.Map; | |
| 14 | import java.util.stream.Collectors; | |
| 15 | import lombok.extern.slf4j.Slf4j; | |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | import org.springframework.beans.factory.annotation.Value; | |
| 18 | import org.springframework.boot.web.client.RestTemplateBuilder; | |
| 19 | import org.springframework.http.HttpEntity; | |
| 20 | import org.springframework.http.HttpHeaders; | |
| 21 | import org.springframework.http.HttpMethod; | |
| 22 | import org.springframework.http.HttpStatus; | |
| 23 | import org.springframework.http.MediaType; | |
| 24 | import org.springframework.http.ResponseEntity; | |
| 25 | import org.springframework.stereotype.Service; | |
| 26 | import org.springframework.web.client.RestTemplate; | |
| 27 | ||
| 28 | /** Service object that wraps the UCSB Academic Curriculum API */ | |
| 29 | @Service | |
| 30 | @Slf4j | |
| 31 | public class UCSBCurriculumService { | |
| 32 | ||
| 33 | @Autowired private ObjectMapper objectMapper; | |
| 34 | ||
| 35 | @Value("${app.ucsb.api.consumer_key}") | |
| 36 | private String apiKey; | |
| 37 | ||
| 38 | @Value("${app.ucsb.api.host}") | |
| 39 | private String apiHost; | |
| 40 | ||
| 41 | private static final Duration CONNECT_TIMEOUT = Duration.ofSeconds(10); | |
| 42 | private static final Duration READ_TIMEOUT = Duration.ofSeconds(60); | |
| 43 | ||
| 44 | private RestTemplate restTemplate = new RestTemplate(); | |
| 45 | ||
| 46 | public UCSBCurriculumService(RestTemplateBuilder restTemplateBuilder) throws Exception { | |
| 47 | restTemplate = | |
| 48 | restTemplateBuilder.connectTimeout(CONNECT_TIMEOUT).readTimeout(READ_TIMEOUT).build(); | |
| 49 | } | |
| 50 | ||
| 51 | public static final String CURRICULUM_ENDPOINT = | |
| 52 | "{apiHost}/academics/curriculums/v1/classes/search"; | |
| 53 | ||
| 54 | public static final String SUBJECTS_ENDPOINT = "{apiHost}/students/lookups/v1/subjects"; | |
| 55 | ||
| 56 | public static final String SECTION_ENDPOINT = | |
| 57 | "{apiHost}/academics/curriculums/v1/classsection/{quarter}/{enrollcode}"; | |
| 58 | ||
| 59 | public static final String ALL_SECTIONS_ENDPOINT = | |
| 60 | "{apiHost}/academics/curriculums/v3/classes/{quarter}/{enrollcode}"; | |
| 61 | ||
| 62 | public static final String FINALS_ENDPOINT = "{apiHost}/academics/curriculums/v3/finals"; | |
| 63 | ||
| 64 | public static final String GE_ENDPOINT = "{apiHost}/students/lookups/v1/requirements"; | |
| 65 | ||
| 66 | public String getJSON(String subjectArea, String quarter, String courseLevel) throws Exception { | |
| 67 | ||
| 68 | HttpHeaders headers = new HttpHeaders(); | |
| 69 |
1
1. getJSON : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 70 |
1
1. getJSON : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 71 |
1
1. getJSON : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 72 |
1
1. getJSON : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 73 | ||
| 74 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 75 | ||
| 76 | String params = | |
| 77 | String.format( | |
| 78 | "?quarter=%s&subjectCode=%s&objLevelCode=%s&pageNumber=%d&pageSize=%d&includeClassSections=%s", | |
| 79 | quarter, subjectArea, courseLevel, 1, 100, "true"); | |
| 80 | String url = CURRICULUM_ENDPOINT + params; | |
| 81 | ||
| 82 |
1
1. getJSON : negated conditional → KILLED |
if (courseLevel.equals("A")) { |
| 83 | params = | |
| 84 | String.format( | |
| 85 | "?quarter=%s&subjectCode=%s&pageNumber=%d&pageSize=%d&includeClassSections=%s", | |
| 86 | quarter, subjectArea, 1, 100, "true"); | |
| 87 | url = CURRICULUM_ENDPOINT + params; | |
| 88 | } | |
| 89 | ||
| 90 | url = url.replace("{apiHost}", apiHost); | |
| 91 | ||
| 92 | log.info("url=" + url); | |
| 93 | ||
| 94 | String retVal = ""; | |
| 95 | MediaType contentType = null; | |
| 96 | HttpStatus statusCode = null; | |
| 97 | ||
| 98 | ResponseEntity<String> re = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 99 | contentType = re.getHeaders().getContentType(); | |
| 100 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 101 | retVal = re.getBody(); | |
| 102 | ||
| 103 | log.trace("json: {}", retVal); | |
| 104 | log.info("contentType: {} statusCode: {}", contentType, statusCode); | |
| 105 |
1
1. getJSON : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getJSON → KILLED |
return retVal; |
| 106 | } | |
| 107 | ||
| 108 | public List<ConvertedSection> getConvertedSections( | |
| 109 | String subjectArea, String quarter, String courseLevel) throws Exception { | |
| 110 | String json = getJSON(subjectArea, quarter, courseLevel); | |
| 111 | CoursePage coursePage = objectMapper.readValue(json, CoursePage.class); | |
| 112 | List<ConvertedSection> result = coursePage.convertedSections(); | |
| 113 |
1
1. getConvertedSections : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getConvertedSections → KILLED |
return result; |
| 114 | } | |
| 115 | ||
| 116 | /** | |
| 117 | * This method retrieves course information and reformats it so that each primary is a single | |
| 118 | * object, that has a list of all of it's secondaries. | |
| 119 | * | |
| 120 | * <p>As a reminder, the UCSB course registration systems (GOLD, Blue, Star, etc.) treat all | |
| 121 | * courses as "sections", even what we typically call "lectures". In the database, some courses | |
| 122 | * have both primary and secondary sections. Primary sections have section numbers ending in 00 | |
| 123 | * (e.g. 100, 200, 300, up to 9900), while secondaries have numbers ending with 01, 02, 03, etc. | |
| 124 | * and "belong" with a primary. | |
| 125 | * | |
| 126 | * <p>What we typically refer to as "lectures" are primary sections ending in 00 (e.g. 100, 200, | |
| 127 | * 300). What we typically refer to as discussion sections are secondaries and end with 01, 02, | |
| 128 | * 03, etc. | |
| 129 | * | |
| 130 | * <p> | |
| 131 | * | |
| 132 | * <p>The UCSB API <i>almost</i> does this, but not quite. It returns a list of all sections, but | |
| 133 | * does not group them into primaries and secondaries. This method relies on the <code> | |
| 134 | * getPrimaries</code> method of the <code>Page</code> class to reformat the data so that each | |
| 135 | * primary section is a single object, with a list of all of its secondaries. | |
| 136 | * | |
| 137 | * @param subjectArea | |
| 138 | * @param quarter | |
| 139 | * @param courseLevel | |
| 140 | * @return a list of Primaries | |
| 141 | * @throws Exception | |
| 142 | */ | |
| 143 | public List<Primary> getPrimaries(String subjectArea, String quarter, String courseLevel) | |
| 144 | throws Exception { | |
| 145 | String json = getJSON(subjectArea, quarter, courseLevel); | |
| 146 | CoursePage coursePage = objectMapper.readValue(json, CoursePage.class); | |
| 147 | List<Primary> result = coursePage.getPrimaries(); | |
| 148 |
1
1. getPrimaries : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getPrimaries → KILLED |
return result; |
| 149 | } | |
| 150 | ||
| 151 | public String getJSONByGE(String quarter, String area) throws Exception { | |
| 152 | HttpHeaders headers = new HttpHeaders(); | |
| 153 |
1
1. getJSONByGE : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 154 |
1
1. getJSONByGE : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 155 |
1
1. getJSONByGE : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 156 |
1
1. getJSONByGE : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 157 | ||
| 158 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 159 | ||
| 160 | String params = | |
| 161 | String.format("?quarter=%s&areas=%s&pageNumber=%d&pageSize=%d", quarter, area, 1, 500); | |
| 162 | String url = (CURRICULUM_ENDPOINT + params).replace("{apiHost}", apiHost); | |
| 163 | ||
| 164 | log.info("url=" + url); | |
| 165 | ||
| 166 | String retVal = ""; | |
| 167 | MediaType contentType = null; | |
| 168 | HttpStatus statusCode = null; | |
| 169 | ||
| 170 | ResponseEntity<String> re = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 171 | contentType = re.getHeaders().getContentType(); | |
| 172 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 173 | retVal = re.getBody(); | |
| 174 | ||
| 175 | log.trace("json: {}", retVal); | |
| 176 | log.info("contentType: {} statusCode: {}", contentType, statusCode); | |
| 177 |
1
1. getJSONByGE : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getJSONByGE → KILLED |
return retVal; |
| 178 | } | |
| 179 | ||
| 180 | public List<Primary> getPrimariesByGE(String quarter, String area) throws Exception { | |
| 181 | String json = getJSONByGE(quarter, area); | |
| 182 | CoursePage coursePage = objectMapper.readValue(json, CoursePage.class); | |
| 183 | List<Primary> result = coursePage.getPrimaries(); | |
| 184 |
1
1. getPrimariesByGE : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getPrimariesByGE → KILLED |
return result; |
| 185 | } | |
| 186 | ||
| 187 | public String getSectionJSON(String subjectArea, String quarter, String courseLevel) | |
| 188 | throws Exception { | |
| 189 | List<ConvertedSection> l = getConvertedSections(subjectArea, quarter, courseLevel); | |
| 190 | ||
| 191 | String arrayToJson = objectMapper.writeValueAsString(l); | |
| 192 | ||
| 193 |
1
1. getSectionJSON : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getSectionJSON → KILLED |
return arrayToJson; |
| 194 | } | |
| 195 | ||
| 196 | public String getSubjectsJSON() throws Exception { | |
| 197 | ||
| 198 | HttpHeaders headers = new HttpHeaders(); | |
| 199 |
1
1. getSubjectsJSON : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 200 |
1
1. getSubjectsJSON : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 201 |
1
1. getSubjectsJSON : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 202 |
1
1. getSubjectsJSON : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 203 | ||
| 204 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 205 | ||
| 206 | String url = SUBJECTS_ENDPOINT.replace("{apiHost}", apiHost); | |
| 207 | ||
| 208 | log.info("url=" + url); | |
| 209 | ||
| 210 | String retVal = ""; | |
| 211 | MediaType contentType = null; | |
| 212 | HttpStatus statusCode = null; | |
| 213 | ||
| 214 | ResponseEntity<String> re = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 215 | contentType = re.getHeaders().getContentType(); | |
| 216 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 217 | retVal = re.getBody(); | |
| 218 | ||
| 219 | log.info("json: {} contentType: {} statusCode: {}", retVal, contentType, statusCode); | |
| 220 |
1
1. getSubjectsJSON : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getSubjectsJSON → KILLED |
return retVal; |
| 221 | } | |
| 222 | ||
| 223 | /** | |
| 224 | * This method retrieves exactly one section matching the enrollCode and quarter arguments, if | |
| 225 | * such a section exists. | |
| 226 | */ | |
| 227 | public String getSection(String enrollCode, String quarter) throws Exception { | |
| 228 | ||
| 229 | HttpHeaders headers = new HttpHeaders(); | |
| 230 |
1
1. getSection : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 231 |
1
1. getSection : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 232 |
1
1. getSection : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 233 |
1
1. getSection : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 234 | ||
| 235 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 236 | ||
| 237 | String url = SECTION_ENDPOINT.replace("{apiHost}", apiHost); | |
| 238 | ||
| 239 | log.info("url=" + url); | |
| 240 | ||
| 241 | Map<String, String> params = new HashMap<>(); | |
| 242 | params.put("quarter", quarter); | |
| 243 | params.put("enrollcode", enrollCode); | |
| 244 | ||
| 245 | String retVal = ""; | |
| 246 | MediaType contentType = null; | |
| 247 | HttpStatus statusCode = null; | |
| 248 | ||
| 249 | ResponseEntity<String> re = | |
| 250 | restTemplate.exchange(url, HttpMethod.GET, entity, String.class, params); | |
| 251 | contentType = re.getHeaders().getContentType(); | |
| 252 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 253 | retVal = re.getBody(); | |
| 254 | ||
| 255 |
1
1. getSection : negated conditional → KILLED |
if (retVal.equals("null")) { |
| 256 | retVal = "{\"error\": \"Enroll code doesn't exist in that quarter.\"}"; | |
| 257 | } | |
| 258 | ||
| 259 | log.info("json: {} contentType: {} statusCode: {}", retVal, contentType, statusCode); | |
| 260 |
1
1. getSection : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getSection → KILLED |
return retVal; |
| 261 | } | |
| 262 | ||
| 263 | /** | |
| 264 | * This method retrieves all of the sections related to a certain enroll code. For example, if the | |
| 265 | * enrollCode is for a discussion section, the lecture section and all related discussion sections | |
| 266 | * will also be returned. | |
| 267 | */ | |
| 268 | public String getAllSections(String enrollCode, String quarter) throws Exception { | |
| 269 | ||
| 270 | HttpHeaders headers = new HttpHeaders(); | |
| 271 |
1
1. getAllSections : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 272 |
1
1. getAllSections : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 273 |
1
1. getAllSections : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "3.0"); |
| 274 |
1
1. getAllSections : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 275 | ||
| 276 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 277 | ||
| 278 | String url = ALL_SECTIONS_ENDPOINT.replace("{apiHost}", apiHost); | |
| 279 | ||
| 280 | log.info("url=" + url); | |
| 281 | ||
| 282 | Map<String, String> params = new HashMap<>(); | |
| 283 | params.put("quarter", quarter); | |
| 284 | params.put("enrollcode", enrollCode); | |
| 285 | ||
| 286 | String retVal = ""; | |
| 287 | MediaType contentType = null; | |
| 288 | HttpStatus statusCode = null; | |
| 289 | ||
| 290 | ResponseEntity<String> re = | |
| 291 | restTemplate.exchange(url, HttpMethod.GET, entity, String.class, params); | |
| 292 | contentType = re.getHeaders().getContentType(); | |
| 293 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 294 | retVal = re.getBody(); | |
| 295 | ||
| 296 |
1
1. getAllSections : negated conditional → KILLED |
if (retVal.equals("null")) { |
| 297 | retVal = "{\"error\": \"Enroll code doesn't exist in that quarter.\"}"; | |
| 298 | } | |
| 299 | ||
| 300 | log.info("json: {} contentType: {} statusCode: {}", retVal, contentType, statusCode); | |
| 301 |
1
1. getAllSections : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getAllSections → KILLED |
return retVal; |
| 302 | } | |
| 303 | ||
| 304 | public String getJSONbyQtrEnrollCd(String quarter, String enrollCd) throws Exception { | |
| 305 | ||
| 306 | HttpHeaders headers = new HttpHeaders(); | |
| 307 |
1
1. getJSONbyQtrEnrollCd : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 308 |
1
1. getJSONbyQtrEnrollCd : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 309 |
1
1. getJSONbyQtrEnrollCd : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 310 |
1
1. getJSONbyQtrEnrollCd : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 311 | ||
| 312 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 313 | ||
| 314 | String url = "{apiHost}/academics/curriculums/v3/classsection/" + quarter + "/" + enrollCd; | |
| 315 | url = url.replace("{apiHost}", apiHost); | |
| 316 | ||
| 317 | log.info("url=" + url); | |
| 318 | ||
| 319 | String retVal = ""; | |
| 320 | MediaType contentType = null; | |
| 321 | HttpStatus statusCode = null; | |
| 322 | ||
| 323 | ResponseEntity<String> re = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 324 | contentType = re.getHeaders().getContentType(); | |
| 325 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 326 | retVal = re.getBody(); | |
| 327 | ||
| 328 | log.info("json: {} contentType: {} statusCode: {}", retVal, contentType, statusCode); | |
| 329 |
1
1. getJSONbyQtrEnrollCd : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getJSONbyQtrEnrollCd → KILLED |
return retVal; |
| 330 | } | |
| 331 | ||
| 332 | public String getFinalsInfo(String quarter, String enrollCd) throws Exception { | |
| 333 | HttpHeaders headers = new HttpHeaders(); | |
| 334 |
1
1. getFinalsInfo : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 335 |
1
1. getFinalsInfo : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "3.0"); |
| 336 |
1
1. getFinalsInfo : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 337 | ||
| 338 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 339 | ||
| 340 | String params = String.format("?quarter=%s&enrollCode=%s", quarter, enrollCd); | |
| 341 | String url = (FINALS_ENDPOINT + params).replace("{apiHost}", apiHost); | |
| 342 | ||
| 343 | log.info("url=" + url); | |
| 344 | ||
| 345 | String retVal; | |
| 346 | MediaType contentType; | |
| 347 | HttpStatus statusCode; | |
| 348 | ||
| 349 | ResponseEntity<String> re = restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 350 | contentType = re.getHeaders().getContentType(); | |
| 351 | statusCode = (HttpStatus) re.getStatusCode(); | |
| 352 | retVal = re.getBody(); | |
| 353 | ||
| 354 | log.info("json: {} contentType: {} statusCode: {}", retVal, contentType, statusCode); | |
| 355 |
1
1. getFinalsInfo : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getFinalsInfo → KILLED |
return retVal; |
| 356 | } | |
| 357 | ||
| 358 | public String getGeneralEducationInfo() throws Exception { | |
| 359 | HttpHeaders headers = new HttpHeaders(); | |
| 360 |
1
1. getGeneralEducationInfo : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED |
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); |
| 361 |
1
1. getGeneralEducationInfo : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED |
headers.setContentType(MediaType.APPLICATION_JSON); |
| 362 |
1
1. getGeneralEducationInfo : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-version", "1.0"); |
| 363 |
1
1. getGeneralEducationInfo : removed call to org/springframework/http/HttpHeaders::set → KILLED |
headers.set("ucsb-api-key", this.apiKey); |
| 364 | ||
| 365 | HttpEntity<String> entity = new HttpEntity<>("body", headers); | |
| 366 | ||
| 367 | String url = GE_ENDPOINT.replace("{apiHost}", apiHost); | |
| 368 | ||
| 369 | log.info("Fetching GE areas from {}", url); | |
| 370 | ResponseEntity<String> response = | |
| 371 | restTemplate.exchange(url, HttpMethod.GET, entity, String.class); | |
| 372 | ||
| 373 | log.debug("GE areas JSON: {}", response.getBody()); | |
| 374 |
1
1. getGeneralEducationInfo : replaced return value with "" for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getGeneralEducationInfo → KILLED |
return response.getBody(); |
| 375 | } | |
| 376 | ||
| 377 | public List<String> getRequirementCodesByCollege(String collegeCode) throws Exception { | |
| 378 | String json = getGeneralEducationInfo(); | |
| 379 | ||
| 380 | List<GERequirement> allAreas = | |
| 381 | objectMapper.readValue(json, new TypeReference<List<GERequirement>>() {}); | |
| 382 | ||
| 383 |
1
1. getRequirementCodesByCollege : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/UCSBCurriculumService::getRequirementCodesByCollege → KILLED |
return allAreas.stream() |
| 384 |
2
1. lambda$getRequirementCodesByCollege$0 : replaced boolean return with false for edu/ucsb/cs156/courses/services/UCSBCurriculumService::lambda$getRequirementCodesByCollege$0 → KILLED 2. lambda$getRequirementCodesByCollege$0 : replaced boolean return with true for edu/ucsb/cs156/courses/services/UCSBCurriculumService::lambda$getRequirementCodesByCollege$0 → KILLED |
.filter(area -> area.getCollegeCode().equalsIgnoreCase(collegeCode)) |
| 385 | .map(GERequirement::getRequirementCode) | |
| 386 | .distinct() | |
| 387 | .collect(Collectors.toList()); | |
| 388 | } | |
| 389 | } | |
Mutations | ||
| 69 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 72 |
1.1 |
|
| 82 |
1.1 |
|
| 105 |
1.1 |
|
| 113 |
1.1 |
|
| 148 |
1.1 |
|
| 153 |
1.1 |
|
| 154 |
1.1 |
|
| 155 |
1.1 |
|
| 156 |
1.1 |
|
| 177 |
1.1 |
|
| 184 |
1.1 |
|
| 193 |
1.1 |
|
| 199 |
1.1 |
|
| 200 |
1.1 |
|
| 201 |
1.1 |
|
| 202 |
1.1 |
|
| 220 |
1.1 |
|
| 230 |
1.1 |
|
| 231 |
1.1 |
|
| 232 |
1.1 |
|
| 233 |
1.1 |
|
| 255 |
1.1 |
|
| 260 |
1.1 |
|
| 271 |
1.1 |
|
| 272 |
1.1 |
|
| 273 |
1.1 |
|
| 274 |
1.1 |
|
| 296 |
1.1 |
|
| 301 |
1.1 |
|
| 307 |
1.1 |
|
| 308 |
1.1 |
|
| 309 |
1.1 |
|
| 310 |
1.1 |
|
| 329 |
1.1 |
|
| 334 |
1.1 |
|
| 335 |
1.1 |
|
| 336 |
1.1 |
|
| 355 |
1.1 |
|
| 360 |
1.1 |
|
| 361 |
1.1 |
|
| 362 |
1.1 |
|
| 363 |
1.1 |
|
| 374 |
1.1 |
|
| 383 |
1.1 |
|
| 384 |
1.1 2.2 |