Search in sources :

Example 36 with Category

use of it.vige.rubia.model.Category in project rubia-forums by flashboss.

the class AdminController method editCategory.

/**
 * edit category
 *
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String editCategory() {
    String navState = null;
    boolean success = false;
    try {
        int categoryId = -1;
        String cour = ForumUtil.getParameter(p_categoryId);
        if (cour != null && cour.trim().length() > 0) {
            categoryId = Integer.parseInt(cour);
        }
        // grab the category from the module and set the title
        Category category = forumsModule.findCategoryById(categoryId);
        category.setTitle(categoryName);
        forumsModule.update(category);
        String start = getBundleMessage("ResourceJSF", "Category_updated_0");
        String end = getBundleMessage("ResourceJSF", "Category_updated_1");
        setMessage(FEEDBACK, start + " \"" + categoryName + "\" " + end);
        navState = "";
        success = true;
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (success) {
            // cleanup the state
            cleanup();
        }
    }
    return navState;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 37 with Category

use of it.vige.rubia.model.Category in project rubia-forums by flashboss.

the class AdminController method moveCategoryDown.

/**
 * @return the navigation state of the application
 */
public String moveCategoryDown() {
    String navState = null;
    try {
        // get the categoryId where this forum should be added
        int categoryId = -1;
        String cour = ForumUtil.getParameter(p_categoryId);
        if (cour != null && cour.trim().length() > 0) {
            categoryId = Integer.parseInt(cour);
        }
        Category category = forumsModule.findCategoryById(categoryId);
        category.setOrder(category.getOrder() + down);
        forumsModule.update(category);
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        Iterator<Category> categories = forumsModule.findCategories(forumInstanceId).iterator();
        for (int index = 10; categories.hasNext(); index += 10) {
            category = categories.next();
            category.setOrder(index);
            forumsModule.update(category);
        }
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException)

Example 38 with Category

use of it.vige.rubia.model.Category in project rubia-forums by flashboss.

the class AdminController method addForum.

/**
 * adds a new forum
 *
 * @return the navigation state of the application
 */
public String addForum() {
    String navState = null;
    boolean success = false;
    try {
        // add this new forum to the category
        Category category = forumsModule.findCategoryById(selectedCategory);
        forumsModule.createForum(category, forumName, forumDescription);
        String start = getBundleMessage("ResourceJSF", "Forum_created_0");
        String end = getBundleMessage("ResourceJSF", "Forum_created_1");
        setMessage(FEEDBACK, start + " \"" + forumName + "\" " + end);
        success = true;
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (success) {
            // cleanup the state
            cleanup();
        }
    }
    return navState;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException)

Example 39 with Category

use of it.vige.rubia.model.Category in project rubia-forums by flashboss.

the class Search method getCategoriesItems.

public Collection<SelectItem> getCategoriesItems() {
    Collection<SelectItem> categories = new ArrayList<SelectItem>();
    categories.add(new SelectItem("", "Search All Categories"));
    try {
        // Luca Stancapiano start
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        List<Category> c = forumsModule.findCategories(forumInstanceId);
        if (c != null) {
            for (Category category : c) {
                categories.add(new SelectItem(category.getId().toString(), category.getTitle()));
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
    return categories;
}
Also used : Category(it.vige.rubia.model.Category) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException)

Example 40 with Category

use of it.vige.rubia.model.Category in project rubia-forums by flashboss.

the class AdminController method moveCategoryUp.

/**
 * @return the navigation state of the application
 */
public String moveCategoryUp() {
    String navState = null;
    try {
        // get the categoryId where this forum should be added
        int categoryId = -1;
        String cour = ForumUtil.getParameter(p_categoryId);
        if (cour != null && cour.trim().length() > 0) {
            categoryId = Integer.parseInt(cour);
        }
        Category category = forumsModule.findCategoryById(categoryId);
        category.setOrder(category.getOrder() + up);
        forumsModule.update(category);
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        Iterator<Category> categories = forumsModule.findCategories(forumInstanceId).iterator();
        for (int index = 10; categories.hasNext(); index += 10) {
            category = categories.next();
            category.setOrder(index);
            forumsModule.update(category);
        }
    } catch (Exception e) {
        handleException(e);
    }
    return navState;
}
Also used : Category(it.vige.rubia.model.Category) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException)

Aggregations

Category (it.vige.rubia.model.Category)71 Forum (it.vige.rubia.model.Forum)50 CreateCategory.createCategory (it.vige.rubia.selenium.adminpanel.action.CreateCategory.createCategory)48 RemoveCategory.removeCategory (it.vige.rubia.selenium.adminpanel.action.RemoveCategory.removeCategory)48 CreateForum.createForum (it.vige.rubia.selenium.adminpanel.action.CreateForum.createForum)40 Topic (it.vige.rubia.model.Topic)36 Post (it.vige.rubia.model.Post)34 RemoveForum.removeForum (it.vige.rubia.selenium.adminpanel.action.RemoveForum.removeForum)32 CreateTopic.createTopic (it.vige.rubia.selenium.forum.action.CreateTopic.createTopic)30 RemoveTopic.removeTopic (it.vige.rubia.selenium.forum.action.RemoveTopic.removeTopic)24 AfterClass (org.junit.AfterClass)16 BeforeClass (org.junit.BeforeClass)16 Attachment (it.vige.rubia.model.Attachment)15 Poll (it.vige.rubia.model.Poll)14 PollOption (it.vige.rubia.model.PollOption)12 Test (org.junit.Test)11 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)8 Poster (it.vige.rubia.model.Poster)7 CreatePost.createPost (it.vige.rubia.selenium.forum.action.CreatePost.createPost)7 ModuleException (it.vige.rubia.ModuleException)6