I advanced with my parser SQL to generate the field "code" automatically. (varchar 2000 in ad_userquery, 2000 can to be short in the future)
I put a example of the result after this text. When I to advance more I publish the code and a link public in the bitbucket.
Now I have a problem with the IN and with complex querys with subselect. At the time, I want to improve the parser (or advanced search) with the IN. I looked the symbols types ^=, ~= and others but I think that there isn't nothing to the IN.
I think that if exist it should show the field to mark which ones what user wants (Checkbox with Select and multiple - JS -Ajax).
Anyone know anything about this? (Before I begin and I to do a new customization that maybe isn't necessary in the advanced search).
Ps.: My idea in the momment it is add a option in the menu preference: "register querys with zero rows of return". If it is active,
then I will sugery a change the the program Query.java to execute the parser and after it save in ad_userquery, if anyone of the community will have interest in this improvment.
public String getCode(String Sql )
// TODO: IN
// TODO: new Object[]{AD_Org_ID, C_BPartner_ID, C_DocType_ID, C_Region_ID, To_Region_ID, LBR_BPartnerCategory_ID, LBR_FiscalGroup_BPartner_ID, LBR_FiscalGroup_Product_ID, LBR_NCM_ID, LBR_ProductCategory_ID, M_Product_ID, (lbr_IsSubTributaria ? "Y" : "N"), (isSOTrx ? "Y" : "N"), lbr_TransactionType}
// TODO: Sublect
INPUT:
SELECT * from LBR_TAXDEFINITION
WHERE (((IsActive = 'Y')
OR (AD_Org_ID IN (0, ?)))
AND ((C_BPartner_ID IS NULL)
OR (C_BPartner_ID = ?))
AND ((C_DocType_ID IS NULL)
OR (C_DocType_ID = ?))
AND ((C_Region_ID IS NULL)
OR (C_Region_ID = ?))
AND ((To_Region_ID IS NULL)
OR (To_Region_ID = ?))
AND (LBR_BPartnerCategory_ID BETWEEN 0 AND 3)
AND ((LBR_FiscalGroup_BPartner_ID IS NULL)
OR (LBR_FiscalGroup_BPartner_ID = ?))
AND ((LBR_FiscalGroup_Product_ID IS NULL)
OR (LBR_FiscalGroup_Product_ID = ?))
AND ((LBR_NCM_ID IS NULL)
OR (LBR_NCM_ID = ?))
AND ((LBR_ProductCategory_ID IS NULL)
OR (LBR_ProductCategory_ID = ?))
AND ((M_Product_ID IS NULL)
OR (M_Product_ID = ?))
AND (lbr_IsSubTributaria IN ('B', ?))
AND (IsSOTrx IN ('B', ?))
AND ((lbr_TransactionType IS NULL)
OR (lbr_TransactionType = ?)))
OUTPUT:
IsActive<^> = <^>Y<^><^><^>(((<^>)
<~>AD_Org_ID<^> IN <^>0<^>?<^>OR<^>(<^>))
<~>C_BPartner_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>C_BPartner_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>C_DocType_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>C_DocType_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>C_Region_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>C_Region_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>To_Region_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>To_Region_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>LBR_BPartnerCategory_ID<^> BETWEEN <^>0<^>3<^>AND<^>(<^>)
<~>LBR_FiscalGroup_BPartner_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>LBR_FiscalGroup_BPartner_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>LBR_FiscalGroup_Product_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>LBR_FiscalGroup_Product_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>LBR_NCM_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>LBR_NCM_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>LBR_ProductCategory_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>LBR_ProductCategory_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>M_Product_ID<^> IS NULL <^><^><^>AND<^>((<^>)
<~>M_Product_ID<^> = <^><^>?<^>OR<^>(<^>))
<~>lbr_IsSubTributaria<^> IN <^>B<^>?<^>AND<^>(<^>)
<~>IsSOTrx<^> IN <^>B<^>?<^>AND<^>(<^>)
<~>lbr_TransactionType<^> IS NULL <^><^><^>AND<^>((<^>)
<~>lbr_TransactionType<^> = <^><^>?<^>OR<^>(<^>)))