Working with Express Report

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes some methods of working with express report. After starting the example the following operations are executed:

Source Code

Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Displaying of Express Report section):

-(void)executeExample {
    // Get express report
    SPPLOlapReport report = m_olapReport;
    // Get express report title
    SNString title = report->title();
    printf("Express report title: %s\n",title->UTF8String());
    // Get express report copy
    SPPLOlapReport copy =report->copy()->qClass<PPLOlapReport>();
    // Get express report copy without custom data warehouse
    SPPLOlapReport copyWithoutStorage =report->copyWithoutStorage()->qClass<PPLOlapReport>();
    // Get dimension array
    SNArray allDimensions = [self allDimensions];
    if (allDimensions->count() < 1) {
        printf("No dimension is found");
        return;
    }
    // Get first dimension in array
    SPPLDimension dimension = allDimensions->objectAtIndex<PPLDimension>(0);
    printf("Number of express report fixed dimensions: %d\n", report->fixedDimensions()->count());
    // Specify fixed dimension
    report->putDimensionToFixed(dimension);
    printf("Number of express report fixed dimensions: %d\n", report->fixedDimensions()->count());
    printf("Number of dimension located in columns for the first report copy: %d\n",copy->leftDimensions()->count());
    // Specify dimension located in columns for the first report copy
    copy->putDimensionToLeft(dimension);
    printf("Locating of dimension in columns for the first report copy\n");
    printf("Number of dimensions located in columns for the first report copy: %d\n", copy->leftDimensions()->count());
    // Get second cube dimension in array
    SPPLDimension dimension1 = allDimensions->objectAtIndex<PPLDimension>(1);
    printf("Number of dimensions located in rows for the second report copy: %d\n", copyWithoutStorage->topDimensions()->count());
    // Specify dimension located in rows for the second report copy
    copyWithoutStorage->putDimensionToTop(dimension1);
    printf("Locating of dimension in rows for the second  report copy\n");
    printf("Number of dimensions located in rows for the second report copy: %d\n", copyWithoutStorage->topDimensions()->count());
    // Get express report data source
    SPPLDataSource dataSource = report->dataSource();
    printf("Name of the object, based on which an express report data source is created: %s\n",dataSource->descriptor()->name()->UTF8String());
    // Get express report dimension element selection container
    SPPLDimensionSelectionSet selectionSet = report->selectionSet();
    printf("Number of dimension element selections in express report label container: %d\n",selectionSet->selectionsCount());
    // Set new identifier of metric dimension for the first report copy
    copy->setMetrics(NStr("New metric dimension"));
    printf("Metric dimension identifier for the first report copy: %s\n",copy->metrics()->UTF8String());
    // Set new identifier of observation object dimension for the first report copy
    copy->setObjectives(NStr("New observation object dimension"));
    printf("Observation object identifier for the first report copy: %s\n",copy->objectives()->UTF8String());
    // Set new identifier of calendar dimension used for building a timeline for the first report copy
    copy->setTimeline(NStr("New timeline dimension"));
    printf("Identifier of calendar dimension used for building a timeline in the firs report copy: %s\n",copy->timeline()->UTF8String());
    // Create a repository copy for the first dimension
    SPPLMetabaseRepositoryObjectDescriptor descriptor = dimension->relatedObjectDescriptor()->copy()->qClass<PPLMetabaseRepositoryObjectDescriptor>();
    // Create a new data source based on repository object copy
    SPPLDataSource createdDataSource = PPLDataSource::dataSource(descriptor);
    if (createdDataSource != NULL) {
        // Set new repository object name, based on which a data source is created
        createdDataSource->descriptor()->setName(NStr("New repository object"));
        // Set new data source for the first report copy
        copy->setDataSource(createdDataSource);
        printf("Name of the object, based on which the first report copy data source is created: %s\n",copy->dataSource()->descriptor()->name()->UTF8String());
    } else {
        printf("Failed to create a new data source based on the repository object copy");
    }
    printf("Object name, based on which the first report copy data source is created: %s\n",copy->dataSource()->descriptor()->name()->UTF8String());
    // Get copy of express report dimension element selection container
    SPPLDimensionSelectionSet createdSelectionSet = report->selectionSet()->copy()->qClass<PPLDimensionSelectionSet>();
    // Get last selection in container copy
    SPPLDimensionSelection selection = createdSelectionSet->getSelectionByIndex(createdSelectionSet->selectionsCount() - 1);
    // Remove last selection from container copy
    createdSelectionSet->removeSelection(selection->dimension()->id());
    // Set new selection container for the first report copy
    copy->setSelectionSet(createdSelectionSet);
    printf("Number of dimension element selections in the first report copy selection container: %d\n",copy->selectionSet()->selectionsCount());
    // Display information about map data source
    [self printMapDSInfo];
}
-(void) printMapDSInfo {
    // Get express report controller
    MAExpressAnalysisReportViewController *contr = (MAExpressAnalysisReportViewController *)m_controller;
    // Get express report delegate
    EAReportDelegateImpl *delegate = [contr delegate];
    // Save current report state
    [delegate saveReport];
    // Get map data source settings
    SNDictionary mapDSSettings = [delegate olapReport]->mapDSSettings();
    if (mapDSSettings != nullptr) {
        printf("Available keys of map settings dictionary:\n");
        N_FOREACH(SNString, key, mapDSSettings->allKeys()) {
            printf("%s\n", key->UTF8String());
        }
        } else  {
        printf("Map data source settings are not defined\n");
    }
}

After executing the example the development environment console displays information about the express report and its copies, changes in metric dimension array, observation object dimension array, and in calendar dimension array, by which report object timeline is built, and also information about the new data source and first report copy selection container:

Express report title: &[Dimensions.FACTS_WDI_COPY_1557]

Number of express report fixed dimensions: 1

Number of express report fixed dimensions: 2

Number of dimensions located in columns for the first report copy: 1

Locating of dimension in columns for the first report copy

Number of dimensions located in columns for the first report copy: 2

Number of dimensions located in rows for the second report copy: 1

Locating of dimension in rows for the second report copy

Number of dimensions located in rows for the second report copy: 2

Name of the object, based on which an express report data source is created: World Development Indicators

Number of dimension element selections in express report selection container: 3

Metric dimension identifier for the first report copy: New metric dimension

Observation object dimension identifier for the first report copy: New observation object dimension

Identifier of calendar dimension used for building a timeline in the first report copy: New timeline dimension

Object name, based on which the first report copy data source is created: New repository object

Available keys of map settings dictionary:

COLOR_KEY

DIM_KEY

SETTINGSFORMETRICS

SIZE_KEY

HEIGHT_KEY

See also:

Example of pplib++ Library Use