예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationField"/> class.
 /// </summary>
 /// <param name="owner">The owner.</param>
 /// <param name="isGroupingField">If <c>true</c> then this field is treated as group. 
 /// It lacks of Out connector and its sub-fields ain't removed when it is collapsed. 
 /// <c>false</c> is by default.</param>
 public DestinationField(ExpressionObjectBase owner, bool isGroupingField = false) : this(owner)
 {
     if (isGroupingField)
     {
         IsGroupingField = true;
         IsGroupCollapsed = true;
         KeepSubfieldsAlive = true;
         HideConnector = true;
     }
 }
예제 #2
0
        private SourceField CreateField(ExpressionObjectBase owner, string name, PropertyInfo property)
        {
            var dataType = SourceNodeFactory.GetDataType(property.PropertyType);

            return new SourceField(owner)
                       {
                           DataType = dataType,
                           Name = name,
                           ConnectorOut = { DataType = dataType, Name = name },
                           SetName = SetName,
                           SystemName = property.Name,
                           InnerName = property.Name
                       };
        }
예제 #3
0
        private ExpressionNode ToExpressionNode(ExpressionObjectBase expressionObject, Connection connection)
        {
            if (!expressionObject.IsValid)
                throw new IncompleteTreeException(expressionObject);

            if (expressionObject is SourceFieldList)
                return ToSourceExpressionNode((SourceFieldList)expressionObject, connection);

            switch (expressionObject.Type)
            {
                case ExpressionNodeType.CustomFunction:
                    return ToCustomFunctionNodeNode(expressionObject);
                case ExpressionNodeType.ToUpper:
                    return new ToUpperFunctionNode(ToExpressionNode(((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection.Source.Owner,
                        ((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection));

                case ExpressionNodeType.ToLower:
                    return new ToLowerFunctionNode(ToExpressionNode(((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection.Source.Owner,
                        ((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection));

                case ExpressionNodeType.Trim:
                    return new TrimFunctionNode(ToExpressionNode(((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection.Source.Owner,
                        ((OneInOneOutExpression)expressionObject).ConnectorIn.Connection.Source.Connection));

                case ExpressionNodeType.Concat:
                    return new ConcatFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Left:
                    return new LeftSubStringFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection));

                case ExpressionNodeType.Right:
                    return new RightSubStringFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Add:
                    return new AddFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Subtract:
                    return new SubtractFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Divide:
                    return new DivideFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Multiply:
                    return new MultiplyFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.Constant:
                    return new ConstantNode(((ConstantExpression)expressionObject).ConnectorOut.Connection.Source.Connection.Source.DataType,
                        ((ConstantExpression)expressionObject).Value);

                case ExpressionNodeType.IsLess:
                    return new IsLessFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.IsGreater:
                    return new IsGreaterFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.If:
                    if (((ThreeInOneOutExpression)expressionObject).Connector1In.Connection == null
                        || ((ThreeInOneOutExpression)expressionObject).Connector2In.Connection == null
                        || ((ThreeInOneOutExpression)expressionObject).Connector3In.Connection == null)
                        throw new IncompleteTreeException(expressionObject);

                    return new IfStatementNode(ToExpressionNode(((ThreeInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((ThreeInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((ThreeInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((ThreeInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection),
                        ToExpressionNode(((ThreeInOneOutExpression)expressionObject).Connector3In.Connection.Source.Connection.Source.Owner,
                            ((ThreeInOneOutExpression)expressionObject).Connector3In.Connection.Source.Connection));

                case ExpressionNodeType.AddDays:
                    return new AddDaysFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

                case ExpressionNodeType.DateDiffDays:
                    return new DateDiffDaysFunctionNode(ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector1In.Connection.Source.Connection),
                        ToExpressionNode(((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection.Source.Owner,
                            ((TwoInOneOutExpression)expressionObject).Connector2In.Connection.Source.Connection));

            }

            return null;
        }
예제 #4
0
        private CustomFunctionNode ToCustomFunctionNodeNode(ExpressionObjectBase customFunction)
        {
            var customFunctionNode = new CustomFunctionNode(customFunction.FunctionName);

            foreach (var connection in customFunction.ConnectorsIn)
            {
                customFunctionNode.Expressions.Add(ToExpressionNode(connection.Connection.Source.Connection.Source.Owner,
                    connection.Connection.Source.Connection));
            }

            return customFunctionNode;
        }
        private static SourceField CreateFileSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            var result = new SourceField(owner)
                             {
                                 DataType = NodeDataType.File,
                                 Name = field.Name,
                                 ConnectorOut = { DataType = NodeDataType.File, Name = field.Name },
                                 SetName = SourceFieldSetNames.Item,
                                 InnerName = field.SystemName,
                                 SystemName = field.SystemName,
                                 SubfieldsRetriever = new FileSubfieldsRetriever(SourceFieldSetNames.Item)
                             };

            return result;
        }
        private static SourceField CreateSampleSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            var result = new SourceField(owner)
                             {
                                 DataType = NodeDataType.List,
                                 Name = field.Name,
                                 ConnectorOut = { DataType = NodeDataType.List, Name = field.Name },
                                 SetName = SourceFieldSetNames.Item,
                                 InnerName = string.Format("{0}List", field.SystemName),
                                 SystemName = string.Format("{0}List", field.SystemName),
                                 SubfieldsRetriever = new SampleSubfieldsRetriever(SourceFieldSetNames.Item)
                             };

            return result;
        }
        /// <summary>
        /// Creates the reverse cross reference source field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>SourceField.</returns>
        /// <exception cref="System.InvalidOperationException">Invalid field type.</exception>
        private static SourceField CreateReverseCrossReferenceSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            if (field.ColumnType == ColumnTypes.ReverseReference)
            {
                return new SourceField(owner)
                {
                    DataType = NodeDataType.ReverseCrossReference,
                    Name = field.Name,
                    ConnectorOut = { DataType = NodeDataType.ReverseCrossReference, Name = field.Name },
                    SetName = SourceFieldSetNames.Item,
                    InnerName = field.SystemName,
                    SystemName = string.Format("{0}Member", field.SystemName),
                    SubfieldsRetriever = new ReverseCrossReferenceSubfieldsRetriever(field.Id)
                };
            }

            if (field.ColumnType == ColumnTypes.ReverseMultiReference)
            {
                var result = new SourceField(owner)
                    {
                        DataType = NodeDataType.List,
                        Name = field.Name,
                        ConnectorOut = { DataType = NodeDataType.List, Name = field.Name },
                        SetName = SourceFieldSetNames.Item,
                        InnerName = string.Format("{0}List", field.SystemName),
                        SystemName = string.Format("{0}List", field.SystemName),
                        SubfieldsRetriever = new ReverseCrossReferenceSubfieldsRetriever(field.Id)
                    };

                return result;
            }

            throw new InvalidOperationException("Invalid field type.");
        }
        /// <summary>
        /// Creates the result source field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>SourceField.</returns>
        private static SourceField CreateResultSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            var result = new SourceField(owner)
            {
                DataType = NodeDataType.Result,
                Name = field.Name,
                ConnectorOut = { DataType = NodeDataType.Result, Name = field.Name },
                SetName = SourceFieldSetNames.Item,
                InnerName = field.SystemName,
                SystemName = field.SystemName
            };

            return result;
        }
        /// <summary>
        /// Creates the generic source field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>SourceField.</returns>
        private static SourceField CreateGenericSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            var dataType = SourceNodeFactory.GetDataType(GetType(field.ColumnType));
            var result = new SourceField(owner)
                {
                    DataType = dataType,
                    Name = field.Name,
                    ConnectorOut = { DataType = dataType, Name = field.Name },
                    SetName = SourceFieldSetNames.Item,
                    InnerName = field.SystemName,
                    SystemName = field.SystemName
                };

            return result;
        }
        /// <summary>
        /// Creates the source field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="owner">The owner.</param>
        /// <returns>SourceField.</returns>
        private static SourceField CreateSourceField(IProcessField field, ExpressionObjectBase owner)
        {
            switch (field.ColumnType)
            {
                case ColumnTypes.Reference:
                case ColumnTypes.MultiReference:
                    return CreateCrossReferenceSourceField(field, owner);

                case ColumnTypes.ReverseReference:
                case ColumnTypes.ReverseMultiReference:
                    return CreateReverseCrossReferenceSourceField(field, owner);

                case ColumnTypes.Checklist:
                    return CreateChecklistSourceField(field, owner);

                case ColumnTypes.DisplayList:
                    return CreateDisplayListSourceField(field, owner);

                case ColumnTypes.Sample:
                    return CreateSampleSourceField(field, owner);

                case ColumnTypes.File:
                    return CreateFileSourceField(field, owner);

                case ColumnTypes.Result:
                    return CreateResultSourceField(field, owner);

                default:
                    return CreateGenericSourceField(field, owner);
            }
        }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SourceField"/> class.
 /// </summary>
 /// <param name="owner">The owner.</param>
 public SourceField(ExpressionObjectBase owner)
 {
     ConnectorOut = new ConnectorOut(owner);
     Id = ConnectorOut.Id;
 }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectorIn"/> class.
 /// </summary>
 /// <param name="owner">The owner.</param>
 public ConnectorIn(ExpressionObjectBase owner)
     : base(owner)
 {
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DestinationField"/> class.
 /// </summary>
 /// <param name="owner">The owner.</param>
 public DestinationField(ExpressionObjectBase owner)
 {
     ConnectorIn = new ConnectorIn(owner);
     Id = ConnectorIn.Id;
 }