public class QueryObject
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
QueryObject.XqyQueryType
Define the query type for the underlying XQY layer
|
Modifier and Type | Field and Description |
---|---|
static int |
GET |
static int |
GETLIST |
static int |
MAP_CUSTOM
Used in method setResultMapping.
|
static int |
MAP_EQUAL
Used in method setResultMapping.This value defines that the query result is not mapped.
|
static int |
MAP_FLATTEN
Used in method setResultMapping.This values defines that the query result must be
flattened into single level.
|
static int |
MAP_SPECIFIED
Used in method setResultMapping.
|
static int |
PARAM_BIGDECIMAL
Used in method addParameter.
|
static int |
PARAM_BOOLEAN
Used in method addParameter.
|
static int |
PARAM_BUSOBJECT
Used in method addParameter.
|
static int |
PARAM_DATE
Used in method addParameter.
|
static int |
PARAM_DOUBLE
Used in method addParameter.
|
static int |
PARAM_INT
Used in method addParameter.
|
static int |
PARAM_STRING
Used in method addParameter.
|
static int |
PARAM_XML
Used in method addParameter.
|
Constructor and Description |
---|
QueryObject(java.lang.String queryText)
Construct a QueryObject object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
_getAdditionalInfo(java.lang.String key) |
java.lang.String |
_getCCFClass() |
java.lang.String |
_getMapInfo() |
int |
_getRequestType() |
boolean |
_isQueryTypeModified() |
void |
_setCCFClass(java.lang.String ccfClassName) |
void |
_setMapInfo(java.lang.String ccfMap) |
void |
_setQueryType(QueryObject.XqyQueryType xqyQueryType) |
void |
_setRequestType(int operationtype) |
void |
addAssociationQuery(AssociationQueryObject associationQuery) |
void |
addParameter(java.lang.String paramName,
java.lang.String columnName,
int type)
Define a parameter for the query.
|
void |
addParameter(java.lang.String paramName,
java.lang.String columnName,
int type,
java.lang.Object value)
Define a parameter for the query and set its value.
|
XqyResultSet |
execute()
Returns the dataset (resultset) as xml.
|
XqyResultSet |
execute(BusObjectManager busObjectManager)
Returns the dataset (resultset) as xml.
|
boolean |
flatSourceEntries() |
java.util.Enumeration |
getAssociationQueries() |
Cursor |
getCursor() |
int |
getMetaData(int metadata) |
BusObject |
getObject()
Returns the BusObject that is the resultant Objects obtained from executing this query.
|
BusObject |
getObject(BusObjectManager bom)
Returns the BusObject that is the resultant Objects obtained from executing this query.
|
<T extends BusObject> |
getObjects()
Returns the BusObjectIterator that contains the resultant Objects obtained from executing this query.
|
<T extends BusObject> |
getObjects(BusObjectManager bom)
Returns the BusObjectIterator that contains the resultant Objects obtained from executing this query.
|
java.util.Enumeration |
getParameters() |
java.lang.String |
getQueryText()
Returns the query text with which this QueryObject is associated.
|
QueryObject.XqyQueryType |
getQueryType()
Deprecated.
We are not going to support this api in future releases.
Returns the query type set for this QueryObject
|
java.lang.Class |
getResultClass()
Returns the class of the resulting objects.
|
java.lang.String[][] |
getResultMapping()
Returns the Result Mapping
|
int |
getResultMappingType()
Returns the Mapping type.
|
java.lang.String |
getXqyQuery()
Returns the query in the xqy format.
|
void |
mapObjectData1(int rootNode,
int objectData) |
void |
setCursor(Cursor cursor)
Sets the cursor
|
void |
setParameterValue(java.lang.String paramName,
java.lang.Object value)
Sets the value of the query parameter of this object.
|
void |
setQueryType(QueryObject.XqyQueryType xqyQueryType)
Set the type of query for the underlying XQY layer
Note: DBSQL is performance efficient
|
void |
setResultClass(java.lang.Class clazz)
To specify the class of resulting objects.
|
void |
setResultMapping(int resultMappingType,
java.lang.String[][] strings)
Sets the ResultMapping.
|
void |
setTransientResult(boolean asTransient)
Specifies whether the objects returned by the query are persistent objects (default) or transient objects.
|
int |
validateQuery(int iValidate) |
public static final int PARAM_STRING
public static final int PARAM_INT
public static final int PARAM_DATE
Date
public static final int PARAM_BIGDECIMAL
BigDecimal
public static final int PARAM_DOUBLE
double
public static final int PARAM_BOOLEAN
boolean
public static final int PARAM_XML
xml
public static final int PARAM_BUSOBJECT
BusObject
public static final int MAP_EQUAL
public static final int MAP_FLATTEN
public static final int MAP_SPECIFIED
public static final int MAP_CUSTOM
public static final int GET
public static final int GETLIST
public QueryObject(java.lang.String queryText)
queryText
- the query textpublic void setResultClass(java.lang.Class clazz)
clazz
- the class of the resulting objects.public java.lang.Class getResultClass()
public void setQueryType(QueryObject.XqyQueryType xqyQueryType)
public void _setQueryType(QueryObject.XqyQueryType xqyQueryType)
@Deprecated public QueryObject.XqyQueryType getQueryType()
public boolean _isQueryTypeModified()
public void addParameter(java.lang.String paramName, java.lang.String columnName, int type)
paramName
- the name of the parameter; this name should be present in the query text as a parameter (preceded by ':'),
e.g. WHERE CustomerID=:CustomerIDcolumnName
- the name of the column the parameter is applied to; it is a concatenation of table name and column name,
e.g. "Customer.CustomerID"type
- the type of the column; the value of this field is one of the PARAM_xxx constants in this class.public void addParameter(java.lang.String paramName, java.lang.String columnName, int type, java.lang.Object value)
paramName
- the name of the parameter; this name should be present in the query text as a parameter (preceded by ':'),
e.g. WHERE CustomerID=:CustomerIDcolumnName
- the name of the column the parameter is applied to; it is a concatenation of table name and column name,
e.g. "Customer.CustomerID"type
- the type of the column; the value of this field is one of the PARAM_xxx constants in this class.value
- the value for this parameterpublic void setParameterValue(java.lang.String paramName, java.lang.Object value)
paramName
- the name of the parameter;value
- the value for this parameteraddParameter(String, String, int)
public void addAssociationQuery(AssociationQueryObject associationQuery)
associationQuery
- public java.lang.String getQueryText()
public java.util.Enumeration getAssociationQueries()
public void setCursor(Cursor cursor)
cursor
- public Cursor getCursor()
public java.util.Enumeration getParameters()
public void setResultMapping(int resultMappingType, java.lang.String[][] strings)
For example, if mapping type is MAP_FLATTEN
query.setResultClass(UIOrder.class);
query.setResultMapping(QueryObject.MAP_FLATTEN, null);
For a sample nested derived custom class with an object layout as shown below
the WSAppServer framework will generate mapping in the Base class as shown below:<FullOrderDetails derived="Northwind::OrderDetails"> <MyOrderID>OrderID</MyOrderID> <MyProductID>ProductID</MyProductID> <MyUnitPrice>UnitPrice</MyUnitPrice> <MyQuantity>Quantity</MyQuantity> <MyDiscount>Discount</MyDiscount> <MyCategoryID>ProductIDObject.CategoryID</MyCategoryID> -------------------------------> Flattened attributes <MyCategoryName>ProductIDObject.CategoryIDObject.CategoryName</MyCategoryName> --------> Flattened attributes <OrderInfo occ="1" derived="Northwind::Orders" derivedRelation="OrderIDObject"> -------> Nested derived class <OrderID>OrderID</OrderID> <CustomerID>CustomerID</CustomerID> <EmployeeID>EmployeeID</EmployeeID> <OrderDate>OrderDate</OrderDate> <RequiredDate>RequiredDate</RequiredDate> <ShippedDate>ShippedDate</ShippedDate> <ShipVia>ShipVia</ShipVia> <Freight>Freight</Freight> <ShipName>ShipName</ShipName> <ShipAddress>ShipAddress</ShipAddress> <ShipCity>ShipCity</ShipCity> <ShipRegion>ShipRegion</ShipRegion> <ShipPostalCode>ShipPostalCode</ShipPostalCode> <ShipCountry>ShipCountry</ShipCountry> <CustomerName>CustomerIDObject.ContactName</CustomerName> -----> Flattened attributes inside nested derived custom class <EmployeeName>EmployeeIDObject.FirstName</EmployeeName> </OrderInfo> </FullOrderDetails>
String[][] qMapping = new String[][]{ // SOURCE TARGET { "FullOrderDetails/Products", "FullOrderDetails/" }, { "FullOrderDetails/Products/Categories", "FullOrderDetails/" }, { "FullOrderDetails/Orders", "FullOrderDetails/OrderInfo" }, { "FullOrderDetails/Orders/Customers", "FullOrderDetails/OrderInfo/" }, { "FullOrderDetails/Orders/Employees", "FullOrderDetails/OrderInfo/" }, }; ....; query.setResultMapping(QueryObject.MAP_SPECIFIED, qMapping); ....;The objective of the GetXXXObject(s) method is to capture data from the related data fields (from Xqy) and compose a custom bus object. In this case, data fields are coming from Products, Categories, Orders, Customers and Employees models.
Note: Products, Categories, Orders, Customers and Employees are the Standard models (or Persistence models) in 'Northwind' package
Observe that in case of flattened attributes the number of elements in the TARGET mapping before or after the mapping delimiter i.e. / are always less as compared to SOURCE. For above example, it means that WS-AppServer framework will pick the Xqy response from Products and all the children of Products are appended directly to another xml with FullOrderDetails as their root element. Same applies to mappings defined for Customers and Employees
For nested classes, the strategy is to rename the tag to what has been specified in the target mapping i.e. xqy response containing element <Orders> will be renamed to <OrderInfo>
resultMappingType
- The mapping type. This could be either MAP_SPECIFIED or MAP_FLATTEN.strings
- pass null if mapping type is MAP_FLATTEN , or a 2-d array specifying the source
and target mappingpublic void setTransientResult(boolean asTransient)
asTransient
- true to specify that the query result objects are transient, false to result peristent objectspublic java.lang.String[][] getResultMapping()
public int getResultMappingType()
public <T extends BusObject> BusObjectIterator<T> getObjects()
AnonymousBusObject
class.public <T extends BusObject> BusObjectIterator<T> getObjects(BusObjectManager bom)
AnonymousBusObject
class.bom
- BusObjectManagerpublic BusObject getObject()
AnonymousBusObject
class is returned.public BusObject getObject(BusObjectManager bom)
AnonymousBusObject
class is returned.bom
- The associated BusObjectManager objectpublic XqyResultSet execute()
public XqyResultSet execute(BusObjectManager busObjectManager)
public java.lang.String getXqyQuery()
public boolean flatSourceEntries()
public void mapObjectData1(int rootNode, int objectData)
rootNode
- objectData
- public int validateQuery(int iValidate)
public int getMetaData(int metadata)
public void _setRequestType(int operationtype)
data
- strings
- string
- public int _getRequestType()
public void _setCCFClass(java.lang.String ccfClassName)
public java.lang.String _getCCFClass() throws BsfClassRegistryException
BsfClassRegistryException
public void _setMapInfo(java.lang.String ccfMap)
public java.lang.String _getMapInfo() throws BsfClassRegistryException
BsfClassRegistryException
public java.lang.String _getAdditionalInfo(java.lang.String key) throws BsfClassRegistryException
BsfClassRegistryException