Multidomain MDM
- Multidomain MDM 10.3 HotFix 2
- All Products
package com.informatica.mdm.sample.cs; import com.informatica.mdm.cs.CallContext; import com.informatica.mdm.cs.api.CompositeServiceException; import com.informatica.mdm.cs.client.CompositeServiceClient; import com.informatica.mdm.sdo.cs.base.CoFilter; import com.informatica.mdm.sdo.cs.base.CoFilterNode; import com.informatica.mdm.sdo.cs.base.Key; import com.siperian.sif.client.EjbSiperianClient; import com.siperian.sif.client.SiperianClient; import commonj.sdo.DataObject; import commonj.sdo.helper.DataFactory; import commonj.sdo.helper.HelperContext; import mdm.informatica.co_ors.*; import mdm.informatica.cs_ors.*; import java.io.PrintStream; import java.util.Arrays; import java.util.Properties; public class GeneratedSDO { public static void main(String[] args) throws CompositeServiceException { if(args.length != 3) { System.err.println("USAGE: GeneratedSDO <ors> <user> <pass>"); return; } new GeneratedSDO(args[0], args[1], args[2]).execute(); } private String orsId; private String user; private String pass; private HelperContext helperContext; private PrintStream out = System.out; public GeneratedSDO(String orsId, String user, String pass) { this.orsId = orsId; this.user = user; this.pass = pass; } public void execute() throws CompositeServiceException { String systemName = "Admin"; Properties config = new Properties(); config.put(SiperianClient.SIPERIANCLIENT_PROTOCOL, EjbSiperianClient.PROTOCOL_NAME); CompositeServiceClient client = CompositeServiceClient.newCompositeServiceClient(config); CallContext callContext = new CallContext(orsId, user, pass); helperContext = client.getHelperContext(callContext); DataFactory dataFactory = helperContext.getDataFactory(); // 1. Create new person WritePerson createPerson = (WritePerson)dataFactory.create(WritePerson.class); WritePersonParameters createPersonParameters = (WritePersonParameters)dataFactory.create(WritePersonParameters.class); createPersonParameters.setSystemName(systemName); createPerson.setParameters(createPersonParameters); Person person = (Person)dataFactory.create(Person.class); createPerson.setObject(person); person.getChangeSummary().beginLogging(); PersonRoot personRoot = (PersonRoot)dataFactory.create(PersonRoot.class); personRoot.setFirstName("John"); personRoot.setLastName("Smith"); person.setPerson(personRoot); person.getChangeSummary().endLogging(); dump("*** CREATE NEW PERSON ...", createPerson); WritePersonReturn createPersonResponse = (WritePersonReturn)client.process(callContext, (DataObject)createPerson); dump("*** PERSON CREATED:", createPersonResponse); String personRowId = createPersonResponse.getObject().getPerson().getRowidObject(); Key key = (Key)dataFactory.create(Key.class); key.setRowid(personRowId); CoFilterNode coFilterNode = (CoFilterNode)dataFactory.create(CoFilterNode.class); coFilterNode.setName(Person.class.getSimpleName()); coFilterNode.setKey(key); CoFilter coFilter = (CoFilter)dataFactory.create(CoFilter.class); coFilter.setObject(coFilterNode); ReadPersonParameters readPersonParameters = (ReadPersonParameters)dataFactory.create(ReadPersonParameters.class); readPersonParameters.setCoFilter(coFilter); ReadPerson readPerson = (ReadPerson)dataFactory.create(ReadPerson.class); readPerson.setParameters(readPersonParameters); dump("*** READ CREATED PERSON...", readPerson); ReadPersonReturn readPersonResponse = (ReadPersonReturn)client.process(callContext, (DataObject)readPerson); dump("*** READ RESULT:", readPersonResponse); person = readPersonResponse.getObject(); ((DataObject)person).detach(); person.getChangeSummary().beginLogging(); personRoot = person.getPerson(); // add new 'one' child LUGenderLookup genderCd = (LUGenderLookup)dataFactory.create(LUGenderLookup.class); genderCd.setGenderCode("M"); personRoot.setGenderCd(genderCd); // add two 'many' children PersonTelephoneNumbersPager phonePager = (PersonTelephoneNumbersPager)dataFactory.create(PersonTelephoneNumbersPager.class); PersonTelephoneNumbers phone1 = (PersonTelephoneNumbers)dataFactory.create(PersonTelephoneNumbers.class); phone1.setPhoneNumber("111-11-11"); PersonTelephoneNumbers phone2 = (PersonTelephoneNumbers)dataFactory.create(PersonTelephoneNumbers.class); phone2.setPhoneNumber("222-22-22"); phonePager.setItem(Arrays.asList(phone1, phone2)); personRoot.setTelephoneNumbers(phonePager); person.getChangeSummary().endLogging(); WritePerson updatePerson = (WritePerson)dataFactory.create(WritePerson.class); updatePerson.setObject(person); WritePersonParameters updatePersonParameters = (WritePersonParameters)dataFactory.create(WritePersonParameters.class); updatePersonParameters.setSystemName(systemName); updatePersonParameters.setInteractionId(""); updatePerson.setParameters(updatePersonParameters); dump("*** UPDATE PERSON...", updatePerson); WritePersonReturn updatePersonResponse = (WritePersonReturn)client.process(callContext, (DataObject)updatePerson); dump("*** PERSON UPDATED:", updatePersonResponse); coFilterNode.setDepth(3); readPersonParameters.setReadSystemFields(true); dump("*** READ UPDATED PERSON WITH CHILDREN (with system fields)...", readPerson); readPersonResponse = (ReadPersonReturn)client.process(callContext, (DataObject)readPerson); dump("*** READ RESULT:", readPersonResponse); person = readPersonResponse.getObject(); ((DataObject)person).detach(); person.getChangeSummary().beginLogging(); // delete one phone person.getPerson().getTelephoneNumbers().getItem().remove(0); // change gender genderCd = (LUGenderLookup)dataFactory.create(LUGenderLookup.class); genderCd.setGenderCode("F"); personRoot.setGenderCd(genderCd); person.getChangeSummary().endLogging(); WritePerson deletePhone = (WritePerson)dataFactory.create(WritePerson.class); deletePhone.setObject(person); WritePersonParameters deletePhoneParameters = (WritePersonParameters)dataFactory.create(WritePersonParameters.class); deletePhoneParameters.setSystemName(systemName); deletePhone.setParameters(deletePhoneParameters); dump("*** DELETE CHILD...", deletePhone); WritePersonReturn deletePhoneResponse = (WritePersonReturn)client.process(callContext, (DataObject)deletePhone); dump("*** CHILD DELETED:", deletePhoneResponse); readPersonParameters.setReadSystemFields(false); dump("*** READ PERSON AFTER CHILD WAS DELETEED...", readPerson); readPersonResponse = (ReadPersonReturn)client.process(callContext, (DataObject)readPerson); dump("*** READ RESULT:", readPersonResponse); person = readPersonResponse.getObject(); ((DataObject)person).detach(); person.getChangeSummary().beginLogging(); ((DataObject)person.getPerson()).delete(); person.getChangeSummary().endLogging(); WritePerson deletePerson = (WritePerson)dataFactory.create(WritePerson.class); deletePerson.setObject(person); WritePersonParameters deletePersonParameters = (WritePersonParameters)dataFactory.create(WritePersonParameters.class); deletePersonParameters.setSystemName(systemName); deletePerson.setParameters(deletePersonParameters); dump("*** DELETE PERSON...", deletePerson); WritePersonReturn deletePersonResponse = (WritePersonReturn)client.process(callContext, (DataObject)deletePerson); dump("*** PERSON DELETED:", deletePersonResponse); dump("*** TRY TO READ PERSON AFTER DELETE", readPerson); try { readPersonResponse = (ReadPersonReturn)client.process(callContext, (DataObject)readPerson); dump("*** READ RESULT:", readPersonResponse); } catch (CompositeServiceException e) { out.println("*** READ RESULT: " + e.getLocalizedMessage()); } } private void dump(String title, Object object) { DataObject dataObject = (DataObject)object; String xml = helperContext.getXMLHelper().save( dataObject, dataObject.getType().getURI(), dataObject.getType().getName()); out.println(title); out.println(xml); out.println(); } }