Exemplo n.º 1
0
 /** DELETE /ordenCompras/:id -> delete the "id" ordenCompra. */
 @RequestMapping(
     value = "/ordenCompras/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteOrdenCompra(@PathVariable Long id) {
   log.debug("REST request to delete OrdenCompra : {}", id);
   ordenCompraRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("ordenCompra", id.toString()))
       .build();
 }
Exemplo n.º 2
0
 /** GET /ordenCompras/:id -> get the "id" ordenCompra. */
 @RequestMapping(
     value = "/ordenCompras/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<OrdenCompraDTO> getOrdenCompra(@PathVariable Long id) {
   log.debug("REST request to get OrdenCompra : {}", id);
   return Optional.ofNullable(ordenCompraRepository.findOne(id))
       .map(ordenCompraMapper::ordenCompraToOrdenCompraDTO)
       .map(ordenCompraDTO -> new ResponseEntity<>(ordenCompraDTO, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Exemplo n.º 3
0
 /** GET /ordenCompras -> get all the ordenCompras. */
 @RequestMapping(
     value = "/ordenCompras",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 @Transactional(readOnly = true)
 public ResponseEntity<List<OrdenCompraDTO>> getAllOrdenCompras(Pageable pageable)
     throws URISyntaxException {
   Page<OrdenCompra> page = ordenCompraRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/ordenCompras");
   return new ResponseEntity<>(
       page.getContent()
           .stream()
           .map(ordenCompraMapper::ordenCompraToOrdenCompraDTO)
           .collect(Collectors.toCollection(LinkedList::new)),
       headers,
       HttpStatus.OK);
 }
Exemplo n.º 4
0
 /** PUT /ordenCompras -> Updates an existing ordenCompra. */
 @RequestMapping(
     value = "/ordenCompras",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<OrdenCompraDTO> updateOrdenCompra(
     @Valid @RequestBody OrdenCompraDTO ordenCompraDTO) throws URISyntaxException {
   log.debug("REST request to update OrdenCompra : {}", ordenCompraDTO);
   if (ordenCompraDTO.getId() == null) {
     return createOrdenCompra(ordenCompraDTO);
   }
   OrdenCompra ordenCompra = ordenCompraMapper.ordenCompraDTOToOrdenCompra(ordenCompraDTO);
   OrdenCompra result = ordenCompraRepository.save(ordenCompra);
   return ResponseEntity.ok()
       .headers(
           HeaderUtil.createEntityUpdateAlert("ordenCompra", ordenCompraDTO.getId().toString()))
       .body(ordenCompraMapper.ordenCompraToOrdenCompraDTO(result));
 }
Exemplo n.º 5
0
 /** POST /ordenCompras -> Create a new ordenCompra. */
 @RequestMapping(
     value = "/ordenCompras",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<OrdenCompraDTO> createOrdenCompra(
     @Valid @RequestBody OrdenCompraDTO ordenCompraDTO) throws URISyntaxException {
   log.debug("REST request to save OrdenCompra : {}", ordenCompraDTO);
   if (ordenCompraDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new ordenCompra cannot already have an ID")
         .body(null);
   }
   OrdenCompra ordenCompra = ordenCompraMapper.ordenCompraDTOToOrdenCompra(ordenCompraDTO);
   OrdenCompra result = ordenCompraRepository.save(ordenCompra);
   return ResponseEntity.created(new URI("/api/ordenCompras/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("ordenCompra", result.getId().toString()))
       .body(ordenCompraMapper.ordenCompraToOrdenCompraDTO(result));
 }