private ProcessDefinitionBehavior getProcessDefinition(Map<String, Object> processDataMap) {
String processId = StringUtil.getString(processDataMap.get("PROCESS_ID"));
String deploymentId = StringUtil.getString(processDataMap.get("DEPLOYMENT_ID"));
String resourceName = StringUtil.getString(processDataMap.get("RESOURCE_NAME"));
String processKey = StringUtil.getString(processDataMap.get("PROCESS_KEY"));
DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
ProcessDefinitionBehavior processDefinition = deploymentCache.getProcessDefinitionCache().get(processId);
if (processDefinition == null) {
String sqlText = "SELECT BYTES FROM FIXFLOW_DEF_BYTEARRAY WHERE NAME=? and DEPLOYMENT_ID=?";
// 构建查询参数
List<Object> objectParamWhere = new ArrayList<Object>();
objectParamWhere.add(resourceName);
objectParamWhere.add(deploymentId);
List<Map<String, Object>> dataObj = sqlCommand.queryForList(sqlText, objectParamWhere);
Map<String, Object> dataMap = dataObj.get(0);
Object bytesObject = dataMap.get("BYTES");
if (bytesObject != null) {
byte[] bytes = (byte[]) bytesObject;
ResourceSet resourceSet = getResourceSet();
String fixflowFilePath = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getNoneTemplateFilePath();
URL url = ReflectUtil.getResource(fixflowFilePath);
if(url == null){
throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION_FILENOTFOUND,fixflowFilePath);
}
String filePath = url.toString();
Resource ddddResource = null;
try {
if (!filePath.startsWith("jar")) {
filePath = java.net.URLDecoder.decode(url.getFile(),"utf-8");
ddddResource = resourceSet.createResource(URI.createFileURI(filePath));
} else {
ddddResource = resourceSet.createResource(URI.createURI(filePath));
}
ddddResource.load(new ByteArrayInputStream(bytes), null);
} catch (Exception e) {
throw new FixFlowClassLoadingException(ExceptionCode.CLASSLOAD_EXCEPTION, e);
}
DefinitionsBehavior definitions = (DefinitionsBehavior) ddddResource.getContents().get(0).eContents().get(0);
definitions.setProcessId(processId);
for (RootElement rootElement : definitions.getRootElements()) {
if (rootElement instanceof ProcessDefinitionBehavior) {
ProcessDefinitionBehavior processObj = (ProcessDefinitionBehavior) rootElement;
if (processObj.getProcessDefinitionKey().equals(processKey)) {
processDefinition = (ProcessDefinitionBehavior) rootElement;
break;
}
}
}
processDefinition.setDefinitions(definitions);
// 加载事件定义.
loadEvent(processDefinition);
// 加载数据变量
loadVariable(processDefinition);
// 设置FlowNode元素的子流程
loadSubProcess(processDefinition);
processDefinition.persistentInit(processDataMap);
deploymentCache.addProcessDefinition(processDefinition);
return processDefinition;
}
return null;
} else {