-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to find out if roles have been retirable/voidable before, feel free to check the database table to see if it has these fields.
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually did that and thats why i have made sure theyre not persisted. I guess my confusion is on the rest side especially how to handle https://rest.openmrs.org/#delete-a-role. In the previous implementation, i believe delete was done by https://github.com/openmrs/openmrs-module-webservices.rest/blob/893152380641452f75696a7fc35609fcbb7613a0/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/resource/impl/MetadataDelegatingCrudResource.java#L128-L137. So my thinking here is to be able to have the same implementation for the role resource.
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was that delete done for Role?
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the roleresource1_8 class, we instead have purge method
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purge method is simply doing this:
Context.getUserService().purgeRole(role)
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since i am extending the DelegatingCrudResource class implementing delete is inevitable and i was informed by these two test cases
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those two tests are not correct, because the Role property does not have any retire fields in the database. So it does not save them.
If you put these two lines after
handle(req)
, the test would fail.Context.flushSession(); Context.clearSession();
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that makes sense!
Lemi correct all this in my next commit
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa Should the delete method return the resourcenotsupported exception?
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you point me to the exact delete method that you are talkin about?
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/openmrs/openmrs-module-webservices.rest/blob/9c492c03034bbd563a21d7cc27b121e9e5339430/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java#L303
2d80f75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that one we can throw an UnsupportedOperationException