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-5797: Field Domain - Switching from Hibernate Mappings to Annotations #4827

Open
wants to merge 3 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
44 changes: 38 additions & 6 deletions api/src/main/java/org/openmrs/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,66 @@
import java.util.Set;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
* Field
*
* @version 1.0
*/
@Entity
@Table(name = "field")
@Audited
public class Field extends BaseChangeableOpenmrsMetadata {

public static final long serialVersionUID = 4454L;

// Fields

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "field_id_seq")
@GenericGenerator(
name = "field_id_seq",
strategy = "native",
parameters = @Parameter(name = "sequence", value = "field_field_id_seq")
)
@Column(name = "field_id")
private Integer fieldId;


@ManyToOne
@JoinColumn(name = "field_type")
private FieldType fieldType;


@ManyToOne
@JoinColumn(name = "concept_id")
private Concept concept;


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

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


@Column(name = "default_value", columnDefinition = "TEXT")
@Lob
private String defaultValue;


@Column(name = "select_multiple", length = 1, nullable = false)
private Boolean selectMultiple = false;

@Transient
private Set<FieldAnswer> answers;

// Constructors
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 @@ -44,7 +44,6 @@
<mapping resource="org/openmrs/api/db/hibernate/DiagnosisAttributeType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Drug.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/DrugReferenceMap.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Field.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/FieldType.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/Form.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/FormField.hbm.xml" />
Expand Down
85 changes: 0 additions & 85 deletions api/src/main/resources/org/openmrs/api/db/hibernate/Field.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
Expand Up @@ -2740,6 +2740,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th
.addAnnotatedClass(ProgramAttributeType.class)
.addAnnotatedClass(HL7InError.class)
.addAnnotatedClass(OrderType.class)
.addAnnotatedClass(org.openmrs.Field.class)
.getMetadataBuilder().build();


Expand Down
Loading