Calling Other Business Services
A method in one business service can call a method in another business service. For example, SupplierProcessor.addSupplier could call AddressBookProcessor.addAddressBook or AddressBookProcessor.addAddressBook could call PhonesProcessor.addPhones.
In this code sample, the PhonesProcessor.addPhones method takes an internalProcessPhones value object; this object is created and populated before calling the method:
//RI: Business service call to business service
//call PhonesProcessor
//only call phones processor if phones exist.
if (internalVO.getInternalPhones() != null) {
//create new internalVO for phones processor
InternalProcessPhone phones = new InternalProcessPhone();
//map data from internalVO to phones processor internalVO
phones.setMnAddressBookNumber(internalVO.getMnAddressBook
Number());
phones.setPhones(internalVO.getInternalPhones());
phones.setSzProgramId(programId);
//call phones processor to add phones
E1MessageList phonesMessages =
RI_PhonesProcessor.addPhones(context, connection, phones);
//If errors occur, change the error type to WARNING because
//we don't want to stop processing of Address Book record due
//to error while adding phones, interpret as warning instead.
if (phonesMessages.hasErrors()) {
phonesMessages.changeMessageType(E1Message.ERROR_MSG_TYPE,
E1Message.WARNING_MSG_TYPE);
//set list of phones to list w/ only added phones.
internalVO.setInternalPhones(phones.getPhones());
}
//add messages returned from phones processor
messages.addMessages(phonesMessages);
}
A business service method can call a business service utility method. For example, PurchaseOrderProcessor. processPurchaseOrder can call ItemProcessor.processItem and EntityProcessor.processEntity.
This code sample shows a business service call to a business service utility:
//RI: Business service call to business service
//call business service utility
//This business service returns a status code, this example will not
//use the status code to drive functionality, but
//could be evaluated to change processing.
InternalEntityUtility utilityEntity = new InternalEntityUtility();
utilityEntity.setMnAddressBookNumber(internalVO.getMnAddressBook
Number());
utilityEntity.setSzLongAddressNumber(internalVO.getSzLongAddress
Number());
utilityEntity.setSzTaxId(internalVO.getSzTaxId());
E1MessageList entityMessages = EntityProcessor.processEntity(context,
connection, utilityEntity);
internalVO.setMnAddressBookNumber(utilityEntity.getMnAddressBook
Number());
internalVO.setSzLongAddressNumber(utilityEntity.getSzLongAddress
Number());
internalVO.setSzTaxId(utilityEntity.getSzTaxId());
//Don't stop processing in case of errors from utility, change type to
// warning and add them to error collection.
if(entityMessages.hasErrors())
entityMessages.changeMessageType(E1Message.ERROR_MSG_TYPE,E1Message.
WARNING_MSG_TYPE);
//take messages generated from EntityProcessor and add them to the
//high level value object.
if (retMessages == null)
{
retMessages = entityMessages;
}
else
{
retMessages.addMessages(entityMessages);
}