T
- The entity that backs each row in datatablesID
- The unique identifier of the entity Tpublic interface DataTablesService<T,ID>
Modifier and Type | Method and Description |
---|---|
T |
add(T transientObject)
Adds an object of type T
|
ID |
addAndReturnID(T transientObject)
Adds an object of type T
|
void |
additionalColumnConfiguration(ColumnConfiguration columnConfiguration,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.ui.Model model)
Method to handle custom column configurations, such as adding field maps or hiding columns based on user type etc.
|
java.lang.Integer |
adjustColumnPositionDueToInvisibleColumns(ColumnConfiguration columnConfiguration,
java.lang.Integer columnPosition)
Adjusts the column position to account for hidden column missmatch between datatables columns and datatables-editable
columns.
|
T |
convertColumnsToEntity(ColumnConfiguration rowConfig,
T oldEntity)
Takes a ColumnConfiguration and updates the passed in entity with the new values.
|
ColumnConfiguration |
convertEntityToColumns(T entity)
Takes a T entity and converts it to a ColumnConfiguration; a ColumnConfiguration contains a number of Columns.
|
java.lang.String |
editEntity(ID id,
java.lang.Integer columnPosition,
java.lang.Object value,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.ui.Model model)
Updates an existing entity of type T, using its primary key, the column position in the datatables of the field being
updated and the updated value.
|
T |
find(ID id)
Get a T record using it's id
|
java.util.List<T> |
findAll(java.util.List<T> tableRows,
boolean useCache)
Retrieves all the data in the table.
|
ApplicationSettings |
getAppSettings() |
java.util.List<T> |
getData(java.util.List<T> tableRows,
boolean useCache,
javax.servlet.http.HttpServletRequest request)
Retrieves the data.
|
DtoFieldChangeFactory |
getDtoFieldChangeFactory() |
GenericDao<T,ID> |
getGenericDao() |
org.apache.log4j.Logger |
getLog() |
java.lang.String |
getMessageUsingKey(java.lang.String key)
Gets a message from a resource bundle.
|
java.lang.String |
getQueryUsingKey(java.lang.String key)
Get a query from the passed in QueryHelper
|
org.springframework.validation.Validator |
getValidator() |
java.lang.String |
handleEntityFormEdit(T entity,
ID entityID,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method handles the edit of an entity using the form instead of inline editing.
|
java.lang.String |
prepareValidationErrorMessage(org.springframework.validation.BindingResult bindingResult,
T entity)
Prepares a validation error message using Spring's BindingResult from an entity validation.
|
org.json.JSONObject |
processRequestForDataTables(javax.servlet.http.HttpServletRequest request)
Entry point for getting, filtering, sorting, handle pagination and constructing JSONObject; the JSONObject is then written
to the response.
|
java.util.List<T> |
query(java.lang.String queryString,
java.util.Map<java.lang.String,java.lang.Object> queryParameters)
Method for custom query.
|
void |
remove(T persistentObject)
Deletes entity T from table.
|
void |
removeUsingID(ID id)
Deletes an entity using its primary key
|
T |
update(T transientObject)
Updates an object of type T
|
ID |
updateAndReturnID(T transientObject)
Updates an object of type T
|
java.lang.String |
validateEntity(T entity)
Validates an entity
|
ColumnConfiguration convertEntityToColumns(T entity)
entity
- T convertColumnsToEntity(ColumnConfiguration rowConfig, T oldEntity)
rowConfig
- oldEntity
- the entity that will be updatedorg.json.JSONObject processRequestForDataTables(javax.servlet.http.HttpServletRequest request)
request
- response
- java.io.IOException
java.util.List<T> getData(java.util.List<T> tableRows, boolean useCache, javax.servlet.http.HttpServletRequest request)
tableRows
- will be null if List is not in sessionuseCache
- If true data will be cachedrequest
- the HttpServletRequest containing all the information from the request. This can be used when overriding this
method to retrieve query params etc.java.util.List<T> findAll(java.util.List<T> tableRows, boolean useCache)
tableRows
- will be null if List is not in sessionuseCache
- If true data will be cachedT update(T transientObject)
transientObject
- The object to be added/updatedID updateAndReturnID(T transientObject)
transientObject
- The object to be added/updatedT add(T transientObject)
transientObject
- The object to be added/updatedID addAndReturnID(T transientObject)
transientObject
- The object to be added/updatedT find(ID id) throws javax.persistence.EntityNotFoundException
id
- The unique identifier of the entity T (in most cases the primary key of the entity)javax.persistence.EntityNotFoundException
- when no entity with (primary key) ID existsjava.util.List<T> query(java.lang.String queryString, java.util.Map<java.lang.String,java.lang.Object> queryParameters)
queryString
- the query String with named parameters: Select a FROM TableName a WHERE a.field = :namedParamqueryParameters
- the named parameters corresponding to the :namedParam in the queryString. The key of the map need correspond to
namedParam while the value is the actual value used in the query.void remove(T persistentObject) throws javax.persistence.EntityNotFoundException
T
- Entity to deletejava.lang.IllegalArgumentException
- if the instance is not an entity or is a detached entityjavax.persistence.EntityNotFoundException
java.lang.String editEntity(ID id, java.lang.Integer columnPosition, java.lang.Object value, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
id
- the unique identifier of the entity TcolumnPosition
- the column position in the datatables that matches the field being updatedvalue
- the new value of the field * @param requestresponse
- model
- java.lang.String handleEntityFormEdit(T entity, ID entityID, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
entity
- used when all fields on the entity are present on the formentityID
- the id of the entity to updaterequest
- the request containing all parametersresponse
- void removeUsingID(ID id) throws javax.persistence.EntityNotFoundException
id
- unique identifierjavax.persistence.EntityNotFoundException
- if no enity exists with the specified unique identifierjava.lang.String validateEntity(T entity)
entity
- the entity to validatejava.lang.String prepareValidationErrorMessage(org.springframework.validation.BindingResult bindingResult, T entity)
bindingResult
- the validation result from an entityentity
- the entity that was just validated, used to find the labels of particular fields to create prettier error
messages.java.lang.Integer adjustColumnPositionDueToInvisibleColumns(ColumnConfiguration columnConfiguration, java.lang.Integer columnPosition)
columnConfiguration
- columnPosition
- the current column to checkvoid additionalColumnConfiguration(ColumnConfiguration columnConfiguration, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
columnConfiguration
- The ColumnConfiguration from this.convertEntityToColumnsrequest
- the HttpServletRequestresponse
- the HttpServletResponsemodel
- the ModelGenericDao<T,ID> getGenericDao()
ApplicationSettings getAppSettings()
org.springframework.validation.Validator getValidator()
DtoFieldChangeFactory getDtoFieldChangeFactory()
org.apache.log4j.Logger getLog()
java.lang.String getMessageUsingKey(java.lang.String key)
key
- The key of the messagejava.lang.String getQueryUsingKey(java.lang.String key)
key
-