At last the EntityBatchingProducerNode is working. This will replace the old
[mir.git] / source / mir / generator / FreemarkerGenerator.java
index 62e36bf..4329ee0 100755 (executable)
@@ -38,6 +38,8 @@ public class FreemarkerGenerator implements Generator {
            return null;
          if (anObject instanceof TemplateModel)
            return (TemplateModel) anObject;
+//       if (anObject instanceof Date)
+//         return new DateAdapter((Date) anObject);
          else if (anObject instanceof MessageResources)
            return new MessageMethodModel((MessageResources) anObject);
          else if (anObject instanceof String)
@@ -46,6 +48,8 @@ public class FreemarkerGenerator implements Generator {
            return makeMapAdapter((Map) anObject);
          else if (anObject instanceof Iterator)
            return makeIteratorAdapter((Iterator) anObject);
+         else if (anObject instanceof List)
+           return makeIteratorAdapter(((List) anObject).iterator());
          else
            throw new TemplateModelException("Unadaptable class: " + anObject.getClass().getName());
        }
@@ -75,8 +79,10 @@ public class FreemarkerGenerator implements Generator {
            if (!valuesCache.containsKey(aKey)) {
              Object value = map.get(aKey);
 
-             if (value == null)
-               throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
+//    ML: this unfortunately doesn't work, because the entity doesn't seem to store
+//        fields with null values
+//    if (value == null && !map.containsKey(aKey))
+//          throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
 
              valuesCache.put(aKey, makeAdapter(value));
            }
@@ -208,4 +214,21 @@ public class FreemarkerGenerator implements Generator {
       position=0;
     }
        }
+
+/*     private static class DateAdapter implements TemplateHashModel {
+         Date date;
+
+         private DateAdapter(Date aDate) {
+           date = aDate;
+         }
+
+         public boolean isEmpty() {
+           return false;
+         }
+
+         public TemplateModel get(String aKey) throws TemplateModelException {
+           return makeAdapter(new SimpleDateFormat(aKey).format(date));
+         }
+       }
+*/
 }