public Category(org.apache.rave.model.Category category) { this.id = category.getId(); this.text = category.getText(); }
private boolean validateRequest(Category category, User modifier){ return (validateRequest(category.getText(),modifier) && (categoryService.get(category.getId()) != null)); }
@RequestMapping(value = {"/admin/category/update"}, method = RequestMethod.POST) public String updateCategory(@ModelAttribute(ModelKeys.CATEGORY) Category category, @ModelAttribute(ModelKeys.TOKENCHECK) String sessionToken, @RequestParam String token, @RequestParam(required = false) String referringPageId, Model model, SessionStatus status){ checkTokens(sessionToken, token, status); model.addAttribute(ModelKeys.REFERRING_PAGE_ID, referringPageId); User currentUser = userService.getAuthenticatedUser(); boolean isValidRequest = validateRequest(category, currentUser); if (isValidRequest) { categoryService.update(category.getId(), category.getText(), currentUser); } else { addNavigationMenusToModel(SELECTED_ITEM, model, referringPageId); return ViewNames.ADMIN_CATEGORY_DETAIL; } status.setComplete(); model.asMap().clear(); return "redirect:/app/admin/categories?action=update&referringPageId=" + referringPageId; }
private Map<String, Category> saveCategories(ModelWrapper wrapper, Map<String, User> usersByOriginalId) { Map<String, Category> categoryByOldId = Maps.newHashMap(); if (wrapper.getCategories() != null) { for (Category category : wrapper.getCategories()) { String id = category.getId() == null ? category.getText() : category.getId(); category.setId(null); User lastModified = usersByOriginalId.get(category.getLastModifiedUserId()); if (lastModified != null) { category.setLastModifiedUserId(lastModified.getId()); } User created = usersByOriginalId.get(category.getCreatedUserId()); if (created != null) { category.setCreatedUserId(created.getId()); } categoryByOldId.put(id, categoryRepository.save(category)); } } return categoryByOldId; }
private void updateProperties(Category source, JpaCategory converted) { converted.setId(source.getId()); converted.setCreatedDate(source.getCreatedDate()); converted.setCreatedUserId(source.getCreatedUserId()); converted.setLastModifiedDate(source.getLastModifiedDate()); converted.setLastModifiedUserId(source.getLastModifiedUserId()); converted.setText(source.getText()); converted.setWidgets(source.getWidgets()); } }