Friday, November 21, 2008

Java class to print the name of all the installed workflows?

String user1="USER_NAME";
String pwd1="USER_PASSWORD";
IDfSessionManager sMgr=null;
IDfSession session =null;
try
{
IDfClientX clientx = new DfClientX();
IDfClient client = clientx.getLocalClient();
//create a Session Manager object
sMgr = client.newSessionManager();
//create an IDfLoginInfo object named loginInfoObj
IDfLoginInfo loginInfoObj = clientx.getLoginInfo();
loginInfoObj.setUser(user1);
loginInfoObj.setPassword(pwd1);
//bind the Session Manager to the login info
sMgr.setIdentity("temprepo", loginInfoObj);
//could also set identity for more than one Docbases:
session = sMgr.getSession("temprepo");
// Get a list of all installed workflows!
System.out.println( "The following workflows are ready to run:-" );
IDfCollection Workflows = session.getRunnableProcesses("");
int workflowcount=0;
while ( Workflows.next() )
{
IDfTypedObject Next = Workflows.getTypedObject();
// The following chunk of code has to de with
// obtaining the attributes of the
// IDfTypedObject we got back!
java.util.Enumeration e = Next.enumAttrs();
while ( e.hasMoreElements() )
{
IDfAttr NextAttr = (IDfAttr)e.nextElement();
// System.out.print( NextAttr.getName() + " = " );
int AttrCount = 0;
if ( NextAttr.isRepeating())AttrCount = Next.getValueCount( NextAttr.getName() );
else AttrCount = 1;
for (int i=0; i {
// Get the next value!
IDfValue NextAttrValue = Next.getRepeatingValue( NextAttr.getName(), i );

System.out.print( NextAttrValue);workflowcount++;
System.out.println();
}
}

}

}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
if(sMgr!=null&&session!=null)
sMgr.release(session);
}