Used to perform fuzzy matching of sorts ;) NOTE : Commented out code for future extention on this piece
コード例 #1
0
        /// <summary>
        /// Generates the match fragments from data list.
        /// </summary>
        /// <returns></returns>
        private FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var compiler = DataListFactory.CreateDataListCompiler();

                ErrorResultTO invokeErrors;
                var           dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), string.Empty.ToStringBuilder(), DataList.ToStringBuilder(), out invokeErrors);
                var           dl   = compiler.FetchBinaryDataList(dlID, out invokeErrors);
                IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>();

                if (dl != null)
                {
                    foreach (var rs in dl.FetchRecordsetEntries())
                    {
                        // build map for each column in a recordset ;)
                        foreach (var col in rs.Columns)
                        {
                            if (!tmp.Keys.Any(a => a.Item2 == col.ColumnName && a.Item1 == rs.Namespace))
                            {
                                tmp[new Tuple <string, string>(rs.Namespace, col.ColumnName)] = rs.Namespace;
                            }
                        }
                    }
                }

                result = new FuzzyMatchVo(tmp);
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Generates the match fragments from data list.
        /// </summary>
        /// <returns></returns>
        private FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var dataListModel = new DataListModel();
                dataListModel.Create(DataList, DataList);
                IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>();

                foreach (var rs in dataListModel.RecordSets)
                {
                    // build map for each column in a recordset ;)
                    foreach (var col in rs.Columns)
                    {
                        foreach (var scalar in col.Value)
                        {
                            if (!tmp.Keys.Any(a => a.Item2 == scalar.Name && a.Item1 == rs.Name))
                            {
                                tmp[new Tuple <string, string>(rs.Name, scalar.Name)] = rs.Name;
                            }
                        }
                    }
                }

                result = new FuzzyMatchVo(tmp);
            }

            return(result);
        }
コード例 #3
0
        string CreateInjectValue(bool isOutputMapping, FuzzyMatchVo fuzzyMatch, IDev2Definition def)
        {
            string injectValue;
            // When output mapping we need to replace the recordset name if present with MasterRecordset
            //
            string masterRecordsetName;

            if (isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
            {
                var field = def.Name;

                var recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                if (!string.IsNullOrEmpty(recordsetName))
                {
                    masterRecordsetName = recordsetName;
                }
                else
                {
                    // we have no match, use the current mapping value ;)
                    masterRecordsetName = def.RecordSetName;
                }

                injectValue = FormatString(masterRecordsetName, field);
            }
            else
            {
                if (def.IsRecordSet)
                {
                    if (fuzzyMatch != null)
                    {
                        var recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                        masterRecordsetName = !String.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                    }
                    else
                    {
                        masterRecordsetName = def.RecordSetName;
                    }

                    injectValue = FormatString(masterRecordsetName, def.Name);
                }
                else
                {
                    injectValue = DataListUtil.AddBracketsToValueIfNotExist(def.Name);
                }
            }

            return(injectValue);
        }
コード例 #4
0
        FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var dataListModel = new DataListModel();
                dataListModel.Create(DataList, DataList);
                IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>();

                foreach (var rs in dataListModel.RecordSets)
                {
                    MapRecordsetColumn(tmp, rs);
                }
                result = new FuzzyMatchVo(tmp);
            }

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Creates the mapping list.
        /// </summary>
        /// <param name="mappingDefinitions">The mapping definitions.</param>
        /// <param name="parser">The parser.</param>
        /// <param name="autoAddBrackets">if set to <c>true</c> [automatic add brackets].</param>
        /// <param name="isOutputMapping">if set to <c>true</c> [is output mapping].</param>
        /// <param name="fuzzyMatch">The fuzzy match.</param>
        /// <returns></returns>
        private IList <IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList <IInputOutputViewModel> result = new List <IInputOutputViewModel>();
            IList <IDev2Definition>       concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);


            var masterRecordsetName = string.Empty;

            foreach (var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;

                if (!string.IsNullOrEmpty(injectValue) || IsWorkflow)
                {
                    if (autoAddBrackets)
                    {
                        // When output mapping we need to replace the recordset name if present with MasterRecordset
                        //
                        if (isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
                        {
                            var field = DataListUtil.ExtractFieldNameFromValue(injectValue);

                            if (IsWorkflow)
                            {
                                field = def.Name;
                            }

                            string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                            if (!string.IsNullOrEmpty(recordsetName))
                            {
                                masterRecordsetName = recordsetName;
                            }
                            else
                            {
                                // we have no match, use the current mapping value ;)
                                masterRecordsetName = !IsWorkflow?DataListUtil.ExtractRecordsetNameFromValue(injectValue) : def.RecordSetName;
                            }


                            injectValue = FormatString(masterRecordsetName, field);
                        }
                        else
                        {
                            if (def.IsRecordSet)
                            {
                                if (fuzzyMatch != null)
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !String.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }
                                else
                                {
                                    masterRecordsetName = def.RecordSetName;
                                }

                                injectValue = FormatString(masterRecordsetName, def.Name);
                            }
                            else
                            {
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(!IsWorkflow ? injectValue : def.Name);
                            }
                        }
                    }
                }
                else
                {
                    if (!def.IsRecordSet)
                    {
                        if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                        {
                            injectValue = DataListUtil.AddBracketsToValueIfNotExist(def.Name);
                        }
                    }
                    else
                    {
                        if (!isOutputMapping)
                        {
                            var field = def.Name;

                            if (fuzzyMatch != null && def.IsRecordSet)
                            {
                                if (string.IsNullOrEmpty(masterRecordsetName))
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !string.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }

                                injectValue = DataListUtil.ComposeIntoUserVisibleRecordset(masterRecordsetName,
                                                                                           string.Empty, field);
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(injectValue);
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                                {
                                    injectValue = FormatString(def.RecordSetName, def.Name);
                                }
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedOutputMapping))
                            {
                                injectValue = FormatString(def.RecordSetName, def.Name);
                            }
                        }
                    }
                }

                var injectMapsTo = def.MapsTo;

                // no saved mappings add brackets ;)
                if (!string.IsNullOrEmpty(injectMapsTo) && string.IsNullOrEmpty(SavedInputMapping))
                {
                    injectMapsTo = DataListUtil.AddBracketsToValueIfNotExist(injectMapsTo);
                }
                else
                {
                    if (def.IsRecordSet)
                    {
                        var tmp = injectValue.Replace("()", "(*)");
                        injectMapsTo = tmp; // tag it as the same ;)
                    }
                    else
                    {
                        injectMapsTo = injectValue; // tag it as the same ;)
                    }
                }

                // def.RecordSetName -> recordsetName
                var viewModel = new InputOutputViewModel(def.Name, injectValue, injectMapsTo, def.DefaultValue, def.IsRequired, def.RecordSetName, def.EmptyToNull);

                result.Add(viewModel);
            }

            return(result);
        }
コード例 #6
0
        IList <IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList <IInputOutputViewModel> result = new List <IInputOutputViewModel>();
            var concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);

            foreach (var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;
                if (autoAddBrackets)
                {
                    injectValue = CreateInjectValue(isOutputMapping, fuzzyMatch, def);
                }
                var injectMapsTo = def.MapsTo;

                // no saved mappings add brackets ;)
                if (!string.IsNullOrEmpty(injectMapsTo) && string.IsNullOrEmpty(SavedInputMapping))
                {
                    injectMapsTo = DataListUtil.AddBracketsToValueIfNotExist(injectMapsTo);
                }
                else
                {
                    if (def.IsRecordSet)
                    {
                        var tmp = injectValue.Replace("()", "(*)");
                        injectMapsTo = tmp; // tag it as the same ;)
                    }
                    else
                    {
                        injectMapsTo = injectValue; // tag it as the same ;)
                    }
                }

                // def.RecordSetName -> recordsetName
                var viewModel = new InputOutputViewModel(def.Name, injectValue, injectMapsTo, def.DefaultValue, def.IsRequired, def.RecordSetName, def.EmptyToNull);
                viewModel.IsObject = def.IsObject;
                if (def.IsObject)
                {
                    var complexObjectItemModel = _complexObjects.FirstOrDefault(model => model.Name == def.Name);
                    if (complexObjectItemModel != null)
                    {
                        viewModel.JsonString = complexObjectItemModel.GetJson();
                    }
                }
                result.Add(viewModel);
            }

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Creates the mapping list.
        /// </summary>
        /// <param name="mappingDefinitions">The mapping definitions.</param>
        /// <param name="parser">The parser.</param>
        /// <param name="autoAddBrackets">if set to <c>true</c> [automatic add brackets].</param>
        /// <param name="isOutputMapping">if set to <c>true</c> [is output mapping].</param>
        /// <param name="fuzzyMatch">The fuzzy match.</param>
        /// <returns></returns>
        private IList <IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList <IInputOutputViewModel> result = new List <IInputOutputViewModel>();
            IList <IDev2Definition>       concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);

            foreach (var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;
                if (autoAddBrackets)
                {
                    // When output mapping we need to replace the recordset name if present with MasterRecordset
                    //
                    string masterRecordsetName;
                    if (isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
                    {
                        var field = def.Name;

                        string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                        if (!string.IsNullOrEmpty(recordsetName))
                        {
                            masterRecordsetName = recordsetName;
                        }
                        else
                        {
                            // we have no match, use the current mapping value ;)
                            masterRecordsetName = def.RecordSetName;
                        }

                        injectValue = FormatString(masterRecordsetName, field);
                    }
                    else
                    {
                        if (def.IsRecordSet)
                        {
                            if (fuzzyMatch != null)
                            {
                                string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                masterRecordsetName = !String.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                            }
                            else
                            {
                                masterRecordsetName = def.RecordSetName;
                            }

                            injectValue = FormatString(masterRecordsetName, def.Name);
                        }
                        else
                        {
                            injectValue = DataListUtil.AddBracketsToValueIfNotExist(def.Name);
                        }
                    }
                }
                var injectMapsTo = def.MapsTo;

                // no saved mappings add brackets ;)
                if (!string.IsNullOrEmpty(injectMapsTo) && string.IsNullOrEmpty(SavedInputMapping))
                {
                    injectMapsTo = DataListUtil.AddBracketsToValueIfNotExist(injectMapsTo);
                }
                else
                {
                    if (def.IsRecordSet)
                    {
                        var tmp = injectValue.Replace("()", "(*)");
                        injectMapsTo = tmp; // tag it as the same ;)
                    }
                    else
                    {
                        injectMapsTo = injectValue; // tag it as the same ;)
                    }
                }

                // def.RecordSetName -> recordsetName
                var viewModel = new InputOutputViewModel(def.Name, injectValue, injectMapsTo, def.DefaultValue, def.IsRequired, def.RecordSetName, def.EmptyToNull);
                viewModel.IsObject = def.IsObject;
                if (def.IsObject)
                {
                    var complexObjectItemModel = _complexObjects.FirstOrDefault(model => model.Name == def.Name);
                    if (complexObjectItemModel != null)
                    {
                        viewModel.JsonString = complexObjectItemModel.GetJson();
                    }
                }
                result.Add(viewModel);
            }

            return(result);
        }
コード例 #8
0
        /// <summary>
        /// Generates the match fragments from data list.
        /// </summary>
        /// <returns></returns>
        private FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {

                var dataListModel = new DataListModel();
                dataListModel.Create(DataList,DataList);
                IDictionary<Tuple<string, string>, string> tmp = new Dictionary<Tuple<string, string>, string>();

                    foreach (var rs in dataListModel.RecordSets)
                    {
                        // build map for each column in a recordset ;)
                        foreach (var col in rs.Columns)
                        {
                            foreach(var scalar in col.Value)
                            {
                                if (!tmp.Keys.Any(a => a.Item2 == scalar.Name && a.Item1 == rs.Name))
                                {
                                    tmp[new Tuple<string, string>(rs.Name, scalar.Name)] = rs.Name;
                                }
                            }

                        }
                    }

                result = new FuzzyMatchVo(tmp);

            }

            return result;
        }
コード例 #9
0
        /// <summary>
        /// Creates the mapping list.
        /// </summary>
        /// <param name="mappingDefinitions">The mapping definitions.</param>
        /// <param name="parser">The parser.</param>
        /// <param name="autoAddBrackets">if set to <c>true</c> [automatic add brackets].</param>
        /// <param name="isOutputMapping">if set to <c>true</c> [is output mapping].</param>
        /// <param name="fuzzyMatch">The fuzzy match.</param>
        /// <returns></returns>
        private IList<IInputOutputViewModel> CreateMappingList(string mappingDefinitions, IDev2LanguageParser parser, bool autoAddBrackets, bool isOutputMapping, FuzzyMatchVo fuzzyMatch = null)
        {
            IList<IInputOutputViewModel> result = new List<IInputOutputViewModel>();
            IList<IDev2Definition> concreteDefinitions = parser.ParseAndAllowBlanks(mappingDefinitions);

            var masterRecordsetName = string.Empty;

            foreach(var def in concreteDefinitions)
            {
                var injectValue = def.RawValue;

                if(!string.IsNullOrEmpty(injectValue) || IsWorkflow)
                {
                    if(autoAddBrackets)
                    {
                        // When output mapping we need to replace the recordset name if present with MasterRecordset
                        //
                        if(isOutputMapping && def.IsRecordSet && fuzzyMatch != null)
                        {
                            var field = DataListUtil.ExtractFieldNameFromValue(injectValue);

                            if(IsWorkflow)
                            {
                                field = def.Name;
                            }

                            string recordsetName = fuzzyMatch.FetchMatch(def.Name,def.RecordSetName);
                            if(!string.IsNullOrEmpty(recordsetName))
                            {
                                masterRecordsetName = recordsetName;
                            }
                            else
                            {
                                // we have no match, use the current mapping value ;)
                                masterRecordsetName = !IsWorkflow ? DataListUtil.ExtractRecordsetNameFromValue(injectValue) : def.RecordSetName;
                            }

                            injectValue = FormatString(masterRecordsetName, field);

                        }
                        else
                        {
                            if(def.IsRecordSet)
                            {
                                if(fuzzyMatch != null)
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !String.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }
                                else
                                {
                                    masterRecordsetName = def.RecordSetName;
                                }

                                injectValue = FormatString(masterRecordsetName, def.Name);
                            }
                            else
                            {
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(!IsWorkflow ? injectValue : def.Name);
                            }
                        }
                    }
                }
                else
                {
                    if(!def.IsRecordSet)
                    {
                        if(!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                        {
                            injectValue = DataListUtil.AddBracketsToValueIfNotExist(def.Name);
                        }
                    }
                    else
                    {
                        if(!isOutputMapping)
                        {
                            var field = def.Name;

                            if(fuzzyMatch != null && def.IsRecordSet)
                            {
                                if(string.IsNullOrEmpty(masterRecordsetName))
                                {
                                    string recordsetName = fuzzyMatch.FetchMatch(def.Name, def.RecordSetName);
                                    masterRecordsetName = !string.IsNullOrEmpty(recordsetName) ? recordsetName : def.RecordSetName;
                                }

                                injectValue = DataListUtil.ComposeIntoUserVisibleRecordset(masterRecordsetName,
                                                                                           string.Empty, field);
                                injectValue = DataListUtil.AddBracketsToValueIfNotExist(injectValue);
                            }
                            else
                            {
                                if(!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedInputMapping))
                                {
                                    injectValue = FormatString(def.RecordSetName, def.Name);
                                }
                            }
                        }
                        else
                        {
                            if(!String.IsNullOrEmpty(def.RawValue) && String.IsNullOrEmpty(SavedOutputMapping))
                            {
                                injectValue = FormatString(def.RecordSetName, def.Name);
                            }
                        }
                    }
                }

                var injectMapsTo = def.MapsTo;

                // no saved mappings add brackets ;)
                if(!string.IsNullOrEmpty(injectMapsTo) && string.IsNullOrEmpty(SavedInputMapping))
                {
                    injectMapsTo = DataListUtil.AddBracketsToValueIfNotExist(injectMapsTo);
                }
                else
                {
                    if(def.IsRecordSet)
                    {
                        var tmp = injectValue.Replace("()", "(*)");
                        injectMapsTo = tmp; // tag it as the same ;)
                    }
                    else
                    {
                        injectMapsTo = injectValue; // tag it as the same ;)
                    }
                }

                // def.RecordSetName -> recordsetName
                var viewModel = new InputOutputViewModel(def.Name, injectValue, injectMapsTo, def.DefaultValue, def.IsRequired, def.RecordSetName, def.EmptyToNull);

                result.Add(viewModel);
            }

            return result;
        }
コード例 #10
0
        /// <summary>
        /// Generates the match fragments from data list.
        /// </summary>
        /// <returns></returns>
        private FuzzyMatchVo GenerateMatchFragmentsFromDataList()
        {
            FuzzyMatchVo result = null;

            if (!string.IsNullOrEmpty(DataList))
            {
                var compiler = DataListFactory.CreateDataListCompiler();

                ErrorResultTO invokeErrors;
                var dlID = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), string.Empty.ToStringBuilder(), DataList.ToStringBuilder(), out invokeErrors);
                var dl = compiler.FetchBinaryDataList(dlID, out invokeErrors);
                IDictionary<Tuple<string, string>, string> tmp = new Dictionary<Tuple<string, string>, string>();

                if (dl != null)
                {
                    foreach (var rs in dl.FetchRecordsetEntries())
                    {
                        // build map for each column in a recordset ;)
                        foreach (var col in rs.Columns)
                        {
                            if (!tmp.Keys.Any(a => a.Item2 == col.ColumnName && a.Item1 == rs.Namespace))
                            {
                                tmp[new Tuple<string, string>(rs.Namespace, col.ColumnName)] = rs.Namespace;
                            }
                        }
                    }
                }

                result = new FuzzyMatchVo(tmp);

            }

            return result;
        }