Skip to main content

skip to main content

developerWorks  >  Information Management  >

Demystifying the use of items and parts in DB2 Content Manager

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

Michael Schwartz (miss@us.ibm.com), Senior Software Engineer, IBM

09 Feb 2006

Get a clear explanation of the various content retrieval options in DB2® Content Manager and when to use them, including DK_CM_CONTENT_ATTRONLY, DK_CM_CONTENT_IDONLY, DK_CM_CONTENT_ITEMTREE, and more. Benefit from examples of the most appropriate content retrieval option in DB2 Content Manager for a given situation.

Introduction

This article explains the various content retrieval options you can use and when to use each one based upon my experience of working with DB2 Content Manager, Version 8. This article first provides a listing of all the content retrieval options with a description of each option, then further explains when to use each option. There are a lot of choices, and sometimes a content retrieval option is chosen that provides you with more information than you need. In this case, you would want to know which content retrieval option provides the least amount of information that would satisfy your retrieval request. Also, if you are considering building an application that performs well, you need to know which options provide the best performance for your needs.

Content retrieval options

Table 1 provides a listing of the various content retrieval options with a description of each option:


Table 1. Content retrieval options
Content retrieval optionDescription
DK_CM_CONTENT_NOContents of the Resource object is not retrieved. You do get access to the DKPARTS attribute.
DK_CM_CONTENT_ATTRONLYThe attributes of an object are retrieved only. You do not get access to the DKPARTS attribute.
DK_CM_CONTENT_IDONLYThe persistent ID (PID) for an object is retrieved only. You do not get access to the DKPARTS attribute.
DK_CM_CHECKOUTCheckout an item during a retrieval.
DK_CM_CONTENT_CHILDRENRetrieve the children of the current DDO. You do not get access to the DKPARTS attribute.
DK_CM_CONTENT_ITEMTREE_NO_LINKSRetrieve the whole item tree hierarchy, excluding links. You do get access to the DKPARTS attribute.
DK_CM_CONTENT_ONELEVELRetrieves the attributes of the item plus the PIDs of the immediate children. You do not get access to the DKPARTS attribute.
DK_CM_CONTENT_ITEMTREERetrieve the whole item tree hierarchy, including links. You do get access to the DKPARTS attribute.
DK_CM_VERSION_LATESTRetrieve the latest version of an item. You do get access to the DKPARTS attribute.
DK_CM_CONTENT_YESRetrieve the contents of the Resource object. You do get access to the DKPARTS attribute.
DK_CM_CONTENT_ONLYRetrieve the contents of the Resource object. This can only be used after using either DK_CM_CONTENT_NO or DK_CM_CONTENT_YES. You do get access to the DKPARTS attribute.
DK_CM_CONTENT_LINKS_OUTBOUNDRetrieve outbound links for the item. You do not get access to the DKPARTS attribute.
DK_CM_CONTENT_LINKS_INBOUNDRetrieve inbound links for the item. You do not get access to the DKPARTS attribute.

If you are looking for the greatest possible performance, use either DK_CM_CONTENT_IDONLY or DK_CM_CONTENT_ATTRONLY when doing a retrieve. Listing 1 shows you how to do so:


Listing 1. Code snippet to show how to use DK_CM_CONTENT_IDONLY or DK_CM_CONTENT_ATTRONLY
				
/* Specify Search / Query Options */
DKNVPair options[] = new DKNVPair[3];
options[0] = new DKNVPair(DKConstant.DK_CM_PARM_MAX_RESULTS, maxresults);
/* options[1] = new DKNVPair(DKConstant.DK_CM_PARM_RETRIEVE,
                             new Integer(DKConstant.DK_CM_CONTENT_ATTRONLY)); */
options[1] = new DKNVPair(DKConstant.DK_CM_PARM_RETRIEVE,
                          new Integer(DKConstant.DK_CM_CONTENT_IDONLY));
options[2] = new DKNVPair(DKConstant.DK_CM_PARM_END, null);
/* Execute the query */
cursor = dsICM.execute(query, DKConstantICM.DK_CM_XQPE_QL_TYPE, options);

The above snippet of Java™ code sets up a query to retrieve the PID of an item. The commented option would retrieve all the attributes that belong to an item. These two types of retrievals are the quickest, as no additional data structures have to be built. Also, once you have a PID, you can use it with the retrieve method of a DDO object to obtain the DKPARTS attribute if you need to work with parts belonging to an item.

If you are building a back-end program that would augment parts belonging to an item, first retrieve the PIDs of the items that satisfy the query. Then in a loop, create a DDO based on a PID and specify that you want to retrieve the DKPARTS attribute associated with an item by using DK_CM_CONTENT_NO, DK_CM_CONTENT_YES, DK_CM_CONTENT_ITEMTREE_NOLINKS or DK_CM_CONTENT_ITEMTREE. I have listed these options in the order of the quickest to the slowest, based upon my experience with DB2 Content Manager.

If you are building a graphical user interface (GUI), use DK_CM_CONTENT_ATTRONLY or DK_CM_CONTENT_ONELEVEL depending upon whether you want to make it clear which items have children and which ones do not. When looking at the parts belonging to an item, use DK_CM_CONTENT_NO, DK_CM_CONTENT_YES, DK_CM_CONTENT_ITEMTREE_NOLINKS or DK_CM_CONTENT_ITEMTREE. I have listed these options in the order of the quickest to the slowest based upon my experience with DB2 Content Manager.

Generally you want to perform retrievals that give you what you need and no more than this. This enables the retrievals to be as quick as possible. An item tree is a heavyweight object that takes time to build, and it is a structure you have to use an XML parser on. You'll be better off if you avoid using an item tree in your code. Also, you should save as many objects as you can so you do not have to execute queries constantly.

If you plan on working with an object, then you first have to check it out using the option DK_CM_CHECKOUT. If you want to work with the latest version, then use the option DK_CM_VERSION_LATEST. If you want to work with the children of an item, then use the option DK_CM_CONTENT_CHILDREN.

When dealing with links, you either want the inbound or outbound links or both. Use DK_CM_CONTENT_LINKS_INBOUND, DK_CM_CONTENT_LINKS_OUTBOUND or DK_CM_CONTENT_LINKS_INBOUND | DK_CM_CONTENT_LINKS_OUTBOUND. This helps to understand the topology of the data structure that is involved.

Summary

In this article the various content retrieval options have been explained. When building a back-end program, it is best to first retrieve the PIDs or only the attributes of an item. Then use the retrieve method of the DDO to obtain the contents and the DKPARTS attribute. When building a GUI, it is best to first retrieve only the attributes of an item or attributes of an item and the first level of children that an item has. This depends on whether you want to know if an item has children or not. Then you would use the retrieve method of the DDO to obtain the contents and the DKPARTS attribute. It is best to avoid using an item tree unless there is a need for it.



Resources

Learn

Get products and technologies
  • Build your next development project with IBM trial software, available for download directly from developerWorks.


Discuss


About the author

Michael S. Schwartz has a Ph.D. in Mathematics. He is a Senior Software Engineer dealing in databases, WebSphere, and Content Management. DB2, Content Management, and Records Management are some of the areas he has written papers on.




Rate this page


Please take a moment to complete this form to help us better serve you.



 


 


Not
useful
Extremely
useful
 


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!



Back to top


IBM and DB2 are registered trademarks of IBM in the United States and other countries. Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others. Other company, product, or service names may be trademarks or service marks of others.