private String getTemplateTermSetPopulatedWithValues(
     Map<String, String> columnValues, TemplateTermSet termSet)
     throws ValueNotFoundKarmaException, NoValueFoundInNodeException {
   StringBuilder output = new StringBuilder();
   for (TemplateTerm term : termSet.getAllTerms()) {
     // String template term
     if (term instanceof StringTemplateTerm) {
       output.append(term.getTemplateTermValue());
     }
     // Column template term
     else if (term instanceof ColumnTemplateTerm) {
       String hNodeId = term.getTemplateTermValue();
       if (columnValues.containsKey(hNodeId)) {
         Node node = factory.getNode(columnValues.get(hNodeId));
         if (node != null) {
           if (node.getValue().asString() == null || node.getValue().asString().equals("")) {
             throw new NoValueFoundInNodeException();
           }
           output.append(node.getValue().asString());
         }
       } else {
         String columnName = this.factory.getHNode(hNodeId).getColumnName();
         throw new ValueNotFoundKarmaException(
             "Could not retrieve value from column: " + columnName + ".", hNodeId);
       }
     }
   }
   return output.toString();
 }
 /*
  * Special constructor for comparing a variable to 0.
  */
 public TemplateConstraint(TemplateVariable v, InfixReln R) {
   TemplateTerm t = new TemplateTerm(v.getFormulaType());
   t.setParameter(v);
   TemplateTerm z = TemplateTerm.makeZero(v.getFormulaType());
   LHS = t;
   reln = R;
   RHS = z;
 }