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

TRUNK-5793: AllergyReaction Domain - Switching from Hibernate Mappings to Annotations #4824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions api/src/main/java/org/openmrs/AllergyReaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,49 @@
package org.openmrs;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;
import org.openmrs.util.OpenmrsUtil;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
* Represent allergy reactions
*/
@Entity
@Table(name = "allergy_reaction")
@Audited
public class AllergyReaction extends BaseOpenmrsObject implements java.io.Serializable{

public static final long serialVersionUID = 1;


@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "allergy_reaction_id_seq")
@GenericGenerator(
name = "allergy_reaction_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "allergy_reaction_allergy_reaction_id_seq")
)
@Column(name = "allergy_reaction_id")
private Integer allergyReactionId;


@ManyToOne
@JoinColumn(name = "allergy_id", nullable = false)
private Allergy allergy;


@ManyToOne
@JoinColumn(name = "reaction_concept_id", nullable = false)
private Concept reaction;


@Column(name = "reaction_non_coded")
private String reactionNonCoded;

/**
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<property name="hibernate.search.model_mapping">org.openmrs.api.db.hibernate.search.LuceneAnalyzerFactory</property>

<!-- API -->

<mapping resource="org/openmrs/api/db/hibernate/AllergyReaction.hbm.xml" />

<mapping resource="org/openmrs/api/db/hibernate/Concept.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAnswer.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAttribute.hbm.xml" />
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.jupiter.api.Test;

import org.openmrs.Allergy;
import org.openmrs.AllergyReaction;
import org.openmrs.CareSetting;
import org.openmrs.Concept;
import org.openmrs.ConceptClass;
Expand Down Expand Up @@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(AllergyReaction.class)
.getMetadataBuilder().build();


Expand Down
Loading