Example #1
0
	  public virtual object execute(CommandContext commandContext)
	  {
		ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
		DeploymentCache deploymentCache = processEngineConfiguration.DeploymentCache;
		ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
		ensureNotNull("Process Definition '" + processDefinitionId + "' not found", "processDefinition", processDefinition);

		foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
		{
		  checker.checkReadProcessDefinition(processDefinition);
		}

		StartFormHandler startFormHandler = processDefinition.StartFormHandler;
		if (startFormHandler == null)
		{
		  return null;
		}

		FormEngine formEngine = Context.ProcessEngineConfiguration.FormEngines[formEngineName];

		ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);

		StartFormData startForm = startFormHandler.createStartFormData(processDefinition);

		object renderedStartForm = null;
		try
		{
		  renderedStartForm = formEngine.renderStartForm(startForm);
		}
		catch (ScriptEvaluationException e)
		{
		  LOG.exceptionWhenStartFormScriptEvaluation(processDefinitionId, e);
		}
		return renderedStartForm;
	  }
Example #2
0
        public virtual object renderStartForm(StartFormData startForm)
        {
            if (string.ReferenceEquals(startForm.FormKey, null))
            {
                return(null);
            }
            string formTemplateString = getFormTemplateString(startForm, startForm.FormKey);

            return(executeScript(formTemplateString, null));
        }
Example #3
0
        public virtual void testGetStartFormData()
        {
            // given
            string processDefinitionId = selectProcessDefinitionByKey(FORM_PROCESS_KEY).Id;

            createGrantAuthorization(PROCESS_DEFINITION, FORM_PROCESS_KEY, userId, READ);

            // when
            StartFormData startFormData = formService.getStartFormData(processDefinitionId);

            // then
            assertNotNull(startFormData);
            assertEquals("deployment:org/camunda/bpm/engine/test/api/form/start.form", startFormData.FormKey);
        }
Example #4
0
        // GetStartForm test
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetStartFormWithAuthenticatedTenant()
        public virtual void testGetStartFormWithAuthenticatedTenant()
        {
            testRule.deployForTenant(TENANT_ONE, "org/camunda/bpm/engine/test/api/authorization/formKeyProcess.bpmn20.xml");

            ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY);

            identityService.setAuthentication("aUserId", null, Arrays.asList(TENANT_ONE));

            StartFormData startFormData = formService.getStartFormData(instance.ProcessDefinitionId);

            // then
            assertNotNull(startFormData);
            assertEquals("aStartFormKey", startFormData.FormKey);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testStartFormDefaultValue() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testStartFormDefaultValue()
        {
            string processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("FormPropertyDefaultValueTest.testDefaultValue").latestVersion().singleResult().Id;

            StartFormData startForm = formService.getStartFormData(processDefinitionId);


            IList <FormProperty> formProperties = startForm.FormProperties;

            assertEquals(4, formProperties.Count);

            foreach (FormProperty prop in formProperties)
            {
                if ("booleanProperty".Equals(prop.Id))
                {
                    assertEquals("true", prop.Value);
                }
                else if ("stringProperty".Equals(prop.Id))
                {
                    assertEquals("someString", prop.Value);
                }
                else if ("longProperty".Equals(prop.Id))
                {
                    assertEquals("42", prop.Value);
                }
                else if ("longExpressionProperty".Equals(prop.Id))
                {
                    assertEquals("23", prop.Value);
                }
                else
                {
                    assertTrue("Invalid form property: " + prop.Id, false);
                }
            }

            // Override 2 properties. The others should pe posted as the default-value
            IDictionary <string, string> formDataUpdate = new Dictionary <string, string>();

            formDataUpdate["longExpressionProperty"] = "1";
            formDataUpdate["booleanProperty"]        = "false";
            ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataUpdate);

            assertEquals(false, runtimeService.getVariable(processInstance.Id, "booleanProperty"));
            assertEquals("someString", runtimeService.getVariable(processInstance.Id, "stringProperty"));
            assertEquals(42L, runtimeService.getVariable(processInstance.Id, "longProperty"));
            assertEquals(1L, runtimeService.getVariable(processInstance.Id, "longExpressionProperty"));
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public org.camunda.bpm.engine.variable.VariableMap execute(final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext)
        public override VariableMap execute(CommandContext commandContext)
        {
            StartFormData startFormData = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext));

            ProcessDefinition definition = startFormData.ProcessDefinition;

            checkGetStartFormVariables((ProcessDefinitionEntity)definition, commandContext);

            VariableMap result = new VariableMapImpl();

            foreach (FormField formField in startFormData.FormFields)
            {
                if (formVariableNames == null || formVariableNames.Contains(formField.Id))
                {
                    result.put(formField.Id, createVariable(formField, null));
                }
            }

            return(result);
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCustomStartFormHandlerExecutesQuery()
        public virtual void testCustomStartFormHandlerExecutesQuery()
        {
            // given
            startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);

            string processDefinitionId = selectProcessDefinitionByKey(DEFAULT_PROCESS_KEY).Id;

            createGrantAuthorization(PROCESS_DEFINITION, DEFAULT_PROCESS_KEY, userId, READ);

            // when
            StartFormData startFormData = formService.getStartFormData(processDefinitionId);

            // then
            assertNotNull(startFormData);

            assertNotNull(MyDelegationService.CURRENT_AUTHENTICATION);
            assertEquals(userId, MyDelegationService.CURRENT_AUTHENTICATION.UserId);

            assertEquals(Convert.ToInt64(5), MyDelegationService.INSTANCES_COUNT);
        }
Example #8
0
 public virtual object renderStartForm(StartFormData startForm)
 {
     return(renderFormData(startForm));
 }