I've got an MVC application written with Zend Framework that pulls data from an Oracle 10g database and displays this data in Tables and Lists and visually enriches this data through colors and charts. There is no ORM and no Create, Update or Delete involved, just pure Reading. The data is inserted from another application. The data in the DB is modeled after the concepts they represent and accessed by DB Views that aggregate this data from various other tables (legacy, can't change), e.g.
| Event ID | Start | End | Status | Created_By |
-----------------------------------------------------------------------------
| 12345678 | 2009-10-01 12:00:00 | 2009-10-01 12:15:00 | booked | John Doe |
| 12345679 | 2009-11-01 13:00:00 | 2009-12-01 12:00:00 | booked | John Doe |
| 12345680 | 2009-11-01 13:00:00 | 2009-12-01 12:00:00 | tba | Jane Doe |
Users can influence column display, ordering and sorting from the View. Clients can deny/allow access to columns and limit column content to certain values. Users cannot override client settings. A User is an actor, while a client is basically just a filter that creates a subset of available data to a user belonging to the client. User and Client settings are persisted.
My current approach works roughly like this:
Request --> Controller
| <--> sanitizes and returns Request params
| ---> Facade (capsules steps to fetch View Data)
| | <--> Table Data Gateway builds Query for requested View
| | <--> Query Decorator¹ applies User/Client settings
| | <--> DB Adapter fetches RecordSet from decorated Query
| <----returns Recordset
| <--> applies RecordSet to View
| <--> Data-Aware ViewHelper render RecordSet (and View)
Response <--returns rendered View
¹
The Query Decorator can read in the persisted User/Client settings and add it to the basic Query object returned by the TDG on the fly.
However, lately I've been doubting this approach and want to improve it. I guess I could remove the TDGs completely and make View building fully generic from the UI; based on the DB structure alone. The users would certainly like this. The thing is, the View has to know a lot about the data. The ViewHelpers have to know column names in order to enrich the data and often they do so in regards to multiple columns in the Recordsets. They cannot be generic and something tells me this is trouble anyway. It feels like mishmash. I just cannot pinpoint why.
Any patterns, ideas - and opinions - are greatly appreciated. I know the question is somewhat vague, but like I said, I cannot pinpoint what makes me doubt this approach. So I guess I am looking for any good practise approaches to building user and client customizable database centric applications in a maintainable way. I certainly don't need a solution, just some ideas and maybe a few links to see how other people approach this problem, so I can take it into account on the next refactoring.
Note
I'll leave the question open for the full duration before accepting an answer. Any input is appreciated.