com.sas.iquery.builder
Class DisabledTotalsBuilder

com.sas.iquery.builder.DisabledTotalsBuilder
All Implemented Interfaces:
Builder<java.util.Map<DataItem,java.util.Set<TotalingType>>>

public class DisabledTotalsBuilder
implements Builder<java.util.Map<DataItem,java.util.Set<TotalingType>>>

Builder class for disabling totals and sub-totals. Changes are NOT committed to the model until build() is called.

Examples:

        // new builder
        DisabledTotalsBuilder builder = newDisabledTotalsBuilder(ds);
        Map<DataItem, Set<TotalingType>> disabledTotalsBuilt = builder // builder
            .totalingType(TotalingType.ALLTOTAL, Role.COLUMN) //          turn on all totaling for the query's Columns
            .totalingType(TotalingType.ALLTOTAL, Role.ROW) //             turn on all totaling for the query's Rows
            .disable(dsDataItems.get(0), TotalingType.AXISTOTAL) //       turn off axis total for DIR_1
            .disable(dsDataItems.get(1), TotalingType.ALLTOTAL) //        turn off axis+sub totals for DIR_2
            .enable(dsDataItems.get(2), TotalingType.ALLTOTAL) //         force axis+sub totals to be show for DIR_3
            .persistGroups(true) //                                       persist this info upon saving query
            .build();
 


Method Summary
 java.util.Map<DataItem,java.util.Set<TotalingType>> build()
          Build and return and Intelligent Query object, based on parameters supplied to the Builder implementation.
 DisabledTotalsBuilder clear(DataItem... dataItems)
          Clears all totaling types for the data items given.
 DisabledTotalsBuilder clear(TotalingType... totalingTypes)
          Clears all data items for the totaling types given.
static void clearByDataItem(BusinessQuery businessQuery, java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
          Directly updates the business query with the mapping of data items and to be cleared totaling types.
static java.util.List<DataItem> clearTotaling(BusinessQuery businessQuery, TotalingType totalingType)
          Clears the totaling lists for the business query.
static void clearTotaling(BusinessQuery businessQuery, TotalingType totalingType, DataItem... dataItems)
          Clear the data items for the given totaling type.
 DisabledTotalsBuilder disable(DataItem dataItem, TotalingType... totalingTypes)
          Disable the item for the totaling types given.
 DisabledTotalsBuilder disable(TotalingType totalingType, DataItem... dataItems)
          Disable the totaling type for the items given.
static void disableByDataItem(BusinessQuery businessQuery, java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
          Directly updates the business query with the mapping of data items and disabled totaling types.
static void disableTotaling(BusinessQuery businessQuery, TotalingType totalingType, DataItem... dataItems)
          Set the data items to have a disabled totaling for the given totaling type.
 DisabledTotalsBuilder enable(DataItem dataItem, TotalingType... totalingTypes)
          Enable the item for the totaling types given.
 DisabledTotalsBuilder enable(TotalingType totalingType, DataItem... dataItems)
          Enable the totaling type for the items given.
static void enableByDataItem(BusinessQuery businessQuery, java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
          Directly updates the business query with the mapping of data items and enabled totaling types.
static void enableTotaling(BusinessQuery businessQuery, TotalingType totalingType, DataItem... dataItems)
          Set the data items to have a enabled totaling for the given totaling type.
 BusinessQuery getBusinessQuery()
           
 java.util.Map<DataItem,java.util.Set<TotalingType>> getByDataItems()
          Get a mapping from data selection WITH pending changes that have not been committed with build().
 java.util.Map<TotalingType,java.util.Set<DataItem>> getByTotalingTypes()
          Get a mapping from data selection WITH any pending changes that have not been committed with build().
 java.util.Set<DataItem> getDisabledItemsForType(TotalingType totalingType)
          Get the data items disabled for the totaling type given WITH any pending changes that have not been committed with build().
static java.util.Map<DataItem,java.util.Set<TotalingType>> getDisabledTotalingByItem(BusinessQuery businessQuery)
          Returns a mapping of data items to the totaling types disabled for that data item.
static java.util.Map<DataItem,java.util.Set<TotalingType>> getDisabledTotalingByItem(BusinessQuery businessQuery, boolean recursive)
          returns a mapping of data items to the totaling types disabled for that data item.
static java.util.Map<TotalingType,java.util.Set<DataItem>> getDisabledTotalingByType(BusinessQuery businessQuery)
          Returns a mapping of data items to the totaling types disabled for that data item.
static java.util.Map<TotalingType,java.util.Set<DataItem>> getDisabledTotalingByType(BusinessQuery businessQuery, boolean recursive)
          Returns a mapping of data items to the totaling types disabled for that data item.
 java.util.Set<TotalingType> getDisabledTypesForItem(DataItem dataItem)
          Get the total types disabled for the data item given WITH any pending changes that have not been committed with build().
 boolean isBuilt()
          returns true if the builder has changes pending and the build() method has not been called since those changes were made.
static boolean isDisabledTotaling(BusinessQuery businessQuery, DataItem item, TotalingType totalingType)
          Returns true if the total is disabled for that data item or any of the base items for that data item.
static boolean isDisabledTotaling(BusinessQuery businessQuery, DataItem item, TotalingType totalingType, boolean checkParentModels, boolean checkRootItems)
          Returns true if the total is disabled for that data item.
static boolean isDisabledTotaling(DataSelection businessQuery, DataItem item, TotalingType totalingType, boolean checkParentModels)
          Returns true if the total is disabled for that data item or any of the base items for that data item.
 boolean isPersistGroups()
          returns true if the active groups for this builder's data selection will be persisted to XML
static boolean isPersistGroups(BusinessQuery businessQuery)
          returns true if the active groups for this builder's data selection will be persisted to XML
 boolean isRemovePending()
          returns true if the builder's next build() will remove all of the grouping behaviors.
 void load(BusinessQuery businessQuery)
          Clears any pending changes and loads a complete snapshot of the disabled totals from the specified data selection.
 DisabledTotalsBuilder persistGroups(boolean enable)
          Clears all totaling types for the data items given.
static void persistGroups(BusinessQuery businessQuery, boolean persistGroups)
          turns on persistence of active groups for this query.
 DisabledTotalsBuilder remove()
          Removes the disabled totaling behaviors for the data selection all together on the next build.
static java.util.List<DataItem> removeTotaling(BusinessQuery businessQuery)
          version of the above remove() that acts directly on the business query
static java.util.List<DataItem> removeTotaling(BusinessQuery businessQuery, TotalingType totalingType)
          Removes the disabled totaling for the totaling type from the business query.
static void setQueryTotaling(BusinessQuery businessQuery, TotalingType totalingType, Role role)
          turns on totaling for the specified totaling type and role
 DisabledTotalsBuilder totalingType(TotalingType totalingType, Role role)
          turns on totaling for the specified totaling type and role
 

Method Detail

getBusinessQuery

public BusinessQuery getBusinessQuery()
Returns:
the builder's data selection.

isBuilt

public boolean isBuilt()
returns true if the builder has changes pending and the build() method has not been called since those changes were made.


isRemovePending

public boolean isRemovePending()
returns true if the builder's next build() will remove all of the grouping behaviors.


build

public java.util.Map<DataItem,java.util.Set<TotalingType>> build()
                                                          throws MetadataException
Description copied from interface: Builder
Build and return and Intelligent Query object, based on parameters supplied to the Builder implementation.

null is never returned from this method. A MetadataException will be thrown in the case where the object could not be constructed.

Specified by:
build in interface Builder<java.util.Map<DataItem,java.util.Set<TotalingType>>>
Returns:
an Intelligent Query object of type T.
Throws:
MetadataException - if the object could not be build
See Also:
Builder.build()

load

public void load(BusinessQuery businessQuery)
Clears any pending changes and loads a complete snapshot of the disabled totals from the specified data selection. (Does not do a build or commit those to the builder's data selection).

Parameters:
dataSelection -

getByDataItems

public java.util.Map<DataItem,java.util.Set<TotalingType>> getByDataItems()
Get a mapping from data selection WITH pending changes that have not been committed with build().

Returns:

getByTotalingTypes

public java.util.Map<TotalingType,java.util.Set<DataItem>> getByTotalingTypes()
Get a mapping from data selection WITH any pending changes that have not been committed with build().

Returns:

getDisabledItemsForType

public java.util.Set<DataItem> getDisabledItemsForType(TotalingType totalingType)
Get the data items disabled for the totaling type given WITH any pending changes that have not been committed with build().

Parameters:
totalingType -
Returns:

getDisabledTypesForItem

public java.util.Set<TotalingType> getDisabledTypesForItem(DataItem dataItem)
Get the total types disabled for the data item given WITH any pending changes that have not been committed with build().

Parameters:
dataItem -
Returns:

totalingType

public DisabledTotalsBuilder totalingType(TotalingType totalingType,
                                          Role role)
turns on totaling for the specified totaling type and role


setQueryTotaling

public static void setQueryTotaling(BusinessQuery businessQuery,
                                    TotalingType totalingType,
                                    Role role)
                             throws MetadataException
turns on totaling for the specified totaling type and role

Throws:
MetadataException

persistGroups

public DisabledTotalsBuilder persistGroups(boolean enable)
Clears all totaling types for the data items given.

Parameters:
dataItems -
Returns:

isPersistGroups

public boolean isPersistGroups()
returns true if the active groups for this builder's data selection will be persisted to XML


persistGroups

public static void persistGroups(BusinessQuery businessQuery,
                                 boolean persistGroups)
                          throws MetadataException
turns on persistence of active groups for this query.

Throws:
MetadataException

isPersistGroups

public static boolean isPersistGroups(BusinessQuery businessQuery)
returns true if the active groups for this builder's data selection will be persisted to XML


disable

public DisabledTotalsBuilder disable(TotalingType totalingType,
                                     DataItem... dataItems)
                              throws MetadataException
Disable the totaling type for the items given.

Parameters:
totalingType -
dataItems -
totalingType -
Returns:
Throws:
MetadataException

disable

public DisabledTotalsBuilder disable(DataItem dataItem,
                                     TotalingType... totalingTypes)
Disable the item for the totaling types given.

Parameters:
dataItem -
totalingTypes -
Returns:

disableTotaling

public static void disableTotaling(BusinessQuery businessQuery,
                                   TotalingType totalingType,
                                   DataItem... dataItems)
                            throws MetadataException
Set the data items to have a disabled totaling for the given totaling type. Note: TOTAL_NONE means "do not inherit the parent query model's behavior".

Throws:
MetadataException

disableByDataItem

public static void disableByDataItem(BusinessQuery businessQuery,
                                     java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
                              throws MetadataException
Directly updates the business query with the mapping of data items and disabled totaling types.

Parameters:
dataSelection -
mapping -
Throws:
MetadataException

enable

public DisabledTotalsBuilder enable(TotalingType totalingType,
                                    DataItem... dataItems)
                             throws MetadataException
Enable the totaling type for the items given.

Parameters:
totalingType -
dataItems -
Returns:
Throws:
MetadataException

enable

public DisabledTotalsBuilder enable(DataItem dataItem,
                                    TotalingType... totalingTypes)
Enable the item for the totaling types given.

Parameters:
dataItem -
totalingTypes -
Returns:

enableTotaling

public static void enableTotaling(BusinessQuery businessQuery,
                                  TotalingType totalingType,
                                  DataItem... dataItems)
                           throws MetadataException
Set the data items to have a enabled totaling for the given totaling type. Note: TOTAL_NONE means "do not inherit the parent query model's behavior".

Throws:
MetadataException

enableByDataItem

public static void enableByDataItem(BusinessQuery businessQuery,
                                    java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
                             throws MetadataException
Directly updates the business query with the mapping of data items and enabled totaling types.

Parameters:
dataSelection -
mapping -
Throws:
MetadataException

clear

public DisabledTotalsBuilder clear(TotalingType... totalingTypes)
Clears all data items for the totaling types given.

Parameters:
totalingTypes -
Returns:

clear

public DisabledTotalsBuilder clear(DataItem... dataItems)
Clears all totaling types for the data items given.

Parameters:
dataItems -
Returns:

clearTotaling

public static void clearTotaling(BusinessQuery businessQuery,
                                 TotalingType totalingType,
                                 DataItem... dataItems)
                          throws MetadataException
Clear the data items for the given totaling type. Note: TOTAL_NONE means "do not inherit the parent query model's behavior".

Throws:
MetadataException

clearByDataItem

public static void clearByDataItem(BusinessQuery businessQuery,
                                   java.util.Map<DataItem,java.util.Set<TotalingType>> mapping)
                            throws MetadataException
Directly updates the business query with the mapping of data items and to be cleared totaling types.

Parameters:
dataSelection -
mapping -
Throws:
MetadataException

remove

public DisabledTotalsBuilder remove()
Removes the disabled totaling behaviors for the data selection all together on the next build.

Parameters:
dataItems -
Returns:

removeTotaling

public static java.util.List<DataItem> removeTotaling(BusinessQuery businessQuery)
                                               throws MetadataException
version of the above remove() that acts directly on the business query

Throws:
MetadataException

getDisabledTotalingByType

public static java.util.Map<TotalingType,java.util.Set<DataItem>> getDisabledTotalingByType(BusinessQuery businessQuery)
Returns a mapping of data items to the totaling types disabled for that data item. Includes searching parent models.

Parameters:
businessQuery -
Returns:

getDisabledTotalingByType

public static java.util.Map<TotalingType,java.util.Set<DataItem>> getDisabledTotalingByType(BusinessQuery businessQuery,
                                                                                            boolean recursive)
Returns a mapping of data items to the totaling types disabled for that data item.

Parameters:
businessQuery -
recursive - if true then parent models will be searched.
Returns:

getDisabledTotalingByItem

public static java.util.Map<DataItem,java.util.Set<TotalingType>> getDisabledTotalingByItem(BusinessQuery businessQuery)
Returns a mapping of data items to the totaling types disabled for that data item. Includes searching parent models.

Parameters:
businessQuery -
Returns:

getDisabledTotalingByItem

public static java.util.Map<DataItem,java.util.Set<TotalingType>> getDisabledTotalingByItem(BusinessQuery businessQuery,
                                                                                            boolean recursive)
returns a mapping of data items to the totaling types disabled for that data item.

Parameters:
businessQuery -
recursive - if true then parent models will be searched.
Returns:

isDisabledTotaling

public static boolean isDisabledTotaling(BusinessQuery businessQuery,
                                         DataItem item,
                                         TotalingType totalingType)
Returns true if the total is disabled for that data item or any of the base items for that data item. (Note: TOTAL_NONE will return true if the totaling type is not to be inherited from the parent query.)

Parameters:
dataSelection -
item -
totalType -
Returns:

isDisabledTotaling

public static boolean isDisabledTotaling(DataSelection businessQuery,
                                         DataItem item,
                                         TotalingType totalingType,
                                         boolean checkParentModels)
Returns true if the total is disabled for that data item or any of the base items for that data item. (Note: TOTAL_NONE will return true if the totaling type is not to be inherited from the parent query.)

Parameters:
item -
checkParentModels - check parent business queries for data items that do not have TOTAL_NONE set.
dataSelection -
totalType -
Returns:

isDisabledTotaling

public static boolean isDisabledTotaling(BusinessQuery businessQuery,
                                         DataItem item,
                                         TotalingType totalingType,
                                         boolean checkParentModels,
                                         boolean checkRootItems)
Returns true if the total is disabled for that data item. (Note: TOTAL_NONE will return true if the totaling type is not to be inherited from the parent query.)

Parameters:
item -
checkParentModels - check parent business queries for data items that do not have TOTAL_NONE set.
checkRootItems - if not found by the item then if it is a data item reference it starts walking up the base items.
dataSelection -
totalType -
Returns:

removeTotaling

public static java.util.List<DataItem> removeTotaling(BusinessQuery businessQuery,
                                                      TotalingType totalingType)
                                               throws MetadataException
Removes the disabled totaling for the totaling type from the business query.

Returns:
A list of the previously disabled for totaling data items.
Throws:
MetadataException

clearTotaling

public static java.util.List<DataItem> clearTotaling(BusinessQuery businessQuery,
                                                     TotalingType totalingType)
                                              throws MetadataException
Clears the totaling lists for the business query.

Returns:
A list of the previously disabled for totaling data items.
Throws:
MetadataException



Copyright © 2009 SAS Institute Inc. All Rights Reserved.