Archive

Archive for April, 2010

Business Objects Framework in Documentum

April 30, 2010 Comments off

Documentum Business Objects Framework (DBOF) is a new framework for developing and executing reusable business object components. The framework is built into DFC and
accessible from applications written using DFC.

DBOF provides a way for developers to hook their own logic into normal DFC procedures by extending DFC classes. DBOF lives wherever DFC lives, either on the Content Server or Application Server, or on any of the other clients.

There are two types of Documentum business objects type based business objects (TBO) and service based business objects (SBO).

Type Based Objects (TBO):

Type based objects are implemented as classes that extend basic persistent DFC types such as DfDocument, DfSysObject, DfPersistentObject, DfFolder, etc. They allow you to encapsulate business logic that is specific to a particular Docbase object type. In this case, DFC dynamically constructs an instance of the new subclass at runtime. Even when accessed by programs unaware of the new subclass.

There are two main reasons for creating a TBO:

1) To provide a new behavior for new or existing custom object types. For instance, a developer may decide to add getter and setter methods for object specific attributes or add new methods like adding a Product to a Catalog TBO.

2) Customizing low-level operations to enforce data validations, referential integrity and object specific business rules. For instance, a developer may decide to override the save() and checkinEx () methods to be able to validate data before saving them in the persistent storage.

In a TBO, typically the business rules and any other logic is implemented in the methods save(), checkout(), checkin(), saveLock(). Because checkout () and checkin () methods are final, the DFC system has provided methods checkinEx(…) and checkoutEx(…) methods for such operations.

Service Based Objects (SBO):

Service based objects are not tied to a specific Documentum object type. They are generalized objects that provide a specific service that may operateon different Documentum object types or other business objects.

Assigning ACLs and Releasing Session in Docbase

April 28, 2010 Comments off

We can assign Permission sets or as they call ACLs to an object or document using API , DQL ,DAB , DA and DFC means inside docbase.

Assign a ACL to a document:

public void assignACL() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name=’UniqueDocName’ “);
IDfACL dfACL = (IDfACL) idfSession.getObjectByQualification(“dm_acl where
object_name=’ACL NAME’ “);
sysObj.setACL(dfACL);
sysObj.save();
}

How to release a session in docbase using Session Manager ?

Releasing a session makes a session invalid. So if you get an object from a session and then release that session, the object you have is no longer valid.Couple of important points to remember while trying to release a session :

1. Always release your sessions (in a finally)
2. Don’t use objects obtained from a session which has been released

Below i am trying to release a session using session Manager:

public void releaseSession() throws Exception {
sessMgr.release(idfSession);
}

Handling LifeCycles in DCTM using DFC

April 27, 2010 Comments off

We know how Documentum helps attach a LifeCycle to a document and How to handle its states viz.How to Promote & Demote a Lifecycle state .Let’s try to bring in the same using DFC Concepts.

Attach a LifeCycle to a document in docbase:

public void attachLifeCycle() throws Exception{
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name= ‘UniqueDocName’ “);
IDfSysObject procObj = (IDfSysObject)
idfSession.getObjectByQualification(“dm_policy where object_name=
‘LifeCycle Name’ “);
sysObj.attachPolicy(procObj.getObjectId(), “Author”,””);
}

Promote a LifeCycle state of a document inside a docbase:

public void promoteLifeCycle (String State) throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name = ‘UniqueDocName’ “);
sysObj.promote(State,false,false);
}

Demote a LifeCycle state of a document inside a docbase:

public void demoteLifeCycle(String state) throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name = ‘UniqueDocName’ “);
sysObj.demote(state,false);
}

How to suspend or resume a LifeCycle of a document in Documentum ?

Expire a LifeCycle state of a document in a docbase:

public void expireLifeCycle (String state) throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name=’UniqueDocName’ “);
sysObj.suspend(state,false,false);
}

Resume a LifeCycle state of a document inside docbase:

public void resumeLifeCycle (String state) throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.
getObjectByQualification(“dm_document where
object_name=’UniqueDocName’ “);
sysObj.resume(state,false,false,false);
}

Your valuable comments matters , i will work on the same if any tuning to the above piece of snippets is required.

Thank You

Handling Workflows and Tasks in DCTM using DFC

April 26, 2010 Comments off

How can we Start workflows in a docbase using docbase right from getting the attachment document , getting the workflow template , creating a workbuilder to start a workflow ,getting the First Activity,getting the Package Name , Port and Package DocType ,Adding the attachment document to List ,Adding a Package to Workflow Builder and finally how do we view the tasks in INBOX ?

The tried out example below will give you the step by step procedure of starting a workflow in a docbase and viewing tasks in inbox in DCTM using DFC.

Starting workflow in a docbase:

public void startWorkflow() throws Exception {

IDfSysObject sysObj = (IDfSysObject) idfSession. getObjectByQualification(“dm_document where object_name=’Test-Document'”);

IDfProcess process = (IDfProcess) idfSession.getObjectByQualification (“dm_process where object_name=’temp_workflow'”);

IDfWorkflowBuilder builder = idfSession.newWorkflowBuilder(process.getObjectId());

IDfId wfId = builder.initWorkflow();

IDfList startActivityNames = builder.getStartActivityNames();

IDfList startActivities = builder.getStartActivityIds();

String activityName = startActivityNames.getString(0);

IDfId activityID = (IDfId) startActivities.get(0);

IDfActivity activity = (IDfActivity) idfSession.getObject(activityID);

int nPorts = activity.getPortCount();

String InputPortName = null;

String PkgType = null;

String PkgName = null;

for (int j=0; j<nPorts; j++) {

System.out.println( “Port Name: ” + activity.getPortName(j) + “, ” + “Port Type = ” + activity.getPortType(j) );

if (activity.getPortType(j).equals( “INPUT” ) ) {

InputPortName = activity.getPortName(j);

PkgType = activity.getPackageType(j);

PkgName = activity.getPackageName(j);

}
}

IDfList dfList = new DfList();

dfList.append(sysObj.getObjectId());

IDfId wfId2 = builder.runWorkflow();

builder.addPackage(activityName, InputPortName, PkgName, PkgType, null, false, dfList);

System.out.println(“Package added”);

}

Viewing task in inbox:

public void getInbox() throws Exception {

IDfCollection tasks = idfSession.getTasks(“temp”, DfSession.DF_TASKS, “name, date_sent, message “, “task_name”);
try {
while (tasks.next()) {
IDfWorkitem wi = (IDfWorkitem) idfSession.getObject
(tasks.getId(“item_id”));
IDfId queueItemId = wi.getQueueItemId();
IDfQueueItem qi = (IDfQueueItem) idfSession.getObject(queueItemId);
System.out.println(tasks.getString(“sent_by”) +” “+
tasks.getString(“task_name”)+” “+ tasks.getString(“date_sent”)+” “+ tasks.getString(“message”)+” “+ qi.getItemName());
IDfActivity dfActivity=wi.getActivity();
System.out.println(“\tActivity Information : “+dfActivity.getString(“object_name”));
IDfCollection packColl= null;
try {
packColl=wi.getPackages(“”);
while(packColl.next()) {
IDfSysObject sysObj=(IDfSysObject) idfSession.getObject (packColl.getId(“r_component_id”));
System.out.println(“\t Package Information: ” + sysObj.getString(“object_name”));
}

} finally {
if(packColl != null)
packColl.close();
}

// to finish a Task or Workitem
//finishTask(wi);
}

} finally {
if(tasks!=null) tasks.close();
}
}

Handling Virtual Documents using DFC

April 21, 2010 Comments off

Today’s post i will try to put in some useful examples to create and handle Virtual documents and etc in Documentum docbase using Documentum Foundation Classes.

1. Create a virtual document in docbase:

public void createVirtualDocument() throws Exception {
IDfSysObject pSysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 2/log4j.properties”);
IDfSysObject cSysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/trace.log”);
pSysObj.setIsVirtualDocument(true);
pSysObj.save();
IDfVirtualDocument vDoc = pSysObj.asVirtualDocument(“CURRENT”, false);
IDfVirtualDocumentNode pNode = vDoc.getRootNode();
pSysObj.checkout();
IDfVirtualDocumentNode nodeChild1 = vDoc.addNode(pNode, null,
cSysObj.getChronicleId(),”CURRENT”, false,
false);
pSysObj.checkin(false, “CURRENT”);
}

2. Export a virtual document from docbase:

public void exportVirtualDocument() throws Exception {
System.out.println(“exporting virtual document”);
IDfExportOperation expOpr = new DfExportOperation();
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 2/log4j.properties”);
if (sysObj.isVirtualDocument()) {
IDfVirtualDocument vdoc = sysObj.asVirtualDocument(“CURRENT”,
false);
IDfExportNode expNode = (IDfExportNode) expOpr.add(sysObj);
expOpr.setDestinationDirectory(expOpr.
getDefaultDestinationDirectory());
boolean flag = expOpr.execute();
}
}

3. View virtual document from docbase:

public void viewVirtualDocument() throws Exception {
IDfSysObject pSysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 2/log4j.properties”);
if (pSysObj.isVirtualDocument() ) {
System.out.println(“virtual document –> true”);
IDfVirtualDocument vDoc = pSysObj.asVirtualDocument(“CURRENT”, false);
IDfVirtualDocumentNode pNode = vDoc.getRootNode();
for ( int i=0;i<pNode.getChildCount();i++) {
IDfVirtualDocumentNode cNode = pNode.getChild(i);
System.out.println("Child Name " +cNode.getSelectedObject().
getObjectName());
}
}
}

4. Retrieve document from documentum using IDQL:

public void collection() throws Exception {
IDfQuery query = new DfQuery();
query.setDQL(“select * from dm_document where object_name=’New Document’
and any r_version_label like ‘CURRENT%'”);
IDfCollection coll = query.execute(idfSession, 0);
while (coll.next() ) {
IDfTypedObject typeObject = (IDfTypedObject) coll.getTypedObject();
System.out.println(“Object Name ” + typeObject.getString(“r_object_id”));
System.out.println(“creation date ” + typeObject.getString(“r_creation_date”));
}
if ( coll != null )
coll.close();
}

Handling Basic Operations in DCTM using DFC

April 20, 2010 Comments off

1.Check out a document from docbase:

public void checkoutDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (!sysObj.isCheckedOut()) // if it is not checked out
sysObj.checkout();
System.out.println(“is Check out ” + sysObj.isCheckedOut());
}

2.Check in a document to docbase:

public void checkinDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (sysObj.isCheckedOut()) { // if it is checked out
sysObj.checkin(false,”CURRENT”);
}
}

3.Delete a document from docbase:

public void deleteDocument() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/Test-Document”);
if (sysObj != null ) {
sysObj.destroyAllVersions(); // delete all versions
System.out.println(“object destroyed…..”);
}
}

4.Update document’s metadata\attributes in docbase:

public void updateAttributes() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/New Document”);
sysObj.setString(“object_name”, “New Document”);
sysObj.setString(“authors”, “author1”);
sysObj.setRepeatingString(“authors”,1,”author2″);
sysObj.save();
}

5.Retrieve document’s metadata\attributes from docbase:

public void getAttributes() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet
Name/Folder Level 1/New Document”);
if (sysObj != null ) {
System.out.println(“objectName ” + sysObj.getString(“object_name”));
//System.out.println(“authors ” + sysObj.getString(“authors”));
String authors = sysObj.getAllRepeatingStrings(“authors”, “,”);
ArrayList list = new ArrayList();
StringTokenizer st = new StringTokenizer(authors, “,”);
System.out.println(“length of st ” + st.countTokens());
while( st.hasMoreTokens()) {
list.add(st.nextElement());
}
System.out.println(“length ” + list.size());
for (int i=0;i<list.size();i++) {
System.out.println("Author["+i+"] " + list.get(i));
}
}
}

Documentum Foundation Classes Examples for Java-Contd.

April 19, 2010 Comments off

Today let us discuss few more examples on DFC.
1. Check out a document from docbase using IDfOperations:

public void checkoutDocument() throws Exception {
IDfCheckoutOperation checkoutOpr = new DfCheckoutOperation();
System.out.println(“Checkout Dir ” + checkoutOpr.getDefaultDestinationDirectory()); checkoutOper.setDestinationDirectory(checkoutOpr.getDefaultDestinationDirectory());
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath(“/Cabinet Name/Folder Level 2/ Test-Document”);
IDfCheckoutNode node = (IDfCheckoutNode) checkoutOpr.add(sysObj); boolean flag = checkoutOpr.execute();
}

2.Check in a document to docbase using IDfOperations:

public void checkinDocument() throws Exception {
IDfCheckinOperation checkinOpr = new DfCheckinOperation();
IDfCheckinNode node = (IDfCheckinNode) checkinOpr.add(sysObj);
System.out.println(“Flag —->” + checkinOpr.execute());
}

3.Making use of IAPI methods:

public void dmclAPI() throws Exception {
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByQualification (“dm_document where object_name=’Test-Document'”);
String objId = sysObj.getObjectId().getId();
String name = (String)idfSession.apiGet(“get”, objId + “,object_name”);
System.out.println(“Name :” + name); //idfSession.apiSet(“set”, objId +”,title”,”sample-doc”); idfSession.apiExec(“link”, objId +”,/Cabinet Name/Folder Level 2″);
System.out.println(“Linked ” + idfSession.apiExec(“save”, objId));
}

4.To import a document into docbase:

public void importDocument() throws Exception {
IDfSysObject sysObj= (IDfFolder) idfSession.getObjectByPath (“/Cabinet Name/Folder Level 2”); System.out.println(“Object ID” + sysObj.getObjectId());
IDfImportOperation importOpr = new DfImportOperation();
importOper.setSession(idfSession);
if (importOpr == null ) {
System.out.println(“operation object is null”);
return;
}
importOpr.setDestinationFolderId(sysObj.getObjectId());
importOpr.setVersionLabels(“imported using operation”);
IDfImportNode node = (IDfImportNode) importOpr.add (“C:\\Documentum\\config\\ Test-Document”);
node.setFormat(“pdf”);
boolean flag = importOpr.execute();
}

5.Cancelcheckout a document into docbase:

public void cancelCheckoutDocument() throws Exception {
IDfCancelCheckoutOperation cancelcheckoutOpr = new DfCancelCheckoutOperation();
IDfSysObject sysObj = (IDfSysObject) idfSession.getObjectByPath (“/Cabinet Name/Folder Level 2/ Test-Document”);
IDfCancelCheckoutNode node = (IDfCancelCheckoutNode) cancelcheckoutOpr.add (sysObj); boolean flag = cancelcheckoutOpr.execute();
}

Stay tuned preparing few more examples.

%d bloggers like this: