Friday, January 4, 2008

Queue Item Maintenance

Issue:
The recording of task events are tracked in tables, namely the dmi_queue_item table. These build up proportionally to the number of tasks executed. As time goes on and performance potentially slows down, these queues will need to be deleted.

Requirements:
Periodically delete old records from the dmi_queue_item table, but keep track of a document’s workflow history for a certain amount of time beyond the dmi_queue_item cleaning.

Solution:
The first thing to determine is whether the out-of-box dm_QueueMgt job can do what’s required. This job runs a method that can delete queue items older than a cutoff date. This is useful, however, we want to keep the workflow history of a document. This is also useful because this table keeps a record of many other events in the repository which need to be deleted on a scheduled basis. The solution was to create a custom table which holds the requirement queue items to maintain the workflow history of documents, and to create a new job and method to populate it before as part of queue management.

Solution Details:
First, create a custom table using DQL (Note: this table has the same columns as the dmi_queue_item table):

UNREGISTER TABLE wf_history_s
EXECUTE exec_sql WITH query='DROP TABLE wf_history_s'
EXECUTE exec_sql WITH query='CREATE TABLE wf_history_s
(
r_object_id VARCHAR2(32),
object_type VARCHAR2(32),
id_1 VARCHAR2(32),
string_5 VARCHAR2(200),
string_4 VARCHAR2(200),
string_3 VARCHAR2(200),
string_2 VARCHAR2(200),
string_1 VARCHAR2(200),
workflow_id VARCHAR2(32),
policy_id VARCHAR2(32),
registry_id VARCHAR2(32),
audit_signature VARCHAR2(255),
audited_obj_vstamp INTEGER,
user_name VARCHAR2(32),
time_stamp_utc DATE,
audit_version INTEGER,
chronicle_id VARCHAR2(32),
controlling_app VARCHAR2(32),
object_name VARCHAR2(255),
audited_obj_id VARCHAR2(32),
version_label VARCHAR2(32),
acl_domain VARCHAR2(32),
attribute_list_id VARCHAR2(32),
host_name VARCHAR2(128),
user_id VARCHAR2(32),
i_audited_obj_class INTEGER,
event_source VARCHAR2(64),
event_name VARCHAR2(64),
r_gen_source INTEGER,
owner_name VARCHAR2(32),
time_stamp DATE,
event_description VARCHAR2(64),
session_id VARCHAR2(32),
current_state VARCHAR2(64),
application_code VARCHAR2(64),
acl_name VARCHAR2(32),
attribute_list VARCHAR2(2000),
i_is_archived VARCHAR2(32),
id_5 VARCHAR2(32),
id_4 VARCHAR2(32),
id_3 VARCHAR2(32),
id_2 VARCHAR2(32)
)'

REGISTER TABLE dm_dbo.wf_history_s
(
r_object_id CHAR(32),
object_type CHAR(32),
id_1 CHAR(32),
string_5 CHAR(200),
string_4 CHAR(200),
string_3 CHAR(200),
string_2 CHAR(200),
string_1 CHAR(200),
workflow_id CHAR(32),
policy_id CHAR(32),
registry_id CHAR(32),
audit_signature CHAR(255),
audited_obj_vstamp INT,
user_name CHAR(32),
time_stamp_utc TIME,
audit_version INT,
chronicle_id CHAR(32),
controlling_app CHAR(32),
object_name CHAR(255),
audited_obj_id CHAR(32),
version_label CHAR(32),
acl_domain CHAR(32),
attribute_list_id CHAR(32),
host_name CHAR(128),
user_id CHAR(32),
i_audited_obj_class INT,
event_source CHAR(64),
event_name CHAR(64),
r_gen_source INT,
owner_name CHAR(32),
time_stamp TIME,
event_description CHAR(64),
session_id CHAR(32),
current_state CHAR(64),
application_code CHAR(64),
acl_name CHAR(32),
attribute_list CHAR(2000),
i_is_archived CHAR(32),
id_5 CHAR(32),
id_4 CHAR(32),
id_3 CHAR(32),
id_2 CHAR(32)
)

update dm_registered object
set owner_table_permit = 15,
set group_table_permit = 15,
set world_table_permit = 15
where table_name = 'wf_history_s'

Second, create a custom Documentum method to be executed by the custom queue management job. This class should have the following methods and logic:

a. Populate Workflow History Table according to criteria. Here’s an example dql:

"insert into dm_dbo.wf_history_s " +
"(r_object_id, event_name, time_stamp, user_name, audited_obj_id, string_4, workflow_id, string_3) " +
"SELECT '0000000000000000' as r_object_id, task_name as event_name, date_sent as time_stamp, sent_by as user_name, r_object_id as audited_obj_id, name as string_4 , router_id, task_state as string_3 " +
"FROM dmi_queue_item " +
"WHERE r_object_id not in (select audited_obj_id from dm_dbo.wf_history_s) " +
"AND router_id != '0000000000000000' " +
"AND date_sent < DATEADD(Day, -"+sCutOffDate+", date(today)) " +
"AND delete_flag = 1";

b. If the Workflow History Table gets populated successfully, delete the dmi_queue_item rows according to criteria. Here’s an example dql:

"DELETE dmi_queue_item objects " +
"WHERE router_id != '0000000000000000' " +
"AND date_sent < DATEADD(Day, -"+m_cutoff+", date(today)) " +
"AND delete_flag = 1";

c. Write the job report to the repository.

Third, create the custom queue management job.

Thursday, December 13, 2007

Documentum Workflow: Reporting History by Document

Issue:
Tracking workflow status by document from Webtop’s Properties/History tab.

Requirements:
Allow a user to select a document in Webtop and click on Properties/History to view the document’s workflow history.

Solution History:
Webtop: Out-of-box workflow functionality which requires running the dm_WFReporting job and auditing events.

Report: Properties/History
Location: Select Workflow task and go to Properties/History
You’ll get a list of the work activities, there date/time stamps and who performed it.

Report: Workflow Reporting
Location: Tools/Workflow/Workflow Reporting
Attributes: Workflow Name, Status, Active, Task Name, Performer, Supervisor
Edit Report:
User – select a user
Document – select a document by drilling down folders
Template – select a workflow template
Show overdue, all, running, or completed workflows

Report: Historical Report (Process or User)
Location: Tools/Workflow/Historical Report/Process or User
Form options:

  • Display statistics for business process running
  • From: To:
  • Include only process where these conditions are met
  • Process Template name contains: type in text
  • Or User contains: type in text
  • Workflow Supervisor is: select user
  • Duration: select operater and type in days, hours, minutes
  • Cost: select operator and type in number
  • Location is: select folder

WorkQueue Monitor
Location: Select Workflow task and go to Properties/History
Functionality: You’ll get a list of the work activities, there date/time stamps and who performed it.

Solution:
Create a custom Package_History table
Purpose: This is necessary because the link between the workflow instance and the package id (the content id) is lost after the workflow is complete. This provides the track record of workflow’s packages during the workflow activity and after the workflow is complete.

Create a custom Workflow_History table
Purpose: To keep track of workflow queue items. We decided to store all workflow related queue events in a custom table to assure that the historical information for the workflow activities would not be deleted by the queue management job.

Query the workflow history based on the following steps

  1. Look up the workflow instance ID from the custom package history table based on the Object ID.
  2. Select attributes from the custom workflow history table
  3. Union these results with a selection from the dmi_queue_item table

Present the User with the following information about the document’s workflow history
Date: Timestamp of action
Work Queue: Name of the work queue or activity
Performer: Name of the user who performance the task
Action: The event status of the activity

Changes to Webtop
Component changes
· Make a copy of the history_component.xml to the custom folder and extend for the original configuration file, and point the behavior to the new class
· Set “String_3” to true: true so it will show up on the jsp page.


Create a custom component behavior class
The main customization is with the query string method:

protected String getQuery(String strVisibleAttrs, ArgumentList args)
{
if(m_strSelectedVersionObjectId == null)
m_strSelectedVersionObjectId = m_strObjectId;
String strWhere = m_strQueryConditionFormat;
strWhere = StringUtil.replace(strWhere, "{r_object_id}", "'" +
m_strSelectedVersionObjectId + "'");
StringBuffer buf = new StringBuffer(128);
buf.append("SELECT ");
buf.append(strVisibleAttrs);
buf.append("'1' as dummy");
buf.append(" FROM dm_dbo.wf_history_s WHERE ");
buf.append(strWhere);
buf.append(" OR workflow_id in (select r_workflow_id ");
buf.append(" from dm_dbo.package_history ");
buf.append(" where r_component_id = '"+m_strObjectId+"' ) ");
buf.append(" UNION ");
buf.append(" SELECT sent_by as user_name, task_name as event_name,
task_state as string_3, date_sent as time_stamp, '1' as dummy ");
buf.append(" FROM dmi_queue_item");
buf.append(" WHERE router_id in ");
buf.append(" (select r_workflow_id ");
buf.append(" from dm_dbo.package_history ");
buf.append(" where r_component_id = '"+m_strObjectId+"' ) ");
buf.append(" ORDER BY 4 ASC");

System.out.println("Query: "+buf.toString());
return buf.toString();
}

Component Presentation Changes
The history.jsp file is copied and moved the custom folder in /custom/webcomponet/library/history

Friday, December 7, 2007

Documentum Workflow: Queue Management

Overview
In Workflows, each work item or task has to be managed, maintained and tracked. As workflows are executed and performed, there are certain aspects of managing these tasks that are not straight forward and are definitely not offered out-of-the-box with Webtop.

Management:

Issue:
Work queue tasks could be acquired then left unattended unless a scheduled job runs to determine whether the user who acquired the task is still using the system or has left for the day.

Solution History:

First Attempt:
The first fix was to customize the logout functionality of Webtop to set the work item (task) to the “putback” auto-activity. The “putback” auto-activity then gets the work item’s sequence number and subtracts 1 from it and sets the work item back to the previous activity.

First Attempt Issues:
This does not take into account user’s who X out of their browser without logging out. It also doesn’t scale.

Follow Up Attempt:
We decided to create a scheduled job which would execute a java method that “unacquired” the work items, like the “unassign” functionality in the Work Queue Monitor page on Webtop. This required some reverse engineering of the existing unassign class to figure which services and api’s were used and the objects and jars required. This also required looking at DA’s User Session functionality and bringing that in as well. Here are the components of this solution:

Documentum Objects
dm_job
dm_method

Java classes

Class: public class TimeoutPutBackMethod implements IDmMethod

Methods:

execute(Map params, OutputStream output)

- This is the main dm_method execution method which excepts parameters sent from the job and an output stream which ends up as a report written to the “Temp/Jobs// log files.

getAllActiveSessions(session, output)

- This method uses DfSessionCommand object to get all of the active sessions on the repository.
- This also queries the a_held_by (Username who acquired it) values of the work items to figure out which work items should be unassigned.

unAssignWorkflowTasks(IDfSession session, String UserName, String sDCTMDocbase, OutputStream output)

- Calls the getWQName method to lookup the work queue name based on the activity name.
- Calls UnassignQueuedTask.unassignTasks

getWQName(IDfSession session, String ActivityName)
- queries the dm_activity table looking for the performer (work queue name) based on the activity name.

Class: public class UnassignQueuedTask

Method:
unassignTasks(IDfSession m_session, String m_taskId, String m_queueName, String m_docbase, OutputStream output)

- This method constructs a work queue manager service and work queue object to unassign the work item.

Non-standard APIs used
import java.io.OutputStream;
Used for outputting strings to a job report file.
import com.documentum.services.workqueue.IWorkQueue;
This is used to construct a workqueue and unassign it
import com.documentum.services.workqueue.IWorkQueueMgmt;
This is used to construct a workqueue manager service
import com.documentum.mthdservlet.IDmMethod;
Used to implement this method and to be able to execute it as a dm_method object
import com.documentum.admin.commands.DfSessionCommand;
This is used to get all of the active sessions in the repository

Thursday, October 18, 2007

Fixing the Deprecated api exec for Lifecycles

A few months ago I came across a deprecated api that I was trying to use to uninstall a dm_policy or lifecycle. What I needed to do was uninstall the LC apply a new ACL to the LC object and install it. I searched EMC's dev discussions and found a few references to this, but no real solutions. I knew that the App Builder dealt with lifecycles, so I took a look at the DDS.jar files to see if there was something of interest. There was.

Here's the deprecate code I was trying to fix:

obj = (IDfSysObject)m_session.getObject(idObj);
m_objectId = idObj.toString();
// Uninstall this LifeCycle Object
m_session.apiExec("uninstall",m_objectId);
obj.setACLName(sAcl);
IDfACL idAclObj = (IDfACL)(m_session.getObject(getDocbaseObjectIDIfExists
("dm_acl WHERE ( object_name = '" + sAcl + "' )")));
sAclDomain = idAclObj.getDomain();
obj.setACLDomain(sAclDomain);
obj.save();
m_session.apiExec("install",m_objectId);

In the 5.3 DFC eclipse IDE, the "apiExec" was crossed out. I could compile the code, but the runtime environment needed to be very controlled. After digging into the DDS.jar file of the App Builder I fould a "policy" object which looked useful.

The following is the fixed code:

import java.beans.PropertyVetoException;
import com.documentum.policy.data.*;
try{
obj = (IDfSysObject)m_session.getObject(idObj);

m_objectId = idObj.toString();
// Uninstall this LifeCycle Object
IDfPolicy policy = new DfPolicy();
policy.setDocbaseContext(m_session);
try{
policy.open(new DfId(m_objectId), 1);
policy.uninstall();
obj.setACLName(sAcl);
IDfACL idAclObj = (IDfACL)(m_session.getObject
(getDocbaseObjectIDIfExists("dm_acl WHERE ( object_name = '" + sAcl +
"' )")));
sAclDomain = idAclObj.getDomain();
obj.setACLDomain(sAclDomain);
obj.save();
policy.validate();
policy.install();
}catch(IOException ioe){

}catch(PropertyVetoException pve){ }
}catch(DfException e) { }

Wednesday, October 10, 2007

DCM Configuration Nightmare

I was involved in a DCM implementation that was highly organized, but riddled with validation issues. This was in a highly regulated pharmaceutical company with strict qualifications from the development to QA to Produciton environments. Here's an overview list of the issues:

  1. IQs and OQs were dry run by the same users.

  2. Developers were asked to run some of the OQs.

  3. When moving from Dev (where the app worked) to QA, some of the DCM configuration was entered in manually. Inevitable human error caused many late nights figuring out what changed.

So for issue one, we eventually broke out the OQ dry runs to other users. For issue two, we outsourced all responsibility for running the IQ/OQs for validation. Issue three, was never figured out completely until after the project went to production.



DCM Configuration Issues

Why was configuring DCM an issue? Well, for one reason TBO customizations had certain hard coded conditions with relied on the specific Roles and ACLs, Lifecycle states relied on specific ACLs to function as expected, and the UI configuration relied on specific Roles and ACLs as well. Docapps could bring over Roles, but you can't modified them in the App Builder tool. Also, the App Builder doesn't recognize ACLs that are created in a repository without using Permission Templates.



Within DCM you have the following components (among others) to configure:

  • Business Applications (which are part of the DocumentClass object)
  • Document Classes (coordinators, contributors, templates)
  • Auto Name Schemes
  • Lifecycle State Extensions
  • Roles
  • ACLs
  • Auto Processes

With each of these components comes varying amounts of configuration details. The headaches come with Roles, ACLs, and LC Extensions. All you need is a misspelled acl or a forgotten role assignment to cause all sorts of havoc. The question becomes "how do you compare environments?" You dump all the objects and attributes. You can't run DQLs to determine the differences. You have to create an application which uses DFC interfaces to enable access to all the Documentum objects of DCM and expose all of their attributes.


Extracting DCM objects as XML

What we ended up developing is an XML bridge which allowed us to extract all (or a subset) of the DCM objects to XML. The schema allowed us to compare XML extractions from one environment to another. We would then take the extraction and run the configuration end of the application on a new docbase which had the base DCM installed and the docapps applied. This saved weeks of time manually configuring the application. Over the course of building and validating four environments the weeks saved, turns into months of effort saved by using this tool.

The Configurator Utility is available for you needs. If you would like to find out more about this utililty please email me at webber_john@charter.net.

Thursday, August 30, 2007

Specs: We'll write these if we have to

The good news about writing functional specifications is that you’ll most likely have plenty of examples to read for reference and a template to use. The bad news is that you might have to write it. Even if you don’t write it you’ll have to read and understand it. You’ll have to read the business requirements and understand those too. As you read these, you should be thinking about the technical specs, what prototyping will need to be done, and where the holes are. One more thing, make sure the eventual users of the system are engaged and sign off on all functional decisions. If they blow off meetings and are not involved in the process, they’ll be back later and will demand changes.

Large companies with a lot of procedures, lawyers, regulations, and outsourcing will undoubtedly require that technical specs be written before starting development. This is fine for about 80% of the project, however the technical details during the development, testing and deployment will change. The technical specs will need to be reworked to reflect this change at the end of the project. If you start out with this expectation, you won’t get as frustrated writing the specs without all the details. Be sure to write down in the assumptions that you expect to rewrite the specs after the project goes live.

As you solve the technical issues keep the following questions in mind:
  • Are the User’s of the system served well by this design?
  • Are there too many details written down at this stage?
  • Are there features which are training issues vs. customizations?
  • How much continuous discovery will this project have?
  • Will the development or testing be outsourced?

Are the User’s of the system served well by this design?
Any reservations should be considered and detailed here. In many cases the writers of the specs don’t really know Documentum well enough to fully understand possible scope creep issues and the technical ramifications of writing something like “this system will support nine languages…”
I don’t know how many times the specs were written in a vacuum. The User’s were too busy to fully detail the business requirements so the spec writer reads the manual and fills the functional specs with existing functionality.

Are there too many details written down at this stage?
I’ve read functional specs that have been bogged down by details which will change. Here’s where the lumpers and the splitters show there true colors. The lumpers will write too little detail, while the splitters will describe too much. It’s my experience that approximately 10 to 20% of what you need to develop a comprehensive application will not be known at the time that the functional spec written. Make this assumption, record it and move on. You can really slow a project down by trying to perfect all the details at this point.

Are there features which are training issues vs. customizations?
This question is usually asked if the initial discovery phase was done by folks who did not know the Documentum application well enough. The business requirements would reflect this lack of knowledge, would cascade to the specs. You have to gage how much continuous discovery this project might have. Was the business unit as engaged in the project as it should be, or will they perk up during the testing phase and really start thinking about how they’re gong to use this?

Will the development or testing be outsourced?
I had to bring this up because in these times of going the cheaper route, the project just may be going over seas. I wouldn’t worry though, because every Documentum project that I’ve done is way too involved to ship the whole thing to a third party vendor. Outsourcing pieces of the project may make sense. If you have to outsource get ready to write a lot more to describe what to do. Also, prepare to hand hold the third party through some of the more complex details of the development or testing.

The bottom line is that there’s a balance between the time you take to write or correct quality specs and the time it takes to develop. In some cases, it may make more sense to prototype and write the specs afterward. You’ll have to make this decision and get buy in up front. Don’t just do it; if it ends up taking longer to prototype, you’ll be on the hook to explain why.

Monday, August 27, 2007

Prototyping and proof of concept: This is fun!

This is fun if project managers get that POCs are crucial to the decision making process:

  • When someone on the team says “The way I did it at company X…”, but this way doesn’t feel right, prototyping should be considered to detail the pros and cons of the solution.
  • Every project has at least a few gray areas where the business users aren’t quite sure what they want and say they’d like to “see” something.

The fun part is actually working out some of the pieces of the puzzle. It’s also satisfying to prove to yourself and others that your gut feeling was right, or that it was wrong, but not as wrong as everyone thought. Here are some of the pieces to the puzzle that you may be able to figure out:

  • Is the customization possible? What is the level of complexity?
  • How many resources are needed and what type to achieve the functionality requested?
  • Is the estimated amount of servers of the infrastructure correct?
  • Will the application solution perform to the user’s expectations?
  • Will the schedule slip because of the functionality required?

Setting a POC sandbox also allows for installation experience and a preview into some of the issues that you’ll have to solve later. For example, when was the last time an installation of a Documentum product went exactly according to the installation documentation? Is your database administrator new to Documentum databases? This would be a good chance to get through the DBA headaches.

What about storage requirements? After loading up some dummy data, does the total disk space estimate make sense? When the dev, test, and production environments are taken into account including extra room for migrations, is there still enough space?

TBO vs. WDK customizations
I really like TBOs. They are very useful to making changes to attributes during all content operations. There will be times when you look at a customization to a drop down in the UI to achieve some kind of functionality and it occurs to you that it could be done with a TBO. Prototyping will help you work through the reality of that idea.

The bottom line is that you will be dealing with scope creep if you don’t prototype solutions when it makes sense to do so. When someone says “we need to customize” , make sure through a test of the functionality of the application that it’s not just a configuration. The WDK can be very flexible in terms of configuration and TBOs are great to use for customizations.