Skip to content

Commit

Permalink
TRUNK-6270: PatientIdentifierType - Switching from Hibernate Mapping …
Browse files Browse the repository at this point in the history
…to JPA annotations (openmrs#4774)
  • Loading branch information
wikumChamith authored Oct 7, 2024
1 parent 5b415de commit eb2333a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 105 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/BaseOpenmrsMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class BaseOpenmrsMetadata extends BaseOpenmrsObject implements O
@Field
private String name;

@Column(name = "description", length = 255)
@Column(name = "description", columnDefinition = "clob")
private String description;

@ManyToOne(optional = false)
Expand Down
36 changes: 32 additions & 4 deletions api/src/main/java/org/openmrs/PatientIdentifierType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@
package org.openmrs;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**
* PatientIdentifierType
*/
@Entity
@Table(name = "patient_identifier_type")
@Audited
@AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "name", nullable = false, length = 50))
})
public class PatientIdentifierType extends BaseChangeableOpenmrsMetadata {

public static final long serialVersionUID = 211231L;
Expand Down Expand Up @@ -61,19 +77,31 @@ public enum UniquenessBehavior {

// Fields
@DocumentId
@Id
@GeneratedValue(generator = "native")
@GenericGenerator(name = "native", strategy = "native")
@Column(name = "patient_identifier_type_id")
private Integer patientIdentifierTypeId;


@Column(name = "format")
private String format;

@Field
@Column(name = "required", nullable = false)
private Boolean required = Boolean.FALSE;


@Column(name = "format_description", length = 250)
private String formatDescription;

@Column(name = "validator", length = 200)
private String validator;


@Enumerated(EnumType.STRING)
@Column(name = "location_behavior", length = 50)
private LocationBehavior locationBehavior;


@Enumerated(EnumType.STRING)
@Column(name = "uniqueness_behavior", length = 50)
private UniquenessBehavior uniquenessBehavior;

/** default constructor */
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 @@ -60,7 +60,6 @@
<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/PatientIdentifierType.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" />
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 @@ -52,6 +52,7 @@
import org.openmrs.OrderSet;
import org.openmrs.OrderType;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifierType;
import org.openmrs.PatientState;
import org.openmrs.PersonAddress;
import org.openmrs.PersonAttributeType;
Expand Down Expand Up @@ -2733,6 +2734,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(PatientState.class)
.addAnnotatedClass(DrugIngredient.class)
.addAnnotatedClass(AlertRecipient.class)
.addAnnotatedClass(PatientIdentifierType.class)
.getMetadataBuilder().build();


Expand Down

0 comments on commit eb2333a

Please sign in to comment.