Example usage for java.lang Float floatValue

List of usage examples for java.lang Float floatValue

Introduction

In this page you can find the example usage for java.lang Float floatValue.

Prototype

@HotSpotIntrinsicCandidate
public float floatValue() 

Source Link

Document

Returns the float value of this Float object.

Usage

From source file:net.ymate.platform.commons.lang.TreeObject.java

/**
 *  - Float
 *
 * @param f
 */
public TreeObject add(Float f) {
    return add(f != null ? f.floatValue() : 0f, TYPE_FLOAT);
}

From source file:org.etudes.jforum.view.admin.CategoryAction.java

public void insertSave() throws Exception {
    boolean isfacilitator = JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId())
            || SecurityService.isSuperUser();

    if (!isfacilitator) {
        this.context.put("message", I18n.getMessage("User.NotAuthorizedToManage"));
        this.setTemplateName(TemplateKeys.MANAGE_NOT_AUTHORIZED);
        return;//  w w w .  ja v  a 2  s . c om
    }

    JForumCategoryService jforumCategoryService = (JForumCategoryService) ComponentManager
            .get("org.etudes.api.app.jforum.JForumCategoryService");

    org.etudes.api.app.jforum.Category category = jforumCategoryService.newCategory();

    category.setTitle(SafeHtml.escapeJavascript(this.request.getParameter("category_name").trim()));
    category.setContext(ToolManager.getCurrentPlacement().getContext());
    category.setCreatedBySakaiUserId(UserDirectoryService.getCurrentUser().getId());

    boolean isGradable = "1".equals(this.request.getParameter("grade_category"));

    // open, due, allow until dates
    String startDateParam = this.request.getParameter("start_date");
    if (startDateParam != null && startDateParam.trim().length() > 0) {
        Date startDate;
        try {
            startDate = DateUtil.getDateFromString(startDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        category.getAccessDates().setOpenDate(startDate);

        String hideUntilOpen = this.request.getParameter("hide_until_open");
        if (hideUntilOpen != null && "1".equals(hideUntilOpen)) {
            category.getAccessDates().setHideUntilOpen(Boolean.TRUE);
        } else {
            category.getAccessDates().setHideUntilOpen(Boolean.FALSE);
        }
    } else {
        category.getAccessDates().setOpenDate(null);
        category.getAccessDates().setHideUntilOpen(Boolean.FALSE);
    }

    // due date
    String endDateParam = this.request.getParameter("end_date");
    if (endDateParam != null && endDateParam.trim().length() > 0) {
        Date endDate;
        try {
            endDate = DateUtil.getDateFromString(endDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        category.getAccessDates().setDueDate(endDate);
        //String lockCategory = this.request.getParameter("lock_category");
        /*if (lockCategory != null && "1".equals(lockCategory))
        {
           category.getAccessDates().setLocked(Boolean.TRUE);
        }
        else
        {
           category.getAccessDates().setLocked(Boolean.FALSE);
        }*/
    } else {
        category.getAccessDates().setDueDate(null);
        //category.getAccessDates().setLocked(Boolean.FALSE);
    }

    // allow until
    String allowUntilDateParam = this.request.getParameter("allow_until_date");
    if (allowUntilDateParam != null && allowUntilDateParam.trim().length() > 0) {
        Date allowUntilDate;
        try {
            allowUntilDate = DateUtil.getDateFromString(allowUntilDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        category.getAccessDates().setAllowUntilDate(allowUntilDate);
    } else {
        category.getAccessDates().setAllowUntilDate(null);
    }

    // grades
    category.setGradable(Boolean.valueOf(isGradable));

    if (category.isGradable()) {
        org.etudes.api.app.jforum.Grade grade = category.getGrade();

        grade.setContext(ToolManager.getCurrentPlacement().getContext());
        try {
            Float points = Float.parseFloat(this.request.getParameter("point_value"));

            if (points.floatValue() < 0)
                points = Float.valueOf(0.0f);
            if (points.floatValue() > 1000)
                points = Float.valueOf(1000.0f);
            points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

            grade.setPoints(points);
        } catch (NumberFormatException ne) {
            grade.setPoints(0f);
        }

        String minPostsRequired = this.request.getParameter("min_posts_required");

        if ((minPostsRequired != null) && ("1".equals(minPostsRequired))) {
            try {
                grade.setMinimumPostsRequired(true);
                int minimumPosts = this.request.getIntParameter("min_posts");
                grade.setMinimumPosts(minimumPosts);
            } catch (NumberFormatException ne) {
                grade.setMinimumPosts(0);
            }
        }

        String sendToGradebook = this.request.getParameter("send_to_grade_book");
        boolean addToGradeBook = false;
        if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
            addToGradeBook = true;
        }
        grade.setAddToGradeBook(Boolean.valueOf(addToGradeBook));
    }

    try {
        jforumCategoryService.createCategory(category);

        // if add to grade option unchecked after saving show the error that there is existing title in the gradebook
        String sendToGradebook = this.request.getParameter("send_to_grade_book");
        boolean addToGradeBook = false;
        if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
            addToGradeBook = true;
        }
        if (category.isGradable() && category.getGrade() != null && addToGradeBook) {
            /*JForumGBService jForumGBService = null;
            jForumGBService = (JForumGBService)ComponentManager.get("org.etudes.api.app.jforum.JForumGBService");
                    
            String gradebookUid = ToolManager.getInstance().getCurrentPlacement().getContext();
            if (jForumGBService != null && jForumGBService.isAssignmentDefined(gradebookUid, category.getTitle()))
            {
               this.context.put("errorMessage", I18n.getMessage("Grade.AddEditCategoryGradeBookConflictingAssignmentNameException"));
            }*/

            if (!category.getGrade().isAddToGradeBook()) {
                if (category.getGrade().getPoints() <= 0) {
                    this.context.put("errorMessage", I18n
                            .getMessage("Grade.AddEditCategoryGradeBookAssignmentHasIllegalPointsException"));
                } else {
                    this.context.put("errorMessage", I18n
                            .getMessage("Grade.AddEditCategoryGradeBookConflictingAssignmentNameException"));
                }
                this.request.addParameter("category_id", String.valueOf(category.getId()));
                this.edit();
                return;
            }
        }
    } catch (JForumAccessException e) {
        this.context.put("message", I18n.getMessage("User.NotAuthorizedToManage"));
        this.setTemplateName(TemplateKeys.MANAGE_NOT_AUTHORIZED);
        return;
    }

    /*Category c = new Category();
    c.setName(SafeHtml.escapeJavascript(this.request.getParameter("category_name").trim()));
    c.setModerated("1".equals(this.request.getParameter("moderate")));
    c.setGradeCategory("1".equals(this.request.getParameter("grade_category")));
            
    // star and end dates
    String startDateParam = this.request.getParameter("start_date");
    if (startDateParam != null && startDateParam.trim().length() > 0)
    {
       Date startDate;
       try
       {
    startDate = DateUtil.getDateFromString(startDateParam.trim());
       } catch (ParseException e)
       {
    this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
    this.insert();
    return;
       }
       c.setStartDate(startDate);
               
       if (startDate != null){
    SimpleDateFormat df = new SimpleDateFormat(SakaiSystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
    c.setStartDateFormatted(df.format(startDate));
       }
    }
    else
    {
      c.setStartDate(null);
    }
            
    String endDateParam = this.request.getParameter("end_date");
    if (endDateParam != null && endDateParam.trim().length() > 0)
    {
       Date endDate;
       try
       {
    endDate = DateUtil.getDateFromString(endDateParam.trim());
       } catch (ParseException e)
       {
    this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
    this.insert();
    return;
       }
       c.setEndDate(endDate);
       String lockCategory = this.request.getParameter("lock_category");
       if (lockCategory != null && "1".equals(lockCategory)){
    c.setLockCategory(true);
       }
       else
       {
    c.setLockCategory(false);
       }
               
       if (endDate != null){
    SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
    c.setEndDateFormatted(df.format(endDate));
       }
    }
    else
    {
      c.setEndDate(null);
      c.setLockCategory(false);
    }
               
    int categoryId = this.cm.addNew(c);
    c.setId(categoryId);
            
    if (c.isGradeCategory())
    {
       // create grade
       Grade grade = new Grade();
               
       grade.setContext(ToolManager.getCurrentPlacement().getContext());
       grade.setCategoryId(c.getId());
       try 
       {
    Float points = Float.parseFloat(this.request.getParameter("point_value"));
            
    if (points.floatValue() < 0) points = Float.valueOf(0.0f);
    if (points.floatValue() > 1000) points = Float.valueOf(1000.0f);
    points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);
            
    grade.setPoints(points);
       } 
       catch (NumberFormatException ne) 
       {
    grade.setPoints(0f);
       }
               
       String minPostsRequired = this.request.getParameter("min_posts_required");
               
       if ((minPostsRequired != null) && ("1".equals(minPostsRequired)))
       {
    try 
    {
       grade.setMinimumPostsRequired(true);
       int minimumPosts = this.request.getIntParameter("min_posts");
       grade.setMinimumPosts(minimumPosts);            
    } 
    catch (NumberFormatException ne) 
    {
       grade.setMinimumPosts(0);
    }
       }
       grade.setType(Forum.GRADE_BY_CATEGORY);
               
       int gradeId = this.gm.addNew(grade);
       grade.setId(gradeId);
               
       String sendToGradebook = this.request.getParameter("send_to_grade_book");
       boolean addToGradeBook = false;
       if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1))
       {
    addToGradeBook = true;
       }
       grade.setAddToGradeBook(addToGradeBook);      
               
       //if add to grade book is true then add the grade to grade book
       if (addToGradeBook)
       {
    addToGradeBook = updateGradebook(grade);
       }
       this.gm.updateAddToGradeBookStatus(gradeId, addToGradeBook);
    }*/

    //ForumRepository.addCourseCategoryToCache(c);

    // auto save navigation
    autoSaveNavigation();
}

From source file:org.etudes.jforum.view.admin.CategoryAction.java

public void editSave() throws Exception {
    boolean isfacilitator = JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId())
            || SecurityService.isSuperUser();

    if (!isfacilitator) {
        this.context.put("message", I18n.getMessage("User.NotAuthorizedToManage"));
        this.setTemplateName(TemplateKeys.MANAGE_NOT_AUTHORIZED);
        return;//from ww w .j  a  va2  s .c  om
    }

    JForumCategoryService jforumCategoryService = (JForumCategoryService) ComponentManager
            .get("org.etudes.api.app.jforum.JForumCategoryService");

    org.etudes.api.app.jforum.Category category = jforumCategoryService
            .getCategory(this.request.getIntParameter("categories_id"));

    category.setModifiedBySakaiUserId(UserDirectoryService.getCurrentUser().getId());

    category.setTitle(SafeHtml.escapeJavascript(this.request.getParameter("category_name").trim()));

    if (category.getAccessDates() != null) {

        // open, due, allow until dates
        String startDateParam = this.request.getParameter("start_date");
        if (startDateParam != null && startDateParam.trim().length() > 0) {
            Date startDate;
            try {
                startDate = DateUtil.getDateFromString(startDateParam.trim());
            } catch (ParseException e) {
                this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
                this.edit();
                return;
            }
            category.getAccessDates().setOpenDate(startDate);

            String hideUntilOpen = this.request.getParameter("hide_until_open");
            if (hideUntilOpen != null && "1".equals(hideUntilOpen)) {
                category.getAccessDates().setHideUntilOpen(Boolean.TRUE);
            } else {
                category.getAccessDates().setHideUntilOpen(Boolean.FALSE);
            }
        } else {
            category.getAccessDates().setOpenDate(null);
            category.getAccessDates().setHideUntilOpen(Boolean.FALSE);
        }

        String endDateParam = this.request.getParameter("end_date");
        if (endDateParam != null && endDateParam.trim().length() > 0) {
            Date endDate;
            try {
                endDate = DateUtil.getDateFromString(endDateParam.trim());
            } catch (ParseException e) {
                this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
                this.request.addParameter("category_id", String.valueOf(category.getId()));
                this.edit();
                return;
            }
            category.getAccessDates().setDueDate(endDate);

            /*String lockCategory = this.request.getParameter("lock_category");
                    
            if (lockCategory != null && "1".equals(lockCategory))
            {
               category.getAccessDates().setLocked(true);
            }
            else
            {
               category.getAccessDates().setLocked(false);
            }*/
        } else {
            category.getAccessDates().setDueDate(null);
            //category.getAccessDates().setLocked(false);
        }

        // allow until
        String allowUntilDateParam = this.request.getParameter("allow_until_date");
        if (allowUntilDateParam != null && allowUntilDateParam.trim().length() > 0) {
            Date allowUntilDate;
            try {
                allowUntilDate = DateUtil.getDateFromString(allowUntilDateParam.trim());
            } catch (ParseException e) {
                this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
                this.edit();
                return;
            }
            category.getAccessDates().setAllowUntilDate(allowUntilDate);
        } else {
            category.getAccessDates().setAllowUntilDate(null);
        }
    }

    boolean isGradable = "1".equals(this.request.getParameter("grade_category"));

    // grades
    category.setGradable(Boolean.valueOf(isGradable));

    if (category.isGradable()) {
        org.etudes.api.app.jforum.Grade grade = category.getGrade();
        if (grade == null) {
            grade = jforumCategoryService.newGrade(category);
        }

        grade.setContext(ToolManager.getCurrentPlacement().getContext());
        try {
            Float points = Float.parseFloat(this.request.getParameter("point_value"));

            if (points.floatValue() < 0)
                points = Float.valueOf(0.0f);
            if (points.floatValue() > 1000)
                points = Float.valueOf(1000.0f);
            points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

            grade.setPoints(points);
        } catch (NumberFormatException ne) {
            grade.setPoints(0f);
        }

        String minPostsRequired = this.request.getParameter("min_posts_required");

        if ((minPostsRequired != null) && ("1".equals(minPostsRequired))) {
            try {
                grade.setMinimumPostsRequired(true);
                int minimumPosts = this.request.getIntParameter("min_posts");
                grade.setMinimumPosts(minimumPosts);
            } catch (NumberFormatException ne) {
                grade.setMinimumPosts(0);
            }
        } else {
            grade.setMinimumPostsRequired(false);
            grade.setMinimumPosts(0);
        }

        String sendToGradebook = this.request.getParameter("send_to_grade_book");
        boolean addToGradeBook = false;
        if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
            addToGradeBook = true;
        }
        grade.setAddToGradeBook(Boolean.valueOf(addToGradeBook));
    } else {
        category.setGrade(null);
    }

    try {
        jforumCategoryService.modifyCategory(category);

        // if add to grade option unchecked after saving show the error that there is existing title in the gradebook
        String sendToGradebook = this.request.getParameter("send_to_grade_book");
        boolean addToGradeBook = false;
        if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
            addToGradeBook = true;
        }
        if (category.isGradable() && category.getGrade() != null && addToGradeBook) {
            /*JForumGBService jForumGBService = null;
            jForumGBService = (JForumGBService)ComponentManager.get("org.etudes.api.app.jforum.JForumGBService");
                    
            String gradebookUid = ToolManager.getInstance().getCurrentPlacement().getContext();
            if (jForumGBService != null && jForumGBService.isAssignmentDefined(gradebookUid, category.getTitle()))
            {
               this.context.put("errorMessage", I18n.getMessage("Grade.AddEditCategoryGradeBookConflictingAssignmentNameException"));
            }*/

            if (!category.getGrade().isAddToGradeBook()) {
                if (category.getGrade().getPoints() <= 0) {
                    this.context.put("errorMessage", I18n
                            .getMessage("Grade.AddEditCategoryGradeBookAssignmentHasIllegalPointsException"));
                } else {
                    this.context.put("errorMessage", I18n
                            .getMessage("Grade.AddEditCategoryGradeBookConflictingAssignmentNameException"));
                }
                this.request.addParameter("category_id", String.valueOf(category.getId()));
                this.edit();
                return;
            }
        }
    } catch (JForumAccessException e) {
        // already check access
    } catch (JForumGradesModificationException e) {
        JForum.enableCancelCommit();
        this.context.put("errorMessage", I18n.getMessage("Category.Form.CannotEditCategoryGrade"));
        this.request.addParameter("category_id", String.valueOf(category.getId()));
        this.edit();
        return;
    }
    /*Category c = new Category(ForumRepository.getCategory(
    this.request.getIntParameter("categories_id")), true);
    c.setName(SafeHtml.escapeJavascript(this.request.getParameter("category_name").trim()));
    c.setModerated("1".equals(this.request.getParameter("moderate")));
    c.setGradeCategory("1".equals(this.request.getParameter("grade_category")));
            
    int topicDatesCount = DataAccessDriver.getInstance().newTopicDAO().getTopicDatesCountByCategory(c.getId());
    int forumDatesCount = DataAccessDriver.getInstance().newForumDAO().getForumDatesCount(c.getId());
            
    // star and end dates
    if (topicDatesCount == 0 && forumDatesCount == 0)
    {
       String startDateParam = this.request.getParameter("start_date");
       if (startDateParam != null && startDateParam.trim().length() > 0)
       {
    Date startDate;
    try
    {
       startDate = DateUtil.getDateFromString(startDateParam.trim());
    } catch (ParseException e)
    {
       this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
       this.request.addParameter("forum_id", String.valueOf(c.getId()));
       this.edit();
       return;
    }
    c.setStartDate(startDate);
            
    if (startDate != null){
       SimpleDateFormat df = new SimpleDateFormat(SakaiSystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
       c.setStartDateFormatted(df.format(startDate));
    }
       }
       else
       {
    c.setStartDate(null);
       }
               
       String endDateParam = this.request.getParameter("end_date");
       if (endDateParam != null && endDateParam.trim().length() > 0)
       {
    Date endDate;
    try
    {
       endDate = DateUtil.getDateFromString(endDateParam.trim());
    } catch (ParseException e)
    {
       this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
       this.request.addParameter("forum_id", String.valueOf(c.getId()));
       this.edit();
       return;
    }
    c.setEndDate(endDate);
            
    String lockForum = this.request.getParameter("lock_category");
    if (lockForum!= null && "1".equals(lockForum)){
       c.setLockCategory(true);
    }
    else
    {
       c.setLockCategory(false);
    }
            
    if (endDate != null){
       SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
       c.setEndDateFormatted(df.format(endDate));
    }
       }
       else
       {
    c.setEndDate(null);
    c.setLockCategory(false);
       }
    }
    else
    {
       c.setStartDate(null);
       c.setEndDate(null);
       c.setLockCategory(false);
    }
               
    if (c.isGradeCategory())
    {
       // check for category forums for grading enabled
       if (this.gm.isCategoryForumsGradable(c.getId()))
       {
    JForum.enableCancelCommit();
    this.context.put("errorMessage", I18n.getMessage("Category.Form.CannotEditGrade"));
    this.request.addParameter("category_id", String.valueOf(c.getId()));
    this.edit();
    return;
       }
               
       // update category
       this.cm.update(c);
               
       ForumRepository.reloadCourseCategory(c);
               
       new ModerationCommon().setForumsModerationStatus(c, c.isModerated());
                  
       // existing grade
       Grade exisGrade = this.gm.selectByCategoryId(c.getId());
               
       if (exisGrade == null)
       {
    // create grade
    Grade grade = new Grade();
            
    grade.setContext(ToolManager.getCurrentPlacement().getContext());
    grade.setCategoryId(c.getId());
    try {
       Float points = Float.parseFloat(this.request.getParameter("point_value"));
               
       if (points.floatValue() < 0) points = Float.valueOf(0.0f);
       if (points.floatValue() > 1000) points = Float.valueOf(1000.0f);
       points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);
               
       grade.setPoints(points);
    } catch (NumberFormatException ne) {
       grade.setPoints(0f);
    }
            
    String minPostsRequired = this.request.getParameter("min_posts_required");
            
    if ((minPostsRequired != null) && ("1".equals(minPostsRequired)))
    {
       try 
       {
          grade.setMinimumPostsRequired(true);
          int minimumPosts = this.request.getIntParameter("min_posts");
          grade.setMinimumPosts(minimumPosts);            
       } 
       catch (NumberFormatException ne) 
       {
          grade.setMinimumPosts(0);
       }
    }
            
    grade.setType(Forum.GRADE_BY_CATEGORY);
            
    int gradeId = this.gm.addNew(grade);
            
    String sendToGradebook = this.request.getParameter("send_to_grade_book");
    boolean addToGradeBook = false;
    if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1))
    {
       addToGradeBook = true;
    }
    grade.setAddToGradeBook(addToGradeBook);
            
    grade.setId(gradeId);
            
    //if add to grade book is true then add the grade to grade book
    if (addToGradeBook)
    {
       addToGradeBook = updateGradebook(grade);
    }
    this.gm.updateAddToGradeBookStatus(gradeId, addToGradeBook);
       }
       else
       {
    // update existing grade and update any entry in the gradebook
    exisGrade.setContext(ToolManager.getCurrentPlacement().getContext());
    exisGrade.setCategoryId(c.getId());
    try {
       Float points = Float.parseFloat(this.request.getParameter("point_value"));
               
       if (points.floatValue() < 0) points = Float.valueOf(0.0f);
       if (points.floatValue() > 1000) points = Float.valueOf(1000.0f);
       points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);
       exisGrade.setPoints(points);
               
    } catch (NumberFormatException ne) {
       exisGrade.setPoints(0f);
    }   
            
    String minPostsRequired = this.request.getParameter("min_posts_required");
            
    if ((minPostsRequired != null) && ("1".equals(minPostsRequired)))
    {
       try 
       {
          exisGrade.setMinimumPostsRequired(true);
          int minimumPosts = this.request.getIntParameter("min_posts");
          exisGrade.setMinimumPosts(minimumPosts);            
       } 
       catch (NumberFormatException ne) 
       {
          exisGrade.setMinimumPosts(0);
       }
    }
    else
    {
       try 
       {
          exisGrade.setMinimumPostsRequired(false);
          exisGrade.setMinimumPosts(0);            
       } 
       catch (NumberFormatException ne) 
       {
          exisGrade.setMinimumPosts(0);
       }
    }
            
    this.gm.updateCategoriesGrade(exisGrade);
            
    String sendToGradebook = this.request.getParameter("send_to_grade_book");
    boolean addToGradeBook = false;
    if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1))
    {
       addToGradeBook = true;
    }
                        
    // update any entry in the grade book for points and any name changes.
    if (addToGradeBook)
    {
       exisGrade.setAddToGradeBook(addToGradeBook);
       addToGradeBook = updateGradebook(exisGrade);
    } 
    else
    {
       // remove any existing entry in the grade book
       removeEntryFromGradeBook(exisGrade);
    }
    exisGrade.setAddToGradeBook(addToGradeBook);
    this.gm.updateAddToGradeBookStatus(exisGrade.getId(), addToGradeBook);
       }
    }
    else
    {
       // delete any existing grade associated with category if not graded
       Grade exisGrade = this.gm.selectByCategoryId(c.getId());
               
       if (exisGrade != null)
       {
    // check for evaluations
    int evalCount = DataAccessDriver.getInstance().newEvaluationDAO().selectEvaluationsCountByGradeId(exisGrade.getId());
            
    if (evalCount > 0)
    {
       JForum.enableCancelCommit();
       this.context.put("errorMessage", I18n.getMessage("Category.Form.CannotEditGradedCategory"));
       this.request.addParameter("category_id", String.valueOf(c.getId()));
       this.edit();
       return;
    }
    else
    {
       if (exisGrade.isAddToGradeBook())
       {
          removeEntryFromGradeBook(exisGrade);
       }
               
       // delete the grade
       DataAccessDriver.getInstance().newGradeDAO().delete(exisGrade.getId());
    }
       }
               
       // update category
       this.cm.update(c);
               
       // update gradable forum and topic dates in the gradebook
       if (!c.isGradeCategory())
       {
    updateGradebookForumsTopics(c);
       }
               
       ForumRepository.reloadCourseCategory(c);
               
       new ModerationCommon().setForumsModerationStatus(c, c.isModerated());
               
    }*/

    // auto save navigation
    autoSaveNavigation();
}

From source file:org.etudes.component.app.jforum.JforumDataServiceImpl.java

/**
 * Adds grade to topic/*from   ww w. j a  va  2 s  .  co m*/
 * 
 * @param fromTopic   From topic
 * 
 * @param toTopic   To topic
 */
protected void addGradeToTopic(Topic fromTopic, Topic toTopic) {
    Grade fromGrade = fromTopic.getGrade();

    if (fromGrade != null) {
        toTopic.setGradeTopic(Boolean.TRUE);

        org.etudes.api.app.jforum.Grade grade = toTopic.getGrade();

        try {
            Float points = fromGrade.getPoints();

            if (points.floatValue() < 0)
                points = Float.valueOf(0.0f);
            if (points.floatValue() > 1000)
                points = Float.valueOf(1000.0f);
            points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

            grade.setPoints(points);
        } catch (NumberFormatException ne) {
            grade.setPoints(0f);
        }

        if (fromGrade.isMinimumPostsRequired()) {
            grade.setMinimumPostsRequired(true);
            grade.setMinimumPosts(fromGrade.getMinimumPosts());
        }

        grade.setAddToGradeBook(fromGrade.isAddToGradeBook());
    }
}

From source file:org.etudes.component.app.jforum.JforumDataServiceImpl.java

/**
 * Creates category/* ww  w .  ja  v a 2s .  co m*/
 * 
 * @param toContextId   To context or site
 * 
 * @param fromCategory   Existing category
 * 
 * @return   Newly created category
 */
protected Category createCategory(String toContextId, Category fromCategory) {
    if (logger.isDebugEnabled()) {
        logger.debug("Creating category......");
    }

    /* create category */
    JForumCategoryService jforumCategoryService = (JForumCategoryService) ComponentManager
            .get("org.etudes.api.app.jforum.JForumCategoryService");

    org.etudes.api.app.jforum.Category category = jforumCategoryService.newCategory();

    category.setTitle(fromCategory.getTitle());
    category.setContext(toContextId);
    category.setCreatedBySakaiUserId(UserDirectoryService.getCurrentUser().getId());

    boolean isGradable = fromCategory.isGradable();

    // open date
    category.getAccessDates().setOpenDate(fromCategory.getAccessDates().getOpenDate());

    // hide until open
    if (fromCategory.getAccessDates().getOpenDate() != null) {
        category.getAccessDates().setHideUntilOpen(fromCategory.getAccessDates().isHideUntilOpen());
    }

    // due date
    category.getAccessDates().setDueDate(fromCategory.getAccessDates().getDueDate());

    /*if (category.getAccessDates().getDueDate() != null)
    {
       category.getAccessDates().setLocked(fromCategory.getAccessDates().isLocked());
    }*/

    // allow until date
    category.getAccessDates().setAllowUntilDate(fromCategory.getAccessDates().getAllowUntilDate());

    // grades
    if (fromCategory.isGradable()) {
        Grade fromGrade = fromCategory.getGrade();

        if (fromGrade != null) {
            category.setGradable(Boolean.valueOf(isGradable));

            org.etudes.api.app.jforum.Grade grade = category.getGrade();

            grade.setContext(toContextId);
            try {
                Float points = fromGrade.getPoints();

                if (points.floatValue() < 0)
                    points = Float.valueOf(0.0f);
                if (points.floatValue() > 1000)
                    points = Float.valueOf(1000.0f);
                points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

                grade.setPoints(points);
            } catch (NumberFormatException ne) {
                grade.setPoints(0f);
            }

            if (fromGrade.isMinimumPostsRequired()) {
                grade.setMinimumPostsRequired(true);
                grade.setMinimumPosts(fromGrade.getMinimumPosts());
            }

            grade.setAddToGradeBook(fromGrade.isAddToGradeBook());
        }
    }

    try {
        jforumCategoryService.createCategory(category);
    } catch (JForumAccessException e) {
        if (logger.isWarnEnabled()) {
            logger.warn(e.toString(), e);
        }
    }

    return category;
}

From source file:org.etudes.component.app.jforum.JforumDataServiceImpl.java

/**
 * Creates forum/* w  w  w . j a  v  a 2s  .co m*/
 * 
 * @param toCategory   Forum category
 * 
 * @param fromForum      Existing forum
 * 
 * @return   The newly created forum
 */
protected Forum createForum(Category toCategory, Forum fromForum) {
    if (toCategory == null || fromForum == null) {
        return null;
    }

    if (toCategory.isGradable() && (fromForum.getGradeType() != Grade.GradeType.DISABLED.getType())) {
        fromForum.setGradeType(Grade.GradeType.DISABLED.getType());
    }

    Forum toForum = jforumForumService.newForum();

    toForum.setName(SafeHtml.escapeJavascript(fromForum.getName()));
    toForum.setDescription(SafeHtml.escapeJavascript(fromForum.getDescription()));
    toForum.setCategoryId(toCategory.getId());
    toForum.setCreatedBySakaiUserId(UserDirectoryService.getCurrentUser().getId());

    // open date
    toForum.getAccessDates().setOpenDate(fromForum.getAccessDates().getOpenDate());

    // hide until open
    if (fromForum.getAccessDates().getOpenDate() != null) {
        toForum.getAccessDates().setHideUntilOpen(fromForum.getAccessDates().isHideUntilOpen());
    }

    // due date
    toForum.getAccessDates().setDueDate(fromForum.getAccessDates().getDueDate());

    /*if (toForum.getAccessDates().getDueDate() != null)
    {
       toForum.getAccessDates().setLocked(fromForum.getAccessDates().isLocked());
    }*/

    // allow until date
    toForum.getAccessDates().setAllowUntilDate(fromForum.getAccessDates().getAllowUntilDate());

    // type - noraml, reply only, read only
    toForum.setType(fromForum.getType());

    // access type - all site participants, deny access, selected groups
    toForum.setAccessType(fromForum.getAccessType());

    // groups
    if (fromForum.getAccessType() == Forum.ForumAccess.GROUPS.getAccessType()) {
        List<String> fromForumGroups = fromForum.getGroups();

        if (fromForumGroups != null) {
            // get from site groups
            String fromContext = fromForum.getCategory().getContext();

            Site fromSite, toSite;
            try {
                // from context groups
                fromSite = SiteService.getSite(fromContext);
                Collection fromSakaiSiteGroups = fromSite.getGroups();

                Set<String> fromForumGroupTitles = new HashSet<String>();
                Set<String> fromForumGroupIds = new HashSet<String>();

                for (String fromForumGroupId : fromForumGroups) {
                    fromForumGroupIds.add(fromForumGroupId);
                }

                for (Iterator<Group> fromSakaiSiteGroupsIter = fromSakaiSiteGroups
                        .iterator(); fromSakaiSiteGroupsIter.hasNext();) {
                    Group sakaiSiteGroup = fromSakaiSiteGroupsIter.next();

                    if (fromForumGroupIds.contains(sakaiSiteGroup.getId())) {
                        fromForumGroupTitles.add(sakaiSiteGroup.getTitle().trim());
                    }
                }

                // to context groups
                String toSakaiSiteGroupTitle = null;
                toSite = SiteService.getSite(toCategory.getContext());
                Collection toSakaiSiteGroups = toSite.getGroups();

                for (Iterator<Group> toSakaiSiteGroupIter = toSakaiSiteGroups.iterator(); toSakaiSiteGroupIter
                        .hasNext();) {
                    Group toSakaiSiteGroup = toSakaiSiteGroupIter.next();

                    toSakaiSiteGroupTitle = toSakaiSiteGroup.getTitle().trim();

                    if (fromForumGroupTitles.contains(toSakaiSiteGroupTitle)) {
                        if (toForum.getGroups() == null) {
                            toForum.setGroups(new ArrayList<String>());
                        }
                        toForum.getGroups().add(toSakaiSiteGroup.getId());
                    }
                }
            } catch (IdUnusedException e) {
            }
        } else {
            toForum.setAccessType(Forum.ForumAccess.SITE.getAccessType());
        }

    }

    // grades
    if (!toCategory.isGradable()) {
        if (fromForum.getGradeType() == Grade.GradeType.TOPIC.getType()) {
            toForum.setGradeType(Grade.GradeType.TOPIC.getType());
        } else if (fromForum.getGradeType() == Grade.GradeType.FORUM.getType()) {
            toForum.setGradeType(Grade.GradeType.FORUM.getType());
            Grade fromGrade = fromForum.getGrade();

            if (fromGrade != null) {
                org.etudes.api.app.jforum.Grade grade = toForum.getGrade();

                grade.setContext(toCategory.getContext());
                try {
                    Float points = fromGrade.getPoints();

                    if (points.floatValue() < 0)
                        points = Float.valueOf(0.0f);
                    if (points.floatValue() > 1000)
                        points = Float.valueOf(1000.0f);
                    points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

                    grade.setPoints(points);
                } catch (NumberFormatException ne) {
                    grade.setPoints(0f);
                }

                if (fromGrade.isMinimumPostsRequired()) {
                    grade.setMinimumPostsRequired(true);
                    grade.setMinimumPosts(fromGrade.getMinimumPosts());
                }

                grade.setAddToGradeBook(fromGrade.isAddToGradeBook());
            }
        }
    }

    try {
        jforumForumService.createForum(toForum);
    } catch (JForumAccessException e) {
        return null;
    }

    return toForum;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected void setAxisTickMarks(Axis axis, Paint lineColor, AxisSettings axisSettings) {
    boolean axisTickMarksVisible = axisSettings.getTickMarksVisible() == null
            || axisSettings.getTickMarksVisible().booleanValue();

    axis.setTickMarksVisible(axisTickMarksVisible);

    if (axisTickMarksVisible) {
        Float axisTickMarksInsideLength = axisSettings.getTickMarksInsideLength();
        if (axisTickMarksInsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksInsideLength.floatValue());

        Float axisTickMarksOutsideLength = axisSettings.getTickMarksOutsideLength();
        if (axisTickMarksOutsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksOutsideLength.floatValue());

        Paint tickMarkPaint = axisSettings.getTickMarksPaint() != null
                && axisSettings.getTickMarksPaint().getPaint() != null
                        ? axisSettings.getTickMarksPaint().getPaint()
                        : lineColor;/*from   w ww .  j a  v  a 2 s  .  c o m*/

        if (tickMarkPaint != null) {
            axis.setTickMarkPaint(tickMarkPaint);
        }
        Stroke tickMarkStroke = axisSettings.getTickMarksStroke();
        if (tickMarkStroke != null)
            axis.setTickMarkStroke(tickMarkStroke);
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void setPlotBackground(Plot p, JRChartPlot jrPlot) {
    Paint defaultBackgroundPaint = (Paint) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_PAINT);
    Float defaultBackgroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_ALPHA);
    Float defaultForegroundAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_FOREGROUND_ALPHA);

    Image defaultBackgroundImage = (Image) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE);
    Integer defaultBackgroundImageAlignment = (Integer) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALIGNMENT);
    Float defaultBackgroundImageAlpha = (Float) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_BACKGROUND_IMAGE_ALPHA);

    Paint backgroundPaint = jrPlot.getOwnBackcolor() != null ? jrPlot.getOwnBackcolor()
            : defaultBackgroundPaint;/* w ww. j ava  2 s. c om*/
    if (backgroundPaint != null) {
        p.setBackgroundPaint(backgroundPaint);
    }

    Float backgroundAlpha = jrPlot.getBackgroundAlphaFloat() != null ? jrPlot.getBackgroundAlphaFloat()
            : defaultBackgroundAlpha;
    if (backgroundAlpha != null)
        p.setBackgroundAlpha(backgroundAlpha.floatValue());

    Float foregroundAlpha = jrPlot.getForegroundAlphaFloat() != null ? jrPlot.getForegroundAlphaFloat()
            : defaultForegroundAlpha;
    if (foregroundAlpha != null)
        p.setForegroundAlpha(foregroundAlpha.floatValue());

    if (defaultBackgroundImage != null) {
        p.setBackgroundImage(defaultBackgroundImage);
        if (defaultBackgroundImageAlignment != null) {
            p.setBackgroundImageAlignment(defaultBackgroundImageAlignment.intValue());
        }
        if (defaultBackgroundImageAlpha != null) {
            p.setBackgroundImageAlpha(defaultBackgroundImageAlpha.floatValue());
        }
    }

}

From source file:org.etudes.jforum.view.admin.ForumAction.java

public void insertSave() throws Exception {
    boolean isfacilitator = JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId())
            || SecurityService.isSuperUser();

    if (!isfacilitator) {
        this.context.put("message", I18n.getMessage("User.NotAuthorizedToManage"));
        this.setTemplateName(TemplateKeys.MANAGE_NOT_AUTHORIZED);
        return;//from   www.ja  v a2  s . c  om
    }

    if (this.request.getIntParameter("categories_id") == -1) {
        this.context.put("errorMessage", I18n.getMessage("Forums.Forum.SelectCategory"));
        this.insert();
        return;
    }

    //Category c = DataAccessDriver.getInstance().newCategoryDAO().selectById(this.request.getIntParameter("categories_id"));

    JForumCategoryService jforumCategoryService = (JForumCategoryService) ComponentManager
            .get("org.etudes.api.app.jforum.JForumCategoryService");
    org.etudes.api.app.jforum.Category category = null;
    try {
        category = jforumCategoryService.getCategory(this.request.getIntParameter("categories_id"),
                UserDirectoryService.getCurrentUser().getId());
    } catch (JForumAccessException e1) {
        // already virified the access
    }

    if (category == null) {
        JForum.enableCancelCommit();
        this.context.put("errorMessage", I18n.getMessage("Forums.Forum.CategoryNotExist"));
        this.insert();
        return;
    }

    if (category.isGradable() && (this.request.getParameter("grading_enabled") != null
            && Integer.parseInt(this.request.getParameter("grading_enabled")) == 1)) {
        JForum.enableCancelCommit();
        this.context.put("errorMessage", I18n.getMessage("Forums.Forum.CannotAddForumGrading"));
        this.insert();
        return;
    }

    JForumForumService jforumForumService = (JForumForumService) ComponentManager
            .get("org.etudes.api.app.jforum.JForumForumService");
    org.etudes.api.app.jforum.Forum forum = jforumForumService.newForum();

    forum.setName(SafeHtml.escapeJavascript(this.request.getParameter("forum_name")));
    forum.setDescription(SafeHtml.escapeJavascript(this.request.getParameter("description")));
    forum.setCategoryId(this.request.getIntParameter("categories_id"));
    forum.setCreatedBySakaiUserId(UserDirectoryService.getCurrentUser().getId());
    String startDateParam = this.request.getParameter("start_date");

    // dates
    if (startDateParam != null && startDateParam.trim().length() > 0) {
        Date startDate;
        try {
            startDate = DateUtil.getDateFromString(startDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        forum.getAccessDates().setOpenDate(startDate);

        String hideUntilOpen = this.request.getParameter("hide_until_open");
        if (hideUntilOpen != null && "1".equals(hideUntilOpen)) {
            forum.getAccessDates().setHideUntilOpen(Boolean.TRUE);
        } else {
            forum.getAccessDates().setHideUntilOpen(Boolean.FALSE);
        }
    } else {
        forum.getAccessDates().setOpenDate(null);
        forum.getAccessDates().setHideUntilOpen(Boolean.FALSE);
    }

    // due date
    String endDateParam = this.request.getParameter("end_date");
    if (endDateParam != null && endDateParam.trim().length() > 0) {
        Date endDate;
        try {
            endDate = DateUtil.getDateFromString(endDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        forum.getAccessDates().setDueDate(endDate);

        /*String lockForum = this.request.getParameter("lock_forum");
        if (lockForum != null && "1".equals(lockForum))
        {
           forum.getAccessDates().setLocked(Boolean.TRUE);
        }
        else
        {
           forum.getAccessDates().setLocked(Boolean.FALSE);
        }*/
    } else {
        forum.getAccessDates().setDueDate(null);
        //forum.getAccessDates().setLocked(Boolean.FALSE);
    }

    // allow until
    String allowUntilDateParam = this.request.getParameter("allow_until_date");
    if (allowUntilDateParam != null && allowUntilDateParam.trim().length() > 0) {
        Date allowUntilDate;
        try {
            allowUntilDate = DateUtil.getDateFromString(allowUntilDateParam.trim());
        } catch (ParseException e) {
            this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
            this.insert();
            return;
        }
        forum.getAccessDates().setAllowUntilDate(allowUntilDate);
    } else {
        forum.getAccessDates().setAllowUntilDate(null);
    }

    // type - noraml, reply only, read only
    forum.setType(Integer.parseInt(this.request.getParameter("forum_type")));

    // access type - all site participants, deny access, selected groups
    forum.setAccessType(Integer.parseInt(this.request.getParameter("access_type")));
    if (forum.getAccessType() == org.etudes.api.app.jforum.Forum.ForumAccess.GROUPS.getAccessType()) {
        String selectedGroups[] = (String[]) this.request.getParameterValues("selectedGroups");
        if (logger.isDebugEnabled())
            logger.debug("selectedGroups[] " + selectedGroups);

        List selectedGroupsList = new ArrayList();

        if (selectedGroups != null && selectedGroups.length > 0) {
            for (int i = 0; i < selectedGroups.length; i++)
                selectedGroupsList.add(selectedGroups[i]);
        }
        forum.setGroups(selectedGroupsList);
    }

    if (this.request.getParameter("grading_enabled") != null
            && Integer.parseInt(this.request.getParameter("grading_enabled")) == 1) {
        int gradeType = Integer.parseInt(this.request.getParameter("grading_type"));

        forum.setGradeType(Integer.parseInt(this.request.getParameter("grading_type")));

        if (gradeType == org.etudes.api.app.jforum.Grade.GradeType.FORUM.getType()) {
            // grade
            org.etudes.api.app.jforum.Grade grade = forum.getGrade();

            try {
                Float points = Float.parseFloat(this.request.getParameter("points"));

                if (points.floatValue() < 0)
                    points = Float.valueOf(0.0f);
                if (points.floatValue() > 1000)
                    points = Float.valueOf(10000.0f);
                points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);

                grade.setPoints(points);
            } catch (NumberFormatException ne) {
                grade.setPoints(0f);
            }

            String minPostsRequired = this.request.getParameter("min_posts_required");

            if ((minPostsRequired != null) && ("1".equals(minPostsRequired))) {
                try {
                    grade.setMinimumPostsRequired(true);
                    int minimumPosts = this.request.getIntParameter("min_posts");
                    grade.setMinimumPosts(minimumPosts);
                } catch (NumberFormatException ne) {
                    grade.setMinimumPosts(0);
                }
            } else {
                try {
                    grade.setMinimumPostsRequired(false);
                    grade.setMinimumPosts(0);
                } catch (NumberFormatException ne) {
                    grade.setMinimumPosts(0);
                }
            }

            grade.setType(Forum.GRADE_BY_FORUM);

            String sendToGradebook = this.request.getParameter("send_to_grade_book");
            Boolean addToGradeBook = Boolean.FALSE;
            if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
                addToGradeBook = Boolean.TRUE;
            }
            grade.setAddToGradeBook(addToGradeBook);
        }
    } else
        forum.setGradeType(org.etudes.api.app.jforum.Grade.GradeType.DISABLED.getType());

    try {
        int addedForumId = jforumForumService.createForum(forum);

        // if add to grade option unchecked after saving show the error that there is existing title in the gradebook
        String sendToGradebook = this.request.getParameter("send_to_grade_book");
        boolean addToGradeBook = false;
        if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1)) {
            addToGradeBook = true;
        }
        if (addToGradeBook) {
            /*JForumGBService jForumGBService = null;
            jForumGBService = (JForumGBService)ComponentManager.get("org.etudes.api.app.jforum.JForumGBService");
                    
            String gradebookUid = ToolManager.getInstance().getCurrentPlacement().getContext();
            if (jForumGBService != null && jForumGBService.isAssignmentDefined(gradebookUid, forum.getName()))
            {
               this.context.put("errorMessage", I18n.getMessage("Grade.AddEditForumGradeBookConflictingAssignmentNameException"));
            }*/
            org.etudes.api.app.jforum.Forum addedForum = jforumForumService.getForum(addedForumId);

            if (!addedForum.getGrade().isAddToGradeBook()) {
                if (addedForum.getGrade().getPoints() <= 0) {
                    this.context.put("errorMessage",
                            I18n.getMessage("Grade.AddEditForumGradeBookAssignmentHasIllegalPointsException"));
                } else {
                    this.context.put("errorMessage",
                            I18n.getMessage("Grade.AddEditForumGradeBookConflictingAssignmentNameException"));
                }

                this.request.addParameter("forum_id", String.valueOf(addedForum.getId()));
                this.edit();
                return;
            }
        }
    } catch (JForumAccessException e) {
        // already verified access
    }

    /*addGradeTypesToContext();
            
    // check if grading is enabled for forum category
    Category c = DataAccessDriver.getInstance().newCategoryDAO().selectById(this.request.getIntParameter("categories_id"));
            
    if (c.isGradeCategory()
    && (this.request.getParameter("grading_enabled") != null && Integer.parseInt(this.request.getParameter("grading_enabled")) == 1))
    {
       JForum.enableCancelCommit();
       this.context.put("errorMessage", I18n.getMessage("Forums.Forum.CannotAddForumGrading"));
       this.insert();
       return;
    }
            
    Forum f = new Forum();
    f.setDescription(SafeHtml.escapeJavascript(this.request.getParameter("description")));
            
    if (c.getStartDate() == null && c.getEndDate() == null)
    {
       String startDateParam = this.request.getParameter("start_date");
       if (startDateParam != null && startDateParam.trim().length() > 0)
       {
    Date startDate;
    try
    {
       startDate = DateUtil.getDateFromString(startDateParam.trim());
    }
    catch (ParseException e)
    {
       this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
       this.insert();
       return;
    }
    f.setStartDate(startDate);
            
    if (startDate != null)
    {
       SimpleDateFormat df = new SimpleDateFormat(SakaiSystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
       f.setStartDateFormatted(df.format(startDate));
    }
       }
       else
       {
    f.setStartDate(null);
       }
            
       String endDateParam = this.request.getParameter("end_date");
       if (endDateParam != null && endDateParam.trim().length() > 0)
       {
    Date endDate;
    try
    {
       endDate = DateUtil.getDateFromString(endDateParam.trim());
    }
    catch (ParseException e)
    {
       this.context.put("errorMessage", I18n.getMessage("Forums.Forum.DateParseError"));
       this.insert();
       return;
    }
    f.setEndDate(endDate);
    String lockForum = this.request.getParameter("lock_forum");
    if (lockForum != null && "1".equals(lockForum))
    {
       f.setLockForum(true);
    }
    else
    {
       f.setLockForum(false);
    }
            
    if (endDate != null)
    {
       SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
       f.setEndDateFormatted(df.format(endDate));
    }
       }
       else
       {
    f.setEndDate(null);
    f.setLockForum(false);
       }
    }
    else
    {
       f.setStartDate(null);
       f.setEndDate(null);
       f.setLockForum(false);
    }
            
    f.setIdCategories(this.request.getIntParameter("categories_id"));
    f.setName(SafeHtml.escapeJavascript(this.request.getParameter("forum_name")));
    f.setModerated("1".equals(this.request.getParameter("moderate")));
    f.setType(Integer.parseInt(this.request.getParameter("forum_type")));
    f.setAccessType(Integer.parseInt(this.request.getParameter("access_type")));
    if (f.getAccessType() == Forum.ACCESS_GROUPS)
    {
       String selectedGroups[] = (String[]) this.request.getParameterValues("selectedGroups");
       if (logger.isDebugEnabled())
    logger.debug("selectedGroups[] " + selectedGroups);
            
       List selectedGroupsList = new ArrayList();
            
       if (selectedGroups != null && selectedGroups.length > 0)
       {
    for (int i = 0; i < selectedGroups.length; i++)
       selectedGroupsList.add(selectedGroups[i]);
       }
       f.setGroups(selectedGroupsList);
    }
    if (this.request.getParameter("grading_enabled") != null && Integer.parseInt(this.request.getParameter("grading_enabled")) == 1)
       f.setGradeType(Integer.parseInt(this.request.getParameter("grading_type")));
    else
       f.setGradeType(Forum.GRADE_DISABLED);
            
    int forumId = DataAccessDriver.getInstance().newForumDAO().addNew(f);
    f.setId(forumId);
            
    ForumRepository.addForum(f);
            
    // if grading type is forum create grading
    if (f.getGradeType() == Forum.GRADE_BY_FORUM)
    {
       Grade grade = new Grade();
            
       grade.setContext(ToolManager.getCurrentPlacement().getContext());
       grade.setForumId(forumId);
       try
       {
    Float points = Float.parseFloat(this.request.getParameter("points"));
            
    if (points.floatValue() < 0)
       points = Float.valueOf(0.0f);
    if (points.floatValue() > 1000)
       points = Float.valueOf(10000.0f);
    points = Float.valueOf(((float) Math.round(points.floatValue() * 100.0f)) / 100.0f);
            
    grade.setPoints(points);
       }
       catch (NumberFormatException ne)
       {
    grade.setPoints(0f);
       }
            
       String minPostsRequired = this.request.getParameter("min_posts_required");
            
       if ((minPostsRequired != null) && ("1".equals(minPostsRequired)))
       {
    try
    {
       grade.setMinimumPostsRequired(true);
       int minimumPosts = this.request.getIntParameter("min_posts");
       grade.setMinimumPosts(minimumPosts);
    }
    catch (NumberFormatException ne)
    {
       grade.setMinimumPosts(0);
    }
       }
       else
       {
    try
    {
       grade.setMinimumPostsRequired(false);
       grade.setMinimumPosts(0);
    }
    catch (NumberFormatException ne)
    {
       grade.setMinimumPosts(0);
    }
       }
            
       grade.setType(Forum.GRADE_BY_FORUM);
            
       String sendToGradebook = this.request.getParameter("send_to_grade_book");
       boolean addToGradeBook = false;
       if ((sendToGradebook != null) && (Integer.parseInt(sendToGradebook) == 1))
       {
    addToGradeBook = true;
       }
            
       int gradeId = DataAccessDriver.getInstance().newGradeDAO().addNew(grade);
       grade.setId(gradeId);
            
       grade.setAddToGradeBook(addToGradeBook);
            
       // if add to grade book is true then add the grade to grade book
       if (addToGradeBook)
       {
            
     * if (f.getStartDate() != null) { Calendar calendar =
     * Calendar.getInstance();
     * 
     * Date startDate = f.getStartDate();
     * 
     * Date nowDate = calendar.getTime();
     * 
     * if (nowDate.before(startDate)) { addToGradeBook = false; }
     * else { addToGradeBook = updateGradebook(grade); }
     * 
     * } else { addToGradeBook = updateGradebook(grade); }
             
    Date endDate = f.getEndDate();
            
    if (endDate == null)
    {
       endDate = c.getEndDate();
    }
            
    addToGradeBook = updateGradebook(grade, endDate);
       }
       grade.setAddToGradeBook(addToGradeBook);
       DataAccessDriver.getInstance().newGradeDAO().updateAddToGradeBookStatus(gradeId, addToGradeBook);
    }*/

    // auto save navigation
    autoSaveNavigation();
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void setAxisTickMarks(Axis axis, Paint lineColor) {
    Boolean defaultAxisTickMarksVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_TICK_MARKS_VISIBLE);
    if (defaultAxisTickMarksVisible != null && defaultAxisTickMarksVisible.booleanValue()) {
        Float defaultAxisTickMarksInsideLength = (Float) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_INSIDE_LENGTH);
        if (defaultAxisTickMarksInsideLength != null)
            axis.setTickMarkInsideLength(defaultAxisTickMarksInsideLength.floatValue());

        Float defaultAxisTickMarksOutsideLength = (Float) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_OUTSIDE_LENGTH);
        if (defaultAxisTickMarksOutsideLength != null)
            axis.setTickMarkInsideLength(defaultAxisTickMarksOutsideLength.floatValue());

        Paint tickMarkPaint = getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_PAINT) != null
                        ? (Paint) getDefaultValue(defaultAxisPropertiesMap,
                                ChartThemesConstants.AXIS_TICK_MARKS_PAINT)
                        : lineColor;/*  w w  w. j av  a  2s  . c  o  m*/

        if (tickMarkPaint != null) {
            axis.setTickMarkPaint(tickMarkPaint);
        }
        Stroke defaultTickMarkStroke = (Stroke) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_STROKE);
        if (defaultTickMarkStroke != null)
            axis.setTickMarkStroke(defaultTickMarkStroke);
    }
}