use of com.nixmash.blog.jpa.model.Tag in project nixmash-blog by mintster.
the class PostsController method tagTitles.
@RequestMapping(value = "/titles/tag/{tagValue}", method = GET)
public String tagTitles(@PathVariable("tagValue") String tagValue, Model model) throws TagNotFoundException, UnsupportedEncodingException {
Tag tag = postService.getTag(URLDecoder.decode(tagValue, "UTF-8"));
boolean showMore = postService.getPublishedPostsByTagId(tag.getTagId()).size() > TITLE_PAGING_SIZE;
model.addAttribute("tag", tag);
model.addAttribute("showmore", showMore);
return POSTS_TAGTITLES_VIEW;
}
use of com.nixmash.blog.jpa.model.Tag in project nixmash-blog by mintster.
the class AdminPostsController method tagList.
// endregion
// region Tags
@RequestMapping(value = "/tags", method = GET)
public ModelAndView tagList(Model model) {
ModelAndView mav = new ModelAndView();
mav.addObject("tags", postService.getTagCloud(-1));
mav.addObject("newTag", new Tag());
mav.setViewName(ADMIN_TAGS_VIEW);
return mav;
}
use of com.nixmash.blog.jpa.model.Tag in project nixmash-blog by mintster.
the class AdminPostsController method addTag.
@RequestMapping(value = "/tags/new", method = RequestMethod.POST)
public String addTag(@Valid TagDTO tagDTO, BindingResult result, SessionStatus status, RedirectAttributes attributes) {
if (result.hasErrors()) {
return ADMIN_TAGS_VIEW;
} else {
Tag tag = postService.createTag(tagDTO);
logger.info("Tag Added: {}", tag.getTagValue());
status.setComplete();
webUI.addFeedbackMessage(attributes, FEEDBACK_MESSAGE_TAG_ADDED, tag.getTagValue());
return "redirect:/admin/posts/tags";
}
}
use of com.nixmash.blog.jpa.model.Tag in project nixmash-blog by mintster.
the class AdminPostsControllerTests method deleteTag_decreases_tag_count.
@Test
public void deleteTag_decreases_tag_count() throws Exception {
int preTagCount = postService.getTagDTOs().size();
Tag preTag = postService.getTag("h2tagsix");
mvc.perform(deleteTagRequest(preTag.getTagId())).andExpect(redirectedUrl("/admin/posts/tags"));
int postTagCount = postService.getTagDTOs().size();
assertThat(postTagCount, is(lessThan(preTagCount)));
}
use of com.nixmash.blog.jpa.model.Tag in project nixmash-blog by mintster.
the class AdminPostsControllerTests method updateTag_changes_tag_value.
@Test
public void updateTag_changes_tag_value() throws Exception {
Tag preTag = postService.getTag("h2tagfour");
mvc.perform(updateTagRequest(preTag.getTagId(), "updateChangesTagName")).andExpect(redirectedUrl("/admin/posts/tags"));
Tag postTag = postService.getTag("updateChangesTagName");
assertEquals(preTag.getTagId(), postTag.getTagId());
}
Aggregations