+ expandedWhereClause = ParameterExpander.expandExpression( aValueMap, whereClause );
+ expandedOrderByClause = ParameterExpander.expandExpression( aValueMap, orderByClause );
+
+ batchesData = new Vector();
+ batchLocations = new Vector();
+
+ nrEntities = storage.getSize(expandedWhereClause)-nrEntitiesToSkip;
+ nrEntitiesInFirstBatch = nrEntities % nrEntitiesPerBatch;
+ while (nrEntitiesInFirstBatch<minNrEntitiesInFirstBatch && nrEntities-nrEntitiesInFirstBatch>=nrEntitiesPerBatch)
+ nrEntitiesInFirstBatch = nrEntitiesInFirstBatch + nrEntitiesPerBatch;
+ nrBatchesAfterFirst = (nrEntities-nrEntitiesInFirstBatch)/nrEntitiesPerBatch;
+
+ batchLocations.add(new BatchLocation(nrBatchesAfterFirst*nrEntitiesPerBatch, nrEntitiesInFirstBatch));
+ batchData = new HashMap();
+ batchData.put("identifier", "");
+ batchData.put("index", Integer.toString(1));
+ batchData.put("size", Integer.toString(nrEntitiesInFirstBatch));
+ batchesData.add(batchData);
+
+ for (i=0; i<nrBatchesAfterFirst; i++) {
+ batchLocations.add(1, new BatchLocation(i*nrEntitiesPerBatch, nrEntitiesPerBatch));
+ batchData = new HashMap();
+ batchData.put("identifier", Integer.toString(i));
+ batchData.put("index", Integer.toString(nrBatchesAfterFirst-i+1));
+ batchData.put("size", Integer.toString(nrEntitiesPerBatch));
+ batchesData.add(1, batchData);
+ }
+
+ batchData = new HashMap();
+ aValueMap.put(batchInfoKey, batchData);
+ batchData.put("all", batchesData);
+ batchData.put("first", batchesData.get(0));
+ batchData.put("last", batchesData.get(batchesData.size()-1));
+
+ if (batchListSubNode!=null) {
+ batchListSubNode.produce(aValueMap, aVerb, aLogger);
+ }
+
+ nrBatchesToProcess = nrBatchesAfterFirst+1;
+ if (verb.nrBatchesToProcess>-1 && verb.nrBatchesToProcess<nrBatchesToProcess) {
+ nrBatchesToProcess=verb.nrBatchesToProcess;
+ }
+
+ if (batchSubNode!=null) {
+ for (i=0; i<nrBatchesToProcess; i++) {
+ location = (BatchLocation) batchLocations.get(i);
+
+ batchData.put("current", batchesData.get(i));
+ if (i>0)
+ batchData.put("previous", batchesData.get(i-1));
+ else
+ batchData.put("previous", null);
+
+ if (i<batchesData.size()-1)
+ batchData.put("next", batchesData.get(i+1));
+ else
+ batchData.put("next", null);
+
+ Iterator j = new EntityIteratorAdapter(storage, expandedWhereClause, expandedOrderByClause,
+ location.nrEntities, definition, location.nrEntities, location.firstEntity);
+ List entities = new Vector();
+
+ while (j.hasNext())
+ entities.add(0, j.next());
+
+ aValueMap.put( batchDataKey, entities );
+
+ batchSubNode.produce(aValueMap, aVerb, aLogger);
+ }