Tuesday, March 18, 2008

Using ObjectInfo and its Subclasses in Intralink Scripting

Data can be extracted from Intralink with Intralink Scripting in a number of ways. The getTableCellValue() method can be used to pull data from a displayed table or form, but sometimes this is just not enough.

For example, let's say you want to know, for certain Commonspace objects, the file name in the file vault. This can be accomplished in several ways. You can use Oracle SQL queries, but this requires administrative access to Oracle on the server, and we need something simpler.

Another option is to check out the files to a Workspace, then examine the contents of the 'File Path' column. This is easier than SQL, but can be a time consuming task, especially if data is needed on many objects.

It turns out that there's a simple and direct way to access the information without SQL and without checkouts. The Java code that provides the core of the Intralink client provides powerful classes and methods that can be used to tap directly into Intralink. A little bit of Java Reflection tells us all about it, including constructors, methods, and available fields.

One hierachy of classes to do this is the ObjectInfo class and subclasses. These provide very extensive information about objects, in Commonspace and Workspaces, without needing to access displayed fields in the Intralink GUI.

Here is a list of most 'ObjectInfo' derived classes:

com.ptc.intralink.ila.AdmRelLevelObjectInfo
com.ptc.intralink.ila.AdmRelSchemeObjectInfo
com.ptc.intralink.ila.AdmRoleObjectInfo
com.ptc.intralink.ila.AdmUserGroupObjectInfo
com.ptc.intralink.ila.AdmUserObjectInfo
com.ptc.intralink.ila.ApprovalSchemeObjectInfo
com.ptc.intralink.ila.AttrClassObjectInfo
com.ptc.intralink.ila.AttrDefObjectInfo
com.ptc.intralink.ila.CSBaselineObjectInfo
com.ptc.intralink.ila.CSFolderObjectInfo
com.ptc.intralink.ila.CSObjectInfo
com.ptc.intralink.ila.CSPIObjectInfo
com.ptc.intralink.ila.CSPIVObjectInfo
com.ptc.intralink.ila.CSSubmFormObjectInfo
com.ptc.intralink.ila.LILObjectInfo
com.ptc.intralink.ila.LOObjectInfo
com.ptc.intralink.ila.LOVObjectInfo
com.ptc.intralink.ila.ObjectInfo
com.ptc.intralink.ila.PIVDependencyObjectInfo
com.ptc.intralink.ila.RTPObjectInfo
com.ptc.intralink.ila.WSDependencyObjectInfo
com.ptc.intralink.ila.WSObjectInfo
com.ptc.intralink.ila.WSPIObjectInfo

Here is some code that utilizes parts of ObjectInfo and CSPIVObjectInfo to get the file path for selected Commonspace objects:

IL.selectAll( "PIV" );
String[] o = IL.getSelectedObjects( "PIV" );
IL.deselectAll( "PIV" );

for (int i=0; i<o.length; i++) {
CSPIVObjectInfo oi = (CSPIVObjectInfo)ObjectInfo.createByKey( ObjectInfo.tPIV, o[i] );
String filePath = oi.getFilePath();
System.out.println( o[i] + "\t" + filePath );
}

The tricky part was figuring out how to instantiate the ObjectInfo objects, but with a little trial and error, and the help of Java Reflection output, it doesn't take to long to figure it out.

No comments: