At last the EntityBatchingProducerNode is working. This will replace the old
[mir.git] / source / mir / producer / EntityListProducerNode.java
1 package mir.producer;
2
3 import java.util.*;
4 import java.io.*;
5 import mir.entity.adapter.*;
6 import mir.entity.*;
7 import mir.storage.*;
8 import mir.util.*;
9
10 public class EntityListProducerNode extends ProducerNodeDecorator {
11   private String key;
12   private String whereClause;
13   private String orderByClause;
14   private int batchSize;
15   private EntityAdapterDefinition definition;
16   private StorageObject storage;
17   private int limit;
18   private int skip;
19
20   public EntityListProducerNode(String aKey, StorageObject aStorage,
21       EntityAdapterDefinition aDefinition, String aWhereClause, String anOrderByClause,
22       int aLimit, int aSkip, ProducerNode aSubNode) {
23     super(aSubNode);
24
25     storage = aStorage;
26     definition = aDefinition;
27     key = aKey;
28     whereClause = aWhereClause;
29     orderByClause = anOrderByClause;
30     limit = aLimit;
31     skip = aSkip;
32   }
33
34   public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure {
35     try {
36       aValueMap.put(key,
37         new EntityIteratorAdapter(
38           storage,
39           ParameterExpander.expandExpression( aValueMap, whereClause ),
40           ParameterExpander.expandExpression( aValueMap, orderByClause ),
41           20,
42           definition,
43           limit,
44           skip )
45       );
46       super.produce(aValueMap, aVerb, aLogger);
47     }
48     catch (Throwable t) {
49       throw new ProducerFailure(t.getMessage(), t);
50     }
51   };
52
53 }