Skip to content

Commit

Permalink
TRUNK-5946: ProgramAttributeType Domain - Switching from Hibernate Ma…
Browse files Browse the repository at this point in the history
…ppings to Annotations (#4777)

* TRUNK-5946: ProgramAttributeType Domain switching from XML Mappings to Annotations

* TRUNK-5946: Updated OrderService test

* TRUNK-5946: added ID generating sequence
  • Loading branch information
ManojLL authored Oct 26, 2024
1 parent 5dfd740 commit b2bd587
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 64 deletions.
20 changes: 20 additions & 0 deletions api/src/main/java/org/openmrs/ProgramAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,32 @@

package org.openmrs;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;
import org.openmrs.attribute.AttributeType;
import org.openmrs.attribute.BaseAttributeType;

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

@Entity
@Table(name = "program_attribute_type")
@Audited
public class ProgramAttributeType extends BaseAttributeType<PatientProgram> implements AttributeType<PatientProgram> {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "program_attribute_type_id_seq")
@GenericGenerator(
name = "program_attribute_type_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "program_attribute_type_program_attribute_type_id_seq")
)
@Column(name = "program_attribute_type_id")
private Integer programAttributeTypeId;

@Override
Expand Down
1 change: 0 additions & 1 deletion api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
<mapping resource="org/openmrs/api/db/hibernate/EncounterProvider.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/EncounterRole.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Program.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramAttributeType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflow.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflowState.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Cohort.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 @@ -56,6 +56,7 @@
import org.openmrs.PatientState;
import org.openmrs.PersonAddress;
import org.openmrs.PersonAttributeType;
import org.openmrs.ProgramAttributeType;
import org.openmrs.Provider;
import org.openmrs.ProviderAttributeType;
import org.openmrs.Relationship;
Expand Down Expand Up @@ -2736,6 +2737,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(DrugIngredient.class)
.addAnnotatedClass(AlertRecipient.class)
.addAnnotatedClass(PatientIdentifierType.class)
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.getMetadataBuilder().build();

Expand Down

0 comments on commit b2bd587

Please sign in to comment.