This week, I focused on addressing several issues in my implementation of building O3 using the OpenMRS SDK. Additionally, I initiated the transition of the OpenMRS SDK from Java 7 to Java 8. Let's dive into the problems we encountered during the implementation:
Changing to module installer for downloading configuration
Instead of using the previous approach of owaHelper.downloadOwa(configDir, config, moduleInstaller)
to download O3 configurations, we simplified the process by switching to moduleInstaller.installModules(configs, configDir.getPath())
Unable to build the O3 outside the SDK source folder
While testing my code, I overlooked an issue that my mentor Daniel discovered when testing the initial release. When attempting to deploy O3 with the SDK outside the source folder, two issues were encountered:
- The SDK only displayed Reference Application 3.0.0-SNAPSHOT as the available version.
- Users encountered the following error:
Unable to find/resolve artifact. Failure to find org.openmrs.module:initializer-omod:jar:2.5.0 in https://mavenrepo.openmrs.org/public was cached in the local repository, resolution will not be reattempted until the update interval of openmrs-repo has elapsed or updates are forced
To resolve these issues, we have to add the following code to settings.xml:
<repository>
<id>mks-nexus-public</id>
<name>Mekom Repository</name>
<url>https://nexus.mekomsolutions.net/repository/maven-public</url>
</repository>
I updated the documentation to reflect these changes. You can find the updated version of the documentation here.
Additionally, I plan to create a forum post inviting the community to try setting up an O3 backend server using the SDK. This will help us gather feedback from the community and make any necessary adjustments.
I also created this PR to address any post commit issues.
Transition to Java 8
As part of the GSoC project, one of the key goals is to modernize the OpenMRS SDK code base by transitioning from Java 7 to Java 8. To initiate this transition, the first step is to switch the Java version to 8 for the Maven plugin.
After thoroughly testing and ensuring that the code is functioning correctly with Java 8, I created a pull request (PR) to implement the necessary changes. You can find the PR here.
Future
In order to modernize the OpenMRS SDK with Java 8, there are several key areas where improvements can be made. Here are some of the planned changes:
- Lambda Expressions: Replace anonymous inner classes with lambda expressions where appropriate. Lambda expressions provide a more concise and expressive way to write code, making it easier to work with functional interfaces and improve readability.
- Streams API: Utilize the Streams API for working with collections and performing various operations such as filtering, mapping, and reducing. Streams offer a declarative and functional approach to data processing, resulting in more concise and efficient code.
- Date and Time API: Replace the older java.util.Date and java.util.Calendar classes with the new Date and Time API introduced in Java 8. The new API provides improved functionality for date and time manipulation, formatting, and parsing, making code more robust and less error-prone.
- Optional Class: Adopt the use of the Optional class to handle nullable values. Optional provides a safer and more expressive way to deal with situations where a value may or may not be present, helping to avoid null pointer exceptions and improve code clarity.
By incorporating these features and best practices introduced in Java 8, the OpenMRS SDK can benefit from enhanced readability, maintainability, and performance. It will also align the codebase with modern Java development standards and make it easier for developers to work with the SDK.
Thank you for reading, see you next week!