Table of Contents

Search

  1. Preface
  2. Introduction to Business Entity Services
  3. EJB Business Entity Service Calls
  4. REST Business Entity Service Calls
  5. REST APIs for Data Director
  6. SOAP Business Entity Service Calls
  7. Cross-reference Records and BVT Calculations Services
  8. Supporting Corporate Linkage Service
  9. External Calls to Cleanse, Analyze, and Transform Data
  10. Appendix A: Using REST APIs to Add Records
  11. Appendix B: Using REST APIs to Upload Files
  12. Appendix C: Using REST APIs to Manage Reports

Getting Source Row IDs with the MergeCO.BeforeEverything External Call

Getting Source Row IDs with the MergeCO.BeforeEverything External Call

During a merge action, source row IDs help trace the source base objects. You can get source row IDs from the inputSDO process method parameter with the MergeCO.BeforeEverything external call.
To get the source row IDs, perform the following steps:
  1. Implement the MergeCO.BeforeEverything external call.
    The following sample code from the MergePerson.java file gets the source row IDs with the MergeCO.BeforeEveryting external call:
    package com.informatica.mdm.sample.cs; import java.util.List; import java.util.Map; import com.informatica.mdm.sdo.co.base.BaseObject; import com.informatica.mdm.sdo.co.base.CompositeObjectBase; import com.informatica.mdm.sdo.co.base.KeysAndOverrides; import com.informatica.mdm.sdo.co.base.MergedRecord; import com.informatica.mdm.sdo.co.base.MergedRecordPager; import com.informatica.mdm.sdo.co.base.Pager; import com.informatica.mdm.sdo.cs.base.BusinessEntityKey; import com.informatica.mdm.sdo.cs.base.Key; import com.informatica.mdm.spi.cs.StepException; import com.informatica.mdm.spi.externalcall.CustomLogic; import commonj.sdo.ChangeSummary; import commonj.sdo.DataObject; import commonj.sdo.Property; import commonj.sdo.helper.HelperContext; import org.eclipse.persistence.sdo.SDOChangeSummary; /** * Call this piece of code before the Person business entity record merge or the previewMerge API call. */ public class MergePerson implements CustomLogic { public static final String KEYS_AND_OVERRIDES = "keysAndOverrides"; public static final String OVERRIDES = "overrides"; public static final String MERGE = "MERGE"; @Override public DataObject process(HelperContext helperContext, DataObject inputSdo, Map<String, Object> inParams, Map<String, Object> outParams) throws StepException { DataObject keysAndOverrides = (DataObject) inParams.get(KEYS_AND_OVERRIDES); if (keysAndOverrides != null) { explainMerge(inParams); DataObject overrides = keysAndOverrides.getDataObject(OVERRIDES); if (overrides != null) { // if "overrides" are provided, then user is not simply merging several records, but // tryes to merge some child records or provides some winner override List<DataObject> list = overrides.getList("Person/TelephoneNumbers/item"); if ((list != null) && !list.isEmpty()) { SDOChangeSummary changeSummary = (SDOChangeSummary) overrides.getChangeSummary(); changeSummary.resumeLogging(); // remove "MERGE" element from all "Telephone" items, this will prevent mering of "Telephone" child records for (DataObject dataObject : list) { if (dataObject.isSet(MERGE)) { dataObject.unset(MERGE); } } // send updated "overrides" back to Hub outParams.put(KEYS_AND_OVERRIDES, keysAndOverrides); } } } return inputSdo; } private void explainMerge(Map<String, Object> inParams) { BusinessEntityKey businessEntityKey = (BusinessEntityKey) inParams.get("businessEntityKey"); System.out.println(String.format("%s:%s", businessEntityKey.getName(), businessEntityKey.getKey().getRowid())); KeysAndOverrides keysAndOverrides = (KeysAndOverrides) inParams.get("keysAndOverrides"); List<Key> keys = keysAndOverrides.getKeys(); for (Key key : keys) { System.out.println(String.format(" | <- %s", key.getRowid())); } CompositeObjectBase overrides = keysAndOverrides.getOverrides(); if(overrides != null) { DataObject co = (DataObject) overrides; ChangeSummary changeSummary = co.getChangeSummary(); DataObject root = co.getDataObject(co.getType().getName()); dumpOne("", co.getType().getName(), root, changeSummary); } } private void dumpOne(String prefix, String name, DataObject dataObject, ChangeSummary changeSummary) { String rowidObject = dataObject.getString("rowidObject"); if(rowidObject != null) { System.out.println(String.format("%s%s:%s", prefix, name, rowidObject)); } List<MergedRecord> mergeItems = dataObject.getList("MERGE/item"); if(mergeItems != null) { for (MergedRecord mergeItem : mergeItems) { System.out.println(String.format("%s | <- %s", prefix, mergeItem.getKey().getRowid())); } } List<Property> properties = dataObject.getInstanceProperties(); for (Property property : properties) { Object o = dataObject.get(property); if((o instanceof Pager) && !(o instanceof MergedRecordPager)) { DataObject pager = (DataObject) o; System.out.println(prefix + property.getName()); List<DataObject> items = pager.getList("item"); for (int i = 0; i < items.size(); i++) { DataObject item = items.get(i); dumpOne(prefix + " " ,"[" + i + "]", item, changeSummary); } } if(o instanceof BaseObject) { dumpOne(prefix + " ", property.getName(), (DataObject) o, changeSummary); } } if(changeSummary.isModified(dataObject)) { List<ChangeSummary.Setting> oldValues = changeSummary.getOldValues(dataObject); for (ChangeSummary.Setting setting : oldValues) { Property property = setting.getProperty(); if(!"MERGE".equals(property.getName())) { Object value = dataObject.get(property); System.out.println(String.format("%s manual override: %s = %s", prefix, property.getName(), value)); } } } } }
    The inputSDO process method parameter is the merge target. Any keys and overrides are from the merge source.
  2. To trigger an external call, run a POST request for the Merge API or Preview Merge API with any standard REST client, such as Postman.
    The process calls the MergeCO.BeforeEverything event.
    The following sample POST request outputs the source row IDs:
    POST: http://localhost:8080/cmx/cs/localhost-orcl103-MDM_SAMPLE/Person/{{person1_id}}?action=previewMerge { "keys": [ { "rowid": "{{person2_id}}" } ], "overrides": { "Person": { "Addresses": { "item":[ { "rowidObject": "{{person1_Addresses1_id}}", "MERGE": { "item":[{"key":{"rowid": "{{person2_Addresses1_id}}"}}], "$original": { "item":[null] } } } ] }, "TelephoneNumbers": { "item":[ { "rowidObject": "{{person1_TelephoneNumbers1_id}}", "phoneNum": "777-77-77", "$original": { "phoneNum":null }, "MERGE": { "item":[{"key":{"rowid": "{{person2_TelephoneNumbers1_id}}"}}], "$original": { "item":[null] } } } ] } } } }
    The following sample output displays the source row IDs:
    2020-03-20 11:59:49,631 INFO [stdout] (default task-55) Person:401924 2020-03-20 11:59:49,631 INFO [stdout] (default task-55) | <- 401925 2020-03-20 11:59:49,632 INFO [stdout] (default task-55) | <- 401926 2020-03-20 11:59:49,632 INFO [stdout] (default task-55) TelephoneNumbers 2020-03-20 11:59:49,632 INFO [stdout] (default task-55) [0]:1724 2020-03-20 11:59:49,632 INFO [stdout] (default task-55) | <- 1725 2020-03-20 11:59:49,633 INFO [stdout] (default task-55) | <- 1726 2020-03-20 11:59:49,633 INFO [stdout] (default task-55) manual override: phoneNum = 777-77-77 2020-03-20 11:59:49,633 INFO [stdout] (default task-55) Addresses 2020-03-20 11:59:49,633 INFO [stdout] (default task-55) [0]:2124 2020-03-20 11:59:49,633 INFO [stdout] (default task-55) | <- 2125 2020-03-20 11:59:49,634 INFO [stdout] (default task-55) | <- 2126

0 COMMENTS

We’d like to hear from you!