BOCopy

This interface facilitates copying a graph of business objects or a business graph that contains a graph of business objects.

Purpose

There are two forms of this interface. The first is used with a graph of a business object or a business graph containing a graph of business objects. The only requirement is that it is a service data object. The other is used when a subset of a source business graph is being copied into a target business graph.

The business object framework defines two different forms of copy. The first is a straightforward copy by the value, with a deep and a shallow variant. This means that you can either copy only the top level, or also copy the children. This copy mechanism can be applied to both a graph of business objects or a business graph containing a graph of business objects. Its implementation is unrelated to the shape of the source object.

The second form is intended for a use model where a subset of a source business graph is being copied into a target business graph. This form not only copies the source business object (and its descendants if it is the deep variant), but also copies the Change, Event, and Verb Header information that is pertinent to the business object(s) being copied into the target business graph.

Example

This is an example of the copy/Shallow form.

BOFactory factoryService =
    (BOFactory) new
ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOCopy copyService =
    (BOCopy) new
ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");

// Use the Factory Create model for the top level object.
DataObject productCategoryBG =
  factoryService.create("http://www.scm.com/ProductCategoryTypes/ProductCategoryBG",
                           "ProductCategoryBG");

// Use the Containment Create model on the contained objects.
DataObject productCategory = productCategoryBG.createDataObject("productCategory");
DataObject product = productCategory.createDataObject("product");

// Copy a business graph (deep).
DataObject newProductCategoryBG = copyService.copy(productCategoryBG);

// Copy a business object (deep).
DataObject newProductCategory = copyService.copy(productCategory);

// Copy a business object (shallow).
DataObject newProductCategory2 = copyService.copyShallow(productCategory);

This is an example of the copyIntro form.

BOFactory factoryService =
    (BOFactory) new
ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOCopy copyService =
    (BOCopy) new
ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");

// Use the Factory Create model for the top level object.
DataObject productCategoryBG =
  factoryService.create("http://www.scm.com/ProductCategoryTypes/ProductCategoryBG",
                          "ProductCategoryBG");

// Use the Containment Create model on the contained objects.
DataObject productCategory = productCategoryBG.createDataObject("productCategory");
DataObject product = productCategory.createDataObject("product");

// Copy a child business object with a business graph context,
// into a new business graph.
DataObject productBG =
  factoryService.create("http://www.scm.com/ProductTypes/ProductBG",
                          "ProductBG");
copyService.copyInto(product, productBG, "product");

This is an example of the copyIntro Complex form.

BOFactory factoryService =
  (BOFactory) new 
ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
BOCopy copyService =
  (BOCopy) new ServiceManager().locateService("com/ibm/websphere/bo/BOCopy");

// If you want to perform a complex copy from a source business graph
// to a target business graph and maintain context where:
//
// - The source business graph contains:
//   - ProductCategoryBG productCategoryBG
//   - ProductCategory productCategory0 (parent productCategoryBG)
//   - ProductCategory productCategory1 (parent productCategory0)
//   - ProductCategory productCategory2 (parent productCategory0)
//   - Product product1 (parent productCategory1)
//   - Product product2 (parent productCategory2)
//
// - The target business graph contains:
//   - ProductInventoryBG productInventoryBG
//   - ProductInventory productInventory (parent productInventoryBG)
//     - Property oldProduct (initially empty)
//     - Property newProduct (initially empty)
//
// The following code copies product1 from the source business graph
// to the target business graph's ProductInventory business object's
// oldProduct property, and product2 from the source business graph
// to the target business graph's ProductInventory business object's
// newProduct property.

// Create the source business graph and its graph of business objects.
DataObject productCategoryBG =
  factoryService.create("http://www.scm.com/ProductCategoryTypes/ProductCategoryBG",
                          "ProductCategoryBG");
DataObject productCategory0 = productCategoryBG.createDataObject("productCategory");
DataObject productCategory1 = productCategory0.createDataObject("productCategory");
DataObject productCategory2 = productCategory0.createDataObject("productCategory");
DataObject product1 = productCategory1.createDataObject("product");
DataObject product2 = productCategory2.createDataObject("product");

// Create the target business graph.
DataObject productInventoryBG =

factoryService.create("http://www.scm.com/ProductCategoryTypes/ProductInventoryBG",
                       "ProductInventoryBG");
DataObject productInventory =
    productInventoryBG.createDataObject("productInventory");

// Copy product1 and product2 from the source business
// graph, with their associated ChangeSummary/EventSummary context, into
// the target business graph's ProductInventory business object's oldProduct and
// newProduct properties. Use two mechanisms to demonstrate how path can be used.
copyService.copyInto(product1, productInventory, "oldProduct");
DataObject oldProduct = productInventory.getDataObject("oldProduct");
oldProduct.delete();
copyService.copyInto(product1, productInventoryBG, "productInventory/oldProduct");

Parent topic: Programming interfaces

Related reference
BOChangeSummary
BODataObject
BOEquality
BOEventSummary
BOFactory
BOType
BOTypeMetadata
BOXMLDocument
BOXMLSerializer

Related information
Interface BOCopy APIs


Terms of use |

Last updated: Tue Sep 20 03:22:36 2005

Copyright IBM Corporation 2005.
This information center is powered by Eclipse technology (http://www.eclipse.org)