package com.vci.server.workflow.server;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
import org.dom4j.Document;
|
|
import com.vci.common.log.ServerWithLog4j;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.workflow.data.ProcessCategoryInfo;
|
import com.vci.corba.workflow.data.ProcessDefinitionInfo;
|
import com.vci.server.workflow.server.delegate.ProcessCustomDelegate;
|
|
public class WorkFlowCahe {
|
|
//保存模板
|
private static Map<String,Document> templateMap = new HashMap<String, Document>() ;
|
|
public static Map<String, Document> getTemplateMap() {
|
if (templateMap.isEmpty()) {
|
initTemplateMap();
|
}
|
return templateMap;
|
}
|
|
private static void initTemplateMap() {
|
if (WorkFlowCahe.getTemplateMap() != null && WorkFlowCahe.getTemplateMap().size() == 0) {
|
ProcessCategoryInfo[] processCategories;
|
ProcessCustomDelegate delegate = new ProcessCustomDelegate();
|
try {
|
processCategories = delegate.getProcessCategories("root");
|
//processCategories = this.getProcessCategories("root", null);
|
for (ProcessCategoryInfo pc : processCategories) {
|
String id = pc.id;
|
ProcessDefinitionInfo[] processDefinitions = delegate.getProcessDefinitions(id);
|
for (ProcessDefinitionInfo pf : processDefinitions) {
|
String jbpmDeploymentId = pf.jbpmDeploymentId;
|
|
delegate.loadWorkFlowTemplate(jbpmDeploymentId);
|
//this.loadWorkFlowTemplate(jbpmDeploymentId, null);
|
}
|
}
|
} catch (VCIError e) {
|
//e.printStackTrace();
|
ServerWithLog4j.logger.error("initTemplateMap error", e);
|
}
|
}
|
}
|
|
// public static void setTemplateMap(Map<String, Document> templateMap) {
|
// WorkFlowCahe.templateMap = templateMap;
|
// }
|
|
public static synchronized void setMap(String jbpmDeploymentId,Document doc){
|
templateMap.put(jbpmDeploymentId, doc);
|
}
|
}
|