merged 1.1 branch into head
[mir.git] / source / mir / producer / EntityListProducerNode.java
index 32e0d3a..e28a3ea 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001-2006 The Mir-coders group
  *
  * This file is part of Mir.
  *
@@ -19,8 +19,6 @@
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
  * the code of this program with  any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
  * and distribute linked combinations including the two.  You must obey the
  * GNU General Public License in all respects for all of the code used other than
  * the above mentioned libraries.  If you modify this file, you may extend this
  */
 package mir.producer;
 
-import java.util.Collections;
-import java.util.Map;
-
 import mir.entity.adapter.EntityAdapterModel;
 import mir.entity.adapter.EntityIteratorAdapter;
-import mir.log.LoggerWrapper;
 import mir.util.CachingRewindableIterator;
 import mir.util.ParameterExpander;
 import mir.util.StringRoutines;
 
+import java.util.Collections;
+
 public class EntityListProducerNode extends ProducerNodeDecorator {
   private String keyExpression;
   private String whereClause;
@@ -67,24 +63,24 @@ public class EntityListProducerNode extends ProducerNodeDecorator {
     skipExpression = aSkipExpression;
   }
 
-  public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure, ProducerExc {
+  public void produce(ProductionContext aProductionContext) throws ProducerFailure, ProducerExc {
     try {
-      int limit = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, limitExpression, -1);
-      int skip = ParameterExpander.evaluateIntegerExpressionWithDefault(aValueMap, skipExpression, 0);
+      int limit = ParameterExpander.evaluateIntegerExpressionWithDefault(aProductionContext.getValueSet(), limitExpression, -1);
+      int skip = ParameterExpander.evaluateIntegerExpressionWithDefault(aProductionContext.getValueSet(), skipExpression, 0);
 
       if (skipExpression != null && !skipExpression.trim().equals(""))
-        skip = ParameterExpander.evaluateIntegerExpression(aValueMap, skipExpression);
-      String key = ParameterExpander.expandExpression(aValueMap, keyExpression);
+        skip = ParameterExpander.evaluateIntegerExpression(aProductionContext.getValueSet(), skipExpression);
+      String key = ParameterExpander.expandExpression(aProductionContext.getValueSet(), keyExpression);
 
       try {
         ParameterExpander.setValueForKey(
-          aValueMap,
+          aProductionContext.getValueSet(),
           key,
           new CachingRewindableIterator(
             new EntityIteratorAdapter( mainTablePrefix,
-              StringRoutines.splitString(ParameterExpander.expandExpression( aValueMap, extraTables).trim(), ","),
-              ParameterExpander.expandExpression( aValueMap, whereClause ),
-              ParameterExpander.expandExpression( aValueMap, orderByClause ),
+              StringRoutines.splitString(ParameterExpander.expandExpression(aProductionContext.getValueSet(), extraTables).trim(), ","),
+              ParameterExpander.expandExpression(aProductionContext.getValueSet(), whereClause ),
+              ParameterExpander.expandExpression(aProductionContext.getValueSet(), orderByClause ),
               Math.min(50, limit),
               model,
               definition,
@@ -94,10 +90,11 @@ public class EntityListProducerNode extends ProducerNodeDecorator {
         );
       }
       catch (Throwable t) {
-        aLogger.error("cannot retrieve list into keyExpression " + key + ": " + t.getMessage());
+        aProductionContext.getLogger().warn("cannot retrieve list into keyExpression " + key, t);
+
         try {
           ParameterExpander.setValueForKey(
-            aValueMap,
+            aProductionContext.getValueSet(),
             key,
             new CachingRewindableIterator(Collections.EMPTY_LIST.iterator())
           );
@@ -107,9 +104,9 @@ public class EntityListProducerNode extends ProducerNodeDecorator {
       }
     }
     catch (Throwable t) {
-      aLogger.error("cannot process entity list producer node: : " + t.getMessage());
+      aProductionContext.getLogger().error("cannot process entity list producer node: : ", t);
     }
 
-    super.produce(aValueMap, aVerb, aLogger);
+    super.produce(aProductionContext);
   }
 }
\ No newline at end of file