LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer.sql
Class LySqlRequestEncoder

java.lang.Object
  extended by leon.peer.LyRequestEncoder
      extended by leon.peer.LyBlobRequestEncoder
          extended by leon.peer.sql.LySqlRequestEncoder
All Implemented Interfaces:
LyJoinRequestEncoder
Direct Known Subclasses:
LyAccessRequestEncoder, LyHsqldbRequestEncoder, LyIdbRequestEncoder, LyMySqlRequestEncoder, LyPostgresqlRequestEncoder

public class LySqlRequestEncoder
extends LyBlobRequestEncoder
implements LyJoinRequestEncoder

This class is used to send requests to a SQL database connection and to receive its answers.

See Also:
LyRequestEncoder, LySqlConnection, LySqlDataProvider

Field Summary
static java.lang.String __VERSION
           
static char CHAR_QUOTE
           
static java.lang.String DOMAIN_FILTER_RELATION
           
static java.lang.String STRING_QUOTE
           
static java.lang.String STRING_TWO_QUOTES
           
 
Fields inherited from class leon.peer.LyBlobRequestEncoder
MAX_BLOB_BUFFER
 
Constructor Summary
LySqlRequestEncoder(LyDataProvider provider, LyDataSource dataSource, java.lang.String valueSep)
          Constructor.
 
Method Summary
 java.lang.Object buildObject(LyUnionRequestEncoder encoder, LyClass peerClass)
          Return a new instance of the specified class.
 LySqlRequestInfo clearChildRequestInfo(LySqlRequestEncoder encoder)
          We are noi longer the parent of the specified encoder's request info the specified encoders's request info becomes a new child of current context.
 java.lang.String completeSelectedFields(java.util.Vector<java.lang.String> existingFields, LySort sort, boolean needDistinct, java.lang.String tableName)
          Used to add a list of fields to a select request.
 java.lang.String completeSelectedFields(java.util.Vector<java.lang.String> existingFields, LySortCriterion criterion, java.lang.String tableName)
          Used to add a list of fields to a select request.
 boolean createObject(java.lang.Object object)
          To create a new object.
 boolean deleteObject(java.lang.Object object)
          To delete an object.
 boolean deleteObjects(java.util.Vector<java.lang.Object> objects)
          To delete an object.
 java.lang.String encodeLimitCondition(int limit)
          encode the limit condition.
 java.util.Vector<LyFilter> getFilters(LyUnionBinding unionBinding)
          Look for filters inside a LyUnionBinding.
 boolean getObject(LyObjectId objectId, java.util.Vector<LyField> fields)
          Get an object.
 java.util.Collection<LyValueSet> getObjects(LyUnionRequestEncoder encoder, java.util.Vector<LyField> fields, LySort sort, LyFilter filter, int n)
          Get a set of objects with a join request.
 boolean getObjects(java.util.Vector<LyField> fields, LySort sort, LyFilter filter, int n)
          Get a set of objects.
 LySqlRequestInfo getRequestInfo()
          Get or create the request info : this is the context for aliases and encoding info to generate the request.
 boolean getSize(LyFilter filter)
          Return the number of objects from the data provider .
 java.lang.Integer getSize(LyUnionRequestEncoder encoder, LyFilter filter)
          Return the number of objects from the data provider with a join request.
 java.lang.String getSQLFormatDate(java.lang.String quotedId, LyDateFieldInfo fieldInfo)
          String force formating date for order by using FORMAT(quotedId, 'YYYY-MM-DD HH:MM:SS') but syntax is specific depending on database vendor.
 java.lang.String getTableAliasForSelfTargetRelationClass(java.lang.String domain, LyClassInfo classInfo, LyFieldInfo fieldInfo, java.lang.String tableName)
          Search for the table alias of a given table for a given logical class class and target class on the case of a self (class and target class identical) pointing relation
 LySqlRequestInfo setChildRequestInfo(LySqlRequestEncoder encoder, LySqlRequestInfo.Join childType)
          Transfer the request info to the specified encoder the specified encoders's request info becomes a new child of current context.
 boolean setObject(java.lang.Object object)
          To set an object.
 boolean setObjects(java.util.Vector<java.lang.Object> objects)
          To set a set of objects.
 void setResponse(LyResponse response)
          Set the request encoder response.
 void setTrim(boolean trim)
           
 boolean supportCaseSensitive()
          Returns a boolean that indicates if case sensitive is supported.
 
Methods inherited from class leon.peer.LyBlobRequestEncoder
getBlobContent
 
Methods inherited from class leon.peer.LyRequestEncoder
getClassBinding, getDataClass, getProvider, getResponse, isSynchronous, loadObject, setClassBinding, setDataClass, toString, toString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

DOMAIN_FILTER_RELATION

public static final java.lang.String DOMAIN_FILTER_RELATION
See Also:
Constant Field Values

CHAR_QUOTE

public static final char CHAR_QUOTE
See Also:
Constant Field Values

STRING_QUOTE

public static final java.lang.String STRING_QUOTE
See Also:
Constant Field Values

STRING_TWO_QUOTES

public static final java.lang.String STRING_TWO_QUOTES
See Also:
Constant Field Values
Constructor Detail

LySqlRequestEncoder

public LySqlRequestEncoder(LyDataProvider provider,
                           LyDataSource dataSource,
                           java.lang.String valueSep)
Constructor.

Parameters:
provider -
dataSource -
valueSep -
Method Detail

setTrim

public void setTrim(boolean trim)

setResponse

public void setResponse(LyResponse response)
Set the request encoder response. Inherited method of LyRequestEncoder to set properties to the response.

Overrides:
setResponse in class LyRequestEncoder
Parameters:
the - response

getObject

public boolean getObject(LyObjectId objectId,
                         java.util.Vector<LyField> fields)
Get an object.

Specified by:
getObject in class LyRequestEncoder
Parameters:
objectId - object identifier
fields - the fields to load (if null, load all)
Returns:
true if the request was correctly sent to the external data provider.

getObjects

public java.util.Collection<LyValueSet> getObjects(LyUnionRequestEncoder encoder,
                                                   java.util.Vector<LyField> fields,
                                                   LySort sort,
                                                   LyFilter filter,
                                                   int n)
Get a set of objects with a join request.

Specified by:
getObjects in interface LyJoinRequestEncoder
Parameters:
encoder - the asking union encoder.
fields - the fields to load (if null, load all)
sort - indicates sorting criterion, or null if default sort is used.
filter - indicates filtering criterion, or null if there is no filter.
n - maximum number of objects to get.
Returns:
true if the request was correctly sent to the external data provider.

getObjects

public boolean getObjects(java.util.Vector<LyField> fields,
                          LySort sort,
                          LyFilter filter,
                          int n)
Get a set of objects.

Specified by:
getObjects in class LyRequestEncoder
Parameters:
fields - the fields to load (if null, load all)
sort - indicates sorting criterion, or null if default sort is used.
filter - indicates filtering criterion, or null if there is no filter.
n - maximum number of objects to get.
Returns:
true if the request was correctly sent to the external data provider.

getSize

public java.lang.Integer getSize(LyUnionRequestEncoder encoder,
                                 LyFilter filter)
Return the number of objects from the data provider with a join request.

Specified by:
getSize in interface LyJoinRequestEncoder
Parameters:
encoder - The union encoder demanding the number of the objects.
filter - indicates filtering criterion, or null if there is no filter.
Returns:
The count of objects matching the filter or null if there is an error.

getSize

public boolean getSize(LyFilter filter)
Return the number of objects from the data provider .

Specified by:
getSize in class LyRequestEncoder
Parameters:
filter - indicates filtering criterion, or null if there is no filter.
Returns:
true if the request was correctly sent to the external data provider.

deleteObject

public boolean deleteObject(java.lang.Object object)
To delete an object.

Specified by:
deleteObject in class LyRequestEncoder
Parameters:
object - the object to delete
Returns:
true if the request was correctly sent to the external data provider.

deleteObjects

public boolean deleteObjects(java.util.Vector<java.lang.Object> objects)
To delete an object.

Overrides:
deleteObjects in class LyRequestEncoder
Parameters:
object - the object to delete
Returns:
true if the request was correctly sent to the external data provider.

createObject

public boolean createObject(java.lang.Object object)
To create a new object.

Specified by:
createObject in class LyRequestEncoder
Parameters:
values - the values of the new object
Returns:
true if the request was correctly sent to the external data provider.

setObject

public boolean setObject(java.lang.Object object)
To set an object.

Specified by:
setObject in class LyRequestEncoder
Parameters:
object - the object to set
values - the new values of the object
Returns:
true if the request was correctly sent to the external data provider.

setObjects

public boolean setObjects(java.util.Vector<java.lang.Object> objects)
To set a set of objects.

Overrides:
setObjects in class LyRequestEncoder
Parameters:
objects - the objects to set
values - the new values of the objects
Returns:
true if the request was correctly sent to the external data provider.

completeSelectedFields

public java.lang.String completeSelectedFields(java.util.Vector<java.lang.String> existingFields,
                                               LySort sort,
                                               boolean needDistinct,
                                               java.lang.String tableName)
Used to add a list of fields to a select request. May be overridden for specific encoders.

Parameters:
sort - The sort of the request
needDistinct - Indicates if a need distinct clause is in the select request.
tableName - The table name
Returns:
A string with a list of comma separated fields to add to the select request or null if there is no fields to add.

completeSelectedFields

public java.lang.String completeSelectedFields(java.util.Vector<java.lang.String> existingFields,
                                               LySortCriterion criterion,
                                               java.lang.String tableName)
Used to add a list of fields to a select request. May be ovverriden for specific encoders.

Parameters:
criterion - The sort criterion of the request
tableName - The table name
Returns:
A string with a list of comma separated fields to add to the select request or null if there is no fields to add.

getFilters

public java.util.Vector<LyFilter> getFilters(LyUnionBinding unionBinding)
Look for filters inside a LyUnionBinding.

Parameters:
unionBinding - current binding
Returns:
the filter list if any is found, null otherwise

getSQLFormatDate

public java.lang.String getSQLFormatDate(java.lang.String quotedId,
                                         LyDateFieldInfo fieldInfo)
String force formating date for order by using FORMAT(quotedId, 'YYYY-MM-DD HH:MM:SS') but syntax is specific depending on database vendor. If not overridden this method does nothing and returns the quotedId to keep backward compatibility.

Parameters:
quotedId - id of the date field (using aliases, table names and quotes if needed)
peerField - peer field related to this column

getTableAliasForSelfTargetRelationClass

public java.lang.String getTableAliasForSelfTargetRelationClass(java.lang.String domain,
                                                                LyClassInfo classInfo,
                                                                LyFieldInfo fieldInfo,
                                                                java.lang.String tableName)
Search for the table alias of a given table for a given logical class class and target class on the case of a self (class and target class identical) pointing relation

Parameters:
classInfo - target logical class
fieldInfo - optional parameter to search the alias name in the context of this fieldInfo
tableName - table name
Returns:
the table alias if found, the table name otherwise.

supportCaseSensitive

public boolean supportCaseSensitive()
Returns a boolean that indicates if case sensitive is supported. Default implementation return true.

Returns:
True if supported, false otherwise.

buildObject

public java.lang.Object buildObject(LyUnionRequestEncoder encoder,
                                    LyClass peerClass)
Return a new instance of the specified class. The encoder must build the object with the same method as it loads the object itself.

Specified by:
buildObject in interface LyJoinRequestEncoder
Parameters:
peerClass - the physical class of the created object.
encoder - The union encoder demanding the creation
Returns:
a new instance of of a physical object of the specified class.

getRequestInfo

public LySqlRequestInfo getRequestInfo()
Get or create the request info : this is the context for aliases and encoding info to generate the request.

Returns:
the requestInfo

setChildRequestInfo

public LySqlRequestInfo setChildRequestInfo(LySqlRequestEncoder encoder,
                                            LySqlRequestInfo.Join childType)
Transfer the request info to the specified encoder the specified encoders's request info becomes a new child of current context.

Parameters:
encoder - target encoder
childType - the type of child, one of the TYPE_xxx constants. parameter is ignored when parent is null.

clearChildRequestInfo

public LySqlRequestInfo clearChildRequestInfo(LySqlRequestEncoder encoder)
We are noi longer the parent of the specified encoder's request info the specified encoders's request info becomes a new child of current context.

Parameters:
encoder - target encoder

encodeLimitCondition

public java.lang.String encodeLimitCondition(int limit)
encode the limit condition.

Parameters:
limit - max numbut of rows fetched

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com