Exemple #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);
 }
Exemple #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);
 }
Exemple #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);
 }