Possible values: "xml" and "json".
long
boolean
getFieldValue(Object fieldName)
getCriteriaValue(fieldName)
.DSResponse
.jakarta.servlet.http.HttpServletRequest
boolean
boolean
oldValues
in the request as a List, even if singular.setOutputs(java.util.List)
.boolean
true
if progressive loading is enabled, false
if it is disabled for this particular request or null
if this was not explicitly set, meaning that OperationBinding- and DataSource-level settings will be respected and automatically switching to loading data progressively if DataSource.progressiveLoadingThreshold is exceeded would also work as expected.true
if it is a raw REST mode request.getREST()
true
if it is REST request.jakarta.servlet.ServletContext
long
getUploadedFile(String fieldName)
getUploadedFileStream(String fieldName)
boolean
values
in the request as a List, even if singular.true
if JSON responses should be wrapped with markers.boolean
boolean
boolean
boolean
isPaged()
removeAttribute(String key)
setAdvancedCriteria(AdvancedCriteria advancedCriteria)
setAllowArbitrarySubqueries(boolean newValue)
setAllowMultiUpdate(boolean newValue)
setAttribute(String key, Object value)
setBatchSize(long batchSize)
void
setCanSyncCache(boolean canSyncCache)
setCriteria(Object criteria)
setCriteria(String fieldName, Object value)
setCriteriaValue(String fieldName, Object value)
setDataFormat(String dataFormat)
setEndRow(long endRow)
setExportAs(String exportAs)
setExportDelimiter(String exportDelimiter)
setExportDisplay(String exportDisplay)
setExportFields(List exportFields)
setExportFieldTitles(Map exportFieldTitles)
setExportFilename(String exportFilename)
exporting to the server filesystem
.setExportFooter(String exportFooter)
setExportHeader(String exportHeader)
setExportHeaderless(boolean exportHeaderless)
setExportPath(String exportPath)
setExportResults(Boolean exportResults)
setExportTitleSeparatorChar(String exportTitleSeparatorChar)
setExportTo(OutputStream exportOutputStream)
setExportToClient(boolean exportToClient)
setExportToFilesystem(boolean exportToFilesystem)
exportFilename
on the server filesystem.setFieldValue(Object fieldName, Object value)
setFreeOnExecute(boolean freeOnExecute)
setGroupBy(String... groupBy)
fetch
operation group by fields can be set.setGroupBy(List<String> groupBy)
setHashedFields(List hashedFields)
storeWithHash
that already contain hashed values in this request, and that therefore should not be rehashed.void
setIncludeBinaryFields(boolean includeBinaryFields)
DSRequests
that target SQLDataSource
.setJoinTransaction(Boolean newValue)
setJsonPrefix(String jsonPrefix)
setJsonSuffix(String jsonSuffix)
setLineBreakStyle(String lineBreakStyle)
setOldValues(Map oldValues)
setOperationId(String operationId)
setOperationType(String operationType)
setOutputs(List outputs)
setPartOfTransaction(boolean newValue)
setPendingAddFlag(boolean pendingAdd)
setProgressiveLoading(Boolean progressiveLoading)
setRawREST(Boolean isRawREST)
setRawSummaryFunctions(Map<String,String> rawSummaryFunctions)
setRequestContext(RequestContext context)
BaseRequest.setContext(RequestContext)
instead.setSkipAudit(boolean skipAudit)
void
setSkipCacheSync(boolean skipCacheSync)
setStartRow(long startRow)
setStreamResults(boolean streamResults)
setSummaryFunctions(Map<String,SummaryFunctionType> summaryFunctions)
setTenantId(String tenantId)
setTextMatchStyle(String textMatchStyle)
setUserRoles(String rolesString)
setUserRoles(String... roles)
setUserRoles(List<String> userRoles)
setValidated(boolean newValue)
setValidationMode(String validationMode)
setWrapJSONResponses(Boolean wrapJSONResponses)
boolean
validate()
getContext, getDSCacheManager, getDSTransaction, getRPCManager, isClientRequest, setClientRequest, setContext, setDSCacheManager, setDsTransaction, setDSTransaction
dataSourceName
- name of the datasource for this requestoperationType
- operationType for this requestvc
- the ValidationContext to initialize this request withRPCManager
. Depending on the operation you're performing you'll need to call some other setters on the returned instance before calling execute().dataSourceName
- name of the datasource for this requestoperationType
- operationType for this requestrpcManager
- The RPCManager in use for this requestDSCacheManager
. This constructor is preferred to calling setDSCacheManager() after DSRequest creation, because the DS cache is useful during DSRequest construction Depending on the operation you're performing you'll need to call some other setters on the returned instance before calling execute().
dataSourceName
- name of the datasource for this requestoperationType
- operationType for this requestdsCacheManager
- The DSCacheManager in use for this requestvalidate()
method has been called and did not return any errors, but see also setValidated(boolean)
.validate()
method has been called and did not return any errors. You can use this API to directly set the validated state of a DSRequest.setValidated(false)
on the DSREquest then executes it, it will be validated again. This may be desirable if the DMI alters the DSRequest in some way/newValue
- whether this request has been validated If you setPartOfTransaction(true)
and the automatically handled transaction fails, the status for your DSRequest will be reported as STATUS_TRANSACTION_FAILED, which is an indication to the client that the DSRequest did nothing.
Use this API if you have written custom Java code to handle a DSRequest, and:
setPartOfTransaction(true)
in this case reflects the fact that your updates will be automatically rolled back along with other updates in the automatically managed transaction. public DSResponse myDMI(DSRequest req) { String str = req.getFieldValue("someField").toLowerCase(); // Do something with str here return req.execute(); }Here, by blindly calling a method without first checking for null, you introduce the possibility of this DMI crashing before the execute() call; the execute() call would have determined that this DSRequest should be part of the automatic transaction, meaning a failure of it would have rolled back the whole transaction. This early failure in DMI code leaves the DSRequest still separate from the transaction, so rollback would not happen.
What we do in a case like this is check if the DSRequest would have joined the automatic transaction if the DMI had been bypassed: if it would, the DSRequest is considered to be part of the transaction. So in this case, the overall transaction would be rolled back in the event of a NullPointerException
arising from the first line of the DMI method. That is correct and desirable failure behavior for this case and the majority of ordinary DMI usages on a built-in DataSource type, where the DMI is there to augment the built-in functionality, and dsRequest.execute() will ultimately be called.
However, a DMI can do anything at all - there is no certainty that dsRequest.execute() will eventually be called. If the DMI described above did not make that call then the request would not have been part of the transaction regardless of success or failure, and our heuristic test - would the request have joined the transaction if the DMI had been bypassed? - would make the wrong decision. To prevent the possibility of this happening, you would either:
setPartOfTransaction(false)
right at the top of your DMI method. This would handle transactional failure correctly without any further code to writeSQLTransaction.rollbackTransaction(dsRequest.getRPCManager());
newValue
- whether this request is part of a transactiontextMatchStyle
- the text match style to setBaseRequest.getContext()
instead.operationType
- the operation type - see above for valid values. The operationId is a means for client-side DataBound Components to request variants of the basic DataSource operations that the server may support, such as normal fetch
operations vs fetch
operations that use a single parameter and do full-text search. See the Client Reference for DSRequest.operationId for more information.
operationId
- the operationId to useFor requests submitted by a SmartClient DataBoundComponent, this is the component ID.
If the operationType is "fetch", then the criteria specifies the search criteria.
If the operationType is "remove" or "update" then the criteria are the primary key/value pairs for the record to be updated or deleted. This set of fields is derived directly from the field specification in the dataSource for this operation - all fields marked as {primaryKey: true} are considered primary keys and their field names and values will be sent as part of the criteria in this case.
The criteria returned from this method are in simple Java Collections form (as they are sent over the network). Use getAdvancedCriteria()
to retrieve an AdvancedCriteria
which provides simple APIs for manipulating criteria. The modified criteria can be applied to the DSRequest via setAdvancedCriteria(com.isomorphic.criteria.AdvancedCriteria)
.
If criteria were passed as simple Criteria this method will convert them to the more general AdvancedCriteria format by turning them into an AND Criterion containing one or more "startWith" or "contains" Criteria according to dsRequest.textMatchStyle.
Note that AdvancedCriteria will only be able to be executed by the built-in server DataSources (JPA, Hibernate, SQL) in Power Edition and above.
AdvancedCriteria has "_constructor" parameter set to "AdvancedCriteria".
Note: AdvancedCriteria will only be able to be executed by the built-in server DataSources (JPA, Hibernate, SQL) in Power Edition and above.
advancedCriteria
- the criteria to use for this DSRequestgetCriteria()
, because declarative security settings or custom server logic may have affected the latter. This method is provided so that your code can determine what the client actually sent, regardless of any server processing that has taken place.criteria
in the request as a List, even if singular. Custom client-side code for submitting "update"s or "remove"s can pass multiple sets of criteria
and values
and oldValues
as an alternative to using queuing (see the client-side API RPCManager.startQueue()). If you take this approach, calling getOldValueSets() is a convenience method for always retrieving sets of values as a List.
The criteria passed in this method are in simple Java Collections form (as they are sent over the network), but you can get use setAdvancedCriteria(AdvancedCriteria)
with AdvancedCriteria helper classes: AdvancedCriteria
exists to assist in modifying the criteria.
If AdvancedCriteria passed to this method setAdvancedCriteria(AdvancedCriteria)
method will be used.
criteria
- Map or List of Maps: the criteria to use for this DSRequestfieldName
- The field namevalue
- The criterion valuefieldName
- Form field of type 'binary'.Exception
- if an error occurs while retrieving the uploaded filefieldName
- Form field of type 'binary'.Exception
- if an error occurs while retrieving the uploaded file streamDSRequests
that target SQLDataSource
.By default binary fields are:
includeBinaryFields
- false
to skip selecting binary fieldsIf the operationType is "add" then the values are interpreted as a complete record to add. Note that a complete record at this stage may be missing primary keys that are expected to be auto-generated by the persistence layer.
If the operationType is "update", then the values represent the new values for the records matching the criteria specified on this request.
As a convenience, this method returns the criteria if this DSRequest is of type fetch or remove.
getValues()
, because declarative security settings or custom server logic may have affected the latter. This method is provided so that your code can determine what the client actually sent, regardless of any server processing that has taken place. As a convenience, this method returns the criteria that the client submitted if this DSRequest is of type fetch or remove.
values
in the request as a List, even if singular. Custom client-side code for submitting "update"s or "remove"s can pass multiple sets of criteria
and values
and oldValues
as an alternative to using queuing (see the client-side API RPCManager.startQueue()). If you take this approach, calling getOldValueSets() is a convenience method for always retrieving sets of values as a List.
values
- Map or List of Maps - the values to use for this DSRequest The server can compare the oldValues
to the most recent stored values in order to detect that the user was looking at stale values when the user submitted changes (NOTE: this means of detecting concurrent edit is sometimes called "long transactions").
Note that client logic must be written to pass oldValues
. SmartClient DataBound Components do so automatically, but manually submitted DSRequests may not.
oldValues
in the request as a List, even if singular. Custom client-side code for submitting "update"s or "remove"s can pass multiple sets of criteria
and values
and oldValues
as an alternative to using queuing (see the client-side API RPCManager.startQueue()). If you take this approach, calling getOldValueSets() is a convenience method for always retrieving sets of values as a List.
oldValues
- Map - the old values to use for this DSRequestIf you call this method on a DSRequest that has multiple sortBy fields specified, a warning will be logged and the first sortBy field will be returned.
This method signature is the generic method that returns all fields for which a sort has been requested. If the list contains more than one entry, then that means the data should be sorted by the first field in the list, then within that first sort data should be sorted by the next field in the list and so on. So the second sortBy field can only affect data that has the same value for the first sortBy field.
The returned value is a List of Strings that are the names of the fields to sort by. If the String is prefixed by a -
then that specifies descending order. Otherwise it's a request for an ascending sort on that field.
A concrete example of when a sortBy is sent by an ISC databound component: Let's say you have a ListGrid that has a partially loaded dataset (the dataset is too large to be on the client at once, so you're only showing, say, the first 100 rows). If you now click on one of the columns to sort by that column, the ListGrid will send a DSRequest to the server with a sortBy fieldName of the field that was clicked on. Since not all data is present on the client, the grid can't do the sort client-side (and still continue to display the first 100 matches to the current filter criteria).
sortBy
- String or List of Strings: field or list of fields to sort by. Note that a prefix of -
can be used to specify descending order sort.Valid only for an operation of type "fetch". See the Server Summaries overview in the client-side documentation for details and examples of usage.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
List
with field names to group by, or null if no grouping is configuredValid only for an operation of type "fetch". See the Server Summaries overview in the client-side documentation for details and examples of usage.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
groupBy
- List
with field names to group by.fetch
operation group by fields can be set. In this case only fields that appear in this List
and in dsRequest.summaryFunctions
attribute will be fetched.groupBy
- String...
with field names to group by.Valid only for an operation of type "fetch". See the Server Summaries overview in the client-side documentation for details and examples of usage.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
If you need to get all summary functions requested by the client, even if they are not framework built-ins, see getRawSummaryFunctions()
.
Map<String,SummaryFunctionType>
with field names as keys and summary functions as values.Valid only for an operation of type "fetch". See the Server Summaries overview in the client-side documentation for details and examples of usage.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
summaryFunctions
- Map<String,SummaryFunctionType>
with field names as keys and summary functions as values. getSummaryFunctions()
will only return recognized, built-in summaryFunctions from the SummaryFunctionType
enum, so getRawSummaryFunctions()
is the only way to retrieve client-requested summary functions that are not built into the framework, so that you can perform custom aggregation. See the Server Summaries > Custom Aggregation example in the Showcase.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
Map<String,String>
with field names as keys and summary functions as values. getSummaryFunctions()
will only return recognized, built-in summaryFunctions from the SummaryFunctionType
enum, so getRawSummaryFunctions()
is the only way to retrieve client-requested summary functions that are not built into the framework, so that you can perform custom aggregation. See the Server Summaries > Custom Aggregation example in the Showcase.
NOTE: this feature is supported only in Power Edition or above, and only when using the built-in SQL, JPA or Hibernate connectors.
rawSummaryFunctions
- Map<String,SummaryFunctionType>
with field names as keys and summary functions as values. The batch size will normally be based on endRow
if that has been set and batchSize will then be set to the number of rows to be returned, so they are all fetched at once.
For a request which does not have endRow
set you can call setBatchSize(long)
to try and influence the JDBC driver as a performance optimization. When using a Hibernate datasource criteria.setFetchSize will be called with this value.
The batch size can also be controlled from a config property through server.properties, namely, 'sql.defaultFetchBatchSize'. By default this property is unset but once set it configures the batchSize for any "fetch" dsRequest that does not have an endRow and has not had setBatchSize()
called explicitly If you use setBatchSize() to set a negative batch size, SmartClient Server will not call the JDBC setFetchSize() API at all, so you will get the default behavior of the JDBC driver / database.
batchSize
- the size of the batch as a whole number.When multi-record capable components make requests to the server for data, they send the startRow and endRow parameters to indicate the slice of data they need to show to the user right now.
You can use the isPaged() method on this request to check if you need to respect startRow/endRow for this request.
Note that startRow and endRow are zero-based, inclusive at the beginning and exclusive at the end (like substring), so startRow: 0, endRow: 1 is a request for the first record.
Note that startRow and endRow are zero-based, inclusive at the beginning and exclusive at the end (like substring), so startRow: 0, endRow: 1 is a request for the first record.
startRow
- the index of the first requested record (using zero-based numbering)If getEndRow() returns DSRequest.ENDROW_UNSET (a negative value), that signifies a request for all records matching the current criteria.
Note that startRow and endRow are zero-based, inclusive at the beginning and exclusive at the end (like substring), so startRow: 0, endRow: 1 is a request for the first record.
Note that startRow and endRow are zero-based, inclusive at the beginning and exclusive at the end (like substring), so startRow: 0, endRow: 1 is a request for the first record.
endRow
- the index of the last requested record (using zero-based numbering)true
if progressive loading is enabled, false
if it is disabled for this particular request or null
if this was not explicitly set, meaning that OperationBinding- and DataSource-level settings will be respected and automatically switching to loading data progressively if DataSource.progressiveLoadingThreshold is exceeded would also work as expected. Search for DataSource.progressiveLoading
and DataSource.progressiveLoadingThreshold
in SmartClient Reference for more details.Boolean
true
- progressive loading is explicitly enabled; false
- progressive loading is explicitly disabled; null
- default value to fall back to default behavior.DSRequest.progressiveLoading
is explicitly set to false
SmartClient won't automatically switch to loading data progressively even if DataSource.progressiveLoadingThreshold
is exceeded. Search for DataSource.progressiveLoading and DataSource.progressiveLoadingThreshold in SmartClient Reference for more details. Note that this setting applies only to fetch requests - it has no effect if specified on any other kind of request.
progressiveLoading
- boolean
true
- progressive loading will be enabled; false
- progressive loading will be disabled.getCriteriaValue(fieldName)
. This method treats the DSRequest as a single record. If the valueSet contains a value for the requested fieldName, it is returned. If not, the criteria is checked for the requested fieldName. If a value exists there, it is returned. Otherwise null is returned. This is a convenience method. For any given operation, a particular fieldName will usually appear in either the valueSet or criteria.
fieldName
- the fieldName whose value you want to look up If AdvancedCriteria
were passed, getCriteriaValue finds the first value provided for the fieldName anywhere in the AdvancedCriteria structure, by depth-first search.
fieldName
- the fieldName whose criteria value you want to look upAdvancedCriteria
, setCriteriaValue
will create a Criterion
based on the current textMatchStyle
of the DSRequest
, and combine it with the existing AdvancedCriteria
with an AndCriterion
. Existing Criteria
referencing the indicated fieldName are not modified. Otherwise, setCriteriaValue
updates the existing criteria Map. Any existing criterion for the indicated fieldName
is overwritten.
fieldName
- indicated field of criterionvalue
- required value the field must equalfieldName
is already referenced in the criteria, then the overwritten criterion value; otherwise null Generally, this method treats the criteria and values on the DSRequest as a single record: for "add" and "update" operations, the field value becomes part of the values to save. Otherwise ("fetch", "remove") the value is added to the criteria as though setCriteriaValue(String,Object)
were called. For "update" operations, you set criteria values with the setCriteria(Object)
or setCriteriaValue(String, Object)
APIs. However, this distinction only applies for regular update-via-primaryKey, where allowMultiUpdate
is not in force. Multi-update DSRequests must place the entire state of the update, both criteria and values, in the DSRequest values.
fieldName
- the fieldName whose value you want to setvalue
- the value to set for the fieldException
- if an error occurs while retrieving the DataSourcetenantId
- the tenant ID to set for this requestIf validation is successful for all fields, this method returns null. Otherwise it returns an ErrorReport for the first record that encountered a validation error.
Exception
DSResponse
. Related updates issue additional requests to database thus reducing performance. By default (if value set to null
) related updates will be generated only for "add" and "update" operations because related objects are loaded anyway and performance impact is minimal. Related updates for "remove" operation will not be generated by default (if value set to null
). Related updates generation loads related objects from database while simple "remove" operation does not. Depending on database structure performance impact can be significant if value set to true
.
Boolean
true
- related updates will be generated; false
- related updates will not be generated; null
- related updates will be generated only for "add" and "update" operations, related updates will not be generated for "remove" operation.Note: This conversion happens internally and the criteria on this request will be modified.
Exception
execute
in class BaseRequest<DSRequest,DSResponse>
BaseResponse
Exception
- if an error occurs during request executionthree-argument version
, but the third argument (isSnippet) is always false.name
- the name of the new object as it should appear in the Velocity namespacevalue
- arbitrary Java objectDSTransaction.addToTemplateContext()
If you would like to add Java objects to all Velocity templates, you can do so via the Velocity Tools mechanism described here: http://velocity.apache.org/tools/releases/2.0/index.html Just add the velocity tools jars to your deployment and place your tools.xml configuration file in the CLASSPATH (typically WEB-INF/classes).
The isSnippet
parameter controls whether the framework treats the context object as a regular context variable, or a user-defined snippet of text. If isSnippet
is true, the context object will be evaluated through Velocity immediately prior to the main Velocity evaluation taking place. This means that you can create context variables that themselves contain variable references, and those references will be correctly resolved in the final output. Read the "User-defined snippets" section of the "customQuerying" article in the client-side docs for more details.
name
- the name of the new object as it should appear in the Velocity namespacevalue
- arbitrary Java objectisSnippet
- Is the context object a user-defined snippet?transformRequestScript
, transformResponseScript
or fieldValueScript - you can make additional Java objects available to the script, for this request only, by calling this method. To make objects available to every request in a queue, see DSTransaction.addToScriptContext()
For example, set up a string in Java code:
dsRequest.addToScriptContext("mySimpleString", "This is a test");
and then use that string in your transformation script:
<DataSource ID="myDS">
<transformResponseScript language="groovy">
// Add a property to the response object
responseObject["testingTransform"] = mySimpleString;
. . .
</transformResponseScript>
. . .
</DataSource>
name
- the name of the new object as it should be made available to the scriptvalue
- arbitrary Java objectname
- the name of the object to remove
Note that DSRequests with allowMultiUpdate
in force, either because this
method has been called or because of the operationBinding
setting, must
include the entire state of the update - both the values and the criteria - in the
DSRequest values
as discussed
here
Note that if not set, or set to null
this is controlled by
dataSource.defaultMultiUpdatePolicy
, see client docs for details.
newValue
- true to allow multi-updates; false to restrict updates so that they
can affect just one single record, identified by primaryKey values in
the record providedDSRequest
setting in a subquery
Limiting server-initiated DSRequest
s by default is a safety measure: by
ensuring that you have to explicitly allow arbitrary subqueries, we hope to encourage
careful consideration of the potential security implications. For example, a
server-initiated DSRequest
could take untrusted criteria from a client
request and use it in a subquery to access something like a protected Stored Procedure
that is accessible as a customized "fetch" operationBinding. This would only be allowed
if allowArbitrarySubqueries
is explicitly set on
newValue
- true to allow arbitrary subqueries (anyDSRequest property is allowed in
a subquery); false to restrict subqueries so that they are only allowed
to specify proeprties that are allowed for an ordinary client requestsetOutputs(java.util.List)
. Will return
null if the client did not send a list of outputs and no manual server-side call to
setOutputs() has been made. Note that this is not the definitive list of fields to be
returned to the client - for that, see
getConsolidatedOutputs()
This method is called during DSRequest construction to set the list of output fields
requested by the client. Therefore, you can call this method from a DMI, custom
DataSource or other custom server side code to override the output fields requested by
the client. Note that this is not the definitive list of fields to be returned to the
client - for that, see getConsolidatedOutputs()
outputs
- the list of requested outputs as a List of String, or nullDSField
s specified in this DSRequest's
"additionalOutputs" property. "additionalOutputs" is a comma separated
String
of requested fields not defined in the dataSource directly.
The field is defined in the form of "fieldName:includeFrom".List
of DSField
s specified in the DSRequest's
"additionalOutputs" property.exportResults
- true if results are to be exportedexportAs
- one of "csv", "xml", "json", "xls"exportDelimiter
- the character to use as a delimiter in CSV exportsexportTitleSeparatorChar
- the character to replace spaces with in XML field-titles.exporting to the server filesystem
. This is also used
to name the downloaded file if we are exporting to the client
,
but only if the server.properties
flag RPCManager.downloadsRelyOnFilenameInURL
is set false. The default value of true for that flag means that the server will
always use the name that the client requested for the downloaded file, so a call to this
method will have no effect (the reason for this default is that it gives the most
predictably correct results when dealing with filenames expressed in non-Latin character
sets).
When no filename is provided, the default is "Results".
exportFilename
- the name of the file to save the exported data intoexportPath
- Path to applyexportDisplay
- one of "window" or "download"lineBreakStyle
- the linebreak style to use in the exported dataexportFields
- the list of field-names to exportexportFieldTitles
- the list of field-names to exportstoreWithHash
that already contain hashed
values in this request, and that therefore should not be rehashed. The common case is
where those values have been copied from an existing (already hashed) record.hashedFields
- the list of field names that already have hashed contentexportHeader
- Optional text to appear above the dataexportHeaderless
- If true, the column names will be omitted from CSV and Excel exports.streamResults
- true to cause data to be streamedexportFilename
on
the server filesystem. See also setExportToClient(boolean)
Note this is automatically set to true
if
setExportTo(java.io.OutputStream)
is called.
exportToFilesystem
- true to cause the export data to be written to the server
filesystemsetExportToFilesystem(boolean)
is also set, we will
both download the exported data and write it to a filesystem file on the server. If
neither of these is set, the export operation no-ops.exportToClient
- true to cause the exported data to be downloaded to the clientsetExportTo(OutputStream)
API, it will be null.Also note that we perform the export synchronously as part of the DSRequest's execute flow when a user-provided OutputStream is in place. This allows you to make use of the OutputStream immediately after executing the request from a DMI, like this:
OutputStream myStream = new MyOutputStream(); dsRequest.setExportTo(myStream); DSResponse resp = dsRequest.execute(); // Do something with "myStream" here
exportOutputStream
- An OutputStream to use for the exporttrue
if it is REST request.Boolean
true
- REST request.isREST
- Boolean
true
- REST request.true
if it is a raw REST mode request.Boolean
true
- raw REST request.isRawREST
- Boolean
true
- raw REST request.String
REST request data format.dataFormat
- String
REST request data format. Accepted values: 'xml' or 'json'.true
if JSON responses should be wrapped with markers.Boolean
true
- JSON responses will be wrapped with markers; false
- JSON responses will contain plain objects.wrapJSONResponses
- boolean
true
- JSON responses will be wrapped with markers; false
- JSON responses will contain plain objects.String
JSON prefix marker.jsonPrefix
- String
JSON prefix marker.String
JSON suffix marker.jsonSuffix
- String
JSON suffix marker.rolesString
- A comma-separated String containing the user roles to set for this requestroles
- the user roles to set for this request.These roles are compared against when declarative security runs against this request. If this method is called this request will also be marked as a client request which in turn enables declarative security checks for it.
userRoles
- the user roles to set for this request. This value will be used by the framework to populate fields of types "creator" and "modifier". This API is intended for use when you are a using some custom authentication scheme - it is unnecessary if you are using the Servlet API for authentication, because we will default to using the value returned by HttpServletRequest.getRemoteUser()
.
If this method is called this request will also be marked as a client request which in turn enables declarative security checks for it.
userId
- the user id to set for this request.BaseRequest.setContext(RequestContext)
instead.key
- The key of the object in the DSRequest's attribute mapAttributes set on the DSRequest are not serialized and sent to the browser. Custom attributes exist solely for passing extra information between different server-side subsystems that might process the DSRequest. For example: Java logic in a DMI might set attributes on a DSRequest to cause differences in processing by a custom DataSource that checks for those attributes.
key
- The key of the object in the DSRequest's attribute mapvalue
- The object to storekey
- The key of the object in the DSRequest's attribute mapsetJoinTransaction(Boolean)
, which overrides any setting derived from configuration. This method is only applicable to DSRequests for a DataSource that supports transaction management. SmartClient's built-in SQL and Hibernate DataSources both have transaction support. If you intend to write a DataSource that supports transactions, you should call this method to determine if user code has overridden configuration settings for this DSRequest.
See the client-side documentation for details of configuring automatic transaction support.
setTransactionPolicy
For a manually created dsRequest (one not sent by the client), in order to participate in the current automatic transaction, setRPCManager(RPCManager)
must be called. Then, the dsRequest will automatically participate in the current automatic transaction (if there is one) without the need to call this method.
This method is only applicable to DSRequests for a DataSource that supports transaction management. SmartClient's built-in SQL and Hibernate DataSources both have transaction support.
Note that this method can only be called on a DSRequest that has not yet started processing; it will fail with an exception if it is called on a request that has already started.
See the client-side documentation for details of configuring automatic transaction support.
newValue
- Set true to force this DSRequest's update to start or join a transaction; false to force this DSRequest's update to be auto-committed independently of any other update in the queue; null to revert to configuration settings (this is the default if this method is never called)com.isomorphic.datasource.DSRequestAlreadyStartedException
- if this DSRequest has already started processing Typically, there is no need to call freeAllResources
because it is automatically handled by the framework. You only need to call this API when all of the following apply:
setRPCManager()
on the request, ANDsetFreeOnExecute(false)
on the DSRequest, or the default setting of freeOnExecute
is false for this type of request.setRPCManager()
or setDSTransaction()
on server-created DSRequests because this is required in order to participate in automatically managed transactions. Regarding 3), any DSRequest that targets a SQLDataSource and retrieves data from a binary column (CLOB) is freeOnExecute:false
by default, since otherwise most JDBC drivers will close the InputStream used to read binary data.
Also, any DSRequest targeting HibernateDataSource or JPADataSource is freeOnExecute:false
by default in order to allow traversing lazy entity associations.
Note that the resources freed by this API are made immediately available to other threads: do not cache DataSource instances or other resources and attempt to reuse them after calling this API. In general, use this API only if you are sure you have to (because you have a DSRequest like the one described above), and even then use it with care; ideally, call it as the last thing you do immediately before your DMI method ends.
freeAllResources
in class BaseRequest<DSRequest,DSResponse>
If you pass true to this method, it causes resources used by the DSRequest (including the DataSource object and implementation-specific resources such as database connections) to be freed early - as soon as the DSRequest has finished executing. If you pass false, it causes those resource to be freed late - during final cleanup by the RPCManager if setRPCManager()
has been called, otherwise, when your code manually calls freeAllResources()
, otherwise, by the DSRequest's finalizer when garbage collection occurs.
Generally, you should use freeOnExecute(true)
- the default - as this is the most efficient thing to do. However, there are times when you need the resources to be retained - for example, if you have a server-side DSRequest that streams its results.
See freeAllResources()
for a further discussion of scenarios where immediate cleanup is not desirable.
freeOnExecute
- as described abovegetDroppedFields()
Note, the list returned by this method is a copy, and thus should be considered read-only.
If the criteria is already Advanced and either:
Note that this is the only version of addToCriteria()
that attempts to automatically preserve simple criteria semantics as described above. If you do not want this behavior, use one of the other signatures of this method.
fieldName
- The field name to use in the criteriavalue
- The filter value to applyException
addToCriteria(Criterion)
, but passing criterion data as individual parameters.fieldName
- The field name to use in the criteriaoperator
- The operatorId to usevalue
- The filter value to applyException
addToCriteria(Criterion)
, but passing criterion data as individual parameters.fieldName
- The field name to use in the criteriaoperator
- The operatorId to usevalue
- An array of valuesException
addToCriteria(Criterion)
, but passing criterion data as individual parameters. Note that this method uses OperatorBase parameter as operator ID to avoid typos.fieldName
- The field name to use in the criteriaoperator
- The operatorBase to usevalue
- The filter value to applyException
addToCriteria(Criterion)
, but passing criterion data as individual parameters. Note that this method uses OperatorBase parameter as operator ID to avoid typos.fieldName
- The field name to use in the criteriaoperator
- The operatorBase to usevalue
- An array of valuesException
addToCriteria(Criterion)
, but passing criterion data as individual parameters.fieldName
- The field name to use in the criteriaoperator
- The operatorId to usevalue
- The filter value to apply, for comparison operators like "contains"start
- The range-start value to apply, for range operators like "between"end
- The range-end value to apply, for range operators like "between"Exception
two argument signature
of this method. If the DSRequest's criteria is simple, the simple criteria is converted to an equivalent AdvancedCriteria and then processed as if the criteria had been Advanced all along, which is to amend the criteria as follows:
criterion
- The criterion to use in the criteriaException
In a completely custom DataSource (ie, one that extends BasicDataSource
), you should add a call to this method if you want the protection it provides against null key values. The simplest thing to do is what the built-in DataSources do - throw an UpdateWithoutPKException
if this method returns a non-empty List.
Note that this method honors the operationBinding setting "allowMultiUpdate" - if that property is set for the operation this DSRequest is running, this method always returns an empty List. Also, it is possible to switch off key checking for "add" operations altogether by setting the property validate.primaryKeys.for.add
to false
in your server.properties
file. Finally, be aware that primaryKey fields that declare a customInsertExpression
are never considered to have "missing values", because it is assumed that the custom expression will cause a value to appear at SQL generation or execution time.
Exception
skipCacheSync
- true
if cacheSync must be skipped, false
if it must be performed.true
if cacheSync must be skipped, false
if it must be performed.skipAudit
- true
if auditing must be skipped, false
if it must be performed.true
if auditing must be skipped, false
if it must be performed.canSyncCache
-
BaseRequest.getContext()
instead.