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-5836: ConceptDatatype Domain - Switching from Hibernate Mappings to Annotations #4854

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
23 changes: 21 additions & 2 deletions api/src/main/java/org/openmrs/ConceptDatatype.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
*/
package org.openmrs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.annotations.GenericGenerator;
import com.google.errorprone.annotations.Immutable;
rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved


rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved
/**
* ConceptDatatype
*/
@Entity
@Table(name="concept_datatype")
rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved
@Audited
public class ConceptDatatype extends BaseChangeableOpenmrsMetadata {

Expand Down Expand Up @@ -65,9 +76,17 @@ public class ConceptDatatype extends BaseChangeableOpenmrsMetadata {
public static final String COMPLEX_UUID = "8d4a6242-c2cc-11de-8d13-0010c6dffd0f";

// Fields
@DocumentId
rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "concept_datatype_id_seq")
@GenericGenerator(
name = "concept_datatype_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "_datatype_concept_datatype_id_seq")
rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved
)
@Column(name = "concept_datatype_Id")
private Integer conceptDatatypeId;

@Column(name = "hl7abbreviation")
rishabhrawat05 marked this conversation as resolved.
Show resolved Hide resolved
private String hl7Abbreviation;

// Constructors
Expand Down
5 changes: 2 additions & 3 deletions api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<mapping resource="org/openmrs/api/db/hibernate/ConceptName.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptNameTag.hbm.xml" />
<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 resource="org/openmrs/api/db/hibernate/ConceptStateConversion.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptSet.hbm.xml" />
Expand Down Expand Up @@ -60,8 +59,8 @@
<mapping resource="org/openmrs/api/db/hibernate/Role.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Patient.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/PatientIdentifier.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/PatientProgram.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/PatientProgramAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/PatientProgram.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/PatientProgramAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/RelationshipType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Order.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderAttribute.hbm.xml" />
Expand Down

This file was deleted.

13 changes: 9 additions & 4 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2719,10 +2719,14 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
.configure().applySettings(configuration.getProperties()).build();

Metadata metaData = new MetadataSources(standardRegistry).addAnnotatedClass(Allergy.class)
.addAnnotatedClass(Encounter.class).addAnnotatedClass(SomeTestOrder.class)
.addAnnotatedClass(Diagnosis.class).addAnnotatedClass(Condition.class)
.addAnnotatedClass(Visit.class).addAnnotatedClass(VisitAttributeType.class)
Metadata metaData = new MetadataSources(standardRegistry)
.addAnnotatedClass(Allergy.class)
.addAnnotatedClass(Encounter.class)
.addAnnotatedClass(SomeTestOrder.class)
.addAnnotatedClass(Diagnosis.class)
.addAnnotatedClass(Condition.class)
.addAnnotatedClass(Visit.class)
.addAnnotatedClass(VisitAttributeType.class)
.addAnnotatedClass(MedicationDispense.class)
.addAnnotatedClass(ProviderAttributeType.class)
.addAnnotatedClass(ConceptMapType.class)
Expand All @@ -2740,6 +2744,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(ConceptDatatype.class)
.getMetadataBuilder().build();


Expand Down
Loading