X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fproducer%2FEntityBatchingProducerNode.java;h=22cae784f63bedcf722c62489ebf9aa68ae14a0c;hb=5379fccb255fc05ef109129b93b576663819c7df;hp=fd8e8ba9a4131a8d0e91d40c79fa7e95b29652f8;hpb=8563841098b6ab3e6233f61519e58b41dcc30266;p=mir.git diff --git a/source/mir/producer/EntityBatchingProducerNode.java b/source/mir/producer/EntityBatchingProducerNode.java index fd8e8ba9..22cae784 100755 --- a/source/mir/producer/EntityBatchingProducerNode.java +++ b/source/mir/producer/EntityBatchingProducerNode.java @@ -31,16 +31,18 @@ package mir.producer; -import java.util.*; -import java.io.*; -import mir.entity.adapter.*; -import mir.entity.*; -import mir.storage.*; -import mir.util.*; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; -public class EntityBatchingProducerNode implements ProducerNode { - private Map verbs; +import mir.entity.adapter.EntityAdapterModel; +import mir.entity.adapter.EntityIteratorAdapter; +import mir.log.LoggerWrapper; +import mir.util.ParameterExpander; +public class EntityBatchingProducerNode implements ProducerNode { private String batchInfoKey; private String batchDataKey; private EntityAdapterModel model; @@ -50,7 +52,7 @@ public class EntityBatchingProducerNode implements ProducerNode { private String nrEntitiesToSkipExpression; private String nrEntitiesPerBatchExpression; private String minNrEntitiesInFirstBatchExpression; - private String defaultNrBatchesToProcessExpression; + private String nrBatchesToProcessExpression; private ProducerNode batchSubNode; private ProducerNode batchListSubNode; @@ -61,57 +63,16 @@ public class EntityBatchingProducerNode implements ProducerNode { String aDefinition, String aWhereClause, String anOrderByClause, - int anrEntitiesPerBatchExpression, - int aminNrEntitiesInFirstBatchExpression, - int anrEntitiesToSkipExpression, - ProducerNode aBatchSubNode) { - this(aBatchDataKey, aBatchInfoKey, aModel, aDefinition, aWhereClause, - anOrderByClause, anrEntitiesPerBatchExpression, aminNrEntitiesInFirstBatchExpression, anrEntitiesToSkipExpression, - aBatchSubNode, null); - } - - public EntityBatchingProducerNode( - String aBatchDataKey, - String aBatchInfoKey, - EntityAdapterModel aModel, - String aDefinition, - String aWhereClause, - String anOrderByClause, - int aNrEntitiesPerBatch, - int aMinNrEntitiesInFirstBatch, - int aNrEntitiesToSkip, - ProducerNode aBatchSubNode, - ProducerNode aBatchListSubNode) { - - this(aBatchDataKey, aBatchInfoKey, aModel, aDefinition, - aWhereClause, anOrderByClause, - Integer.toString(aNrEntitiesPerBatch), - Integer.toString(aMinNrEntitiesInFirstBatch), - Integer.toString(aNrEntitiesToSkip), - "1", - aBatchSubNode, aBatchListSubNode); - - } - - public EntityBatchingProducerNode( - String aBatchDataKey, - String aBatchInfoKey, - EntityAdapterModel aModel, - String aDefinition, - String aWhereClause, - String anOrderByClause, String anrEntitiesPerBatchExpression, String aminNrEntitiesInFirstBatchExpression, String anrEntitiesToSkipExpression, - String aDefaultNrBatchesToProcessExpression, + String aNrBatchesToProcessExpression, ProducerNode aBatchSubNode, ProducerNode aBatchListSubNode) { batchSubNode = aBatchSubNode; batchListSubNode = aBatchListSubNode; - verbs = new HashMap(); - batchDataKey = aBatchDataKey; batchInfoKey = aBatchInfoKey; model = aModel; @@ -121,10 +82,17 @@ public class EntityBatchingProducerNode implements ProducerNode { nrEntitiesToSkipExpression = anrEntitiesToSkipExpression; nrEntitiesPerBatchExpression = anrEntitiesPerBatchExpression; minNrEntitiesInFirstBatchExpression = aminNrEntitiesInFirstBatchExpression; - defaultNrBatchesToProcessExpression = aDefaultNrBatchesToProcessExpression; + nrBatchesToProcessExpression = aNrBatchesToProcessExpression; + } + + protected boolean isAborted(Map aValueMap) { + Object producerValue = aValueMap.get(NodedProducer.PRODUCER_KEY); + return ( + (producerValue instanceof NodedProducer) && + ((NodedProducer) producerValue).getIsAborted()); } - public void produce(Map aValueMap, String aVerb, PrintWriter aLogger) throws ProducerFailure { + public void produce(Map aValueMap, String aVerb, LoggerWrapper aLogger) throws ProducerFailure { Iterator browser; int nrEntities; int nrBatchesAfterFirst; @@ -136,7 +104,6 @@ public class EntityBatchingProducerNode implements ProducerNode { Map batchData; String expandedWhereClause; String expandedOrderByClause; - EntityBatchingProducerNodeVerb verb = (EntityBatchingProducerNodeVerb) verbs.get(aVerb); List batchLocations; BatchLocation location; @@ -150,12 +117,7 @@ public class EntityBatchingProducerNode implements ProducerNode { try { - if (verb==null) { - nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, defaultNrBatchesToProcessExpression, -1 ); - } - else { - nrBatchesToProcess=verb.nrBatchesToProcess; - } + nrBatchesToProcess = ParameterExpander.evaluateIntegerExpressionWithDefault( aValueMap, nrBatchesToProcessExpression, -1 ); expandedWhereClause = ParameterExpander.expandExpression( aValueMap, whereClause ); expandedOrderByClause = ParameterExpander.expandExpression( aValueMap, orderByClause ); @@ -196,7 +158,7 @@ public class EntityBatchingProducerNode implements ProducerNode { batchData.put("last", batchesData.get(batchesData.size()-1)); batchData.put("count", new Integer(batchesData.size())); - if (batchListSubNode!=null) { + if (batchListSubNode!=null && (!isAborted(aValueMap))) { batchListSubNode.produce(aValueMap, aVerb, aLogger); } @@ -205,7 +167,7 @@ public class EntityBatchingProducerNode implements ProducerNode { } if (batchSubNode!=null) { - for (i=0; i