Working with Report Resources

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example implements working with report resources. After starting the example the following operations are executed:

Source Code

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

// Get express report
SPPLOlapReport olapReport = m_olapReport;
// Get report resource container
SPPLReportResources resources = olapReport->resources();
// Get report resources
SPPLReportResource res1 = resources->items()[0]->qClass<PPLReportResource>();
// Display information about report resources
printf("%s %s\n", "Resource extension:", res1->ext()->UTF8String());
printf("%s %s\n", "Path to resources:", res1->path()->UTF8String());
if (res1->fullPath() != NULL) {
    printf("%s %s\n", "Full path to resources:", res1->fullPath()->UTF8String());
} else {
    printf("Full path to resources is not defined\n");
}
printf("%s %s\n", "Resource identifier:", res1->id()->UTF8String());
printf("%s %s\n", "MIME type of resources:", res1->mimeType()->UTF8String());
// Display number of resources settings
printf("%s %d\n", "Number of report resources settings:", res1->generatePlist()->qClass<NMutableDictionary>()->count());
// Create new report resources
SNString newId = NString::stringWithNSString(@"NewResource1");
SPPLReportResource newRes1 = PPLReportResource::resource(newId, res1->path(), res1->ext(), res1->mimeType(), olapReport);
// Create new report resources based on settings dictionary
SNMutableDictionary pList = res1->generatePlist()->qClass<NMutableDictionary>();
SPPLReportResource newRes2 = PPLReportResource::resource(pList, olapReport);
// Create and fill in array of resources
SNMutableArray arr = new NMutableArray();
arr->addObject(newRes1);
arr->addObject(newRes2);
// Create a new container of report resources
SPPLReportResources newResources = new PPLReportResources(arr);
// Display identifiers of created report resources
for (int i = 0; i < newResources->items()->count(); i++) {
    printf("%s %s\n", "Identifier of added resources:", newResources->items()->objectAtIndex<PPLReportResource>(i)->id()->UTF8String());
}
// Create a new report by means of repository object description, based on which a source report is created, and its copy
SPPLReport newReport1 = PPLReport::report(olapReport->descriptor());
if (newReport1 != NULL) {
    SPPLReport newReport2 = newReport1->copy()->qClass<PPLReport>();
    // Get dictionary of created report settings
    SNMutableDictionary newReportPList = newReport2->generatePlist()->qClass<NMutableDictionary>();
    // Display number of report settings
    printf("%s %d\n", "Number of report settings:", newReportPList->count());
    // Delete report objects
    newReport1->~PPLReport();
    newReport2->~PPLReport();
}

After executing the example the development environment console displays values of report settings:

Resource extension: svg

Path to resources: 24gsty4k

Full path to resources: /Users/gam/Library/Application Support/iPhone Simulator/7.0.3/Applications/BC361FA1-CE06-4160-A2BA-1CE978341EB8/Documents/repositories/B2130311EBF84A38299E03DEB2196EFF/OLAP_MOB/24gsty4k.svg

Resource identifier: 24gsty4k

MIME type of resources: image/svg+xml

Number of report resource settings: 4

Identifier of added resources: NewResource1

Identifier of added resources: 24gsty4k

Number of report settings: 2

See also:

Example of pplib++ Library Use