-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RESTWS-647: Searching for Orderable Concepts #274
Conversation
*/ | ||
@Resource(name = RestConstants.VERSION_1 + "/orderable", supportedClass = Concept.class, supportedOpenmrsVersions = { | ||
"1.11.*", "1.12.*", "2.0.*" }) | ||
public class OrderableResource1_11 extends BaseDelegatingResource<ConceptSearchResult> implements Searchable { |
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.
What happens if this was put in the 1.9 sub module? It is using any api that requires a minimum of platform 1.11?
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 We cannot move it since OrderType is deprecated in 1.9
import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; | ||
import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; | ||
|
||
public class OrderableResource1_11Test extends BaseDelegatingResourceTest<OrderableResource1_11, ConceptSearchResult> { |
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 also add a controller test for this resource? Just like ConceptController1_8Test for the concept resource.
} | ||
} | ||
|
||
if (conceptClasses == null | (conceptClasses != null && conceptClasses.size() == 0)) |
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.
On the above line after == null, was the next supposed to be "|" or "||"?
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.
also if the first case (conceptClasses == null
) is not true you dont need to check again that its not null.
so this is enough
if (conceptClasses == null || conceptClasses.size() == 0)
and I think you should use this
if (conceptClasses == null || conceptClasses.isEmpty())
since this shows your intent more clearly and isEmpty might also be faster than computing the size and checking if that is 0
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.
@teleivo changed to that.
|
||
if (classUuids != null) { | ||
for (String uuid : classUuids) { | ||
ConceptClass cc = getConceptClassByUuid(uuid, orderableConceptClasses); |
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 the above, did you think of using? (ConceptClass) ConversionUtil.convert(uuid, ConceptClass.class)
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.
Switched to this. I was using this function to search for a concept class from the already loaded concept classes instead of loading the class from the database again.
056e516
to
91b94af
Compare
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_11; |
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 would think these should be for 1.10 (since that's when we completely rewrote the order entry API)
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.
@djazayeri moved it to 1.1
* orderable. It returns ConceptSearchResults instead of Concepts | ||
*/ | ||
@Resource(name = RestConstants.VERSION_1 + "/orderable", supportedClass = Concept.class, supportedOpenmrsVersions = { | ||
"1.11.*", "1.12.*" }) |
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.
should also include 2.0.* and 2.1.*, right?
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.
@djazayeri i have included them
@djazayeri Can you advise me on how to handle the tests? They are failing because of Conversion Exceptions |
@vtuwei the conversion exceptions are happening because on your OrderableResource1_10 you have the supportedClass as Concept.class instead of ConceptSearchResult.class |
1cb26af
to
f3da11c
Compare
Thank you @dkayiwa i will add more tests. |
@vtuwei will review again after you have added the missing tests. |
085f704
to
457d658
Compare
@dkayiwa please review |
|
||
private ConceptService service; | ||
|
||
private boolean isIndexUpToDate = false; |
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.
Is the above variable necessary if you used http://junit.sourceforge.net/javadoc/org/junit/BeforeClass.html?
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 onlyOnce expects a static modifier. That means the concept service has to be a static instance.
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.
Does it even have to be an instance variable? 😊
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 not really. Do i switch to the beforeclass annotation?
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 what you are trying to do is setup once for the whole class instead of for each method, then that is exactly what this annotation is meant for. 😊
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 ConceptService cannot be a static instance. The test fails when it is a static instance.
No description provided.