IBM Cúram – Extra Features of Readmulti Operations


Introduction


There are extra features associated with the readmulti operation in IBM Cúram. The developer can add their filter method on the top of the results returned by a readmulti operation. There are a predefined process which we have to follow to implement it, Please find it in below-given sections.
The developer can use this feature to group records based on some extra business logic or attribute which are not being stored in the same entity. The developer don’t want to write a separate logic to handle it.


Implementation


The implementation of this feature is very simple and straight forward.
There are some predefined steps, please find the description below –

The developer has to write the Java class which will pass an argument in the readmulti operation. The class must extend curam.util.dataaccess.ReadmultiOperation class to implement the feature.


// Class to use as ReadmultiOperation
static class MyKWReadmultiOperation
       extends curam.util.dataaccess.ReadmultiOperation
{
  // Remember last dept, for grouping
  private String lastDepartment;

  // Department salary accumulator
  private curam.util.type.Money salaryDeptTotal;

  // Total Salary Accumulator
  private curam.util.type.Money salaryGrandTotal;

  public void pre()
    throws AppException, InformationalException {
    
  }

  public void first (Object dtls)
  throws AppException, InformationalException {
    
  }

  public boolean operation(Object dtls)
    throws AppException, InformationalException {

    

    return true;
  }

 public void post()
    throws AppException, InformationalException {
    
  }

  public int getMaximum() {
    
    return 0;
  }

  private void printGroupTotals() {
    
  }
}

The order in which read multi operation are called are given below –

Operation Description
pre This operation always called once before anything else.
first This operation called once with the first record provided at least one record exists.
filter This operation called for each record including first.
operation This operation called for each record for which filter return true.
post This operation always called one after everything else.
getMaximum This operation specifies the maximum number of records that should be matched.


Code use


MyKWReadmultiOperation myKWReadmultiOperation = new MyKWReadmultiOperation();

ReturnObject returnObject = readMulti(key,myKWReadmultiOperation);

Leave a Reply

Your email address will not be published. Required fields are marked *