| 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 | Pattern teamPattern = | |
| 42 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
teamRegex == null || teamRegex.isBlank() ? null : Pattern.compile(teamRegex); |
| 43 | ||
| 44 | for (Team team : course.getTeams()) { | |
| 45 |
2
1. accept : negated conditional → KILLED 2. accept : negated conditional → KILLED |
if (teamPattern != null && !teamPattern.matcher(team.getName()).matches()) { |
| 46 | continue; | |
| 47 | } | |
| 48 |
1
1. accept : removed call to edu/ucsb/cs156/frontiers/services/RepositoryService::createTeamRepository → KILLED |
repositoryService.createTeamRepository( |
| 49 | course, team, repositoryPrefix, isPrivate, permissions, orgId); | |
| 50 | } | |
| 51 | ctx.log("Done"); | |
| 52 | } | |
| 53 | } | |
Mutations | ||
| 25 |
1.1 |
|
| 42 |
1.1 2.2 |
|
| 45 |
1.1 2.2 |
|
| 48 |
1.1 |