class AccessRequestService {

    public List<CompletedAccessRequestWrapper> getCompletedRequests() {
    /*  This object is all of the Activiti Variables associated with the request
        This map will contain the following:
        When the request was opened
        When the request was actioned by an approver (or canceled by a user/approver)
        How many attempts it took to approve the user
    */
        final ObjectMapper mapper = new ObjectMapper();
        List<CompletedAccessRequestWrapper> results = new ArrayList<>();

        String query = new StringBuilder(REQUESTS_QUERY)
                .append("order by updated desc;")
                .toString();

        NativeQueryImpl q = (NativeQueryImpl) entityManager.createNativeQuery(query);
        q.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);

        List < Map < String, AccessRequestWrapper >> result = q.getResultList();
        for (Map<String, AccessRequestWrapper> map: result) {
            CompletedAccessRequestWrapper requestWrapper = mapper.convertValue(map, CompletedAccessRequestWrapper.class);
            results.add(requestWrapper);
        }

        return (List<CompletedAccessRequestWrapper>)filterResults(results);
    }

    @Autowired public  AccessRequestService(TaskService taskService,
                                AccessRequestRepository accessRequestRepository,
                                GatekeeperRoleService gatekeeperRoleService,
                                RuntimeService runtimeService,
                                HistoryService historyService,
                                GatekeeperApprovalProperties gatekeeperApprovalProperties,
                                AccountInformationService accountInformationService,
                                GatekeeperOverrideProperties overridePolicy,
                                DatabaseConnectionService databaseConnectionService,
                                EntityManager entityManager);

}