List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:org.squale.squaleweb.applicationlayer.action.results.project.ProjectResultsAction.java
/** * Rcupre les dtails de la pratique/*w ww .j av a 2s .c o m*/ * * @param pMapping le mapping. * @param pForm le formulaire lire. * @param pRequest la requte HTTP. * @param pResponse la rponse de la servlet. * @return l'action raliser. */ public ActionForward mark(ActionMapping pMapping, ActionForm pForm, HttpServletRequest pRequest, HttpServletResponse pResponse) { ActionForward forward = null; ActionErrors errors = new ActionErrors(); // sert aussi pour le traceur String value = "", minValue = "", maxValue = "", factorParent = "", param = "", note = "", markParamForTracker = ""; try { forward = init(pMapping, pRequest, pForm); if (null == forward) { param = (String) pRequest.getParameter("tre"); factorParent = (String) pRequest.getParameter("factorParent"); IApplicationComponent acGrid = AccessDelegateHelper.getInstance("QualityGrid"); // Obtention de la pratique long practiceId = Long.parseLong((String) pRequest.getParameter("tre")); PracticeRuleDTO practice = new PracticeRuleDTO(); practice.setId(practiceId); practice = (PracticeRuleDTO) acGrid.execute("getQualityRule", new Object[] { practice, new Boolean(false) }); FactorRuleDTO factor = new FactorRuleDTO(); if (factorParent != null) { // Obtention du facteur long factorId = Long.parseLong(factorParent); factor.setId(factorId); factor = (FactorRuleDTO) acGrid.execute("getQualityRule", new Object[] { factor, new Boolean(false) }); } else { factor.setId(-1); factor.setName(""); } // Prparation de l'appel des couches mtier IApplicationComponent ac = AccessDelegateHelper.getInstance("Results"); AuditDTO audit = (AuditDTO) (ActionUtils.getCurrentAuditsAsDTO(pRequest).get(0)); ComponentDTO project = (ComponentDTO) pRequest.getSession() .getAttribute(BaseDispatchAction.PROJECT_DTO); ResultsDTO result = null; value = (String) pRequest.getParameter("currentMark"); // Suivant le type de paramtre pass, on peut savoir si on vient du graph ou si // on vient du tableau de rpartition if (value != null) { // Clic sur le tableau de rpartition // Note entire ajouter l'url du traceur markParamForTracker = "¤tMark=" + value; Integer intValue = new Integer(value); // Un nombre maximal de rsultats est retrouv Object[] paramIn = { audit, project, new Long(practiceId), intValue, new Integer(WebMessages.getString(Locale.getDefault(), "component.max")) }; // Appel de la couche mtier result = (ResultsDTO) ac.execute("getValueResults", paramIn); // Transformation vers le formulaire WTransformerFactory.objToForm(MarkTransformer.class, (WActionForm) pForm, new Object[] { result, factor, practice, intValue }); note = WebMessages.getString(pRequest, "project.results.mark.status_" + value); } else { // clic sur le graph minValue = (String) pRequest.getParameter("minMark"); maxValue = (String) pRequest.getParameter("maxMark"); // Intervalle ajouter l'url du traceur markParamForTracker = "&minMark=" + minValue + "&maxMark=" + maxValue; // Conversion en double Double minMark = new Double(minValue); Double maxMark = new Double(maxValue); // Un nombre maximal de rsultats est retrouv Object[] paramIn = { audit, project, new Long(practiceId), minMark, maxMark, new Integer(WebMessages.getString(Locale.getDefault(), "component.max")) }; // Appel de la couche mtier result = (ResultsDTO) ac.execute("getValueResultsForInterval", paramIn); // Transformation vers le formulaire WTransformerFactory.objToForm(MarkTransformer.class, (WActionForm) pForm, new Object[] { result, factor, practice, minMark, maxMark }); note = WebMessages.getString(pRequest, "project.results.mark"); // pour le traceur note += "[" + minMark.doubleValue() + "," + maxMark.doubleValue(); // Suivant la note, on l'inclus ou pas la dans l'intervalle // on ne l'inclus que si c'est 3 if (maxMark.intValue() != PracticeResultBO.EXCELLENT) { note += "["; } else { note += "]"; } } forward = pMapping.findForward("mark"); } } catch (Exception e) { // Traitement factoris des exceptions handleException(e, errors, pRequest); } if (!errors.isEmpty()) { // Enregistrement des messages et routage vers une page d'erreur saveMessages(pRequest, errors); forward = pMapping.findForward("total_failure"); } // Mise en place du traceur historique String url = "mark.do?action=mark&tre=" + param + markParamForTracker; if (factorParent != null) { url += "&factorparent=" + factorParent; } updateHistTracker(note, url, TrackerStructure.FACTOR_VIEW, pRequest, false); // Indique que l'on vient d'une vue synthse et pas d'une vue composant changeWay(pRequest, "false"); // ICI on doit dire qu'il faudra effacer completement le traceur // aprs le passage sur le prochain composant needToReset(pRequest, "true"); // ***************************************************************** return forward; }
From source file:org.sakaiproject.tool.gradebook.business.impl.GradebookManagerHibernateImpl.java
public double getTotalPointsInternal(final Long gradebookId, final Gradebook gradebook, final List categories, final String studentId) { HibernateCallback hc = new HibernateCallback() { @Override//from ww w . ja v a 2s . c o m public Object doInHibernate(Session session) throws HibernateException { double totalPointsPossible = 0; List assgnsList = session.createQuery( "select asn from Assignment asn where asn.gradebook.id=:gbid and asn.removed=false and asn.notCounted=false and asn.ungraded=false and asn.pointsPossible > 0") .setParameter("gbid", gradebookId).list(); Iterator scoresIter = session.createQuery( "select agr.pointsEarned, asn from AssignmentGradeRecord agr, Assignment asn where agr.gradableObject=asn and agr.studentId=:student and asn.gradebook.id=:gbid and asn.removed=false and asn.notCounted=false and asn.ungraded=false and asn.pointsPossible > 0") .setParameter("student", studentId).setParameter("gbid", gradebookId).list().iterator(); Set categoryTaken = new HashSet(); Set assignmentsTaken = new HashSet(); while (scoresIter.hasNext()) { Object[] returned = (Object[]) scoresIter.next(); Double pointsEarned = (Double) returned[0]; Assignment go = (Assignment) returned[1]; if (pointsEarned != null) { if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_NO_CATEGORY) { assignmentsTaken.add(go.getId()); } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_ONLY_CATEGORY && go != null) { assignmentsTaken.add(go.getId()); } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY && go != null && categories != null) { for (int i = 0; i < categories.size(); i++) { Category cate = (Category) categories.get(i); if (cate != null && !cate.isRemoved() && go.getCategory() != null && cate.getId().equals(go.getCategory().getId())) { assignmentsTaken.add(go.getId()); categoryTaken.add(cate.getId()); break; } } } } } if (!assignmentsTaken.isEmpty()) { if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY) { for (int i = 0; i < categories.size(); i++) { Category cate = (Category) categories.get(i); if (cate != null && !cate.isRemoved() && categoryTaken.contains(cate.getId())) { totalPointsPossible += cate.getWeight().doubleValue(); } } return totalPointsPossible; } Iterator assignmentIter = assgnsList.iterator(); while (assignmentIter.hasNext()) { Assignment asn = (Assignment) assignmentIter.next(); if (asn != null) { Double pointsPossible = asn.getPointsPossible(); if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_NO_CATEGORY && assignmentsTaken.contains(asn.getId())) { totalPointsPossible += pointsPossible.doubleValue(); } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_ONLY_CATEGORY && assignmentsTaken.contains(asn.getId())) { totalPointsPossible += pointsPossible.doubleValue(); } } } } else totalPointsPossible = -1; return totalPointsPossible; } }; return (Double) getHibernateTemplate().execute(hc); }
From source file:org.sakaiproject.tool.gradebook.business.impl.GradebookManagerHibernateImpl.java
public double getTotalPointsEarnedInternal(final Long gradebookId, final String studentId, final Gradebook gradebook, final List categories) { HibernateCallback hc = new HibernateCallback() { @Override//w w w . j a va 2s . c om public Object doInHibernate(Session session) throws HibernateException { double totalPointsEarned = 0; Iterator scoresIter = session.createQuery( "select agr.pointsEarned, asn from AssignmentGradeRecord agr, Assignment asn where agr.gradableObject=asn and agr.studentId=:student and asn.gradebook.id=:gbid and asn.removed=false and asn.notCounted=false and asn.ungraded=false and asn.pointsPossible > 0") .setParameter("student", studentId).setParameter("gbid", gradebookId).list().iterator(); List assgnsList = session.createQuery( "from Assignment as asn where asn.gradebook.id=:gbid and asn.removed=false and asn.notCounted=false and asn.ungraded=false and asn.pointsPossible > 0") .setParameter("gbid", gradebookId).list(); Map cateScoreMap = new HashMap(); Map cateTotalScoreMap = new HashMap(); Set assignmentsTaken = new HashSet(); while (scoresIter.hasNext()) { Object[] returned = (Object[]) scoresIter.next(); Double pointsEarned = (Double) returned[0]; Assignment go = (Assignment) returned[1]; if (pointsEarned != null) { if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_NO_CATEGORY) { totalPointsEarned += pointsEarned.doubleValue(); assignmentsTaken.add(go.getId()); } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_ONLY_CATEGORY && go != null) { totalPointsEarned += pointsEarned.doubleValue(); assignmentsTaken.add(go.getId()); } else if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY && go != null && categories != null) { for (int i = 0; i < categories.size(); i++) { Category cate = (Category) categories.get(i); if (cate != null && !cate.isRemoved() && go.getCategory() != null && cate.getId().equals(go.getCategory().getId())) { assignmentsTaken.add(go.getId()); if (cateScoreMap.get(cate.getId()) != null) { cateScoreMap.put(cate.getId(), new Double(((Double) cateScoreMap.get(cate.getId())).doubleValue() + pointsEarned.doubleValue())); } else { cateScoreMap.put(cate.getId(), new Double(pointsEarned)); } break; } } } } } if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY && categories != null) { Iterator assgnsIter = assgnsList.iterator(); while (assgnsIter.hasNext()) { Assignment asgn = (Assignment) assgnsIter.next(); if (assignmentsTaken.contains(asgn.getId())) { for (int i = 0; i < categories.size(); i++) { Category cate = (Category) categories.get(i); if (cate != null && !cate.isRemoved() && asgn.getCategory() != null && cate.getId().equals(asgn.getCategory().getId())) { if (cateTotalScoreMap.get(cate.getId()) == null) { cateTotalScoreMap.put(cate.getId(), asgn.getPointsPossible()); } else { cateTotalScoreMap.put(cate.getId(), new Double( ((Double) cateTotalScoreMap.get(cate.getId())).doubleValue() + asgn.getPointsPossible().doubleValue())); } } } } } } if (assignmentsTaken.isEmpty()) totalPointsEarned = -1; if (gradebook.getCategory_type() == GradebookService.CATEGORY_TYPE_WEIGHTED_CATEGORY) { for (int i = 0; i < categories.size(); i++) { Category cate = (Category) categories.get(i); if (cate != null && !cate.isRemoved() && cateScoreMap.get(cate.getId()) != null && cateTotalScoreMap.get(cate.getId()) != null) { totalPointsEarned += ((Double) cateScoreMap.get(cate.getId())).doubleValue() * cate.getWeight().doubleValue() / ((Double) cateTotalScoreMap.get(cate.getId())).doubleValue(); } } } if (log.isDebugEnabled()) log.debug("getTotalPointsEarnedInternal for studentId=" + studentId + " returning " + totalPointsEarned); return totalPointsEarned; } }; return (Double) getHibernateTemplate().execute(hc); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.OverlaidBarLine.java
public DatasetMap calculateValue() throws Exception { logger.debug("IN"); seriesNames = new Vector(); seriesCaptions = new LinkedHashMap(); categoriesTooltip = new HashMap<String, String>(); seriesTooltip = new HashMap<String, String>(); lineNoShapeSeries1 = new Vector<String>(); lineNoShapeSeries2 = new Vector<String>(); String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject); categories = new HashMap(); //DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DatasetMap datasetMap = new DatasetMap(); SourceBean sbRows = SourceBean.fromXMLString(res); List listAtts = sbRows.getAttributeAsList("ROW"); // run all categories (one for each row) categoriesNumber = 0;/*from w w w.j a v a 2 s . c om*/ // one dataset for mapping left, one for mapping right // datasetMap.getDatasets().put("bar", new DefaultCategoryDataset()); // datasetMap.getDatasets().put("line", new DefaultCategoryDataset()); datasetMap.getDatasets().put("1-bar", new DefaultCategoryDataset()); datasetMap.getDatasets().put("1-line", new DefaultCategoryDataset()); datasetMap.getDatasets().put("2-bar", new DefaultCategoryDataset()); datasetMap.getDatasets().put("2-line", new DefaultCategoryDataset()); boolean first = true; //categories.put(new Integer(0), "All Categories"); for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) { SourceBean category = (SourceBean) iterator.next(); List atts = category.getContainedAttributes(); HashMap series = new LinkedHashMap(); HashMap additionalValues = new LinkedHashMap(); String catValue = ""; String nameP = ""; String value = ""; if (first) { if (name.indexOf("$F{") >= 0) { setTitleParameter(atts); } if (getSubName() != null && getSubName().indexOf("$F") >= 0) { setSubTitleParameter(atts); } first = false; } //run all the attributes, to define series! int numColumn = 0; for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) { numColumn++; SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next(); nameP = new String(object.getKey()); value = new String((String) object.getValue()); if (nameP.equalsIgnoreCase("x")) { catValue = value; categoriesNumber = categoriesNumber + 1; categories.put(new Integer(categoriesNumber), value); } else { if (nameP.startsWith("add_") || nameP.startsWith("ADD_")) { if (additionalLabels) { String ind = nameP.substring(4); additionalValues.put(ind, value); } } // must be after x definition else if (nameP.toUpperCase().startsWith("TIP_X")) { // additional information if (enableToolTips) { categoriesTooltip.put(nameP + "_" + catValue, value); } } else if (nameP.toUpperCase().startsWith("TIP_")) { // additional information if (enableToolTips) { seriesTooltip.put(nameP, value); } } else if (nameP.toUpperCase().startsWith("FREETIP_X")) { // additional information if (enableToolTips) { freeToolTips = true; //help the search later in MyCategoryToolTipGenerator categoriesTooltip.put(nameP + "_" + catValue, value); } } else { if (seriesLabelsMap != null) { String serieLabel = (String) seriesLabelsMap.get(nameP); if (serieLabel == null) { if (!hiddenSeries.contains(nameP)) { logger.error("serie Label not found for serie with name " + nameP + ": this may lead to errors, check if serie's name from dataset is equal to the one specified in template"); logger.warn( "series name in template are wrongly defined, remove series naming, check template"); series.put(nameP, value); seriesLabelsMap = null; } } else { series.put(serieLabel, value); seriesCaptions.put(serieLabel, nameP); int i = 0; } } else { logger.debug("SERIES_LABELS not specified: insert real serie's name"); series.put(nameP, value); } } // for now I make like if addition value is checked he seek for an attribute with name with value+name_serie } } // for each serie for (Iterator iterator3 = series.keySet().iterator(); iterator3.hasNext();) { String nameS = (String) iterator3.next(); String labelS = ""; String valueS = (String) series.get(nameS); Double valueD = null; try { valueD = Double.valueOf(valueS); } catch (Exception e) { logger.warn("error in double conversion, put default to null"); valueD = null; } if (!hiddenSeries.contains(nameS)) { if (seriesLabelsMap != null && (seriesCaptions != null && seriesCaptions.size() > 0)) { nameS = (String) (seriesCaptions.get(nameS)); labelS = (String) seriesLabelsMap.get(nameS); } else labelS = nameS; //Line and second axis // LINE CASE if (!isHiddenSerie(nameS) && seriesDraw.get(nameS) != null && (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line") || ((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes"))) { useLines = true; if (!seriesNames.contains(nameS)) seriesNames.add(nameS); // SET THE AXIS if (seriesScale != null && seriesScale.get(nameS) != null && ((String) seriesScale.get(nameS)).equalsIgnoreCase("2")) { //set the nonShapes if (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes") && !lineNoShapeSeries2.contains(nameS)) { lineNoShapeSeries2.add(nameS); } ((DefaultCategoryDataset) (datasetMap.getDatasets().get("2-line"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } else { if (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes") && !lineNoShapeSeries1.contains(nameS)) { lineNoShapeSeries1.add(nameS); } ((DefaultCategoryDataset) (datasetMap.getDatasets().get("1-line"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } } else if (!isHiddenSerie(nameS)) {// BAR CASE useBars = true; if (!seriesNames.contains(nameS)) seriesNames.add(nameS); // if to draw mapped to first axis if (seriesScale != null && seriesScale.get(nameS) != null && ((String) seriesScale.get(nameS)).equalsIgnoreCase("2")) { if (!seriesNames.contains(nameS)) seriesNames.add(nameS); ((DefaultCategoryDataset) (datasetMap.getDatasets().get("2-bar"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } else { // if to draw as a bar if (!seriesNames.contains(nameS)) seriesNames.add(nameS); ((DefaultCategoryDataset) (datasetMap.getDatasets().get("1-bar"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } } // if there is an additional label are if (additionalValues.get(nameS) != null) { String val = (String) additionalValues.get(nameS); String index = catValue + "-" + nameS; catSerLabels.put(index, val); } } } } if (listAtts.size() == 0) { if (name.indexOf("$F{") >= 0) { setTitleParameter(""); } if (getSubName().indexOf("$F") >= 0) { setSubTitleParameter(""); } } logger.debug("OUT"); return datasetMap; }
From source file:org.sakaiproject.tool.gradebook.test.GradebookServiceNewTest.java
public void testStudentRebuff() throws Exception { setAuthnId(INSTRUCTOR_UID);// ww w. ja va 2 s . c o m // Score the unreleased assignment. gradebookService.setAssignmentScoreString(GRADEBOOK_UID_NO_CAT, ASN_TITLE1, STUDENT_IN_SECTION_UID1, new String("39"), "Service Test"); // Try to get a list of assignments as the student. setAuthnId(STUDENT_IN_SECTION_UID1); try { if (log.isInfoEnabled()) log.info("Ignore the upcoming authorization errors..."); gradebookService.getAssignments(GRADEBOOK_UID_NO_CAT); fail(); } catch (SecurityException e) { } // And then try to get the score. Double score; try { score = new Double(gradebookService.getAssignmentScoreString(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1)); fail(); } catch (SecurityException e) { } // try to get grades for students for item List grades; try { List studentIds = new ArrayList(); studentIds.add(STUDENT_IN_SECTION_UID1); studentIds.add(STUDENT_NOT_IN_SECTION_UID1); grades = gradebookService.getGradesForStudentsForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, studentIds); } catch (SecurityException e) { } // try to get gradeDef for student for item - should return null if not released GradeDefinition gradeDef; gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertTrue(gradeDef.getGrade() == null); // Now release the assignment. setAuthnId(INSTRUCTOR_UID); org.sakaiproject.tool.gradebook.Assignment assignment = gradebookManager.getAssignment(asn1IdNoCat); assignment.setReleased(true); gradebookManager.updateAssignment(assignment); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); // Now see if the student gets lucky. setAuthnId(STUDENT_IN_SECTION_UID1); score = new Double(gradebookService.getAssignmentScoreString(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1)); Assert.assertTrue(score.doubleValue() == 39.0); gradeDef = gradebookService.getGradeDefinitionForStudentForItem(GRADEBOOK_UID_NO_CAT, asn1IdNoCat, STUDENT_IN_SECTION_UID1); Assert.assertTrue(gradeDef.getGrade().equals((new Double(39).toString()))); setAuthnId(STUDENT_IN_SECTION_UID1); Map viewableStudents = gradebookService.getViewableStudentsForItemForCurrentUser(GRADEBOOK_UID_NO_CAT, asn1IdNoCat); assertEquals(0, viewableStudents.size()); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.CombinedCategoryBar.java
public DatasetMap calculateValue() throws Exception { logger.debug("IN"); seriesNames = new Vector(); seriesCaptions = new LinkedHashMap(); String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject); categories = new HashMap(); DatasetMap datasetMap = new DatasetMap(); SourceBean sbRows = SourceBean.fromXMLString(res); List listAtts = sbRows.getAttributeAsList("ROW"); // One row for each category categoriesNumber = 0;// www. j a v a 2s.c om // 4 datasets, 2 for first axis named 1, 2 for second axis named 2 datasetMap.getDatasets().put("1-bar", new DefaultCategoryDataset()); datasetMap.getDatasets().put("1-line", new DefaultCategoryDataset()); datasetMap.getDatasets().put("2-bar", new DefaultCategoryDataset()); datasetMap.getDatasets().put("2-line", new DefaultCategoryDataset()); lineNoShapeSeries1 = new Vector<String>(); lineNoShapeSeries2 = new Vector<String>(); categoriesTooltip = new HashMap<String, String>(); seriesTooltip = new HashMap<String, String>(); seriesOrder = new ArrayList<String>(); boolean first = true; //categories.put(new Integer(0), "All Categories"); for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) { // run all categories (one for each row) SourceBean category = (SourceBean) iterator.next(); List atts = category.getContainedAttributes(); // attributes: x is category name, values as serie_name are others, addition values can be added HashMap series = new LinkedHashMap(); HashMap additionalValues = new LinkedHashMap(); String catValue = ""; String nameP = ""; String value = ""; if (first) { if (name.indexOf("$F{") >= 0) { setTitleParameter(atts); } if (getSubName() != null && getSubName().indexOf("$F") >= 0) { setSubTitleParameter(atts); } first = false; } //run all the attributes, to define series! int numColumn = 0; for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) { numColumn++; SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next(); // In order to have tootltip for category they must be defined after x nameP = new String(object.getKey()); value = new String((String) object.getValue()); if (nameP.equalsIgnoreCase("x")) // category name { catValue = value; categoriesNumber = categoriesNumber + 1; categories.put(new Integer(categoriesNumber), value); } else { if (nameP.toUpperCase().startsWith("ADD_")) { // additional information if (additionalLabels) { String ind = nameP.substring(4); additionalValues.put(ind, value); } } // must be after x definition else if ((nameP.toUpperCase()).startsWith("TIP_X")) { // additional information if (enableToolTips) { categoriesTooltip.put(nameP.toUpperCase() + "_" + catValue, value); } } else if (nameP.toUpperCase().startsWith("TIP_")) { // additional information if (enableToolTips) { seriesTooltip.put(nameP.toUpperCase(), value); } } else if (nameP.toUpperCase().startsWith("FREETIP_X")) { // additional information if (enableToolTips) { freeToolTips = true; //help the search later in MyCategoryToolTipGenerator categoriesTooltip.put(nameP.toUpperCase() + "_" + catValue, value); } } else { if (seriesLabelsMap != null) { // a serie String serieLabel = (String) seriesLabelsMap.get(nameP); series.put(serieLabel, value); if (!seriesOrder.contains(serieLabel)) { seriesOrder.add(serieLabel); } seriesCaptions.put(serieLabel, nameP); } else { series.put(nameP, value); if (!seriesOrder.contains(nameP)) { seriesOrder.add(nameP); } } } // for now I make like if addition value is checked he seek for an attribute with name with value+name_serie } } // for each serie for (Iterator iterator3 = series.keySet().iterator(); iterator3.hasNext();) { String nameS = (String) iterator3.next(); String labelS = ""; String valueS = (String) series.get(nameS); Double valueD = null; try { valueD = Double.valueOf(valueS); } catch (Exception e) { logger.warn("error in double conversion, put default to null"); valueD = null; } if (!hiddenSeries.contains(nameS)) { if (seriesLabelsMap != null && (seriesCaptions != null && seriesCaptions.size() > 0)) { nameS = (String) (seriesCaptions.get(nameS)); labelS = (String) seriesLabelsMap.get(nameS); if (labelS == null) labelS = nameS; } else labelS = nameS; // Fill DATASET: Check if has to be filled dataset 1 or dataset 2, to bar or lines // LINE CASE if (!isHiddenSerie(nameS) && seriesDraw.get(nameS) != null && (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line") || ((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes"))) { if (!seriesNames.contains(nameS)) seriesNames.add(nameS); // SET THE AXIS if (seriesScale != null && seriesScale.get(nameS) != null && ((String) seriesScale.get(nameS)).equalsIgnoreCase("2")) { useLinesRenderers = true; if (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes") && !lineNoShapeSeries2.contains(nameS)) { lineNoShapeSeries2.add(nameS); } ((DefaultCategoryDataset) (datasetMap.getDatasets().get("2-line"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } else { useLinesRenderers = true; if (((String) seriesDraw.get(nameS)).equalsIgnoreCase("line_no_shapes") && !lineNoShapeSeries1.contains(nameS)) { lineNoShapeSeries1.add(nameS); } ((DefaultCategoryDataset) (datasetMap.getDatasets().get("1-line"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } } else if (!isHiddenSerie(nameS)) {// BAR CASE if (!seriesNames.contains(nameS)) seriesNames.add(nameS); // if to draw mapped to first axis if (seriesScale != null && seriesScale.get(nameS) != null && ((String) seriesScale.get(nameS)).equalsIgnoreCase("2")) { if (!seriesNames.contains(nameS)) seriesNames.add(nameS); ((DefaultCategoryDataset) (datasetMap.getDatasets().get("2-bar"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } else { // if to draw as a bar if (!seriesNames.contains(nameS)) seriesNames.add(nameS); ((DefaultCategoryDataset) (datasetMap.getDatasets().get("1-bar"))) .addValue(valueD != null ? valueD.doubleValue() : null, labelS, catValue); } } // if(!isHiddenSerie(nameS)){ // if(!seriesNames.contains(nameS)) // seriesNames.add(nameS); // if(seriesScale != null && seriesScale.get(nameS)!=null && ((String)seriesScale.get(nameS)).equalsIgnoreCase("2")){ // 2 axis // if(!seriesNames.contains(nameS))seriesNames.add(nameS); // ((DefaultCategoryDataset)(datasetMap.getDatasets().get("2"))).addValue(Double.valueOf(valueS).doubleValue(), labelS, catValue); // } // else{ // 1 axis // if(!seriesNames.contains(nameS))seriesNames.add(nameS); // ((DefaultCategoryDataset)(datasetMap.getDatasets().get("1"))).addValue(Double.valueOf(valueS).doubleValue(), labelS, catValue); // } // } // if there is an additional label are if (additionalValues.get(nameS) != null) { String val = (String) additionalValues.get(nameS); String index = catValue + "-" + nameS; catSerLabels.put(index, val); } } } // close series cycle } // Close cycle on SpagoBI Dataset rows if (listAtts.size() == 0) { if (name.indexOf("$F{") >= 0) { setTitleParameter(""); } if (getSubName() != null && getSubName().indexOf("$F") >= 0) { setSubTitleParameter(""); } } logger.debug("OUT"); return datasetMap; }
From source file:org.ramadda.repository.database.DatabaseManager.java
/** * _more_/*from w w w . j a v a2s . c o m*/ * * @param dos _more_ * @param i _more_ * * @throws Exception _more_ */ private void writeDouble(DataOutputStream dos, Double i) throws Exception { if (i == null) { dos.writeDouble(Double.NaN); } else { dos.writeDouble(i.doubleValue()); } }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected void handleCategoryPlotSettings(CategoryPlot p, JRChartPlot jrPlot) { PlotSettings plotSettings = getPlotSettings(); Double themeLabelRotation = plotSettings.getLabelRotation(); // Handle rotation of the category labels. CategoryAxis axis = p.getDomainAxis(); boolean hasRotation = jrPlot.getLabelRotationDouble() != null || themeLabelRotation != null; if (hasRotation) { double labelRotation = jrPlot.getLabelRotationDouble() != null ? jrPlot.getLabelRotationDouble().doubleValue() : themeLabelRotation.doubleValue(); if (labelRotation == 90) { axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); } else if (labelRotation == -90) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } else if (labelRotation < 0) { axis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions((-labelRotation / 180.0) * Math.PI)); } else if (labelRotation > 0) { axis.setCategoryLabelPositions( CategoryLabelPositions.createDownRotationLabelPositions((labelRotation / 180.0) * Math.PI)); }/*from w w w .ja v a 2 s . c o m*/ } PlotOrientation plotOrientation = jrPlot.getOrientation() != null ? jrPlot.getOrientation() : plotSettings.getOrientation(); if (plotOrientation != null) { p.setOrientation(plotOrientation); } CategoryItemRenderer categoryRenderer = p.getRenderer(); Paint[] paintSequence = getPaintSequence(plotSettings, jrPlot); if (paintSequence != null) { for (int i = 0; i < paintSequence.length; i++) { categoryRenderer.setSeriesPaint(i, paintSequence[i]); } } Paint[] outlinePaintSequence = getOutlinePaintSequence(plotSettings); if (outlinePaintSequence != null) { for (int i = 0; i < outlinePaintSequence.length; i++) { categoryRenderer.setSeriesOutlinePaint(i, outlinePaintSequence[i]); } } Stroke[] strokeSequence = getStrokeSequence(plotSettings); if (strokeSequence != null) { for (int i = 0; i < strokeSequence.length; i++) { categoryRenderer.setSeriesStroke(i, strokeSequence[i]); } } Stroke[] outlineStrokeSequence = getOutlineStrokeSequence(plotSettings); if (outlineStrokeSequence != null) { for (int i = 0; i < outlineStrokeSequence.length; i++) { categoryRenderer.setSeriesOutlineStroke(i, outlineStrokeSequence[i]); } } Boolean domainGridlineVisible = plotSettings.getDomainGridlineVisible(); if (domainGridlineVisible == null || domainGridlineVisible.booleanValue()) { PaintProvider domainGridlinePaint = plotSettings.getDomainGridlinePaint(); if (domainGridlinePaint != null) { p.setDomainGridlinePaint(domainGridlinePaint.getPaint()); } Stroke domainGridlineStroke = plotSettings.getDomainGridlineStroke(); if (domainGridlineStroke != null) { p.setDomainGridlineStroke(domainGridlineStroke); } } Boolean rangeGridlineVisible = plotSettings.getRangeGridlineVisible(); if (rangeGridlineVisible == null || rangeGridlineVisible.booleanValue()) { PaintProvider rangeGridlinePaint = plotSettings.getRangeGridlinePaint(); if (rangeGridlinePaint != null) { p.setRangeGridlinePaint(rangeGridlinePaint.getPaint()); } Stroke rangeGridlineStroke = plotSettings.getRangeGridlineStroke(); if (rangeGridlineStroke != null) { p.setRangeGridlineStroke(rangeGridlineStroke); } } }
From source file:org.sakaiproject.tool.gradebook.business.impl.GradebookManagerHibernateImpl.java
/** * Gets the total number of points possible in a gradebook. *///from w w w . j a v a 2 s . c o m @Override public double getTotalPoints(final Long gradebookId) { Double totalPoints = (Double) getHibernateTemplate().execute(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException { Gradebook gradebook = getGradebook(gradebookId); List cates = getCategoriesWithAssignments(gradebookId); return new Double(getLiteralTotalPointsInternal(gradebookId, session, gradebook, cates)); //return new Double(getTotalPointsInternal(gradebookId, session)); } }); return totalPoints.doubleValue(); }
From source file:org.sakaiproject.tool.gradebook.ui.SpreadsheetUploadBean.java
public String saveGrades() { if (logger.isDebugEnabled()) logger.debug("create assignment and save grades"); if (logger.isDebugEnabled()) logger.debug("first check if all variables are numeric"); logger.debug("********************" + scores); LetterGradePercentMapping lgpm = new LetterGradePercentMapping(); if (getGradeEntryByLetter()) { lgpm = getGradebookManager().getLetterGradePercentMapping(getGradebook()); }//from w w w .j av a 2 s .c om Iterator iter = scores.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); if (!entry.getKey().equals("Assignment")) { if (getGradeEntryByPoints() || getGradeEntryByPercent()) { String points = (String) entry.getValue(); try { if (logger.isDebugEnabled()) logger.debug("checking if " + points + " is a numeric value"); double score = convertStringToDouble(points); if (score < 0) { FacesUtil.addErrorMessage(getLocalizedString("import_assignment_negative")); return "spreadsheetPreview"; } } catch (ParseException e) { if (logger.isDebugEnabled()) logger.debug(points + " is not a numeric value"); FacesUtil.addErrorMessage(getLocalizedString("import_assignment_notsupported")); return "spreadsheetPreview"; } } else if (getGradeEntryByLetter()) { if (lgpm.getGradeMap() == null) { FacesUtil.addErrorMessage(getLocalizedString("gb_setup_no_grade_entry_scale")); return "spreadsheetPreview"; } String letterScore = (String) entry.getValue(); if (letterScore != null && letterScore.length() > 0) { String formattedLetterScore = lgpm.standardizeInputGrade(letterScore); if (formattedLetterScore == null) { FacesUtil.addErrorMessage(getLocalizedString("import_assignment_invalid_letter")); return "spreadsheetPreview"; } } } } } try { Category newCategory = retrieveSelectedCategory(); if (newCategory != null) { assignmentId = getGradebookManager().createAssignmentForCategory(getGradebookId(), newCategory.getId(), assignment.getName(), assignment.getPointsPossible(), assignment.getDueDate(), new Boolean(assignment.isNotCounted()), new Boolean(assignment.isReleased()), new Boolean(assignment.isExtraCredit())); } else { assignmentId = getGradebookManager().createAssignment(getGradebookId(), assignment.getName(), assignment.getPointsPossible(), assignment.getDueDate(), new Boolean(assignment.isNotCounted()), new Boolean(assignment.isReleased()), new Boolean(assignment.isExtraCredit())); } FacesUtil.addRedirectSafeMessage( getLocalizedString("add_assignment_save", new String[] { assignment.getName() })); assignment = getGradebookManager().getAssignment(assignmentId); List gradeRecords = new ArrayList(); //initialize comment List List comments = new ArrayList(); //check if a comments column is selected for the defalt select item value is // 0 which mean no comments to be imported if (selectedCommentsColumnId != null && selectedCommentsColumnId > 0) comments = createCommentList(assignment); if (logger.isDebugEnabled()) logger.debug("remove title entry form map"); scores.remove("Assignment"); if (logger.isDebugEnabled()) logger.debug("iterate through scores and and save assignment grades"); Iterator it = scores.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String uid = (String) entry.getKey(); String scoreAsString = (String) entry.getValue(); if (scoreAsString != null && scoreAsString.trim().length() > 0) { if (getGradeEntryByPercent() || getGradeEntryByPoints()) { try { Double scoreAsDouble; scoreAsDouble = convertStringToDouble(scoreAsString); if (scoreAsDouble != null) scoreAsDouble = new Double(FacesUtil.getRoundDown(scoreAsDouble.doubleValue(), 2)); AssignmentGradeRecord asnGradeRecord = new AssignmentGradeRecord(assignment, uid, scoreAsDouble); asnGradeRecord.setPercentEarned(scoreAsDouble); // in case gb entry by % - sorted out in manager gradeRecords.add(asnGradeRecord); if (logger.isDebugEnabled()) logger.debug("added grades for " + uid + " - score " + scoreAsString); } catch (ParseException pe) { // the score should have already been validated at this point, so // there is something wrong logger.error("ParseException encountered while parsing value: " + scoreAsString + " Score was not updated."); } } else if (getGradeEntryByLetter()) { AssignmentGradeRecord asnGradeRecord = new AssignmentGradeRecord(assignment, uid, null); asnGradeRecord.setLetterEarned(lgpm.standardizeInputGrade(scoreAsString)); gradeRecords.add(asnGradeRecord); } } } if (logger.isDebugEnabled()) logger.debug("persist grade records to database"); getGradebookManager().updateAssignmentGradesAndComments(assignment, gradeRecords, comments); getGradebookBean().getEventTrackingService().postEvent("gradebook.importItem", "/gradebook/" + getGradebookId() + "/" + assignment.getName() + "/" + getAuthzLevel()); return "spreadsheetListing"; } catch (ConflictingAssignmentNameException e) { if (logger.isErrorEnabled()) logger.error(e); FacesUtil.addErrorMessage(getLocalizedString("add_assignment_name_conflict_failure")); } return null; }