Jump to content
We've recently updated our Privacy Statement, available here ×

How to print text of query?


federico.cattozzi

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Thank you, I don't think about this solution.

So I have defined a new parameter QUERY with default expression similar to the query which was in <queryString> tag and I have put "<![CDATA[$P!{QUERY}]]>" in <queryString>, and all works.

 

If you work with iReport you lose some features of the "Report Query" window using this solution and all becomes less maintainable.

Link to comment
Share on other sites

I use jEdit software and BeanShell scripting language built-in it to do multiple text replacements.

It's useful also in this case to convert query from <queryString> format to java compliant format.

The script below can be used as macro in jEdit, but you have to test it for your code.

Code:
// This is a recorded macro. First, check over the// commands to make sure this is what you intended. Then,// save this buffer, and the macro should appear in the// Macros menu..//add quotes before and after every line and carriage return "\n" for pretty printSearchAndReplace.setSearchString("^(.*)$");SearchAndReplace.setReplaceString("\"\\\"\" + _1 + \"\\\\n\\\"+\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.setSearchFileSet(new CurrentBufferSet());SearchAndReplace.replaceAll(view);//add necessary characters to un-comment every parameter (P and P! are converted differently)SearchAndReplace.setSearchString("\\$P(!?)\\{([\\w\\_]*)\\}");SearchAndReplace.setReplaceString("_1 != null && _1.equals(\"!\") ? \"\\\"+$P\" + \"{\" + _2 + \"}\" + \"+\\\"\" : \"\'\\\"+$P\" + \"{\" + _2 + \"}\" + \"+\\\"\'\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.setSearchFileSet(new CurrentBufferSet());SearchAndReplace.replaceAll(view);//remove last characters of the query added by last replacementSearchAndReplace.setSearchString("(.*)\\\\n\"\\+\\z");SearchAndReplace.setReplaceString("_1 + \"\\\"\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.replaceAll(view);//convert tabs to "\t" for pretty printSearchAndReplace.setSearchString("\\t");SearchAndReplace.setReplaceString("\"\\\\t\"");SearchAndReplace.setBeanShellReplace(true);SearchAndReplace.setIgnoreCase(false);SearchAndReplace.setRegexp(true);SearchAndReplace.replaceAll(view);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...