X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fproducer%2FEntityBatchingProducerNode.java;h=3e3a294f6605b75ca49846e0467333edff0513e6;hb=6b6b6215ebe066b81f1fa6b0c71a532ca7b4fc3f;hp=abdacc657e8cbb26bb1fba645cb94104eb47bbda;hpb=afcbbd1dee154b4d24a4a77dacc7e07503dd182c;p=mir.git diff --git a/source/mir/producer/EntityBatchingProducerNode.java b/source/mir/producer/EntityBatchingProducerNode.java index abdacc65..3e3a294f 100755 --- a/source/mir/producer/EntityBatchingProducerNode.java +++ b/source/mir/producer/EntityBatchingProducerNode.java @@ -29,31 +29,17 @@ */ package mir.producer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import mir.entity.adapter.EntityAdapterModel; import mir.entity.adapter.EntityIteratorAdapter; -import mir.log.LoggerWrapper; import mir.util.ParameterExpander; import mir.util.StringRoutines; +import java.util.*; + /** - *

Title: EntityBatchingProducerNode

- *

Description: - * This producer makes it possible to show articles in batches, like on archive - * pages. - * - * The order by clause should lead to a result set in reverse order: - * the first row will be the last entity in the last batch - *

- *

Copyright: Copyright (c) 2003

- *

Company:

- * @author not attributable - * @version 1.0 + * This producer makes it possible to show articles in batches, like on archive pages. + * The order by clause should lead to a result set in reverse order: + * the first row will be the last entity in the last batch */ public class EntityBatchingProducerNode implements ProducerNode { @@ -112,7 +98,7 @@ public class EntityBatchingProducerNode implements ProducerNode { ((NodedProducer) producerValue).getIsAborted()); } - public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { + public void produce(ProductionContext aProducerContext) throws ProducerExc, ProducerFailure { int nrEntities; int nrBatchesAfterFirst; int nrEntitiesInFirstBatch; @@ -131,15 +117,15 @@ public class EntityBatchingProducerNode implements ProducerNode { int minNrEntitiesInFirstBatch; try { - nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, nrBatchesToProcessExpression, -1 ); + nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault(aProducerContext.getValueSet(), nrBatchesToProcessExpression, -1); - expandedWhereClause = ParameterExpander.expandExpression( aValueMap, whereClause ); - expandedOrderByClause = ParameterExpander.expandExpression( aValueMap, orderByClause ); + expandedWhereClause = ParameterExpander.expandExpression( aProducerContext.getValueSet(), whereClause ); + expandedOrderByClause = ParameterExpander.expandExpression( aProducerContext.getValueSet(), orderByClause ); - nrEntitiesToSkip = ParameterExpander.evaluateIntegerExpression( aValueMap, nrEntitiesToSkipExpression); - nrEntitiesPerBatch = ParameterExpander.evaluateIntegerExpression( aValueMap, nrEntitiesPerBatchExpression); - minNrEntitiesInFirstBatch = ParameterExpander.evaluateIntegerExpression( aValueMap, minNrEntitiesInFirstBatchExpression); - List extraTableList = StringRoutines.splitString(ParameterExpander.expandExpression( aValueMap, extraTables).trim(), ","); + nrEntitiesToSkip = ParameterExpander.evaluateIntegerExpression( aProducerContext.getValueSet(), nrEntitiesToSkipExpression); + nrEntitiesPerBatch = ParameterExpander.evaluateIntegerExpression( aProducerContext.getValueSet(), nrEntitiesPerBatchExpression); + minNrEntitiesInFirstBatch = ParameterExpander.evaluateIntegerExpression( aProducerContext.getValueSet(), minNrEntitiesInFirstBatchExpression); + List extraTableList = StringRoutines.splitString(ParameterExpander.expandExpression( aProducerContext.getValueSet(), extraTables).trim(), ","); batchesData = new ArrayList(); batchLocations = new ArrayList(); @@ -168,14 +154,14 @@ public class EntityBatchingProducerNode implements ProducerNode { } batchData = new HashMap(); - ParameterExpander.setValueForKey(aValueMap, batchInfoKey, batchData); + ParameterExpander.setValueForKey(aProducerContext.getValueSet(), batchInfoKey, batchData); batchData.put("all", batchesData); batchData.put("first", batchesData.get(0)); batchData.put("last", batchesData.get(batchesData.size()-1)); batchData.put("count", new Integer(batchesData.size())); - if (batchListSubNode!=null && (!isAborted(aValueMap))) { - batchListSubNode.produce(aValueMap, aVerb, aLogger); + if (batchListSubNode!=null && (!isAborted(aProducerContext.getValueSet()))) { + batchListSubNode.produce(aProducerContext); } if (nrBatchesToProcess<0 || nrBatchesToProcess>nrBatchesAfterFirst+1) { @@ -183,7 +169,7 @@ public class EntityBatchingProducerNode implements ProducerNode { } if (batchSubNode!=null) { - for (i=0; i