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

bindu | BAH-314 | Added functionality to create a report request using RequestRequest resource #24

Closed
wants to merge 3 commits into from

Conversation

binduak
Copy link
Contributor

@binduak binduak commented Dec 14, 2017

No description provided.

@binduak
Copy link
Contributor Author

binduak commented Dec 14, 2017

For detailed discussion on this PR, please check this Bahmni talk.

Copy link
Member

@djazayeri djazayeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just made a few comments, but since @mseaton has been more engaged with this ticket I would expect that his comments are more valuable.

@@ -0,0 +1,79 @@
/**
* The contents of this file are subject to the OpenMRS Public License
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong license. We now use MPLv2. See http://openmrs.org/license/
(You can probably copy this from some existing file elsewhere into your IntelliJ settings.)


@Override
public SimpleObject asRepresentation(Mapped<ReportDefinition> instance, Representation rep) throws ConversionException {
System.out.println("In MappedReportDefinitionConverter asRepresentation()");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't leave a println here.
I assume that return(null) isn't right either, is it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

/**
* {@link Converter} for {@link RenderingMode}s
*/
@Handler(supports = Mapped.class, order = 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to handle all Mapped, not just Mapped so I think you may need to generalize this to handle more than just Mapped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djazayeri do you mean that this class should be extending Converter<Mapped<T extends Parameterizable>> rather than being a special case for ReportDefinition (aka Converter<Mapped<ReportDefinition>>)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mks-d yes I think that is right. The converter says it handles Mapped, so we need to handle Mapped. If we want to code specifically for a Mapped we can do that in a switch and throw an UnsupportedOperationException if it is not a ReportDefinition I suppose, but otherwise we should handle it generically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mseaton @djazayeri The Mapped class is created by the Handler dynamically. The type associated with the relevant Mapped class will not be available at runtime. So I couldn't make it generalised.

public void setProperty(Object mapped, String propertyName, Object value) throws ConversionException {
try {
if ("parameterizable".equals(propertyName)) {
value = ConversionUtil.convert(value, ReportDefinition.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd want to generalize this line to handle all Mapped...

Copy link
Member

@mseaton mseaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on review comments, I believe this is some more work to do before we can merge this in. See comments above.


/**
* {@link Converter} for {@link RenderingMode}s
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc is incorrect


@Override
public SimpleObject asRepresentation(Mapped<ReportDefinition> instance, Representation rep) throws ConversionException {
System.out.println("In MappedReportDefinitionConverter asRepresentation()");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

/**
* {@link Converter} for {@link RenderingMode}s
*/
@Handler(supports = Mapped.class, order = 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mks-d yes I think that is right. The converter says it handles Mapped, so we need to handle Mapped. If we want to code specifically for a Mapped we can do that in a switch and throw an UnsupportedOperationException if it is not a ReportDefinition I suppose, but otherwise we should handle it generically

assertEquals(response.get("status"), ReportRequest.Status.REQUESTED);
assertEquals(response.get("priority"), ReportRequest.Priority.NORMAL);
SimpleObject resultObject = (SimpleObject) response.get("renderingMode");
String rendererType = (String) resultObject.get("rendererType");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be testing the Mapped is coming back correctly. Is this tested and found to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes @mseaton, this test case is not covering the different Mapped types. I will update in the next PR.

@binduak
Copy link
Contributor Author

binduak commented Dec 26, 2017

As I mentioned in the above comments, I couldn't make the Mapped class generalised. So I had to come up with other approach where I am overriding the setProperty method in ReportRequestResource class. Here I have handle to the particular class type. I will be posting the code block in this talk. @djazayeri @mseaton

…eportingrest into BAH-314

# Conflicts:
#	omod/src/main/java/org/openmrs/module/reportingrest/web/resource/ReportRequestResource.java
#	omod/src/test/java/org/openmrs/module/reportingrest/web/resource/ReportRequestResourceTest.java
@binduak
Copy link
Contributor Author

binduak commented Jan 24, 2018

Closing this PR. Will be raising a new PR with the changes in sometime.

@binduak binduak closed this Jan 24, 2018
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.

4 participants