Skip to content

Commit

Permalink
merge: continued develop
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Oct 27, 2024
1 parent 5cc9c86 commit 1256dfa
Show file tree
Hide file tree
Showing 52 changed files with 2,710 additions and 131 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "hephaestus",
"workspaces": [
"webapp/*"
],
"scripts": {
"generate:api:clean": "rimraf webapp/src/app/core/modules/openapi",
"generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs",
"generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model",
"generate:api": "npm run generate:api:application-server-specs && npm run generate:api:clean && npm run generate:api:application-server-client"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.13.5",
"rimraf": "6.0.1"
}
"name": "hephaestus",
"workspaces": [
"webapp/*"
],
"scripts": {
"generate:api:clean": "rimraf webapp/src/app/core/modules/openapi",
"generate:api:application-server-specs": "cd server/application-server && mvn verify -DskipTests=true -Dapp.profiles=specs",
"generate:api:application-server-client": "npx openapi-generator-cli generate -i server/application-server/openapi.yaml -g typescript-angular -o webapp/src/app/core/modules/openapi --additional-properties fileNaming=kebab-case,withInterfaces=true --generate-alias-as-model",
"generate:api": "npm run generate:api:application-server-specs && npm run generate:api:clean && npm run generate:api:application-server-client"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "2.13.5",
"rimraf": "6.0.1"
}
}
124 changes: 67 additions & 57 deletions server/application-server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/TeamDTO"
$ref: "#/components/schemas/TeamInfoDTO"
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Team"
$ref: "#/components/schemas/TeamInfo"
/admin/config/repositories:
post:
tags:
Expand Down Expand Up @@ -109,7 +109,7 @@ paths:
schema:
type: array
items:
$ref: "#/components/schemas/Team"
$ref: "#/components/schemas/TeamInfo"
/meta:
get:
tags:
Expand Down Expand Up @@ -246,7 +246,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/Team"
$ref: "#/components/schemas/TeamInfo"
components:
schemas:
PullRequestInfo:
Expand Down Expand Up @@ -315,20 +315,16 @@ components:
updatedAt:
type: string
format: date-time
LabelInfo:
AdminConfig:
required:
- color
- id
- name
- repositoriesToMonitor
type: object
properties:
id:
type: integer
format: int64
name:
type: string
color:
type: string
repositoriesToMonitor:
uniqueItems: true
type: array
items:
type: string
UserProfile:
required:
- contributedRepositories
Expand All @@ -353,39 +349,6 @@ components:
type: array
items:
$ref: "#/components/schemas/PullRequestInfo"
PullRequestReviewInfo:
required:
- codeComments
- htmlUrl
- id
- isDismissed
- state
type: object
properties:
id:
type: integer
format: int64
isDismissed:
type: boolean
state:
type: string
enum:
- COMMENTED
- APPROVED
- CHANGES_REQUESTED
- UNKNOWN
codeComments:
type: integer
format: int32
author:
$ref: "#/components/schemas/UserInfo"
pullRequest:
$ref: "#/components/schemas/PullRequestBaseInfo"
htmlUrl:
type: string
submittedAt:
type: string
format: date-time
RepositoryInfo:
required:
- htmlUrl
Expand All @@ -405,13 +368,6 @@ components:
type: string
htmlUrl:
type: string
MetaData:
type: object
properties:
repositoriesToMonitor:
type: array
items:
type: string
UserTeams:
required:
- id
Expand All @@ -434,7 +390,7 @@ components:
uniqueItems: true
type: array
items:
$ref: "#/components/schemas/Team"
$ref: "#/components/schemas/TeamInfo"
PullRequestBaseInfo:
required:
- htmlUrl
Expand Down Expand Up @@ -496,7 +452,21 @@ components:
type: string
htmlUrl:
type: string
Team:
TeamInfo:
required:
- color
- id
- name
type: object
properties:
id:
type: integer
format: int64
name:
type: string
color:
type: string
LabelInfo:
required:
- color
- id
Expand All @@ -510,6 +480,46 @@ components:
type: string
color:
type: string
PullRequestReviewInfo:
required:
- codeComments
- htmlUrl
- id
- isDismissed
- state
type: object
properties:
id:
type: integer
format: int64
isDismissed:
type: boolean
state:
type: string
enum:
- COMMENTED
- APPROVED
- CHANGES_REQUESTED
- UNKNOWN
codeComments:
type: integer
format: int32
author:
$ref: "#/components/schemas/UserInfo"
pullRequest:
$ref: "#/components/schemas/PullRequestBaseInfo"
htmlUrl:
type: string
submittedAt:
type: string
format: date-time
MetaData:
type: object
properties:
repositoriesToMonitor:
type: array
items:
type: string
LeaderboardEntry:
required:
- numberOfApprovals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import de.tum.in.www1.hephaestus.gitprovider.pullrequest.PullRequestInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.pullrequestreview.PullRequestReviewInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.repository.RepositoryInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO;
import io.hypersistence.utils.hibernate.type.util.ClassImportIntegrator;

Expand All @@ -25,7 +25,7 @@ public List<Integrator> getIntegrators() {
@SuppressWarnings("rawtypes")
List<Class> classes = new ArrayList<>();
classes.add(UserInfoDTO.class);
classes.add(TeamDTO.class);
classes.add(TeamInfoDTO.class);
classes.add(IssueInfoDTO.class);
classes.add(LabelInfoDTO.class);
classes.add(MilestoneInfoDTO.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.tum.in.www1.hephaestus.admin;

import java.util.Set;

import org.springframework.lang.NonNull;

public record AdminConfigDTO(@NonNull Set<String> repositoriesToMonitor) {
public static AdminConfigDTO fromAdminConfig(AdminConfig adminConfig) {
return new AdminConfigDTO(adminConfig.getRepositoriesToMonitor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.core.oidc.StandardClaimNames;
Expand All @@ -16,19 +17,16 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.user.UserTeamsDTO;

@RestController
@RequestMapping("/admin")
public class AdminController {

private final AdminService adminService;

public AdminController(AdminService adminService) {
this.adminService = adminService;
}
@Autowired
private AdminService adminService;

@GetMapping
public String admin() {
Expand All @@ -46,9 +44,9 @@ public static record AuthUserInfoDTO(String name, List<String> roles) {
}

@GetMapping("/config")
public ResponseEntity<AdminConfig> getConfig() {
public ResponseEntity<AdminConfigDTO> getConfig() {
try {
return ResponseEntity.ok(adminService.getAdminConfig());
return ResponseEntity.ok(AdminConfigDTO.fromAdminConfig(adminService.getAdminConfig()));
} catch (NoAdminConfigFoundException e) {
return ResponseEntity.notFound().build();
}
Expand Down Expand Up @@ -79,12 +77,12 @@ public ResponseEntity<UserInfoDTO> removeTeamFromUser(@PathVariable String login
}

@PutMapping("/teams")
public ResponseEntity<TeamDTO> createTeam(@RequestBody TeamDTO team) {
public ResponseEntity<TeamInfoDTO> createTeam(@RequestBody TeamInfoDTO team) {
return ResponseEntity.ok(adminService.createTeam(team.name(), team.color()));
}

@DeleteMapping("/teams/{teamId}")
public ResponseEntity<TeamDTO> deleteTeam(@PathVariable Long teamId) {
public ResponseEntity<TeamInfoDTO> deleteTeam(@PathVariable Long teamId) {
return adminService.deleteTeam(teamId)
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.notFound().build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.springframework.stereotype.Service;

import de.tum.in.www1.hephaestus.gitprovider.team.Team;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamDTO;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamInfoDTO;
import de.tum.in.www1.hephaestus.gitprovider.team.TeamService;
import de.tum.in.www1.hephaestus.gitprovider.user.User;
import de.tum.in.www1.hephaestus.gitprovider.user.UserInfoDTO;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void run() {
}
}
// make sure teams are initialized
List<TeamDTO> teams = teamService.getAllTeams();
List<TeamInfoDTO> teams = teamService.getAllTeams();
if (teams.isEmpty()) {
logger.info("No teams found, creating default teams");
teamService.createDefaultTeams();
Expand Down Expand Up @@ -117,18 +117,18 @@ public Optional<UserInfoDTO> removeTeamFromUser(String login, Long teamId) {
return Optional.of(UserInfoDTO.fromUser(user));
}

public TeamDTO createTeam(String name, String color) {
public TeamInfoDTO createTeam(String name, String color) {
logger.info("Creating team with name: " + name + " and color: " + color);
return TeamDTO.fromTeam(teamService.createTeam(name, color));
return TeamInfoDTO.fromTeam(teamService.createTeam(name, color));
}

public Optional<TeamDTO> deleteTeam(Long teamId) {
public Optional<TeamInfoDTO> deleteTeam(Long teamId) {
logger.info("Deleting team with ID: " + teamId);
Optional<Team> optionalTeam = teamService.getTeam(teamId);
if (optionalTeam.isEmpty()) {
return Optional.empty();
}
teamService.deleteTeam(teamId);
return Optional.of(TeamDTO.fromTeam(optionalTeam.get()));
return Optional.of(TeamInfoDTO.fromTeam(optionalTeam.get()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public TeamController(TeamService teamService) {
}

@GetMapping("/all")
public ResponseEntity<List<TeamDTO>> getTeams() {
public ResponseEntity<List<TeamInfoDTO>> getTeams() {
return ResponseEntity.ok(teamService.getAllTeams());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.tum.in.www1.hephaestus.gitprovider.team;

import org.springframework.lang.NonNull;

public record TeamInfoDTO(@NonNull Long id, @NonNull String name, @NonNull String color) {
public static TeamInfoDTO fromTeam(Team team) {
return new TeamInfoDTO(team.getId(), team.getName(), team.getColor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public Optional<Team> getTeam(String name) {
return teamRepository.findByName(name);
}

public List<TeamDTO> getAllTeams() {
List<TeamDTO> teams = teamRepository.findAll().stream().map(TeamDTO::fromTeam).toList();
public List<TeamInfoDTO> getAllTeams() {
List<TeamInfoDTO> teams = teamRepository.findAll().stream().map(TeamInfoDTO::fromTeam).toList();
logger.info("Getting all (" + teams.size() + ") teams");
return teams;
}
Expand Down
Loading

0 comments on commit 1256dfa

Please sign in to comment.