コード例 #1
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                Evaluations = FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression ? new List <JsonMappingEvaluated> {
                    new JsonMappingEvaluated(env1, Compound.SourceName)
                } : ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                .Item
                .Where(x => !x.IsWarewolfAtomExpression)
                .Select(FsInteropFunctions.LanguageExpressionToString)
                .Select(x =>
                        new JsonMappingEvaluated(env1, x))
                .ToList();
            }
        }
コード例 #2
0
        public void ObjectName_GivenIsObjectAndObjectResult_ShouldUpdateDatalist()
        {
            //---------------Set up test pack-------------------
            CustomContainer.DeRegister <IShellViewModel>();
            var shellVm = new Mock <IShellViewModel>();

            shellVm.Setup(model => model.UpdateCurrentDataListWithObjectFromJson(It.IsAny <string>(), It.IsAny <string>())).Verifiable();
            CustomContainer.Register(shellVm.Object);
            var act = new DsfWebGetActivity {
                SourceId = Guid.NewGuid(), Outputs = null, IsObject = true
            };
            var outputsRegion = new OutputsRegion(ModelItemUtils.CreateModelItem(act), true)
            {
                ObjectResult = this.SerializeToJsonString(new DefaultSerializationBinder())
            };


            //---------------Assert Precondition----------------
            Assert.IsTrue(outputsRegion.IsObject);
            Assert.IsTrue(!string.IsNullOrEmpty(outputsRegion.ObjectResult));
            Assert.IsTrue(FsInteropFunctions.ParseLanguageExpressionWithoutUpdate("[[@objName]]").IsJsonIdentifierExpression);
            //---------------Execute Test ----------------------
            outputsRegion.ObjectName = "[[@objName]]";
            //---------------Test Result -----------------------
            shellVm.Verify(model => model.UpdateCurrentDataListWithObjectFromJson(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            Assert.AreEqual(outputsRegion.ObjectName, act.ObjectName);
        }
コード例 #3
0
        public void Given_ParseLanguageExpression_Should()
        {
            const string personChildName    = "[[@Person.Child.Name]]";
            var          languageExpression = FsInteropFunctions.ParseLanguageExpression(personChildName, 0);

            Assert.IsNotNull(languageExpression);
        }
コード例 #4
0
 private void UpdateDataListWithJsonObject(string expression)
 {
     if (IsObject && !string.IsNullOrEmpty(JsonString))
     {
         try
         {
             var language = FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(expression);
             if (language.IsJsonIdentifierExpression)
             {
                 if (DataListSingleton.ActiveDataList != null)
                 {
                     var objToProcess = JsonConvert.DeserializeObject(JsonString) as JObject;
                     var firstOrDefault = objToProcess?.Properties().FirstOrDefault();
                     if (firstOrDefault != null)
                     {
                         var processString = firstOrDefault.Value.ToString();
                         DataListSingleton.ActiveDataList.GenerateComplexObjectFromJson(
                             DataListUtil.RemoveLanguageBrackets(expression), processString);
                     }
                 }
             }
         }
         catch (Exception)
         {
             //Is not an object identifier
         }
     }
 }
コード例 #5
0
        public void Given_ParseLanguageExpressionWithoutUpdate_Should()
        {
            const string personChildName            = "[[@Person.Child.Name]]";
            var          languageExpression         = FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(personChildName);
            var          isJsonIdentifierExpression = languageExpression.IsJsonIdentifierExpression;

            Assert.IsNotNull(languageExpression);
            Assert.IsTrue(isJsonIdentifierExpression);
        }
コード例 #6
0
        public void Given_LanguageExpressionToString_Should()
        {
            const string personChildName = "[[@Person.Child.Name]]";

            Assert.IsNotNull(FsInteropFunctions.PositionColumn);
            var languageExpression         = FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(personChildName);
            var languageExpressionToString = FsInteropFunctions.LanguageExpressionToString(languageExpression);

            Assert.AreEqual(typeof(string), languageExpressionToString.GetType());
        }
コード例 #7
0
 string CalculateDestinationNameFromSourceName(string sourceName)
 {
     LanguageAST.LanguageExpression parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
     if (parsed.IsScalarExpression)
     {
         return(((LanguageAST.LanguageExpression.ScalarExpression)parsed).Item);
     }
     if (parsed.IsRecordSetExpression)
     {
         return(((LanguageAST.LanguageExpression.RecordSetExpression)parsed).Item.Column);
     }
     return(((LanguageAST.LanguageExpression.RecordSetNameExpression)parsed).Item.Name);
 }
コード例 #8
0
        public IList <string> FormatDsfActivityField(string activityField)
        {
            IList <string> result = new List <string>();

            var regions = DataListCleaningUtils.SplitIntoRegionsForFindMissing(activityField);

            foreach (var region in regions)
            {
                // Sashen: 09-10-2012 : Using the new parser
                var intellisenseParser = new SyntaxTreeBuilder();

                var nodes = intellisenseParser.Build(region);

                // No point in continuing ;)
                if (nodes == null)
                {
                    return(result);
                }

                if (intellisenseParser.EventLog.HasEventLogs)
                {
                    var languageParser = new Dev2DataLanguageParser();

                    try
                    {
                        result = languageParser.ParseForActivityDataItems(region);
                    }
                    catch (Dev2DataLanguageParseError)
                    {
                        return(new List <string>());
                    }
                    catch (NullReferenceException)
                    {
                        return(new List <string>());
                    }
                }
                var allNodes = new List <Node>();
                result = FormatDsfActivityField(result, intellisenseParser, nodes, allNodes);
            }
            try
            {
                FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(activityField);
            }
            catch (Exception)
            {
                return(result.Where(lang => activityField.Contains("[[" + lang + "]]")).ToList());
            }

            return(result);
        }
コード例 #9
0
#pragma warning disable S1541 // Methods and properties should not be too complex
        public static string ValidateInput(string sourceName)
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            try
            {
                var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
                if (parsed.IsComplexExpression)
                {
                    var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed;
                    if (complex.Item
                        .Any(x => x.IsRecordSetNameExpression))
                    {
                        return(ErrorResource.CannotCommaSeperateRecordset);
                    }
                    if (complex.Item.Count() < 3 ||
                        complex.Item.Count() % 2 != 1 ||

                        !Enumerable.Range(1, complex.Item.Count() - 1)
                        .Where(i => i % 2 == 1)
                        .Select(i =>

                                FsInteropFunctions.LanguageExpressionToString(
                                    complex.Item.ElementAt(i)
                                    ) == ",")
                        .Aggregate((a, b) => a && b))

                    {
                        return(ErrorResource.ExpressionMustBeCommaSeperated);
                    }
                }
                else
                {
                    if (!parsed.IsRecordSetNameExpression &&
                        !parsed.IsRecordSetExpression &&
                        !parsed.IsScalarExpression &&
                        !parsed.IsWarewolfAtomExpression)
                    {
                        return(ErrorResource.OnlyScalarRecordsetCommaSeperated);
                    }
                }
            }
            catch (Exception)
            {
                return(ErrorResource.UnableToParseSourceName);
            }
            return(null);
        }
コード例 #10
0
        public static string ValidateInput(string sourceName)
        {
            try
            {
                var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0);
                if (parsed.IsComplexExpression)
                {
                    var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed;
                    if (complex.Item
                        .Any(x => x.IsRecordSetNameExpression))
                    {
                        return(ErrorResource.CannotCommaSeperateRecordset);
                    }
                    if (complex.Item.Count() < 3 ||
                        complex.Item.Count() % 2 != 1 ||
                        // ReSharper disable MaximumChainedReferences
                        !Enumerable.Range(1, complex.Item.Count() - 1)
                        .Where(i => i % 2 == 1)
                        .Select(i =>

                                FsInteropFunctions.LanguageExpressionToString(
                                    complex.Item.ElementAt(i)
                                    ) == ",")
                        .Aggregate((a, b) => a && b))
                    // ReSharper restore MaximumChainedReferences
                    {
                        return(ErrorResource.ExpressionMustBeCommaSeperated);
                    }
                }
                else if (!parsed.IsRecordSetNameExpression &&
                         !parsed.IsRecordSetExpression &&
                         !parsed.IsScalarExpression &&
                         !parsed.IsWarewolfAtomExpression)
                {
                    return(ErrorResource.OnlyScalarRecordsetCommaSeperated);
                }
            }
            catch (Exception)
            {
                return(ErrorResource.UnableToParseSourceName);
            }
            return(null);
        }
コード例 #11
0
        public void GetValue(string s, List <IServiceInput> dt)
        {
            var exp = FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(s);

            if (exp.IsComplexExpression)
            {
                var item = ((LanguageAST.LanguageExpression.ComplexExpression)exp).Item;
                var vals = item.Where(a => a.IsRecordSetExpression || a.IsScalarExpression || a.IsJsonIdentifierExpression).Select(FsInteropFunctions.LanguageExpressionToString);
                dt.AddRange(vals.Select(a => new ServiceInput(a, "")));
            }
            if (exp.IsScalarExpression)
            {
                dt.Add(new ServiceInput(s, ""));
            }
            if (exp.IsRecordSetExpression)
            {
                dt.Add(new ServiceInput(s, ""));
            }
            if (exp.IsJsonIdentifierExpression)
            {
                dt.Add(new ServiceInput(s, ""));
            }
        }
コード例 #12
0
        public JsonMappingCompoundTo(
            IExecutionEnvironment env,
            JsonMappingTo compound)
        {
            var env1 = env;

            Compound    = compound;
            Evaluations = new List <JsonMappingEvaluated>();

            if (!IsCompound)
            {
                Evaluations.Add(new JsonMappingEvaluated(env1, compound.SourceName));
            }
            else
            {
                if (FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0).IsRecordSetNameExpression)
                {
                    Evaluations = new List <JsonMappingEvaluated> {
                        new JsonMappingEvaluated(env1, Compound.SourceName)
                    };
                }
                else
                {
                    // we know this is a comma seperated list of expressions
                    Evaluations =
                        // ReSharper disable MaximumChainedReferences
                        ((LanguageAST.LanguageExpression.ComplexExpression)FsInteropFunctions.ParseLanguageExpression(Compound.SourceName, 0))
                        .Item
                        .Where(x => !x.IsWarewolfAtomExpression)
                        .Select(FsInteropFunctions.LanguageExpressionToString)
                        .Select(x =>
                                new JsonMappingEvaluated(env1, x))
                        .ToList();
                }         // ReSharper restore MaximumChainedReferences
            }
        }
コード例 #13
0
        /// <summary>
        /// Is the list.
        /// </summary>
        /// <param name="activityField">The activity field.</param>
        /// <returns></returns>
        public IList <string> FormatDsfActivityField(string activityField)
        {
            //2013.06.10: Ashley Lewis for bug 9306 - handle the case of miss-matched region braces

            IList <string> result = new List <string>();

            var regions = DataListCleaningUtils.SplitIntoRegionsForFindMissing(activityField);

            foreach (var region in regions)
            {
                // Sashen: 09-10-2012 : Using the new parser
                var intellisenseParser = new SyntaxTreeBuilder();

                Node[] nodes = intellisenseParser.Build(region);

                // No point in continuing ;)
                if (nodes == null)
                {
                    return(result);
                }

                if (intellisenseParser.EventLog.HasEventLogs)
                {
                    IDev2StudioDataLanguageParser languageParser = DataListFactory.CreateStudioLanguageParser();

                    try
                    {
                        result = languageParser.ParseForActivityDataItems(region);
                    }
                    catch (Dev2DataLanguageParseError)
                    {
                        return(new List <string>());
                    }
                    catch (NullReferenceException)
                    {
                        return(new List <string>());
                    }
                }
                var allNodes = new List <Node>();


                if (nodes.Any() && !intellisenseParser.EventLog.HasEventLogs)
                {
                    nodes[0].CollectNodes(allNodes);

                    // ReSharper disable once ForCanBeConvertedToForeach
                    for (int i = 0; i < allNodes.Count; i++)
                    {
                        if (allNodes[i] is DatalistRecordSetNode)
                        {
                            var    refNode  = allNodes[i] as DatalistRecordSetNode;
                            string nodeName = refNode.GetRepresentationForEvaluation();
                            nodeName = nodeName.Substring(2, nodeName.Length - 4);
                            result.Add(nodeName);
                        }
                        else if (allNodes[i] is DatalistReferenceNode)
                        {
                            var    refNode  = allNodes[i] as DatalistReferenceNode;
                            string nodeName = refNode.GetRepresentationForEvaluation();
                            nodeName = nodeName.Substring(2, nodeName.Length - 4);
                            result.Add(nodeName);
                        }
                    }
                }
            }
            try
            {
                FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(activityField);
            }
            catch (Exception)
            {
                return(result.Where(lang => activityField.Contains("[[" + lang + "]]")).ToList());
            }

            return(result);
        }