PUZZLE Reporter Plugin (1.0.2)

Changelog

Component Category Description
PUZZLE Reporter Plugin 1.0.2 Dependency PUZZLE core version 49.2.0.
Improvement Initial version.

Description

This PUZZLE plugin allows a client to request PUZZLE to create a report for a solution of a job. A report is a document based on a template filled with values from a solution of a job.

PUZZLE creates reports for a solution on demand. When you request PUZZLE to create a report, PUZZLE performs the following steps:

  1. PUZZLE interprets the template attribute of the request body as a url

  2. PUZZLE downloads the template file available at this url

  3. PUZZLE processes the template

    • PUZZLE fills the values of the solution with solutionId for the job with id jobId into the template.

    • PUZZLE resolves any resource reference in the template, by looking in the resourcesUrl attribute and the default resource directory.

  4. PUZZLE creates the report in the format given in the attribute format.

The default resource directory is the fallback directory for resolving resource reference. This section describe the resolving process in details.

PUZZLE supports file and http url types.

Important: Every URL must be reachable from the point of view of the host running the PUZZLE instance.

Default templates

By default, a PUZZLE REST installation contains a set of templates in the directory static/templates and the set of corresponding resources in the directory static/resources.

The directory static/resources is used as the default resources directory.

The following table lists all resource references of the default templates.

template Resource reference Description
en/puzzle_report_pallet_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
en/puzzle_report_box_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
en/puzzle_report_pack_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
en/puzzle_report_pack_plus_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
en/puzzle_report_ship_it_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
de/puzzle_report_pallet_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
de/puzzle_report_box_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
de/puzzle_report_pack_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
de/puzzle_report_pack_plus_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.
de/puzzle_report_ship_it_template.jrxml logo.png The png image that is used as logo in the upper right corner of the report.

Resolve resource references in a template

First PUZZLE tries to resolve resource references with the resourcesUrl attribute and uses the default resource directory if necessary.

The default resource directory is set by default to ./static/resources and can be changed using the Reporter.defaultResourcesDirectory parameter in the puzzle.parameter file.

For example, the template static/templates/puzzle_pallet_template.jrxml contains a reference to the resource logo.png.

If you set resourcesUrl in a request to http://mypuzzle.de/resources, PUZZLE will resolve the resource reference logo.png with http://mypuzzle.de/resources/logo.png.

If no file is available at this url, PUZZLE verify if the default resources directory contains a file named logo.png.

If this file exists, PUZZLE uses this file to resolve the resource reference logo.png, otherwise PUZZLE returns an error.

If you do not specify a resourcesUrl, PUZZLE immediately searches for resource references in the default resource directory.

/report

Precondition: the state of the job is DONE.

Create a report for a solution of a job. PUZZLE uses the template and the format specified in the request body.

Request Body schema: application/json
jobId
required
integer <int64> >= 1

Identifier of the job for which PUZZLE should create a report.

solutionId
required
integer >= 1

Identifier of the solution of the specified job for which PUZZLE should create a report.

format
required
string

PUZZLE should create a report in this format. Currently supported values are:

  • pdf for the Portable Document Format (PDF)
template
required
string

A url that references the template to be used to create the report.

resourcesUrl
string

Url used by PUZZLE to resolve the resource reference specified in the template attribute. For details on how PUZZLE resolves the resource reference, see the description section.

Responses

200

The generated template in the specified format as a binary stream. The Content-Type depends on the requested format.

Pallet example report in the pdf format

Response Schema: */*
string
404

There does not exist a job with the given jobId.

500

An error occurred.

post /report
PUZZLE instance at host hostname port 8888
http://hostname:8888/puzzle/api/v1/report
PUZZLE instance at localhost port 8888
http://localhost:8888/puzzle/api/v1/report

Request samples

application/json
Copy
Expand all Collapse all
{
  • "jobId": 1,
  • "solutionId": 1,
  • "format": "pdf",
  • "template": "file:./static/templates/puzzle_pallet_template.jrxml",
}

Response samples

application/json
Copy
Expand all Collapse all
{
  • "errorMessage": "PUZZLE cannot find job with id 123",
  • "additionalInformation": "",
  • "errorClass": "de.fraunhofer.iml.puzzle.adapter.execution.Exceptions.Rest.PuzzleJobNotFoundException"
}