Exemplo n.º 1
0
 /** GET /polCandidates/:id -> get the "id" polCandidate. */
 @RequestMapping(
     value = "/polCandidates/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PolCandidate> getPolCandidate(@PathVariable Long id) {
   log.debug("REST request to get PolCandidate : {}", id);
   PolCandidate polCandidate = polCandidateRepository.findOneWithEagerRelationships(id);
   return Optional.ofNullable(polCandidate)
       .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Exemplo n.º 2
0
 /** GET /polCandidates -> get all the polCandidates. */
 @RequestMapping(
     value = "/polCandidates",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<PolCandidate>> getAllPolCandidates(Pageable pageable)
     throws URISyntaxException {
   log.debug("REST request to get a page of PolCandidates");
   Page<PolCandidate> page = polCandidateRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/polCandidates");
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
Exemplo n.º 3
0
 /** DELETE /polCandidates/:id -> delete the "id" polCandidate. */
 @RequestMapping(
     value = "/polCandidates/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deletePolCandidate(@PathVariable Long id) {
   log.debug("REST request to delete PolCandidate : {}", id);
   polCandidateRepository.delete(id);
   polCandidateSearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("polCandidate", id.toString()))
       .build();
 }
Exemplo n.º 4
0
 /** PUT /polCandidates -> Updates an existing polCandidate. */
 @RequestMapping(
     value = "/polCandidates",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PolCandidate> updatePolCandidate(
     @Valid @RequestBody PolCandidate polCandidate) throws URISyntaxException {
   log.debug("REST request to update PolCandidate : {}", polCandidate);
   if (polCandidate.getId() == null) {
     return createPolCandidate(polCandidate);
   }
   PolCandidate result = polCandidateRepository.save(polCandidate);
   polCandidateSearchRepository.save(result);
   return ResponseEntity.ok()
       .headers(
           HeaderUtil.createEntityUpdateAlert("polCandidate", polCandidate.getId().toString()))
       .body(result);
 }
Exemplo n.º 5
0
 /** POST /polCandidates -> Create a new polCandidate. */
 @RequestMapping(
     value = "/polCandidates",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<PolCandidate> createPolCandidate(
     @Valid @RequestBody PolCandidate polCandidate) throws URISyntaxException {
   log.debug("REST request to save PolCandidate : {}", polCandidate);
   if (polCandidate.getId() != null) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "polCandidate", "idexists", "A new polCandidate cannot already have an ID"))
         .body(null);
   }
   PolCandidate result = polCandidateRepository.save(polCandidate);
   polCandidateSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/polCandidates/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("polCandidate", result.getId().toString()))
       .body(result);
 }