| HRider API
Español | English

Use Case: Get Appraisal Reports


This example shows how to get the reports available for a specific appraisal and how to download their content.

As in the previous examples, we use the link to the company and the appraisal to obtain both resources through a GET call:

Link companyLink = root.getLinks().getCompanies().build(companyId);
Company company = service.get(Company.class, companyLink);        
Link appraisalLink = company.getLinks().getAppraisals().build("" + appraisalId);
Appraisal appraisal = service.get(Appraisal.class, appraisalLink);

Following the appraisal's reports link we get all the reports available to it:

ReportsCollection collection = service.get(ReportsCollection.class, appraisal.getLinks().getReports());
List<Report> reports = collection.getEmbedded().getReports();

For a feedback appraisal we get this result:

ID                            Description                               Mimetypes           
---------------------------   ---------------------------------------   ---------------------------------
feedback-reports              Individual reports for feedback appra...  application/json    
feedback-results              Individual results list for feedback ...  text/csv,application/
feedback-results-jobs         Results by jobs for feedback appraisal    text/csv,application/
feedback-results-gender       Results by gender for feedback appraisal  text/csv,application/
feedback-results-age          Results by age for feedback appraisal     text/csv,application/
feedback-results-antiquity    Results by seniority ranges for feedb...  text/csv,application/
feedback-detail               Individual results detailed by indica...  text/csv,application/
feedback-group-detail         Individual results detailed by indica...  text/csv,application/
feedback-action-plan          Action plan objectives list for each ...  text/csv,application/

Each report contains an ID, a description of what the report contains, and the content types that are supported to download.
For example, the second report, with ID feedback-results can be download at both Excel and CSV and includes the list of individual results for a feedback appraisal.
The following code snippet downloads the report in Excel and saves it to a file:

InputStream in = service.get(InputStream.class, reports.get(1).getLinks().getSelf(), 

try (FileOutputStream fout = new FileOutputStream(new File(outputDir, "feedback-results.xls"))) {
    saveToFile(in, fout);
} catch (IOException ex) {
    LOG.log(Level.SEVERE, "error saving file", ex);

Alternatively we could have created the link manually using the report ID. In this example the URI to the report would be (replacing 'companyId' and 'appraisalId' with their corresponding IDs):