/**
 * GetWorkOrderIdAction.java
 * Created on Jun 20, 2008
 * (C) Copyright TANDBERG Television Ltd.
 */
package com.tandbergtv.watchpoint.pmm.action;

import org.apache.log4j.Logger;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

/**
 * This action handler sets the work order Id in the 'processId' variable of the template. 
 * 
 * @author spuranik
 */
public class SetProcessIdAction implements ActionHandler {

	private static final long serialVersionUID = 1L;
	public final static String PROCESS_ID = "processId";
	private static final Logger logger = Logger.getLogger(SetProcessIdAction.class);

	/* (non-Javadoc)
	 * @see org.jbpm.graph.def.ActionHandler#execute(org.jbpm.graph.exe.ExecutionContext)
	 */
	public void execute(ExecutionContext context) throws Exception {
		int id = (int)context.getProcessInstance().getId();
		context.setVariable(PROCESS_ID, id);
		logger.debug("Set processId to: " + id);
	}
}
