vsoneta Posted March 16, 2009 Share Posted March 16, 2009 I am using Adobe Air with my application which shows the user the reports which uses jasperserver 3.1. I am having issues from adobe air to open the files in pdf, xls, csv and all the exports. I somehow got the pdf opening by installing adobe reader 9, but for others no luck. So I was thinking about one approach and not sure whether this can be done.. so need help from the experts. on my .zul file I have a button, when clicked, generates a url eg. http://..../jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/DierTracts/Contracts&ContractID=512&ContractID=512 From here it should generate(run) the above report and save it in there local( with the extension provided from the database and then the user can open it on there installed application.And the above thing should happen in that button click and the user will be given the path to open the file... Somthing like that.. Please help me how can this be achieved... or someother way ... please help Link to comment Share on other sites More sharing options...
developerdude Posted March 16, 2009 Share Posted March 16, 2009 If I understand you correctly, you want to get a report from JasperServer and save a report as a file someplace external to JasperServer, or take that data and display it outside of JasperServer. JasperServer reports run from the JasperServer scheduler are saved in the JasperServer repository. To retrieve those reports you can access them via HTTP and then write them to a file someplace or otherwise use the data you have downloaded as you wish. I do this by opening a URLConnection (which usually resolves to an HttpURLConnection) in Java and then stream the data to a local file. However, if you are wanting to run the report at any given time I have not done that as my requirements are that I export reports run via the scheduler, not provide dynamic access. My app uses a different URL than the URL for any given report and I haven't tried to download those (our reports are not idempotent - i.e., when you run them they tag data in the database). It may be possible to use the same or similar methodology for your problem but I have never even peeked into Adobe Air to know if it has this capability - I can only say how I did it in Java. In Java there is an API for running JasperReports directly.Post Edited by Lauren Bish at 03/16/09 23:44 Link to comment Share on other sites More sharing options...
vsoneta Posted March 17, 2009 Author Share Posted March 17, 2009 Hi Lauren, Yes you understood it right, I want to get a report from jasperserver and save a report as a file on the users local machine and give them an option to open it. You said that jasperserver reports are saved in JasperServer repository.. are they visible directly or I have to write a code to get them.. ie Can I see the file in MYSQL database and if yes which table are they saved.. I want to see the repository on my server... Do you have the code that retrieve those reports and write them to a file... Once again thank you so much for your help Link to comment Share on other sites More sharing options...
vsoneta Posted March 17, 2009 Author Share Posted March 17, 2009 Hi Lauren, Can you please send me your contact information at vsoneta@yahoo.com. Please so that I can get help from you directly... Link to comment Share on other sites More sharing options...
swood Posted March 17, 2009 Share Posted March 17, 2009 Can you make a web services call? You can run the report that way, and export into different formats. Or you can pull the report from the repository after it has been run. Have a look at the Web services guide. ShermanJaspersoft Link to comment Share on other sites More sharing options...
developerdude Posted March 18, 2009 Share Posted March 18, 2009 The reports in the repository are visible to human users - not sure if you can get to a saved report (that has been filled) from the web services - I was under the impression that I could only get 'resources' not actual reports (that's the way I read the web services docs anyway). I haven't looked myself, but I believe a report 'file' (actually I think it is the JasperPrint object or something like that) are saved as a blob in the database. See my reply to SWoods below. Link to comment Share on other sites More sharing options...
developerdude Posted March 18, 2009 Share Posted March 18, 2009 To pull the report (the resulting file) from the repository do I just call the get method with type "TYPE_REPORTUNIT"? I was under the impression, possibly mistaken, that I could not get the actual report. The docs read like the only types I could retrieve are the resources (images, JRXML, etc.) and not the scheduled report results. I have my exporter working fine now, but it would be cleaner if I could use the web service instead of downloading using HTTP. Link to comment Share on other sites More sharing options...
developerdude Posted March 18, 2009 Share Posted March 18, 2009 I tried to get (not run) the report from the repository in a unit test and so far no success. I got an exception:java.lang.Exception: Attachment not present! at com.jaspersoft.jasperserver.irplugin.wsclient.WSClient.get(WSClient.java:282) Which is fairly self-explanatory: no file attached to the responseSnippet of code below. Code: Post Edited by Lauren Bish at 03/18/09 23:15 Link to comment Share on other sites More sharing options...
swood Posted March 20, 2009 Share Posted March 20, 2009 Your exception is caused by the file not existing before the call. Here is something out of the JasperServer remote unit tests that works:File tmpFile = File.createTempFile("jasperserver", "");tmpFile.deleteOnExit();ResourceDescriptor uriDescriptor = new ResourceDescriptor();uriDescriptor.setUriString("/ContentFiles/pdf/Test_Report_Pdf");ResourceDescriptor resource = wsclnt.get(uriDescriptor, tmpFile);assertEquals(ResourceDescriptor.TYPE_CONTENT_RESOURCE, resource.getWsType());assertEquals("/ContentFiles/pdf/Test_Report_Pdf", resource.getUriString());assertEquals(ResourceDescriptor.CONTENT_TYPE_PDF, resource.getResourcePropertyValue(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE));assertTrue(tmpFile.exists()); The ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE is one of: public static final String CONTENT_TYPE_PDF = "pdf"; public static final String CONTENT_TYPE_HTML = "html"; public static final String CONTENT_TYPE_XLS = "xls"; public static final String CONTENT_TYPE_RTF = "rtf"; public static final String CONTENT_TYPE_CSV = "csv"; public static final String CONTENT_TYPE_IMAGE = "img"; ShermanJaspersoft Link to comment Share on other sites More sharing options...
developerdude Posted March 20, 2009 Share Posted March 20, 2009 Thanks Sherman, I'll give that a try. I am still unclear on one or two issues though: The goal I am trying to accomplish is to download a particular report from the repository. I would prefer to use the web services to download it directly instead of what I do now. Currently I get a report base filename from the job I retrieve from the scheduling web services, append the date/time stamp pattern to the end of that and the extension from the format, then I get an HTTP stream using "http://hostname:8080/jasperserver/fileview/fileview" + the filename I constructed. So, if I construct the name the same way (with the date stamp) and pass that as part of the URI (maybe sans the extension?) will I get back what I expect? I.E., "MyReport-20090101.xls" (which already exists)? If not, then what report am I getting back when I call it with the URI and filename "MyReport"? Is it re-running the report with the given params in the ResourceDescriptor? Thanks.Post Edited by Lauren Bish at 03/20/09 15:52 Link to comment Share on other sites More sharing options...
lucianc Posted March 23, 2009 Share Posted March 23, 2009 developerdudeWrote: So, if I construct the name the same way (with the date stamp) and pass that as part of the URI (maybe sans the extension?) will I get back what I expect? I.E., "MyReport-20090101.xls" (which already exists)? If not, then what report am I getting back when I call it with the URI and filename "MyReport"? Is it re-running the report with the given params in the ResourceDescriptor? You need to use the resource URI of the generated report (i.e. something like /generated_reports/MyReport-20090101.xls) to get the data via web services. If you only use "MyReport" (and there is no resource by that name in the repository), you would get an error.Regards,Lucian Link to comment Share on other sites More sharing options...
developerdude Posted March 23, 2009 Share Posted March 23, 2009 Thanks Lucian. I'll give that a try when I get the time. I do want to open source my solution so others can use it and I would rather get the data from the repository directly than via the file-view URL and HTTP. My initial understanding of the web services was apparently mistaken in that I thought I couldn't get the already run report via the WS API. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now