Skip to content

Commit

Permalink
Merge pull request #98 from correctexam/develop
Browse files Browse the repository at this point in the history
new route to query all zone for an exam
  • Loading branch information
barais authored Oct 30, 2023
2 parents 52877a0 + 932e02e commit 4ac75b1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
33 changes: 33 additions & 0 deletions src/main/java/fr/istic/service/ZoneService.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,37 @@ public Optional<ZoneDTO> partialResizeUpdate(ResizeZoneDTO rzoneDTO, long id) {
}




public ZoneDTO[] getZone4Exam(Long examid) {
log.debug("Request to get Zone 4 Exam: {}", examid);
var resp = new ZoneDTO[3];
Optional<Exam> ex = Exam.findByIdOptional(examid) ;
if (ex.isPresent()){
if (ex.get().namezone != null){
resp[0]=zoneMapper.toDto(ex.get().namezone);
} else {
resp[0]=new ZoneDTO();
}
if (ex.get().firstnamezone != null){
resp[1]=zoneMapper.toDto(ex.get().firstnamezone);
} else {
resp[1]=new ZoneDTO();
}
if (ex.get().idzone != null){
resp[2]=zoneMapper.toDto(ex.get().idzone);
} else {
resp[2]=new ZoneDTO();
}

} else {
resp[0]=new ZoneDTO();
resp[0]=new ZoneDTO();
resp[0]=new ZoneDTO();

}
return resp;
}


}
6 changes: 3 additions & 3 deletions src/main/java/fr/istic/web/rest/ExtendedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1232,11 +1232,11 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE
@GET
@Path("/getScanPdf/{scanId}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@RolesAllowed({ AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN })
// @RolesAllowed({ AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN })
public Response getScan(@PathParam("scanId") long scanId, @Context SecurityContext ctx) {
if (!securityService.canAccess(ctx, scanId, Scan.class)) {
/* if (!securityService.canAccess(ctx, scanId, Scan.class)) {
return Response.status(403, "Current user cannot access to this ressource").build();
}
}*/
try {
if (this.fichierS3Service.isObjectExist("scan/" + scanId + ".pdf")) {

Expand Down
18 changes: 17 additions & 1 deletion src/main/java/fr/istic/web/rest/ZoneResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.*;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

Expand Down Expand Up @@ -150,6 +149,23 @@ public Response getZone(@PathParam("id") Long id, @Context SecurityContext ctx)
return ResponseUtil.wrapOrNotFound(zoneDTO);
}

/**
* {@code GET /zones/:id} : get the "id" zone.
*
* @param id the id of the zoneDTO to retrieve.
* @return the {@link Response} with status {@code 200 (OK)} and with body the zoneDTO, or with status {@code 404 (Not Found)}.
*/
@GET
@Path("/byExam/{examid}")
public Response getZoneByExam(@PathParam("examid") Long examid, @Context SecurityContext ctx) {
log.debug("REST request to get Zone : {}", examid);
// No scurity for voir copies
ZoneDTO[] zoneDTOs = zoneService.getZone4Exam(examid);
var response = Response.ok().entity(zoneDTOs);
return response.build();
}


/**
* {@code PATCH /zones/:id} : Partial updates given fields of an existing zone, field will ignore if it is null
*
Expand Down

0 comments on commit 4ac75b1

Please sign in to comment.