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

nbochenko

Members
  • Posts

    25
  • Joined

  • Last visited

nbochenko's Achievements

Explorer

Explorer (4/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. As far as I know, CDH 4.5 is supported, pre-4.x versions are no longer supported by CDH either.
  2. Hi, A simplified version of these steps would be: 1. Install JRS from scratch to new DB. No need to edit context.xml if you point it to another DB at the beginning. 2. Export repo with import-export tools. 3. Import this repo to the new repo. Note that the versions should be the same, or you have to follow the upgrade procedure. If you had a working instance of JRS before importing the old repository, you should be able to login with jasperadmin/jasperadmin and superuser/superuser (default access credentials). Regards, Nikita
  3. What Java version are you running? Is this Oracle Java 1.7? You could try re-deploying Oracle JDBC driver via JBoss (console or via control files) and if that deployed successfully, re-deploy JRS.
  4. Issue:In some use cases default aggregation function in domain designer is set to "None". In some rare cases, if you need to edit many fields, you may want to change the default aggregation function selected in UI: [toc] Resolution:In order to change it, find file /domain.designer.display.js. Locate the lines: if (!item.isParent()) { metanode.extra['dataType'] = item.param.extra.JavaType, metanode.extra['defaultAgg'] = 'none', metanode.extra['defaultMask'] = 'none' } Change metanode.extra['defaultAgg'], for example, to this: metanode.extra['defaultAgg'] = 'Average', You will need to refresh your page. Note that this is only a UI setting, and won't change your domain. It is relevant only when selecting Measures.
  5. GoalsUsing REST to design a simple continuous integration with SVN, Python 2.7 and JasperReports Server gives some obvious benefits: Versioning of reports with easy roll-back procedureContinuous integrationManagement of development and production environmentsDisclaimerSample code is not production ready. It has numerous issues and should be used only as a starting point or as demonstration means. DocumentationJasperReports Server Web Services Guide - see Docs.Python 2.7 official documentation.Requests library for PythonApache Subversion (SVN) documentation pysvn documentationShort DescriptionThere are various hooks available in Subversion. We are mostly interested in post-commit hooks. Using knowledge of previous article about uploading reports (see uploading reports with python 2.7 and requests ), we can see that continuous integration in its simple form should be easy: Commit to SVNOn the server side, run post-commit hookPost-commit hook calls update on local version of SVN repo via pysvnExecutes PUT request on new reportsIf reports have been updated, we need to run POST request to update themDetailsUsing pysvn to create or update working copy: #!/usr/bin/env pythonimport pysvnimport loggingimport argparse#see attachment and comments for detailsfrom report_upload import report_uploaddef svn_checkout(svn_url, svn_path): """ Used to checkout or update local copy svn_url - repo url, could be svn://, file://, http:// svn_path - local path of the working copy, i.e. /home/user/jasper_repo/ """ client = pysvn.Client() if not os.path.exists(svn_path): client.checkout(svn_url, svn_path) else: try: client.update(svn_path) except Exception as e: print e raise def report_log(rev, svn_path): """ Using revision and local working copy to generate changed files rev is revision number in, for ex., 3 svn_path local path of the working copy, i.e. /home/user/jasper_repo/ """ revision = pysvn.Revision(pysvn.opt_revision_kind.number, rev) client = pysvn.Client() # getting svn log for revision number with changed paths log = client.log(svn_path, discover_changed_paths=True, revision_end=revision) # getting list of files for HEAD head_files = client.list(svn_path, recurse=True) files = [] for i in head_files: # using pysvn.node_kind.file to separate actual files if i[0].kind == pysvn.node_kind.file: files.append(unicode(i[0].repos_path[1:])) diff_paths = [] # separating changed paths in log to a list for i in log: paths = i['changed_paths'] for j in paths: if j['action'] in ['A', 'M']: diff_paths.append(unicode(j['path'])) # returning only intersection with file list and changed files list diff_files = set(diff_paths).intersection(files) return list(diff_files)if __name__ == '__main__': # logging in a very simple form logging.basicConfig(filename='error.log', level=logging.WARNING, format='%(asctime)s %(message)s') # initializing argparse. It is useful if we need to run the hook manually parser = argparse.ArgumentParser(description="SVN uploader on post-commit") parser.add_argument("-R","--rev", help="Revision", required=True) parser.add_argument("-f","--svn_url", help="SVN url", required=True) parser.add_argument("-p","--svn_path", help="local path to init") args = parser.parse_args() # checking out or updating local svn repository try: svn_checkout(args.svn_url, args.svn_path) except Exception as e: logging.error('Exception in svn_checkout(): %s' % e) # getting file list for report upload diff_files = report_log(args.rev, args.svn_path) for i in diff_files: report_upload(repo_path=i, report_jrxml=args.svn_path + str(i), report_datasource="/datasources/repositoryDS", jasper_url='http://localhost:8080/jasperserver-pro', user='jasperadmin', password='jasperadmin') # done![/code]You can use report_upload from uploading reports with python 2.7 and requests. The most notable changes are: jrxml file is loaded in a variableif PUT does not work we attempt POST. A correct way would be to test path for existence and select a correct method depending on the request.Add a post-commit hook to svn hooks. For example: svn_upload.py -R $2 -f file:///opt/svn-repo -p /opt/upload/jasper-working-copy See subversion documentation and sample hook scripts (hooks/post-commit.tmpl) for details. On windows you will have to use cmd or bat scripts. For example: set TXT=%1set REV=%2echo "updating %TXT%" >> commit.logD:sourcejaspertrunkrestsupdate_svn.py -R %REV% -f file:///D:/source/test_repo -p d:/source/svn_test>>commit.log Sample codeSee attached zip archive for sample code. Current issuesNo production optimizationDoes not handle PUT and POST differences correctly - jsut attempts one after another/DDoes not handle locks. It should be locking files if development is done by more than one person to avoid conflicts.No actual error handling. If your postcommit failed - it has failed, and you will never know it.No deleting of deleted files.Works only with one datasource. No attachments or Input Controls.Directories are also not created- you will have to follow existing repo path in your SVN repository or force other paths.Logging should be more elaborate.
  6. GoalsSystem Administrators or developers may have a need to download arbitrary report contents via REST to JasperReports Server. Using a simple script to do that rather than import/export, iReport or JSS can be useful in number of situations: Embedding report download and viewing in other applicationsDevelopment process - download report content without tying up to repository structure. Could be useful to initilize a new repository with new structure.System Administration process - when using an export is not feasibleBulk download via command-lineVarious test utilitiesThis article is related to uploading reports with python 2.7 and requests DocumentationJasperReports Server Web Services Guide - see Docs.Python 2.7 official documentation.Requests library for PythonShort descriptionWeb Services Guide, 2.2.1 and 2.2.2 Requesting the Contents of a JasperReport and Requesting the Contents of a File Resource This is a bit more complex than uploading a report (see uploading reports with python 2.7 and requests ) GET http://<host>:<port>/jasperserver[-pro]/rest/resource/path/to/resource/We will get a valid ResourceDescriptor with all attachements listedNow we need to parse this ResourceDescriptor and download required attachementsNw we need to download each file, for example: GET /jasperserver/rest/resource/reports/samples/AllAccounts_files/AllAccounts_Res3?fileData=trueYou HAVE to use fileData=trueResourceDescriptor syntax is out of the scope of this article. I would suggest exisiting ResourceDescriptors. You can check them via iReport or REST GET to resources service. Example request#!/usr/bin/envimport requestsimport xml.etree.ElementTree as ET # Path to resource rest service:url = 'http://loclahost:8080/jasperserver-pro/rest/resource' # Report to process:report = '/somereport' # Authorisation credentials:auth = ('jasperadmin', 'jasperadmin') # file types to download:file_types = ['jrxml', 'img', 'jar' ] # Init session so we have no need to auth again and again:s = requests.Session() r = s.get(url=url+report, auth=auth) # init empty dictionaryfiles = {} # creating tree from ResourceDescripotor we have in Responsetree = ET.fromstring(r.content) # searching tree. Could be more efficient with Xpath# You may also implement testing for reportUnit wsType for speedsup for i in tree.iter('resourceDescriptor'): if 'wsType' in i.attrib: # we do not need all wsTypes, checking against file_types set previously if i.attrib['wsType'] in file_types: #Storing uriString and wsType files[i.attrib['name']] = [i.attrib['uriString'], i.attrib['wsType']] # This could have been done while searching the tree.for filename in files: #each file has a bit different url file_url = url + files[filename][0] using session and parameters to get file content r = s.get(url=url, params=params) # Files in repository # can be stored without extension, so # writing to filename with extension of wsType. i.e: # jrxml, jar, img. This has implication of all images # having ".img" file extension, etc. # Note that file is opened in binary mode with open(filename + "." + files[filename][1], "wb") as f: # we can have binary data, so using r.content f.write(r.content) # Done![/code]Example implementation: command-line utility to download report filesSee report_download.zip. Required libraries (in most cases only requests needs to be installed): import requestsimport argparseimport xml.etree.ElementTree as ETimport loggingimport httplibimport osimport sys [/code]To see help, run report_download.py -h: usage: report_download.py [-h] -r REPO_PATH [-f FOLDER] [-l JASPER_URL] [-u USER] [-p PASSWORD]Upload jrxml file as a report to JasperReports serveroptional arguments: -h, --help show this help message and exit -r REPO_PATH, --repo_path REPO_PATH Report repository path (with report name) -f FOLDER, --folder FOLDER Folder to download report -l JASPER_URL, --jasper_url JASPER_URL JasperReports Server URL, default http://localhost:8080/jasperserver-pro -u USER, --user USER JasperReports Server user, default superuser -p PASSWORD, --password PASSWORD JasperReports Server password, default superuser[/code]Example usage: report_download.py -r /organizations/organization_1/reports/samples/Cascading_multi_select_report -l http://localhost/jasperserver-pro-51 -f cascading[/code]NotesIn this article I am assuming the PRO version of JasperReports Server is used. However, the same should work for CE version if you use correct uri, repo path and user.
  7. GoalsSystem Administrators or developers may have a need to upload arbitrary reports via REST to JasperReports Server. Using a simple script to do that rather than import/export, iReport or JSS can be useful in number of situations: Development process - new report version of the report uploaded via SVN or GIT hook. This keeps both reports versioned and deployed to the server.System Administration process - when using an export is not feasibleBulk upload via command-lineEmbedding report upload functionality in other applicationsVarious test utilitiesDocumentationJasperReports Server Web Services Guide - see Docs.Python 2.7 official documentation.Requests library for PythonShort descriptionWeb Services Guide, 2.2.4 Creating a Resource describes how to create a request. In a short form this should be: PUT http://<host>:<port>/jasperserver[-pro]/rest/resource/path/to/resource/form-data: valid ResourceDescriptorapplication/octet-stream for attached JRXML files.ResourceDescriptor syntax is out of the scope of this article. I would suggest exisiting ResourceDescriptors. You can check them via iReport or REST GET to resources service. A sample resourcedescriptor_0.xml is attached for reference. Example requestLooking through requests documentation this should look something like this: #!/usr/bin/pythonimport requests #open resource descriptor and jrxml file for readingtry: resource_descriptor = open('resource_descriptor.xml', 'rb') report_jrxml = open('test.jrxml', 'rb')except: raise #Path to resource rest service:url = 'http://loclahost:8080/jasperserver-pro/rest/resource' #Authorisation credentials:auth = ('jasperadmin', 'jasperadmin') #initialize data. Requests will handle encoding.data = {"ResourceDescriptor": resource_descriptor.read() } #initialize files with report_name and data tuple. Requests will handle encoding.#Note that "name" in the PUT request should equal report_files path,#i.e. for report in /repopathtoreport/report the path would be /repopathtoreport/report_filesfiles = {'/repopathtoreport/report_files': ('report_name', upload)} #making a put request straight from documentationr = requests.put(url=url, data=data, files=files, auth=auth) #to see request status code do#print r.status_code #will raise HTTP error if there is one:r.raise_for_status() #Done! Good practice would be to close files when they are not required - both can be quite big.[/code]Example implementation: command-line utility to upload reportsExample uses jinja2 to render valid ResourceDescriptor. Templates should be located in 'templates' directory (see res_descr.xml) See jasperrest_0.zipfor jasperrest.py. Libraries required: import requestsimport argparseimport loggingimport httplibimport jinja2import os[/code]To see help, run jasperrest.py -h : usage: jasperrest.py [-h] -r REPO_PATH -j REPORT_JRXML -d REPORT_DATASOURCE [-l JASPER_URL] [-u USER] [-p PASSWORD] [-t TEMPLATE]Upload jrxml file as a report to JasperReports serveroptional arguments: -h, --help show this help message and exit -r REPO_PATH, --repo_path REPO_PATH New report repository path (with report name) -j REPORT_JRXML, --report_jrxml REPORT_JRXML jrxml_file for upload -d REPORT_DATASOURCE, --report_datasource REPORT_DATASOURCE datasource repo path -l JASPER_URL, --jasper_url JASPER_URL JasperReports Server URL, default http://localhost:8080/jasperserver-pro -u USER, --user USER JasperReports Server user, default superuser -p PASSWORD, --password PASSWORD JasperReports Server password, default superuser -t TEMPLATE, --template TEMPLATE ResourceDescriptor template name in templates dir, default res_descr.xml Sample syntax: jasperrest -r /public/new07 -j test.jrxml -d /organizations/organization_1/datasources/repositoryDS -l http://localhost:8080/jasperserver-pro NotesIn this article I am assuming the PRO version of JasperReports Server is used. However, the same should work for CE version if you use correct uri, repo path and user.
  8. Case insensitive search for Oracle 10g/11gBy default Oracle DB performs case-sensitive search when doing like %char%. That causes filters created in AdHoc Designer to be also case-sensitive. Starting from db version 10g, you can use REGEXP_LIKE condition to enable case-sensitive search. You would need to: [toc]Open /WEB-INF/applicationContext-semanticLayer.xmlFind: <bean id="oracleSQLGenerator" parent="defaultSQLGenerator" scope="prototype" /> Edit entry "contains" to use regexp_like(source_char, pattern, match_param). See example belowSave this file and restart the server.Example<entry key="contains"> <value> def search = args[1].value; if (search == null) return sqlArgs[0] + " like '%' || " + sqlArgs[1] + " || '%'" if (! (search instanceof String)) { search = search.value } return " regexp_like(" + sqlArgs[0] + "," + "'" + search.replace("'","''") + "', 'i')" </value></entry> Note this line: return " regexp_like(" + sqlArgs[0] + "," + "'" + search.replace("'","''") + "', 'i')" Original line would use LIKE %...%: return sqlArgs[0] + " like '%" + search.replace("'","''") + "%'" Other DBsDepending on your DB, you may want to customise other related beans in applicationContext-semanticLayer.xml. MySQL by default performs case-insensitive search via collation table. PostgreSQL by default performs case-sensitive search, but can use regular expression in a similar to Oracle manner. See beans "postgreSQLGenerator" and "mysqlSQLGenerator" for details on MySQL or PostgreSQL. You can also find some other, less often used SQL variations defined there.
  9. IssueOccasionally the labels are too big for the Pie Chart and do not fit into the chart. Is there a way to control this behaviour? SolutionYou can use Fusion Charts properties for that. If you check Fusion docs you will find this property: <chart ...="" managelabeloverflow="1" ...>[/code]Essentially it will wrap the labels if there is enough space. You can apply this in a Pie Chart in this manner: <fc:chart type="Pie" xmlns:fc="http://jaspersoft.com/fusion" xsi:schemalocation="http://jaspersoft.com/fusion http://jaspersoft.com/schema/fusion.xsd"> <fc:chartproperty name="manageLabelOverflow"> <fc:propertyexpression> <!--[CDATA["1"]]--> </fc:propertyexpression> </fc:chartproperty> ...</fc:chart>[/code]BeforeAfterYou can find some other available properties in Fusion Charts documentation.
  10. Q: Legend settings for selected series should be hidden based on a parameter selection. How should we achieve that?[toc on_off::hide=1] A: You can use a series property contributor that sets the showInLegend for each series.The solution is rather convoluted because series contributors can only access bucket and measure values and cannot directly reference dataset values such as parameters. For that reason a dummy column level is required to make the values available for the chart. For example: <dataaxis axis="Columns"> <axislevel name="root"> <labelexpression>"root"</labelexpression> <axislevelbucket> <bucketexpression>""</bucketexpression> <bucketproperty name="showCategory1"> ($P{showSeries}.indexOf("All") != -1) || ($P{showSeries}.indexOf("Category1") != -1) </bucketproperty> <bucketproperty name="showCategory2"> ($P{showSeries}.indexOf("All") != -1) || ($P{showSeries}.indexOf("Category2") != -1) </bucketproperty> <bucketproperty name="showCategory3"> ($P{showSeries}.indexOf("All") != -1) || ($P{showSeries}.indexOf("Category3") != -1) </bucketproperty> </axislevelbucket> </axislevel></dataaxis>[/code]and <hc:series name="Category1"> <hc:contributor name="SeriesProperty"> <hc:contributorproperty name="showInLegend" value="root.showCategory1" valuetype="Bucket" /> </hc:contributor></hc:series><hc:series name="Category2"> <hc:contributor name="SeriesProperty"> <hc:contributorproperty name="showInLegend" value="root.showCategory2" valuetype="Bucket" /> </hc:contributor></hc:series><hc:series name="Category3"> <hc:contributor name="SeriesProperty"> <hc:contributorproperty name="showInLegend" value="root.showCategory3" valuetype="Bucket" /> </hc:contributor></hc:series>[/code]
  11. IssueIn some cases you may need to find out the version of a deployed JasperReports Server via shell or command line. SolutionYou can find your JasperReports Server verison in WEB-INF/Internal. Community Edition<js-install>/WEB-INF/internal/jasperserver.properties[/code]PRO edition<js-install>/WEB-INF/internal/jasperserver-pro.properties[/code]ExamplesOn Linux, if Apache Tomcat is installed in /opt/tomcat/, the path to these files would be: /apache-tomcat-7.0.29/webapps/jasperserver-pro-501/WEB-INF/internal[/code]On Windows, it can be something like this: C:Program FilesApache Software FoundationTomcat 6.0webappsjasperserver-proWEB-INFinternal[/code]
  12. IssueIf you use rest v2 to export a report, you will always recieve paginated export, even if exporter allows non-paginated export. Can a report export be non-paginated? SolutionUse parameter ignorePagination=true in your REST call, for example: http://127.0.0.1:8080/jasperserver-pro/rest_v2/reports/public/testReport.html?ignorePagination=true[/code]This also works for other formats that support non-paginated output: PDF, XLS, etc. for export of excel - XLS http://127.0.0.1:8080/jasperserver-pro/rest_v2/reports/public/testReport.XLS?ignorePagination=true[/code]for export of PDF format http://127.0.0.1:8080/jasperserver-pro/rest_v2/reports/public/testReport.PDF?ignorePagination=true[/code]
  13. You have to use anonsvn:anonsvn. See http://anonsvn:anonsvn@code.jaspersoft.com/svn/repos/jasperserver for example, or use "Browse Source Code" link
  14. You have to use anonsvn:anonsvn. See http://anonsvn:anonsvn@code.jaspersoft.com/svn/repos/jasperserver for example, or use "Browse Source Code" link
×
×
  • Create New...