コード例 #1
0
 /** GET /projects -> get all the projects. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 @Transactional(readOnly = true)
 public List<ProjectDTO> getAllProjects() {
   log.debug("REST request to get all Projects");
   return projectService.findAll();
 }
コード例 #2
0
 /** GET /projects/:id -> get the "id" project. */
 @RequestMapping(
     value = "/projects/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<ProjectDTO> getProject(@PathVariable String id) {
   log.debug("REST request to get Project : {}", id);
   ProjectDTO projectDTO = projectService.findOne(id);
   return Optional.ofNullable(projectDTO)
       .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
コード例 #3
0
 /** DELETE /projects/:id -> delete the "id" project. */
 @RequestMapping(
     value = "/projects/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteProject(@PathVariable String id) {
   log.debug("REST request to delete Project : {}", id);
   projectService.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("project", id.toString()))
       .build();
 }
コード例 #4
0
 /** PUT /projects -> Updates an existing project. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<ProjectDTO> updateProject(@RequestBody ProjectDTO projectDTO)
     throws URISyntaxException {
   log.debug("REST request to update Project : {}", projectDTO);
   if (projectDTO.getId() == null) {
     return createProject(projectDTO);
   }
   ProjectDTO result = projectService.save(projectDTO);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("project", projectDTO.getId().toString()))
       .body(result);
 }
コード例 #5
0
 /** POST /projects -> Create a new project. */
 @RequestMapping(
     value = "/projects",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<ProjectDTO> createProject(@RequestBody ProjectDTO projectDTO)
     throws URISyntaxException {
   log.debug("REST request to save Project : {}", projectDTO);
   if (projectDTO.getId() != null) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "project", "idexists", "A new project cannot already have an ID"))
         .body(null);
   }
   ProjectDTO result = projectService.save(projectDTO);
   return ResponseEntity.created(new URI("/api/projects/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("project", result.getId().toString()))
       .body(result);
 }