Skip to content

TRUNK-5906 : ConceptReferenceTerm Domain - Switching from Hibernate Mappings to Annotations #4907

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 29 additions & 2 deletions api/src/main/java/org/openmrs/ConceptReferenceTerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import javax.persistence.Table;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.util.HashSet;

/**
* A concept reference term is typically name for a concept by which it is referred in another
Expand All @@ -25,22 +37,37 @@
* @since 1.9
*/
@Audited
@Entity
@Table(name = "concept_reference_term")
public class ConceptReferenceTerm extends BaseChangeableOpenmrsMetadata {

private static final long serialVersionUID = 1L;

@DocumentId
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "concept_reference_term_id_seq")
@GenericGenerator(
name = "concept_reference_term_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "concept_reference_term_concept_reference_term_id_seq")
)
@Column(name = "concept_reference_term_id")
private Integer conceptReferenceTermId;

@ManyToOne
@JoinColumn(name = "concept_source_id", nullable = false)
private ConceptSource conceptSource;

//The unique code used to identify the reference term in it's reference terminology
@Field(analyze = Analyze.NO)
@Column(name = "code", length = 255, nullable = false)
private String code;

@Column(name = "version", length = 50)
private String version;

private Set<ConceptReferenceTermMap> conceptReferenceTermMaps;
@OneToMany(mappedBy = "termA", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<ConceptReferenceTermMap> conceptReferenceTermMaps = new HashSet<>();

/** default constructor */
public ConceptReferenceTerm() {
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 @@ -38,7 +38,6 @@
<mapping resource="org/openmrs/api/db/hibernate/ConceptMap.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptStopWord.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptSource.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptReferenceTerm.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptReferenceTermMap.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DiagnosisAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DiagnosisAttributeType.hbm.xml" />
Expand Down

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
Expand Up @@ -2742,6 +2742,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(ConceptReferenceTerm.class)
.getMetadataBuilder().build();


Expand Down