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-5803: Migrate ConceptAnswer from Hibernate Mapping XML to JPA #4895

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions api/src/main/java/org/openmrs/ConceptAnswer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

import org.hibernate.envers.Audited;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
Expand All @@ -20,34 +29,64 @@
*
* @see Concept#getAnswers()
*/
@Entity
@Table(name = "concept_answer")
@Audited
public class ConceptAnswer extends BaseOpenmrsObject implements Auditable, java.io.Serializable, Comparable<ConceptAnswer> {


public static final long serialVersionUID = 3744L;


// Fields
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "concept_answer_id",nullable = false,updatable = false)
private Integer conceptAnswerId;

/**
* The question concept that this object is answering
*/
@NotNull
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@Column(name = "concept_id", nullable = false)
private Concept concept;

/**
* The answer to the question
*/
@NotNull
@ManyToOne(fetch = FetchType.LAZY,optional = false)
@Column(name = "answer_concept", nullable = false)
private Concept answerConcept;

/**
* The {@link Drug} answer to the question. This can be null if this does not represent a drug
* type of answer
*/
@ManyToOne(fetch = FetchType.LAZY)
@Column(name = "answer_drug")
private Drug answerDrug;

/**
* The creator of this concept answer
*/
@NotNull(message = "Creator must not be null")
@Column(name = "creator", nullable = false, updatable = false)
private User creator;

/**
* The date this concept answer was created
*/
@NotNull
@Column(name = "date_created", nullable = false, updatable = false)
private Date dateCreated;

/**
* The sort weight of this concept answer. This is used to sort the answers to a question in a
* specific order
*/
@Column(name = "sort_weight")
private Double sortWeight;

// Constructors
Expand All @@ -73,6 +112,7 @@ public ConceptAnswer(Concept answerConcept, Drug d) {
/**
* @return Returns the answerConcept.
*/

public Concept getAnswerConcept() {
return answerConcept;
}
Expand Down