GSoC 2021 - Week 1

Posted on June 12, 2021

Planning the work

I’ve started the week by gathering all requirements for the task ahead.

First, I’ve used these two articles on OpenMRS Wiki:

I also had to spend some time with REST API documentation here, because not every endpoint is documented well, and in some cases, required features were already implemented but not yet documented :)

After a few hours I’ve been able to come up with the draft list of tasks that I will be tackling this summer. Here it is:

As you can see, most of them involve creating a brand new resource for our objects.

Me and my mentors decided that we’ll be adding or removing tasks from this list when needed, according to the time left.

Let’s look at the first task from the list :)

My first task

My first task - exposing the list of administration links for installed modules through REST.

RESTWS-821

Created wrapper class for the resource return value

I’ve created class ModuleAdministrationLinks1_8 that represents one module with its administration links. It also contains AdministrationLink inner class to encapsulate a single link with its title.

Created AdministrationLinksResource1_8

It extends BaseDelegatingReadableResource class, because it only provides GET operations, as those objects cannot be persisted directly.

The implementation of it is fairly simple. I’m gathering all AdministrationSection extensions by calling ModuleFactory.getExtensions("org.openmrs.admin.list"). Then I’m casting each extension to its supper class - AdministrationSectionExt and retrieving a map of administration links. What’s left to do is to pack this into my custom class and send it as a response :)

Created AdministrationLinksResource1_8Test

Every class must be tested. That’s why I’ve created a basic unit test for my new REST Resource. My class extends BaseDelegatingResourceTest so I didn’t have much code to write myself.

Posted a Pull Request

After implementing all of the above, I’ve posted a pull request to review:

https://github.com/openmrs/openmrs-module-webservices.rest/pull/484

I’ve also created a pull request with the documentation for the AdministrationLinksResource:

https://github.com/openmrs/openmrs-contrib-rest-api-docs/pull/140

My second task

My second task was RESTWS-822.

It involved adding the ability to include disabled users when querying UserResource.

After investigating, it turned out that the Resource already supports such a filter, and you would only need to append includeAll=true parameter to retrieve all users, including disabled ones.

That’s why I’ve only made a pull request to update the REST API documentation:

https://github.com/openmrs/openmrs-contrib-rest-api-docs/pull/141

Summary

That’s it for the week. It was a fairly productive one, mainly because I’m in the middle of preparing for my final exams at the university :)

Next week, I will try to implement a more significant task - RESTWS-823. It will involve me creating a REST resource from scratch.

Take care and stay safe!

Resources: