Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8667

Re: Multiple entities added to parent table? Deep Insert does not work offline.

$
0
0

Hi Rodrigo,

 

I'm researching this topic, I'll get back to you when I get more information.

 

Thanks Midhun VP, for your code snippet. Please keep in mind that this code does not use the offline store class. The SDK SP05 provides support for backward compatibility, so this code should work.

 

If you want to use the offline store SDK  SP05+, then you need to use different classes

 

    // Create your Entity Set, for example Agency Entity

    ODataEntity newEntity

          = new ODataEntityDefaultImpl(Collections.TRAVEL_AGENCY_ENTITY_TYPE);

    newEntity.getProperties().put(Collections.TRAVEL_AGENCY_ENTRY_ID,

    new ODataPropertyDefaultImpl(Collections.TRAVEL_AGENCY_ENTRY_ID, <agency id>));

    newEntity.getProperties().put(Collections.TRAVEL_AGENCY_ENTRY_NAME,

    new ODataPropertyDefaultImpl(Collections.TRAVEL_AGENCY_ENTRY_NAME, <agency name>));

    ... // Add other the required properties

 

    // Create changeSet

    ODataRequestChangeSet changeSetItem = new ODataRequestChangeSetDefaultImpl();

 

    // Create batch item

    ODataRequestParamSingle batchItem = new ODataRequestParamSingleDefaultImpl();

 

    // Allocate new Entity

    batchItem.setResourcePath(getAgencyResourcePath(mode, agency));

    batchItem.setMode(mode);

    batchItem.setPayload(newEntity);

    batchItem.setCustomTag(createBatchTag(mode, agency.getAgencyId()));

 

    // Add headers

    Map<String, String> createHeaders = new HashMap<String, String>();

    createHeaders.put("accept", "application/atom+xml");

    createHeaders.put("content-type", "application/atom+xml");

    batchItem.setOptions(createHeaders);

 

    // Add changeset

    changeSetItem.add(batchItem);

 

    // you can add more Batch items to the same changeset

 

    // Add batch item to batch request

    ODataRequestParamBatch requestParamBatch.add(changeSetItem);

 

    // Send batch request through the offline store

    store.scheduleRequest(requestParamBatch, ODataRequestListener);

 

Best regards,

Claudia


Viewing all articles
Browse latest Browse all 8667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>