gpt4 book ai didi

java - 如何使用 JBPM 4.4 的 jpdl 获取 ProcessDefinition?

转载 作者:搜寻专家 更新时间:2023-10-31 20:19:10 24 4
gpt4 key购买 nike

在我的项目中有一个现有的 old.jpdl.xml 定义。它工作正常。现在我想运行另一个 new.jpdl.xml 定义。部署 ear 文件后,我尝试在以下代码的帮助下使用新的 ProcessDefinitionId 读取 new.jpdl.xml。

我认为我缺少部署步骤。有人可以指导我如何部署或阅读 new.jpdl.xml 吗?

public String getProcessInstanceID(ProcessEngine processEngine,
FlowControl flowcontrol, String processDefinitionID)
{
String processInstanceID = null;
log.debug("Entering method - getProcessInstanceID");
ProcessDefinitionQuery pdq = processEngine.getRepositoryService()
.createProcessDefinitionQuery();
pdq.deploymentId(processDefinitionID);
ProcessDefinition procDef = pdq.uniqueResult();

if (null == procDef)
{
log.error("Process Definition could not be found for the deployment ID: "
+ processDefinitionID);
}

Map<String, Object> variables = new HashMap<String, Object>();
variables.put("flowcontrol", flowcontrol);

ProcessInstance processInstance = processEngine.getExecutionService()
.startProcessInstanceByKey(procDef.getKey(), variables);

log.debug("Process Instance ID:" + processInstance.getId());
processInstanceID = processInstance.getId();
log.debug("Exiting method - getProcessInstanceID");
return processInstanceID;
}

最佳答案

我创建了一个批处理作业来部署 jpdl 文件。成功部署后,JBPM api 在内部将值插入到 JBPM4_XXX 表中。下面的类我已经用来部署新的 jpdl 文件。为了传递 jpdl 名称和 key 的值,我使用了 spring 依赖项。最后这些步骤成功了。

    public class JBPMDeploymentService extends BatchService {

/**
* Logger for Batch service
*/
protected static final Logger log = Logger.getLogger(NAPSJBPMDeploymentService.class);

private Map<String, String> jpdlMap = new HashMap<String, String>();

private Map<String, String> procInstMap = new HashMap<String, String> ();

public void doService() throws NAPSBatchException
{
log.info("Entering into doService Method of JBPMDeploymentService ...");
String approvalFlow = getJpdlFileType();

String jpdlXML = getJPDLxml(approvalFlow);

String procInst = getProcessInstanceKey(approvalFlow);

// constructs the ProcessEngine
ProcessEngine processEngine = new Configuration().setResource("naps.jbpm.cfg.xml").buildProcessEngine();

// retrieve the needed services
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();



repositoryService.createDeployment()
.addResourceFromClasspath(jpdlXML)
.deploy();
//executionService.startProcessInstanceByKey(procInst);

}

/**
* @return the jpdlMap
*/
public Map<String, String> getJpdlMap() {
return jpdlMap;
}

/**
* @param jpdlMap the jpdlMap to set
*/
public void setJpdlMap(Map<String, String> jpdlMap) {
this.jpdlMap = jpdlMap;
}

/**
* @param jpdlKey
* @return jpdl xml name
*/
private String getJPDLxml(String jpdlKey)
{
return jpdlMap.get(jpdlKey);
}

/**
* @return the procInstMap
*/
public Map<String, String> getProcInstMap() {
return procInstMap;
}

/**
* @param procInstMap the procInstMap to set
*/
public void setProcInstMap(Map<String, String> procInstMap) {
this.procInstMap = procInstMap;
}

/**
* @param procInstKey
* @return process Instance key
*/
private String getProcessInstanceKey(String procInstKey){
return this.procInstMap.get(procInstKey);
}
}

关于java - 如何使用 JBPM 4.4 的 jpdl 获取 ProcessDefinition?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29991859/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com