⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getprocessinstancelogcommand.java

📁 workflow first jbpm
💻 JAVA
字号:
package org.jbpm.command;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.Token;
import org.jbpm.logging.log.ProcessLog;

/**
 * Retrieve the <code>org.jbpm.logging.log.ProcessLog</code> for the
 * process with the given process-id
 * 
 * returns a map that maps {@link Token}s to {@link List}s.
 * 
 * @author Bernd Ruecker (bernd.ruecker@camunda.com)
 *
 */
public class GetProcessInstanceLogCommand implements Command {
	
	private static final long serialVersionUID = -2812852941518870502L;
	
	private long processInstanceId;
	
  public GetProcessInstanceLogCommand() {	  
	}
  
  public GetProcessInstanceLogCommand(long processInstanceId) {
    this.processInstanceId = processInstanceId;
  }

	public Object execute(JbpmContext jbpmContext) throws Exception {
        Map logMap = jbpmContext.getLoggingSession().findLogsByProcessInstance(processInstanceId);
        return loadLogdFromMap(logMap);	
	}

	/**
	 * access everything on all ProcessLog objects,
	 * which is not in the default fetch group from hibernate, 
	 * but needs to be accesible from the client
	 * 
	 * overwrite this method, if you need more details in your client
	 * 
	 * @param m
	 */
	protected Map loadLogdFromMap(Map logMap) {
        Iterator iter = logMap.keySet().iterator();
        while (iter.hasNext()) {
            Token t = (Token) iter.next();

            List logs = (List) logMap.get(t);
            Iterator iter2 = logs.iterator();
            while (iter2.hasNext()) {
                ProcessLog pl = (ProcessLog) iter2.next();
                // TODO: I am not sure if we need that, write a test for it
                pl.getActorId();
                pl.toString();
            }
        }	
		return logMap;
	}

	/**
	 * @deprecated use getProcessInstanceId instead
	 */
	public long getProcessId() {
		return processInstanceId;
	}

  /**
   * @deprecated use setProcessInstanceId instead
   */
	public void setProcessId(long processId) {
		this.processInstanceId = processId;
	}

  public long getProcessInstanceId() {
    return processInstanceId;
  }

  public void setProcessInstanceId(long processInstanceId) {
    this.processInstanceId = processInstanceId;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -