Home > DOCUMENTUM > Handling Virtual Documents using DFC

Handling Virtual Documents using DFC

April 21, 2010

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();
}

%d bloggers like this: