...
- Copy the .jrxml file to the reports directory on the server. Report files should be installed in the cspace/reports directory under the Tomcat directory (whose path should be in the
CSPACE_JEESERVER_HOME
environment variable). Note the name of the file, e.g., "acq_basic.jrxml".
- Create a report metadata record to register the report with CollectionSpace. This requires you record contains information about the report, so that CollectionSpace knows how to run it. You will need to run a curl command to send the record to the server's REST API. The following example declares that the report "acq_basic.jrxml" should be shown to users when they are editing Acquisition records. Set the
outputMIME
value to the desired default output type for the report. This can be any output type supported by JasperReports.
...
Code Block |
---|
curl -X POST http://localhost:8180/cspace-services/reports
-i -u admin@{yourtenant}.collectionspace.org:{password}
-H "Content-Type: application/xml" -T report.xml |
Installing reports automatically
As of release 7.2, CollectionSpace automatically installs built-in reports on startup, so creating report records manually using curl is not necessary. To make a report automatically install:
- Add the .jrxml file to the built-in reports directory in the services source tree on your server. This directory is located at services/report/3rdparty/jasper-cs-report/src/main/resources inside the services source code directory.
- Add a report metadata record .xml file to the same directory. This file must have the same name as the report file, but the extension
.xml
instead of.jrxml
. - Add the report to the tenant bindings file for your tenant. This file is located at services/common/src/main/cspace/config/services/tenants/{yourtenant}/{yourtenant}-tenant-bindings.delta.xml inside the services source code directory. Replace "{yourtenant}" with the name of your tenant. The tenant binding file for the publicart tenant contains an example of what to add: https://github.com/collectionspace/services/blob/676faa9cf37ee4d99816d3392eb1984d247cfb0b/services/common/src/main/cspace/config/services/tenants/publicart/publicart-tenant-bindings.delta.xml#L11-L22. For each report you want to have installed automatically, create property with the key "report", and set the value to the name of the report (the name of the .jrxml and .xml files, without the extension).
- Redeploy the services, and restart CollectionSpace. The report should appear in the CollectionSpace UI.
Documents and forDocType
values
It's common to create reports that describe Object records that are related to a procedural record, such as an Intake. In this case, the context document is the procedural record (the Intake, Accession, etc.), even though the report will actually generate output about the related Object records. The forDocType
values present in the XML above control where the user will see the report in the UI. You may infer from the XML above that one report can appear for multiple types of records -- this is useful when a report summarizes Objects associated with multiple kinds of procedural records (Intakes, Acquisitions, Loans, etc.). The value of the csid
parameter passed to the report from CollectionSpace will be the unique id of the record on which the user ran the report (e.g., the Intake, or the Acquisition). Your report query must select Object records associated to that record through relations.
...