Example #1
0
 /** GET /specialitys -> get all the specialitys. */
 @RequestMapping(
     value = "/specialitys",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<Speciality> getAllSpecialitys() {
   log.debug("REST request to get all Specialitys");
   return specialityRepository.findAll();
 }
Example #2
0
 /** GET /specialitys/:id -> get the "id" speciality. */
 @RequestMapping(
     value = "/specialitys/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Speciality> getSpeciality(@PathVariable Long id) {
   log.debug("REST request to get Speciality : {}", id);
   return Optional.ofNullable(specialityRepository.findOne(id))
       .map(speciality -> new ResponseEntity<>(speciality, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Example #3
0
 /** DELETE /specialitys/:id -> delete the "id" speciality. */
 @RequestMapping(
     value = "/specialitys/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteSpeciality(@PathVariable Long id) {
   log.debug("REST request to delete Speciality : {}", id);
   specialityRepository.delete(id);
   specialitySearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("speciality", id.toString()))
       .build();
 }
Example #4
0
 /** PUT /specialitys -> Updates an existing speciality. */
 @RequestMapping(
     value = "/specialitys",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Speciality> updateSpeciality(@Valid @RequestBody Speciality speciality)
     throws URISyntaxException {
   log.debug("REST request to update Speciality : {}", speciality);
   if (speciality.getId() == null) {
     return createSpeciality(speciality);
   }
   Speciality result = specialityRepository.save(speciality);
   specialitySearchRepository.save(speciality);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("speciality", speciality.getId().toString()))
       .body(result);
 }
Example #5
0
 /** POST /specialitys -> Create a new speciality. */
 @RequestMapping(
     value = "/specialitys",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Speciality> createSpeciality(@Valid @RequestBody Speciality speciality)
     throws URISyntaxException {
   log.debug("REST request to save Speciality : {}", speciality);
   if (speciality.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new speciality cannot already have an ID")
         .body(null);
   }
   Speciality result = specialityRepository.save(speciality);
   specialitySearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/specialitys/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("speciality", result.getId().toString()))
       .body(result);
 }