backend fixed Patch Research

This commit is contained in:
Bartha Maxime 2024-04-17 23:00:00 +02:00
parent 3ea48c20aa
commit 47f1bffb24
2 changed files with 11 additions and 13 deletions

View File

@ -80,9 +80,10 @@ public class ResearcherController {
Researcher researcher = researchesServ.getResearcherById(id); Researcher researcher = researchesServ.getResearcherById(id);
if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin}, token) if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin}, token)
|| researcher == researchesServ.getResearcherByUser(authServ.getUserFromToken(token))) && researcher.getId() != researchesServ.getResearcherByUser(authServ.getUserFromToken(token)).getId())
return new UnauthorizedResponse<>(null); return new UnauthorizedResponse<>(null);
if (researcher == null) return new ResponseEntity<>(HttpStatus.BAD_REQUEST); if (researcher == null) return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
researchesServ.modifyResearcherData(researcher,updates); researchesServ.modifyResearcherData(researcher,updates);

View File

@ -83,18 +83,9 @@ public class ResearchesService {
case "title": case "title":
research.setTitle((String) entry.getValue()); research.setTitle((String) entry.getValue());
break; break;
case "date":
research.setReleaseDate((Date) entry.getValue());
break;
case "paperType": case "paperType":
research.setPaperType((PaperType) entry.getValue()); research.setPaperType((PaperType) entry.getValue());
break; break;
case "PdfLocation":
research.setPdfLocation((String) entry.getValue());
break;
case "bibtexLocation":
research.setBibTexLocation((String) entry.getValue());
break;
case "language": case "language":
research.setLanguage((String) entry.getValue()); research.setLanguage((String) entry.getValue());
break; break;
@ -104,6 +95,9 @@ public class ResearchesService {
case "summary": case "summary":
research.setSummary((String) entry.getValue()); research.setSummary((String) entry.getValue());
break; break;
case "access":
research.setAccess(Access.valueOf((String) entry.getValue()));
break;
} }
} }
articleRepo.save(research); articleRepo.save(research);
@ -175,12 +169,15 @@ public class ResearchesService {
for (Map.Entry<String, Object> entry : updates.entrySet()){ for (Map.Entry<String, Object> entry : updates.entrySet()){
switch (entry.getKey()){ switch (entry.getKey()){
case "orcidId": case "orcidId":
if (entry.getValue() != null)
researcher.setOrcidId((String) entry.getValue()); researcher.setOrcidId((String) entry.getValue());
break; break;
case "domain": case "domain":
if (entry.getValue() != null)
researcher.setDomain((String) entry.getValue()); researcher.setDomain((String) entry.getValue());
break; break;
case "site": case "site":
if (entry.getValue() != null)
researcher.setSite((String) entry.getValue()); researcher.setSite((String) entry.getValue());
break; break;
} }