Creating Objects and Capturing Their IDs


As discussed earlier, creating objects using the BusinessObjects Enterprise SDK requires first instantiating an object factory called the plugin manager. In programming, a factory provides users a place for instantiating several types of objects. The IPluginMgr factory uses a method named getPluginInfo that takes the object's internal program ID identifier type. This is the PROG_ID property found in every object.

As noted earlier, objects may be created, but not submitted, individually to the InfoStore. An InfoObject collection must be created first and then new objects can be added to it. The ID of the object is available immediately after it is added to the collection using the standard getID() accessor method. Most objects require setting their title (name) and parent object identifier. Some, such as users and groups, do not. Please consult the documentation before creating new document typesmany require implementing interfaces that are beyond the scope of this book. Listing 30.5 shows how to create a new folder object using the PluginMgr and capture its unique identifier.

Listing 30.5. Creating a Folder

//get parent folder ID using lookup function in BOEUtil class found on //http://www.usingcrystal.com int PARENT_ID=BOEUtil.getObjectByName("Report Samples",iStore).getID(); //instantiate plugin manager factory IPluginMgr pluginMgr = iStore.getPluginMgr(); //choose folder plugin by its progID IPluginInfo folderPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.Folder"); //provision a new infoobject collection IInfoObjects newInfoObjects = iStore.newInfoObjectCollection(); //add an empty infoobject to the collection IInfoObject infoObject = newInfoObjects.add(folderPlugin); //get the object's numeric ID int newObjectID=infoObject.getID(); //set required properties infoObject.setTitle(FOLDER_TITLE); infoObject.setDescription(FOLDER_DESCRIPTION); infoObject.setParentID(PARENT_ID); //commit collection iStore.commit(newInfoObjects); //print out all properties for debuging System.out.println(BOEUtil.infoObjectToString(infoObject));




Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net