Birt Reports (generated in .xls format) after 1st download attempt are not populating latest records

Jyoti_7762
edited February 11, 2022 in Analytics #1

Hi,

We're facing a peculiar issue while generating Birt reports (in .xls format) in the shared drive location in the Cordys production server.

The Birt report gets triggered (via 'Generate Birt Report' click button present in the front-end UI in one of the Cordys application xforms) and generated in the shared drive location in the production server by means of a method 'GenerateBirtReport' that takes in 3 input parameters (String reportName, String paramName, String paramVal). Here, this method does the following tasks:

  1. picks up the rptdesign files (by report name) from the shared drive location in the server as...cordys installation directory\BirtRepository\"\deferralReports\"+reportName;
  2. Appends data sources (the data records) from the database to the report template
  3. Generate output file in .xls format

Following is the code for the above 3 tasks performed by the method:

String getRptReq = ""
+ " "+rptDesignPath+""
+ " XLS"
+ " false"
+ " true"
+ reportParams
+ "";

Following is the code for fetching the report from the file path location (via 'Generate Birt Report' click button in the front end UI) that triggers the report after a waiting time of 600000 ms i.e.10 mins:

            int getReq = BSF.getXMLDocument().parseString(getRptReq);
        getreportBirt.addParameterAsXml(getReq);            
        getreportBirt.setUser(DTUtility.getAdminUser());
            birtResponse = getreportBirt.sendAndWait(600000);
        String filePathOriginal = Node.getData(XPath.getFirstMatch(".//PhysicalLink", null, birtResponse));

Finally, following is the code for deriving current datetime, reading (matching) the Birt file name with the report name of the rptdesign file present in the input path location and finally generating (writing) the Birt report file in the specified output location in the shared drive in the Cordys production server:

SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMMddHHmmss");
Calendar cal = Calendar.getInstance();
String NewFileName = "";

        if("SampleBirtFile.rptdesign".equalsIgnoreCase(reportName))
        {
            NewFileName = "SampleBirtFile"+sdf.format(cal.getTime())+".xls";
        }

FileInputStream oFileToRead = new FileInputStream(filePathOriginal);
byte b[] = new byte[oFileToRead.available()];
while(oFileToRead.read(b) != -1){}
FileOutputStream oFileToWrite = new FileOutputStream(sharedFolder+"\"+"webroot\shared\birt\reports\reportFiles\"+NewFileName);
oFileToWrite.write(b);
oFileToWrite.close();
oFileToRead.close();

        File oFile = new File(filePathOriginal);

        if(oFile.exists())
        {
            oFile.delete();
        }                       
        return CommonUtilities.maskSharedFolder(sharedFolder+"\\"+"webroot\\shared\\birt\\reports\\reportFiles\\"+NewFileName);
    }
    catch(Exception e)
    {
        return e.getMessage();
    }       
    finally{
        if(Node.isValidNode(birtResponse)){
            Node.delete(birtResponse);
        }

The code seems fine.
But when we're trying to generate the Birt report file say, during the 1st attempt for a particular date, the excel file contains all the latest records till that current date. And on successive (2nd, 3rd, 4th,...) download attempts during the same day, the generated excel files don't show all the records till the latest date. Also, the size of the excel file generated during the 1st attempt has been observed to be larger than those generated during the 2nd, 3rd, 4th,...attempts (owing to less and incongruous records).

For eg., for March 2, 2019, we triggered the Birt reports twice during the day @12:19 pm and 13:33pm respectively. Upon observation, the first file i.e. SampleBirtFile_2019Mar02121926 generated @12:19 pm during the 1st attempt contained all the latest records till March 2 2019. However, the second file i.e. SampleBirtFile_2019Mar02133339 triggered @13:33 pm didn't contain all the records and on top of that, showed records till March 1 2019 only.

The issue, as observed, is persisting for a long time an we'd seriously appreciate any inputs/suggestions/action points on this matter for resolution.

Thanks for being patient..!!

Enclosures:

  1. rptdesign file version
  2. SampleBirtReport(xls) files anomalies in records based on latest dates (on March 2 2019)