public int getMaximum();
public boolean filter(Object dtls) throws AppException, InformationalException;
Each record is passed to filter before being passed to your operation method. Any record which results in filter returning false is not passed to operation. The default filter always returns true.
public void pre() throws AppException, InformationalException;
If you want to write code that is called with the first row read from the database, you can override:
public void first(Object dtls) throws AppException, InformationalException;
The same record is also passed to the operation method.
public void post() throws AppException, InformationalException;
Be aware, this function is always called once, regardless of the value returned by the operation method.
E.newInstance().readmultiHelper(key, op, true);
This means that each record read from the database is locked for write access as it is read.
You can use a combination of the above methods, with your own data members, to achieve many common styles readmulti operation. For instance, Extra Features of Readmulti Operations shows a readmulti operation that produces a report grouped by department:
static class MyReadmultiOperation
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 {
// initialization
lastDepartment = "";
salaryGrandTotal = 0.0;
}
public void first (Object dtls)
throws AppException, InformationalException {
// per-department group initialization
salaryDeptTotal = 0.0;
// remember last department for grouping.
lastDepartment = dtls.department;
}
public boolean operation(Object dtls)
throws AppException, InformationalException {
// Change of department group
if (!(lastDepartment.equals(dtls.department))) {
printGroupTotals();
// redo per-dept initialization
first(dtls);
}
// detail report line
curam.util.resources.Trace.kTopLevelLogger.info("Emp ");
curam.util.resources.Trace.kTopLevelLogger.info(
dtls.employeeId);
curam.util.resources.Trace.kTopLevelLogger.info(
" salary: ");
curam.util.resources.Trace.kTopLevelLogger.info(
dtls.salary);
// accumulate dept salary
salaryDeptTotal += dtls.salary;
// accumulate total salary
salaryGrandTotal += dtls.salary;
return true;
}
public void post()
throws AppException, InformationalException {
// only if there was at least one department
if (!(lastDepartment.empty())) {
printGroupTotals();
// final group
// Grand total report line:
curam.util.resources.Trace.kTopLevelLogger.info(
"Grand total salary: ");
curam.util.resources.Trace.kTopLevelLogger.info(
salaryGrandTotal);
}
}
public int getMaximum() {
// Explicitly enforce that all matching records are
// considered. Any number other than zero would limit
// the number of records.
return 0;
}
private void printGroupTotals() {
// group report line
curam.util.resources.Trace.kTopLevelLogger.info(
"Department ");
curam.util.resources.Trace.kTopLevelLogger.info(
lastDepartment);
curam.util.resources.Trace.kTopLevelLogger.info(
" total salary: ");
curam.util.resources.Trace.kTopLevelLogger.info(
salaryDeptTotal);
}
}