// Path: src/main/java/yourwebproject2/model/entity/Category.java
// @Entity
// @Table(indexes = {  @Index(name="name_idx", columnList = "name", unique = true),
//         @Index(name="priority_idx", columnList = "priority"),
//         @Index(name="parentCategory_idx", columnList = "parent_category")})
// public class Category extends JPAEntity<Long> {
//     private String name;
//     private Integer priority;
//     private Category parentCategory;
// 
//     @NotNull @NotBlank
//     @Column
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @NotNull
//     @Column
//     public Integer getPriority() {
//         return priority;
//     }
// 
//     public void setPriority(Integer priority) {
//         this.priority = priority;
//     }
// 
//     @ManyToOne(fetch = FetchType.EAGER)
//     public Category getParentCategory() {
//         return parentCategory;
//     }
// 
//     public void setParentCategory(Category parentCategory) {
//         this.parentCategory = parentCategory;
//     }
// 
//     @Override
//     public String toString() {
//         return "Category{" +
//                 "name='" + name + '\'' +
//                 ", priority=" + priority +
//                 ", parentCategory=" + parentCategory +
//                 '}';
//     }
// }
// 
// Path: src/main/java/yourwebproject2/service/CategoryService.java
// public interface CategoryService extends BaseService<Category, Long> {
//     /**
//      * Validates whether the given category already
//      * exists in the system.
//      *
//      * @param categoryName
//      *
//      * @return
//      */
//     public boolean isCategoryPresent(String categoryName);
// 
//     /**
//      * Validates whether the given category priority already
//      * exists in the system.
//      *
//      * @param priorityId
//      *
//      * @return
//      */
//     public boolean isPriorityPresent(Integer priorityId);
// 
//     /**
//      * Find category by name
//      *
//      * @param categoryName
//      * @return
//      */
//     public Category findByCategoryName(String categoryName) throws NotFoundException;
// 
//     /**
//      * Find sub categories by parent category
//      *
//      * @param parentCategory
//      * @return
//      */
//     public List<Category> findSubCategories(Category parentCategory) throws NotFoundException;
// }


import yourwebproject2.model.entity.Category;
import yourwebproject2.service.CategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.HashMap;
                    break;
                case "parent":
                    params.put("parent", p[1]);
                    break;
            }
        }

        Integer priority = null;
        if(params.containsKey("name") && (params.containsKey("priority") || params.containsKey("parent"))) {
            if(params.containsKey("priority")) {
                try {
                    priority = Integer.parseInt(params.get("priority"));
                } catch (NumberFormatException nfe) {
                    System.out.println("Priority not a number");
                    System.exit(1);
                }
            }
        } else {
            printUsage();
        }

        LOG.info("Params: "+params);
        System.out.println("Params: "+params);

        ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"classpath:/config/spring/appContext-jdbc.xml",
                "classpath:/config/spring/appContext-repository.xml",
                "classpath:/config/spring/appContext-service.xml",
                "classpath:/config/spring/appContext-interceptor.xml"}, true);
        LOG.info("Loaded the context: " + ctx.getBeanDefinitionNames());

// Path: src/main/java/yourwebproject2/model/entity/Category.java
// @Entity
// @Table(indexes = {  @Index(name="name_idx", columnList = "name", unique = true),
//         @Index(name="priority_idx", columnList = "priority"),
//         @Index(name="parentCategory_idx", columnList = "parent_category")})
// public class Category extends JPAEntity<Long> {
//     private String name;
//     private Integer priority;
//     private Category parentCategory;
// 
//     @NotNull @NotBlank
//     @Column
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     @NotNull
//     @Column
//     public Integer getPriority() {
//         return priority;
//     }
// 
//     public void setPriority(Integer priority) {
//         this.priority = priority;
//     }
// 
//     @ManyToOne(fetch = FetchType.EAGER)
//     public Category getParentCategory() {
//         return parentCategory;
//     }
// 
//     public void setParentCategory(Category parentCategory) {
//         this.parentCategory = parentCategory;
//     }
// 
//     @Override
//     public String toString() {
//         return "Category{" +
//                 "name='" + name + '\'' +
//                 ", priority=" + priority +
//                 ", parentCategory=" + parentCategory +
//                 '}';
//     }
// }
// 
// Path: src/main/java/yourwebproject2/service/CategoryService.java
// public interface CategoryService extends BaseService<Category, Long> {
//     /**
//      * Validates whether the given category already
//      * exists in the system.
//      *
//      * @param categoryName
//      *
//      * @return
//      */
//     public boolean isCategoryPresent(String categoryName);
// 
//     /**
//      * Validates whether the given category priority already
//      * exists in the system.
//      *
//      * @param priorityId
//      *
//      * @return
//      */
//     public boolean isPriorityPresent(Integer priorityId);
// 
//     /**
//      * Find category by name
//      *
//      * @param categoryName
//      * @return
//      */
//     public Category findByCategoryName(String categoryName) throws NotFoundException;
// 
//     /**
//      * Find sub categories by parent category
//      *
//      * @param parentCategory
//      * @return
//      */
//     public List<Category> findSubCategories(Category parentCategory) throws NotFoundException;
// }


// Path: src/main/java/yourwebproject2/core/tool/CategoryTool.java
import yourwebproject2.model.entity.Category;
import yourwebproject2.service.CategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.HashMap;

                    break;
                case "parent":
                    params.put("parent", p[1]);
                    break;
            }
        }

        Integer priority = null;
        if(params.containsKey("name") && (params.containsKey("priority") || params.containsKey("parent"))) {
            if(params.containsKey("priority")) {
                try {
                    priority = Integer.parseInt(params.get("priority"));
                } catch (NumberFormatException nfe) {
                    System.out.println("Priority not a number");
                    System.exit(1);
                }
            }
        } else {
            printUsage();
        }

        LOG.info("Params: "+params);
        System.out.println("Params: "+params);

        ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"classpath:/config/spring/appContext-jdbc.xml",
                "classpath:/config/spring/appContext-repository.xml",
                "classpath:/config/spring/appContext-service.xml",
                "classpath:/config/spring/appContext-interceptor.xml"}, true);
        LOG.info("Loaded the context: " + ctx.getBeanDefinitionNames());

        CategoryService categoryService = (CategoryService) ctx.getBean("categoryServiceImpl");