| 1 | package edu.ucsb.cs156.frontiers.jobs; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.frontiers.entities.Course; | |
| 4 | import edu.ucsb.cs156.frontiers.entities.Team; | |
| 5 | import edu.ucsb.cs156.frontiers.enums.RepositoryPermissions; | |
| 6 | import edu.ucsb.cs156.frontiers.services.GithubTeamService; | |
| 7 | import edu.ucsb.cs156.frontiers.services.RepositoryService; | |
| 8 | import edu.ucsb.cs156.frontiers.services.jobs.JobContext; | |
| 9 | import edu.ucsb.cs156.frontiers.services.jobs.JobContextConsumer; | |
| 10 | import java.util.regex.Pattern; | |
| 11 | import lombok.Builder; | |
| 12 | ||
| 13 | @Builder | |
| 14 | public class CreateTeamRepositoriesJob implements JobContextConsumer { | |
| 15 | Course course; | |
| 16 | RepositoryService repositoryService; | |
| 17 | GithubTeamService githubTeamService; | |
| 18 | String repositoryPrefix; | |
| 19 | Boolean isPrivate; | |
| 20 | RepositoryPermissions permissions; | |
| 21 | String teamRegex; | |
| 22 | ||
| 23 | @Override | |
| 24 | public Course getCourse() { | |
| 25 |
1
1. getCourse : replaced return value with null for edu/ucsb/cs156/frontiers/jobs/CreateTeamRepositoriesJob::getCourse → KILLED |
return course; |
| 26 | } | |
| 27 | ||
| 28 | @Override | |
| 29 | public void accept(JobContext ctx) throws Exception { | |
| 30 | ctx.log("Creating team repositories..."); | |
| 31 | ||
| 32 | Integer orgId; | |
| 33 | try { | |
| 34 | orgId = githubTeamService.getOrgId(course.getOrgName(), course); | |
| 35 | } catch (Exception e) { | |
| 36 | throw new IllegalStateException( | |
| 37 | "Failed to get organization ID for org: " + course.getOrgName() + " - " + e.getMessage(), | |
| 38 | e); | |
| 39 | } | |
| 40 | ||
| 41 |
1
1. accept : negated conditional → KILLED |
if (teamRegex == null) { |
| 42 | for (Team team : course.getTeams()) { | |
| 43 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/RepositoryService::createTeamRepository → KILLED |
repositoryService.createTeamRepository( |
| 44 | course, team, repositoryPrefix, isPrivate, permissions, orgId); | |
| 45 | } | |
| 46 | } else { | |
| 47 | Pattern pattern = Pattern.compile(teamRegex); | |
| 48 | ||
| 49 | for (Team team : course.getTeams()) { | |
| 50 |
1
1. accept : negated conditional → KILLED |
if (pattern.matcher(team.getName()).find()) { |
| 51 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/RepositoryService::createTeamRepository → KILLED |
repositoryService.createTeamRepository( |
| 52 | course, team, repositoryPrefix, isPrivate, permissions, orgId); | |
| 53 | } | |
| 54 | } | |
| 55 | } | |
| 56 | ||
| 57 | ctx.log("Done"); | |
| 58 | } | |
| 59 | } | |
Mutations | ||
| 25 |
1.1 |
|
| 41 |
1.1 |
|
| 43 |
1.1 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |