Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes some methods of working with data source dimension element selection. After starting the example the following operations are executed:
Selection container of data source dimension elements is retrieved.
Container description and number of dimension element selection in container are retrieved.
A copy of selection container is created.
A dictionary with selection container settings is created.
Dimension selection is retrieved from container by means of dimension key.
Array of keys of selected elements is retrieved up to obtained selection.
Dimension selection is retrieved by means of selection container index.
Array of selected elements for obtained selection is retrieved.
A copy of the first selection is created.
The dimension, for which obtained selection is stored, is retrieved.
It is checked if one of the dimension elements is selected.
A new selection container is created based on existing container.
One of the new container selections is deleted.
A new selection is created based on the obtained data source dimension.
New selection elements are selected and deselected by various methods.
Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Data Analysis section):
// Get selection container of data source dimension elements SPPLDimensionSelectionSet pivotSet = m_olapReport->selectionSet(); // Get description of dimension element selection container SNString selectionSetDescription = pivotSet->description(); printf("Description of dimension element selection container:\n%s\n", selectionSetDescription->UTF8String()); // Get number of dimension element selections int selectionsCount = pivotSet->selectionsCount(); printf("Number of dimension element selections: %d\n", selectionsCount); // Get copy of selection container SNID copiedSelectionSetObject = pivotSet->copy(); // Get container object from copy SPPLDimensionSelectionSet copiedSelectionSet = copiedSelectionSetObject->qClass<PPLDimensionSelectionSet>(); // Get dictionary with selection container copy settings SNDictionary plist = copiedSelectionSet->generatePlist()->qClass<NDictionary>(); printf("Number of settings dictionary elements: %d\n", plist->count()); // Get array of cube dimensions SNArray allDimensions = [self allDimensions]; if (allDimensions->count() < 1) { printf("No dimension is found"); return; } // Get first cube dimension in array SPPLDimension dimension = allDimensions->objectAtIndex<PPLDimension>(0); // Get first selection by means of selected dimension key SPPLDimensionSelection selection = pivotSet->getSelectionByDimensionKey(dimension->key()); // Get array of keys of first selection selected elements SNInt64Array keys = selection->selectedKeys(); printf("Number of first selection keys: %d\n", keys->count()); // Get selection by index in selection container SPPLDimensionSelection selection2 = pivotSet->getSelectionByIndex(1); // Get array of second selection selected elements SNArray elements = selection2->selectedElements(); printf("Number of second selection selected elements: %d\n", elements->count()); // Get copy of first selection SPPLDimensionSelection selectionCopy = selection->copy()->qClass<PPLDimensionSelection>(); // Get dimension, for which selection is stored, from first selection copy SPPLDimension selectionDimension = selectionCopy->dimension(); printf("Name of the dimension, for which selection is stored: %s\n", selectionDimension->name()->UTF8String()); // Get first element key from array of first selection keys int64 elementKey = keys->objectAtIndex(0); // Get element by key and check if this element is selected bool isSelected = selection->isElementSelected(elementKey); // Display check result message in the development environment console if(isSelected) printf("First dimension element with the key %lld is selected\n", elementKey); else printf("First dimension element with the key %lld is not selected\n", elementKey); // Create a new selection container SPPLDimensionSelectionSet createdSelectionSet = new PPLDimensionSelectionSet(); // Fill new container in cycle for(int i = 0; i < pivotSet->selectionsCount(); i++) { // Get dimension by index SPPLDimension currentDimension = allDimensions->objectAtIndex<PPLDimension>(i); // Get selection from existing container by identifier of the dimension, for which selection is stored SPPLDimensionSelection currentSelection = pivotSet->getSelectionByDimensionId(currentDimension->id()); // Add selection to new container createdSelectionSet->addSelection(currentSelection, currentDimension->id()); } // Get number of new container elements int createdSelectionSetCount = createdSelectionSet->selectionsCount(); printf("Number of new container elements: %d\n", createdSelectionSetCount); // Delete first dimension selection from new container createdSelectionSet->removeSelection(dimension->id()); // Get number of new container elements after deleting selection createdSelectionSetCount = createdSelectionSet->selectionsCount(); printf("Number of new container elements after deleting selection: %d\n", createdSelectionSetCount); // Get second cube dimension SPPLDimension dimension2 = allDimensions->objectAtIndex<PPLDimension>(1); // Create a new selection for obtained dimension SPPLDimensionSelection createdSelection = new PPLDimensionSelection(dimension2); // Get name of the dimension, based on which selection is created SNString dimensionName = createdSelection->dimension()->name(); printf("Name of the dimension, based on which a new selection is created: %s\n", dimensionName->UTF8String()); printf("Dimension identifier: %s\n", createdSelection->description()->UTF8String()); // Select all new selection elements createdSelection->selectAll(); printf("Selecting all new selection elements\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count()); // Deselect all new selection elements createdSelection->deselectAll(); printf("Deselecting all new selection elements\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count()); // Get array of all keys of second dimension elements SNInt64Array itemsKeys = dimension2->elements()->itemsKeys(); // Get key of second dimension last element int64 key = itemsKeys->objectAtIndex(itemsKeys->count() - 1); // Select second dimension last element createdSelection->select(key); printf("Selecting new selection last element\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count()); // Deselect second dimension last element createdSelection->deselect(key); printf("Deselecting new selection last element\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count()); // Delete last object from array of keys itemsKeys->removeObjectAtIndex(itemsKeys->count() - 1); // Select all elements by array of keys createdSelection->selectAll(itemsKeys); printf("Selecting all elements in array of keys\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count()); // Delete last object from array of keys itemsKeys->removeObjectAtIndex(itemsKeys->count() - 1); // Deselect all elements by array of keys createdSelection->deselectAll(itemsKeys); printf("Deselecting all elements in changed array of keys\n"); printf("Number of new selection elements: %d\n", createdSelection->selectedElements()->count());
After executing the example the development environment console displays information about obtained and created selection containers of data source dimension elements, information about selections retrieved from these containers, name of the dimension, based on which a new selection is created, and also results of operations for selecting and deselecting selection elements:
Description of dimension element selection container:
Selections count: 3
[CUT_REGIONS_68045]
[FACTS_WDI_COPY_1557]
[CALENDAR_Y_ENG_533]
Number of dimension element selections: 3
Number of settings dictionary elements: 3
Number of first selection keys: 6
Number of second selection selected elements: 1
Name of the dimension, for which selection is stored: Calendar
First dimension element with the key 16 is selected
Number of new container elements: 3
Number of new container elements after deleting selection: 2
Name of the dimension, based on which a new selection is created: Regions
Dimension identifier: [D_TO_105]
Selecting all new selection elements
Number of new selection elements: 8
Deselecting all new selection elements
Number of new selection elements: 0
Selecting new selection last element
Number of new selection elements: 1
Deselecting new selection last element
Number of new selection elements: 0
Selecting all elements in array of keys
Number of new selection elements: 7
Deselecting all elements in changed array of keys
Number of new selection elements: 1
See also: