Skip to content

Conversation

@snowvirus
Copy link

Description of the PR

This PR refactors the ConceptProposal class to use JPA annotations, replacing the previous Hibernate XML mapping. The changes include:

  • Annotated ConceptProposal.java with JPA annotations like @entity, @table, @id, @manytoone, etc.

  • Removed ConceptProposal.hbm.xml

  • Updated hibernate.cfg.xml to remove reference to the XML mapping

--- Adjusted related test datasets and test cases:

--standardTestDataset.xml

--standardTest-1.9.7-dataSet.xml

--ConceptServiceTest-proposals.xml

  • Modified ConceptServiceImplTest to work with the updated mapping

Why.

  • To modernize the codebase by using annotation-based ORM, improving maintainability and aligning with current best practices.

Issue I worked on

see jira_issue

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@snowvirus
Copy link
Author

@dkayiwa @ibacher @vasharma05
a review please

@snowvirus
Copy link
Author

Am requesting 4 a review please @dkayiwa @ibacher @vasharma05

private String locale;

@Column(name = "uuid", nullable = false, unique = true, length = 38)
private String uuid;
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 inherited from the base object.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @ibacher, you're right — uuid is inherited from BaseOpenmrsObject. I'll remove the duplicate declaration

Comment on lines 95 to 96
@Column(name = "locale", nullable = false)
private String locale;
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why migrating to Hibernate annotations requires that we add properties. That sort of thing should be moved to a separate PR.

Copy link
Author

Choose a reason for hiding this comment

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

ok. am to do it

Comment on lines 222 to 265
public String getUuid() {
return uuid;
}

public void setUuid(String uuid) {
this.uuid = uuid;
}
Copy link
Member

Choose a reason for hiding this comment

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

Already inherited.

Copy link
Author

Choose a reason for hiding this comment

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

Good point, thanks! I'll remove the duplicate uuid methods since they’re inherited already

* Convenience method to mark this proposal as rejected. Be sure to call
* Context.getConceptService().saveConceptProposal(this) after calling this method
*/
public void rejectConceptProposal() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be in this PR.

Comment on lines 241 to 246
public String toString() {
if (conceptProposalId == null) {
return "";
}
return conceptProposalId.toString();
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be in this PR.

<mapping resource="org/openmrs/api/db/hibernate/ConceptClass.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptDatatype.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptProposal.hbm.xml" />
<mapping class="org.openmrs.ConceptProposal"/>
Copy link
Member

Choose a reason for hiding this comment

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

This isn't how we've handled any other of the migrations. Please look at similar tickets for how this is done.

<concept_proposal concept_proposal_id="8" original_text="not married" state="UNMAPPED" encounter_id="3" obs_concept_id="21" creator="1" date_created="2009-06-03 13:55:12.0" uuid="87a68666-5067-11de-80cb-001e378eb67e"/>
<concept_proposal concept_proposal_id="9" original_text="not married" state="UNMAPPED" encounter_id="4" obs_concept_id="4" creator="1" date_created="2009-06-03 13:55:12.0" uuid="97a68666-5067-11de-80cb-001e378eb67e"/>
<concept_proposal concept_proposal_id="10" original_text="single" state="UNMAPPED" encounter_id="3" obs_concept_id="4" creator="1" date_created="2009-06-03 13:55:12.0" uuid="88a68666-5067-11de-80cb-001e378eb67e"/>
<concept_proposal concept_proposal_id="5" original_text="not married" state="UNMAPPED" encounter_id="3" obs_concept_id="4" creator="1" date_created="2009-06-03 13:55:12.0" uuid="67a68666-5067-11de-80cb-001e378eb67e" locale="en"/>
Copy link
Member

Choose a reason for hiding this comment

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

Changing to Hibernate Annotations should not require changes to test data. That's a sign this PR is doing more than it should. PRs should be focused on a minimal set of changes that belong together so that we can back them out with minimal disruption.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for pointing that out! I’ll revert the test data changes to keep this PR focused strictly on the annotations migration

@snowvirus snowvirus closed this Apr 21, 2025
@snowvirus snowvirus force-pushed the TRUNK-5900-conceptproposal-annotations branch from 5b9fdf3 to eab865d Compare April 21, 2025 06:02
@snowvirus
Copy link
Author

i did something terrible. to reset all my changes. but i request to reopen this branch if possible
@ibacher @dkayiwa @teleivo

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.

2 participants