Multidomain MDM
- Multidomain MDM 10.4 HotFix 3
- All Products
public class ValidatePerson implements CustomLogic { private CompositeServiceClient besClient; private CallContext callContext; public ValidatePerson(CompositeServiceClient besClient, CallContext callContext) { this.besClient = besClient; this.callContext = callContext; } @Override public DataObject process(HelperContext helperContext, DataObject inputSdo, Map < String, Object > inParams, Map < String, Object > outParams) throws StepException { try { List < ValidationError > errorList = new ArrayList < > (); DataFactory dataFactory = helperContext.getDataFactory(); // Ensure that the Person SDO has at least one Address item List<?> list = inputSdo.getList("Person/Addresses/item"); if ((list == null) || list.isEmpty()) { String personId = inputSdo.getString("Person/rowidObject"); if(personId != null) { // Verify if an address already exists DataObject readEntity = dataFactory.create(ReadEntity.class); DataObject personFilter = readEntity.createDataObject("parameters").createDataObject("coFilter").createDataObject("object"); personFilter.setString("name", "Person"); personFilter.createDataObject("key").setString("rowid", personId); DataObject addressFilter = personFilter.createDataObject("object"); addressFilter.setString("name", "Addresses"); addressFilter.createDataObject("pager").setInt("recordsToReturn", 1); DataObject readEntityReturn = besClient.process(callContext, readEntity); List existingList = readEntityReturn.getList("object/Person/Addresses/item"); if (existingList == null || existingList.isEmpty()) { errorList.add(createValidationError(dataFactory, "CUSTOM-00001", "You must enter at least one Address.", "Person.Addresses")); }
public class CustomLogicFactoryImpl implements CustomLogicFactory { public static final String PERSON = "Person"; private static final CustomLogic EMPTY_LOGIC = new EmptyLogic(); private CompositeServiceClient besClient; public CustomLogicFactoryImpl(CompositeServiceClient besClient) { this.besClient = besClient; } @Override public CustomLogic create(ExternalCallRequest externalCallRequest, CallContext callContext) throws StepException { // Interest is in the Person business entity. The logic can handle a few service phases. Trigger trigger = externalCallRequest.getTrigger(); String businessEntity = trigger.getBusinessEntity(); ServicePhase phase = trigger.getServicePhase(); switch (phase) { case WRITE_CO_BEFORE_VALIDATE: if (PERSON.equals(businessEntity)) { return new ValidatePerson(besClient, callContext); } break; case PREVIEW_MERGE_CO_BEFORE_EVERYTHING: case MERGE_CO_BEFORE_EVERYTHING: if (PERSON.equals(businessEntity)) { return new MergePerson(); } break; default: // } return EMPTY_LOGIC; // This one does nothing }
/** * Web service implementation. * It must accept a {urn:bes-external-call.informatica.mdm}ExternalCallRequest as an operation input * and return a {urn:bes-external-call.informatica.mdm}ExternalCallResponse as output. */ @WebServiceProvider( targetNamespace = "http://cs.sample.mdm.informatica.com/", serviceName = "CustomLogicService", portName = "CustomLogicServicePort", wsdlLocation = "WEB-INF/wsdl/custom-logic-service.wsdl" ) @ServiceMode(Mode.PAYLOAD) public class CustomLogicService implements Provider<Source> { @Override public Source invoke(Source request) { CompositeServiceClient compositeServiceClient = createCompositeServiceClient(); CustomLogicFactory customLogicFactory = new CustomLogicFactoryImpl(compositeServiceClient); String appName = "<trusted_user>"; // replace with proper application user name // Create a processor instance and let the instance perform the job. // Provide a custom logic factory implementation. ExternalCallProcessor externalCallProcessor = new ExternalCallProcessor(compositeServiceClient, appName, customLogicFactory); return externalCallProcessor.invoke(request); }
File Name
| Description
| Location
|
---|---|---|
bes-external-call.xsd
| Defines the request and response types for all external calls. An external web service operation must use the request and response types for the input and output elements.
| <MDM installation directory>/hub/server/lib/mdm-spi.jar
|
custom-logic-service.wsdl
| WSDL file for the example web service. Defines the external services, operations, methods, and data types that the service methods exchange.
| <MDM installation directory>/hub/resourcekit/samples/BESExternalCall/source/resources/webapp/WEB-INF/wsdl/
|
ValidatePerson.java and
MergePerson.java
| Examples of custom validate and merge operations that run with the example web service.
This example uses .java files, but your external web service might require a different coding standard.
| <MDM installation directory>/hub/resourcekit/samples/BESExternalCall/source/java/
|
build.xml
| Builds the
bes-external-call.ear file.
| <MDM installation directory>/hub/resourcekit/samples/BESExternalCall/
|
bes-external-call.ear
| The
.ear file that you deploy to the application server to run this example.
| <MDM installation directory>/hub/resourcekit/samples/BESExternalCall/build/
|