Depends a little bit on the background, I would say.

Here are some criteria under which I would stick it into the DAO layer:
1. If you expect that there should never really be missing days and cases of missing days are really cases of "broken data" 2. Every usage scenario you can possibly think of needs all the gaps filled, nobody (no service or use case) wants to know about the gaps 3. You don't mind (or even want) the missing days to be populated back into the DB, so over time the holes will be filled in the database.

If all 3 are true, I would stick it into the DAO layer.

If number 3 is true, as an alternative, I would think about writing a quick script that populates the missing database records once - assuming that the reason for them missing in the first place has been fixed. If for whatever reason you will always have cases in which gaps will reoccur, then a one-time fixing script won't work of course...

Also, if 2. is true for now but you are not completely sure whether it will remain true forever, you could offer 2 methods in your DAO - getExistingDaysInMonth and getAllDaysInMonthWithGapsFilled() (or find some prettier names ;-) ) and then you can decide for each service which of the two you want to use.

On the other hand, if you need to fill the gaps only in one or two special cases (services), then I would rather put it in the service level.

Hope this helps - and hope I'm right ;-)

MARK


Robin Ericsson wrote:
On 4/27/06, Peter Svensson <[EMAIL PROTECTED]> wrote:
Hmm. I'm not sure I follow you here.
Would you like to make a method which reads a Set of pojos from the dao and
then return an array of all days except those in a month, or what?

In a "good" month, the database contains all days, but there might be
months where a few or all days are missing in the database.

What I'm looking for is a good abstract java way of filling those
gaps. Maybe like this (in ugly pseudo code :) :

for( all entries in pojo list ) {
    complete[pojo.date()] = pojo;
}

for( Calendar.days in a month() ) {
    if ( !complete.exists(Calendar.date()) {
        complete[date] = new pojo;
    }
}

But where should this be? In the dao, in the middle layer or in the
page? That is my question. Another idea of code aswell perhaps :)

--
        regards,
        Robin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to