Exemplo n.º 1
0
        public virtual IVariableInstance Execute(ICommandContext commandContext)
        {
            if (executionId is null)
            {
                throw new ActivitiIllegalArgumentException("executionId is null");
            }
            if (variableName is null)
            {
                throw new ActivitiIllegalArgumentException("variableName is null");
            }

            IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId);

            if (execution == null)
            {
                throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", typeof(IExecution));
            }

            IVariableInstance variableEntity;

            if (isLocal)
            {
                variableEntity = execution.GetVariableInstanceLocal(variableName, false);
            }
            else
            {
                variableEntity = execution.GetVariableInstance(variableName, false);
            }

            return(variableEntity);;
        }
Exemplo n.º 2
0
        public virtual IDataObject Execute(ICommandContext commandContext)
        {
            if (executionId is null)
            {
                throw new ActivitiIllegalArgumentException("executionId is null");
            }
            if (dataObjectName is null)
            {
                throw new ActivitiIllegalArgumentException("dataObjectName is null");
            }

            IExecutionEntity execution = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(executionId);

            if (execution == null)
            {
                throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", typeof(IExecution));
            }

            IDataObject dataObject = null;

            IVariableInstance variableEntity;

            if (isLocal)
            {
                variableEntity = execution.GetVariableInstanceLocal(dataObjectName, false);
            }
            else
            {
                variableEntity = execution.GetVariableInstance(dataObjectName, false);
            }

            string localizedName        = null;
            string localizedDescription = null;

            if (variableEntity != null)
            {
                IExecutionEntity executionEntity = commandContext.ExecutionEntityManager.FindById <IExecutionEntity>(variableEntity.ExecutionId);
                while (!executionEntity.IsScope)
                {
                    executionEntity = executionEntity.Parent;
                }

                BpmnModel        bpmnModel       = ProcessDefinitionUtil.GetBpmnModel(executionEntity.ProcessDefinitionId);
                ValuedDataObject foundDataObject = null;
                if (executionEntity.ParentId is null)
                {
                    foreach (ValuedDataObject dataObjectDefinition in bpmnModel.MainProcess.DataObjects)
                    {
                        if (dataObjectDefinition.Name.Equals(variableEntity.Name))
                        {
                            foundDataObject = dataObjectDefinition;
                            break;
                        }
                    }
                }
                else
                {
                    SubProcess subProcess = (SubProcess)bpmnModel.GetFlowElement(execution.ActivityId);
                    foreach (ValuedDataObject dataObjectDefinition in subProcess.DataObjects)
                    {
                        if (dataObjectDefinition.Name.Equals(variableEntity.Name))
                        {
                            foundDataObject = dataObjectDefinition;
                            break;
                        }
                    }
                }

                if (!(locale is null) && foundDataObject != null)
                {
                    JToken languageNode = Context.GetLocalizationElementProperties(locale, foundDataObject.Id, execution.ProcessDefinitionId, withLocalizationFallback);

                    if (variableEntity != null && languageNode != null)
                    {
                        JToken nameNode = languageNode[DynamicBpmnConstants.LOCALIZATION_NAME];
                        if (nameNode != null)
                        {
                            localizedName = nameNode.ToString();
                        }
                        JToken descriptionNode = languageNode[DynamicBpmnConstants.LOCALIZATION_DESCRIPTION];
                        if (descriptionNode != null)
                        {
                            localizedDescription = descriptionNode.ToString();
                        }
                    }
                }

                if (foundDataObject != null)
                {
                    dataObject = new DataObjectImpl(variableEntity.Name, variableEntity.Value, foundDataObject.Documentation, foundDataObject.Type, localizedName, localizedDescription, foundDataObject.Id);
                }
            }

            return(dataObject);
        }