public String getQuestion(Map<String, String> input) { // If there is not velocity template associated with this question if (this.velocityTemplate == null) { // Return the explicitly set qeustion XML return this.question; } try { VelocityContext context = new VelocityContext(); // Add some generic helpers just in case context.put("formatter", new VelocityFormatter(context)); context.put("helper", new HITQuestionHelper()); context.put("today", new Date()); if (input != null && input.values() != null) { Iterator iter = input.keySet().iterator(); while (iter.hasNext()) { String key = (String)iter.next(); // Make a RAW version that's untouched context.put(key + RAW_KEY_SUFFIX, input.get(key)); // Make the default version a QAP-cleaned version if (input.get(key) != null && input.get(key) instanceof String) context.put(key, cleanString((String)input.get(key))); else context.put(key, input.get(key)); } } StringWriter writer = new StringWriter(); this.velocityTemplate.merge(context, writer); this.question = writer.toString(); return question; } catch (Exception e) { log.error("Could not read Question", e); return null; } }
@Override public String getQuestion(Map<String, String> input) { // If there is not velocity template associated with this question if (this.velocityTemplate == null) { // Return the explicitly set qeustion XML return this.question; } try { VelocityContext context = new VelocityContext(); // Add some generic helpers just in case context.put("formatter", new VelocityFormatter(context)); context.put("helper", new HITQuestionHelper()); context.put("today", new Date()); if (input != null && input.values() != null) { Iterator iter = input.keySet().iterator(); while (iter.hasNext()) { String key = (String)iter.next(); // Make a RAW version that's untouched context.put(key + RAW_KEY_SUFFIX, input.get(key)); // Make the default version a QAP-cleaned version if (input.get(key) != null && input.get(key) instanceof String) // SMA: changed cleanString context.put(key, cleanString((String)input.get(key))); else context.put(key, input.get(key)); } } StringWriter writer = new StringWriter(); this.velocityTemplate.merge(context, writer); this.question = writer.toString(); return question; } catch (Exception e) { log.error("Could not read Question", e); return null; } }