diff --git a/api/src/main/java/org/openmrs/Form.java b/api/src/main/java/org/openmrs/Form.java index bc006cd9cf0..d018aa69d58 100644 --- a/api/src/main/java/org/openmrs/Form.java +++ b/api/src/main/java/org/openmrs/Form.java @@ -16,28 +16,57 @@ import java.util.List; import java.util.Set; +import javax.persistence.CascadeType; +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.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; + /** * Form * * @version 1.0 */ +@Entity +@Table(name = "form") @Audited public class Form extends BaseChangeableOpenmrsMetadata { public static final long serialVersionUID = 845634L; // Fields - + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "form_form_id_seq") + @GenericGenerator( + name = "form_fomr_id_seq", + strategy = "native", + parameters = @Parameter(name = "sequence", value ="form_form_form_form_id_seq") + ) + @Column(name = "form_id", nullable = false) private Integer formId; + @Column(name = "version", nullable = false, length = 50) private String version; + @Column(name = "build", nullable = true) private Integer build; + @Column(name = "published", nullable = true, length = 1) private Boolean published = false; + @ManyToOne + @JoinColumn(name = "encounter_type") private EncounterType encounterType; + @OneToMany(mappedBy = "form", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private Set formFields; // Constructors diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml index 2bd3c6ad8dc..68b1828d8e8 100644 --- a/api/src/main/resources/hibernate.cfg.xml +++ b/api/src/main/resources/hibernate.cfg.xml @@ -46,7 +46,6 @@ - diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/Form.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/Form.hbm.xml deleted file mode 100644 index 1e67c45288a..00000000000 --- a/api/src/main/resources/org/openmrs/api/db/hibernate/Form.hbm.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - form_form_id_seq - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api/src/test/java/org/openmrs/api/OrderServiceTest.java b/api/src/test/java/org/openmrs/api/OrderServiceTest.java index 6d553c03825..6b2dd5a439d 100644 --- a/api/src/test/java/org/openmrs/api/OrderServiceTest.java +++ b/api/src/test/java/org/openmrs/api/OrderServiceTest.java @@ -35,6 +35,7 @@ import org.openmrs.DrugIngredient; import org.openmrs.DrugOrder; import org.openmrs.Encounter; +import org.openmrs.Form; import org.openmrs.FreeTextDosingInstructions; import org.openmrs.GlobalProperty; import org.openmrs.Location; @@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th .addAnnotatedClass(ProgramAttributeType.class) .addAnnotatedClass(HL7InError.class) .addAnnotatedClass(OrderType.class) + .addAnnotatedClass(Form.class) .getMetadataBuilder().build();