Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

In this page you can find the example usage for java.lang Double doubleValue.

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:com.mobileman.projecth.web.controller.ArztController.java

/**
 * @param request//from ww w  .  jav a2  s  . c  om
 * @param model
 * @return "arzt/index"
 */
@RequestMapping(method = RequestMethod.GET, value = "/arzt/index")
public String getDoctorOverview(HttpServletRequest request, Model model) {
    DataHolder dataHolder = new DataHolder(request);
    Doctor doctor = dataHolder.getDoctor();
    model.addAttribute("doctor", doctor);
    model.addAttribute("date_from", DateUtils.date2str(dataHolder.getDateFrom()));
    model.addAttribute("date_to", DateUtils.date2str(dataHolder.getDateTo()));
    Date dateFrom = dataHolder.getDateFrom();
    Date dateTo = dataHolder.getDateTo();

    boolean hasData = false;
    ///////////////////////////////////////////////////
    List<Object[]> data = doctorService.findPatientsCountByDisease(doctor.getId());
    List<PatientsCountByDisease> patientsCountByDiseases = new ArrayList<PatientsCountByDisease>();
    model.addAttribute("patientsCountByDiseases", patientsCountByDiseases);
    for (Object[] item : data) {
        PatientsCountByDisease pc = new PatientsCountByDisease(Number.class.cast(item[0]).intValue(),
                (Disease) item[1]);
        patientsCountByDiseases.add(pc);
        hasData = true;
    }

    ///////////////////////////////////////////////////
    List<PatientsKpiAverageScoreTimelineByDisease> kpiStats = new ArrayList<PatientsKpiAverageScoreTimelineByDisease>();
    model.addAttribute("patientsKpiAverageScoreTimelineByDiseases", kpiStats);
    for (PatientsCountByDisease pc : patientsCountByDiseases) {
        List<KeyPerformanceIndicatorType> kpis = keyPerformanceIndicatorTypeService
                .findAll(pc.getDisease().getId());
        for (KeyPerformanceIndicatorType kpit : kpis) {
            List<KeyPerformanceIndicatorStatistics> statistics = patientKPIService
                    .computeKPIAverageTimeline(kpit.getId(), dateFrom, dateTo);
            if (statistics != null && !statistics.isEmpty()) {
                PatientsKpiAverageScoreTimelineByDisease item = new PatientsKpiAverageScoreTimelineByDisease(
                        kpit, statistics);
                kpiStats.add(item);
            }
        }
    }

    ///////////////////////////////////////////////////////////////
    data = doctorService.findPatientsCountByGenderByDisease(doctor.getId());
    List<PatientsCountByGendersByDisease> patientsCountByGenderByDiseases = new ArrayList<PatientsCountByGendersByDisease>();
    model.addAttribute("patientsCountByGenderByDiseases", patientsCountByGenderByDiseases);
    for (PatientsCountByDisease pcd : patientsCountByDiseases) {
        PatientsCountByGendersByDisease stat = new PatientsCountByGendersByDisease(pcd.getDisease(),
                localeService);
        patientsCountByGenderByDiseases.add(stat);
        for (Object[] countItem : data) {
            if (countItem[2].equals(pcd.getDisease())) {
                int count = Number.class.cast(countItem[0]).intValue();
                stat.add(count, Gender.class.cast(countItem[1]));
            }
        }

        hasData = true;
    }

    ///////////////////////////////////////////////////////////////
    data = doctorService.findPatientsCountByAgeByDisease(doctor.getId());
    List<PatientsCountsByAgeByDisease> patientsCountByAgeByDisease = new ArrayList<PatientsCountsByAgeByDisease>();
    model.addAttribute("patientsCountByAgeByDisease", patientsCountByAgeByDisease);
    for (PatientsCountByDisease pcd : patientsCountByDiseases) {
        PatientsCountsByAgeByDisease stat = new PatientsCountsByAgeByDisease(pcd.getDisease(), localeService);
        patientsCountByAgeByDisease.add(stat);
        for (Object[] countItem : data) {

            if (countItem[2].equals(pcd.getDisease())) {
                int count = countItem[0] != null ? Number.class.cast(countItem[0]).intValue() : 0;
                stat.add(count, Number.class.cast(countItem[1]).intValue());
            }
        }

        hasData = true;
    }

    ///////////////////////////////////////////////////////////////
    data = doctorService.findPatientsKpiAverageScoreByDisease(doctor.getId());
    List<PatientsKpiAverageScoresByDisease> patientsKpiAverageScoreByDisease = new ArrayList<PatientsKpiAverageScoresByDisease>();
    model.addAttribute("patientsKpiAverageScoreByDisease", patientsKpiAverageScoreByDisease);
    for (PatientsCountByDisease stat : patientsCountByDiseases) {

        PatientsKpiAverageScoresByDisease pkpis = new PatientsKpiAverageScoresByDisease();
        patientsKpiAverageScoreByDisease.add(pkpis);

        List<KeyPerformanceIndicatorType> kpits = keyPerformanceIndicatorTypeService
                .findAll(stat.getDisease().getId());
        for (KeyPerformanceIndicatorType kpit : kpits) {

            boolean found = false;
            for (Object[] item : data) {
                KeyPerformanceIndicatorType kpitTmp = KeyPerformanceIndicatorType.class.cast(item[1]);
                if (kpit.equals(kpitTmp)) {
                    Double score = Double.class.cast(item[2]);
                    pkpis.add(kpit, score.doubleValue());
                    found = true;
                    break;
                }
            }

            if (!found) {
                pkpis.add(kpit, 0.0d);
            }
        }

        hasData = true;
    }

    model.addAttribute("hasData", Boolean.valueOf(hasData));

    return "arzt/index";
}

From source file:com.acc.storefront.controllers.pages.PickupInStoreController.java

@RequestMapping(value = PRODUCT_CODE_PATH_VARIABLE_PATTERN + "/pointOfServices", method = RequestMethod.POST)
public String getPointOfServiceForStorePickupSubmit(@PathVariable("productCode") final String productCode,
        @RequestParam(value = "locationQuery", required = false) final String locationQuery,
        @RequestParam(value = "latitude", required = false) final Double latitude,
        @RequestParam(value = "longitude", required = false) final Double longitude,
        @RequestParam(value = "page", defaultValue = "0") final int page,
        @RequestParam(value = "show", defaultValue = "Page") final AbstractSearchPageController.ShowMode showMode,
        @RequestParam(value = "sort", required = false) final String sortCode,
        @RequestParam(value = "cartPage", defaultValue = "Page") final Boolean cartPage,
        @RequestParam(value = "entryNumber", defaultValue = "0") final Long entryNumber,
        @RequestParam(value = "qty", defaultValue = "0") final Long qty, final HttpServletResponse response,
        final Model model) {
    GeoPoint geoPoint = null;/*  w  w w.  jav a2s  .c o  m*/
    if (longitude != null && latitude != null) {
        geoPoint = new GeoPoint();
        geoPoint.setLongitude(longitude.doubleValue());
        geoPoint.setLatitude(latitude.doubleValue());
    }

    model.addAttribute("qty", qty);

    return getPointOfServiceForStorePickup(productCode, locationQuery, geoPoint, page, showMode, sortCode,
            cartPage, entryNumber, model, RequestMethod.POST, response);
}

From source file:com.openbravo.pos.forms.DataLogicSales.java

public final double findProductStock(String warehouse, String id, String attsetinstid) throws BasicException {

    PreparedSentence p = new PreparedSentence(s,
            "SELECT UNITS FROM STOCKCURRENT WHERE LOCATION = ? AND PRODUCT = ?",
            new SerializerWriteBasic(Datas.STRING, Datas.STRING), SerializerReadDouble.INSTANCE);

    Double d = (Double) p.find(warehouse, id, attsetinstid);
    return d == null ? 0.0 : d.doubleValue();
}

From source file:com.blackbear.flatworm.converters.CoreConverters.java

public String convertDecimal(Object obj, Map<String, ConversionOption> options) {
    Double d = (Double) obj;
    if (d == null) {
        return null;
    }// ww w .j av  a2  s  .com

    int decimalPlaces = 0;
    ConversionOption conv = (ConversionOption) options.get("decimal-places");

    String decimalPlacesOption = null;
    if (null != conv)
        decimalPlacesOption = conv.getValue();

    boolean decimalImplied = "true".equals(Util.getValue(options, "decimal-implied"));

    if (decimalPlacesOption != null)
        decimalPlaces = Integer.parseInt(decimalPlacesOption);

    DecimalFormat format = new DecimalFormat();
    format.setDecimalSeparatorAlwaysShown(!decimalImplied);
    format.setGroupingUsed(false);
    if (decimalImplied) {
        format.setMaximumFractionDigits(0);
        d = new Double(d.doubleValue() * Math.pow(10D, decimalPlaces));
    } else {
        format.setMinimumFractionDigits(decimalPlaces);
        format.setMaximumFractionDigits(decimalPlaces);
    }
    return format.format(d);
}

From source file:de.fhg.fokus.odp.middleware.ckan.CKANGatewayUtil.java

/**
 * Returns a list of the most popular tags.
 * /*w w w  .j a v a2s .co  m*/
 * @param numberOfTags
 *            the number of popular tags to return.
 * @return the most popular tags or null if an error occurred.
 */
@Deprecated
@SuppressWarnings("unchecked")
public static JSONArray getMostPopularTagsOld(int numberOfTags) {

    // check the parameters
    if (numberOfTags <= 0) {
        return null;
    }

    // the json array to return
    JSONArray toreturn = new JSONArray();

    // the array to store rating values
    double[] ratingValues = new double[numberOfTags];
    // even tough Java does it automatically, we set the values to zero
    for (int i = 0; i < ratingValues.length; i++) {
        ratingValues[i] = 0.0;
    }

    // a help array for the package ratings
    HashMap<String, Double> packageRatings = new HashMap<String, Double>();

    // prepare the REST API call
    String RESTcall = "api/rest/tag";

    try {
        // run the REST call to obtain all tags
        String tagListString = connectorInstance.restCallWithAuthorization(RESTcall, null);
        if (tagListString == null) {
            log.log(Level.SEVERE, "Failed to realize api call \"" + url + RESTcall + "\" !!!");
            return null;
        }

        // parse the JSON string and obtain an array of JSON objects
        Object obj = JSONValue.parse(tagListString);
        JSONArray array = (JSONArray) obj;

        // move over the tags in the array
        for (int i = 0; i < array.size(); i++) {

            // pick the tag name
            String tagName = (String) array.get(i);

            // run the REST call to obtain all packages for the tag in
            // question
            String tRESTcall = RESTcall + "/" + tagName;
            String pListString = connectorInstance.restCallWithAuthorization(tRESTcall, null);

            if (pListString == null) {
                log.log(Level.SEVERE, "Failed to realize api call \"" + url + RESTcall + "\" !!!");
                return null;
            }

            // parse the JSON string
            Object pObj = JSONValue.parse(pListString);
            JSONArray pArray = (JSONArray) pObj;

            // iterate over the JSON array
            double tagRating = 0.0;
            for (int j = 0; j < pArray.size(); j++) {
                // pick the name of the package
                String pName = (String) (pArray.get(j));

                // check whether the average rating value has already been
                // obtained
                Double aRatingValueD = packageRatings.get(pName);

                if (aRatingValueD == null) {
                    // in case it was not obtained until now --> get it and
                    // store it locally
                    double aRatingValue = CKANGatewayUtil.getDataSetRatingsAverage(pName);
                    aRatingValueD = new Double(aRatingValue);
                    packageRatings.put(pName, aRatingValueD);
                }

                // update the tag rating
                tagRating += aRatingValueD.doubleValue();
            }

            // update the toreturn array
            if (toreturn.size() < numberOfTags) {
                toreturn.add(tagName);
                ratingValues[toreturn.size() - 1] = tagRating;

            } else {
                // get the smallest value in the rating values
                int minIndex = minDoubleArray(ratingValues);
                if (ratingValues[minIndex] < tagRating) {
                    ratingValues[minIndex] = tagRating;
                    toreturn.set(minIndex, tagName);
                }
            }
        }
    }
    // catch potential exceptions
    catch (MalformedURLException e) {
        log.log(Level.SEVERE, "Failed to realize api call \"" + url + RESTcall + "\" !!!");
        return null;
    } catch (IOException e) {
        return null;
    }

    return toreturn;
}

From source file:com.ctc.storefront.controllers.pages.PickupInStoreController.java

@RequestMapping(value = PRODUCT_CODE_PATH_VARIABLE_PATTERN + "/pointOfServices", method = RequestMethod.POST)
public String getPointOfServiceForStorePickupSubmit(@PathVariable("productCode") final String productCode, // NOSONAR
        @RequestParam(value = "locationQuery", required = false) final String locationQuery,
        @RequestParam(value = "latitude", required = false) final Double latitude,
        @RequestParam(value = "longitude", required = false) final Double longitude,
        @RequestParam(value = "page", defaultValue = "0") final int page,
        @RequestParam(value = "show", defaultValue = "Page") final AbstractSearchPageController.ShowMode showMode,
        @RequestParam(value = "sort", required = false) final String sortCode,
        @RequestParam(value = "cartPage", defaultValue = "Page") final Boolean cartPage,
        @RequestParam(value = "entryNumber", defaultValue = "0") final Long entryNumber,
        @RequestParam(value = "qty", defaultValue = "0") final Long qty, final HttpServletResponse response,
        final Model model) {
    GeoPoint geoPoint = null;// w  w w.j  av a 2 s. c  o m
    if (longitude != null && latitude != null) {
        geoPoint = new GeoPoint();
        geoPoint.setLongitude(longitude.doubleValue());
        geoPoint.setLatitude(latitude.doubleValue());
    }

    model.addAttribute("qty", qty);

    return getPointOfServiceForStorePickup(productCode, locationQuery, geoPoint, page, showMode, sortCode,
            cartPage, entryNumber, model, RequestMethod.POST, response);
}

From source file:org.sakaiproject.tool.gradebook.ui.AssignmentDetailsBean.java

protected void init() {
    if (logger.isDebugEnabled())
        logger.debug("loadData assignment=" + assignment + ", previousAssignment=" + previousAssignment
                + ", nextAssignment=" + nextAssignment);
    if (logger.isDebugEnabled())
        logger.debug("isNotValidated()=" + isNotValidated());
    if (logger.isDebugEnabled())
        logger.debug("workInProgress=" + workInProgress);
    if (workInProgress) {
        // Keeping the current form values in memory is a one-shot deal at
        // present. The next time the user does anything, the form will be
        // refreshed from the database.
        workInProgress = false;/*from  ww  w .  ja v a  2 s. c o m*/
        ToolSession session = SessionManager.getCurrentToolSession();
        final String fromPage = (String) session.getAttribute("fromPage");
        if (fromPage != null) {
            setBreadcrumbPage(fromPage);
        }

        return;
    }

    // set the filter value for this page
    super.setSelectedSectionFilterValue(this.getSelectedSectionFilterValue());
    super.init();

    ToolSession session = SessionManager.getCurrentToolSession();
    final String fromPage = (String) session.getAttribute("breadcrumbPage");
    if (fromPage != null) {
        setBreadcrumbPage(fromPage);
    }

    // Clear view state.
    previousAssignment = null;
    nextAssignment = null;
    scoreRows = new ArrayList();
    updatedComments = new ArrayList();
    updatedGradeRecords = new ArrayList();
    isAllStudentsViewOnly = true;

    if (assignmentId != null) {
        assignment = getGradebookManager().getAssignmentWithStats(assignmentId);
        if (assignment != null) {
            // Get the list of assignments.  If we are sorting by mean, we
            // need to fetch the assignment statistics as well. If categories
            // are enabled, we need to retrieve the categories and extract the assignments
            // b/c the assignments will be grouped by category
            List assignments;
            if (!getCategoriesEnabled() && Assignment.SORT_BY_MEAN.equals(getAssignmentSortColumn())) {
                assignments = getGradebookManager().getAssignmentsWithStats(getGradebookId(),
                        getAssignmentSortColumn(), isAssignmentSortAscending());
            } else if (!getCategoriesEnabled()) {
                assignments = getGradebookManager().getAssignments(getGradebookId(), getAssignmentSortColumn(),
                        isAssignmentSortAscending());
            } else {
                // Categories are enabled, so the assignments are grouped by category
                assignments = new ArrayList();

                List categoryListWithCG = getGradebookManager().getCategoriesWithStats(getGradebookId(),
                        getAssignmentSortColumn(), isAssignmentSortAscending(), getCategorySortColumn(),
                        isCategorySortAscending(), true);

                // if drop scores, must apply the average total as it was calculated for all assignments within the category
                if (assignment.getCategory() != null && assignment.getCategory().isDropScores()) {
                    for (Object obj : categoryListWithCG) {
                        if (obj instanceof Category) {
                            List<Assignment> catAssignments = ((Category) obj).getAssignmentList();
                            if (catAssignments != null) {
                                for (Assignment catAssignment : catAssignments) {
                                    if (catAssignment.equals(assignment)) {
                                        assignment.setAverageTotal(catAssignment.getAverageTotal());
                                        assignment.setMean(catAssignment.getMean());
                                    }

                                }
                            }
                        }
                    }
                }

                List categoryList = new ArrayList();

                // first, remove the CourseGrade from the Category list
                for (Iterator catIter = categoryListWithCG.iterator(); catIter.hasNext();) {
                    Object catOrCourseGrade = catIter.next();
                    if (catOrCourseGrade instanceof Category) {
                        categoryList.add((Category) catOrCourseGrade);
                    }
                }

                if (!isUserAbleToGradeAll() && isUserHasGraderPermissions()) {
                    //SAK-19896, eduservice's can't share the same "Category" class, so just pass the ID's
                    List<Long> catIds = new ArrayList<Long>();
                    for (Category category : (List<Category>) categoryList) {
                        catIds.add(category.getId());
                    }
                    List<Long> viewableCats = getGradebookPermissionService()
                            .getCategoriesForUser(getGradebookId(), getUserUid(), catIds);
                    List<Category> tmpCatList = new ArrayList<Category>();
                    for (Category category : (List<Category>) categoryList) {
                        if (viewableCats.contains(category.getId())) {
                            tmpCatList.add(category);
                        }
                    }
                    categoryList = tmpCatList;
                }

                if (categoryList != null) {
                    Iterator catIter = categoryList.iterator();
                    while (catIter.hasNext()) {
                        Category myCat = (Category) catIter.next();
                        List catAssigns = myCat.getAssignmentList();
                        if (catAssigns != null) {
                            assignments.addAll(catAssigns);
                        }
                    }
                }
                // we also need to retrieve all of the assignments that have not
                // yet been assigned a category
                if (!isUserAbleToGradeAll() && (isUserHasGraderPermissions() && !getGradebookPermissionService()
                        .getPermissionForUserForAllAssignment(getGradebookId(), getUserUid()))) {
                    // is not authorized to view the "Unassigned" Category
                } else {
                    List assignNoCategory = getGradebookManager().getAssignmentsWithNoCategory(getGradebookId(),
                            getAssignmentSortColumn(), isAssignmentSortAscending());
                    if (assignNoCategory != null) {
                        assignments.addAll(assignNoCategory);
                    }
                }
            }

            // Set up next and previous links, if any.
            int thisIndex = assignments.indexOf(assignment);
            if (thisIndex > 0) {
                previousAssignment = (Assignment) assignments.get(thisIndex - 1);
            }
            if (thisIndex < (assignments.size() - 1)) {
                nextAssignment = (Assignment) assignments.get(thisIndex + 1);
            }

            Category category = assignment.getCategory();
            Long categoryId = null;
            if (category != null)
                categoryId = category.getId();

            // Set up score rows.
            Map enrollmentMap = getOrderedEnrollmentMapForItem(categoryId);

            List studentUids = new ArrayList(enrollmentMap.keySet());
            List gradeRecords = new ArrayList();
            if (getGradeEntryByPoints())
                gradeRecords = getGradebookManager().getAssignmentGradeRecords(assignment, studentUids);
            else
                gradeRecords = getGradebookManager().getAssignmentGradeRecordsConverted(assignment,
                        studentUids);

            List<AssignmentGradeRecord> studentGradeRecords = getGradebookManager()
                    .getAllAssignmentGradeRecords(getGradebookId(), studentUids);

            getGradebookManager().applyDropScores(studentGradeRecords);

            copyDroppedFromGradeFlag(gradeRecords, studentGradeRecords);

            if (!isEnrollmentSort()) {
                // Need to sort and page based on a scores column.
                List scoreSortedStudentUids = new ArrayList();
                for (Iterator iter = gradeRecords.iterator(); iter.hasNext();) {
                    AbstractGradeRecord agr = (AbstractGradeRecord) iter.next();
                    scoreSortedStudentUids.add(agr.getStudentId());
                }

                // Put enrollments with no scores at the beginning of the final list.
                studentUids.removeAll(scoreSortedStudentUids);

                // Add all sorted enrollments with scores into the final list
                studentUids.addAll(scoreSortedStudentUids);

                studentUids = finalizeSortingAndPaging(studentUids);
            }

            // Get all of the grading events for these enrollments on this assignment
            GradingEvents allEvents = getGradebookManager().getGradingEvents(assignment, studentUids);
            // NOTE: we are no longer converting the events b/c we are
            // storing what the user entered, not just points
            //getGradebookManager().convertGradingEventsConverted(assignment, allEvents, studentUids, getGradebook().getGrade_type());

            Map gradeRecordMap = new HashMap();
            for (Iterator iter = gradeRecords.iterator(); iter.hasNext();) {
                AssignmentGradeRecord gradeRecord = (AssignmentGradeRecord) iter.next();
                if (studentUids.contains(gradeRecord.getStudentId())) {
                    gradeRecordMap.put(gradeRecord.getStudentId(), gradeRecord);
                }
            }

            // If the table is not being sorted by enrollment information, then
            // we had to gather grade records for all students to set up the
            // current page. In that case, eliminate the undisplayed grade records
            // to reduce data contention.
            if (!isEnrollmentSort()) {
                gradeRecords = new ArrayList(gradeRecordMap.values());
            }

            // Get all of the comments for these enrollments on this assignment.
            List comments = getGradebookManager().getComments(assignment, studentUids);
            Map commentMap = new HashMap();
            for (Iterator iter = comments.iterator(); iter.hasNext();) {
                Comment comment = (Comment) iter.next();
                commentMap.put(comment.getStudentId(), comment);
            }

            for (Iterator iter = studentUids.iterator(); iter.hasNext();) {
                String studentUid = (String) iter.next();
                Map enrFunctionMap = (Map) enrollmentMap.get(studentUid);
                List enrRecList = new ArrayList(enrFunctionMap.keySet());
                EnrollmentRecord enrollment = (EnrollmentRecord) enrRecList.get(0); // there is only one rec in this map

                AssignmentGradeRecord gradeRecord = (AssignmentGradeRecord) gradeRecordMap.get(studentUid);
                if (gradeRecord == null) {
                    gradeRecord = new AssignmentGradeRecord(assignment, studentUid, null);
                    gradeRecords.add(gradeRecord);
                }

                Comment comment = (Comment) commentMap.get(studentUid);
                if (comment == null) {
                    comment = new Comment(studentUid, null, assignment);
                }

                boolean userCanGrade = false;
                String itemFunction = (String) enrFunctionMap.get(enrollment);
                if (itemFunction != null && itemFunction.equalsIgnoreCase(GradebookService.gradePermission))
                    userCanGrade = true;

                scoreRows.add(new ScoreRow(enrollment, gradeRecord, comment, allEvents.getEvents(studentUid),
                        userCanGrade));
                if (userCanGrade)
                    isAllStudentsViewOnly = false;
            }

            if (getCategoriesEnabled()) {
                if (assignment.getCategory() != null) {
                    List<String> items = new ArrayList<String>();
                    if (assignment.getCategory().getDropHighest() != 0) {
                        items.add(getLocalizedString("cat_drop_highest_display",
                                new String[] { assignment.getCategory().getDropHighest().toString() }));
                    }
                    if (assignment.getCategory().getDrop_lowest() != 0) {
                        items.add(getLocalizedString("cat_drop_lowest_display",
                                new String[] { assignment.getCategory().getDrop_lowest().toString() }));
                    }
                    String categoryGradeDrops = null;
                    if (items.size() > 0) {
                        categoryGradeDrops = " " + items.toString().replace('[', '(').replace(']', ')');
                    }
                    if (getWeightingEnabled()) {
                        Double weight = assignment.getCategory().getWeight();
                        if (weight != null && weight.doubleValue() > 0)
                            weight = new Double(weight.doubleValue() * 100);
                        if (weight == null)
                            throw new IllegalStateException("Double weight == null!");
                        assignmentWeight = weight.toString();
                        assignmentCategory = assignment.getCategory().getName() + " "
                                + getLocalizedString("cat_weight_display", new String[] { assignmentWeight });
                        if (categoryGradeDrops != null) {
                            assignmentCategory = assignmentCategory + categoryGradeDrops;
                        }
                    } else {
                        assignmentCategory = assignment.getCategory().getName();
                        if (categoryGradeDrops != null) {
                            assignmentCategory = assignmentCategory + categoryGradeDrops;
                        }
                    }
                } else {
                    assignmentCategory = getLocalizedString("assignment_details_assign_category");
                }
            }

        } else {
            // The assignment might have been removed since this link was set up.
            if (logger.isWarnEnabled())
                logger.warn("No assignmentId=" + assignmentId + " in gradebookUid " + getGradebookUid());
            FacesUtil.addErrorMessage(getLocalizedString("assignment_details_assignment_removed"));
        }
    }

    if (isScoringAgentEnabled()) {
        scoringAgentData = initializeScoringAgentData(getGradebookUid(), assignmentId, null);
    }
}

From source file:org.catechis.Stats.java

/**This method takes a Hashtable with the test_date-score format.
* We steps thru the list, adding up the scores and then divides by the number of tests.
* We also check the dates, hanging on to the latest date for later retrieval in the
* getLastTest method.//from   www.  ja  v a 2 s  .co  m
*/
public double getAverage(Hashtable tests) {
    int number_of_tests = tests.size();
    double running_total = 0.0;
    int i = 0;
    last_time = 0;
    Enumeration e = tests.keys();
    while (e.hasMoreElements()) {
        String str_grade = (String) e.nextElement();
        String str_date = (String) tests.get(str_grade);
        Double dbl_score = new Double(str_grade);
        double score = dbl_score.doubleValue();
        running_total = (running_total + score);
        i++;
        compareDates(str_date);
    }
    running_total_of_tests = running_total_of_tests + running_total;
    total_test_count = total_test_count + number_of_tests;
    double average_score = (running_total / number_of_tests);
    return average_score;
}

From source file:org.sakaiproject.tool.gradebook.ui.GradebookSetupBean.java

/**
 * Because we display input as "percentage" to user but store it as
 * decimal, we need a way to convert our weights from decimal to %
 *//*from   www  . j  a  v a2s  .co  m*/
private void convertWeightsFromDecimalsToPercentages() {
    if (!getWeightingEnabled())
        return;

    if (categories != null && !categories.isEmpty()) {
        Iterator iter = categories.iterator();
        while (iter.hasNext()) {
            Object obj = iter.next();
            if (!(obj instanceof Category)) {
                continue;
            }
            Category myCat = (Category) obj;
            Double weight = myCat.getWeight();
            if (weight != null && weight.doubleValue() > 0) {
                myCat.setWeight(new Double(weight.doubleValue() * 100));
            }
        }
    }
}

From source file:org.sakaiproject.tool.gradebook.ui.GradebookSetupBean.java

private void initLetterGradeRows() {
    letterGradeRows = new ArrayList();

    for (Iterator iter = letterGradesList.iterator(); iter.hasNext();) {
        String grade = (String) iter.next();

        // Bottom grades (with a lower bound of 0%)
        Double d = defaultLGPM.getValue(grade);
        boolean editable = ((d != null) && (d.doubleValue() > 0.0));
        letterGradeRows.add(new LetterGradeRow(lgpm, grade, editable));
    }//from w  w w  .  j  a va 2  s . c  om
}