Friday, October 12, 2007

Java: Hotline Update #3

This time the changes were drastic to the Hotline call tracking program, and so therefore had to be implemented at the beginning of this month rather than mid-month like last time. There were two requested changes; add two more call option buttons and allow the reports to be run over a day's period rather than only by month. The first change was very simple, as that has been done before, the reporting change however was far more complex.

Daily reports is something I considered when originally building Hotline, and even asked those that would run reports if it was a feature they would need. Of course the answer was no, not necessary. Really shouldn't have listened and built the option in anyway.

In order to make this change several things had to be altered. First was creating the new JComboBox for selecting the day range, which was basically a carbon copy of the current code with only minor name changing tweaks. Second was to create the file structure where the report files could be stored on a daily basis rather than monthly. This basically entailed creating 31 folders numbered appropriately 1 - 31. Inside each would be that day's files.

Now that the simple pieces were covered, on to the difficult section. The challenge was implementing this change while still retaining the ability to run reports off of the previous date on a monthly basis. Since the location of these files were different the file location variable (fileLocation) was created and replaced the current static code ("data\\" + year + "\\" + month). Depending on the date of the files requested this variable may have appended on the end the day variable ("\\" + day). For saving the needed files correctly this was the only necessary change, taking the variable fileLocation creation outside of the normal If/Then statement.

if ((year == 2007) && (month <>
fileLocation = "data\\" + year + "\\" + month;
else
fileLocation = "data\\" + year + "\\" + month + "\\" + day;

Now that the files saved correctly, it was time to make sure reports could be run off of them. What had to happen was separating out the report creation instances from those that run monthly to those that would run daily. Before all reporting was dealt with inside of the same If/Then nested statements, now they are worked on separately with a return call at the end of each statement. This way the calls to run reports on monthly dates could be done first and the IF statements for the daily report runs could be simplified. For example:

if (targetFile.equals(TECH) && Integer.parseInt(targetYear) == 2007 && Integer.parseInt
(targetMonth) <>

for the monthly report on technical only calls. The clarifying If/Then statement for the daily reports could then be written simply as:

if (targetFile.equals(TECH))

Then it was only a matter of adding a For loop that would tally all of the reports for the covered date range one at a time and input their information into an array.


Before this update when a file was not present, such as when a representative was out of the office, the report would provide an error message informing the user of this fact.

For a report run over a months time this message appeared maybe once in four months. But now that the report can be run over a shorter date range this message could appear quite often. As a result any such messages stating a file is missing were removed, the only messages retained were those that pointed out errors that would not allow the report to run, such as no month was selected.

There has been some talk of removing some of the buttons, which hasn't been done yet. I can see this requiring me to permanently assign certain variables to buttons to avoid reusing any variables and therefore avoiding combining data for the two buttons into a single report. I don't see that being difficult, it would just require a little effort to keep track of which variables belong to which call type. Something to deal with when we cross that bridge, not beforehand.

No comments: