-
Notifications
You must be signed in to change notification settings - Fork 35
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
Prov 103 [issue](https://issues.openmrs.org/browse/PROV-103) #45
Conversation
…via reflection for openmrs version 2.x.x solve a backward incompatibility change
#37 been trying out mostof the methods to see if i can use the object to heres the ticket in question PROV-103 please let me know if there's something am missing or any other step i can make to solve this ticket |
@josephbate can you include a link to the JIRA ticket as advised at? https://wiki.openmrs.org/display/docs/Pull+Request+Tips |
okay let me do that quickly |
sorry for the delay i had power issues but i have edited the post @dkayiwa |
heres the ticket in question PROV-103 please let me know if you see it |
@josephbate could you add it above in the description like here |
Thanks @josephbate . |
hello everyone **My finding currently working on #37 **
`try {
the problem with this approach without using the imported NameSuport class it cannot work, so that means the new version of that class when loaded cannot override the imported because casting the class in the new stance object makes it override it hence giving the same exception so with that i am asking for assistance on this @dkayiwa @mozzy11 |
It would probably be better to do this with MethodHandles, but (without any error handling): Class<?> cls = Class.forName("org.openmrs.layout.name.NameSupport");
Method getInstance = cls.getMethod("getInstance");
Object instance = getInstance.invoke(null);
Method getDefaultLayoutTemplate = cls.getDeclaredMethod("getDefaultLayoutTemplate");
Object layoutTemplate = getDefaultLayoutTemplate.invoke(instance); |
thank you @ibacher |
hello everyone My finding as of #37
thank you so much guys @dkayiwa @gitcliff @mozzy11 @ibacher my issue is ready for review |
|
||
public void controller(FragmentModel model) throws ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { | ||
|
||
Class<?> cls1 = Class.forName("org.openmrs.layout.LayoutSupport"); |
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.
Thanks @josephbate .
can you make this backward compatible , this should only run conditionally in the higher OpenMRS version where we have this change in the class location ,or else we should directly import the class in the older versions of OpenMRS
@@ -14,13 +14,35 @@ | |||
|
|||
package org.openmrs.module.providermanagement.fragment.controller; | |||
|
|||
import org.openmrs.layout.web.name.NameSupport; | |||
import java.lang.reflect.*; |
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.
see our java convetions for imports
https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-Imports
api/src/main/java/org/openmrs/module/providermanagement/ReflectString.java
Outdated
Show resolved
Hide resolved
@josephbate you need to properly configure your IDE to avoid any unnecessary formatting |
@josephbate , you can use this constant to check the running Openmrs version |
Hi Everyone, there is something that is holding this PR to be merged? |
} | ||
|
||
|
||
/** |
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 we're going to include Javadocs, they should actually provide some information.
* @throws IllegalAccessException | ||
*/ | ||
|
||
public void controller(FragmentModel model) throws ClassNotFoundException, NoSuchMethodException, SecurityException, |
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 think at this point, its just easier to say throws Exception
, no?
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, is there nothing we can do here to recover from these exceptions?
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.
do you have any suggestions @ibacher
/* | ||
* backward compatibility | ||
*/ | ||
Class<?> nameSurpport; |
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.
Class<?> nameSurpport; | |
Class<?> nameSupport; |
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.
hello @ibacher thank you for pointing them out let me try to solve them
Hello @ibacher i think i i have resolved some of the problems you pointed out |
api/pom.xml
Outdated
@@ -4,7 +4,7 @@ | |||
<parent> | |||
<groupId>org.openmrs.module</groupId> | |||
<artifactId>providermanagement</artifactId> | |||
<version>2.14.0-SNAPSHOT</version> | |||
<version>2.15.0-SNAPSHOT</version> |
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 not expect version changes to be part of this pull request.
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 not expect version changes to be part of this pull request.
it think the verion i forked is base on 2.15.0- snapshot
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.
Check what the current upstream version is.
|
||
/* | ||
* backward compatibility | ||
* dynamic class loading and reflection to interact with classes that provide layout templates for perso names in the system, allowing for flexibility and extensibility in managing name layouts. |
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 do not see value added by this comment.
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.
hello @dkayiwa i have made some changes please find them in the commit below
@josephbate did you address my comment about the version change? |
done! @dkayiwa |
Can you fix the build errors? |
pom.xml
Outdated
@@ -4,7 +4,7 @@ | |||
|
|||
<groupId>org.openmrs.module</groupId> | |||
<artifactId>providermanagement</artifactId> | |||
<version>2.14.0-SNAPSHOT</version> | |||
<version>2.15.0-SNAPSHOT</version> |
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 is this version change for?
omod/pom.xml
Outdated
@@ -4,7 +4,7 @@ | |||
<parent> | |||
<groupId>org.openmrs.module</groupId> | |||
<artifactId>providermanagement</artifactId> | |||
<version>2.14.0-SNAPSHOT</version> |
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 is this version change 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.
i was reacting to this comment, and was restoring the prevoius version before my commits
intially i had som build failures thats why i made switch
i think everything works fine! |
Can you look at these build failures? |
And also fix the build failures. |
Issue in Question
(link:https://issues.openmrs.org/browse/PROV-103?src=confmacro)
getting Errors in deploying the module
i made changes in the omod config.xml however i didnt see the changes when i deployed my omod file in the server, i keted on getting the same error
so used print statements to check if the omad file was picked up but that didn't reflect in my logs
i release there was a worning of my server configuration not existing when i selected the providerSearch option
WARN - OpenmrsUtil.getDirectoryInApplicationDataDirectory(1155) |2022-11-14 18:17:07,548| 'C:\Users\toshiba\openmrs\server2\configuration' doesn't exist. Creating directories now.
i assume in some way the omod file is not detected by the server or there is something i missed
@dkayiwa @mozzy11 @ibacher @gitcliff