Exemplo n.º 1
0
        private SourceFieldNode ToSourceExpressionNode(SourceFieldList expressionObject, Connection connection)
        {
            if (!expressionObject.IsValid)
                throw new IncompleteTreeException(expressionObject);


            var field = expressionObject.GetSourceFieldForConnection(connection.Source);

            var fieldName = field.GetName();

            if (_values.ContainsKey(fieldName))
            {
                var value = _values[fieldName];
                return new SourceFieldNode(field.DataType, fieldName, value, field.SetName, field.InnerName, field.SystemName);
            }

            return new SourceFieldNode(field.DataType, fieldName, null, field.SetName, field.InnerName, field.SystemName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts to source.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="sourceType">Type of the source.</param>
        /// <param name="propertyFilter">The property filter.</param>
        /// <param name="setName">Name of the set.</param>
        /// <returns>SourceFieldList.</returns>
        public static SourceFieldList ConvertToSource(string name, Type sourceType, Func<PropertyInfo, bool> propertyFilter, string setName)
        {
            var result = new SourceFieldList {ExpressionName = name};

            var properties = sourceType.GetProperties();

            foreach (var property in properties.Where(propertyFilter))
            {
                var sf = new SourceField(result)
                             {
                                 Name = property.Name,
                                 ConnectorOut = {DataType = GetDataType(property.PropertyType), Name = property.Name},
                                 SetName = setName,
                                 InnerName = property.Name
                             };
                sf.Id = sf.ConnectorOut.Id;
                result.Fields.Add(sf);
            }

            return result;
        }
        public void AddIdFieldsFromPublishedProcessInfoTest()
        {
            // Arrange.
            const string ObjectName = "testObject";
            const string SetName = "TestItem";

            var vm = new ExpressionDesignerWindowViewModelBase();
            var accessor = new PrivateAccessor(vm);

            var baseProcess = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => baseProcess.BaseProcess).Returns((PublishedProcessInfo)null);

            var derivedProcess = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => derivedProcess.BaseProcess).Returns(baseProcess);

            var baseFields = new SourceFieldList();
            var derivedFields = new SourceFieldList();

            // Act.
            accessor.CallMethod("AddIdFields", baseProcess, baseFields, ObjectName, SetName);
            accessor.CallMethod("AddIdFields", derivedProcess, derivedFields, ObjectName, SetName);

            // Assert.
            //Assert.AreEqual(1, baseFields.Fields.Count);

            //var idField = baseFields.Fields.First(f => f.SystemName == Constants.IdColumnName);

            //Assert.AreEqual(NodeDataType.Int, idField.DataType);
            //Assert.AreEqual("Id", idField.Name);
            //Assert.AreEqual(Constants.IdColumnName, idField.SystemName);
            //Assert.AreEqual(Constants.IdColumnName, idField.InnerName);
            //Assert.AreEqual(SetName, idField.SetName);
            //Assert.AreEqual(ObjectName, idField.ObjectName);

            Assert.AreEqual(1, derivedFields.Fields.Count);
            //idField = derivedFields.Fields.First(f => f.SystemName == Constants.IdColumnName);
            var baseIdField = derivedFields.Fields.First(f => f.SystemName == Constants.BaseIdColumnName);

            //Assert.AreEqual(NodeDataType.Int, idField.DataType);
            //Assert.AreEqual("Id", idField.Name);
            //Assert.AreEqual(Constants.IdColumnName, idField.SystemName);
            //Assert.AreEqual(Constants.IdColumnName, idField.InnerName);
            //Assert.AreEqual(SetName, idField.SetName);
            //Assert.AreEqual(ObjectName, idField.ObjectName);

            Assert.AreEqual(NodeDataType.Int, baseIdField.DataType);
            Assert.AreEqual("Base Id", baseIdField.Name);
            Assert.AreEqual(Constants.BaseIdColumnName, baseIdField.SystemName);
            Assert.AreEqual(Constants.BaseIdColumnName, baseIdField.InnerName);
            Assert.AreEqual(SetName, baseIdField.SetName);
            Assert.AreEqual(ObjectName, baseIdField.ObjectName);
        }
        /// <summary>
        /// Adds state-related system fields.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="source">The source field list.</param>
        /// <param name="objectName">The source object name.</param>
        /// <param name="sourceFieldsSetName">The source fields set name.</param>
        /// <exception cref="System.ArgumentNullException">
        /// process
        /// or
        /// source
        /// </exception>
        /// <exception cref="ArgumentNullException">The <paramref name="process" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source" /> parameter is null.</exception>
        protected void AddStateFields(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName)
        {
            const string CurrentStateName = "Current State";
            const string CurrentStateSystemName = "CurrentStateName";

            if (process == null)
                throw new ArgumentNullException("process");

            if (source == null)
                throw new ArgumentNullException("source");

            if (!process.IsStateEnabled)
                return;

            var dataType = SourceNodeFactory.GetDataType(typeof(string));

            var sf = new SourceField(source)
                         {
                             DataType = dataType,
                             Name = CurrentStateName,
                             ConnectorOut = { DataType = dataType, Name = CurrentStateName },
                             ObjectName = objectName,
                             SetName = sourceFieldsSetName,
                             InnerName = CurrentStateSystemName,
                             SystemName = CurrentStateSystemName
                         };
            source.Fields.Add(sf);

            dataType = SourceNodeFactory.GetDataType(typeof(DateTime));
            sf = new SourceField(source)
                     {
                         DataType = dataType,
                         Name = Constants.StateModifiedDisplayName,
                         ConnectorOut = { DataType = dataType, Name = Constants.StateModifiedDisplayName },
                         ObjectName = objectName,
                         SetName = sourceFieldsSetName,
                         InnerName = Constants.StateModifiedColumnName,
                         SystemName = Constants.StateModifiedColumnName
                     };
            source.Fields.Add(sf);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Converts to source.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldList">The field list.</param>
 /// <param name="setName">Name of the set.</param>
 /// <returns>SourceFieldList.</returns>
 public static SourceFieldList ConvertToSource(string name, IEnumerable<Expressions.FieldInfo> fieldList, string setName)
 {
     var result = new SourceFieldList {ExpressionName = name};
     foreach (var field in fieldList)
     {
         var sf = new SourceField(result)
                      {
                          DataType = GetDataType(field.DataType),
                          Name = field.Name,
                          InnerName = field.InnerName,
                          ConnectorOut = {DataType = GetDataType(field.DataType), Name = field.Name},
                          SetName = setName,
                          SystemName = field.SystemName
                      };
         sf.Id = sf.ConnectorOut.Id;
         result.Fields.Add(sf);
     }
     return result;
 }
        /// <summary>
        /// Adds the fields as connectors.
        /// </summary>
        /// <param name="diagramViewModel">The diagram view model.</param>
        /// <param name="expressionObject">The expression object.</param>
        private void AddFieldsAsConnectors(IDiagramViewModel diagramViewModel, SourceFieldList expressionObject)
        {
            ConnectorsOut.Clear();
            foreach (var node in expressionObject.Fields.OrderBy(x => x.Name))
            {
                var connector = new ExpressionConnectorViewModel(new ExpressionConnector(ConnectorType.Out, node), diagramViewModel);
                ConnectorsOut.Add(connector);

                ExpandSubconnectors(connector, false, true);
            }
        }
            /// <summary>
            /// Begins the load process fields.
            /// </summary>
            /// <param name="publishedProcessId">The published process identifier.</param>
            /// <param name="sourceField">The source field.</param>
            /// <param name="action">The action.</param>
            protected async void BeginLoadProcessFields(
                int publishedProcessId, IExpressionField sourceField, Action<IExpressionField, IEnumerable<IExpressionField>> action)
            {
                var result = new SourceFieldList();

                try
                {
                    var processRetriever = await PublishedProcessFieldsRetriever.GetPublishedProcessFieldsAsync(publishedProcessId);

                    AddIdFields(processRetriever.Process, result, null, SourceFieldSetNames.Item);
                    AddStateFields(processRetriever.Process, result, null, SourceFieldSetNames.Item);
                    AddVersionFields(processRetriever.Process, result, null, SourceFieldSetNames.Item);

                    foreach (var field in processRetriever.Fields)
                    {
                        result.Fields.Add(CreateSourceField(new ProcessFieldInfoWrapper(field), sourceField.Connector.Owner));
                    }
                }
                catch (DataPortalException)
                {
                }
                finally
                {
                    if (action != null)
                        action(sourceField, result.Fields);
                }
            }
        public void AddSourceVersionFieldsFromPublishedProcessInfoTest()
        {
            // Arrange.
            const string ObjectName = "testObject";
            const string SetName = "TestItem";

            var vm = new ExpressionDesignerWindowViewModelBase();
            var accessor = new PrivateAccessor(vm);

            var process1 = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => process1.ProcessOption).Returns(ProcessOption.VersionEnabled);

            var process2 = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => process2.ProcessOption).Returns(ProcessOption.None);

            var source1 = new SourceFieldList();
            var source2 = new SourceFieldList();

            // Act.
            accessor.CallMethod("AddVersionFields", process1, source1, ObjectName, SetName);
            accessor.CallMethod("AddVersionFields", process2, source2, ObjectName, SetName);

            // Assert.
            Assert.AreEqual(3, source1.Fields.Count);

            var versionNumber = source1.Fields.FirstOrDefault(f => f.SystemName == Constants.VersionNumber);
            var versionDate = source1.Fields.FirstOrDefault(f => f.SystemName == Constants.VersionDate);
            var versionMasterId = source1.Fields.FirstOrDefault(f => f.SystemName == Constants.VersionMasterId);

            Assert.IsNotNull(versionNumber);
            Debug.Assert(versionNumber != null, "versionNumber != null");
            Assert.AreEqual(NodeDataType.String, versionNumber.DataType);
            Assert.AreEqual(Constants.VersionNumberName, versionNumber.Name);
            Assert.AreEqual(Constants.VersionNumber, versionNumber.InnerName);
            Assert.AreEqual(Constants.VersionNumber, versionNumber.SystemName);
            Assert.AreEqual(SetName, versionNumber.SetName);
            Assert.AreEqual(ObjectName, versionNumber.ObjectName);

            Assert.IsNotNull(versionDate);
            Debug.Assert(versionDate != null, "versionDate != null");
            Assert.AreEqual(NodeDataType.DateTime, versionDate.DataType);
            Assert.AreEqual("Version Date", versionDate.Name);
            Assert.AreEqual(Constants.VersionDate, versionDate.InnerName);
            Assert.AreEqual(Constants.VersionDate, versionDate.SystemName);
            Assert.AreEqual(SetName, versionDate.SetName);
            Assert.AreEqual(ObjectName, versionDate.ObjectName);

            Assert.IsNotNull(versionMasterId);
            Debug.Assert(versionMasterId != null, "versionMasterId != null");
            Assert.AreEqual(NodeDataType.Int, versionMasterId.DataType);
            Assert.AreEqual("Version Master Id", versionMasterId.Name);
            Assert.AreEqual(Constants.VersionMasterId, versionMasterId.InnerName);
            Assert.AreEqual(Constants.VersionMasterId, versionMasterId.SystemName);
            Assert.AreEqual(SetName, versionMasterId.SetName);
            Assert.AreEqual(ObjectName, versionMasterId.ObjectName);

            Assert.AreEqual(0, source2.Fields.Count);
        }
        public void ToSourceExpressionNodeShouldThrowExceptionIdSourceFieldListIsInvalid()
        {
            var obj = new ExpressionNodeFactory();
            var connection = new Connection();
            connection.Source = new ConnectorOut(connection);
            connection.Sink = new ConnectorIn(connection);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            destination.Fields[0].ConnectorIn.Id = connection.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection.Source.Id;

            Mock.Arrange(() => source.IsValid).Returns(true).InSequence().Returns(true).InSequence().Returns(false).InSequence();

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  connection
                              };

            obj.CreateExpressionNodes(objects);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Finalizes the update.
        /// </summary>
        /// <param name="sourceFieldList">The source field list.</param>
        /// <param name="fieldList">The field list.</param>
        /// <param name="source">The source.</param>
        /// <param name="expressions">The expressions.</param>
        /// <param name="parentWindow">The parent window.</param>
        private void FinalizeUpdate(SourceFieldList sourceFieldList, List<IExpressionField> fieldList, SourceFieldList source, List<IExpressionObjectBase> expressions, ITopLevelWindow parentWindow)
        {
            sourceFieldList.Fields.Clear();
            foreach (var field in fieldList)
            {
                sourceFieldList.Fields.Add((SourceField)field);
            }

            // delete obsolete fields (removed from process)
            var sourceListArray = sourceFieldList.Fields.ToArray();
            foreach (var field in sourceListArray)
            {
                if (source.Fields.All(t => t.Name != field.Name))
                {
                    var removed = sourceFieldList.Fields.First(t => t.Name == field.Name);
                    expressions.Remove(removed.ConnectorOut.Connection);

                    sourceFieldList.Fields.Remove(removed);
                }
            }

            this.expressionDesigner.LoadFromExpressionObjects(expressions);

            WindowManager.Value.ShowChildWindow(parentWindow, this);
        }
Exemplo n.º 11
0
        /// <summary>
        /// The edit expression.
        /// </summary>
        /// <param name="parentWindow">
        /// The parent window.
        /// </param>
        /// <param name="variableList">
        /// The variable list.
        /// </param>
        /// <param name="connection">
        /// The connection.
        /// </param>
        /// <param name="expressionDesignerString">
        /// The expression designer string.
        /// </param>
        /// <param name="saveAction">
        /// The save action.
        /// </param>
        /// <param name="cancelAction">
        /// The cancel action.
        /// </param>
        /// <param name="removeAction">
        /// The remove action.
        /// </param>
        public void EditExpression(
            ITopLevelWindow parentWindow,
            DataVariableEditList variableList,
            ConnectionSetupEdit connection,
            string expressionDesignerString,
            Action saveAction,
            Action cancelAction,
            Action removeAction)
        {

            const string expressionResult = "Expression Result";

            this.saveAction = saveAction;
            this.cancelAction = cancelAction;
            this.removeAction = removeAction;

            var source = new SourceFieldList { ExpressionName = "Received Data", Top = 10, Left = 10 };

            source.Fields.Add(new SourceField(null)
            {
                DataType = NodeDataType.String,
                Name = "Data",
                SetName = "Data",
                SystemName = "Data",
                ConnectorOut =
                {
                    DataType = NodeDataType.String,
                    Name = "Data"
                }
            });

            var expressions = new List<IExpressionObjectBase>();

            var isNew = true;

            ExpressionContainer expressionsContainer;
            try
            {
                expressionsContainer = Serializer.Deserialize(expressionDesignerString);
            }
            catch
            {
                expressionsContainer = null;
            }

            if (!string.IsNullOrWhiteSpace(expressionDesignerString) && expressionsContainer != null)
            {
                isNew = false;
                var destinationFieldList = expressionsContainer.Expressions.FirstOrDefault(x => x.ExpressionName == expressionResult) as DestinationFieldList;
                if (destinationFieldList != null)
                {

                    var newVariablesField = GetVariableList(variableList, expressionResult).Fields;

                    var oldEdited = from f in newVariablesField
                                    where destinationFieldList.Fields.Select(x => x.SystemName).Contains(f.SystemName)
                                    select f;

                    if (oldEdited.Any())
                    {
                        foreach (var field in oldEdited)
                        {
                            var nf = destinationFieldList.Fields.First(x => x.SystemName == field.SystemName);
                            nf.DataType = field.DataType;
                            nf.Name = field.Name;
                        }
                    }


                    foreach (var field in newVariablesField)
                    {
                        if (destinationFieldList.Fields.All(x => x.SystemName != field.SystemName))
                        {
                            destinationFieldList.Fields.Add(field);
                        }
                    }

                    //remove old field
                    var oldList = new HashSet<string>();
                    foreach (var des in destinationFieldList.Fields)
                    {
                        if (newVariablesField.All(x => x.SystemName != des.SystemName))
                        {
                            oldList.Add(des.SystemName);
                        }
                    }

                    if (oldList.Any())
                    {
                        foreach (var item in oldList)
                        {
                            var remove = destinationFieldList.Fields.FirstOrDefault(x => x.SystemName == item);
                            if (remove != null)
                            {
                                destinationFieldList.Fields.Remove(remove);
                            }
                            
                        }
                       
                    }


                }

                expressions.AddRange(expressionsContainer.Expressions);
            }
            else
            {
                expressions.Add(source);
                expressions.Add(GetVariableList(variableList, expressionResult));
            }

            if (expressionsContainer != null)
            {
                var sourceFieldList =
                   (from fl in expressions
                    where fl is SourceFieldList
                    select fl).Cast<SourceFieldList>().FirstOrDefault();

                if (sourceFieldList != null)
                {
                    var fieldList = sourceFieldList.Fields.Cast<IExpressionField>().ToList();
                    UpdateStoredFields(fieldList, source.Fields, (sf) => FinalizeUpdate(sourceFieldList, fieldList, source, expressions, parentWindow)); // Here we load all subtypes async that's why we need reload window after all subtypes are loaded
                }
            }

            if (!isNew)
            {
                return;
            }

            this.expressionDesigner.Diagram.Items.Clear();
            ExpressionTranslator.TranslateToDiagram(expressions, this.expressionDesigner.Diagram);

            WindowManager.Value.ShowChildWindow(parentWindow, this);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Adds the field node.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="diagramViewModel">The diagram view model.</param>
 private static void AddFieldNode(SourceFieldList item, IDiagramViewModel diagramViewModel)
 {
     var sfl = new SourceFieldsExpressionNode(diagramViewModel, item);
     diagramViewModel.Items.Add(new NodeViewModel<SourceFieldsExpressionNode, ExpressionConnection>(sfl, diagramViewModel));
 }
        /// <summary>
        /// The add last modified date field.
        /// </summary>
        /// <param name="process"> The process. </param>
        /// <param name="source"> The source. </param>
        /// <param name="objectName"> The object name. </param>
        /// <param name="sourceFieldsSetName"> The source fields set name. </param>
        /// <exception cref="ArgumentNullException"> </exception>
        protected void AddLastModifiedOnField(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName)
        {
            const string LastModifiedOnDisplayName = "Last Modified On";

            if (process == null)
                throw new ArgumentNullException("process");

            if (source == null)
                throw new ArgumentNullException("source");

            var dataType = SourceNodeFactory.GetDataType(typeof(DateTime));

            var sf = new SourceField(source)
            {
                DataType = dataType,
                Name = LastModifiedOnDisplayName,
                ConnectorOut = { DataType = dataType, Name = LastModifiedOnDisplayName },
                SetName = sourceFieldsSetName,
                InnerName = LastModifiedOnDisplayName,
                SystemName = LastModifiedOnDisplayName,
                ObjectName = objectName
            };

            source.Fields.Add(sf);
        }
        /// <summary>
        /// Adds version-related system fields.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="source">The source field list.</param>
        /// <param name="objectName">The source object name.</param>
        /// <param name="sourceFieldsSetName">The source fields set name.</param>
        /// <exception cref="System.ArgumentNullException">
        /// process
        /// or
        /// source
        /// </exception>
        /// <exception cref="ArgumentNullException">The <paramref name="process" /> parameter is null.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source" /> parameter is null.</exception>
        protected void AddVersionFields(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName)
        {
            if (process == null)
                throw new ArgumentNullException("process");

            if (source == null)
                throw new ArgumentNullException("source");

            if (process.ProcessOptionChoose != ProcessOption.VersionEnabled)
                return;

            var dataType = SourceNodeFactory.GetDataType(typeof(string));

            var sf = new SourceField(source)
                         {
                             DataType = dataType,
                             Name = Constants.VersionNumberName,
                             ConnectorOut = { DataType = dataType, Name = Constants.VersionNumberName },
                             ObjectName = objectName,
                             SetName = sourceFieldsSetName,
                             InnerName = Constants.VersionNumber,
                             SystemName = Constants.VersionNumber
                         };
            source.Fields.Add(sf);

            dataType = SourceNodeFactory.GetDataType(typeof(DateTime));

            sf = new SourceField(source)
                     {
                         DataType = dataType,
                         Name = VersionDateDisplayName,
                         ConnectorOut = { DataType = dataType, Name = VersionDateDisplayName },
                         ObjectName = objectName,
                         SetName = sourceFieldsSetName,
                         InnerName = Constants.VersionDate,
                         SystemName = Constants.VersionDate
                     };
            source.Fields.Add(sf);

            dataType = SourceNodeFactory.GetDataType(typeof(int));

            sf = new SourceField(source)
                     {
                         DataType = dataType,
                         Name = VersionMasterIdDisplayName,
                         ConnectorOut = { DataType = dataType, Name = VersionMasterIdDisplayName },
                         ObjectName = objectName,
                         SetName = sourceFieldsSetName,
                         InnerName = Constants.VersionMasterId,
                         SystemName = Constants.VersionMasterId
                     };

            source.Fields.Add(sf);
        }
        public void AddStateFieldsFromPublishedProcessInfoTest()
        {
            // Arrange.
            const string ObjectName = "testObject";
            const string SetName = "TestItem";

            var process1 = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => process1.IsStateEnabled).Returns(false);

            var process2 = Mock.Create<PublishedProcessInfo>();
            Mock.Arrange(() => process2.IsStateEnabled).Returns(true);

            var fields1 = new SourceFieldList();
            var fields2 = new SourceFieldList();

            var vm = new ExpressionDesignerWindowViewModelBase();
            var accessor = new PrivateAccessor(vm);

            // Act.
            accessor.CallMethod("AddStateFields", process1, fields1, ObjectName, SetName);
            accessor.CallMethod("AddStateFields", process2, fields2, ObjectName, SetName);

            // Assert.
            Assert.AreEqual(0, fields1.Fields.Count);

            Assert.AreEqual(2, fields2.Fields.Count);

            var currentStateField = fields2.Fields.First(f => f.SystemName == Constants.CurrentStateName);

            Assert.AreEqual(NodeDataType.String, currentStateField.DataType);
            Assert.AreEqual(Constants.CurrentStateDisplayName, currentStateField.Name);
            Assert.AreEqual(Constants.CurrentStateName, currentStateField.SystemName);
            Assert.AreEqual(Constants.CurrentStateName, currentStateField.InnerName);
            Assert.AreEqual(SetName, currentStateField.SetName);
            Assert.AreEqual(ObjectName, currentStateField.ObjectName);

            var stateModifiedOnField = fields2.Fields.First(f => f.SystemName == Constants.StateModifiedColumnName);

            Assert.AreEqual(NodeDataType.DateTime, stateModifiedOnField.DataType);
            Assert.AreEqual(Constants.StateModifiedDisplayName, stateModifiedOnField.Name);
            Assert.AreEqual(Constants.StateModifiedColumnName, stateModifiedOnField.SystemName);
            Assert.AreEqual(Constants.StateModifiedColumnName, stateModifiedOnField.InnerName);
            Assert.AreEqual(SetName, stateModifiedOnField.SetName);
            Assert.AreEqual(ObjectName, stateModifiedOnField.ObjectName);
        }
        public void AddLastModifiedOnField4()
        {
            var vm = new ExpressionDesignerWindowViewModelBase();
            var privateAccessor = new PrivateAccessor(vm);
            var source = new SourceFieldList();

            privateAccessor.CallMethod("AddLastModifiedOnField", source, "oldItem", SourceFieldSetNames.Item);

            var lastModifiedOnFieldIsAdded = source.Fields.Any(f => f.SystemName == Constants.LastModifiedOn);

            Assert.IsTrue(lastModifiedOnFieldIsAdded);
        }
Exemplo n.º 17
0
        public void ToSourceExpressionNodeShouldReturnFieldWithValue()
        {
            var obj = new ExpressionNodeFactory();
            var connection = new Connection();
            connection.Source = new ConnectorOut(connection);
            connection.Sink = new ConnectorIn(connection);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            destination.Fields[0].ConnectorIn.Id = connection.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  connection
                              };

            var destNode = obj.CreateExpressionNodes(objects, new Dictionary<string, object> { { "Field", "Value" } });
            var sourceNode = destNode.ResultNodes.FirstOrDefault().Expression as SourceFieldNode;

            Assert.AreEqual("Field", sourceNode.FieldName);
            Assert.AreEqual("Value", sourceNode.Value);
        }
        /// <summary>
        /// Creates the source item.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="expressionName">Name of the expression.</param>
        /// <param name="uniqueName">Name of the unique.</param>
        /// <param name="objectName">Name of the object.</param>
        /// <param name="left">The left position.</param>
        /// <param name="top">The top position.</param>
        /// <returns>List of Source Fields.</returns>  
        private static SourceFieldList CreateSourceItem(
            IProcessEdit process,
            string expressionName,
            string uniqueName,
            string objectName,
            int left,
            int top)
        {
            var result = new SourceFieldList
                {
                    ExpressionName = expressionName,
                    Top = top,
                    Left = left,
                    UniqueName = uniqueName
                };

            AddIdFields(process, result, objectName);
            AddStateFields(process, result, objectName);
            AddVersionFields(process, result, objectName);
            AddLastModifiedOnField(result, objectName);

            foreach (var field in process.GetAllFields())
            {
                var sourceField = CreateSourceField(new ProcessFieldEditWrapper(field), result);
                sourceField.ObjectName = objectName;
                result.Fields.Add(sourceField);
            }

            return result;
        }
Exemplo n.º 19
0
        public void CheckMultipleDestinationsInAddDestinationNode()
        {
            var obj = new ExpressionNodeFactory();
            var connection1 = new Connection();
            connection1.Source = new ConnectorOut(connection1);
            connection1.Sink = new ConnectorIn(connection1);

            var connection2 = new Connection();
            connection2.Source = new ConnectorOut(connection2);
            connection2.Sink = new ConnectorIn(connection2);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination) { SystemName = "Field" });
            destination.Fields[0].Subfields.Add(new DestinationField(destination) { SystemName = "Subfield", ParentField = destination.Fields[0] });

            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            var func = new OneInOneOutExpression(ExpressionNodeType.Count) { UniqueName = "Function" };

            func.ConnectorIn.Id = connection1.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection1.Source.Id;

            ((DestinationField)destination.Fields[0].Subfields[0]).ConnectorIn.Id = connection2.Sink.Id;
            func.ConnectorOut.Id = connection2.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  func,
                                  connection1,
                                  connection2
                              };

            var destNode = obj.CreateExpressionNodes(objects);

            Assert.AreEqual("Field.Subfield", destNode.ResultNodes.ToArray()[0].FieldName);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SourceFieldsExpressionNode"/> class.
        /// </summary>
        /// <param name="diagramViewModel">The diagram view model.</param>
        /// <param name="expressionObject">The expression object.</param>
        public SourceFieldsExpressionNode(IDiagramViewModel diagramViewModel, SourceFieldList expressionObject)
            : base(expressionObject)
        {
            _diagramViewModel = diagramViewModel;
            _connectorsOut.CollectionChanged += ConnectorsOutCollectionChanged;
            
            IsValidFunc = n => true;
            UpdateAction = n => { };

            AddFieldsAsConnectors(diagramViewModel, expressionObject);
        }
Exemplo n.º 21
0
        public void ToExpressionNode_SetChecklistData_Test()
        {
            // Arrange.
            var nodeFactory = new ExpressionNodeFactory();
            var connection1 = new Connection();
            connection1.Source = new ConnectorOut(connection1);
            connection1.Sink = new ConnectorIn(connection1);

            var connection2 = new Connection();
            connection2.Source = new ConnectorOut(connection2);
            connection2.Sink = new ConnectorIn(connection2);

            var connection3 = new Connection();
            connection3.Source = new ConnectorOut(connection3);
            connection3.Sink = new ConnectorIn(connection3);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            destination.Fields.Add(new DestinationField(destination));
            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            var func = new SetChecklistDataExpression { UniqueName = "Function" };

            func.ConnectorIn.Id = connection1.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection1.Source.Id;

            destination.Fields[0].ConnectorIn.Id = connection2.Sink.Id;
            func.Connector1Out.Id = connection2.Source.Id;

            destination.Fields[1].ConnectorIn.Id = connection3.Sink.Id;
            func.Connector2Out.Id = connection3.Source.Id;

            var objects = new List<IExpressionObjectBase> { source, destination, func, connection1, connection2, connection3 };

            // Act.
            var destNode = nodeFactory.CreateExpressionNodes(objects);

            // Assert.
            Assert.IsTrue(destNode.ResultNodes.ElementAt(0).Expression is SetChecklistDataFunctionNode);
            Assert.IsTrue(destNode.ResultNodes.ElementAt(1).Expression is GetContextValueFunctionNode);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Converts to source.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="fieldList">The field list.</param>
 /// <param name="setName">Name of the set.</param>
 /// <returns>SourceFieldList.</returns>
 public static SourceFieldList ConvertToSource(string name, IDictionary<string, object> fieldList, string setName)
 {
     var result = new SourceFieldList {ExpressionName = name};
     foreach (var field in fieldList)
     {
         var sf = new SourceField(result)
                      {
                          DataType = GetDataType(field.Value.GetType()),
                          Name = field.Key,
                          ConnectorOut = {DataType = GetDataType(field.Value.GetType()), Name = field.Key},
                          SetName = setName,
                      };
         sf.Id = sf.ConnectorOut.Id;
         result.Fields.Add(sf);
     }
     return result;
 }
Exemplo n.º 23
0
        private void ToExpressionNodeThreeInOneOutFunctionTest(ExpressionNodeType nodeType, Type functionNode)
        {
            var obj = new ExpressionNodeFactory();
            var connection1 = new Connection();
            connection1.Source = new ConnectorOut(connection1);
            connection1.Sink = new ConnectorIn(connection1);

            var connection2 = new Connection();
            connection2.Source = new ConnectorOut(connection2);
            connection2.Sink = new ConnectorIn(connection2);

            var connection3 = new Connection();
            connection3.Source = new ConnectorOut(connection3);
            connection3.Sink = new ConnectorIn(connection3);

            var connection4 = new Connection();
            connection4.Source = new ConnectorOut(connection4);
            connection4.Sink = new ConnectorIn(connection4);

            var destination = new DestinationFieldList { UniqueName = "Destination" };
            destination.Fields.Add(new DestinationField(destination));
            var source = new SourceFieldList();
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });
            source.Fields.Add(new SourceField(source) { Name = "Field" });

            var func = new ThreeInOneOutExpression(nodeType) { UniqueName = "Function" };

            func.Connector1In.Id = connection1.Sink.Id;
            source.Fields[0].ConnectorOut.Id = connection1.Source.Id;
            func.Connector2In.Id = connection2.Sink.Id;
            source.Fields[1].ConnectorOut.Id = connection2.Source.Id;
            func.Connector3In.Id = connection3.Sink.Id;
            source.Fields[2].ConnectorOut.Id = connection3.Source.Id;

            destination.Fields[0].ConnectorIn.Id = connection4.Sink.Id;
            func.ConnectorOut.Id = connection4.Source.Id;

            var objects = new List<IExpressionObjectBase>
                              {   
                                  source,
                                  destination,
                                  func,
                                  connection1,
                                  connection2,
                                  connection3,
                                  connection4
                              };

            var destNode = obj.CreateExpressionNodes(objects);
            Assert.AreEqual(functionNode, destNode.ResultNodes.FirstOrDefault().Expression.GetType());
        }
Exemplo n.º 24
0
        /// <summary>
        /// Creates the user information item.
        /// </summary>
        /// <param name="uniqueName">
        /// The unique name.
        /// </param>
        /// <returns>
        /// The user information item.
        /// </returns>
        public static SourceFieldList CreateUserInformationItem(string uniqueName)
        {
            var userInfoSource = new SourceFieldList { ExpressionName = "Current User Information", UniqueName = uniqueName };

            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "User Name",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserName",
                        SystemName = "Utils.CurrentUserName",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Full Name",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserFullName",
                        SystemName = "Utils.CurrentUserFullName",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.Int,
                        Name = "Person ID",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserPersonId",
                        SystemName = "Utils.CurrentUserPersonId",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Email Address",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserEmailAddress",
                        SystemName = "Utils.CurrentUserEmailAddress",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "First Name",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserFirstName",
                        SystemName = "Utils.CurrentUserFirstName",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "First Name" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Last Name",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserLastName",
                        SystemName = "Utils.CurrentUserLastName",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.Int,
                        Name = "Business Unit Id",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserBusinessUnitId",
                        SystemName = "Utils.CurrentUserBusinessUnitId",
                        ConnectorOut = { DataType = NodeDataType.Int, Name = "Business Unit Id" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Business Unit",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserBusinessUnit",
                        SystemName = "Utils.CurrentUserBusinessUnit",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "User IP",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserClientIP",
                        SystemName = "Utils.CurrentUserClientIP",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "User IP" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Device Name",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserDeviceName",
                        SystemName = "Utils.CurrentUserDeviceName",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Device Name" }
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.List,
                        Name = "Roles",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserRolesList",
                        SystemName = "Utils.CurrentUserRolesList",
                        ConnectorOut = { DataType = NodeDataType.List, Name = "Roles Id" },
                        SubfieldsRetriever = new RolesRetriever()
                    });
            userInfoSource.Fields.Add(
                new SourceField(null)
                    {
                        DataType = NodeDataType.String,
                        Name = "Locale",
                        SetName = SourceFieldSetNames.CurrentUserInfo,
                        InnerName = "CurrentUserLocale",
                        SystemName = "Utils.CurrentUserLocale",
                        ConnectorOut = { DataType = NodeDataType.String, Name = "Locale" }
                    });

            return userInfoSource;
        }
Exemplo n.º 25
0
        private static void SetupExpressionsDiagram(DiagramViewModel vm)
        {
            vm.Palette.Add(new NodeGroup("String Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                                        {
                                                            ExpressionName = "Uppercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.ToLower)
                                                        {
                                                            ExpressionName = "Lowercase",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.Trim)
                                                        {
                                                            ExpressionName = "Trim",
                                                            ConnectorIn =  { DataType = NodeDataType.String, Name = "String" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Concat)
                                                        {
                                                            ExpressionName = "Concat",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Left)
                                                        {
                                                            ExpressionName = "Left",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" } 
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Right)
                                                        {
                                                            ExpressionName = "Right",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "String 1" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "String 2" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));

            vm.Palette.Add(new NodeGroup("Date Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AddDays)
                                                        {
                                                            ExpressionName = "Add Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Days Count" },
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffDays)
                                                        {
                                                            ExpressionName = "DateDiff Days",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.DateDiffHours)
                                                        {
                                                            ExpressionName = "DateDiff Hours",
                                                            Connector1In = { DataType = NodeDataType.DateTime, Name = "Date 1" },
                                                            Connector2In = { DataType = NodeDataType.DateTime, Name = "Date 2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FunctionExpressionNode, ExpressionConnection>(
                                                        new FunctionExpressionNode(vm, new FunctionExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Current Date",
                                                            FunctionName = "DateTime.Now",
                                                            ConnectorOut = { DataType = NodeDataType.DateTime, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateYear)
                                                        {
                                                            ExpressionName = "Date Year",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Year" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateQuarter)
                                                        {
                                                            ExpressionName = "Date Quarter",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Quarter" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonth)
                                                        {
                                                            ExpressionName = "Date Month",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Month" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateMonthName)
                                                        {
                                                            ExpressionName = "Date Month Name",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Month Name" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<OneInOneOutExpressionNode, ExpressionConnection>(
                                                        new OneInOneOutExpressionNode(vm, new OneInOneOutExpression(ExpressionNodeType.DateWeek)
                                                        {
                                                            ExpressionName = "Date Week",
                                                            ConnectorIn =  { DataType = NodeDataType.DateTime, Name = "Date" },
                                                            ConnectorOut = { DataType = NodeDataType.Int, Name = "Week" }
                                                        }),
                                                        vm
                                                    ),

                                                }));

            vm.Palette.Add(new NodeGroup("Logical Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsLess)
                                                        {
                                                            ExpressionName = "Less",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.IsGreater)
                                                        {
                                                            ExpressionName = "Greater",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.AreEqual)
                                                        {
                                                            ExpressionName = "Equals",
                                                            Connector1In = { DataType = NodeDataType.String, Name = "a" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "b" },
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<ThreeInOneOutExpressionNode, ExpressionConnection>(
                                                        new ThreeInOneOutExpressionNode(vm, new ThreeInOneOutExpression(ExpressionNodeType.If)
                                                        {
                                                            ExpressionName = "Condition",
                                                            Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                                                            Connector2In = { DataType = NodeDataType.String, Name = "When True"  },
                                                            Connector3In = { DataType = NodeDataType.String, Name = "When False" },
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Aggregate Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Add)
                                                        {
                                                            ExpressionName = "Add", 
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1"},
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2"},
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Subtract)
                                                        { 
                                                            ExpressionName = "Subtract",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Multiply)
                                                        {
                                                            ExpressionName = "Multiply",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.Divide)
                                                        {
                                                            ExpressionName = "Divide",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<TwoInOneOutExpressionNode, ExpressionConnection>(
                                                        new TwoInOneOutExpressionNode(vm, new TwoInOneOutExpression(ExpressionNodeType.CustomFunction)
                                                        {
                                                            ExpressionName = "Custom Multiply",
                                                            FunctionName = "?1 * ?2",
                                                            Connector1In = { DataType = NodeDataType.Double, Name = "Value1" },
                                                            Connector2In = { DataType = NodeDataType.Double, Name = "Value2" },
                                                            ConnectorOut = { DataType = NodeDataType.Double, Name = "Result" }
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("SPC Functions",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AboveCenterLine)
                                                        {
                                                            ExpressionName = "Above Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.BelowCenterLine)
                                                        {
                                                            ExpressionName = "Below Center Line", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingDown)
                                                        {
                                                            ExpressionName = "Going Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.GoingUp)
                                                        {
                                                            ExpressionName = "Going Up", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.AlternatingUpAndDown)
                                                        {
                                                            ExpressionName = "Alternating Up and Down", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.LessThanLowerLimits)
                                                        {
                                                            ExpressionName = "Less Than LCL/LSL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "LCL/LSL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.GreaterThanUpperLimits)
                                                        {
                                                            ExpressionName = "Greater Than UCL/USL", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "UCL/USL"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector5In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.Same)
                                                        {
                                                            ExpressionName = "Same", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<SixInOneOutExpressionNode, ExpressionConnection>(
                                                        new SixInOneOutExpressionNode(vm, new SixInOneOutExpression(ExpressionNodeType.Between)
                                                        {
                                                            ExpressionName = "Between", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Double, Name = "Low Value"},
                                                            Connector5In = { DataType = NodeDataType.Double, Name = "High Value"},
                                                            Connector6In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneAorBeyond)
                                                        {
                                                            ExpressionName = "Zone A or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneBorBeyond)
                                                        {
                                                            ExpressionName = "Zone B or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FiveInOneOutExpressionNode, ExpressionConnection>(
                                                        new FiveInOneOutExpressionNode(vm, new FiveInOneOutExpression(ExpressionNodeType.ZoneCorBeyond)
                                                        {
                                                            ExpressionName = "Zone C or beyond", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Sub-group Size"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.Int, Name = "Y Number"},
                                                            Connector5In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedNumber)
                                                        {
                                                            ExpressionName = "Failed Number (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Int, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                    new NodeViewModel<FourInOneOutExpressionNode, ExpressionConnection>(
                                                        new FourInOneOutExpressionNode(vm, new FourInOneOutExpression(ExpressionNodeType.FailedPercent)
                                                        {
                                                            ExpressionName = "Failed Percent (attribute)", 
                                                            Connector1In = { DataType = NodeDataType.SPCChart, Name = "SPC Field"},
                                                            Connector2In = { DataType = NodeDataType.Int, Name = "Number of samples"},
                                                            Connector3In = { DataType = NodeDataType.Double, Name = "X Number"},
                                                            Connector4In = { DataType = NodeDataType.ChartType, Name = "Chart Type"},
                                                            ConnectorOut = { DataType = NodeDataType.Boolean, Name = "Result"}
                                                        }),
                                                        vm
                                                    ),
                                                }));

            vm.Palette.Add(new NodeGroup("Constants",
                                            new INodeViewModel[]
                                                {
                                                    new NodeViewModel<ConstantExpressionNode, ExpressionConnection>(
                                                        new ConstantExpressionNode(vm, new ConstantExpression()
                                                        {
                                                            ExpressionName = "Constant",
                                                            ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                                        }),
                                                        vm
                                                    )
                                                }));


            var uis = new SourceFieldList {ExpressionName = "Current User Information", Left = 10, Top = 400};
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "User Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserName", ConnectorOut = { DataType = NodeDataType.String, Name = "User Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Full Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserFullName", ConnectorOut = { DataType = NodeDataType.String, Name = "Full Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.Int, Name = "Person ID", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserPersonId", ConnectorOut = { DataType = NodeDataType.String, Name = "Person ID" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Email Address", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserEmailAddress", ConnectorOut = { DataType = NodeDataType.String, Name = "Email Address" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Last Name", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserLastName", ConnectorOut = { DataType = NodeDataType.String, Name = "Last Name" } });
            uis.Fields.Add(new SourceField(null) { DataType = NodeDataType.String, Name = "Business Unit", SetName = SourceFieldSetNames.CurrentUserInfo, SystemName = "Utils.CurrentUserBusinessUnitId", ConnectorOut = { DataType = NodeDataType.String, Name = "Business Unit" } });

            // source
            //var fieldList = new Dictionary<string, object>();
            //fieldList["Name"] = "Name";
            //fieldList["Title"] = "Title";
            //fieldList["PublishDate"] = DateTime.Now;
            //fieldList["Author"] = "Author";

            var sourceNodeList = new SourceFieldList();

            //Func<IExpressionField, ICollection<IExpressionField>> sfRetriever = f => GetCRFields(f, sourceNodeList);
            
            sourceNodeList.ExpressionName = "Album";
            sourceNodeList.Top = 10;
            sourceNodeList.Left = 10;
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Name", SetName = SourceFieldSetNames.Item, SystemName = "Name", ConnectorOut = { DataType = NodeDataType.String, Name = "Name" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "Title", SetName = SourceFieldSetNames.Item, SystemName = "Title", ConnectorOut = { DataType = NodeDataType.String, Name = "Title" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList) { DataType = NodeDataType.String, Name = "PublishDate", SetName = SourceFieldSetNames.Item, SystemName = "PublishDate", ConnectorOut = { DataType = NodeDataType.String, Name = "PublishDate" } });
            sourceNodeList.Fields.Add(new SourceField(sourceNodeList)
                                          {
                                              DataType = NodeDataType.String, 
                                              Name = "Author", 
                                              SetName = SourceFieldSetNames.Item, 
                                              SystemName = "Author", 
                                              ConnectorOut = { DataType = NodeDataType.String, Name = "Author" },
                                              SubfieldsRetriever = new CRSubfieldsRetriever()
                                          });



            //var sourceNodes = SourceNodeFactory.ConvertToSource("Album", fieldList, SourceFieldSetNames.Item);
            //sourceNodes.Top = 10;
            //sourceNodes.Left = 10;
            //sourceNodes.Width = 200;

            // destination
            var destinationNodes = DestinationNodeFactory.ConvertToSource(typeof(ExpressionResult));
            destinationNodes.Top = 200;
            destinationNodes.Left = 600 ;

            var expressions = new List<IExpressionObjectBase>();
            expressions.Add(sourceNodeList);
            //expressions.Add(uis);
            expressions.Add(destinationNodes);

            // connection
            var connection = new Connection
                                 {
                                     Id = Guid.NewGuid(),
                                     Source = new ConnectorOut(null) { Id = sourceNodeList.ConnectorsOut[0].Id },
                                     Sink = new ConnectorIn(null) { Id = destinationNodes.ConnectorsIn[0].Id }
                                 };
            //expressions.Add(connection);

            // constant
            var constantExpr = new ConstantExpression { ExpressionName = "Constant", Top = 10, Left = 250, Value = 10,
                                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(constantExpr);

            // oneinoneout
            var oneinoneoutExpr = new OneInOneOutExpression(ExpressionNodeType.ToUpper)
                                      { ExpressionName = "Uppercase", Top = 60, Left = 250, 
                                        ConnectorIn = {DataType = NodeDataType.String, Name = "String"},
                                        ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
                                      };
            //expressions.Add(oneinoneoutExpr);

            // twoinoneout
            var twoinoneoutExpr = new TwoInOneOutExpression(ExpressionNodeType.Concat)
            {
                ExpressionName = "Concat",
                Top = 110,
                Left = 250,
                Connector1In = { DataType = NodeDataType.String, Name = "String" },
                Connector2In = { DataType = NodeDataType.String, Name = "String" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            //expressions.Add(twoinoneoutExpr);

            // threeinoneout
            var threeinoneoutExpr = new ThreeInOneOutExpression(ExpressionNodeType.If)
            {
                ExpressionName = "Condition",
                Top = 180,
                Left = 250,
                Connector1In = { DataType = NodeDataType.Boolean, Name = "Condition" },
                Connector2In = { DataType = NodeDataType.String, Name = "If True" },
                Connector3In = { DataType = NodeDataType.String, Name = "If False" },
                ConnectorOut = { DataType = NodeDataType.String, Name = "Result" }
            };
            expressions.Add(threeinoneoutExpr);

            // function
            var functionExpr = new FunctionExpression(ExpressionNodeType.CustomFunction) { ExpressionName = "Current Date", Top = 280, Left = 250, Width = 100, Height = 45, FunctionName = "DateTime.Now",
                                ConnectorOut = {DataType = NodeDataType.DateTime, Name="Result"}};
            //expressions.Add(functionExpr);

            ExpressionTranslator.TranslateToDiagram(expressions, vm);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Determines whether [is valid mapping] [the specified field list].
        /// </summary>
        /// <param name="fieldList">The field list.</param>
        /// <param name="connector">The connector.</param>
        /// <param name="sourceContext">The source context.</param>
        /// <returns><c>true</c> if [is valid mapping] [the specified field list]; otherwise, <c>false</c>.</returns>
        private bool IsValidMapping(SourceFieldList fieldList, IConnectorOut connector, SourceField sourceContext)
        {
            var sourceField = FindSourceField(fieldList.Fields, connector);

            if (sourceField == null)
                return false;

            return CanAccess(sourceField, sourceContext);
        }
        /// <summary>
        /// Adds the 'Id' and 'Base Id' fields to the specified <see cref="SourceFieldList" />.
        /// </summary>
        /// <param name="process">The source process.</param>
        /// <param name="source">The source field list.</param>
        /// <param name="objectName">The source object name.</param>
        /// <param name="sourceFieldsSetName">The source fields set name.</param>
        /// <exception cref="System.ArgumentNullException">
        /// process
        /// or
        /// source
        /// </exception>
        protected void AddIdFields(IProcessEdit process, SourceFieldList source, string objectName, string sourceFieldsSetName)
        {
            const string IdName = "Id";
            const string BaseIdName = "Base Id";

            if (process == null)
                throw new ArgumentNullException("process");

            if (source == null)
                throw new ArgumentNullException("source");

            var dataType = SourceNodeFactory.GetDataType(typeof(int));
            var sf = new SourceField(source)
                         {
                             DataType = dataType,
                             Name = IdName,
                             ConnectorOut = { DataType = dataType, Name = IdName },
                             ObjectName = objectName,
                             SetName = sourceFieldsSetName,
                             InnerName = Constants.IdColumnName,
                             SystemName = Constants.IdColumnName,
                         };
            source.Fields.Add(sf);

            if (process.BaseProcess == null)
                return;

            sf = new SourceField(source)
                     {
                         DataType = dataType,
                         Name = BaseIdName,
                         ConnectorOut = { DataType = dataType, Name = BaseIdName },
                         ObjectName = objectName,
                         SetName = sourceFieldsSetName,
                         InnerName = Constants.BaseIdColumnName,
                         SystemName = Constants.BaseIdColumnName,
                     };
            source.Fields.Add(sf);
        }