Control the sequence of reports having complex data

Some paginated reports have sets of data that are too complex to be easily reported in a hierarchy. An example is the Work Orders for Preventive Maintenance procedures which have the following structure:

(0) Work Orders (wo)

(1) Work Order Preventive Maintenance Procedures (pmp and wo)

(2) PM Procedure Steps (pmps)

(3) PM ProcedureTrades

(3) PM Procedure Tool Types

(3) PM Procedures Parts

(2) Work Requests

(3) Work Request Craftsperson Assignments

The goal is to report “level 0” of the hierarchy in the View title of the report, for example, “2008000064 - Preventive Maintenance for Monday, December 1, 2008 for PM Schedule 14” . The other three levels of the paginated report are then reported normally.

This technique is useful for other situations where you need to generate portions of reports, and merge them later. Some examples of this are:

  • a chart and the data for the chart
  • a work request and the docx file that holds the manufacturer’s maintenance procedure
  • a lease abstract and then a docx file that contains the full text of the lease

To control the sequence of reports, you write a Java workflow rule that is a long-running job. A typical job, such as the Work Orders example given above, would:

  • Query all work orders that meet the restriction from the datasource.
  • For each work order:
    • Assemble the view title.
    • Run the PM Procedures paginated report .axvw.
    • Restrict the view to just this Work Order.
    • Use the view title.
    • Name the output file uniquely for this restriction (for example, “PM Procedures Report-2008000064”.

Once all Work orders are finished the custom job :

  • Assemble all docx files (that is, PM Procedures Report-2008000064.docx, PM Procedures Report-2008000065.docx, etc.) into a single output file (for example, PM Procedures Report.docx).
  • Returns that (single) file name as the name of the report.

Implementation

The following is an example of using this sequencing in work flow rules when using JAVA.

//builder
PaginatedReportsBuilder builder = new PaginatedReportsBuilder();
List<String> files = new ArrayList<String>();
Context context = ContextStore.get();
//generating first file
com.archibus.ext.report.docx.Report report = new com.archibus.ext.report.docx.Report();
report.setTitle("Title One");
builder.buildDocxFromView(context, report, "ab-test-rmxflxbl-rpt.axvw", null);
files.add(report.getFileFullName());
//generating second file
report = new com.archibus.ext.report.docx.Report();
report.setTitle("Title Two");
builder.buildDocxFromView(context, report, "ab-test-wo-colstyle-rpt.axvw", null);
files.add(report.getFileFullName())
//merging two files into one file
String finalFileFullname = ReportUtility.getReportFilesStorePath(this.context) + "test-appending-two-docx-files.docx";
ReportUtility.appendDocxFiles(files, finalFileFullname);