Exemplo n.º 1
0
  @RequestMapping(value = "", method = RequestMethod.GET)
  @Interceptors({ProjectMemberRequired.class})
  @ResponseBody
  @Cacheable(value = GET_STORIES_CACHE, key = "#projectId + #type + #parentStoryId")
  public List<StoryDTO> getProjectStories(
      @PathVariable("projectId") int projectId,
      @RequestParam(value = "type", required = false, defaultValue = "all") String type,
      @RequestParam(value = "parentStoryId", required = false, defaultValue = "0")
          Integer parentStoryId) {
    if (parentStoryId < 0) {
      throw new BadRequestException("parameter page shoud be positive integer.");
    }
    List<Story> stories = null;
    if (type.equals(GET_COMPLETED_STORIES)) {
      stories = storyService.getAllCompletedStoriesByProjectId(projectId);
    } else if (type.equals(GET_UNCOMPLETED_STORIES)) {
      stories = storyService.getUnCompletedStoriesByParentId(projectId, parentStoryId);
    } else {
      stories = storyService.getAllStoriesByProjectId(projectId, parentStoryId);
    }

    List<StoryDTO> storyDTOs =
        Lists.newArrayList(Lists.transform(stories, StoryTransform.STORY_DTO_FUNCTION));
    fillStoryDTOs(storyDTOs);
    return storyDTOs;
  }