List of usage examples for java.lang Float equals
public boolean equals(Object obj)
From source file:org.muse.mneme.tool.QuestionScoreDelegate.java
/** * {@inheritDoc}//www . j a va 2s . c o m */ public String format(Context context, Object value) { if (value == null) return null; if (!(value instanceof Question)) return value.toString(); Question question = (Question) value; Submission submission = null; Object o = context.get("submission"); if ((o != null) && (o instanceof Submission)) { submission = (Submission) o; } Assessment assessment = null; if (submission != null) { assessment = submission.getAssessment(); } else { o = context.get("assessment"); if (o instanceof Assessment) { assessment = (Assessment) o; } } if (assessment == null) return value.toString(); // use the {}/{} format if doing feedback, or just {} if not. StringBuffer rv = new StringBuffer(); Boolean review = (Boolean) context.get("review"); if (review == null) review = Boolean.FALSE; Boolean grading = (Boolean) context.get("grading"); if (grading == null) grading = Boolean.FALSE; String selector = "worth-points"; // if we are doing review just now, and if we are needing review and it's set, and if the submission has been graded if ((review || grading) && (submission != null) && (submission.getIsReleased() || grading)) { // find the answer Answer answer = null; for (Answer a : submission.getAnswers()) { if (a.getQuestion().equals(question)) { answer = a; break; } } if (answer != null) { // if we are doing question score feedback if (answer.getShowCorrectReview() || grading) { // the auto-scores for this answered question Float score = null; if (grading) { score = answer.getAutoScore(); } else { score = answer.getTotalScore(); } rv.append(context.getMessages().getString("score") + ": " + formatScore(context, score) + " "); selector = "of-points"; } } } // add the possible points for the question Float score = question.getPoints(); if (score.equals(Float.valueOf(1))) { selector += "-singular"; } Object[] args = new Object[1]; args[0] = formatScore(context, score); rv.append(context.getMessages().getFormattedMessage(selector, args)); return rv.toString(); }
From source file:org.muse.mneme.tool.SubmissionScoreDelegate.java
/** * {@inheritDoc}// w ww. j a va 2 s .co m */ public String format(Context context, Object value) { // submission or assessment if (value == null) return null; Submission submission = null; Assessment assessment = null; if (value instanceof Submission) { submission = (Submission) value; assessment = submission.getAssessment(); } else if (value instanceof Assessment) { assessment = (Assessment) value; } if (assessment == null) return value.toString(); // use the {}/{} format if doing feedback, or just {} if not. StringBuffer rv = new StringBuffer(); Boolean review = (Boolean) context.get("review"); String selector = "worth-points"; // if we are doing review and the submission has been graded if ((review != null) && review && (submission != null) && submission.getIsReleased()) { // the total score rv.append("<img src=\"" + context.get("sakai.return.url") + "/icons/grade.png\" alt=\"" + context.getMessages().getString("grade") + "\" />"); Float score = submission.getTotalScore(); rv.append(context.getMessages().getString("grade") + ": " + formatScore(score) + " "); selector = "of-points"; boolean partial = submission.getHasUnscoredAnswers(); if (partial) { selector += "-partial"; } } // add the total possible points for the assessment Float score = assessment.getParts().getTotalPoints(); if (score.equals(Float.valueOf(1))) { selector += "-singular"; } Object[] args = new Object[1]; args[0] = formatScore(score); rv.append(context.getMessages().getFormattedMessage(selector, args)); return rv.toString(); }
From source file:org.openmrs.module.rwandaprimarycare.db.hibernate.HibernatePrimaryCareDAO.java
/** * Make this very specific for now, can generalize later if needed. Params are all self-explanatory search terms * //from w ww .j av a 2 s. co m * @param givenName * @param familyName * @param age * @param gender * @param mothersName * @param address1 * @return */ public List<Patient> getPatients(String givenName, String familyName, String gender, Float age, int ageRange, String address1, PersonAttributeType healthCenterPat, Location userLocation, boolean restrictByHealthCenter) { //TODO: should this only find patients who have the context's health center? //relationships handled at impl level List<Patient> patients = new ArrayList<Patient>(); Date minBirthdate = null; Date maxBirthdate = null; Criteria crit = sessionFactory.getCurrentSession().createCriteria(Patient.class) .add(Restrictions.eq("voided", false)); //System.out.println("givenName " + givenName + " familyName " + familyName + " gender " + gender // + " age " + age + " address1 " + address1); if (age != null && !age.equals(Float.valueOf(0))) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -Math.round(age)); cal.add(Calendar.YEAR, -ageRange); minBirthdate = cal.getTime(); cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -Math.round(age)); cal.add(Calendar.YEAR, ageRange); maxBirthdate = cal.getTime(); crit.add(Restrictions.between("birthdate", minBirthdate, maxBirthdate)); } //this does strange things: //crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if ((givenName != null && !givenName.equals("")) || (familyName != null && !familyName.equals(""))) { Criteria namesSubquery = crit.createCriteria("names").add(Restrictions.eq("voided", false)); if (givenName != null && !givenName.equals("")) namesSubquery.add( Restrictions.or(Restrictions.like("givenName", givenName, MatchMode.ANYWHERE).ignoreCase(), Restrictions.like("familyName", givenName, MatchMode.ANYWHERE).ignoreCase())); if (familyName != null && !familyName.equals("")) { namesSubquery.add( Restrictions.or(Restrictions.like("givenName", familyName, MatchMode.ANYWHERE).ignoreCase(), Restrictions.like("familyName", familyName, MatchMode.ANYWHERE).ignoreCase())); } } if (gender != null && !gender.equals("")) crit.add(Restrictions.eq("gender", gender)); // if (address1 != null && !address1.equals("")) crit.createCriteria("addresses").add(Restrictions.eq("voided", false)) .add(Restrictions.like("address1", address1, MatchMode.ANYWHERE).ignoreCase()); //relationships -- can we write a straight SQL subquery?? //restrict by registered health center if (restrictByHealthCenter) { if (userLocation != null && healthCenterPat != null) crit.createCriteria("attributes").add(Restrictions.eq("voided", false)) .add(Restrictions.eq("attributeType", healthCenterPat)) .add(Restrictions.or(Restrictions.eq("value", userLocation.getLocationId().toString()), Restrictions.isNull("value"))); } patients = crit.list(); return patients; }