Role anonymous = Context.getUserService().getRole("Anonymous");
Role sysdev = Context.getUserService().getRole("System Developer");
anonymous.getChildRoles().add(sysdev);
sysdev.getInheritedRoles().add(anonymous);
Context.getUserService().saveRole(anonymous);
Context.getUserService().saveRole(sysdev);
Context.flushSession();
You get “Unique index or primary key violation” as it tries to put the relationship twice into role_role.
I would actually expect that when you call sysdev.getInheritedRoles().add(anonymous); then it should call anonymous.getChildRoles().add(sysdev); to maintain consistency
Here I couldn’t understand the scene behind this following text,
You get “Unique index or primary key violation” as it tries to put the relationship twice into role_role.
It would be really helpful, if some body guide to understand this description?
Since this was written a couple of years ago, there is a possibility that it was fixed. Can you first of all create a unit test reproducing it on the latest snapshot of openmrs core?
The issue mentioned above does not exist in the system right now. I have added the test case to ensure that problem is solved. I have sent a PR to OpenMRS Core with a test case.
I have tried to do a sanity check on the 1.9.7 tag with this test cases. But I got an unexpected results due to some other problems. I have attached the logs[1] here.
@dkayiwa Could you please help to resolve this one?
Unfortunately, I couldn’t setup my environment with Java 7 right now (I already installed Java 8 in Ubuntu 17.10). Let me find the problem and continue the work.