Package com.castronu.joomlajavaapi.domain

Examples of com.castronu.joomlajavaapi.domain.Category


    public int createCategoryAndReturnCategoryId(String title, String alias, String path, int parentId) throws GenericErrorException, CategoryAlreadyExistException {
        if (getCategoryFromPath(path).size() != 0) {
            throw new CategoryAlreadyExistException(path);
        }

        Category category = aCategoryWithPath(title, alias, path, parentId);

        try {
            getHibernateTemplate().save(JoomlaDslUtils.sanytize(category));
            List<Category> categoryFromPath = getCategoryFromPath(path);
            return categoryFromPath.get(0).getId();
View Full Code Here


        List<Category> firstLevelCategories = getHibernateTemplate().findByCriteria(query);
        Integer counter = 1;
        counter = rebuildBranch(firstLevelCategories, counter);
        //Get the ROOT
        List<Category> categoryFromId = getCategoryFromPath("");
        Category rootCategory = categoryFromId.get(0);
        rootCategory.setLft(0);
        rootCategory.setRgt(counter);
        persist(rootCategory);


    }
View Full Code Here

    @Autowired
    MenuDao menuDao;

    @Before
    public void init() throws GenericErrorException {
        Category category = aCategoryWithPath("ROOT", "root", "", 0);
        categoryDao.save(category);
        Menu menu = aMenu("ROOTMenu","root","",0);
        menuDao.getHibernateTemplate().save(menu);

    }
View Full Code Here

    @Test
    public void rgtLftCategoryTest(){

        categoryDao.getHibernateTemplate().deleteAll(categoryDao.getHibernateTemplate().loadAll(Category.class));
        //This is the root, should be always consistent (rgt is the max of all rgt, lft is 0)
        Category category = aCategoryWithPath("ROOT", "root", "", 0);
        categoryDao.save(category);

        joomlaJavaApi.createCategoriesInCascade("Sud America/Ecuador");

        categoryDao.rebuildCategoryTree();
        //Assert root category
        List<Category> categoryFromPath = categoryDao.getCategoryFromPath("");



        Category rootCategory = categoryFromPath.get(0);
        assertThat(rootCategory.getLft(),is(0));
        assertThat(rootCategory.getRgt(),is(5));
        //Assert brand new category
        categoryFromPath = categoryDao.getCategoryFromPath("sud-america/ecuador");
        Category newCategory = categoryFromPath.get(0);
        assertThat(newCategory.getLft(),is(2));
        assertThat(newCategory.getRgt(),is(3));

        categoryFromPath = categoryDao.getCategoryFromPath("sud-america");
        newCategory = categoryFromPath.get(0);
        assertThat(newCategory.getLft(),is(1));
        assertThat(newCategory.getRgt(),is(4));




    }
View Full Code Here

        String categoryPath = "gli-stati-uniti";
        int id=categoryDao.createCategoryAndReturnCategoryId("Gli Stati Uniti","usa", categoryPath,1);
        List<Category> categoryFromPath = categoryDao.getCategoryFromPath(categoryPath);
        assertThat(categoryFromPath.size(), is(1));
        Category category = categoryFromPath.get(0);
        assertThat(category.getId(), is(id));
        assertThat(category.getId(), is(id));
        assertThat(category.getAlias(), is("usa"));
        assertThat(category.getTitle(), is("Gli Stati Uniti"));

        categoryDao.deleteCategory(categoryPath);
        categoryFromPath = categoryDao.getCategoryFromPath(categoryPath);
        assertThat(categoryFromPath.size(), is(0));
View Full Code Here

    }

    @Test(expected = IllegalStateException.class)
    public void testCreateArticleErrorIfTwoArticleWithSameCategoryAndTitle() throws Exception, GenericErrorException {
        Category category= CategoryBuilder.aCategoryWithPath("Category", "SuCategory", "category/suCategroy",1);
        when(categoryDao.getCategoryFromPath("category/suCategroy")).
                thenReturn(Arrays.asList(category,category));
        contentDao.createArticle("aTitle", "aContent", "category/suCategroy","","","","");
    }
View Full Code Here

public class CategoryBuilder {
        private Category category;

        private CategoryBuilder() {
            category = new Category();
        }
View Full Code Here

TOP

Related Classes of com.castronu.joomlajavaapi.domain.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.