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