Reporting business logic
Here is an interesting problem. I didn't give it any though whatsoever yet, I am just presenting the problem.
A bit about the model:
This is a temporal model, meaning that objects change over time. Validity is a date range object, which define in what range the object is valid. AppointmentSpec is very similar to an outlook recurring meeting. The actual infromation about the meeting is in the AppointmentSpecSnapshot. The scheduling of the appointment is in the ScheduleSpecSnapshot. As you can imagine, both of those can change independently. Appointment is a meeting that took place, and it is always assoicated with an AppointmentSpec.
My task is to generate a report about all the meetings that differ from their AppointmentSpec. Finding out what is the expected start/end hours for an appointment involves quite a bit of business logic. It is basically spanning the spec on a calendar, taking into account all sorts of interesting cases (holidays, vacations, etc).
Usually reports are done from data in the database, often assembled together in creative ways, but there is no way to do that, because the information simply do not exists there.
Just to give an idea about the complexity, on January 10 - 25, the appointment took place on Wendsday every other week 10:00 - 11:00 AM, from Febuary 26 - March 18, the appointment took place every week, Monday 09:00 - 09:30 AM. Note that there is nothing from the Jan 25 to Deb 26.
An appointment should be reported if it has different start/end hours, if it occurs when the AppointmentSpec says it should occur, etc.
Any thoughts?
Comments
first idea after reading: you can track with a sort of flag (or state) if the appointment differ from the spec in the moment of creation or in the moment of change, so your search is limited only to the appointment with the flag raised.
i mean you could be proactive and not reactive, but I don't know if this will involve an overload of "validation"
Roberto
@Roberto,
The AppointmentSpec can change, this means that I can create a perfectly valid appointment, and then change the AppointmentSpec so it is no longer valid.
Spanning the AppointmentSpec is costly in terms of CPU, so I would like to avoid that if possible. Trying to pre-validate would mean that quite a few scenarios would need to do this validation.
In the past have produced this type of report using analytical functions in Oracle. SQL Server 2005 also supports these but they are not as extensive (don't know whether they can support what you would need here). I know that you said that the data does not exist in the database but there's no reason why you can't put it there to report on.
The specs information is in the database.
The problem that I have with it is that there is significant business logic in spanning a spec to a calendar. It is extremely non trivial, and I would really hate to try doing it in the database.
What about using the .NET 2.0 ReportViewer control? It allows to use classes as data sources which sounds like what you need.
Comment preview