-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
159 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...-server/src/main/java/de/tum/in/www1/hephaestus/codereview/comment/CommentConnection.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...src/main/java/de/tum/in/www1/hephaestus/codereview/pullrequest/PullrequestConnection.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...er/src/main/java/de/tum/in/www1/hephaestus/codereview/repository/RepositoryConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.tum.in.www1.hephaestus.codereview.repository; | ||
|
||
import java.time.Instant; | ||
|
||
import org.kohsuke.github.GHRepository; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.data.convert.ReadingConverter; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@ReadingConverter | ||
public class RepositoryConverter implements Converter<GHRepository, Repository> { | ||
|
||
@Override | ||
@Nullable | ||
public Repository convert(@NonNull GHRepository source) { | ||
Repository repository = new Repository(); | ||
repository.setName(source.getName()); | ||
repository.setNameWithOwner(source.getFullName()); | ||
repository.setUrl(source.getHtmlUrl().toString()); | ||
repository.setDescription(source.getDescription()); | ||
repository.setAddedAt(Instant.now()); | ||
return repository; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...r/src/main/java/de/tum/in/www1/hephaestus/codereview/repository/RepositoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.tum.in.www1.hephaestus.codereview.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import de.tum.in.www1.hephaestus.codereview.repository.Repository; | ||
|
||
@org.springframework.stereotype.Repository | ||
public interface RepositoryRepository | ||
extends JpaRepository<Repository, Long> { | ||
|
||
@Query("SELECT r FROM Repository r WHERE r.nameWithOwner = ?1") | ||
Repository findByNameWithOwner(String nameWithOwner); | ||
} |
57 changes: 57 additions & 0 deletions
57
...rver/src/main/java/de/tum/in/www1/hephaestus/codereview/repository/RepositoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package de.tum.in.www1.hephaestus.codereview.repository; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class RepositoryService { | ||
private static final Logger logger = LoggerFactory.getLogger(Repository.class); | ||
|
||
private final RepositoryRepository repositoryRepository; | ||
|
||
public RepositoryService(RepositoryRepository repositoryRepository) { | ||
this.repositoryRepository = repositoryRepository; | ||
} | ||
|
||
/** | ||
* Retrieves all {@link Repository} entities. | ||
* | ||
* @return A list of all Repository entities | ||
*/ | ||
public List<Repository> getAllRepositories() { | ||
var repositories = repositoryRepository.findAll(); | ||
logger.info("Getting Repositories: {}", repositories); | ||
return repositoryRepository.findAll(); | ||
} | ||
|
||
public Repository getRepository(String nameWithOwner) { | ||
return repositoryRepository.findByNameWithOwner(nameWithOwner); | ||
} | ||
|
||
/** | ||
* Creates a new {@link Repository} entity with the current timestamp and saves | ||
* it to | ||
* the repository. | ||
* | ||
* @return The created Repository entity | ||
*/ | ||
public Repository addRepository() { | ||
Repository repository = new Repository(); | ||
repository.setAddedAt(Instant.now()); | ||
logger.info("Adding new Repository with timestamp: {}", repository.getAddedAt()); | ||
return repositoryRepository.save(repository); | ||
} | ||
|
||
public Repository saveRepository(Repository repository) { | ||
logger.info("Adding Repository: {}", repository.getNameWithOwner()); | ||
return repositoryRepository.save(repository); | ||
} | ||
|
||
public long countRepositories() { | ||
return repositoryRepository.count(); | ||
} | ||
} |