ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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);
    }
}