Introduction : While dealing with BO's in Integration designer we may need BO API to deal with BO's to initialize, to get data from bo or to set data to bo for those things we need bo API
Here we will learn bo api along with all it's interfaces and functions in those interfaces.
package : com.ibm.websphere.bo
Interfaces in this package :
- BOFactory
- BOXSDHelper
- BOXMLSerializer
- BOTypeMetadata
- BOType
- BOInstanceValidator
- BOXMLDocument
- BOEquality
- BOEventSummary
- BODataObject
- BOCopy
- BOChangeSummary
1. BOFactory : The BOFactory service provides the ability to create business objects and business documents that are represented in memory by the commonj.sdo.DataObject and com.ibm.websphere.bo.BOXMLDocument objects. It contains following method's by using those we can able to create business objects and business documents at runtime.
A. create
Syntax: commonj.sdo.DataObject create(java.lang.String targetNamespace,
java.lang.String complexTypeName)
- Creates a DataObject from an XML Schema complex type definition.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
DataObject customer = boFactory.create("http://MP_SampleModule/Customer", "Customer");
Syntax: commonj.sdo.DataObject createByElement(java.lang.String targetNamesp ace,java.lang.String globalElementName)
- Creates a DataObject from an XML Schema global element definition.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
DataObject customer = boFactory.createByElement("http://MP_SampleModule/Customer", "customer");
Syntax: commonj.sdo.DataObject createByType(commonj.sdo.Type type)
- Creates a DataObject from a commonj.sdo.Type. The Type can be created using the BOType service.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOType boType = (BOType) new ServiceManager().locateService("com/ibm/websphere/bo/BOType");
Type customerType = boType.create("http://MP_SampleModule/Customer", "Customer");
DataObject customer = boFactory.createFromType(customerType);
Syntax: commonj.sdo.DataObject createByMessage(java.lang.String targetNamesp ace,java.lang.String messageName)
- Creates a DataObject from a WSDL message definition.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
DataObject customer = boFactory.createByMessage("http://MP_SampleModule/Customer", "customer");
E. createXMLDocument
F .createDataTypeWrapper
-
Syntax: BOXMLDocument createXMLDocument(java.lang.String targetName space,java.lang.String globalElementName)
- Creates a BOXMLDocument from an XML Schema global element definition.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOXMLDocument customerDocument = boFactory.createXMLDocument("http://MP_SampleModule/Customer", "customer");
Syntax: BOXMLDocument createXMLDocument(java.lang.String targetName space,java.lang.String globalElementName)
- Creates a BOXMLDocument from an XML Schema global element definition.
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOXMLDocument customerDocument = boFactory.createXMLDocument("http://MP_SampleModule/Customer", "customer");
F .createDataTypeWrapper
Syntax: commonj.sdo.DataObject createDataTypeWrapper(commonj.sdo.TypedataType,java.lang.Object value)
-
Creates a DataObject wrapper for a simple data type
BOFactory boFactory = (BOFactory) new ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOType boType = (BOType) new ServiceManager().locateService("com/ibm/websphere/bo/BOType");
Type stringType = boType.getType("http://www.w3.org/2001/XMLSchema", "string");
DataObject stringType = boFactory.createDataTypeWrapper(stringType, "foo");
2. BOCopy : The BOCopy interface represents the client programming model interface for the BOCopy service. The BOCopy service provides operations for copying Business Objects.
" We have faced one situation in our project if we manipulate any data from one source data object in snippet activity after that if we are trying to use that same source data object in aother snippets we are unable to get the data from that object. It's reference getting lost. In that situation we are using this
BOCopy.
A . copy :
Syntax: commonj.sdo.DataObject copy(commonj.sdo.DataObject sourceBusinessObject)
Creates a deep copy of the Business Object.
BOCopy boCopy = (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");
DataObject copiedCustomer = boCopy.copy(customer);
B. copyShallow
Syntax: commonj.sdo.DataObject copyShallow(commonj.sdo.DataObject sourceBusinessObject)
Creates a shallow copy of the Business Object.
BOCopy boCopy = (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");
DataObject copiedCustomer = boCopy.copyShallow(customer);
C. copyInto
Syntax: void copyInto(commonj.sdo.DataObject sourceBusinessObject,
commonj.sdo.DataObject targetBusinessObject,
java.lang.String targetPropertyPath)
Deprecated. Instead call copy on the source and then set the copy into the destination.
Replacement code:
DataObject copyBO = boCopy.copy(sourceBO);
targetBO.set(path, copyBO);
End of replacement code.
Creates a deep copy of the source Business Object into the property referenced by the combination of the target Business Object and the target property path parameters.
If the property referenced by the target Business Object and the associated target property path has a cardinality of 1 and has a value, it will be overwritten by the copy operation.
If the property referenced by the target Business Object and the associated target property path has a cardinality of N, the copy operation will result in the copied Business Object being added to the list.
The source Business Object cannot be a Business Graph.
The source Business Object's type must match the type of the property referenced by the target Business Object and the associated target property path.
For example, if the source Business Object consisted of a Customer containing an Address, and the target Business Object consisted of a Company containing a Site containing an Address, the following represent valid ways to copy the source Business Object's address Business Object to the target:
BOCopy boCopy = (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");
boCopy.copyInto(addressSource, companyTarget, "site/address");
boCopy.copyInto(addressSource, siteTarget, "address");
D. copyIntoShallow
Syntax: void copyIntoShallow(commonj.sdo.DataObject sourceBusinessObject,
commonj.sdo.DataObject targetBusinessObject,
java.lang.String targetPropertyPath)
Deprecated. Instead call copy on the source and then set the copy into the destination.
Replacement code:
DataObject copyBO = boCopy.copyShallow(sourceBO);
targetBO.set(path, copyBO);
End of replacement code.
Creates a shallow copy of the source Business Object into the property referenced by the combination of the target Business Object and the target property path parameters.
If the property referenced by the target Business Object and the target property path has a cardinality of 1 and has a value, it will be overwritten by the copy operation.
If the property referenced by the target Business Object and the target property path has a cardinality of N, the copy operation will result in the copied Business Object being added to the list.
The source Business Object cannot be a Business Graph.
The source Business Object's type must match the type of the property referenced by the target Business Object and the associated property path.
For example, if the source Business Object consisted of a Customer containing an Address, and the target Business Object consisted of a Company containing a Site containing an Address, the following represent valid ways to copy the source Business Object's address Business Object to the target:
BOCopy boCopy = (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");
boCopy.copyIntoShallow(addressSource, companyTarget, "site/address");
boCopy.copyIntoShallow(addressSource, siteTarget, "address");
E. copyPropertyInto
Syntax: void copyPropertyInto(commonj.sdo.DataObject sourceBusinessObject,
java.lang.String sourcePropertyPath,
commonj.sdo.DataObject targetBusinessObject,
java.lang.String targetPropertyPath)
Deprecated. Instead get the property on the source and set on the destination.
Replacement code:
Object value = sourceBO.get(sourcePath);
targetBO.set(targetPath, value);
End of replacement code.
You may want to special case check for Date type and make a copy of the Date before setting into the destination. Otherwise the same Date object will be in both, and changing one will change the other. The same occurs if it is a List, and the contents of the List are Date objects.
Creates a copy of the simple type property referenced by the source Business Object combined with the source property path into the property referenced by the target Business Object combined with the target property path.
If the simple type property referenced by the target Business Object combined with the target property path has a cardinality of 1 and has a value, it will be overwritten by the copy operation.
If the simple type property referenced by the target Business Object combined with the target property path has a cardinality of N, the copy operation will result in the copied simple type being added to the list.
The property to be copied must be a simple type, and it must have the same type as the property it is being copied into.
For example, if the source Business Object consisted of a Customer containing an Address that contained a street property, and the target Business Object consisted of a Company containing a Site containing an Address that contained a street, the following represent valid ways to copy the street property from the source to the target:
BOCopy boCopy = (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");
boCopy.copyPropertyInto(customer, "address/street", company, "site/address/street");
boCopy.copyPropertyInto(address, "street", site, "address/street");
boCopy.copyPropertyInto(addressSource, "street", addressTarget, "street");
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.