IDfCollections, Part V

In this final post of the IDfCollection series, I offer an alternative to the IDfCollection object, the dmRecordSet. The dmRecordSet is an object I created to extend the capabilities of the IDfCollection and overcome many of the limitations I have been discussing here. For example, the dmRecordSet allows you to:

  • move forward, backward or randomly through the record set;
  • reset the record set to the beginning or the end to be re-processed;
  • add rows to the set;
  • determine the number of rows in the set;
  • determine if a record set is empty or not; and
  • retrieve column definitions.

The following code provides some examples of how easy it is to use the dmRecordSet object.

Instantiate a dmRecordSet:

    IDfCollection col = null;
    String dql = "select r_object_id, object_name, "
           + "r_creation_date, a_content_type, r_full_content_size, a_is_template "
           + "from dm_document where folder('/Temp',descend)";
    IDfQuery q = new DfQuery();
    IDfTypedObject tObj = null;

    q.setDQL(dql);
    col = q.execute(session, DfQuery.DF_READ_QUERY);

    // get record set
    dmRecordSet dmRS = new dmRecordSet(col);

Test for empty set and count rows:

    System.out.println("Record count = " + dmRS.getRowCount());
    if (dmRS.isEmpty()) {
       System.out.println("dmRecordSet is empty");
    } else {
       System.out.println("dmRecordSet is NOT empty");
    }

Process record set:

    while (dmRS.hasNext()) {
       tObj = dmRS.next();
       System.out.print(tObj.getString("r_object_id") + "\t");
       System.out.println(tObj.getString("object_name");
    }

Move to end and process set backwards:

    tObj = dmRS.last();
    while (dmRS.hasPrevious()) {
        tObj = dmRS.previous();
        System.out.print(tObj.getString("r_object_id") + "\t");
        System.out.println(tObj.getString("object_name");
    }

The class, source code and Javadoc for the dmRecordSet can be downloaded here.

I hope you have enjoyed this series on the IDfCollection object, one of the most commonly used but least functional objects in the DFC.  As always, I appreciate your comments and feedback.

Advertisements

About Scott
I have been implementing Documentum solutions since 1997. In 2005, I published a book about developing Documentum solutions for the Documentum Desktop Client (ISBN 0595339689). In 2010, I began this blog as a record of interesting and (hopefully) helpful bits of information related to Documentum, and as a creative outlet.

2 Responses to IDfCollections, Part V

  1. Mauricio O. says:

    I am entering the world of Documentum by maintaining a solution. I found your posts very useful and practical. have been helpful.

    Thank you very much for the work that has been taken to make such wonderful and useful explanation.

    Regards,

    Like

  2. Pingback: New DQL Helper Library | dm_misc: Miscellaneous Documentum Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: