예제 #1
0
        protected internal virtual bool LocalizeDataObjectElements(IList <ValuedDataObject> dataObjects, JToken infoNode)
        {
            bool                localizationValuesChanged = false;
            ICommandContext     commandContext            = Context.CommandContext;
            IDynamicBpmnService dynamicBpmnService        = commandContext.ProcessEngineConfiguration.DynamicBpmnService;

            foreach (ValuedDataObject dataObject in dataObjects)
            {
                dataObject.ExtensionElements.TryGetValue("localization", out IList <ExtensionElement> localizationElements);
                if (localizationElements != null)
                {
                    foreach (ExtensionElement localizationElement in localizationElements)
                    {
                        if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.Equals(localizationElement.NamespacePrefix))
                        {
                            string locale        = localizationElement.GetAttributeValue(null, "locale");
                            string name          = localizationElement.GetAttributeValue(null, "name");
                            string documentation = null;

                            localizationElement.ChildElements.TryGetValue("documentation", out IList <ExtensionElement> documentationElements);
                            if (documentationElements != null)
                            {
                                foreach (ExtensionElement documentationElement in documentationElements)
                                {
                                    documentation = documentationElement.ElementText.Trim();
                                    break;
                                }
                            }

                            if (name is object && IsEqualToCurrentLocalizationValue(locale, dataObject.Id, DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false)
                            {
                                dynamicBpmnService.ChangeLocalizationName(locale, dataObject.Id, name, infoNode);
                                localizationValuesChanged = true;
                            }

                            if (documentation is object && IsEqualToCurrentLocalizationValue(locale, dataObject.Id, DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false)
                            {
                                dynamicBpmnService.ChangeLocalizationDescription(locale, dataObject.Id, documentation, infoNode);
                                localizationValuesChanged = true;
                            }
                        }
                    }
                }
            }

            return(localizationValuesChanged);
        }
예제 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="historyService"></param>
 /// <param name="taskService"></param>
 /// <param name="dynamicBpmnService"></param>
 /// <param name="repositoryService"></param>
 /// <param name="runtimeService"></param>
 /// <param name="managementService"></param>
 /// <param name="asyncExecutor"></param>
 /// <param name="configuration"></param>
 public StandaloneProcessEngineConfiguration(IHistoryService historyService,
                                             ITaskService taskService,
                                             IDynamicBpmnService dynamicBpmnService,
                                             IRepositoryService repositoryService,
                                             IRuntimeService runtimeService,
                                             IManagementService managementService,
                                             IAsyncExecutor asyncExecutor,
                                             IConfiguration configuration) : base(historyService,
                                                                                  taskService,
                                                                                  dynamicBpmnService,
                                                                                  repositoryService,
                                                                                  runtimeService,
                                                                                  managementService,
                                                                                  asyncExecutor,
                                                                                  configuration)
 {
 }
예제 #3
0
        public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration)
        {
            this.processEngineConfiguration = processEngineConfiguration;
            this.name = processEngineConfiguration.ProcessEngineName;
            this.repositoryService         = processEngineConfiguration.RepositoryService;
            this.runtimeService            = processEngineConfiguration.RuntimeService;
            this.historicDataService       = processEngineConfiguration.HistoryService;
            this.taskService               = processEngineConfiguration.TaskService;
            this.managementService         = processEngineConfiguration.ManagementService;
            this.dynamicBpmnService        = processEngineConfiguration.DynamicBpmnService;
            this.asyncExecutor             = processEngineConfiguration.AsyncExecutor;
            this.commandExecutor           = processEngineConfiguration.CommandExecutor;
            this.sessionFactories          = processEngineConfiguration.SessionFactories;
            this.transactionContextFactory = processEngineConfiguration.TransactionContextFactory;

            if (processEngineConfiguration.UsingRelationalDatabase && processEngineConfiguration.DatabaseSchemaUpdate is object)
            {
                commandExecutor.Execute(processEngineConfiguration.SchemaCommandConfig, new SchemaOperationsProcessEngineBuild());
            }

            if (name is null)
            {
                log.LogInformation("default activiti ProcessEngine created");
            }
            else
            {
                log.LogInformation($"ProcessEngine {name} created");
            }

            ProcessEngineFactory.RegisterProcessEngine(this);

            if (asyncExecutor != null && asyncExecutor.AutoActivate)
            {
                asyncExecutor.Start();
            }

            if (processEngineConfiguration.ProcessEngineLifecycleListener != null)
            {
                processEngineConfiguration.ProcessEngineLifecycleListener.OnProcessEngineBuilt(this);
            }

            processEngineConfiguration.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateGlobalEvent(ActivitiEventType.ENGINE_CREATED));
        }
예제 #4
0
        protected internal virtual bool LocalizeFlowElements(ICollection <FlowElement> flowElements, JToken infoNode)
        {
            bool localizationValuesChanged = false;

            if (flowElements == null)
            {
                return(localizationValuesChanged);
            }

            ICommandContext     commandContext     = Context.CommandContext;
            IDynamicBpmnService dynamicBpmnService = commandContext.ProcessEngineConfiguration.DynamicBpmnService;

            foreach (FlowElement flowElement in flowElements)
            {
                if (flowElement is UserTask || flowElement is SubProcess)
                {
                    flowElement.ExtensionElements.TryGetValue("localization", out IList <ExtensionElement> localizationElements);
                    if (localizationElements != null)
                    {
                        foreach (ExtensionElement localizationElement in localizationElements)
                        {
                            if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.Equals(localizationElement.NamespacePrefix))
                            {
                                string locale        = localizationElement.GetAttributeValue(null, "locale");
                                string name          = localizationElement.GetAttributeValue(null, "name");
                                string documentation = null;
                                localizationElement.ChildElements.TryGetValue("documentation", out IList <ExtensionElement> documentationElements);
                                if (documentationElements != null)
                                {
                                    foreach (ExtensionElement documentationElement in documentationElements)
                                    {
                                        documentation = documentationElement.ElementText.Trim();
                                        break;
                                    }
                                }

                                string flowElementId = flowElement.Id;
                                if (IsEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false)
                                {
                                    dynamicBpmnService.ChangeLocalizationName(locale, flowElementId, name, infoNode);
                                    localizationValuesChanged = true;
                                }

                                if (documentation is object && IsEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false)
                                {
                                    dynamicBpmnService.ChangeLocalizationDescription(locale, flowElementId, documentation, infoNode);
                                    localizationValuesChanged = true;
                                }

                                break;
                            }
                        }
                    }

                    if (flowElement is SubProcess subprocess)
                    {
                        bool isFlowElementLocalizationChanged = LocalizeFlowElements(subprocess.FlowElements, infoNode);
                        bool isDataObjectLocalizationChanged  = LocalizeDataObjectElements(subprocess.DataObjects, infoNode);
                        if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged)
                        {
                            localizationValuesChanged = true;
                        }
                    }
                }
            }

            return(localizationValuesChanged);
        }
예제 #5
0
        protected internal virtual void CreateLocalizationValues(string processDefinitionId, Process process)
        {
            if (process == null)
            {
                return;
            }

            ICommandContext     commandContext     = Context.CommandContext;
            IDynamicBpmnService dynamicBpmnService = commandContext.ProcessEngineConfiguration.DynamicBpmnService;
            JToken infoNode = dynamicBpmnService.GetProcessDefinitionInfo(processDefinitionId);

            bool localizationValuesChanged = false;

            process.ExtensionElements.TryGetValue("localization", out IList <ExtensionElement> localizationElements);
            if (localizationElements != null)
            {
                foreach (ExtensionElement localizationElement in localizationElements)
                {
                    if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.Equals(localizationElement.NamespacePrefix))
                    {
                        string locale        = localizationElement.GetAttributeValue(null, "locale");
                        string name          = localizationElement.GetAttributeValue(null, "name");
                        string documentation = null;
                        localizationElement.ChildElements.TryGetValue("documentation", out IList <ExtensionElement> documentationElements);
                        if (documentationElements != null)
                        {
                            foreach (ExtensionElement documentationElement in documentationElements)
                            {
                                documentation = documentationElement.ElementText.Trim();
                                break;
                            }
                        }

                        string processId = process.Id;
                        if (!IsEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode))
                        {
                            dynamicBpmnService.ChangeLocalizationName(locale, processId, name, infoNode);
                            localizationValuesChanged = true;
                        }

                        if (documentation is object && !IsEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode))
                        {
                            dynamicBpmnService.ChangeLocalizationDescription(locale, processId, documentation, infoNode);
                            localizationValuesChanged = true;
                        }

                        break;
                    }
                }
            }

            bool isFlowElementLocalizationChanged = LocalizeFlowElements(process.FlowElements, infoNode);
            bool isDataObjectLocalizationChanged  = LocalizeDataObjectElements(process.DataObjects, infoNode);

            if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged)
            {
                localizationValuesChanged = true;
            }

            if (localizationValuesChanged)
            {
                dynamicBpmnService.SaveProcessDefinitionInfo(processDefinitionId, infoNode);
            }
        }