public virtual ParsedDeployment Build(BpmnDeploymentHelper bpmnDeploymentHelper) { IList <IProcessDefinitionEntity> processDefinitions = new List <IProcessDefinitionEntity>(); IDictionary <IProcessDefinitionEntity, BpmnParse> processDefinitionsToBpmnParseMap = new Dictionary <IProcessDefinitionEntity, BpmnParse>(); IDictionary <IProcessDefinitionEntity, IResourceEntity> processDefinitionsToResourceMap = new Dictionary <IProcessDefinitionEntity, IResourceEntity>(); var resources = deployment.GetResources().Values; foreach (IResourceEntity resource in resources) { if (IsBpmnResource(resource.Name)) { log.LogDebug($"Processing BPMN resource {resource.Name}"); BpmnParse parse = CreateBpmnParseFromResource(bpmnDeploymentHelper, resource); foreach (IProcessDefinitionEntity processDefinition in parse.ProcessDefinitions) { processDefinition.BusinessKey = parse.Deployment.BusinessKey; processDefinition.StartForm = parse.Deployment.StartForm; processDefinition.BusinessPath = parse.Deployment.BusinessPath; processDefinitions.Add(processDefinition); processDefinitionsToBpmnParseMap[processDefinition] = parse; processDefinitionsToResourceMap[processDefinition] = resource; } } } return(new ParsedDeployment(deployment, processDefinitions, processDefinitionsToBpmnParseMap, processDefinitionsToResourceMap)); }
private BpmnParse CreateBpmnParseFromResource(BpmnDeploymentHelper helper, IResourceEntity resource) { string resourceName = resource.Name; MemoryStream inputStream = new MemoryStream(resource.Bytes); var changed = helper.AddCamundaNamespace(inputStream); if (changed.Item1) { resource.Bytes = changed.Item2.ToArray(); inputStream = changed.Item2; } ; inputStream.Seek(0, SeekOrigin.Begin); BpmnParse bpmnParse = bpmnParser.CreateParse().SourceInputStream(inputStream).SetSourceSystemId(resourceName).SetName(resourceName); bpmnParse.Deployment = deployment; if (deploymentSettings != null) { // Schema validation if needed if (deploymentSettings.ContainsKey(Cmd.DeploymentSettingsFields.IS_BPMN20_XSD_VALIDATION_ENABLED)) { bpmnParse.ValidateSchema = Convert.ToBoolean(deploymentSettings[Cmd.DeploymentSettingsFields.IS_BPMN20_XSD_VALIDATION_ENABLED]); } // Process validation if needed if (deploymentSettings.ContainsKey(Cmd.DeploymentSettingsFields.IS_PROCESS_VALIDATION_ENABLED)) { bpmnParse.ValidateProcess = Convert.ToBoolean(deploymentSettings[Cmd.DeploymentSettingsFields.IS_PROCESS_VALIDATION_ENABLED]); } } else { // On redeploy, we assume it is validated at the first deploy bpmnParse.ValidateSchema = false; bpmnParse.ValidateProcess = false; } bpmnParse.Execute(); return(bpmnParse); }