ATT-42: AttachmentResource* to be documented in Swagger#48
ATT-42: AttachmentResource* to be documented in Swagger#48sherrif10 wants to merge 10 commits intoopenmrs:masterfrom sherrif10:ATT-42
Conversation
| <uiframeworkVersion>3.3.1</uiframeworkVersion> | ||
| <uicommonsVersion>1.4</uicommonsVersion> | ||
| <webservices.restVersion>2.17</webservices.restVersion> | ||
| <webservices.restVersion>2.21.0</webservices.restVersion> |
There was a problem hiding this comment.
Could you now test this with the latest version
There was a problem hiding this comment.
Ohh yeah let me do but i was following @mks-d ideal that it may come up with many dependencies
There was a problem hiding this comment.
Unfortunately i tested this on webservices.rest 2.28.0 but i got error invalidActivationKeyException which means that some methods are not yet introduced into 2.28.0, like how @mks-d suggested in talk thread, upgrading to 2.28.0 would bring such an error
There was a problem hiding this comment.
@sherrif10 That is alittle strange...How uniques are the pom depepndencies here and the ones i used in this Pull Request
There was a problem hiding this comment.
When i run them on my machine i got the similar error i stated above invalidActivationKeyException .
omod-2.0/pom.xml
Outdated
| <artifactId>webservices.rest-omod</artifactId> | ||
| <version>${webservices.restVersion}</version> | ||
| <artifactId>webservices.rest-omod-common</artifactId> | ||
| <version>2.21.0</version> |
There was a problem hiding this comment.
Why are you hard coding the version here yet you have already declared it on line 19?
There was a problem hiding this comment.
${webservices.restVersion} acts as a variable of its version , inotherwords hardcoding it by replacing the reall version doesnot make much difference. i can replace it back without hardcoding it
omod-2.0/pom.xml
Outdated
| <groupId>org.openmrs.module</groupId> | ||
| <artifactId>webservices.rest-omod-common</artifactId> | ||
| <version>${webservices.restVersion}</version> | ||
| <version>2.21.0</version> |
There was a problem hiding this comment.
Why are you hard coding the version here yet you have already declared it on line 19?
There was a problem hiding this comment.
${webservices.restVersion} acts as a variable of its version , inotherwords hardcoding it by replacing the reall version doesnot make much difference. i can replace it back without hardcoding it
| <openMRSVersion>${openMRS2_0Version}</openMRSVersion> | ||
| <emrapiVersion>1.19</emrapiVersion> | ||
| <webservices.restVersion>2.17</webservices.restVersion> | ||
| <webservices.restVersion>2.21.0</webservices.restVersion> |
There was a problem hiding this comment.
Is it necessary to redeclare this property when it is already in the parent pom unless if you want to override the version?
There was a problem hiding this comment.
At first glance i thought of it, however let me try undeclaring it thanks @reagan-meant
|
cc @mks-d @ibacher @reagan-meant i think this is ready to be merged,Anything missing please will be highly appreciated |
samuelmale
left a comment
There was a problem hiding this comment.
Thanks a bunch for working on this.
This is close to complete, I think we need to add some test coverage, and be sure you run:
> mvn clean packageFor proper formatting.
| // @Override | ||
| // public Attachment save(Attachment delegate) { | ||
| // Obs obs = Context.getObsService().saveObs(delegate.getObs(), REASON); | ||
| // return new Attachment(obs); | ||
| // } |
There was a problem hiding this comment.
Did you intend to the leave commented code?
There was a problem hiding this comment.
These were earlier in the commit before my changes, except if am to remove it
omod-2.0/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource2_0.java
Show resolved
Hide resolved
|
@dkayiwa: How does it look now, here is the screen shot of documentation |
|
cc @mozzy11 @sacull, @gitcliff @HerbertYiga , @tendomart , feel free to review since reviewing tickets is part of learning thanks |
| .property("preferredName", new StringProperty().example("uuid")) | ||
| .property("preferredAddress", new StringProperty().example("uuid")) | ||
| .property("attributes", new ArrayProperty(new RefProperty("#/definitions/AttachmentAttributeCreate"))) | ||
|
|
omod-2.0/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource2_0.java
Outdated
Show resolved
Hide resolved
omod-2.0/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource2_0.java
Outdated
Show resolved
Hide resolved
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import org.hibernate.FlushMode; |
There was a problem hiding this comment.
| import org.hibernate.FlushMode; |
You have added an import that you are not using.
There was a problem hiding this comment.
thanks @sacull ,Actually am using this import, let me know if there is something else please
There was a problem hiding this comment.
Oddly, I'm sure these two imports weren't used before and the save(Attachement) method looked different, however, I can't find it in history. Maybe something just happened to me. Bravo for vigilance. ;)
There was a problem hiding this comment.
After the last commit (464f5aa) the save(Attachment) method looks like I remembered it, so again these imports are not used:

There was a problem hiding this comment.
Hey @sacull, shall we go with this idea??, I included screenshots for verification
There was a problem hiding this comment.
@sherrif10 It's not my decision whether to leave it or not, I'm not important enough here. ;)
In addition, I would like to take a better look at this PR to be able to click "Approve" with full responsibility, unfortunately, until the end of the week, I am not able to do it due to lack of time. I'm sorry.
There was a problem hiding this comment.
haa you are more important @sacull, we have learnt clean code from you , keep up
There was a problem hiding this comment.
Yes i responded to his comments above
| import org.hibernate.FlushMode; | ||
| import org.openmrs.Obs; | ||
| import org.openmrs.module.attachments.AttachmentsConstants; | ||
| import org.openmrs.module.emrapi.db.DbSessionUtil; |
There was a problem hiding this comment.
| import org.openmrs.module.emrapi.db.DbSessionUtil; |
Same as above.
There was a problem hiding this comment.
Thanks @sacull, actually i used this package on line 214
omod-2.0/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource2_0.java
Outdated
Show resolved
Hide resolved
| public void purge(Attachment delegate, RequestContext context) throws ResponseException { | ||
| String encounterUuid = delegate.getObs().getEncounter() != null ? delegate.getObs().getEncounter().getUuid() : null; | ||
| Context.getObsService().purgeObs(delegate.getObs()); | ||
| voidEncounterIfEmpty(Context.getEncounterService(), encounterUuid); | ||
| } |
There was a problem hiding this comment.
Is this also required for Swagger documentation? If not, why did you override this? I see your doing great stuff here but I think it maybe out of scope.
Same case for: newDelegate(...), delete(...), getByUniqueId(...)
There was a problem hiding this comment.
@samuelmale thanks , let me cross check that code
There was a problem hiding this comment.
I have resolved that , take a look
| @Override | ||
| public List<String> getPropertiesToExposeAsSubResources() { | ||
| return Arrays.asList("comment", "complexData", "Attributes"); | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm not sure about this method, is the override required for Swagger docs?
There was a problem hiding this comment.
Yes , @samuelmale , this method exposes subresource classes as a resource in swagger docs
There was a problem hiding this comment.
Only one approval from either @sacull @tendomart ,will rescue me
Akayeshmantha
left a comment
There was a problem hiding this comment.
LGTM
Nice work @sherrif10
|
Thanks @Akayeshmantha @dkayiwa any cool response from you, can we merge this please |
|
@sherrif10 great work done. |
| * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() | ||
| */ | ||
| @Override | ||
| public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { |
There was a problem hiding this comment.
@sherrif10 , can you create test for this Update method ??
omod-2.0/src/main/java/org/openmrs/module/attachments/rest/AttachmentResource2_0.java
Show resolved
Hide resolved
|
well done @sherrif10 . can you also write some more tests units for the Attachment Resource Rest Controller ?? like here, |
| String uuid = (String) attachment.get("uuid"); | ||
| Assert.assertNotNull("uuid", obs.getUuid()); | ||
| Assert.assertNotNull("comment", obs.getComment()); | ||
| Assert.assertEquals("complexData", obs.getComplexData(), null); |
There was a problem hiding this comment.
@sherrif10 , you instead need to check the deserialised response , not the very json object you posted
| req.setContent(json.getBytes()); | ||
|
|
||
| String editedAttachment = obs.getUuid(); | ||
| Assert.assertNotEquals("Updated complexData ", editedAttachment.equalsIgnoreCase(editedAttachment)); |
There was a problem hiding this comment.
@sherrif10 , same here , you need to check the deserialized response , not the OBS object you posted
|
cc @mozzy11 this LGTM |
|
cc @dkayiwa @mozzy11 This ticket has been the one delaying the release of attachment module even now. We have done necessary work for it to be merged at least. The work being done can enable this ticket to be merged. So am suggesting we finish this by today because personally am too fixed with other tickets in current ongoing sprint thanks |
|
@sherrif10 have u responded to all the review comments? |
|
@dkayiwa i have responded to every comment above |
|
|
||
| <dependency> | ||
| <groupId>org.openmrs.module</groupId> | ||
| <artifactId>webservices.rest-omod</artifactId> |
There was a problem hiding this comment.
Did you change this accidentally? If not, what was the reason behind the change?
| <openMRSVersion>${openMRS2_0Version}</openMRSVersion> | ||
| <emrapiVersion>1.19</emrapiVersion> | ||
| <webservices.restVersion>2.17</webservices.restVersion> | ||
| <webservices.restVersion>2.21.0</webservices.restVersion> |
There was a problem hiding this comment.
I already saw this in the root pom. Do you need to duplicate it here?
| requestContext.setRequest(request); | ||
|
|
||
| // Replay | ||
| // // Replay |
| BasePageableResult response = (BasePageableResult) res.doSearch(requestContext); | ||
| List<Attachment> actualAttachments = response.getPageOfResults(); | ||
|
|
||
| // |
| result = deserialize(handle(req)); | ||
| } | ||
| catch (Exception e) { | ||
| // TODO Auto-generated catch block |
There was a problem hiding this comment.
| json = new ObjectMapper().writeValueAsString(attributes); | ||
| } | ||
| catch (IOException e) { | ||
| // TODO Auto-generated catch block |
There was a problem hiding this comment.
| result = deserialize(handle(req)); | ||
| } | ||
| catch (Exception e) { | ||
| // TODO Auto-generated catch block |
There was a problem hiding this comment.
| json = new ObjectMapper().writeValueAsString(attachment); | ||
| } | ||
| catch (IOException e) { | ||
| // TODO Auto-generated catch block |
There was a problem hiding this comment.
There was a problem hiding this comment.
Hope using logs to catch exception would work here
|
|
||
| @Override | ||
| public String getDisplayProperty() { | ||
| // TODO Auto-generated method stub |
There was a problem hiding this comment.
Are you suggesting i remove these methods above or whole class ?
|
|
||
| @Override | ||
| public Attachment newObject() { | ||
| return new Attachment(Context.getObsService().getObsByUuid("9b6639b2-5785-4603-a364-075c2d61cd51")); |
There was a problem hiding this comment.
Don't you already have a constant for this?
There was a problem hiding this comment.
True dat, will resolve it soon
| String uuid = (String) attachment.get("uuid"); | ||
| Assert.assertNull(result); | ||
| String createdAttachment = obs.getUuid(); | ||
| Assert.assertNotEquals("Created complexData ", createdAttachment.equalsIgnoreCase(createdAttachment)); |
There was a problem hiding this comment.
The created Attachment , so basically this tests above string
| // Check existence in database | ||
| String uuid = (String) attachment.get("uuid"); | ||
| Assert.assertNull(result); | ||
| String createdAttachment = obs.getUuid(); |
There was a problem hiding this comment.
@sherrif10 ,is this really the created attachment obj??
There was a problem hiding this comment.
Yeah i actually tested the created attachment below with ignorecase character
| } | ||
|
|
||
| Assert.assertNull(result); | ||
| String editedAttachment = obs.getUuid(); |
There was a problem hiding this comment.
Yes this is the editted attachment, the editted attachment was initialised as a getUuid() then i tested it ignoring the case case character, if i had not used the ignoreCaseMethod, the test would fail in this context
|
Is this still available. |
|
Yes thanks. WIll look through and update the need branch. |


https://issues.openmrs.org/browse/ATT-42
cc @dkayiwa @ibacher @mks-d kindly review thanks alot