Skip to content

Commit 6acd8ed

Browse files
TRUNK-5948: Conversion of LocationAttribute from xml based to annotation based (#5559)
1 parent 9bc9b21 commit 6acd8ed

File tree

4 files changed

+19
-54
lines changed

4 files changed

+19
-54
lines changed

api/src/main/java/org/openmrs/LocationAttribute.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
package org.openmrs;
1111

1212
import org.hibernate.envers.Audited;
13+
import jakarta.persistence.Entity;
14+
import jakarta.persistence.Table;
15+
import jakarta.persistence.AssociationOverride;
16+
import jakarta.persistence.JoinColumn;
17+
import jakarta.persistence.Id;
18+
import jakarta.persistence.GeneratedValue;
19+
import jakarta.persistence.GenerationType;
20+
import jakarta.persistence.Column;
1321
import org.openmrs.attribute.Attribute;
1422
import org.openmrs.attribute.BaseAttribute;
1523

@@ -19,8 +27,17 @@
1927
* @since 1.9
2028
*/
2129
@Audited
30+
@Entity
31+
@Table(name = "location_attribute")
32+
@AssociationOverride(
33+
name="owner",
34+
joinColumns = @JoinColumn(name="location_id", nullable = false)
35+
)
2236
public class LocationAttribute extends BaseAttribute<LocationAttributeType, Location> implements Attribute<LocationAttributeType, Location> {
2337

38+
@Id
39+
@GeneratedValue(strategy = GenerationType.IDENTITY)
40+
@Column(name="location_attribute_id")
2441
private Integer locationAttributeId;
2542

2643
// BaseAttribute<Location> has an "owner" property of type Location, which we re-expose as "location"

api/src/main/resources/hibernate.cfg.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
<mapping resource="org/openmrs/api/db/hibernate/OrderSetAttribute.hbm.xml" />
4949
<mapping resource="org/openmrs/api/db/hibernate/OrderGroupAttribute.hbm.xml" />
5050
<mapping resource="org/openmrs/api/db/hibernate/OrderGroupAttributeType.hbm.xml" />
51-
<mapping resource="org/openmrs/api/db/hibernate/LocationAttribute.hbm.xml" />
5251
<mapping resource="org/openmrs/api/db/hibernate/EncounterType.hbm.xml" />
5352
<mapping resource="org/openmrs/api/db/hibernate/EncounterProvider.hbm.xml" />
5453
<mapping resource="org/openmrs/api/db/hibernate/ProgramWorkflow.hbm.xml" />

api/src/main/resources/org/openmrs/api/db/hibernate/LocationAttribute.hbm.xml

Lines changed: 0 additions & 53 deletions
This file was deleted.

api/src/test/java/org/openmrs/api/OrderServiceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import org.openmrs.VisitAttributeType;
8585
import org.openmrs.FormResource;
8686
import org.openmrs.ConceptAttribute;
87+
import org.openmrs.LocationAttribute;
8788
import org.openmrs.api.builder.DrugOrderBuilder;
8889
import org.openmrs.api.builder.OrderBuilder;
8990
import org.openmrs.api.context.Context;
@@ -2941,6 +2942,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
29412942
.addAnnotatedClass(ConceptDatatype.class)
29422943
.addAnnotatedClass(ProviderAttribute.class)
29432944
.addAnnotatedClass(ConceptAttribute.class)
2945+
.addAnnotatedClass(LocationAttribute.class)
29442946
.getMetadataBuilder().build();
29452947

29462948

0 commit comments

Comments
 (0)