Most of the batch operations do some kind of iteration through something, through a query most of the times. Platform codes have a standard iterative batch operation that supports iteration through a queue. In case of iterating through query results, queue holds query result objects to iterate on. Iterative batches are easier to implement because most of the standard, repetitive codes are handled by the platform codes. Iterative batch operations's codes only contain operation specific parts of the batch operation. Suspend-resume, terminate, rollback and recover definitions are easier to implement.

There are two kinds of iterative batch operations:

  • generic iterative operations and 
  • query iterative operations. 

Query iterative operations are easier to define and are the most commonly used type of batch operations. Query iterative operations execute a query, and do something for each of the query result rows. Executing the query and looping through records, and executing the same query over and over until all records are processed is the common behaviour of these batches. This common behaviour is done by the platform codes, batch operation handler only implements a method to process each record returned by the query.

Generic Iterative Batch Operations 

Generic iterative operations are more difficult to implement, and should prepare a queue to iterate on. Generic iterative operations are designed to be used in cases where iteration is not done through a query but through something else (business objects, files... etc). To define generic iterative operation, select "Add Iterative Batch" from pop-up menu. Editor form of this kind of batch is as follows:

















In this editor, there are some additional fields; for other fields, refer to ordinary batch operations part. Check boxes (Suspendable, Terminatable...etc) specify whether this batch operation supports that operation. Unlike ordinary batches, most of these functionalities require no extra code from batch operation handler class. Most of the functionalities are handled by platform codes. 

Bottom part of the editor defines batch classes. Iterative batches use three classes: one for the handler and two for the parameters. Handler class is a class extending Iterative Batch Handler and is the main class that implements the batch operation. Parameters classes are used in batch execution to encapsulate batch data. There are two parameter classes: Batch Params and Batch Runtime Data. Batch Params class stores the parameters necessary to run the batch. This class contains the parameters that are sent from client to the batch operation, and defines the user's selection of the batch parameters such as filters to apply to the batch query. Batch Runtime Data class is used during runtime to store runtime data of the batch such as how many records are processed, cached objects for easier execution... etc. Batch Runtime Data class is used as both suspension and recovery data. So, if your batch operation is either suspendable or recoverable you should put everything needed for suspension or recovery in this class. You can let LPT generate these classes for you, or you can select existing classes from your project. If you let LPT generate these classes, generated classes will contain everything you need to implement with explanatory comments such as:


1
2
3
4
5
6
7
public Serializable getReturnData()
{
      // TODO returnthe data to be collected after splitted batch is completed
      // this method is meaningful only in case of split, in child batch operations
      // for instance, return record count processed for each child operation
      return null;
}


Query Iterative Batch Operations

To define query iterative batch operations select "Add Query Iterative Batch"  from pop-up menu. Editor form of this kind of batch is as follows:



















In this editor, there are some additional fields; for other fields, refer to iterative batch operations part. Query Name specifies the query to use for iteration. You should select an existing query (either custom query or existing query). Query Row Count specifies how many records to query per query execution. You can specify a maximum of 100 records to query at once. You should not specify a very small value either, because that would cause execution of the query over and over again too many times if the overall record count is high.

For the bottom part, class definitions is the same as the iterative batch definitions, with one exception. In query iterative batches, batch handler class should extend QueryIterativeBatchHandler class. You can also let LPT generate your classes, or select existing classes here.

Telif HakkıKullanım KoşullarıGizlilik
Copyright © 2018 Logo Yazılım