Monday, June 1, 2009

Intralink Scripting: Commonspace Folder Info - Part 3

In Part 1, I discussed how to use the ILFolderTreeModel class to recursively descend through your Commonspace folders to generate a folder list. In Part 2, I discussed how to use CSFolderObjectInfo to perform actions and obtain information on your folders. Now I'm going to discuss yet another data model class to get even more extensive information from your folders.

Intralink classes that extend ILTableModel are the core data presentation classes of the Intralink client. While the ObjectInfo classes represent a chunk of metadata for a specific object, the ILTabelModel presents the data model that is actually displayed in the GUI. Interrogating these classes lets you get data exactly as you would expect to see it in Intralink.

Two folder related data presentation classes that I'll now discuss are ILFolderAuthTableModel and ILPromoteDemoteTableModel. As you might expect from the name, ILFolderAuthTableModel represents the data presentation model of folder authorizations, while ILPromoteDemoteTableModel represents folder release procedures.

To utilize these classes, we need an ILAppObject representation of the folder. The static method getObjectByKey() of the ObjectInfo class allows us to create this object. Here is an example of instantiating an ILFolderAuthTableModel object:

    String folderName = "Root Folder/ProjectX";
ILAppObject fol_ao = ObjectInfo.getObjectByKey(ObjectInfo.tFolder, folderName);
ILFolderAuthTableModel fa_tm = new ILFolderAuthTableModel(false, fol_ao);
 

The table of data contained in the ILTableModel based object can be accessed with generic methods and other methods specific to the data type. Examples of generic methods include getRowCount(), getColumnCount(), getColumnName(), and getValueAt().

Example: Reporting Authorizations and Release Procedures

This example further expands upon the code in Part 2, by adding the output of folder authorizations, release level authorizations, and release procedures associated with each folder.

Just as in the GUI, the example shows output only if something was explicitly set for that folder. If a folder authorizations was set only in a parent folder, that authorization will not appear in the output for subfolders. The same applies to release procedures.

    CSFolderObjectInfo fol_oi = null;
ILAppObject fol_ao = null;
ILFolderAuthTableModel fa_tm = null;
ILPromoteDemoteTableModel pd_tm = null;

for (int i=0; i<folders.size(); i++) {

String folderName = folders.get(i).toString();
System.out.println( " " + (i+1) + ": " + folderName );

fol_oi = (CSFolderObjectInfo)ObjectInfo.createByKey( ObjectInfo.tFolder, folderName );
fol_ao = ObjectInfo.getObjectByKey( ObjectInfo.tFolder, folderName);

System.out.println( " " + "Release Scheme: " + fol_oi.getReleaseScheme() );
System.out.println( " " + "File Space: " + fol_oi.getFilespace() );

fa_tm = new ILFolderAuthTableModel(false, fol_ao);
System.out.println( " " + "Authorizations: ");

if (fa_tm.getRowCount() > 0) {

// output column info
for (int col=0; col<fa_tm.getColumnCount(); col++) {
String colName = fa_tm.getColumnName(col);
if (col == 0) {
System.out.print( " " + " " + colName );
}
else {
System.out.print( " / " + colName );
}
}
System.out.println();

// output row info
for (int row=0; row<fa_tm.getRowCount(); row++) {
for (int col=0; col<fa_tm.getColumnCount(); col++) {
String val = fa_tm.getValueAt(row,col).toString();
if (col == 0) {
System.out.print( " " + " " + val );
}
else {
System.out.print( " / " + val );
}
}
System.out.println();
}
}
else {
System.out.println( " " + " None" );
}

pd_tm = new ILPromoteDemoteTableModel(fol_ao);
System.out.println( " " + "Release Procedures: ");

if (pd_tm.getRowCount() > 0) {

// output column info
for (int col=0; col<pd_tm.getColumnCount(); col++) {
String colName = pd_tm.getColumnName(col);
if (col == 0) {
System.out.print( " " + " " + colName );
}
else {
System.out.print( " / " + colName );
}
}
System.out.println();

// output row info
for (int row=0; row<pd_tm.getRowCount(); row++) {
String rellevel = pd_tm.getValueAt(row,pd_tm.RELLEVEL_COLUMN).toString();
String promote_rp = pd_tm.getValueAt(row,pd_tm.PROMOTE_COLUMN).toString();
String demote_rp = pd_tm.getValueAt(row,pd_tm.DEMOTE_COLUMN).toString();
System.out.println( " " + " " + rellevel + " / " + promote_rp + " / " + demote_rp );
}
}
else {
System.out.println( " " + " None" );
}


pd_tm = null;
fa_tm = null;

fol_oi = null;
fol_ao = null;

System.out.println();
System.out.flush();
}
 

The output should look something like this:

  1: Root Folder/Project X
Release Scheme: ReleaseScheme-ProjectX
File Space: Filespace_ProjectX
Authorizations:
Name / Folder Role / WIP / Detail / Prototype / Manufacturing / Obsolete
*Admin / FolAdmin / Admin / Admin / Admin / Admin / Admin
*Engr / FolEngr / Engr / Engr / Engr / Engr / Engr
*Mgr / FolMgr / Mgr / Mgr / Mgr / Mgr / Mgr
*View / FolView / View / View / View / View / View
Release Procedures:
Name / Release Procedure Promote To / Release Procedure Demote From
WIP / /
Detail / /
Prototype / ProjectX_Mgr / ProjectX_Mgr
Manufacturing / ProjectX_Mgr / ProjectX_Mgr
Obsolete / /
 

As you can see, you can extract very specific information from Intralink quite easily with Java. This information would be very difficult, if not impossible, to extract using the GUI itself. A little bit of Intralink Scripting can often save you lots of time.


Need a program for data mining your Intralink metadata? Migrating from Intralink 3.x to PDM.Link or TeamCenter and need to extract metadata quickly? Contact me at MarcMettes@InversionConsulting.com to get an inexpensive application right now.

No comments: