示例#1
0
 public void updateCategoryParent(String categoryName, String parentCategoryName) {
   Category find = categoryDAL.findCategoryByName(categoryName);
   if (find == null) {
     throw CategoryException.CategoryNonExistException(categoryName);
   }
   Category parent = categoryDAL.findCategoryByName(parentCategoryName);
   if (parent == null) {
     throw CategoryException.parentCategoryNotExistException(parentCategoryName);
   }
   find.setParent(parent);
   categoryDAL.merge(find);
 }
示例#2
0
 public void updateCategoryParent(long categoryId, long parentCategoryId) {
   Category find = categoryDAL.find(Category.class, categoryId);
   if (find == null) {
     throw CategoryException.CategoryNonExistException(categoryId);
   }
   Category parent = categoryDAL.find(Category.class, categoryId);
   if (parent == null) {
     throw CategoryException.parentCategoryNotExistException(parentCategoryId);
   }
   find.setParent(parent);
   categoryDAL.merge(find);
 }
示例#3
0
 @Transactional
 public void newCategory(Category category) {
   validator.validate(category);
   Category find = categoryDAL.findCategoryByName(category.getName());
   if (find != null) {
     throw CategoryException.CategoryAlreadyExistException(category.getName());
   }
   Category parentValue = category.getParent();
   if (parentValue != null) {
     Category parent = categoryDAL.find(Category.class, parentValue.getId());
     if (parent == null) {
       throw CategoryException.parentCategoryNotExistException(parentValue.getId());
     }
   }
   categoryDAL.insert(category);
 }
示例#4
0
 @Transactional
 public void disableCategory(long categoryId, boolean disableChildren) {
   if (disableChildren) {
     categoryDAL.disableCategoryRecursively(categoryId);
   } else {
     int size = categoryDAL.getChildrenSize(categoryId);
     if (size != 0) {
       throw CategoryException.disableCategoryChildrenExistException();
     }
     categoryDAL.disableCategoryRecursively(categoryId);
   }
 }