|
| Query |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
Specifies the interface that models the information that is necessary to request a result set based on business items that are contained in business models that are managed by the Intelligent Query Metadata Service. The BusinessQuery helps define and manipulate a query based on business metadata. It supports multiple views and the ability to let each view be notified when the model changes.
To specify how a particular data item's values are to be sorted, one may specify the sort direction for the data item. The sort direction attribute for a DataItemReference is inherited from its parent (base) data item if it is not explicitly set (overridden) in the DataItemReference.
To specify the precedence order of the data items to be sorted on, one may specify the "sort order precedence" list of data items for a business query.
Sorting is applied to either a data item or a business query. Sorting is applied to the data item using methods in the DataItem class.
The sort criteria is defined for a data item is based either on the value of category data item label or the value of a measure defined in the definition of that category.
The sort criteria is defined for a business query is based on the value of a measure in the crossing of a set or tuples (which would generate a MDX phrase:
CROSSJOIN({[TIME].[YEAR].MEMBERS}, {[GEOGRAPHIC].[COUNTRY].MEMBERS}), [Measures].[ACTUAL_AVG], DESC) ) ON ROWS.
This type of sort would be achieved by defining the following:
List sortCriteria = new ArrayList();
String[] measures = { measure };<<== where name is [ACTUAL_AVG]
sortCriteria.put(measures);
businessQuery.setSortCriteria(sortCriteria,com.sas.iquery.metadata.business.Role.ROW)
businessQuery.setSortDirection(BusinessQueryActionType.SORT_HIERARCHY_DESCENDING, com.sas.iquery.metadata.business.Role.ROW);
If sorting has been defined for both a data item and a business query, both will be honored if the BusinessQueryProperty.BUSINESS_QUERY_OLAP_SORT_PRECEDENCE property has been set to FALSE. If we applied the following:
businessQuery.setQueryProperty(BusinessQueryProperty.BUSINESS_QUERY_OLAP_SORT_PRECEDENCE, true);
then, we would generate a MDX phrase:
generate ( ORDER([TIME].[YEAR].MEMBERS, [TIME].CURRENTMEMBER.NAME, bdesc),
CrossJoin ( {[TIME].CURRENTMEMBER },
order( [GEOGRAPHIC].[COUNTRY].MEMBERS, [Measures].[ACTUAL_SUM],BDESC) ) )
Business Query can be filtered by a particular value threshold in a measure, a particular value range or list in a catergory, or a particular ranking of value in a measure. This filtering is performed by applying steps to a business query. To determine out how steps can be applied to a business query for OLAP filtering and ranking, see com.sas.iquery.metadata.business.step.
Totaling is applied for a business query for displayed member of a category. Aggregation returns a calculated value using the appropriate aggregate function, based on the aggregation type of the members being used. The Totals definition is defined as follows: Using the "Country" member of the "Geographic" dimension, a calculated member called [Geographic].[Total] is displayed first against the defined measures (in the order that they have been defined in the business model). Therefore, in the case of "Sales_Sum" , total is calculated by adding (with Sum). In the case of "Sales_Max" total is calculated by taking the maximum.
The type of totaling that can be applied are:
To define this type of totaling, use the following:
dataSelection.setTotalType(bq.ALLTOTAL, Role.ROW);<<-- for all totaling on row.
To define this type of totaling, use the following:
dataSelection.setTotalType(bq.SUBTOTAL, Role.ROW);<<-- for sub totaling on row.
To define this type of totaling, use the following:
dataSelection.setTotalType(bq.GRANDTOTAL, Role.ROW);<<-- for grand totaling on row.
To define this type of totaling, use the following:
dataSelection.setTotalType(bq.TOTAL_NONE, Role.ROW);<<-- for no totaling on the row.
Unless otherwise noted, all getter/setter method pairs do not copy their outputs or inputs, respectively. That is, if one calls the setter method and immediately calls the getter method for that same attribute, the object that was just given on the setter method will be returned by the getter. The only general exception to this rule, which is not documented further on the getter/setter methods, is when the output or input is a List, in which case the List is copied but the contents of the list are not copied. (A shallow copy of the List is made in both the setter and getter methods).
| Field Summary | |
static String |
ALLTOTAL
This totalling action defines if either all rows or columns will be subtotaled and grandtotaled for a business model. |
static String |
EVENT_EMPTY_DATA_FORMAT_CHANGED
This event is fired when the empty data format has changed. |
static String |
EVENT_FILTERS_CHANGED
This event is fired when the list of filters has changed. |
static String |
EVENT_QUERY_DEFINITION_CHANGED
This event is fired when a change to an object has occurred that may cause query results to change from prior to the object change. |
static String |
EVENT_QUERY_PROPERTY_CHANGED
This event is fired when a query property has changed. |
static String |
EVENT_REFERENCED_OBJECT_CHANGED
This event is fired when any BusinessModelObject referenced by this BusinessQuery has changed. |
static String |
EVENT_RESULT_ITEM_LIST_CHANGED
This event is fired when the set of result items has changed. |
static String |
EVENT_RESULT_ITEM_ROLE_CHANGED
This event is fired when the role of a result item has changed. |
static String |
EVENT_SOLVE_ORDER_CHANGED
This event is fired when the solve order has changed. |
static String |
EVENT_SORT_CRITERIA_CHANGED
This event is fired when the OLAP sort criteria has changed. |
static String |
EVENT_SORT_DIRECTION_CHANGED
This event is fired when the OLAP sort direction has changed. |
static String |
EVENT_SORT_ORDER_CHANGED
This event is fired when the sort order precedence list has changed. |
static String |
EVENT_STEPS_CHANGED
This event is fired when the step list has changed. |
static String |
EVENT_SUPPORTED_ACTION_CHANGED
This event is fired when the list of supported actions has changed. |
static String |
EVENT_TOTAL_CHANGED
This event is fired when totaling has been changed. |
static String |
EVENT_TOTAL_LABEL_CHANGED
This event is fired when a total label has been changed. |
static String |
GRANDTOTAL
This action defines if grand totaling is applied to outermost dimension for a business model. |
static String |
SUBTOTAL
This action defines if either all innermost rows or columns will be subtotaled for a business model. |
static String |
TOTAL_NONE
This action defines if neither rows or columns will be totaled for a business model. |
| Method Summary | |
void |
addResultItem(DataItem dataItem,
Role role)
Adds a data item with the specified role to the set of data items contained in this business query that make up the requested results (called the result item list). |
void |
addResultItems(List dataItems,
Role role)
Adds a list of data items with the specified role to the set of data items contained in this business query that make up the requested results (called the result item list). |
void |
addStep(StepInterface step,
Role stepRole)
This method adds a Step to the ordered list of Steps that will be applied to a business query for a specific role. |
BusinessModel |
getBusinessModel()
Returns the most extended business model object referenced by business items in this business query. |
String |
getEmptyDataFormat()
Returns the replacement string to be used (in a resultset generated from this query) for empty data. |
com.sas.entities.EntityInterface |
getEntity()
Returns a "rolled-up" entity containing all of the prompts referenced by the business items used in this BusinessQuery. |
List |
getFilters()
Returns the list of FilterItem objects last set on this object via setFilters() |
StructureOfData |
getInputStructure()
Returns an indication as to the type or structure of the data used as input to this query. |
BusinessQuery |
getParentQuery()
Returns the parent query for this BusinessQuery |
boolean |
getQueryProperty(BusinessQueryProperty prop)
Returns the value of a specified query property. |
List |
getReasonsNotValid()
Returns a list of reasons why this object is not a valid business query. |
Role |
getResultItemRole(DataItem dataItem)
Returns the role for the given data item contained in the result item list. |
List |
getResultItems()
Returns the list of data items contained in the result item list of this business query. |
List |
getResultItems(Role withThisRole)
Returns the list of data items contained in the result item list of this business query that have been assigned the given role. |
int |
getResultSetIndex(String dataItemID)
Returns the column index in the resultset for the data item (contained in the result items list) with the given ID. |
List |
getSortCriteria(Role businessSortRole)
This method gets the list of elements that are used to sort (order) on that was applied to this Business Query using the setSortCriteria method. |
BusinessQueryActionType |
getSortDirection(Role businessSortRole)
This method gets the BusinessQueryActionType that describes the type of sorting that will be applied to this Business Query using the setSortDirection method. |
List |
getSortOrderPrecedence()
This method gets the list of DataItems that was last set via setSortOrderPrecedence which specifies a precedence amongst a set of data items. |
StepInterface |
getStep(int stepNumber,
Role stepRole)
This method returns Step that has been applied to a business query for a specific role. |
List |
getSteps(Role stepRole)
This method returns an ordered list of Steps that will be applied to a business query for a specific role. |
String |
getTotalLabel(Role businessTotalRole,
String typeOfTotal)
This method gets the total label used for all totaling rows or columns in a businesss query. |
String |
getTotalType(Role businessTotalRole)
This method gets the type of totaling that has been applied to a business query. |
List |
getValidActions()
Returns a List of ( BusinessQueryActionType) elements. |
void |
insertResultItemsAt(DataItem dataItem,
Role role,
int index)
Inserts the specified a data item with the specified role to the set of data items contained in this business query that make up the requested results. |
boolean |
isActionSupported(BusinessQueryActionType actionType)
Returns whether or not the specified BusinessQueryActionType is currenly supported by the BusinessQuery. |
boolean |
isValid()
Returns whether this business query passes a set of base checks determining whether it is valid. |
void |
removeResultItem(DataItem dataItem)
Removes the specified data item from the set of result items contained in this object. |
void |
removeResultItems(List dataItems)
Removes a list of data items from the list of data items contained in this business query that make up the requested results (called the result item list). |
void |
removeStep(int stepNumber,
Role stepRole)
This method removes a Step to the ordered list of Steps that will be applied to a business query for a specific role. |
void |
setActionSupported(BusinessQueryActionType actionType,
boolean actionSupported)
Sets whether or not the specified BusinessQueryActionType is supported for this BusinessQuery. |
void |
setEmptyDataFormat(String replacementString)
This method specifies the replacement string to be used (in a resultset generated from this query) for empty data. |
void |
setFilters(List filters)
Sets the List of FilterItem objects on this business query to limit the results when this query is run. |
void |
setQueryProperty(BusinessQueryProperty prop,
boolean value)
Sets the value of the specified query property in this object. |
void |
setResultItemRole(DataItem dataItem,
Role role)
Sets the role for the given data item contained in the result item list. |
void |
setResultItems(List dataItems)
Sets the list of data items to use in the result item list. |
void |
setSortCriteria(List sortCriteria,
Role businessSortRole)
This method sets a list that contains the elements that will be used to sort (order) on. |
void |
setSortDirection(BusinessQueryActionType sortDirection,
Role businessSortRole)
This method sets the BusinessQueryActionType that describes the type of sorting that will be applied to this BusinessQuery. |
void |
setSortOrderPrecedence(List sortOrderPrecedence)
This method sets the Sort Order Precedence for this query to the set of given data items. |
void |
setSteps(List steps,
Role stepRole)
This method sets an ordered list of Steps that will be applied to a business query for a specific role. |
void |
setTotalLabel(String totalLabel,
Role businessTotalRole,
String typeOfTotal)
This method sets a total label for all totaling rows or columns in a businesss query. |
void |
setTotalType(String totalingType,
Role businessTotalRole)
This method sets the type of totaling that will be included in the resulting set of members defined as in a row or a column. |
Element |
write(Element parentElement)
Serializes this model as a sub-element to the given DOM element and returns the subelement representing this model. |
| Methods inherited from interface java.beans.PropertyChangeListener |
propertyChange |
| Methods inherited from interface com.sas.iquery.metadata.PropertyChangeListenee |
addListener, getListeners, removeListener |
| Field Detail |
public static final String EVENT_RESULT_ITEM_ROLE_CHANGED
public static final String EVENT_RESULT_ITEM_LIST_CHANGED
public static final String EVENT_FILTERS_CHANGED
public static final String EVENT_SORT_ORDER_CHANGED
public static final String EVENT_TOTAL_CHANGED
public static final String EVENT_TOTAL_LABEL_CHANGED
public static final String EVENT_SORT_DIRECTION_CHANGED
public static final String EVENT_SORT_CRITERIA_CHANGED
public static final String EVENT_SOLVE_ORDER_CHANGED
public static final String EVENT_STEPS_CHANGED
public static final String EVENT_QUERY_PROPERTY_CHANGED
public static final String EVENT_SUPPORTED_ACTION_CHANGED
public static final String EVENT_EMPTY_DATA_FORMAT_CHANGED
public static final String EVENT_REFERENCED_OBJECT_CHANGED
public static final String EVENT_QUERY_DEFINITION_CHANGED
public static final String ALLTOTAL
public static final String SUBTOTAL
public static final String TOTAL_NONE
public static final String GRANDTOTAL
| Method Detail |
public BusinessQuery getParentQuery()
public List getFilters()
setFilters()setFilters(java.util.List)
public void setFilters(List filters)
throws MetadataException
Property change events signaled:
filters - List of FilterItem objects to be set on this business queryMetadataException - if the operation could not be performedpublic boolean getQueryProperty(BusinessQueryProperty prop)
When a business query is initially created, all properties are initialized to a "false" value.
prop - specifies the query property whose value is to be returned.setQueryProperty(BusinessQueryProperty, boolean)
public void setQueryProperty(BusinessQueryProperty prop,
boolean value)
throws MetadataException
Property change events signaled:
prop - The query property whose value is to be changed.value - The value to change the the query property to.MetadataException - if the operation could not be performedpublic String getEmptyDataFormat()
setEmptyDataFormat(java.lang.String)
public void setEmptyDataFormat(String replacementString)
throws MetadataException
Property change events signaled:
replacementString - The value used to represent empty data in a ResultSet.getEmptyDataFormat()public StructureOfData getInputStructure()
public void addResultItem(DataItem dataItem,
Role role)
throws MetadataException
Property change events signaled:
dataItem - The data item to add to the result item listrole - The role that the data item plays in the business query.
If this is null no role is associated with the result item and a
default role will be determined when this business query is run.MetadataException - if the operation could not be performed
public void addResultItems(List dataItems,
Role role)
throws MetadataException
Property change events signaled:
dataItems - a list of DataItem objects to add to the result item listrole - The role that the data items play in the business query.
If this is null no role is associated with the specified data items and
default roles will be determined when this business query is run.MetadataException - if the operation could not be performed
public void insertResultItemsAt(DataItem dataItem,
Role role,
int index)
throws MetadataException
Property change events signaled:
dataItem - The data item to add to the result item listrole - The role that the data item plays in the business query.
If this is null no role is associated with the result item and a
default role will be determined when this business query is run.index - where to insert the data item.MetadataException - if the operation could not be performedIllegalArgumentException - if the data item is null or the index is less then zero
public void removeResultItem(DataItem dataItem)
throws MetadataException
Property change events signaled:
dataItem - a data item object to remove from the result item listMetadataException - if the operation could not be performed
public void removeResultItems(List dataItems)
throws MetadataException
Property change events signaled:
dataItems - a list of DataItem objects to be removed from the result item listMetadataException - if the operation could not be performed
public void setResultItems(List dataItems)
throws MetadataException
Property change events signaled:
dataItems - a list of data items to set in the result item listMetadataException - if the operation could not be performedpublic List getResultItems()
public List getResultItems(Role withThisRole)
throws MetadataException
MetadataException - if the operation could not be performed
public Role getResultItemRole(DataItem dataItem)
throws MetadataException
MetadataException - if the given data item is not in the result item list
public void setResultItemRole(DataItem dataItem,
Role role)
throws MetadataException
Property change events signaled:
dataItem - a Role for the given data item in this business queryMetadataException - if the given data item is not in the result item list
public void addStep(StepInterface step,
Role stepRole)
throws MetadataException
Property change events signaled:
step - The step to be added to the StepManagerstepRole - The role (either Column or Row) where step will be applied.
public StepInterface getStep(int stepNumber,
Role stepRole)
stepNumber - stepRole - The role (either Column or Row) where step will be applied.public List getSteps(Role stepRole)
stepRole - The role (either Column or Row) where step will be applied.
public void setSteps(List steps,
Role stepRole)
throws MetadataException
Property change events signaled:
steps - the list of stepsstepRole - The role (either Column or Row) where step will be applied.MetadataException -
public void removeStep(int stepNumber,
Role stepRole)
throws MetadataException
Property change events signaled:
stepNumber - stepRole - MetadataException - public List getValidActions()
BusinessQueryActionType) elements. This list contains all
all the Action Types that could be valid for this BusinessQuery. This differs from the
getActionsSupported method in that this list does not define the set of
Action that are currently supported by the BusinessQuery, but rather the list of Actions
that can optionally be turned on or off. If an Action does not appear in this list
then the consumer does not have the option of controlling this Action.public boolean isActionSupported(BusinessQueryActionType actionType)
actionType - The type of BusinessQuery Action that is being queried.
public void setActionSupported(BusinessQueryActionType actionType,
boolean actionSupported)
throws MetadataException
getValidActionTypes
method can be enabled.
Property change events signaled:
actionType - The type of BusinessQuery Action to enable or disableactionSupported - A boolean indicating whether to enable or disable the BusinessQuery ActionMetadataException - when trying to set an action to be supported when not in the valid list of supported actionspublic List getSortOrderPrecedence()
public void setSortOrderPrecedence(List sortOrderPrecedence)
throws MetadataException
Property change events signaled:
sortOrderPrecedence - a list a DataItem objects providing sort precedenceMetadataException - when the action is not supportedpublic BusinessQueryActionType getSortDirection(Role businessSortRole)
Sort directions that can be retrieved are:
Note: This method is specifically used to perform ordering for OLAP. This method is not used for relational business model. If businessSortRole is null, COLUMN is assumed. If an invalid Role is presented to this method, an error will be displayed and an SORT_NONE is returned. The valid sortDirection arguments that can be returned are:
Property change events signaled:
businessSortRole - Defines whether this sort applied to a row or column.setSortDirection(BusinessQueryActionType, Role),
setSortCriteria(java.util.List, Role)
public void setSortDirection(BusinessQueryActionType sortDirection,
Role businessSortRole)
throws MetadataException
Note: This method is specifically used to perform ordering for OLAP. This method is not used for relational business model. There is no validation that occurs on the items defined in the sort criteria list. "Order" will arranges members of a specified set, optionally preserving or breaking the hierarchy. There are two varieties of Order: hierarchized (ASC or DESC) and nonhierarchized (BASC or BDESC, where B stands for Break hierarchy). The hierarchized ordering first arranges members according to their position in the hierarchy. Then it orders each level. The nonhierarchized ordering arranges members in the set without regard to the hierarchy.
Valid sortDirection arguments are:
To define a sucessful sort, both a sort direction and a sort criteria must be specified.
Property change events signaled:
sortDirection - the type of sorting that will be applied to this query.businessSortRole - Defines whether this sort applied to a row or column. If businessSortRole is null, COLUMN is assumed.MetadataException - when the action is not supportedIllegalArgumentException - when either a invalid sortDirection or invalid businessSortRole is applied.getSortDirection(Role),
setSortCriteria(List, Role)public String getTotalType(Role businessTotalRole)
businessTotalRole - define whether this totaling is being set for a row or a column. If businessTotalRole is null, COLUMN is assumed.
public void setTotalType(String totalingType,
Role businessTotalRole)
throws MetadataException
Note: Several other methods will be added to support totaling in the future such as setTotalStyle (set label and formatting of the total row or column) and setTotalAggregation set aggregation factor).
The type of totaling applied can be:
Property change events signalled:
totalingType - the type of totaling that will be applied to this query.businessTotalRole - define whether this totaling is being set for a row or a column. If businessTotalRole is null, COLUMN is assumed.MetadataException - when the action is not supportedIllegalArgumentException - when a businessTotalRole is applied.
public String getTotalLabel(Role businessTotalRole,
String typeOfTotal)
Note: If businessTotalRole is null, COLUMN is assumed. If an invalid Role is presented to this method, an error will be displayed and an empty string will be returned.
businessTotalRole - define whether this totaling is being set for a row or a column. If businessTotalRole is null, COLUMN is assumed.typeOfTotal - defines whether total label will be applied to subtotal or grandtotal label.
public void setTotalLabel(String totalLabel,
Role businessTotalRole,
String typeOfTotal)
throws MetadataException
Note: This method may be deprecated for another method that will apply a full style name string pair. This pair would apply items such as labeling and formating (color, font, etc.)
Property change events signaled:
totalLabel - defines label that will be used.businessTotalRole - define whether this totaling is being set for a row or a column. If businessTotalRole is null, COLUMN is assumed.typeOfTotal - defines whether total label will be applied to subtotal or grandtotal label.IllegalArgumentException - when a businessTotalRole is applied.public List getSortCriteria(Role businessSortRole)
Note: If businessSortRole is null, COLUMN is assumed. If an invalid Role is presented to this method, an error will be displayed and an empty list will be returned.
Note: This method is specifically used to perform ordering for OLAP. This method is not used for relational business model.
businessSortRole - Defines whether this sort applied to a row or column.setSortCriteria(java.util.List, com.sas.iquery.metadata.business.Role)
public void setSortCriteria(List sortCriteria,
Role businessSortRole)
throws MetadataException
Note: There is no validation that occurs on the items defined in the sort criteria list.
Note: This method is specifically used to perform ordering for OLAP. This method is not used for relational information maps.
Property change events signaled:
sortCriteria - This parameter could contain a list of two string arrays (first array would be measures and second array would be member -
represent by the string value of the measure or the member). The parameter could also contain a list that contains items that are either
string values that represent members and data item entries that represent measure dataitems.businessSortRole - Defines whether this sort applied to a row or column.MetadataException - when the action is not supportedIllegalArgumentException - when an invalid businessSortRole is applied.getSortCriteria(com.sas.iquery.metadata.business.Role),
getSortDirection(com.sas.iquery.metadata.business.Role)public boolean isValid()
public List getReasonsNotValid()
This method is a union of all validation testing done by this object ... so it tests for role assignment validation, and other basic validation required in order to be a valid query to run.
public Element write(Element parentElement)
throws MetadataException
parentElement - element under which a new element should be created
which holds this model's XML form.MetadataException - if the write failsNullPointerException - if given a null element argumentpublic BusinessModel getBusinessModel()
public int getResultSetIndex(String dataItemID)
dataItemID - ID of a DataItem contained in the result item list
public com.sas.entities.EntityInterface getEntity()
|
| Query |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||