Skip to content
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

Merged
merged 1 commit into from
Apr 12, 2017

Conversation

vtuwei
Copy link
Contributor

@vtuwei vtuwei commented Mar 21, 2017

No description provided.

@mention-bot
Copy link

@vtuwei, thanks for your PR! By analyzing the history of the files in this pull request, we identified @dkayiwa and @teleivo to be potential reviewers.

*/
@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 {
Copy link
Member

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?

Copy link
Contributor Author

@vtuwei vtuwei Mar 27, 2017

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> {
Copy link
Member

@dkayiwa dkayiwa Mar 22, 2017

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))
Copy link
Member

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 "||"?

Copy link
Member

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

Copy link
Contributor Author

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);
Copy link
Member

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)

Copy link
Contributor Author

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.

@vtuwei vtuwei force-pushed the RESTWS-647 branch 8 times, most recently from 056e516 to 91b94af Compare March 27, 2017 08:56
* 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;
Copy link
Member

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)

Copy link
Contributor Author

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.*" })
Copy link
Member

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?

Copy link
Contributor Author

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

@vtuwei
Copy link
Contributor Author

vtuwei commented Mar 29, 2017

@djazayeri Can you advise me on how to handle the tests? They are failing because of Conversion Exceptions

@dkayiwa
Copy link
Member

dkayiwa commented Mar 29, 2017

@vtuwei the conversion exceptions are happening because on your OrderableResource1_10 you have the supportedClass as Concept.class instead of ConceptSearchResult.class

@vtuwei vtuwei force-pushed the RESTWS-647 branch 2 times, most recently from 1cb26af to f3da11c Compare March 30, 2017 09:38
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 45.252% when pulling f3da11c on vtuwei:RESTWS-647 into 9d8cbf6 on openmrs:master.

@vtuwei
Copy link
Contributor Author

vtuwei commented Mar 30, 2017

Thank you @dkayiwa i will add more tests.

@dkayiwa
Copy link
Member

dkayiwa commented Mar 30, 2017

@vtuwei will review again after you have added the missing tests.

@vtuwei vtuwei force-pushed the RESTWS-647 branch 2 times, most recently from 085f704 to 457d658 Compare April 3, 2017 08:35
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 45.765% when pulling 457d658 on vtuwei:RESTWS-647 into 9d8cbf6 on openmrs:master.

@vtuwei
Copy link
Contributor Author

vtuwei commented Apr 3, 2017

@dkayiwa please review


private ConceptService service;

private boolean isIndexUpToDate = false;
Copy link
Member

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?

Copy link
Contributor Author

@vtuwei vtuwei Apr 10, 2017

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.

Copy link
Member

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? 😊

Copy link
Contributor Author

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?

Copy link
Member

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. 😊

Copy link
Contributor Author

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 45.786% when pulling f341eeb on vtuwei:RESTWS-647 into 5202e54 on openmrs:master.

@dkayiwa dkayiwa merged commit 850202b into openmrs:master Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants