| HRider API
Español | English

Use Case: Personal Report

Example of how to get an employee's feedback report and download their PDF.

As in the previous example, we use the company and appraisal IDs to create links to both resources and obtain them using 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);

To get the personal feedback report we build the link to the feedback-reports adding the evaluated employee ID:

Link reportLink = appraisal.getLinks().getReports().build("feedback-reports").build(employeeId);
FeedbackReport report = service.get(FeedbackReport.class, reportLink);      

We see the result obtained:

Employee            Appraisal           Position            % Achieved Indicators  Score     Gap          
------------------- ------------------- ------------------- ---------------------- --------- ---------
EMP006              POTENTIAL            RRHH                100.0                 86.61     85.2           

To download the report in PDF we make the same GET request, this time specifying in the request header that the mime type we want to obtain is application/pdf, and finally saving the content in the output directory:

InputStream in = service.get(InputStream.class, reportLink, net.hrider.api.Constants.MIMETYPE_PDF);
try (FileOutputStream fout = new FileOutputStream(new File(outputDir, "feedback-report.pdf"))) {
    saveToFile(in, fout);
} catch (IOException ex) {
    LOG.log(Level.SEVERE, "error saving file", ex);

Alternatively, the system allows adding a request parameter alt with the value application/pdf instead of specifying the mime type in the header. The following call would be equivalent:

InputStream in = service.get(InputStream.class, reportLink.addQueryParam("alt", "application/pdf"));