Class UpdateService
java.lang.Object
com.invirgance.convirgance.web.service.UpdateService
- All Implemented Interfaces:
Processable,Service
Convenience service for executing simple SQL updates like delete or update. Provides
the ability to run multiple queries as a single transaction. If any of the queries
fails, the entire transaction will be rolled back.
For convenience, the
For convenience, the
setSql(String) method is provided to configure a single
query. This is the same as calling setStatements(List) with a single list
item.- Author:
- jbanes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(HttpRequest request, HttpResponse response) Executes the service, processing the HTTP request and generating a response.A mapping of child records to SQL statements to execute for each child record.The JNDI name used to look up the database connection.Gets the list of parameters to extract from the request.getSql()Returns a single SQL query to execute.Returns a list of SQL queries that will be executed.Iterable<com.invirgance.convirgance.json.JSONObject> process(HttpRequest request) Processes an HTTP request to retrieve data without generating a response.voidsetChildren(Map<String, String> children) A mapping of child records to SQL statements to execute for each child record.voidsetJndiName(String jndiName) Sets the JNDI name for the data source lookup.voidsetParameters(List<Parameter> parameters) Sets the list of parameters to extract from the request.voidSets a single query used to update the database.voidsetStatements(List<String> sql) Sets a list of queries used to update the database.
-
Constructor Details
-
UpdateService
public UpdateService()
-
-
Method Details
-
getParameters
Gets the list of parameters to extract from the request.- Returns:
- The parameters list
-
setParameters
Sets the list of parameters to extract from the request.- Parameters:
parameters- The parameters list
-
getJndiName
The JNDI name used to look up the database connection.This property must reference a valid JNDI resource that returns a
DataSource.- Returns:
- the JNDI name
-
setJndiName
Sets the JNDI name for the data source lookup.- Parameters:
jndiName- The JDNI name.
-
getStatements
Returns a list of SQL queries that will be executed.- Returns:
- A list of SQL queries
-
setStatements
Sets a list of queries used to update the database. Named bindings can be used. They will be bound by key to the parameters provided by the parameters.- Parameters:
sql- The new SQL query.
-
getSql
Returns a single SQL query to execute.- Returns:
- The SQL query.
-
setSql
Sets a single query used to update the database. Named bindings can be used. They will be bound by key to the parameters provided by the parameters.- Parameters:
sql- The new SQL query.
-
getChildren
A mapping of child records to SQL statements to execute for each child record.- Returns:
- a map with the key names of JSONArrays for the key, and SQL statements for the value
-
setChildren
A mapping of child records to SQL statements to execute for each child record. The key of the map must point to a JSONArray in the data. For each entry in the JSONArray, the SQL statement provided will be executed. Each SQL statement will be part of the same transaction as the statement list.- Parameters:
children- a map with the key names of JSONArrays for the key, and SQL statements for the value
-
process
Description copied from interface:ProcessableProcesses an HTTP request to retrieve data without generating a response.This method implements the core data retrieval pipeline and can be used by other components that need access to the data without writing to a response.
- Extract parameters from the HTTP request
- Store parameters in thread-local storage for access by other components
- Use the configured binding to retrieve data based on the parameters
- Apply any configured transformers to the data
- Specified by:
processin interfaceProcessable- Parameters:
request- The HTTP request containing the parameters- Returns:
- An iterable of JSONObjects containing the retrieved and transformed data
-
execute
Description copied from interface:ServiceExecutes the service, processing the HTTP request and generating a response.
-