How to Define Your Own Readmulti Operations

The steps that you follow to define your own specialized readmulti operations are as follows:

  1. Add the readmulti operation to your UML application model. We will assume for this example that you add a standard readmulti operation called readmulti to an entity called E. The standard readmulti operation whose "details" structure will be called EDtls. However, this example applies equally to readmulti, nsreadmulti, nkreadmulti and nsmulti operations in the UML application model, where the "details" structure might not be a generated entity details structure.
  2. Write the specialized readmulti operation class, as follows:
    static class MyReadmultiOperation extends
    curam.util.dataaccess.ReadmultiOperation {
    
      public boolean operation(Object objDtls) throws
        AppException, InformationalException {
    
      // No implementation for the moment
    
      return true;
    
      }
    
    }
    Note: If the readmulti operation specifies a 'Post Data Access' or 'On-fail' operation then your readmulti operation must be a subclass of curam.util.dataaccess.StandardReadMultiOperation. This is because this class builds up an in-memory list of the structs which are read by the readmulti operation in order to make it available to thePost Data Access andOn-fail operations.

    If your readmulti operation processes large numbers of records then this could cause an excessive memory usage overhead; so caution is advised if using specialized readmulti operations in conjunction withPost Data Access orOn-fail operations.

  3. Implement MyReadMultiOperation. operation to perform your specific processing. This method will be called automatically for each record retrieved from the database.

    In general, always return true from readmulti operations. In unusual cases, where you want to stop processing before you hit the end of the record set, return false. This means the operation method will not be called again.

  4. Write the code that will invoke the readmulti operation. This will appear in a BPO implementation and look like this:
    // instance of specialized operation class
    MyReadMultiOperation op = new MyReadMultiOperation();
    
    // instance of readmulti key structure
    EReadmultiKey key;
    
    // set key fields for search
    key.id = 99;
    
    // construct helper and call operation
    E.newInstance().readmultiHelper(key, op);

Each generated readmulti function is associated with a generated "helper" class which exists solely for use in code like that above. The helper class is scoped inside the entity class and has an execute method that begins a readmulti.