throw new FixFlowException("定义文件加载失败!", e);
}
DefinitionsBehavior definitions = (DefinitionsBehavior) ddddResource.getContents().get(0).eContents().get(0);
ProcessDefinitionBehavior process = null;
for (RootElement rootElement : definitions.getRootElements()) {
if (rootElement instanceof ProcessDefinitionBehavior) {
// ProcessDefinitionBehavior
// processObj=(ProcessDefinitionBehavior)rootElement;
// if(processObj.getProcessDefinitionKey().equals("")){
process = (ProcessDefinitionBehavior) rootElement;
break;
// }
}
}
//增加模型验证,by ych 2013 12 27
if(process.isVerification()){
@SuppressWarnings("unused")
StringBuffer sb = new StringBuffer();
String result = VerificationUtil.verifyAll(process);
if(result.length() > 0){
throw new FixFlowException(result);
}
}
process.setDefinitions(definitions);
process.setResourceName(resourceBpmn.getName());
process.setResourceId(resourceBpmn.getId());
if(resourcePng!=null){
String diagramResourceName = StringUtil.getString(resourcePng.getName());
process.setDiagramResourceName(diagramResourceName);
}
CommandContext commandContext = Context.getCommandContext();
ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
int processDefinitionVersion;
ProcessDefinitionBehavior latestProcessDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(process.getProcessDefinitionKey());
if (latestProcessDefinition != null) {
processDefinitionVersion = latestProcessDefinition.getVersion() + 1;
} else {
processDefinitionVersion = 1;
}
if(deployment.getUpdateDeploymentId()!=null&&!deployment.getUpdateDeploymentId().equals("")){
String deploymentId = deployment.getId();
process.setDeploymentId(deploymentId);
ProcessDefinitionBehavior persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKey(
deploymentId, process.getProcessDefinitionKey());
//process.setId(persistedProcessDefinition.getId());
process.setVersion(persistedProcessDefinition.getVersion());
process.setProcessDefinitionId(persistedProcessDefinition.getProcessDefinitionId());
Context.getProcessEngineConfiguration().getDeploymentCache().removeProcessDefinition(process.getProcessDefinitionId());
}else{