June 26, 2021 Update
Still getting the transient object 500 error even after wrapping the code in a try-catch block and persisting the object inside the catch. Tomorrow I will be looking into the error and will try to find a solution for it.
June 28, 2021 Update
I tried to use try-catch blocks and somehow persist the metadata objects, now it works but only when imported into a new instance. If I import it into the same instance I get this error because it’s trying to persist an object that is already existing (conflicting UUIDs). I think it solvable by not saving the object if the same UUID already exists. Tomorrow I’m gonna try that.
June 30, 2021 Update
The export and import features are now working fine, it is able to export the mapping files and all the related metadata including period indicator report definitions, cohort indicator data set definitions, cohort definitions, dimensions, and indicators. It now can without any errors import those metadata too. the metadata show up in the relevant places in the reporting module UI. But for some reason, it doesn’t map the period indicator report with the other metadata and when I try to run the report I get this error.
org.openmrs.module.reporting.evaluation.EvaluationException: Failed to evaluate Error evaluating because:
Cannot find parameter 'endDate' in org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition null
Off the top of my head, I’m thinking of adding a new header file into the export bundle and map the metadata properly on the import to solve this issue.
Tomorrow I’ll be trying to find out the root cause for this behaviour and try to solve the issue.
July 2, 2021 Update
Today I tried to find out why the imported objects don’t work the way they are supposed to, turns out when the
serializedData string in
serializedObjects is deserialized back into original objects it automatically sets attributes like
CohortDefinitons, etc… to null.
XStreamShortSerializer to deserialize the XML string. I wonder how it’s done in the metadata sharing module. I had a look but I couldn’t find exactly how it’s working there.