|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.isomorphic.datasource.DSRequest
public class DSRequest
Server-side representation of a DataSource request initiated by a client-side DataBoundComponent or programmatically by custom client-side JavaScript.
When databound components need to load or persist data, they make Ajax background requests to the server. Those requests are decoded into DSRequest Java objects by SmartClient's server-side Java libraries.
You obtain a DSRequest by either:
RPCManager and calling
com.isomorphic.rpc.RPCManager.getDSRequest or com.isomorphic.rpc.RPCManager.getRequests.
DSRequests can also be used entirely server-side. Your server-side Java code can create a
DSRequest via "new DSRequest()" at any time, and call execute() on it in order to perform
operations against DataSources. These requests
are processed by SmartClient Server exactly as if they had come from the client.
If you are integrating SmartClient with a pre-existing Java data store, you can call various
getters on the DSRequest, such as
DSRequest.getCriteria(), to retrieve request parameters that
you can then use with your pre-existing data store. For example, when working with an ORM
(Object Relational Mapping) system, a typical way of processing an "update" DSRequest is to:
DataTools.setProperties() to
apply new properties to the object, based on the Java Beans naming convention
Built-in connectors: SQL, Hibernate and JPA
The SmartClient Server can also automatically process DSRequests from DataSources with
serverType="sql", "hibernate" or "jpa". In this case, you can call
DSRequest.execute() to cause the default behavior to occur, which will return a
DSResponse populated with data supplied by JPA, Hibernate or SQL.
By modifying the DSRequest before you call execute() and by modifying the DSResponse you receive, you can combine SmartClient's built-in persistence engine support with custom processing.
For example, if you have a SQL table of records that are specific to each user, and there is a column containing the user's id, you could use setFieldValue() to ensure the DSRequest always contains the user's id. This would ensure that fetch, add, update and remove operations are always restricted to the user's own data.
RPCManager,
DSResponse| Field Summary | |
|---|---|
static long |
ENDROW_UNSET
If endRow is set to this constant, then there is no set bound for the number of records the server should return for the current request. |
RPCManager |
rpc
Deprecated. |
| Constructor Summary | |
|---|---|
DSRequest(java.lang.String dataSourceName,
java.lang.String operationType)
Creates an empty DSRequest bound to the named datasource with the specified operationType. |
|
DSRequest(java.lang.String dataSourceName,
java.lang.String operationType,
RPCManager rpcManager)
Creates an empty DSRequest bound to the named datasource with the specified operationType, and associated with the specified RPCManager. |
|
| Method Summary | |
|---|---|
DSRequest |
addToCriteria(java.lang.String fieldName,
java.lang.String operator,
java.lang.Object value)
Adds a criterion of the form { fieldName operator value } to this DSRequest's existing criteria. |
DSRequest |
addToTemplateContext(java.lang.String name,
java.lang.Object value)
If you're using the Velocity-based SQL Templating, you can make additional Java objects available to the the template context by calling this method. |
DSRequest |
clearUploadedFiles()
Clears any uploaded files from this DSRequest. |
DSResponse |
execute()
Executes this DSRequest and returns a DSResponse. |
java.util.List |
getAdditionalOutputs()
Creates and returns a list of DSFields specified in this DSRequest's
"additionalOutputs" property. |
AdvancedCriteria |
getAdvancedCriteria()
Returns the advanced criteria for this operation. |
java.lang.Object |
getAttribute(java.lang.String key)
Returns an Object that has previously been stored in this DSRequest's attribute map. |
java.util.Iterator |
getAttributeNames()
Returns an Iterator that can be used to obtain all the keys in the DSRequest's attribute map. |
java.util.Map |
getClientSuppliedCriteria()
Returns the criteria submitted by the client for this operation as a set of key-value pairs where the keys are field names and the values are field values. |
java.util.Map |
getClientSuppliedValues()
Returns the values that the client submitted for this operation as a set of key-value pairs where the keys are field names and the values are field values. |
java.lang.String |
getComponentId()
Optional componentId passed by the client. |
java.util.Map |
getCriteria()
Returns the criteria for this operation as a set of key-value pairs where the keys are field names and the values are field values. |
java.util.List |
getCriteriaSets()
Returns the criteria in the request as a List, even if singular. |
java.lang.Object |
getCriteriaValue(java.lang.Object fieldName)
Returns the value provided in criteria for a particular fieldName. |
java.lang.String |
getDataFormat()
Resturns data format for REST request. Possible values: "xml" and "json". |
DataSource |
getDataSource()
Returns an instance of class DataSource for this DSRequest. |
java.lang.String |
getDataSourceName()
Returns the dataSourceName for this DSRequest. |
long |
getEndRow()
Returns the index of the last requested record. |
java.io.OutputStream |
getExportTo()
Returns the OuputStream we will use for data export. |
java.lang.Object |
getFieldValue(java.lang.Object fieldName)
Returns the value for a particular fieldName. |
javax.servlet.http.HttpServletRequest |
getHttpServletRequest()
Returns the HttpServletRequest associated with this DSRequest. |
boolean |
getIsAdvancedCriteria()
Check if current criteria is advanced. |
java.lang.String |
getJsonPrefix()
Returns prefix marker for JSON responses. |
java.lang.String |
getJsonSuffix()
Returns suffix marker for JSON responses. |
java.util.List |
getMissingPrimaryKeysForAdd()
Validates that this DSRequest has a value present for every non-generated primaryKey. |
java.util.Map |
getOldValues()
For an "update" or "remove" operation, returns the complete original record as it was delivered to the client, as a set of key-value pairs where the keys are field names and the values are field values. |
java.util.List |
getOldValueSets()
Returns the oldValues in the request as a List, even if singular. |
java.lang.String |
getOperationId()
Optional operationId passed by the client. |
java.lang.String |
getOperationType()
Returns the type of this DataSource operation. |
java.util.List |
getOutputs()
Returns the list of output fields requested by the client, or configured in the operationBinding. |
boolean |
getPendingAddFlag()
Returns the pendingAdd flag associated with this DSRequest |
java.lang.Boolean |
getREST()
Resturns true if it is REST request. |
RPCManager |
getRPCManager()
Returns the RPCManager associated with this DSRequest, if there is one. |
javax.servlet.ServletContext |
getServletContext()
Returns the ServletContext associated with this DSRequest. |
java.util.List |
getSortByFields()
The sortBy specification is only valid for the fetch operation since it specifies the sort order for the returned data. |
long |
getStartRow()
When components that are capable or showing multiple records at once are bound to datasources with large datasets, it becomes important to only send those records that are currently visible in the component (or can become visible with a typical user action). |
java.lang.String |
getTextMatchStyle()
Returns the textMatchStyle in force for this DSRequest, or null if none is set. |
ISCFileItem |
getUploadedFile(java.lang.String fieldName)
|
java.util.List |
getUploadedFiles()
|
java.io.InputStream |
getUploadedFileStream(java.lang.String fieldName)
|
java.util.List |
getUploadedFileStreams()
|
java.lang.String |
getValidationMode()
Returns the validationMode associated with this DSRequest |
java.util.Map |
getValues()
Returns the values for this operation as a set of key-value pairs where the keys are field names and the values are field values. |
java.util.List |
getValueSets()
Returns the values in the request as a List, even if singular. |
java.lang.Boolean |
getWrapJSONResponses()
Returns true if JSON responses should be wrapped with markers. |
boolean |
isPaged()
Returns true if the current request has is requestinga partial set of data using startRow/endRow parameters. |
DSRequest |
removeAttribute(java.lang.String key)
Removes an Object that has previously been stored in this DSRequest's attribute map. |
DSRequest |
setAdvancedCriteria(AdvancedCriteria advancedCriteria)
Sets the criteria for this request to the provided AdvancedCriteria. |
DSRequest |
setAllowMultiUpdate(boolean newValue)
Sets an internal flag for this DSRequest to determine whether updates and deletes are allowed in the absence of primaryKey fields. |
DSRequest |
setAttribute(java.lang.String key,
java.lang.Object value)
Stores an object in this DSRequest's attribute map, associated with the passed key. |
DSRequest |
setCriteria(java.lang.Object criteria)
Sets the criteria for this DSRequest. |
DSRequest |
setCriteria(java.lang.String fieldName,
java.lang.Object value)
Sets the criteria for this DSRequest. |
java.lang.Object |
setCriteriaValue(java.lang.String fieldName,
java.lang.Object value)
Amends the request's criteria with the restriction that the indicated field equals the provided value. |
DSRequest |
setDataFormat(java.lang.String dataFormat)
Sets data format for REST request. |
DSRequest |
setEndRow(long endRow)
Sets the index of the last requested record. |
DSRequest |
setExportAs(java.lang.String exportAs)
The format in which to export data. |
DSRequest |
setExportDelimiter(java.lang.String exportDelimiter)
The delimiter to use for CSV-type exports |
DSRequest |
setExportDisplay(java.lang.String exportDisplay)
How should the exported data be displayed to the user? If not provided, the default is "window". |
DSRequest |
setExportFields(java.util.List exportFields)
The list of fields to export. |
DSRequest |
setExportFieldTitles(java.util.Map exportFieldTitles)
A map containing the titles to use for each field to be exported. |
DSRequest |
setExportFilename(java.lang.String exportFilename)
The name of the file to save the exported data into. |
DSRequest |
setExportFooter(java.lang.String exportFooter)
Optional text to appear at the bottom of the export file. |
DSRequest |
setExportHeader(java.lang.String exportHeader)
Optional text to appear at the top of the export file. |
DSRequest |
setExportHeaderless(boolean exportHeaderless)
This property allows omitting column names from CSV and Excel exports (no effect on JSON or XML exports). |
DSRequest |
setExportPath(java.lang.String exportPath)
Optional path to apply when saving exported data to the filesystem, relative to the base location specified in server.properties setting "export.location" |
DSRequest |
setExportResults(java.lang.Boolean exportResults)
Set the flag indicating whether the results of this request should be exported |
DSRequest |
setExportTitleSeparatorChar(java.lang.String exportTitleSeparatorChar)
The separator character to replace spaces with in XML field-titles. |
DSRequest |
setExportTo(java.io.OutputStream exportOutputStream)
Sets the OuputStream we will use for data export (this means exports to CSV, XML, JSON and Excel formats; PDF exports are "content exports" and are different). |
DSRequest |
setExportToClient(boolean exportToClient)
If true, we download the exported data to the client. |
DSRequest |
setExportToFilesystem(boolean exportToFilesystem)
If true, we export the data to the file named by property exportFilename on
the server filesystem. |
DSRequest |
setFieldValue(java.lang.Object fieldName,
java.lang.Object value)
Sets the value for a particular fieldName, in criteria or values according to the operation type. |
DSRequest |
setFreeOnExecute(boolean freeOnExecute)
Ordinarily, this value is managed transparently by the RPCManager controlling the queue that the DSRequest is part of. |
DSRequest |
setJoinTransaction(java.lang.Boolean newValue)
Sets the join transaction setting for this DSRequest. |
DSRequest |
setJsonPrefix(java.lang.String jsonPrefix)
Sets prefix marker for JSON responses. |
DSRequest |
setJsonSuffix(java.lang.String jsonSuffix)
Sets suffix marker for JSON responses. |
DSRequest |
setLineBreakStyle(java.lang.String lineBreakStyle)
The linebreak style in the exported data. |
DSRequest |
setOldValues(java.util.Map oldValues)
Sets the "old values" for this DSRequest (ie, the values as they were before the set of changes represented by this request). |
DSRequest |
setOperationId(java.lang.String operationId)
For server-initiated DSRequests, sets the operationId to control which operationBinding is used when fulfilling the requests. |
DSRequest |
setOperationType(java.lang.String operationType)
Sets the operation type. |
DSRequest |
setOutputs(java.util.List outputs)
Sets the list of output fields to be returned by this request. |
DSRequest |
setPartOfTransaction(boolean newValue)
Call this method to indicate that a user-written operation is participating in the SmartClient-managed transaction. |
DSRequest |
setPendingAddFlag(boolean pendingAdd)
Sets the pendingAdd flag associated with this DSRequest |
DSRequest |
setREST(java.lang.Boolean isREST)
Sets flag indicating whether it is REST request. |
DSRequest |
setRPCManager(RPCManager rpc)
Associates this DSRequest with the specified RPCManager. |
DSRequest |
setSortBy(java.lang.Object sortBy)
Sets the field or fields to sort by. |
DSRequest |
setStartRow(long startRow)
Sets the index of the first requested record. |
DSRequest |
setStreamResults(boolean streamResults)
If true, results will be streamed one record at a time; if false, we will read all records into memory at once |
DSRequest |
setTextMatchStyle(java.lang.String textMatchStyle)
Sets the textMatchStyle in force for this DSRequest. |
DSRequest |
setValidationMode(java.lang.String validationMode)
Sets the validationMode associated with this DSRequest |
DSRequest |
setValues(java.lang.Object values)
Sets the values for this DSRequest. |
DSRequest |
setWrapJSONResponses(java.lang.Boolean wrapJSONResponses)
Sets flag should JSON responses be wrapped with markers. |
java.lang.Boolean |
shouldJoinTransaction()
Returns the join transaction setting for this DSRequest. |
ErrorReport |
validate()
Performs validation on the values in this DSRequest. |
| Field Detail |
|---|
public RPCManager rpc
public static final long ENDROW_UNSET
DSRequest.getEndRow(),
Constant Field Values| Constructor Detail |
|---|
public DSRequest(java.lang.String dataSourceName,
java.lang.String operationType)
dataSourceName - name of the datasource for this requestoperationType - operationType for this request
public DSRequest(java.lang.String dataSourceName,
java.lang.String operationType,
RPCManager rpcManager)
dataSourceName - name of the datasource for this requestoperationType - operationType for this requestrpcManager - The RPCManager in use for this request| Method Detail |
|---|
public DSRequest setPartOfTransaction(boolean newValue)
You do not need to call this method on DSRequests that will be fulfilled by built-in Hibernate or SQL functionality, and you should not do so.
If you neglect to call this method on a user-fulfilled DSRequest, it will not affect the transaction; if you use the transaction object to perform the storage operation, it will be part of the transaction regardless. However, SmartClient Server may return misleading status codes to the client in the event of a rollback if this method is not called.
To understand why this is, consider a situation where your JDBC update works correctly; the DSResponse is marked with a success status. However, an error in a later update in the same transaction causes your successful update to be rolled back. Now your update was not successful; it should be marked as STATUS__TRANSACTION_FAILED, so that the client knows that the data has not been persisted. If your code has not called setPartOfTransaction() appropriately, the server has no way of knowing that this step ought to take place.
BasicDataSource.getTransactionObject()public java.lang.String getTextMatchStyle()
public DSRequest setTextMatchStyle(java.lang.String textMatchStyle)
public java.lang.String getOperationType()
public DSRequest setOperationType(java.lang.String operationType)
operationType - the operation type - see above for valid values.
public java.lang.String getOperationId()
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.
public DSRequest setOperationId(java.lang.String operationId)
operationId - the operationId to use
DSRequest.getOperationId()public java.lang.String getComponentId()
For requests submitted by a SmartClient DataBoundComponent, this is the component ID.
public java.util.Map getCriteria()
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.
DSRequest.getValues()public AdvancedCriteria getAdvancedCriteria()
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.
public boolean getIsAdvancedCriteria()
AdvancedCriteria has "_constructor" parameter set to "AdvancedCriteria".
public DSRequest setAdvancedCriteria(AdvancedCriteria 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 DSRequest
DSRequest.getCriteria()public java.util.Map getClientSuppliedCriteria()
getCriteria(),
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.
DSRequest.getCriteria(),
DSRequest.getClientSuppliedValues()public java.util.List getCriteriaSets()
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.
DSRequest.getCriteria(),
DSRequest.getValueSets()public DSRequest setCriteria(java.lang.Object criteria)
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 with AdvancedCriteria
helper classes: AdvancedCriteria exists to assist in
modifying the criteria.
If AdvancedCriteria passed to this method setAdvancedCriteria method will be used.
criteria - Map or List of Maps: the criteria to use for this DSRequest
DSRequest.getCriteria()
public DSRequest setCriteria(java.lang.String fieldName,
java.lang.Object value)
fieldName - The field namevalue - The criterion value
DSRequest.getCriteria()public DSRequest clearUploadedFiles()
public ISCFileItem getUploadedFile(java.lang.String fieldName)
throws java.lang.Exception
fileName - Form field of type 'binary'.
java.lang.Exceptionpublic java.util.List getUploadedFiles()
public java.io.InputStream getUploadedFileStream(java.lang.String fieldName)
throws java.lang.Exception
fileName - Form field of type 'binary'.
java.lang.Exceptioncom.isomorphic.servlet.ISCFileItem.getInputStream()public java.util.List getUploadedFileStreams()
com.isomorphic.servlet.ISCFileItem.getInputStream()public java.util.Map getValues()
If 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.
DSRequest.getCriteria(),
DSRequest.getOldValues(),
DSRequest.getClientSuppliedValues()public java.util.Map getClientSuppliedValues()
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.
DSRequest.getCriteria(),
DSRequest.getOldValues(),
DSRequest.getClientSuppliedValues()public java.util.List getValueSets()
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.
DSRequest.getValues(),
DSRequest.getCriteriaSets()public DSRequest setValues(java.lang.Object values)
values - Map or List of Maps - the values to use for this DSRequest
public java.util.Map getOldValues()
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.
DSRequest.getValues()public java.util.List getOldValueSets()
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.
DSRequest.getOldValues()public DSRequest setOldValues(java.util.Map oldValues)
values - Map - the old values to use for this DSRequest
public java.util.List getSortByFields()
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 curent filter criteria).
public DSRequest setSortBy(java.lang.Object sortBy)
sortBy - String or List of Strings: field or list of fields to sort by.
DSRequest.getSortByFields()public boolean isPaged()
DSRequest.getStartRow(),
DSRequest.getEndRow(),
DSRequest.ENDROW_UNSETpublic long getStartRow()
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.
DSRequest.getEndRow(),
DSRequest.isPaged()public DSRequest setStartRow(long startRow)
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)
public long getEndRow()
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.
DSRequest.getStartRow(),
DSRequest.ENDROW_UNSETpublic DSRequest setEndRow(long endRow)
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)
public java.lang.Object getFieldValue(java.lang.Object fieldName)
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
public java.lang.Object getCriteriaValue(java.lang.Object fieldName)
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 up
public java.lang.Object setCriteriaValue(java.lang.String fieldName,
java.lang.Object value)
AdvancedCriteria, 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 equal
fieldName is
already referenced in the criteria, then the overwritten
criterion value; otherwise null
public DSRequest setFieldValue(java.lang.Object fieldName,
java.lang.Object value)
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 were called
fieldName - the fieldName whose value you want to setvalue - the value to set for the fieldpublic java.lang.String getDataSourceName()
public DataSource getDataSource()
throws java.lang.Exception
java.lang.ExceptionDataSource,
DSRequest.getDataSourceName()public java.lang.String getValidationMode()
public DSRequest setValidationMode(java.lang.String validationMode)
public boolean getPendingAddFlag()
public DSRequest setPendingAddFlag(boolean pendingAdd)
public ErrorReport validate()
throws java.lang.Exception
If validation is successful for all fields, this method returns null. Otherwise it returns an ErrorReport for the first record that encountered a validation error.
java.lang.ExceptionErrorReport,
ErrorMessage
public DSResponse execute()
throws java.lang.Exception
java.lang.Exception
public DSRequest addToTemplateContext(java.lang.String name,
java.lang.Object value)
name - the name of the new object as it should appear in the Velocity namespacevalue - arbitrary Java object
public DSRequest setAllowMultiUpdate(boolean newValue)
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 provided
public java.util.List getOutputs()
public DSRequest setOutputs(java.util.List outputs)
This method is called during DSRequest construction to set the list of output fields requested by the client, or configured in the operationBinding. 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 or configured declaratively.
outputs - the list of requested outputs as a List of String, or null
public java.util.List getAdditionalOutputs()
DSFields 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 DSFields specified in the DSRequest's
"additionalOutputs" property.public DSRequest setExportResults(java.lang.Boolean exportResults)
exportResults - true if results are to be exported
public DSRequest setExportAs(java.lang.String exportAs)
exportAs - one of "csv", "xml", "json", "xls"
public DSRequest setExportDelimiter(java.lang.String exportDelimiter)
exportDelimiter - the character to use as a delimiter in CSV exports
public DSRequest setExportTitleSeparatorChar(java.lang.String exportTitleSeparatorChar)
exportTitleSeparatorChar - the character to replace spaces with in XML field-titles.
public DSRequest setExportFilename(java.lang.String exportFilename)
exportFilename - the name of the file to save the exported data into
public DSRequest setExportPath(java.lang.String exportPath)
exportPath - Path to apply
public DSRequest setExportDisplay(java.lang.String exportDisplay)
exportDisplay - one of "window" or "download"
public DSRequest setLineBreakStyle(java.lang.String lineBreakStyle)
lineBreakStyle - the linebreak style to use in the exported data
public DSRequest setExportFields(java.util.List exportFields)
exportFields - the list of field-names to export
public DSRequest setExportFieldTitles(java.util.Map exportFieldTitles)
exportFields - the list of field-names to export
public DSRequest setExportHeader(java.lang.String exportHeader)
exportHeader - Optional text to appear above the data
public DSRequest setExportHeaderless(boolean exportHeaderless)
exportHeaderless - If true, the column names will be omitted from CSV and Excel exports.
public DSRequest setExportFooter(java.lang.String exportFooter)
exportFooter - Optional text to appear below the data
public DSRequest setStreamResults(boolean streamResults)
streamResults - true to cause data to be streamed
public DSRequest setExportToFilesystem(boolean exportToFilesystem)
exportFilename on
the server filesystem. See also @link(com.isomorphic.datasource.DSRequest#setExportToClient)
exportToFilesystem - true to cause the export data to be written to the server
filesystem
public DSRequest setExportToClient(boolean exportToClient)
exportToClient - true to cause the exported data to be downloaded to the client
public java.io.OutputStream getExportTo()
com.isomorphic.datasource.DSResponse#exportTo(OutputStream)
API, it will be null.
public DSRequest setExportTo(java.io.OutputStream exportOutputStream)
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 export
public java.lang.Boolean getREST()
true if it is REST request.
Boolean true - REST request.public DSRequest setREST(java.lang.Boolean isREST)
isREST - Boolean true - REST request.
public java.lang.String getDataFormat()
String REST request data format.public DSRequest setDataFormat(java.lang.String dataFormat)
jsonSuffix - String REST request data format.
Accepted values: 'xml' or 'json'.
public java.lang.Boolean getWrapJSONResponses()
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.public DSRequest setWrapJSONResponses(java.lang.Boolean wrapJSONResponses)
wrapJSONResponses - boolean true - JSON responses
will be wrapped with markers; false - JSON responses will contain
plain objects.
public java.lang.String getJsonPrefix()
String JSON prefix marker.public DSRequest setJsonPrefix(java.lang.String jsonPrefix)
jsonSuffix - String JSON prefix marker.
public java.lang.String getJsonSuffix()
String JSON suffix marker.public DSRequest setJsonSuffix(java.lang.String jsonSuffix)
jsonSuffix - String JSON suffix marker.
public RPCManager getRPCManager()
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
public javax.servlet.ServletContext getServletContext()
public DSRequest setRPCManager(RPCManager rpc)
Note that there is also a convenience constructor that allows you to pass an RPCManager in during construction.
Note that setting an RPCManager on a server-created DSRequest causes that DSRequest to begin behaving as if it had come from the client; one effect of this is that update and remove operations are rejected unless the DSRequest correctly specifies primaryKey fields (this restriction is not usually enforced for server-side DSRequests). If you need to correct this side-effect, you can use setAllowMultiUpdate().
rpcManager - The RPCManager to use for this request
com.isomorphic.rpc.RPCManager.setAllowMultiUpdatepublic java.lang.Object getAttribute(java.lang.String key)
key - The key of the object in the DSRequest's attribute map
com.isomorphic.rpc.RPCManager.getAttributepublic java.util.Iterator getAttributeNames()
com.isomorphic.rpc.RPCManager.getAttribute
public DSRequest setAttribute(java.lang.String key,
java.lang.Object value)
key - The key of the object in the DSRequest's attribute mapvalue - The object to store
com.isomorphic.rpc.RPCManager.setAttributepublic DSRequest removeAttribute(java.lang.String key)
key - The key of the object in the DSRequest's attribute mapcom.isomorphic.rpc.RPCManager.removeAttributepublic java.lang.Boolean shouldJoinTransaction()
setJoinTransaction, 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 trhat 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.
public DSRequest setJoinTransaction(java.lang.Boolean newValue)
throws DSRequestAlreadyStartedException
setTransactionPolicy
For a manually created dsRequest (one not sent by the client), in order to participate in the
current automatic transaction, setRPCManager 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.
Boolean.TRUE - to force this DSRequest's update to start or join a transaction;
Boolean.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)
DSRequestAlreadyStartedException - if this DSRequest has already started processingshouldJoinTransactionpublic DSRequest setFreeOnExecute(boolean freeOnExecute)
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 in the normal case, but for server-only DSRequests, by your own code or, failing that, by the DSRequest's finalizer.
Generally, you should use freeOnExecute(true) - the default- as this is the most efficient thing to do. However, there are time when you need the resources to be retained - for example, if you have a server-side DSRequest that streams its results.
true - or false, as described above
public DSRequest addToCriteria(java.lang.String fieldName,
java.lang.String operator,
java.lang.Object value)
throws java.lang.Exception
If the DSRequest's criteria is simple and the operator is "equals" or null, this method just adds the provided fieldName and value as an extra key/value pair in the simple criteria map. If the DSRequest's criteria is simple and the operator is some other value, 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:
fieldName - The field name to use in the criteriavalue - The filter value to apply
java.lang.Exception
public java.util.List getMissingPrimaryKeysForAdd()
throws java.lang.Exception
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
anh 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.
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||