Example #1
0
        // source ////////////////////////////////////////////////////////

        public virtual object getSource(VariableScope variableScope)
        {
            if (sourceValueProvider is ConstantValueProvider)
            {
                string variableName = (string)sourceValueProvider.getValue(variableScope);

                return(variableScope.getVariableTyped(variableName));
            }
            else
            {
                return(sourceValueProvider.getValue(variableScope));
            }
        }
Example #2
0
 public virtual TypedValue resolve(string variableName)
 {
     return(variableScope.getVariableTyped(variableName));
 }
Example #3
0
        public virtual FormField createFormField(ExecutionEntity executionEntity)
        {
            FormFieldImpl formField = new FormFieldImpl();

            // set id
            formField.Id = id;

            // set label (evaluate expression)
            VariableScope variableScope = executionEntity != null ? executionEntity : StartProcessVariableScope.SharedInstance;

            if (label != null)
            {
                object labelValueObject = label.getValue(variableScope);
                if (labelValueObject != null)
                {
                    formField.Label = labelValueObject.ToString();
                }
            }

            formField.BusinessKey = businessKey;

            // set type
            formField.Type = type;

            // set default value (evaluate expression)
            object defaultValue = null;

            if (defaultValueExpression != null)
            {
                defaultValue = defaultValueExpression.getValue(variableScope);

                if (defaultValue != null)
                {
                    formField.DefaultValue = type.convertFormValueToModelValue(defaultValue);
                }
                else
                {
                    formField.DefaultValue = null;
                }
            }

            // value
            TypedValue value = variableScope.getVariableTyped(id);

            if (value != null)
            {
                formField.Value = type.convertToFormValue(value);
            }
            else
            {
                // first, need to convert to model value since the default value may be a String Constant specified in the model xml.
                TypedValue typedDefaultValue = type.convertToModelValue(Variables.untypedValue(defaultValue));
                // now convert to form value
                formField.Value = type.convertToFormValue(typedDefaultValue);
            }

            // properties
            formField.Properties = properties;

            // validation
            IList <FormFieldValidationConstraint> validationConstraints = formField.ValidationConstraints;

            foreach (FormFieldValidationConstraintHandler validationHandler in validationHandlers)
            {
                // do not add custom validators
                if (!"validator".Equals(validationHandler.name))
                {
                    validationConstraints.Add(validationHandler.createValidationConstraint(executionEntity));
                }
            }

            return(formField);
        }