Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes some methods of working with repository warehouse. After starting the example the following operations are executed:
A common warehouse pool is created.
Default repository warehouse is retrieved.
Text description of default warehouse is retrieved.
Repository warehouse is retrieved by specified path.
Obtained warehouse is synchronized with external memory data.
First warehouse is compared with second one.
Repository description is retrieved by means of default repository warehouse list.
Repository description is retrieved by means of web address, mobile application name, and web application name.
First repository description is compared with second one.
Repository is removed from default warehouse.
A new repository warehouse is created.
A new repository description is added to the created warehouse.
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):
// Create a common warehouse pool SPPLMetabaseRepositoryWarehousePool pool = PPLMetabaseRepositoryWarehousePool::sharedWarehousePool(); // Get default repository warehouse SPPLMetabaseRepositoryWarehouse defaultWarehouse = pool->defaultWarehouse(); // Get repository warehouse description SNString description = defaultWarehouse->description(); // Display repository warehouse description in the development environment console printf("Repository warehouse description:\n%s\n", description->UTF8String()); // Get path to repository warehouse NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"/repositories"]; SNString path = NString::stringWithNSString(filePath); // Get repository warehouse by specified path SPPLMetabaseRepositoryWarehouse sharedWarehouse = pool->sharedWarehouse(path); // Synchronize warehouse with external memory data sharedWarehouse->flush(); // Display result of comparison of repository warehouses obtained by different methods in the development environment console printf("Is first repository warehouse equal to second warehouse? "); defaultWarehouse->isEqual(sharedWarehouse)? printf("yes\n"): printf("no\n"); // Get repositories list SNArray repositories = defaultWarehouse->repositoriesList(); // Get repository description from repositories list SPPLMetabaseRepositoryDescriptor repoDescriptor = repositories->objectAtIndex<PPLMetabaseRepositoryDescriptor>(0); // Get repository web address SNString host = repoDescriptor->host(); // Get repository web application name SNString webAppName = repoDescriptor->webAppName(); // Get repository mobile application name SNString mobileAppName = repoDescriptor->mobileAppName(); // Get repository name by means of web address, mobile application name and repository web application name SPPLMetabaseRepositoryDescriptor repoDescriptor2 = defaultWarehouse->getRepository(host, webAppName, mobileAppName); // Display result of comparison of first and second repositories in the development environment console printf("Are first and second repositories equal? "); repoDescriptor->isEqual(repoDescriptor2)? printf("yes\n"): printf("no\n"); // Display the number of repositories in warehouse in the development environment console printf("Number of repositories in warehouse: %d\n",repositories->count()); // Remove repository from warehouse defaultWarehouse->removeRepository(repoDescriptor); // Display message about repository removal from warehouse in the development environment console printf("Repository removal from warehouse\n"); // Display number of repositories in warehouse in the development environment console printf("Number of repositories in warehouse: %d\n",repositories->count()); // Create a new repository warehouse SPPLMetabaseRepositoryWarehouse createdWarehouse = PPLMetabaseRepositoryWarehouse::warehouse(path); // Create a new repository description SPPLMetabaseRepositoryDescriptor repoDescriptor3 = new PPLMetabaseRepositoryDescriptor(); // Set new repository web address repoDescriptor3->setHost(NStr("http://somehost")); // Set new repository web application name repoDescriptor3->setWebAppName(webAppName); // Set new repository mobile application name repoDescriptor3->setMobileAppName(mobileAppName); // Add repository to new warehouse createdWarehouse->putRepository(repoDescriptor3); // Display message about adding repository to new warehouse in the development environment console printf("Adding repository to new warehouse\n"); // Display number of repositories in new warehouse in the development environment console printf("Number of repositories in new warehouse: %d\n",createdWarehouse->repositoriesList()->count());
After executing the example, the development environment console displays description of the default repository warehouse, the number of elements in the new and source warehouses after adding and removing of repositories, and also results of comparison of warehouses and repositories obtained by different methods:
Repository warehouse description:
Warehouse descriptor:
Path: /Users/vda/Library/Application Support/iPhone Simulator/7.0.3/Applications/68D12A40-29AD-48E0-9301-6183072D1A90/Documents/repositories
Repositories:
<NMutableArray:
Repository:
Hash NULL
Key: 82529
Version: 1
Object Id: MOB5
Source URL: http://krauler/PPMobile_App_v7.2/FilesMobile.axd?appName=MOB5&type=filesList
Local objects:
<NMutableArray:
Object:
Key: 528
Object Id: CUBE_WORLD
Name: World Development Indicators
Type: 3
Modified date: NDate: Thu 22 Dec 2011 18:21:01
Data source ref id: NULL
Hidden NO
Size: 405360
Version: 1678039
Dependencies: 80744024dd8697aaa699504a21131f0e
Object:
Key: 82530
Object Id: OLAP_MOB
Name: OLAP
Type: 1
Modified date: NDate: Wed 26 Feb 2014 16:09:18
Data source ref id: CUBE_WORLD
Hidden NO
Size: 920734
Version: 1678039
Dependencies: 08b1390d973e7516f4e3718334849ac9
Object:
Key: 84237
Object Id: OBJ84237
Name: ExpressReports
Type: 7
Modified date: NDate: Tue 11 Mar 2014 11:19:07
Data source ref id: NULL
Hidden NO
Size: 0
Version: 0
Dependencies: NULL
>
Remote objects
<NMutableArray:
>
>
Is the first repository warehouse equal to the second one? yes
Are the first and the second repositories equal? yes
Number of repositories in warehouse: 1
Repository removal from warehouse
Number of repositories in warehouse: 0
Adding repository to new warehouse
Number of repositories in new warehouse: 1
See also: