diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 05f939f..166e64b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -114,15 +114,15 @@ public class MockController { Research jojoResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(0), PaperType.Article,"here",null,"english", - Access.OpenSource,"IT","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); + Access.OpenSource,"IT","This Article's title speaks for itself \n We'll discuss about advanced Graph search Algorithms"); - Research restrictedResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(1111111111), + Research restrictedResearch = new Research("just another Name",output,new Date(1111111111), PaperType.Article,"restricted",null,"english", - Access.Restricted,"Restricted","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); + Access.Restricted,"Restricted","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); - Research privateResearch = new Research("Graphs : Advanced Search Algorithms",output,new Date(), + Research privateResearch = new Research("the great Potato War",output,new Date(), PaperType.Article,"private",null,"english", - Access.Private,"private","This Article's title speak for itself\n We'll discuss about advanced Graph search Algorithms"); + Access.Private,"private","This Article's title speaks for itself\n We'll discuss about advanced Graph search Algorithms"); researchesService.saveResearch(restrictedResearch); diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java index c9b6270..a29917e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java @@ -73,6 +73,25 @@ public class ResearchController { return new ResponseEntity<>(toReturnResearches,HttpStatus.OK); } + + @GetMapping("/researches/{id}") + public ResponseEntity> getResearchesFromResearcher(@RequestHeader(value = "Authorization",required = false) String token, + @PathVariable Long id + ){ + Iterable researches = researchesServ.getResearchesByAuthor(id); + if (researches == null) return new ResponseEntity<>(HttpStatus.NOT_FOUND); + + ArrayList toReturnResearches = new ArrayList<>(); + + for (Research research: researches){ + if (researchesServ.hasNoAccessTo(research,authServ.getUserFromToken(token))){ + research.setPdfLocation(null); + } + toReturnResearches.add(ResearchDTO.construct(research)); + } + return new ResponseEntity<>(toReturnResearches,HttpStatus.OK); + } + /** post a new research * * @return the research saved diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearcherRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearcherRepository.java index a143972..5863bc4 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearcherRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearcherRepository.java @@ -1,6 +1,8 @@ package ovh.herisson.Clyde.Repositories.ScientificPublications; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.ScientificPublications.Research; import ovh.herisson.Clyde.Tables.ScientificPublications.Researcher; import ovh.herisson.Clyde.Tables.User; @@ -8,4 +10,7 @@ public interface ResearcherRepository extends CrudRepository { Researcher findByUser(User user); Researcher findById(long id); + + @Query("select r from Research r where r.author = ?1") + Iterable findAllByAuthorId(Researcher author); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java index c3eedd4..ae025ce 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/StatsRepository.java @@ -11,7 +11,7 @@ public interface StatsRepository extends CrudRepository { @Query("select new map(to_char(r.releaseDate, 'month') as label, sum(r.views) as y) from Research r group by to_char(r.releaseDate, 'month')") Iterable> viewsByMonths(); - +/** Iterable> viewsByYears(); Iterable> viewsByTopics(); Iterable> coAuthorByMonths(); @@ -22,6 +22,6 @@ public interface StatsRepository extends CrudRepository { Iterable> researchesByYears(); Iterable> researchesByTopics(); Iterable> researchesByMonth(); - +**/ } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/ResearchesService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/ResearchesService.java index 51f7708..213c738 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/ResearchesService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ScientificPublications/ResearchesService.java @@ -42,6 +42,13 @@ public class ResearchesService { return articleRepo.findById(id); } + public Iterable getResearchesByAuthor(long authorId){ + Researcher researcher = researcherRepo.findById(authorId); + if (researcher == null) return null; + + return researcherRepo.findAllByAuthorId(researcher); + } + public boolean hasNoAccessTo(Research research, User user){ diff --git a/frontend/src/Apps/ScientificPublications/FilterComponent.vue b/frontend/src/Apps/ScientificPublications/FilterComponent.vue index 534fd0c..238a31d 100644 --- a/frontend/src/Apps/ScientificPublications/FilterComponent.vue +++ b/frontend/src/Apps/ScientificPublications/FilterComponent.vue @@ -7,18 +7,71 @@