[concern-users] CaseFolder
Brought to you by:
hengels,
leonchiver
|
From: Andy D. <an...@ma...> - 2005-04-29 16:23:50
|
As I look into using con:cern with our product, I'm tempted to employ an idea
and thought I'd bounce it off others to see if it makes sense. A "case" can
sometimes have state that you really don't want to infect your object model
(subject) with. For example, say you have a JournalEntry class in your
object model (and, of course, use Hibernate for ORM :) A user submits a
JournalEntry, which then must be approved by an accountant and a manager.
The JournalEntry enters into a process as the subject of the case. If the
JournalEntry is NOT approved, then the accountant/manager rejecting the entry
can send it back to the user for correction, along with a note. OK, so I
might be willing to let the approval and other flags be in my actual
JournalEntry (isApproved(), etc). But I really don't want the correction
note sent from the accountant/manager to the user to be in the JournalEntry.
So, I'm thinking of creating a "CaseFolder" class that looks something like
this (as an example):
interface CaseFolder
{
Object getSubject();
Object getAnnotation(String key);
void setAnnotation(String key, Object value);
}
Basically, this wraps the actual subject and allows "annotations" to be
inserted into the folder along with the subject of the case. An annotation
is just a generic property, really, and is used to pass around information
related to the case/subject that is not a part of the actual case/subject
(such as the rejection note). The process model would then be built around
the CaseFolder instead of the JournalEntry directly. My "Approved" condition
in the process model would go from:
public boolean eval(JournalEntry subject)
{
return subject.isApproved();
}
to:
public boolean eval(CaseFolder subject)
{
return ((JournalEntry)subject.getSubject()).isApproved();
}
Or, if I decide that I don't want the approve flag stored in my object model:
public boolean eval(CaseFolder subject)
{
return subject.getAnnotation(KEY_APPROVED) == Boolean.TRUE;
}
The client could access the rejection note like this:
String rejectionNote = (String)caseFolder.getAnnotation(KEY_REJECTION_NOTE);
My "Loader" implementation would return instances of this CaseFolder stuffed
with the JournalEntry instead of the JournalEntry directly and would also
handle persisting the annotations along with any changes to the JournalEntry.
Does con:cern already address this issue? Is this a bad idea?
Thanks,
Andy
|