예제 #1
0
 /** GET /fases/:id -> get the "id" fase. */
 @RequestMapping(
     value = "/fases/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<FaseDTO> get(@PathVariable Long id) {
   log.debug("REST request to get Fase : {}", id);
   return Optional.ofNullable(faseRepository.findOne(id))
       .map(faseMapper::faseToFaseDTO)
       .map(faseDTO -> new ResponseEntity<>(faseDTO, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
예제 #2
0
 /** DELETE /fases/:id -> delete the "id" fase. */
 @RequestMapping(
     value = "/fases/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> delete(@PathVariable Long id) {
   log.debug("REST request to delete Fase : {}", id);
   faseRepository.delete(id);
   faseSearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("fase", id.toString()))
       .build();
 }
예제 #3
0
 /** PUT /fases -> Updates an existing fase. */
 @RequestMapping(
     value = "/fases",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<FaseDTO> update(@RequestBody FaseDTO faseDTO) throws URISyntaxException {
   log.debug("REST request to update Fase : {}", faseDTO);
   if (faseDTO.getId() == null) {
     return create(faseDTO);
   }
   Fase fase = faseMapper.faseDTOToFase(faseDTO);
   Fase result = faseRepository.save(fase);
   faseSearchRepository.save(fase);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("fase", faseDTO.getId().toString()))
       .body(faseMapper.faseToFaseDTO(result));
 }
예제 #4
0
 /** POST /fases -> Create a new fase. */
 @RequestMapping(
     value = "/fases",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<FaseDTO> create(@RequestBody FaseDTO faseDTO) throws URISyntaxException {
   log.debug("REST request to save Fase : {}", faseDTO);
   if (faseDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new fase cannot already have an ID")
         .body(null);
   }
   Fase fase = faseMapper.faseDTOToFase(faseDTO);
   Fase result = faseRepository.save(fase);
   faseSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/fases/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("fase", result.getId().toString()))
       .body(faseMapper.faseToFaseDTO(result));
 }
예제 #5
0
 /** GET /fases -> get all the fases. */
 @RequestMapping(
     value = "/fases",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 @Transactional(readOnly = true)
 public ResponseEntity<List<FaseDTO>> getAll(
     @RequestParam(value = "page", required = false) Integer offset,
     @RequestParam(value = "per_page", required = false) Integer limit)
     throws URISyntaxException {
   Page<Fase> page = faseRepository.findAll(PaginationUtil.generatePageRequest(offset, limit));
   HttpHeaders headers =
       PaginationUtil.generatePaginationHttpHeaders(page, "/api/fases", offset, limit);
   return new ResponseEntity<>(
       page.getContent()
           .stream()
           .map(faseMapper::faseToFaseDTO)
           .collect(Collectors.toCollection(LinkedList::new)),
       headers,
       HttpStatus.OK);
 }