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-5866: Migrate OrderSet from Hibernate Mapping XML to JPA annotations. #4890

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
update order set with annotations
dilankavishka committed Jan 19, 2025
commit 2cc16de79d34c1098c6cf1d9fc6ff0469f757701
28 changes: 26 additions & 2 deletions api/src/main/java/org/openmrs/OrderSet.java
Original file line number Diff line number Diff line change
@@ -12,15 +12,21 @@
import java.util.ArrayList;
import java.util.List;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;
import org.openmrs.api.APIException;

import javax.persistence.*;

/**
* Represents the grouping of orders into a set,
* so as to give decision support for the doctors
*
* @since 1.12
*/
@Entity
@Table(name = "order_set")
@Audited
public class OrderSet extends BaseCustomizableMetadata<OrderSetAttribute> {

@@ -36,12 +42,30 @@ public enum Operator {
ALL, ONE, ANY
}

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_set_id_seq")
@GenericGenerator(
name = "order_set_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "order_set_order_set_id_seq")
)
@Column(name = "order_set_id", nullable = false)
private Integer orderSetId;


@Column(name = "operator", nullable = false)
@Enumerated(EnumType.STRING)
private Operator operator;


@OneToMany(
mappedBy = "orderSet",
cascade = CascadeType.ALL,
orphanRemoval = true
)
@OrderColumn(name = "sequence_number")
private List<OrderSetMember> orderSetMembers;

@ManyToOne
@JoinColumn(name = "category")
private Concept category;

/**
1 change: 0 additions & 1 deletion api/src/main/resources/hibernate.cfg.xml
Original file line number Diff line number Diff line change
@@ -66,7 +66,6 @@
<mapping resource="org/openmrs/api/db/hibernate/Order.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderAttributeType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderSet.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderSetMember.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderSetAttributeType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/OrderSetAttribute.hbm.xml" />

This file was deleted.

1 change: 1 addition & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
@@ -2740,6 +2740,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(OrderSet.class)
.getMetadataBuilder().build();