示例#1
0
        /// <summary>
        /// Adds extra properties to EditableRoot.
        /// </summary>
        /// <param name="code">The source code under generation.</param>
        /// <param name="process">Current process.</param>
        public override void AddEditClassProperties(StringBuilder code, IProcessDefinition process)
        {
            base.AddEditClassProperties(code, process);

            if (process.SampleFields == null)
                return;

            foreach (var sample in process.SampleFields.Values)
            {
                var sampleSettings = new XElement("SampleSettings",
                   new XAttribute("Id", sample.Id),
                   new XAttribute("SampleTypeFieldName", sample.SampleTypeFieldName),
                   new XAttribute("UpperSpecFieldName", sample.UpperSpecFieldName),
                   new XAttribute("LowerSpecFieldName", sample.LowerSpecFieldName),
                   new XAttribute("SamplingTechniqueFieldName", sample.SamplingTechniqueFieldName),
                   new XAttribute("SampleSizeType", sample.SampleSizeType.ToString()),
                   new XAttribute("SampleSizeFieldName", sample.SampleSizeFieldName),
                   new XAttribute("BatchSizeFieldName", sample.BatchSizeFieldName),
                   new XAttribute("AQLTableFieldName", sample.AQLTableFieldName),
                   new XAttribute("AQLFieldName", sample.AQLFieldName),
                   new XAttribute("NumberOfDecimalsFieldName", sample.NumberOfDecimalsFieldName));

                code.AppendFormat(@"
		public string {0}{1}
		{{
			get {{ return ""{2}""; }}
		}}
", sample.Name, Constants.SampleSettingPostfix, sampleSettings.ToString().Replace("\"", "\\\""));
            }
        }
示例#2
0
        public virtual void TestGetBpmnXmlFileThroughService()
        {
            string         deploymentId        = repositoryService.CreateDeploymentQuery().First().Id;
            IList <string> deploymentResources = repositoryService.GetDeploymentResourceNames(deploymentId);

            // verify bpmn file name
            Assert.AreEqual(1, deploymentResources.Count);
            string bpmnResourceName = "resources/Bpmn/Deployment/BpmnDeploymentTest.TestGetBpmnXmlFileThroughService.bpmn20.xml";

            Assert.AreEqual(bpmnResourceName, deploymentResources[0]);

            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery().First();

            Assert.AreEqual(bpmnResourceName, processDefinition.ResourceName);
            Assert.IsNull(processDefinition.DiagramResourceName);
            Assert.IsFalse(processDefinition.GetHasStartFormKey());

            IReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl)repositoryService).GetDeployedProcessDefinition(processDefinition.Id);

            Assert.IsNull(readOnlyProcessDefinition.DiagramResourceName);

            // verify content
            System.IO.Stream deploymentInputStream = repositoryService.GetResourceAsStream(deploymentId, bpmnResourceName);
            string           contentFromDeployment = ReadInputStreamToString(deploymentInputStream);

            Assert.True(contentFromDeployment.Length > 0);
            Assert.True(contentFromDeployment.Contains("process id=\"emptyProcess\""));

            System.IO.Stream fileInputStream = ReflectUtil.GetResourceAsStream("resources/Bpmn/Deployment/BpmnDeploymentTest.TestGetBpmnXmlFileThroughService.bpmn20.xml");
            string           contentFromFile = ReadInputStreamToString(fileInputStream);

            Assert.AreEqual(contentFromFile, contentFromDeployment);
        }
示例#3
0
        public virtual void testQueryWithGroupAuthorizationRevokedReadPermission()
        {
            // given
            // given user gets all permissions on any process definition
            IAuthorization authorization = createGrantAuthorization(Resources.ProcessDefinition, AuthorizationFields.Any);

            authorization.GroupId = groupId;
            authorization.AddPermission(Permissions.All);
            saveAuthorization(authorization);

            authorization         = createRevokeAuthorization(Resources.ProcessDefinition, ONE_TASK_PROCESS_KEY);
            authorization.GroupId = groupId;
            authorization.RemovePermission(Permissions.Read);
            saveAuthorization(authorization);

            // when
            IQueryable <IProcessDefinition> query = repositoryService.CreateProcessDefinitionQuery();

            // then
            //verifyQueryResults(query, 1);

            IProcessDefinition definition = query.First();

            Assert.NotNull(definition);
            Assert.AreEqual(TWO_TASKS_PROCESS_KEY, definition.Key);
        }
示例#4
0
        public virtual void testDontWriteDuplicateLogOnBatchMigrationJobExecution()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);

            IProcessInstance processInstance = runtimeService.StartProcessInstanceById(sourceDefinition.Id);

            IMigrationPlan migrationPlan = runtimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            batch = runtimeService.NewMigration(migrationPlan).ProcessInstanceIds((processInstance.Id)).ExecuteAsync();
            IJob seedJob = managementService.CreateJobQuery().First();

            managementService.ExecuteJob(seedJob.Id);

            IJob migrationJob = managementService.CreateJobQuery(c => c.JobDefinitionId == batch.BatchJobDefinitionId).First();

            // when
            managementService.ExecuteJob(migrationJob.Id);

            // then
            Assert.AreEqual(5, userOperationLogQuery().Count());
            //Assert.AreEqual(2, userOperationLogQuery().OperationType(UserOperationLogEntryFields.OperationTypeCreate).EntityType(EntityTypes.Deployment).Count());
            //Assert.AreEqual(3, userOperationLogQuery().OperationType(UserOperationLogEntryFields.OperationTypeMigrate).EntityType(EntityTypes.ProcessInstance).Count());
        }
示例#5
0
        public virtual void TestDeployAndGetProcessDefinition()
        {
            // given process model
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final org.Camunda.bpm.Model.bpmn.IBpmnModelInstance modelInstance = org.Camunda.bpm.Model.bpmn.Bpmn.CreateExecutableProcess("foo").StartEvent().UserTask().EndEvent().Done();
            IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("foo").StartEvent().UserTask().EndEvent().Done();

            // when process model is deployed
            IDeploymentWithDefinitions deployment = repositoryService.CreateDeployment().AddModelInstance("foo.bpmn", modelInstance).DeployAndReturnDefinitions();

            DeploymentIds.Add(deployment.Id);

            // then deployment contains deployed process definitions
            IList <IProcessDefinition> deployedProcessDefinitions = deployment.DeployedProcessDefinitions;

            Assert.AreEqual(1, deployedProcessDefinitions.Count);
            Assert.IsNull(deployment.DeployedCaseDefinitions);
            Assert.IsNull(deployment.DeployedDecisionDefinitions);
            Assert.IsNull(deployment.DeployedDecisionRequirementsDefinitions);

            // and persisted process definition is equal to deployed process definition
            IProcessDefinition persistedProcDef = repositoryService.CreateProcessDefinitionQuery(c => c.ResourceName == "foo.bpmn").First();

            Assert.AreEqual(persistedProcDef.Id, deployedProcessDefinitions[0].Id);
        }
示例#6
0
        /// <summary>
        /// Called when [before_ editable root_ data portal_ insert_ update children].
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="process">The process.</param>
        public override void OnBefore_EditableRoot_DataPortal_Insert_UpdateChildren(StringBuilder assemblyCode, IProcessDefinition process)
        {
            base.OnBefore_EditableRoot_DataPortal_Insert_UpdateChildren(assemblyCode, process);
			if (process.SampleFields == null)
				return;

            foreach (var sample in process.SampleFields.Values)
            {
                assemblyCode.AppendFormat(@"
            if ({0} == null || {0}.Count == 0)
            {{
                LoadProperty({0}Property, {0}SampleList.PopulateSampleList(this));
            }}
            ", sample.Name);

                //if it is not 0 or 1 or 2 which are indexes of SampleType because this is how sample type was stored in old processes
                if (!string.IsNullOrEmpty(sample.SampleTypeFieldName) && !Char.IsDigit(sample.SampleTypeFieldName[0]))
                {
                    assemblyCode.AppendFormat(@"
            if (string.IsNullOrEmpty({0}))
                LoadProperty({0}Property, ""Number"");
            ", sample.SampleTypeFieldName);
                }
            }
        }
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteProcessDefinitionAndRefillDeploymentCache()
        [Test]   public virtual void testDeleteProcessDefinitionAndRefillDeploymentCache()
        {
            // given a deployment with two process definitions in one xml model file
            deployment = repositoryService.CreateDeployment().AddClasspathResource("resources/repository/twoProcesses.bpmn20.xml").Deploy();
            IProcessDefinition processDefinitionOne = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "one").First();
            IProcessDefinition processDefinitionTwo = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "two").First();

            string idOne = processDefinitionOne.Id;

            //one is deleted from the deployment
            repositoryService.DeleteProcessDefinition(idOne);

            //when clearing the deployment cache
            processEngineConfiguration.DeploymentCache.DiscardProcessDefinitionCache();

            //then creating process instance from the existing process definition
            IProcessInstanceWithVariables procInst = runtimeService.CreateProcessInstanceByKey("two").ExecuteWithVariablesInReturn();

            Assert.NotNull(procInst);
            Assert.True(procInst.ProcessDefinitionId.Contains("two"));

            //should refill the cache
            ICache <string, ProcessDefinitionEntity> cache = processEngineConfiguration.DeploymentCache.ProcessDefinitionCache;

            Assert.NotNull(cache.Get(processDefinitionTwo.Id));
            //The deleted process definition should not be recreated after the cache is refilled
            Assert.IsNull(cache.Get(processDefinitionOne.Id));
        }
        protected internal virtual IProcessInstance CreateAndStartProcessInstance(IProcessDefinition processDefinition, string businessKey, string processInstanceName, IDictionary <string, object> variables, IDictionary <string, object> transientVariables, bool startProcessInstance)
        {
            // Todo: ideally, context should be passed here
            _ = Context.CommandContext;

            // Do not start process a process instance if the process definition is suspended
            if (ProcessDefinitionUtil.IsProcessDefinitionSuspended(processDefinition.Id))
            {
                throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.Name + " (id = " + processDefinition.Id + ") is suspended");
            }

            // Get model from cache
            Process process = ProcessDefinitionUtil.GetProcess(processDefinition.Id);

            if (process == null)
            {
                throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.Name + " (id = " + processDefinition.Id + ") could not be found");
            }

            FlowElement initialFlowElement = process.InitialFlowElement;

            if (initialFlowElement == null)
            {
                throw new ActivitiException("No start element found for process definition " + processDefinition.Id);
            }

            return(CreateAndStartProcessInstanceWithInitialFlowElement(processDefinition, businessKey, processInstanceName, initialFlowElement, process, variables, transientVariables, startProcessInstance));
        }
示例#9
0
		public override void ReadProcessData(XmlElement xmlElement, CreationContext creationContext)
		{
			base.ReadProcessData(xmlElement, creationContext);

			// get the process definition for that name
			String subProcessDefinitionName = xmlElement.GetProperty("process");
			creationContext.Check(((Object) subProcessDefinitionName != null), "process is missing in the process state : " + subProcessDefinitionName);
			DbSession dbSession = creationContext.DbSession;
			dbSession.SaveOrUpdate(this._processDefinition);
			try
			{
				this._subProcess = (ProcessDefinitionImpl) dbSession.FindOne(queryFindProcessDefinitionByName, subProcessDefinitionName, DbType.STRING);
			}
			catch (SystemException e)
			{
				creationContext.AddError("process '" + subProcessDefinitionName + "' was not deployed while it is referenced in a process-state. Exception: " + e.Message);
			}

			// parse the processInvokerDelegation
			creationContext.DelegatingObject = this;
			this._processInvokerDelegation = new DelegationImpl();
			XmlElement invocationElement = xmlElement.GetChildElement("process-invocation");
			creationContext.Check((invocationElement != null), "process-invocation is missing in the process-state : " + xmlElement);
			this._processInvokerDelegation.ReadProcessData(invocationElement, creationContext);

			creationContext.DelegatingObject = null;

			// parse the actorExpression
			this._actorExpression = xmlElement.GetProperty("actor-expression");
			creationContext.Check(((Object) _actorExpression != null), "actor-expression is missing in the process-state : " + xmlElement);
		}
示例#10
0
        public void StartProcessTest()
        {
            IProcessInstance processInstance = null;

            Thread.CurrentPrincipal = new PrincipalUserAdapter("ae");

            try
            {
                IDictionary attributeValues = new Hashtable();
                //attributeValues["available"] = "APPROVE";
                //attributeValues["product"] = "abcd";
                //attributeValues["requester"] = "efg";

                IProcessDefinition booaction = definitionComponent.GetProcessDefinition("Hello world 4");

                processInstance = executionComponent.StartProcessInstance(booaction.Id, attributeValues);
                Assert.IsNotNull(processInstance);
            }
            catch (ExecutionException e)
            {
                Assert.Fail("ExcecutionException while starting a new holiday request: " + e.Message);
            }
            finally
            {
                //      loginUtil.logout();
            }
        }
示例#11
0
 public ProcessInstanceImpl(String actorId, ProcessDefinitionImpl processDefinition)
 {
     this._start = DateTime.Now;
     this._initiatorActorId = actorId;
     this._processDefinition = processDefinition;
     this._rootFlow = new FlowImpl(actorId, this);
 }
示例#12
0
        [Test]   public virtual void testSuspensionWithTenancy()
        {
            IBpmnModelInstance instance           = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess(PROCESS_ID).StartEvent().UserTask().EndEvent().Done();
            IProcessDefinition processDefinition  = processEngineTestRule.DeployAndGetDefinition(instance);
            IProcessDefinition processDefinition1 = processEngineTestRule.DeployForTenantAndGetDefinition(TENANT_ONE, instance);
            IProcessDefinition processDefinition2 = processEngineTestRule.DeployForTenantAndGetDefinition(TENANT_TWO, instance);

            IProcessInstance processInstance  = processEngineRule.RuntimeService.StartProcessInstanceById(processDefinition.Id);
            IProcessInstance processInstance1 = processEngineRule.RuntimeService.StartProcessInstanceById(processDefinition1.Id);
            IProcessInstance processInstance2 = processEngineRule.RuntimeService.StartProcessInstanceById(processDefinition2.Id);

            //suspend ITenant one
            processEngineRule.RuntimeService.UpdateProcessInstanceSuspensionState().ByProcessDefinitionKey(processDefinition1.Key).ProcessDefinitionTenantId(processDefinition1.TenantId).Suspend();

            string[] processInstances = new string[] { processInstance1.Id, processInstance2.Id, processInstance.Id };

            verifyStates(processInstances, new string[] { HistoricProcessInstanceFields.StateSuspended, HistoricProcessInstanceFields.StateActive, HistoricProcessInstanceFields.StateActive });


            //suspend without tenant
            processEngineRule.RuntimeService.UpdateProcessInstanceSuspensionState().ByProcessDefinitionKey(processDefinition.Key).ProcessDefinitionWithoutTenantId().Suspend();

            verifyStates(processInstances, new string[] { HistoricProcessInstanceFields.StateSuspended, HistoricProcessInstanceFields.StateActive, HistoricProcessInstanceFields.StateSuspended });

            //reactivate without tenant
            processEngineRule.RuntimeService.UpdateProcessInstanceSuspensionState().ByProcessDefinitionKey(processDefinition.Key).ProcessDefinitionWithoutTenantId().Activate();


            verifyStates(processInstances, new string[] { HistoricProcessInstanceFields.StateSuspended, HistoricProcessInstanceFields.StateActive, HistoricProcessInstanceFields.StateActive });
        }
示例#13
0
 public ProcessInstanceImpl(String actorId, ProcessDefinitionImpl processDefinition)
 {
     this._start             = DateTime.Now;
     this._initiatorActorId  = actorId;
     this._processDefinition = processDefinition;
     this._rootFlow          = new FlowImpl(actorId, this);
 }
示例#14
0
        public void ProcessImage(Int64 processDefinitionId)
        {
            IDefinitionSessionLocal definitionComponent = null;

            try
            {
                definitionComponent          = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                Context.Response.ContentType = "image/gif";
                if (log.IsDebugEnabled)
                {
                    log.Debug("show ProcessImage processDefinitionId:" + processDefinitionId);
                }
                IProcessDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId);
                byte[]             gifContents       = processDefinition.Image;

                if (gifContents != null)
                {
                    Context.Response.OutputStream.Write(gifContents, 0, gifContents.Length);
                }
            }
            finally
            {
                ServiceLocator.Instance.Release(definitionComponent);
            }
        }
        public virtual void deployProcessesAndCreateMigrationPlan()
        {
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);

            migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).Build();
        }
示例#16
0
        public virtual IExecutionEntity CreateSubprocessInstance(IProcessDefinition processDefinition, IExecutionEntity superExecutionEntity, string businessKey)
        {
            IExecutionEntity subProcessInstance = executionDataManager.Create();

            InheritCommonProperties(superExecutionEntity, subProcessInstance);
            subProcessInstance.ProcessDefinitionId   = processDefinition.Id;
            subProcessInstance.ProcessDefinitionKey  = processDefinition.Key;
            subProcessInstance.SuperExecution        = superExecutionEntity;
            subProcessInstance.RootProcessInstanceId = superExecutionEntity.RootProcessInstanceId;
            subProcessInstance.IsScope     = true; // process instance is always a scope for all child executions
            subProcessInstance.StartUserId = Authentication.AuthenticatedUser.Id;
            subProcessInstance.BusinessKey = businessKey;

            // Store in database
            Insert(subProcessInstance, false);

            //if (logger.DebugEnabled)
            //{
            //    logger.debug("Child execution {} created with super execution {}", subProcessInstance, superExecutionEntity.Id);
            //}

            subProcessInstance.ProcessInstanceId    = subProcessInstance.Id;
            superExecutionEntity.SubProcessInstance = subProcessInstance;

            ProcessEngineConfigurationImpl processEngineConfiguration1 = Context.ProcessEngineConfiguration;

            if (processEngineConfiguration1 is object && processEngineConfiguration1.EventDispatcher.Enabled)
            {
                processEngineConfiguration1.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_CREATED, subProcessInstance));
            }

            return(subProcessInstance);
        }
示例#17
0
        /// <summary>Gets the audit from cross referenced table for CR fields with Link Field.</summary>
        /// <param name="process">The process.</param>
        /// <returns></returns>
        private string GetAuditUnions(IProcessDefinition process)
        {
            var code = new StringBuilder();
            foreach (var field in process.TableList[0].FieldList.Where(f => f.IsRef && !string.IsNullOrEmpty(f.LinkFieldSystemName)))
            {
                code.AppendLine().AppendFormat(@"
UNION ALL
SELECT [Id]
      ,[Type]
      ,@id
      ,'{0}'
      ,''
      ,'Link added: Process={1}, Id=' + CAST([ItemId] AS VARCHAR(10))
      ,[UpdateDate]
      ,[UserName]
FROM [audit].[{1}]
WHERE NewValue LIKE 'Process={2}, Id=' + CAST(@id AS VARCHAR(10)) + ',%'
UNION ALL
SELECT [Id]
      ,[Type]
      ,@id
      ,'{0}'
      ,'Link removed: Process={1}, Id=' + CAST([ItemId] AS VARCHAR(10))
	  ,''
      ,[UpdateDate]
      ,[UserName]
FROM [audit].[{1}]
WHERE OldValue LIKE 'Process={2}, Id=' + CAST(@id AS VARCHAR(10)) + ',%'", field.SystemName, field.ReferenceColumnTable, process.Name).AppendLine();
            }

            if (code.Length > 0)
                code.AppendLine().Append("ORDER BY UpdateDate DESC");

            return code.ToString();
        }
示例#18
0
 public virtual void CheckCreateProcessInstance(IProcessDefinition processDefinition)
 {
     if (!TenantManager.IsAuthenticatedTenant(processDefinition.TenantId))
     {
         throw Log.ExceptionCommandWithUnauthorizedTenant("create an instance of the process definition '" + processDefinition.Id + "'");
     }
 }
示例#19
0
 public virtual void CheckReadProcessDefinition(IProcessDefinition processDefinition)
 {
     if (!TenantManager.IsAuthenticatedTenant(processDefinition.TenantId))
     {
         throw Log.ExceptionCommandWithUnauthorizedTenant("get the process definition '" + processDefinition.Id + "'");
     }
 }
        public virtual void testCompletingSuspendedJobDuringRunningInstance()
        {
            testRule.Deploy(ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().ReceiveTask().IntermediateCatchEvent().TimerWithDuration("PT0M").EndEvent().Done());

            // given
            // a process definition
            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery().First();

            // a running instance
            IProcessInstance processInstance = runtimeService.StartProcessInstanceById(processDefinition.Id);

            // suspend the process definition (and the job definitions)
            repositoryService.SuspendProcessDefinitionById(processDefinition.Id);

            // Assert that there still exists a running and active process instance
            Assert.AreEqual(1, runtimeService.CreateProcessInstanceQuery(c => c.SuspensionState == SuspensionStateFields.Active.StateCode).Count());

            // when
            runtimeService.Signal(processInstance.Id);

            // then
            // there should be one suspended job
            Assert.AreEqual(1, managementService.CreateJobQuery(c => c.SuspensionState == SuspensionStateFields.Suspended.StateCode).Count());
            Assert.AreEqual(0, managementService.CreateJobQuery(c => c.SuspensionState == SuspensionStateFields.Active.StateCode).Count());

            Assert.AreEqual(1, runtimeService.CreateProcessInstanceQuery(c => c.SuspensionState == SuspensionStateFields.Active.StateCode).Count());
        }
示例#21
0
        public override IList <IExecution> ExecuteList(ICommandContext commandContext, Page page)
        {
            CheckQueryOk();
            EnsureVariablesInitialized();

            IList <IExecutionEntity> executions = commandContext.ExecutionEntityManager.FindExecutionsByQueryCriteria(this, page) ?? new List <IExecutionEntity>();

            if (Context.ProcessEngineConfiguration.PerformanceSettings.EnableLocalization)
            {
                foreach (IExecutionEntity execution in executions)
                {
                    string activityId = null;
                    if (execution.Id.Equals(execution.ProcessInstanceId))
                    {
                        if (execution.ProcessDefinitionId is object)
                        {
                            IProcessDefinition processDefinition = commandContext.ProcessEngineConfiguration.DeploymentManager.FindDeployedProcessDefinitionById(execution.ProcessDefinitionId);
                            activityId = processDefinition.Key;
                        }
                    }
                    else
                    {
                        activityId = execution.ActivityId;
                    }

                    if (activityId is object)
                    {
                        Localize(execution, activityId);
                    }
                }
            }

            return(executions.Cast <IExecution>().ToList());
        }
        protected internal virtual void Localize(IHistoricProcessInstance processInstance, ICommandContext commandContext)
        {
            IHistoricProcessInstanceEntity processInstanceEntity = (IHistoricProcessInstanceEntity)processInstance;

            processInstanceEntity.LocalizedName        = null;
            processInstanceEntity.LocalizedDescription = null;

            if (_locale is object && processInstance.ProcessDefinitionId is object)
            {
                IProcessDefinition processDefinition = commandContext.ProcessEngineConfiguration.DeploymentManager.FindDeployedProcessDefinitionById(processInstanceEntity.ProcessDefinitionId);
                JToken             languageNode      = Context.GetLocalizationElementProperties(_locale, processDefinition.Key, processInstanceEntity.ProcessDefinitionId, _withLocalizationFallback);

                if (languageNode != null)
                {
                    JToken languageNameNode = languageNode[DynamicBpmnConstants.LOCALIZATION_NAME];
                    if (languageNameNode != null)
                    {
                        processInstanceEntity.LocalizedName = languageNameNode.ToString();
                    }

                    JToken languageDescriptionNode = languageNode[DynamicBpmnConstants.LOCALIZATION_DESCRIPTION];
                    if (languageDescriptionNode != null)
                    {
                        processInstanceEntity.LocalizedDescription = languageDescriptionNode.ToString();
                    }
                }
            }
        }
示例#23
0
        public bool Execute(ICommandContext commandContext)
        {
            ICommandExecutor commandExecutor = commandContext.ProcessEngineConfiguration.CommandExecutor;

            IProcessInstance processInstance = commandExecutor.Execute(new GetProcessInstanceByIdCmd(processInstanceId)) as IProcessInstance;

            if (processInstance is null)
            {
                throw new ActivitiException(string.Concat("Unable to find process instance for the given id: ", processInstanceId));
            }

            IProcessDefinition processDefinition = commandExecutor.Execute(new GetDeploymentProcessDefinitionCmd(processInstance.ProcessDefinitionId));

            if (processDefinition is null)
            {
                throw new ActivitiException(string.Concat("Unable to find process definition for the given id: ", processInstance.ProcessDefinitionId));
            }

            commandExecutor.Execute(new SetExecutionVariablesCmd(processInstance.Id, variables, false));

            string delReason = reason ?? "Cancelled";

            IList <ITask> tasks = commandExecutor.Execute(new GetTasksByProcessInstanceIdCmd(new string[] { processInstanceId }));

            foreach (var task in tasks)
            {
                commandExecutor.Execute(new AddCommentCmd(task.Id, processInstanceId, delReason));
            }

            commandExecutor.Execute(new DeleteProcessInstanceCmd(processInstanceId, delReason));

            return(true);
        }
示例#24
0
        public virtual void testSetRetriesWithQueryAsync()
        {
            // given
            IProcessDefinition processDefinition = testRule.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS);
            IProcessInstance   processInstance1  = engineRule.RuntimeService.StartProcessInstanceByKey("Process");
            IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTasks;

            IQueryable <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTaskQuery = engineRule.ExternalTaskService.CreateExternalTaskQuery();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("batchId", "*").BindResource("processInstance1", processInstance1.Id).BindResource("processDefinition", processDefinition.Key).Start();

            IBatch batch = engineRule.ExternalTaskService.SetRetriesAsync(null, externalTaskQuery, 5);

            if (batch != null)
            {
                executeSeedAndBatchJobs(batch);
            }

            // then
            if (authRule.AssertScenario(scenario))
            {
                externalTasks = engineRule.ExternalTaskService.CreateExternalTaskQuery()
                                .ToList();
                foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks)
                {
                    Assert.AreEqual(5, (int)task.Retries);
                }
            }
        }
示例#25
0
        /// <summary>
        /// Called when [after_ add class properties].
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="process">The process.</param>
        /// <param name="isInfoProperty">if set to <c>true</c> [is information property].</param>
        /// <param name="resolveRefTypes">if set to <c>true</c> [resolve reference types].</param>
        /// <param name="skipId">if set to <c>true</c> [skip identifier].</param>
        public override void OnAfter_AddClassProperties(StringBuilder assemblyCode, IProcessDefinition process, bool isInfoProperty, bool resolveRefTypes, bool skipId = false)
        {
            if (!isInfoProperty) return;

            foreach (var crf in process.RootTable.FieldList.Where(f => f.ColumnType == ColumnTypes.Reference && !f.IsHidden && f.IncludeInList))
            {
                assemblyCode.AppendFormat(@"
        private {1}Info _{0}Member;
        public {1}Info {0}Member
        {{ 
            get 
            {{
                if (_{0}Member == null && {0}Id > 0) 
                {{
                    var items = {1}List.Get{1}PageList(string.Empty, {0}Id, 1, null, null);
                    if (items.Count > 0) 
                    {{
                        _{0}Member = items[0];
                    }}
                }}
                return _{0}Member;
            }}
        }}
"
                    , crf.ColumnName, crf.ReferencedProcessName);
            }
        }
示例#26
0
        public void StartProcessInstance(long processDefinitionId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("StartProcessInstance processDefinitionId:" + processDefinitionId);
            }

            IExecutionSessionLocal  executionComponent  = null;
            IDefinitionSessionLocal definitionComponent = null;

            try
            {
                executionComponent  = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                IProcessDefinition processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId);

                Context.Flash["activity"]          = processDefinition.StartState;
                Context.Flash["processDefinition"] = processDefinition;
                Context.Flash["preview"]           = "activity";
                AddImageCoordinates(processDefinition.StartState);

                //create Form
                IActivityForm activityForm = executionComponent.GetStartForm(processDefinitionId);
                AddFormData(activityForm);
                RenderView("activityForm");
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
                ServiceLocator.Instance.Release(definitionComponent);
            }
        }
        /// <summary>
        /// This method is called after generation of all logic code in Editable Root AddBusinessRules method.
        /// </summary>
        /// <param name="code">Code holder.</param>
        /// <param name="process">Generating process definition.</param>
        public override void OnAfterEditableRootAddBusinessRules(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfterEditableRootAddBusinessRules(code, process);

            code.Append(@" BusinessRules.AddRule(new CalendarsWorkingIntervalsRule());");
            code.Append(@" BusinessRules.AddRule(new CalendarsUniqNameRule());"); 
        }
示例#28
0
        private IProcessInstance StartNewHolidayRequest(String actorId, IDictionary attributeValues)
        {
            IProcessInstance processInstance = null;

            testUtil.LoginUser(actorId);

            try
            {
                //      loginUtil.login( actorId, actorId );
                // start the process instance
                IProcessDefinition holidayRequest = definitionComponent.GetProcessDefinition("Holiday request");

                // perform the first activity
                processInstance = executionComponent.StartProcessInstance(holidayRequest.Id, attributeValues);
                Assert.IsNotNull(processInstance);
            }
            catch (ExecutionException e)
            {
                Assert.Fail("ExcecutionException while starting a new holiday request: " + e.Message);
            }
            finally
            {
                //      loginUtil.logout();
            }

            return(processInstance);
        }
示例#29
0
        /// <summary>
        /// Adds extra properties to EditableRoot.
        /// </summary>
        /// <param name="code">The source code under generation.</param>
        /// <param name="process">Current process.</param>
        public override void AddEditClassProperties(StringBuilder code, IProcessDefinition process)
        {
            base.AddEditClassProperties(code, process);

            foreach (var field in process.RootTable.FieldList.Where(f => f.ColumnType == ColumnTypes.Frequency))
            {
                code.AppendFormat(
                    @"
            public Cebos.Veyron.SharedTypes.FrequencyInfo {0}{4}
            {{
                get
                {{
                    return new Cebos.Veyron.SharedTypes.FrequencyInfo({0}, {0}{1}, {0}{2}, {0}{3});
                }}

                set
                {{
                    {0} = value.Name;
                    {0}{1} = value.FrequencyType;
                    {0}{2} = value.FrequencyHours;
                    {0}{3} = value.SelectedEvent;
                }}
            }}
",
                    field.SystemName,
                    Constants.FrequencyEventTypeFieldSuffix,
                    Constants.FrequencyEventHoursFieldSuffix,
                    Constants.FrequencyEventSelectedFrequencyFieldSuffix,
                    Constants.FrequencyEventInfoFieldSuffix);
            }
        }
        ///<inheritdoc />
        public virtual IProcessInstance Execute(ICommandContext commandContext)
        {
            if (messageName is null)
            {
                throw new ActivitiIllegalArgumentException("Cannot start process instance by message: message name is null");
            }

            IMessageEventSubscriptionEntity messageEventSubscription = commandContext.EventSubscriptionEntityManager.FindMessageStartEventSubscriptionByName(messageName, tenantId);

            if (messageEventSubscription == null)
            {
                throw new ActivitiObjectNotFoundException("Cannot start process instance by message: no subscription to message with name '" + messageName + "' found.", typeof(IMessageEventSubscriptionEntity));
            }

            string processDefinitionId = messageEventSubscription.Configuration;

            if (string.IsNullOrWhiteSpace(processDefinitionId))
            {
                throw new ActivitiException("Cannot start process instance by message: subscription to message with name '" + messageName + "' is not a message start event.");
            }

            DeploymentManager deploymentCache = commandContext.ProcessEngineConfiguration.DeploymentManager;

            IProcessDefinition processDefinition = deploymentCache.FindDeployedProcessDefinitionById(processDefinitionId);

            if (processDefinition == null)
            {
                throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", typeof(IProcessDefinition));
            }

            ProcessInstanceHelper processInstanceHelper = commandContext.ProcessEngineConfiguration.ProcessInstanceHelper;
            IProcessInstance      processInstance       = processInstanceHelper.CreateAndStartProcessInstanceByMessage(processDefinition, messageName, processVariables, transientVariables);

            return(processInstance);
        }
示例#31
0
        /// <summary>
        /// Editables the root_ generate control specific functions.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        public override void EditableRoot_GenerateControlSpecificFunctions(StringBuilder code, IProcessDefinition process)
        {
            base.EditableRoot_GenerateControlSpecificFunctions(code, process);

            foreach (var field in process.TableList[0].FieldList.Where(x => x.ColumnType == ColumnTypes.File && (x.ConvertToPdf || x.UseReport)))
            {
                if (string.IsNullOrEmpty(field.CoverPagePortraitReportName) && string.IsNullOrEmpty(field.CoverPageLandscapeReportName) &&
                    string.IsNullOrEmpty(field.WatermarkPortraitReportName) && string.IsNullOrEmpty(field.WatermarkLandscapeReportName) &&
                    string.IsNullOrEmpty(field.AppendixLandscapeReportName) && string.IsNullOrEmpty(field.AppendixPortraitReportName) &&
                    string.IsNullOrEmpty(field.ReportName)) continue;

                code.Append("\t\t\t").Append(@"
        [NonSerialized]
        [NotUndoable]
        private IFileManager _fileManager;

        public IFileManager TheFileManager
        {
            get 
            { 
                return _fileManager ??
                      (_fileManager = ImportDependency<IFileManager>());
            }
            set { _fileManager = value; }
        }
");
                return;
            }

        }
        //JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
        //ORIGINAL LINE: @Test public void testDeleteProcessDefinitionCascade()
        public virtual void testDeleteProcessDefinitionCascade()
        {
            // given process definition and a process instance
            IBpmnModelInstance bpmnModel = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess(PROCESS_DEFINITION_KEY).StartEvent().UserTask().EndEvent().Done();

            testHelper.Deploy(bpmnModel);

            IProcessDefinition processDefinition = repositoryService.CreateProcessDefinitionQuery(c => c.Key == PROCESS_DEFINITION_KEY).First();

            runtimeService.CreateProcessInstanceByKey(PROCESS_DEFINITION_KEY).ExecuteWithVariablesInReturn();

            authRule.Init(scenario).WithUser("userId").Start();

            //when the corresponding process definition is cascading deleted from the deployment
            repositoryService.DeleteProcessDefinition(processDefinition.Id, true);

            //then exist no process instance and no definition
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(0, runtimeService.CreateProcessInstanceQuery().Count());
                Assert.AreEqual(0, repositoryService.CreateProcessDefinitionQuery().Count());
                if (processEngineConfiguration.HistoryLevel.Id >= HistoryLevelFields.HistoryLevelActivity.Id)
                {
                    Assert.AreEqual(0, engineRule.HistoryService.CreateHistoricActivityInstanceQuery().Count());
                }
            }
        }
示例#33
0
 protected internal virtual void AssertMigratedTo(IHistoricActivityInstance activityInstance,
                                                  IProcessDefinition processDefinition, string activityId)
 {
     Assert.AreEqual(processDefinition.Id, activityInstance.ProcessDefinitionId);
     Assert.AreEqual(processDefinition.Key, activityInstance.ProcessDefinitionKey);
     Assert.AreEqual(activityId, activityInstance.ActivityId);
 }
示例#34
0
        public virtual void testMigrateWithQuery()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            IQueryable <IProcessInstance> query = engineRule.RuntimeService.CreateProcessInstanceQuery();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).BindResource("processInstance", processInstance.Id).Start();

            engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceQuery(query).Execute();

            // then
            if (authRule.AssertScenario(scenario))
            {
                IProcessInstance processInstanceAfterMigration = engineRule.RuntimeService.CreateProcessInstanceQuery().First();

                Assert.AreEqual(targetDefinition.Id, processInstanceAfterMigration.ProcessDefinitionId);
            }
        }
        /// <summary>
        /// Adds the editable root control specific methods.
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="process">The process.</param>
        public override void AddEditableRootControlSpecificMethods(StringBuilder assemblyCode, IProcessDefinition process)
        {
            base.AddEditableRootControlSpecificMethods(assemblyCode, process);

            assemblyCode.Append(@"
        public void Copy()
        {
            using (BypassPropertyChecks)
            {
                Locked = null;
                LockedByAccountId = null;
                LockedByAccountName = null;
                LastModifiedOn = DateTime.Now;
                IsNewVersion = true;
                ApplyEdit();
                Save(true);
            }
        }");

            //When we change IFileProcess, we need to add UploadFile(string fileName) method
            //and update FileFieldUpdater.Update()
            assemblyCode.Append(@"
        public void UploadFile()
        {
            DataPortal.Execute(new UploadFileCommand { FileName = FileName });
        }
        ");
        }
示例#36
0
        /// <summary>
        /// Called when [after_ editable child_ data portal_ fetch].
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        public override void OnAfter_EditableChild_DataPortal_Fetch(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfter_EditableChild_DataPortal_Fetch(code, process);

            AddUpdateApprovalMembers(code, process);
            AddLoadApprovalOverrideMembers(code, process);
        }
        public virtual void testMigrateWithQuery()
        {
            // given
            IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess);
            IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey));

            IProcessInstance instance1 = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);
            IProcessInstance instance2 = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);

            grantAuthorization("user", Resources.ProcessInstance, instance2.Id, Permissions.Read);
            grantAuthorization("user", Resources.ProcessDefinition, "*", Permissions.MigrateInstance);

            IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build();

            IQueryable <IProcessInstance> query = engineRule.RuntimeService.CreateProcessInstanceQuery();

            // when
            authRule.EnableAuthorization("user");
            engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceQuery(query).Execute();

            authRule.DisableAuthorization();


            // then
            IProcessInstance instance1AfterMigration = engineRule.RuntimeService.CreateProcessInstanceQuery(c => c.ProcessInstanceId == instance1.Id).First();

            Assert.AreEqual(sourceDefinition.Id, instance1AfterMigration.ProcessDefinitionId);
        }
        /// <summary>
        /// Called when [after_ editable root_ data portal_ create].
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        public override void OnAfter_EditableRoot_DataPortal_Create(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfter_EditableRoot_DataPortal_Create(code, process);

            code.AppendFormat(@"
            LoadProperty({0}Property, false);", Constants.OutOfOfficePropertyName).AppendLine();
        }
示例#39
0
        public void ShowHome(String preview, Int32 processDefinitionId, Int32 flowId)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("ShowHome preview:" + preview + " processDefinitionId:" + processDefinitionId + " flowId:" + flowId);
            }
            IDefinitionSessionLocal definitionComponent = null;
            IExecutionSessionLocal  executionComponent  = null;

            try
            {
                definitionComponent = ServiceLocator.Instance.GetService(typeof(IDefinitionSessionLocal)) as IDefinitionSessionLocal;
                executionComponent  = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal;
                //			IList taskList = executionComponent.GetTaskList(new Relations(new System.String[]{"processInstance.processDefinition"}));
                IList taskList           = executionComponent.GetTaskList();
                IList processDefinitions = definitionComponent.GetProcessDefinitions();
                // Collect data for the preview
                if (preview != null)
                {
                    if (preview.Equals("process"))
                    {
                        if (processDefinitionId == 0)
                        {
                            ArrayList errors = new ArrayList();
                            errors.Add("when parameter 'preview' is equal to 'process', a valid parameter 'processDefinitionId' should be provided as well,");
                            Context.Flash["errormessages"] = errors;
                        }

                        IProcessDefinition processDefinition = null;

                        // Get the processDefinition
                        processDefinition = definitionComponent.GetProcessDefinition(processDefinitionId);
                        Context.Flash["processDefinition"] = processDefinition;
                    }
                    else if (preview.Equals("activity"))
                    {
                        if (flowId == 0)
                        {
                            ArrayList errors = new ArrayList();
                            errors.Add("when parameter 'preview' is equal to 'activity', a valid parameter 'flowId' should be provided as well,");
                            Context.Flash["errormessages"] = errors;
                        }
                        //					IFlow flow = executionComponent.GetFlow(flowId, new Relations(new System.String[]{"processInstance.processDefinition"}));
                        IFlow flow = executionComponent.GetFlow(flowId);
                        Context.Flash["activity"] = flow.Node;
                        AddImageCoordinates((IState)flow.Node);
                        Context.Flash["processDefinition"] = flow.ProcessInstance.ProcessDefinition;
                    }
                }

                Context.Flash["taskList"]           = taskList;
                Context.Flash["processDefinitions"] = processDefinitions;
                Context.Flash["preview"]            = preview;
            }
            finally
            {
                ServiceLocator.Instance.Release(executionComponent);
                ServiceLocator.Instance.Release(definitionComponent);
            }
        }
示例#40
0
        public override void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
        {
            base.ReadProcessData(xmlElement, creationContext);

            // get the process definition for that name
            String subProcessDefinitionName = xmlElement.GetProperty("process");

            creationContext.Check(((Object)subProcessDefinitionName != null), "process is missing in the process state : " + subProcessDefinitionName);
            DbSession dbSession = creationContext.DbSession;

            dbSession.SaveOrUpdate(this._processDefinition);
            try
            {
                this._subProcess = (ProcessDefinitionImpl)dbSession.FindOne(queryFindProcessDefinitionByName, subProcessDefinitionName, DbType.STRING);
            }
            catch (SystemException e)
            {
                creationContext.AddError("process '" + subProcessDefinitionName + "' was not deployed while it is referenced in a process-state. Exception: " + e.Message);
            }

            // parse the processInvokerDelegation
            creationContext.DelegatingObject = this;
            this._processInvokerDelegation   = new DelegationImpl();
            XmlElement invocationElement = xmlElement.GetChildElement("process-invocation");

            creationContext.Check((invocationElement != null), "process-invocation is missing in the process-state : " + xmlElement);
            this._processInvokerDelegation.ReadProcessData(invocationElement, creationContext);

            creationContext.DelegatingObject = null;

            // parse the actorExpression
            this._actorExpression = xmlElement.GetProperty("actor-expression");
            creationContext.Check(((Object)_actorExpression != null), "actor-expression is missing in the process-state : " + xmlElement);
        }
示例#41
0
        /// <summary>
        /// This method is called before ActionManager.InvokeActions in EditableRoot.DataPortal_Update.
        /// </summary>
        /// <param name="code">
        /// The code.
        /// </param>
        /// <param name="process">
        /// The process.
        /// </param>
        public override void OnBefore_EditableRoot_DataPortal_Update_InvokeActions(StringBuilder code, IProcessDefinition process)
        {
            // Update action items if BasePerson.OutOfOffice changes.
            code.AppendFormat(@"
            ActionItemManager.CheckOutOfOffice(this, oldItem);
");
        }
示例#42
0
        public void StartTest()
        {
            IProcessInstance processInstance = null;

            Thread.CurrentPrincipal = new PrincipalUserAdapter("ae");

            try
            {
                IDictionary attributeValues = new Hashtable();

                IProcessDefinition booaction = processDefinitionService.GetProcessDefinition("Hello world 4");

                processInstance = executionComponent.StartProcessInstance(booaction.Id, attributeValues);
                //這時已經在First State
                Assert.IsNotNull(processInstance);
            }
            catch (ExecutionException e)
            {
                Assert.Fail("ExcecutionException while starting a new holiday request: " + e.Message);
            }
            finally
            {
                //      loginUtil.logout();
            }
        }
示例#43
0
        public virtual void testUpdateEventSubscriptionOnDeployment()
        {
            DeploymentId = repositoryService.CreateDeployment().AddClasspathResource(SIGNAL_START_EVENT_PROCESS).Deploy().Id;

            IEventSubscription eventSubscription = runtimeService.CreateEventSubscriptionQuery(c => c.EventType == "signal").First();

            Assert.NotNull(eventSubscription);
            Assert.AreEqual("alert", eventSubscription.EventName);

            // deploy a new version of the process with different signal name
            string newDeploymentId = repositoryService.CreateDeployment().AddClasspathResource(SIGNAL_START_EVENT_PROCESS_NEW_VERSION).Deploy().Id;

            IProcessDefinition newProcessDefinition = repositoryService.CreateProcessDefinitionQuery() /*.LatestVersion()*/.First();

            Assert.AreEqual(2, newProcessDefinition.Version);

            IList <IEventSubscription> newEventSubscriptions = runtimeService.CreateEventSubscriptionQuery(c => c.EventType == "signal").ToList();

            // only one event subscription for the new version of the process definition
            Assert.AreEqual(1, newEventSubscriptions.Count);

            var tmp = newEventSubscriptions.GetEnumerator();

            tmp.MoveNext();
            EventSubscriptionEntity newEventSubscription = (EventSubscriptionEntity)tmp.Current;

            Assert.AreEqual(newProcessDefinition.Id, newEventSubscription.Configuration);
            Assert.AreEqual("abort", newEventSubscription.EventName);

            // clean db
            repositoryService.DeleteDeployment(newDeploymentId);
        }
示例#44
0
		public ActivityFormImpl(IProcessDefinition processDefinition, IList fields, IDictionary attributeValues)
		{
			this._processDefinition = processDefinition;
			this._activityState = (IActivityState) processDefinition.StartState;
			this._fields = fields;
			this._attributeValues = attributeValues;
			InitTransitionNames(processDefinition.StartState);
		}
示例#45
0
        /// <summary>
        /// Adds the update approval members.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        private void AddUpdateApprovalMembers(StringBuilder code, IProcessDefinition process)
        {
            if (process.RootTable.FieldList.All(f => f.ColumnType != ColumnTypes.Approval))
                return;

            code.AppendFormat(@"
            UpdateApprovalMembers();");
        }
示例#46
0
 public override void OnBefore_EditableRoot_DataPortal_Insert_UpdateChildren(StringBuilder code, IProcessDefinition process)
 {
     foreach (var gageField in process.RootTable.FieldList.Where(x => x.ColumnType == ColumnTypes.GageRR))
     {
         code.AppendFormat(@"
     DataPortal.UpdateChild({0}_Member, new MsaUpdateCriteria{{ParentId = Id, Connection = connection}});", gageField.SystemName);
     }
 }
        /// <summary>
        /// This method is called after generation of all logic code in Editable Root AddBusinessRules method.
        /// </summary>
        /// <param name="code">Code holder.</param>
        /// <param name="process">Generating process definition.</param>
        public override void OnAfterEditableRootAddBusinessRules(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfterEditableRootAddBusinessRules(code, process);

            code.Append(@"BusinessRules.AddRule(new FrequencyPatternNameRule(NameProperty));")
                .AppendLine()
                .Append(@"BusinessRules.AddRule(new FrequencyPatternPatternTypeRule(PatternTypeProperty));");
        }
示例#48
0
        /// <summary>
        /// Called when [after_ editable root_ data portal_ insert].
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        public override void OnAfter_EditableRoot_DataPortal_Insert(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfter_EditableRoot_DataPortal_Insert(code, process);
            if (process.RootTable.FieldList.All(f => f.ColumnType != ColumnTypes.AutoNumber)) return;

            code.AppendLine(@"
                }");
        }
示例#49
0
        /// <summary>
        /// Called when [after_ editable root_ data portal_ create].
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="process">The process.</param>
        public override void OnAfter_EditableRoot_DataPortal_Create(StringBuilder code, IProcessDefinition process)
        {
            base.OnAfter_EditableRoot_DataPortal_Create(code, process);

             foreach (var sample in process.SampleFields.Values)
             {
                 code.AppendFormat("\r\n\t\t\tLoadProperty({0}Property, {0}SampleList.GetSampleList(new DynamicSampleCriteria(this)));", sample.Name);
             }
        }        
        private IEnumerable<string> GetSourceFields(IProcessDefinition process, TableFieldDefinition field, string expression, bool onlyRoot)
        {
            var sourceFields = ExpressionService.GetExpressionSourceFields(expression, onlyRoot).ToArray();
            var allSourceFields = sourceFields.Concat(sourceFields.Select(x => x + "Member"));
            var localization = field.Localization ?? process.DefaultLocalization;
            allSourceFields = allSourceFields.Concat(sourceFields.Select(x => LocalizationUtils.GetLocalizedFieldName(x, localization.Culture.Name)));

            return allSourceFields;
        }
 /// <summary>
 /// This method is called after generation of all logic code in Editable Root OnChildChanged method.
 /// </summary>
 /// <param name="code">Code holder.</param>
 /// <param name="process">Generating process definition.</param>
 public override void OnAfter_EditableRoot_OnChildChanged(StringBuilder code, IProcessDefinition process)
 {
     base.OnAfter_EditableRoot_OnChildChanged(code, process);
     code.Append(@"
     CheckPropertyRules(NameProperty);
     CheckPropertyRules(WorkingIntervalsProperty);
     CheckPropertyRules(WorkingExceptionsProperty);
                  ");
 }
        /// <summary>
        /// Called when generator needs to fill process ReadOnlyList class interfaces.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <returns>Collection of ReadOnlyList interface names.</returns>
        public override IEnumerable<string> GetReadOnlyListInterfaceNames(IProcessDefinition process)
        {
            foreach (var interfaceName in base.GetReadOnlyListInterfaceNames(process))
            {
                yield return interfaceName;
            }

            yield return string.Format(CultureInfo.InvariantCulture, "IFavoriteList<{0}>", GetInfoClassName(process));
        }
示例#53
0
        /// <summary>
        /// Called when [after_ editable child_ data portal_ fetch].
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="process">The process.</param>
        public override void OnAfter_EditableChild_DataPortal_Fetch(StringBuilder assemblyCode, IProcessDefinition process)
        {
            base.OnAfter_EditableChild_DataPortal_Fetch(assemblyCode, process);
            if (process.Checklists == null)
                return;

            foreach (var checklist in process.Checklists.Values)
                assemblyCode.AppendFormat("\r\n\t\t\tSet{0}Property(false, null, System.Linq.Enumerable.Empty<string>());\r\n", checklist.Name);
        }
        public override void EditableRoot_GenerateControlSpecificFunctions(StringBuilder code, IProcessDefinition process)
        {
            base.EditableRoot_GenerateControlSpecificFunctions(code, process);

            if (process.IsVersioningEnabled)
            {
                AddSaveNewVersionReverseCrossReferenceFieldsMethod(code, process);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyGeneratorContext"/> class.
 /// </summary>
 /// <param name="process">The process.</param>
 /// <param name="assemblyType">The assembly type.</param>
 /// <param name="pubInfo">The pub info.</param>
 public AssemblyGeneratorContext(
     IProcessDefinition process,
     AssemblyType assemblyType = AssemblyType.Client,
     PublisherInformation pubInfo = null)
 {
     PubInfo = pubInfo;
     AssemblyType = assemblyType;
     Process = process;
 }
示例#56
0
		public ActivityFormImpl(FlowImpl flow, IList fields, IDictionary attributeValues)
		{
			this._flow = flow;
			this._processInstance = flow.ProcessInstance;
			this._processDefinition = _processInstance.ProcessDefinition;
			this._activityState = (IActivityState) flow.Node;
			this._fields = fields;
			this._attributeValues = attributeValues;
			InitTransitionNames(flow.Node);
		}
        /// <summary>
        /// Adds extra methods to Read-only list.
        /// </summary>
        /// <param name="code">The source code under generation.</param>
        /// <param name="process">Current process.</param>
        public override void AddReadOnlyListClassMethods(System.Text.StringBuilder code, IProcessDefinition process)
        {
            code.Append(
                @"
        public new IEnumerator<IFilterInfo> GetEnumerator()
        {
            return base.GetEnumerator();
        }
");
        }
        /// <summary>
        /// This method is called after generation of all logic code in Editable Root AddBusinessRules method.
        /// </summary>
        /// <param name="code">Code holder.</param>
        /// <param name="process">Generating process definition.</param>
        public override void OnAfterEditableRootAddBusinessRules(StringBuilder code, IProcessDefinition process)
        {
            foreach(var field in process.RootTable.FieldList.Where(f => f.ColumnType == ColumnTypes.Reference))
            {
                code.AppendFormat(
                    @"
            BusinessRules.AddRule(new Cebos.Veyron.SharedTypes.Rules.SingleCrossReferenceValueShouldBePositiveRule({0}Property));
", field.SystemName);
            }
        }
        /// <summary>
        /// Adds the existing records classes.
        /// </summary>
        /// <param name="assemblyCode">The assembly code.</param>
        /// <param name="processView">The process view.</param>
        /// <param name="viewConfig">The view configuration.</param>
        /// <param name="process">The process.</param>
        /// <param name="assemblyGenerator">The assembly generator.</param>
        private static void AddExistingRecordsClasses(StringBuilder assemblyCode, IProcessView processView, DataCollectProcessViewConfigurator viewConfig, IProcessDefinition process, AssemblyGeneratorBase assemblyGenerator)
        {
            var dcConfig = (DataCollectViewConfig) processView.ViewConfiguration;
            var table = new TableDefinition { Name = process.Name };

            assemblyCode.AppendFormat(
               @"
    [Serializable]
    public class {0} : BaseReferenceInfo<{0}>
    {{
        {1}

        public static ReferenceFieldDefinition GetFieldDefinition()
        {{
            ReferenceFieldDefinition fieldDefinition = null;
{2}
            return fieldDefinition;
        }}
    }}
",
               GetExistingRecordsChildClassName(processView, viewConfig, process),
               AssemblyGeneratorBase.GetDisplaylistRefEditableChildProperties(table, dcConfig.ReferenceField),
               assemblyGenerator.GetReferenceDefinition(new TableDefinition {Name = process.Name}, dcConfig.ReferenceField, "fieldDefinition"));

            assemblyCode.AppendFormat(
       @"
    [Serializable]
    public class {0} : BaseReferenceInfoList<{0}, {1}>
    {{
        public static void BeginGetList(int pageNumber, int pageSize, SortList sorting, string filter, System.Action<object, IDataPortalResult> callback)
        {{
            DataPortal.BeginFetch<{0}>(new PagedCriteria {{ PageNumber = pageNumber, PageSize = pageSize, SortColumns = sorting, Filter = filter }}, (o, result) => callback(o, result));
        }}

        public void Assign(IReverseCrossReferenceItem item)
        {{
            IsReadOnly = false;
            Add(({1})item);
            IsReadOnly = true;
        }}

        public void Load(IEnumerable<IReverseCrossReferenceItem> items)
        {{
            IsReadOnly = false;

            Clear();
            AddRange(items.Cast<{1}>());

            IsReadOnly = true;
        }}
    }}
",
GetExistingRecordsListClassName(processView, viewConfig, process),
GetExistingRecordsChildClassName(processView, viewConfig, process));
        }
示例#60
0
        public virtual void ReadProcessData(XmlElement xmlElement, ProcessDefinitionBuildContext creationContext)
		{
			this._processDefinition = creationContext.ProcessDefinition;

			Type delegatingObjectClass = creationContext.DelegatingObject.GetType();
			if (delegatingObjectClass == typeof (AttributeImpl))
			{
				String type = xmlElement.GetProperty("type");
				if ((Object) type != null)
				{
					this._className = ((String) attributeTypes[type]);
					string suportedTypes = "supported types: ";
					foreach (Object o in attributeTypes.Keys)
					{
						suportedTypes += o.ToString() + " ,";				
					}
					creationContext.Check(((Object) this._className != null), "attribute type '" + type + "' is not supported. " + suportedTypes +" !");
				}
				else
				{
					this._className = xmlElement.GetProperty("serializer");
					creationContext.Check(((Object) this._className != null), "for an attribute, you must specify either a type or a serializer");
				}
			}
			else if (delegatingObjectClass == typeof (FieldImpl))
			{
				this._className = xmlElement.GetProperty("class");
				creationContext.Check(((Object) this._className != null), "no class specified for a delegation : " + xmlElement);
			}
			else
			{
				this._className = xmlElement.GetProperty("handler");
				creationContext.Check(((Object) this._className != null), "no handler specified for a delegation : " + xmlElement);
			}

			log.Debug("parsing delegation for tag '" + xmlElement.Name + "' : " + this._className);

			// parse the exception handler    
			String exceptionHandlerText = xmlElement.GetAttribute("on-exception");
			if ((Object) exceptionHandlerText != null)
			{
				_exceptionHandlingType = ExceptionHandlingTypeHelper.FromText(exceptionHandlerText);
				creationContext.Check((_exceptionHandlingType != 0), "unknown exception handler '" + exceptionHandlerText + "' in delegation " + xmlElement);
			}

			// create the configuration string
			XmlElement configurationXml = new XmlElement("cfg");
			IEnumerator iter = xmlElement.GetChildElements("parameter").GetEnumerator();
			while (iter.MoveNext())
			{
				configurationXml.AddChild((XmlElement) iter.Current);
			}
			_configuration = configurationXml.ToString();
		}