Merging Operation Input/Output Into the Cache

The MBO developer can configure input mappings so that client provided parameters and personalization keys are passed with Create or Update operations, which use the "Apply merge of operation input/output" cache policy option, to merge them with the operation results and apply them to the SAP Mobile Server cache to update a composite object graph from a single operation.


mergingResultsIntoCache

  • Merge PreProcessor – accepts client attributes and EIS operation results as input and merges them into a single result according to these rules:
    • Client attributes always contain the surrogate key of the composite root instance, since it is used to identify the graph instance.
    • Client attributes must contain a fully specified (no null attributes) primary key for the pre-processor to merge them with the operation results.
    • If an MBO instance is present in the client attributes but missing from the EIS results, the client-provided instance is used during merge processing. This allows the cache to be populated based solely on client-provided attributes.
    • If an MBO instance or attribute is present in the EIS result, but not in the client attributes, the EIS result is used.
    Essentially the preprocessor treats client attributes as default values that take effect only when the corresponding MBO attribute or MBO instance does not exist in the EIS result. The client attributes contain the client's version of the composite graph nodes influenced by the operation. When a new composite graph is inserted, the set of client attributes contains the complete graph. During an update to a composite graph, only the input attributes associated with the modified nodes and their ancestors are present in the client attributes.
    Note: There is a distinction between a null attribute and a missing attribute, since the preprocessor considers null attribute values to be valid non-primary-key attribute values. If the EIS result contains a null attribute value, the preprocessor does not attempt to find a corresponding default client attribute.
  • Graph Merge Processor – takes the results from the preprocessing phase (graphId and premerged results) and compares them to the current cache contents. The graph merge processor processes the composite graph from parent to child comparing cached graph parts to the corresponding EIS graph parts. The graph merge processor compares the cached graph part (the portion of the graph associated with a particular MBO type) with the corresponding premerged results and updates the cache as follows:
    • If an MBO instance held in the cache differs from the one held in the pre-merged result, the cache is updated with the version held in the pre-merged results.
    • If an MBO instance is contained in the pre-merged result, but not in the cache, the MBO instance is inserted into the cache using the surrogate key contained in the client attributes if a suitable match is found during pre-processing. If a suitable match is not found during pre-processing, a new surrogate key is generated and assigned to the MBO instance before it is inserted into the cache.
    • If the MBO instance is contained the cache, but not in the pre-merged results, the row is logically deleted from the cache.
    • If an MBO result is missing from the pre-merged results, the graph-part associated with the missing result does not change in the cache.
Note: Apply merge of operation input/output processing applies only to a single composite MBO graph instance. Neither the client attributes nor the EIS results can contain multiple root MBO instances. If a set of client attributes is missing a primary key and cannot be matched with an EIS result during the graph merge processing, the surrogate key is discarded and a warning message is generated. A logically deleted row is not created in the cache.