public class HibernateFormDAO extends Object implements FormDAO
FormService
methods.FormDAO
,
FormService
Constructor and Description |
---|
HibernateFormDAO() |
Modifier and Type | Method and Description |
---|---|
void |
deleteField(Field field)
Deletes a field from the database.
|
void |
deleteFieldType(FieldType fieldType)
Delete the given field type from the database
|
void |
deleteForm(Form form)
Delete form from database.
|
void |
deleteFormField(FormField formField)
Deletes a FormField from the database.
|
void |
deleteFormResource(FormResource formResource) |
Form |
duplicateForm(Form form)
Creates new form from the given
Form |
List<Field> |
getAllFields(boolean includeRetired)
Returns all fields in the database, possibly including retired ones
|
List<FieldType> |
getAllFieldTypes(boolean includeRetired)
Get all field types
|
List<FormField> |
getAllFormFields()
Returns all FormFields in the database
|
List<Form> |
getAllForms(boolean includeRetired)
Returns all forms in the database, possibly including retired ones
|
Field |
getField(Integer fieldId) |
FieldAnswer |
getFieldAnswerByUuid(String uuid) |
Field |
getFieldByUuid(String uuid) |
List<Field> |
getFields(Collection<Form> forms,
Collection<FieldType> fieldTypes,
Collection<Concept> concepts,
Collection<String> tableNames,
Collection<String> attributeNames,
Boolean selectMultiple,
Collection<FieldAnswer> containsAllAnswers,
Collection<FieldAnswer> containsAnyAnswer,
Boolean retired)
Returns all fields that match a broad range of (nullable) criteria
|
List<Field> |
getFields(String search) |
List<Field> |
getFieldsByConcept(Concept concept) |
FieldType |
getFieldType(Integer fieldTypeId)
Get fieldType by internal identifier
|
FieldType |
getFieldTypeByName(String name)
Return fieldType associated with given name
|
FieldType |
getFieldTypeByUuid(String uuid) |
Form |
getForm(Integer formId)
Get form by internal form identifier
|
Form |
getForm(String name,
String version)
Get form by exact name and version
|
Form |
getFormByUuid(String uuid) |
Integer |
getFormCount(String partialName,
Boolean published,
Collection<EncounterType> encounterTypes,
Boolean retired,
Collection<FormField> containingAnyFormField,
Collection<FormField> containingAllFormFields,
Collection<Field> fields) |
FormField |
getFormField(Form form,
Concept concept,
Collection<FormField> ignoreFormFields,
boolean force) |
FormField |
getFormField(Integer formFieldId) |
FormField |
getFormFieldByUuid(String uuid) |
List<FormField> |
getFormFields(Form form) |
List<FormField> |
getFormFieldsByField(Field field)
Return a list of FormFields given a Field
|
FormResource |
getFormResource(Form form,
String name) |
FormResource |
getFormResource(Integer formResourceId) |
FormResource |
getFormResourceByUuid(String uuid) |
Collection<FormResource> |
getFormResourcesForForm(Form form) |
List<Form> |
getForms(String partialName,
Boolean published,
Collection<EncounterType> encounterTypes,
Boolean retired,
Collection<FormField> containingAnyFormField,
Collection<FormField> containingAllFormFields,
Collection<Field> fields)
Gets all forms that match all the criteria.
|
List<Form> |
getFormsByName(String name)
Gets all forms with the given name, sorted (alphabetically) by descending version
|
List<Form> |
getFormsContainingConcept(Concept c)
Get all forms that contain the given
Concept as one of their fields. |
Field |
saveField(Field field) |
FieldType |
saveFieldType(FieldType fieldType)
Save the given field type to the database
|
Form |
saveForm(Form form)
Returns the form object originally passed in, which will have been persisted.
|
FormField |
saveFormField(FormField formField) |
FormResource |
saveFormResource(FormResource formResource) |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Set session factory
|
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- public Form saveForm(Form form) throws DAOException
saveForm
in interface FormDAO
DAOException
org.openmrs.api.FormService#createForm(org.openmrs.Form)
public Form duplicateForm(Form form) throws DAOException
FormDAO
Form
duplicateForm
in interface FormDAO
form
- Form
to duplicateForm
DAOException
FormService.duplicateForm(org.openmrs.Form)
public void deleteForm(Form form) throws DAOException
FormDAO
Forms
should be retired and not deleted altogether (since many foreign key
constraints depend on forms, deleting a form would require deleting all traces, and any
historical trail would be lost). This method only clears form roles and attempts to delete
the form record. If the form has been included in any other parts of the database (through a
foreign key), the attempt to delete the form will violate foreign key constraints and fail.deleteForm
in interface FormDAO
form
- Form to deleteDAOException
org.openmrs.api.FormService#deleteForm(org.openmrs.Form)
public Form getForm(Integer formId) throws DAOException
FormDAO
getForm
in interface FormDAO
formId
- Integer
internal identifier for requested FormForm
DAOException
FormService.getForm(java.lang.Integer)
public List<FormField> getFormFields(Form form)
org.openmrs.api.FormService#getFormFields(Form)
public List<Field> getFields(String search)
getFields
in interface FormDAO
search
- String phrase to search forFormDAO.getFields(java.lang.String)
public Field getField(Integer fieldId) throws DAOException
getField
in interface FormDAO
DAOException
FormService.getField(java.lang.Integer)
,
FormDAO.getField(java.lang.Integer)
public List<Field> getAllFields(boolean includeRetired) throws DAOException
FormDAO
getAllFields
in interface FormDAO
includeRetired
- whether or not to return retired fieldsDAOException
FormService.getAllFields(boolean)
,
FormDAO.getAllFields(boolean)
public FieldType getFieldType(Integer fieldTypeId) throws DAOException
FormDAO
getFieldType
in interface FormDAO
fieldTypeId
- Internal Integer identifier of FieldTypeDAOException
FormService.getFieldType(java.lang.Integer)
,
FormDAO.getFieldType(java.lang.Integer)
public List<FieldType> getAllFieldTypes(boolean includeRetired)
FormDAO
getAllFieldTypes
in interface FormDAO
includeRetired
- boolean - include retired field types as well?org.openmrs.api.FormService#getFieldTypes()
,
FormDAO.getAllFieldTypes(boolean)
public FormField getFormField(Integer formFieldId) throws DAOException
getFormField
in interface FormDAO
DAOException
FormService.getFormField(java.lang.Integer)
,
FormDAO.getFormField(java.lang.Integer)
public FormField getFormField(Form form, Concept concept, Collection<FormField> ignoreFormFields, boolean force) throws DAOException
public List<Form> getAllForms(boolean includeRetired)
FormDAO
getAllForms
in interface FormDAO
includeRetired
- boolean - include retired forms?org.openmrs.api.FormService#getForms()
public List<Form> getFormsContainingConcept(Concept c) throws DAOException
FormDAO
Concept
as one of their fields. (Includes
retired forms.)getFormsContainingConcept
in interface FormDAO
c
- the Concept
to search through form fields forDAOException
FormDAO.getFormsContainingConcept(org.openmrs.Concept)
public Field saveField(Field field) throws DAOException
saveField
in interface FormDAO
DAOException
FormService.saveField(org.openmrs.Field)
,
FormDAO.saveField(org.openmrs.Field)
public void deleteField(Field field) throws DAOException
FormDAO
This will fail if any other entities reference this field via a foreign key
deleteField
in interface FormDAO
field
- the Field to deleteDAOException
org.openmrs.api.FormService#deleteField(org.openmrs.Field)
,
FormDAO.deleteField(org.openmrs.Field)
public FormField saveFormField(FormField formField) throws DAOException
saveFormField
in interface FormDAO
DAOException
org.openmrs.api.FormService#createFormField(org.openmrs.FormField)
public void deleteFormField(FormField formField) throws DAOException
FormDAO
deleteFormField
in interface FormDAO
formField
- the FormField to deleteDAOException
org.openmrs.api.FormService#deleteFormField(org.openmrs.FormField)
,
FormDAO.deleteFormField(org.openmrs.FormField)
public List<FormField> getAllFormFields()
FormDAO
getAllFormFields
in interface FormDAO
FormDAO.getAllFormFields()
public List<Field> getFields(Collection<Form> forms, Collection<FieldType> fieldTypes, Collection<Concept> concepts, Collection<String> tableNames, Collection<String> attributeNames, Boolean selectMultiple, Collection<FieldAnswer> containsAllAnswers, Collection<FieldAnswer> containsAnyAnswer, Boolean retired) throws DAOException
FormDAO
getFields
in interface FormDAO
forms
- Collection
of Form
to which the requested Fields must
belongfieldTypes
- Collection
of FieldType
of which the requested
fields must beconcepts
- Collection
of Concepts
which the fields must point
totableNames
- Collection of TableName
s which the fields must point toattributeNames
- Collection of String
attribute names which the
fields must point toselectMultiple
- Boolean
value that matching fields must have for
selectMultiplecontainsAllAnswers
- Collection
of FieldAnswer
s, all of which
a matching field must contain (not yet implemented)containsAnyAnswer
- Collection
of FieldAnswer
s, any one of
which a matching field must contain (not yet implemented)retired
- Boolean
retired status that fields must matchDAOException
FormDAO.getFields(java.util.Collection, java.util.Collection,
java.util.Collection, java.util.Collection, java.util.Collection, java.lang.Boolean,
java.util.Collection, java.util.Collection, java.lang.Boolean)
public Form getForm(String name, String version)
FormDAO
getForm
in interface FormDAO
name
- the name of the form to getversion
- the version of the form to getFormDAO.getForm(java.lang.String, java.lang.String)
public List<Form> getForms(String partialName, Boolean published, Collection<EncounterType> encounterTypes, Boolean retired, Collection<FormField> containingAnyFormField, Collection<FormField> containingAllFormFields, Collection<Field> fields) throws DAOException
FormDAO
getForms
in interface FormDAO
partialName
- String of partial name of form to search onpublished
- boolean - is the form published?encounterTypes
- Collection of EncounterType
s that the form must representretired
- boolean - is the form retired?containingAnyFormField
- Collection of FormField
s, any one of which must be
contained in the formcontainingAllFormFields
- Collection of FormField
s, all of which must be
contained in the formfields
- Collection of Field
s that the form must containDAOException
FormDAO.getForms(java.lang.String, java.lang.Boolean,
java.util.Collection, java.lang.Boolean, java.util.Collection, java.util.Collection,
java.util.Collection)
public Integer getFormCount(String partialName, Boolean published, Collection<EncounterType> encounterTypes, Boolean retired, Collection<FormField> containingAnyFormField, Collection<FormField> containingAllFormFields, Collection<Field> fields) throws DAOException
public Field getFieldByUuid(String uuid)
getFieldByUuid
in interface FormDAO
FormDAO.getFieldByUuid(java.lang.String)
public FieldAnswer getFieldAnswerByUuid(String uuid)
getFieldAnswerByUuid
in interface FormDAO
public FieldType getFieldTypeByUuid(String uuid)
getFieldTypeByUuid
in interface FormDAO
FormDAO.getFieldTypeByUuid(java.lang.String)
public FieldType getFieldTypeByName(String name)
FormDAO
getFieldTypeByName
in interface FormDAO
name
- Name of the fileType to queryFormDAO.getFieldTypeByName(java.lang.String)
public Form getFormByUuid(String uuid)
getFormByUuid
in interface FormDAO
FormDAO.getFormByUuid(java.lang.String)
public FormField getFormFieldByUuid(String uuid)
getFormFieldByUuid
in interface FormDAO
FormDAO.getFormFieldByUuid(java.lang.String)
public List<Form> getFormsByName(String name) throws DAOException
FormDAO
getFormsByName
in interface FormDAO
name
- String name of the forms to getDAOException
FormDAO.getFormsByName(java.lang.String)
public void deleteFieldType(FieldType fieldType) throws DAOException
FormDAO
deleteFieldType
in interface FormDAO
fieldType
- FieldType to deleteDAOException
FormDAO.deleteFieldType(org.openmrs.FieldType)
public FieldType saveFieldType(FieldType fieldType) throws DAOException
FormDAO
saveFieldType
in interface FormDAO
fieldType
- FieldType to save to the databaseDAOException
FormDAO.saveFieldType(org.openmrs.FieldType)
public List<FormField> getFormFieldsByField(Field field)
FormDAO
getFormFieldsByField
in interface FormDAO
FormDAO.getFormFieldsByField(Field)
public FormResource getFormResource(Integer formResourceId)
getFormResource
in interface FormDAO
FormDAO.getFormResource(java.lang.Integer)
public FormResource getFormResourceByUuid(String uuid)
getFormResourceByUuid
in interface FormDAO
FormDAO.getFormResourceByUuid(java.lang.String)
public FormResource getFormResource(Form form, String name)
getFormResource
in interface FormDAO
FormDAO.getFormResource(org.openmrs.Form, java.lang.String)
public FormResource saveFormResource(FormResource formResource)
saveFormResource
in interface FormDAO
FormDAO.saveFormResource(org.openmrs.FormResource)
public void deleteFormResource(FormResource formResource)
deleteFormResource
in interface FormDAO
FormDAO.deleteFormResource(org.openmrs.FormResource)
public Collection<FormResource> getFormResourcesForForm(Form form)
getFormResourcesForForm
in interface FormDAO
FormDAO.getFormResourcesForForm(org.openmrs.Form)
Copyright © 2024 OpenMRS Inc.. All rights reserved.