AbstractComposerAttribute.getConfiguredStatement [message #525377] |
Tue, 06 April 2010 12:22 |
|
Hi dev team!
I'm looking at a search form for "persons" that can be either active or inactive. The search form itself has an Active field with three states: Yes, No, All. The SQL code is created using execAddSearchTerms.
@Override
public void execAddSearchTerms(SearchFilter search){
if(getValue()==null){
search.addWhereToken("P.ACTIVE IN(0,1)");
}
else if(getValue()==0){
search.addWhereToken("P.ACTIVE=0");
}
else if(getValue()==1){
search.addWhereToken("P.ACTIVE=1 AND C.ACTIVE IN (-1,1)");
}
search.addDisplayText(getPersonStateBox().getLabel()
+"="+getSelectedButton().getLabel().replace("&", ""));
}
That's cool and works.
At the same time, I have an advanced search tab using an AbstractPersonComposerField that inherits from AbstractComposerField. There, I have an attribute called Active using the Boolean code type. The SQL Statement is generated a bit differently, unfortunately:
@Override
public String getConfiguredStatement(){
return "(<attribute>P.ACTIVE</attribute> "+
"AND <attribute>C.ACTIVE</attribute>) ";
}
And preliminary testing shows that showing the active or inactive persons shows a different result set depending on whether the standard Active attribute or the advanced search constraint is used.
My question is this: What's the exact effect of the attribute tag in an AbstractComposerAttribute.getConfiguredStatement?
What I need to do, I think, is to rewrite one of the two pieces to result in the same SQL as the the other piece such that there is no result set difference no matter what code is being used.
|
|
|
Re: AbstractComposerAttribute.getConfiguredStatement [message #525382 is a reply to message #525377] |
Tue, 06 April 2010 12:42 |
|
Well, it turns out that I no longer need the answer to the above question in order to solve my problem (the SQL based solution follows below), but I'm still curious.
And I'd love to know whether there are other magic tags to be used!
/**
* This code mimics the PersonSearchForm.
* If the person is not active: P.ACTIVE=0 (and thus C.ACTIVE=C.ACTIVE is always true).
* If the person is active: P.ACTIVE=1 AND C.ACTIVE IN (-1,1).
*/
@Override
public String getConfiguredStatement(){
return "(<attribute>P.ACTIVE</attribute> "+
"AND C.ACTIVE=DECODE(P.ACTIVE, 0, C.ACTIVE," +
" 1, DECODE(C.ACTIVE, 1, C.ACTIVE," +
" -1, C.ACTIVE))) ";
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.02259 seconds