SolutionGuidance / psm

Welcome to the Medicare/Medicaid Provider Enrollment Screening Portal
http://projectpsm.org/
Other
26 stars 20 forks source link

Use Spring annotations to find and initialize admin controllers #1042

Closed jasonaowen closed 6 years ago

jasonaowen commented 6 years ago

A month or so ago, and as a follow up to PR #964, I experimented further with using Spring annotations in the PSM. To quote from that PR description:

When a project is set up to support it, Spring is able to automatically discover new controllers (and other components) by looking for the proper annotation. This makes configuration much simpler, and makes it easier to, for example, add new controllers.

Spring is also able to automatically determine a component's dependencies if they are declared as constructor arguments. In addition to simplifying configuration, this allows us to reduce Java boilerplate code by removing getters and setters.

In #964, I limited the scope of controllers to the reports (package gov.medicaid.controllers.admin.report); in this PR, broaden the scope to all the admin controllers (package gov.medicaid.controllers.admin). In a subsequent PR, I will further broaden the scope, but for the sake of smaller PRs this felt like a good division.

As part of this refactoring, I removed the BaseServiceAdminController and BaseSystemAdminController base classes, as I found they added only complexity. I find it more clear for each controller to explicitly declare the things it depends on, rather than get a bunch of dependencies (needed or not) via inheritance.

I open this as a PR now both in the interest of getting experiments merged as part of winding down my contributions to the PSM, and because it will make solving #1032 a bit easier.


To test this, I logged in as a service admin and made sure that all the functionality still worked (reports, agreement documents, the automatic screening list, the enrollments list, the provider type list, and the screening schedule), and as a system admin to verify that the user list and user search still worked.

jasonaowen commented 6 years ago

Thanks, @PaulMorris !