Skip to Content
avatar image
Former Member

Need help on SMP 3.0 in defining multiple request for SODataOfflineStoreOptions

Hi,

Can someone help me on solving below issue. Thanks in advance.

I am using OData service to download  data in my iOS native application. We have customer and order data on server. On initial launch of application, i am downloading all customers data in my offlineStore. Now the problem what I am facing is If I want to download specific orders for a particular customer as both has relationship. Its not downloading the orders data. Below is the piece of code for definingRequest for downloading orders.

     SODataOfflineStoreOptions * storeOptions = [self OfflineStoreOptionsSharedInstance];

   

     NSLog(@"orders storeOptions : %@", storeOptions);

   

    NSString *keyValue = [NSString stringWithFormat:@"Orders?$filter=CustomerID eq '%@'", @"VINET"];

   

    storeOptions.definingRequests[@"req"] = keyValue;

If someone provide me the code snippet or any link where I can find anything. It will be very helpful.

Thanks,

Ashish jha

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 22, 2015 at 10:05 AM

    Hi,

    Below is the OData service which we are using. If you will go through it, it has number of collections. In my application, I want to download only customer data which I am populated in first screen. On selecting  any customer from list, I want to download orders related to that customer. I think now I have given you clear picture of my problem.

    http://services.odata.org/V4/Northwind/Northwind.svc/

    Looking for your response.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Midhun VP

      Hi Midhun,

      I'm not getting to set multiple requests. Only with one request.

      Is there any parameter i must to set for multiple requests?

      The offlineStore try to open 2 times and presents the error: "Store Open failed Error Domain=NetworkDomain Code=3 "[-10210] The operation failed due to an error on the server."


      Any ideia?

      My code:

      - (void)open {

          _appDelegate = [[UIApplication sharedApplication] delegate];

          NSError *error = nil;

          SODataOfflineStore *offlineStore = [[SODataOfflineStore alloc] init];

         

          [offlineStore setOfflineStoreDelegate: self];

          [offlineStore setRequestErrorDelegate: self];

         

          _store = offlineStore;

          [(SODataOfflineStore *)_store openStoreWithOptions: [self storeOptions] error: &error];

      }

      - (SODataOfflineStoreOptions*)storeOptions {

          SODataOfflineStoreOptions* options = [[SODataOfflineStoreOptions alloc] init];

          NSError *error = nil;

          MAFLogonCore *logonCore = _appDelegate.logonCore;

          HttpConversationManager* httpConvManager = [[HttpConversationManager alloc] init];

          MAFLogonContext *context;

         

          if ([logonCore unlockSecureStore: kRegisterPersistToken error:&error]) {

              context = [logonCore getContext:&error];

          }

         

          MAFLogonRegistrationContext *regContext = context.registrationContext;

          options.enableHttps = regContext.isHttps;

          options.host = regContext.serverHost;

          options.port = regContext.serverPort;

          options.storeEncryptionKey = kRegisterPersistToken;

          options.serviceRoot = [NSString stringWithFormat:@"/%@",   regContext.applicationId];

          options.definingRequests[@"req"] = @"/Cliente";

          options.definingRequests[@"req2"] = @"/Usuario";

          options.storeName = @"Store1";

          options.enableRepeatableRequests = NO;

          options.conversationManager = httpConvManager;

         

          return options;

      }

      Att,

      Ederich, Allan

      It's Mobile SAP Partner

  • avatar image
    Former Member
    May 21, 2015 at 08:24 AM

    Hi Ashish,

    Can you please share the code inside selfOfflineStoreOptionsSharedInstance ??

    As definingRequests is NSMutableDictionary, you can add as many defining requests as you like. The value is OData URLs, relative to the service root.

    SODataOfflineStore *offlineStore = [[SODataOfflineStore alloc] init];
    SODataOfflineStoreOptions *options = [[SODataOfflineStoreOptions alloc] init];
    options.host = serverHost;
    options.port = serverPort;
    options.serviceRoot = [NSString stringWithFormat:@"/%@", applicationId];
    options.conversationManager = myConversationManager;
    options.storeEncryptionKey = @"MyEncryptionKey";
    options.definingRequests[@"req1"] = @"/Customers";
    options.definingRequests[@"req2"] = @"/Orders";
     [offlineStore setOfflineStoreDelegate:self];
      [offlineStore openStoreWithOptions:options error:&error];
    


    Regards,

    Dhani

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      No, I am not getting any error. Since I have already downloaded customer data, so next time when I am trying to download customer specific orders, its opening the store and refreshing. But nothing getting downloaded. Can you tell me the steps what need to do to download customers and then based on CustomerID , download orders.

      Thanks,