コード例 #1
0
        public static string GetDisplayTextExcludeDots(this ModelElementObjectBase node)
        {
            var preffix = (node.ParentId.HasValue && node.ModelElementType != TreeNodeType.Bp) ? $"{node.ModelElementType.ToString().ToLowerInvariant()}" : string.Empty;
            var code    = preffix != "" ? node.Code.ToUpperCamelCaseName() : node.Code;

            return($"{preffix}{code}");
        }
コード例 #2
0
 public List <SingleQuery> GeneratePostQuery(SingleQuery path,
                                             JToken value,
                                             ModelElementObjectBase classDescription,
                                             IList <ModelElementObjectBase> allClassDescriptions)
 {
     return(FillSetQuery(path, value, classDescription, allClassDescriptions, true));
 }
コード例 #3
0
        public static ModelElementObjectBase FindByElementId(this IList <ModelElementObjectBase> elementDescriptions, string elementId)
        {
            var elId = new Guid(elementId);

            ModelElementObjectBase result = elementDescriptions.FirstOrDefault(x => x.Id == elId);

            if (result != null)
            {
                return(result);
            }

            var prop = elementDescriptions.First().FindByElementId(elementId);

            if (prop != null)
            {
                result = elementDescriptions.FirstOrDefault(x => x.ModelDefinitionId == prop.LinkedModelDefinitionId);

                if (result != null)
                {
                    result = new ModelElementObjectBase(result);

                    result.ModelElementType = prop.ModelElementType;

                    result.Children = result.Children.Union(prop.Children).ToList();

                    return(result);
                }

                return(prop);
            }

            return(null);
        }
コード例 #4
0
        private static ModelElementObjectBase FindByPathInternal(this ModelElementObjectBase element, string path, string parentPath, bool useDots)
        {
            if (path == "" && parentPath == "")
            {
                return(element);
            }

            if (parentPath != "")
            {
                parentPath += ".";
            }

            foreach (var child in element.Children)
            {
                var displayText = useDots ? child.DisplayText : child.GetDisplayTextExcludeDots();

                if (path == parentPath + displayText)
                {
                    return(child);
                }

                var res = child.FindByPathInternal(path, parentPath, useDots);

                if (res != null)
                {
                    return(res);
                }
            }

            return(null);
        }
コード例 #5
0
        private ModelElementObjectBase GetCurrentElementInfo(string path, ModelElementObjectBase root)
        {
            var current = root.FindInTreeByPath(path, true);

            if (current == null)
            {
                throw new Exception("No such model element");
            }

            return(current);
        }
コード例 #6
0
        public SingleQuery GeneratePutQuery(SingleQuery path,
                                            JToken value,
                                            ModelElementObjectBase classDescription,
                                            IList <ModelElementObjectBase> allClassDescriptions)
        {
            var add = path.MakeCopy();

            FillAddQuery(add, value, classDescription, allClassDescriptions);

            var query = this.queryLanguageBuilder.RenderQuery(add);

            this.logger.Debug($"Generated query: {query}");

            return(add);
        }
コード例 #7
0
        public static ModelElementObjectBase FindByElement(this IModelElementStorage modelElementStorage, ModelElementObjectBase property)
        {
            var originalProperty = modelElementStorage.GetModelElementTree(property.ModelDefinitionId).FindByElementId(property.Id.ToString());

            var result = new ModelElementObjectBase(originalProperty);

            if (originalProperty.LinkedModelDefinitionId.HasValue)
            {
                var linkedModel = modelElementStorage.GetModelElementTree(originalProperty.LinkedModelDefinitionId.Value);

                result.Children = result.Children.Union(linkedModel.Children).ToList();
            }

            return(result);
        }
コード例 #8
0
        public static ModelElementObjectBase FindByElementId(this ModelElementObjectBase element, string elementId)
        {
            var elementIdGuid = new Guid(elementId);

            foreach (var child in element.Children)
            {
                if (elementIdGuid == child.Id)
                {
                    return(child);
                }

                var res = child.FindByElementId(elementId);

                if (res != null)
                {
                    return(res);
                }
            }

            return(null);
        }
コード例 #9
0
        public ExecutionResult <ApiActionInfo> HandleRequest(string requestUri,
                                                             JObject body,
                                                             HttpVerbs verb,
                                                             bool useDots = true)
        {
            var result = new ApiActionInfo();

            string tags = requestUri;

            var edmObject   = new JObject();
            var currentNode = edmObject;
            ModelElementObjectBase currentElement = null;
            PivotDefinition        pivot          = null;
            bool isProperty = false;
            bool isId       = false;

            foreach (var tag in tags.Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries))
            {
                Guid id;
                if (Guid.TryParse(tag, out id))
                {
                    isProperty = false;
                    isId       = true;
                    currentNode.Add(ObjectHelper.IdPropName, id);
                }
                else
                {
                    if (result.PathItems.Any() == false)
                    {
                        currentElement = this.modelElementStorage.GetModelElementTree(tag);

                        if (currentElement == null)
                        {
                            return(ExecutionResult.ErrorResultFor(result, "404", $"Uri must starts from {currentElement.DisplayText}, but {tag} found."));
                        }

                        result.PathItems.Add(currentElement.DisplayText);
                    }
                    else
                    {
                        //parent tag
                        if (pivot.Type != PivotType.BusinessProcess && pivot.IsIntent && isProperty)
                        {
                            return(ExecutionResult.ErrorResultFor(result, "404", $"Must be id after {currentElement.DisplayText}, found {tag}."));
                        }

                        currentElement = currentElement.FindByPath(tag, useDots);

                        if (currentElement == null)
                        {
                            return(ExecutionResult.ErrorResultFor(result, "404", $"There no property {tag}."));
                        }

                        result.PathItems.Add(currentElement.DisplayText);
                    }

                    isProperty = true;
                    isId       = false;

                    pivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[currentElement.ModelElementType]);

                    if (pivot.IsCollection)
                    {
                        var newNode = new JObject();
                        currentNode.Add(currentElement.DisplayText, new JArray(newNode));
                        currentNode = newNode;
                    }
                    else
                    {
                        var newNode = new JObject();
                        currentNode.Add(currentElement.DisplayText, newNode);
                        currentNode = newNode;
                    }
                }
            }

            if (pivot.Type == PivotType.Value && isProperty)
            {
                return(ExecutionResult.ErrorResultFor(result, "404", $"Must have id after {currentElement.DisplayText}, found."));
            }

            result.EdmObject   = edmObject;
            result.EventAction = DynamicApiHelper.GetEventAction(verb, pivot.Type, isId);

            if ((result.EventAction == EventAction.Add || result.EventAction == EventAction.Initiate ||
                 result.EventAction == EventAction.Set) && body == null)
            {
                return(ExecutionResult.ErrorResultFor(result, "404", $"Request body must not be null for {result.EventAction}."));
            }

            if (body != null)
            {
                foreach (var property in body.Properties())
                {
                    currentNode.Add(property.Name, property.Value);
                }

                if (DynamicApiHelper.MustHaveOperationInEdm(result.EventAction))
                {
                    currentNode.Add("$operation", result.EventAction.ToString().ToLowerInvariant());
                }
            }

            result.PlaceForBody = currentNode;

            return(ExecutionResult.SuccessResult(result));
        }
コード例 #10
0
        public JToken CamelCaseToDotsInFilterInternal(JToken obj, ModelElementObjectBase currentClassDescription)
        {
            if (obj == null)
            {
                return(null);
            }

            switch (obj.Type)
            {
            case JTokenType.Array:
            {
                var arr    = (JArray)obj;
                var result = new JArray();
                foreach (var token in arr.Children())
                {
                    result.Add(CamelCaseToDotsInFilterInternal(token, currentClassDescription));
                }

                return(result);
            }

            case JTokenType.Object:
            {
                var typedObj = (JObject)obj;
                var res      = new JObject();
                var pivot    = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[currentClassDescription.ModelElementType]);
                var pivotCommonProperties = pivot.GetAllCommonProperties();

                foreach (var child in typedObj.Properties())
                {
                    if (child.Name.StartsWith("$"))
                    {
                        res.Add(child.Name, child.Value);
                    }
                    else
                    {
                        var prop =
                            currentClassDescription.Children.FirstOrDefault(
                                x => x.GetDisplayTextExcludeDots() == child.Name);

                        if (prop != null)
                        {
                            var propRes = CamelCaseToDotsInFilterInternal(child.Value,
                                                                          this.modelElementStorage.FindByElement(prop));

                            res.Add(prop.DisplayText, propRes);
                        }
                        else if (pivotCommonProperties.Contains(child.Name))
                        {
                            res.Add(child.Name, child.Value);
                        }
                    }
                }

                return(res);
            }

            default:
                return(obj);
            }
        }
コード例 #11
0
        public JObject Circumcise(JObject obj, ModelElementObjectBase classDescription, string path,
                                  IDictionary <string, IList <ModelElementObjectBase> > allViewModels,
                                  bool excludeDots)
        {
            if (obj == null)
            {
                return(null);
            }

            var result = new JObject();

            var pivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[classDescription.ModelElementType]);

            foreach (var property in pivot.GetAllCommonProperties())
            {
                var token = obj[property];

                if (token != null)
                {
                    if ((property == ObjectHelper.CreatedInfoPropName || property == ObjectHelper.UpdatedInfoPropName) &&
                        token.Type == JTokenType.String)
                    {
                        token = JToken.Parse(token.Value <string>());
                    }

                    result.Add(property, token);
                }
            }

            var viewModel = allViewModels.Where(kv => path.StartsWith(kv.Key))
                            .Select(kv => kv.Value)
                            .FirstOrDefault();

            foreach (var property in classDescription.Children)
            {
                if (obj[property.DisplayText] != null)
                {
                    var resultPropertyDisplayText = excludeDots ? property.GetDisplayTextExcludeDots() : property.DisplayText;

                    if (viewModel != null && viewModel.Any(x => x.Id == property.Id) == false)
                    {
                        continue;
                    }

                    ModelElementObjectBase childClassDescription = null;

                    if (property.LinkedModelDefinitionId.HasValue)
                    {
                        childClassDescription = this.modelElementStorage.GetModelElementTree(property.LinkedModelDefinitionId.Value);
                    }

                    if (childClassDescription != null || property.Children.Any())
                    {
                        var childToken = obj[property.DisplayText];

                        if (childClassDescription != null)
                        {
                            childClassDescription          = new ModelElementObjectBase(childClassDescription);
                            childClassDescription.Children =
                                childClassDescription.Children.Union(property.Children).ToList();
                            childClassDescription.ModelElementType = property.ModelElementType;
                        }
                        else if (property.Children.Any())
                        {
                            childClassDescription = property;
                        }

                        if (childToken.Type == JTokenType.Array)
                        {
                            var childArray    = childToken as JArray;
                            var childArrayRes = new JArray();

                            foreach (var childArrayItem in childArray.Children())
                            {
                                var childObject   = childArrayItem as JObject;
                                var childProperty = this.Circumcise(childObject, childClassDescription, path + "." + property.DisplayText, allViewModels, excludeDots);
                                childArrayRes.Add(childProperty);
                            }

                            result.Add(resultPropertyDisplayText, childArrayRes);
                        }
                        else
                        {
                            var childObject = childToken as JObject;

                            var childProperty = this.Circumcise(childObject, childClassDescription, path + "." + property.DisplayText, allViewModels, excludeDots);

                            result.Add(resultPropertyDisplayText, childProperty);
                        }
                    }
                    else
                    {
                        result.Add(resultPropertyDisplayText, obj[property.DisplayText]);
                    }
                }
            }

            var ac = obj["ac"] as JArray;

            if (ac != null)
            {
                var resAc = new JArray();

                foreach (var acItem in ac)
                {
                    if (acItem[ObjectHelper.ObjectCodePropName] != null)
                    {
                        var code = acItem[ObjectHelper.ObjectCodePropName].Value <string>();
                        var acClassDescription =
                            classDescription.Children.FirstOrDefault(
                                x => x.ModelElementType == TreeNodeType.Ac && x.Code == code);

                        if (acClassDescription != null)
                        {
                            var resAcItem = this.Circumcise(acItem as JObject, acClassDescription,
                                                            path + "." + acClassDescription.DisplayText, allViewModels,
                                                            excludeDots);

                            resAc.Add(resAcItem);
                        }
                    }
                }

                result.Add("ac", resAc);
            }

            return(result);
        }
コード例 #12
0
        public JObject CamelCaseToDots(JObject obj, ModelElementObjectBase classDescription, string path)
        {
            if (obj == null)
            {
                return(null);
            }

            var result = new JObject();

            var pivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[classDescription.ModelElementType]);

            foreach (var property in pivot.GetAllCommonProperties())
            {
                var token = obj[property];

                if (token != null)
                {
                    if ((property == ObjectHelper.CreatedInfoPropName || property == ObjectHelper.UpdatedInfoPropName) &&
                        token.Type == JTokenType.String)
                    {
                        token = JToken.Parse(token.Value <string>());
                    }

                    result.Add(property, token);
                }
            }

            foreach (var property in classDescription.Children)
            {
                var propertyNameMayBe = property.GetDisplayTextExcludeDots();

                var izvratOrNormalPropertyNames = new List <string> {
                    propertyNameMayBe
                };

                if (property.IsIzvratProperty())
                {
                    izvratOrNormalPropertyNames = obj.Properties()
                                                  .Where(x => x.Name.StartsWith(propertyNameMayBe))
                                                  .Select(x => x.Name.Substring(propertyNameMayBe.Length))
                                                  .Where(x => x.StartsWith("."))
                                                  .Select(x => x.Substring(1).Trim())
                                                  .Where(x => string.IsNullOrEmpty(x) == false)
                                                  .Select(x => $"{propertyNameMayBe}.{x}")
                                                  .ToList();
                }

                foreach (var propertyName in izvratOrNormalPropertyNames)
                {
                    if (obj[propertyName] != null)
                    {
                        ModelElementObjectBase childClassDescription = null;

                        if (property.LinkedModelDefinitionId != null)
                        {
                            childClassDescription = this.modelElementStorage.GetModelElementTree(property.LinkedModelDefinitionId.Value);
                        }

                        if (childClassDescription != null || property.Children.Any())
                        {
                            var childToken = obj[propertyName];

                            if (property.Children.Any() && childClassDescription != null)
                            {
                                childClassDescription          = new ModelElementObjectBase(childClassDescription);
                                childClassDescription.Children =
                                    childClassDescription.Children.Union(property.Children).ToList();
                            }
                            else if (childClassDescription == null && property.Children.Any())
                            {
                                childClassDescription = property;
                            }

                            if (childToken.Type == JTokenType.Array)
                            {
                                var childArray    = childToken as JArray;
                                var childArrayRes = new JArray();

                                foreach (var childArrayItem in childArray.Children())
                                {
                                    var childObject   = childArrayItem as JObject;
                                    var childProperty = this.CamelCaseToDots(childObject, childClassDescription, path + "." + property.DisplayText);
                                    childArrayRes.Add(childProperty);
                                }

                                result.Add(property.DisplayText, childArrayRes);
                            }
                            else
                            {
                                var childObject = childToken as JObject;

                                var childProperty = this.CamelCaseToDots(childObject, childClassDescription, path + "." + property.DisplayText);

                                result.Add(property.DisplayText, childProperty);
                            }
                        }
                        else
                        {
                            result.Add(property.DisplayText, obj[propertyName]);
                        }
                    }
                }
            }

            return(result);
        }
コード例 #13
0
        private List <SingleQuery> FillSetQuery(SingleQuery path, JToken value, ModelElementObjectBase classDescription,
                                                IList <ModelElementObjectBase> allClassDescriptions, bool forceSet)
        {
            var children = classDescription.Children.ToList();

            var result = new List <SingleQuery>();

            path = path.MakeCopy();
            if (forceSet)
            {
                path.NodesList.First.Value.Type = QueryNodeType.Property;
            }

            var set = path.MakeCopy().MethodSet();

            var hasVx = false;

            if (value == null)
            {
                throw new InvalidOperationException("Value can not be null");
            }

            if (value.Type != JTokenType.Object)
            {
                throw new InvalidOperationException($"Value for being setted on {path} path should be object, but was {value.Type}");
            }

            foreach (var propertyDescription in children)
            {
                var propertyPivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[propertyDescription.ModelElementType]);
                var propertyToken = value[propertyDescription.DisplayText];

                if (propertyToken != null)
                {
                    if (propertyPivot.IsIntent)
                    {
                        throw new InvalidOperationException($"Intents must be edited independently. But you've sent {path}.{propertyDescription.DisplayText}");
                    }
                }

                //todo: initiate?
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Vx))
            {
                var propertyToken = value[propertyDescription.DisplayText];
                if (propertyToken != null)
                {
                    if (forceSet && propertyToken.Type == JTokenType.Null)
                    {
                        continue;
                    }

                    var vxTypeDescription = allClassDescriptions.FirstOrDefault(x => x.ModelDefinitionId == propertyDescription.LinkedModelDefinitionId);
                    hasVx = true;



                    if (vxTypeDescription != null)
                    {
                        var set2 = path.MakeCopy().AddProperty(ParserHelper.GetPivotName(PivotType.Value))
                                   .SetPivot(PivotType.Value, propertyDescription.Code);

                        result.AddRange(FillSetQuery(set2, propertyToken, vxTypeDescription, allClassDescriptions, true));
                    }
                    else
                    {
                        if (propertyToken.Type != JTokenType.Null && propertyDescription.DataType != null)
                        {
                            switch (propertyDescription.DataType)
                            {
                            case DataType.Boolean:
                                if (propertyToken.Type != JTokenType.Boolean)
                                {
                                    throw new InvalidOperationException($"Value for the property {propertyDescription.DisplayText} should be bool, but was {value.Type}");
                                }
                                break;

                            case DataType.Number:
                                if ((propertyToken.Type == JTokenType.Float) || propertyToken.Type == JTokenType.Integer)
                                {
                                    throw new InvalidOperationException($"Value for the property {propertyDescription.DisplayText} should be bool, but was {value.Type}");
                                }
                                break;
                            }
                        }

                        set.AddArgument(
                            x => x.ArgumentSubjectQuery = SingleQuery.InitiateQuery()
                                                          .AddProperty("vx")
                                                          .SetPivot(PivotType.Value, propertyDescription.Code),
                            x => x.ArgumentValueConstant = propertyToken.ToPrimitiveObject());
                    }
                }
            }

            var pivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[classDescription.ModelElementType]);

            foreach (var property in pivot.GetAllCommonProperties())
            {
                var propertyToken = value[property];
                if (propertyToken != null)
                {
                    if (forceSet && propertyToken.Type == JTokenType.Null)
                    {
                        continue;
                    }

                    hasVx = true;

                    set.AddArgument(
                        x => x.ArgumentSubjectQuery  = SingleQuery.InitiateQuery().AddProperty(property),
                        x => x.ArgumentValueConstant = propertyToken.ToPrimitiveObject());
                }
            }

            if (hasVx || forceSet)
            {
                result.Add(set);
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Md))
            {
                var token = value[propertyDescription.DisplayText];

                if (token != null)
                {
                    if (token.Type != JTokenType.Array)
                    {
                        throw new InvalidOperationException($"Value for being setted on {path} path should be an array, but was {value.Type}");
                    }

                    var arrayPropertyToken = (JArray)token;

                    foreach (var propertyToken in arrayPropertyToken)
                    {
                        if (propertyToken.Type != JTokenType.Object ||
                            propertyToken[ObjectHelper.CapacityPropName] == null ||
                            propertyToken[ObjectHelper.CapacityPropName].Type != JTokenType.String ||
                            propertyToken[ObjectHelper.IdPropName] == null ||
                            propertyToken[ObjectHelper.IdPropName].Type != JTokenType.String)
                        {
                            throw new InvalidOperationException($"Value for md being setted at {path} path should be an array, " +
                                                                $"with objects containing id and capacity string properties. " +
                                                                $"But was {arrayPropertyToken}");
                        }

                        var add = path.MakeCopy()
                                  .MethodAdd()
                                  .SetPivot(PivotType.MasterData, propertyDescription.Code, (string)propertyToken["capacity"])
                                  .AddArgument(
                            x => x.ArgumentSubjectQuery  = SingleQuery.InitiateQuery().AddProperty("id"),
                            x => x.ArgumentValueConstant = (string)propertyToken["id"]);

                        result.Add(add);
                    }
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Ae))
            {
                var aeTypeDescription = allClassDescriptions.FindByElementId(propertyDescription.Id.ToString());
                var token             = value[propertyDescription.DisplayText];

                if (token != null)
                {
                    if (token.Type != JTokenType.Array)
                    {
                        throw new InvalidOperationException(
                                  $"Value for being setted on {path} path should be an array, but was {value.Type}");
                    }

                    var arrayPropertyToken = (JArray)token;

                    foreach (var propertyToken in arrayPropertyToken)
                    {
                        if (propertyToken.Type != JTokenType.Object ||
                            propertyToken[ObjectHelper.CodePropName] == null ||
                            propertyToken[ObjectHelper.CodePropName].Type != JTokenType.String)
                        {
                            throw new InvalidOperationException($"Value for ae being setted at {path} path should be an array, " +
                                                                $"with objects containing code string property and other details. " +
                                                                $"But was {arrayPropertyToken}");
                        }


                        var add = path.MakeCopy()
                                  .MethodAdd()
                                  .SetPivot(PivotType.Attributes, propertyDescription.Code, (string)propertyToken["code"]);

                        aeTypeDescription = new ModelElementObjectBase(aeTypeDescription);
                        aeTypeDescription.ModelElementType = TreeNodeType.Ae;

                        FillAddQuery(add, propertyToken, aeTypeDescription, allClassDescriptions);

                        result.Add(add);
                    }
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Ts))
            {
                var tsTypeDescription = allClassDescriptions.FindByElementId(propertyDescription.Id.ToString());

                var token = value[propertyDescription.DisplayText];

                var arrayPropertyToken = token as JArray;

                if (arrayPropertyToken != null)
                {
                    foreach (var propertyToken in arrayPropertyToken)
                    {
                        var add = path.MakeCopy()
                                  .MethodAdd()
                                  .SetPivot(PivotType.Task, propertyDescription.Code, (string)propertyToken["code"]);

                        FillAddQuery(add, propertyToken, tsTypeDescription, allClassDescriptions);

                        result.Add(add);
                    }
                }
            }

            foreach (var singleQuery in result)
            {
                var query = this.queryLanguageBuilder.RenderQuery(singleQuery);

                this.logger.Debug($"Generated query: {query}");
            }

            return(result);
        }
コード例 #14
0
        private void FillAddQuery(SingleQuery path,
                                  JToken value,
                                  ModelElementObjectBase classDescription,
                                  IList <ModelElementObjectBase> allClassDescriptions)
        {
            var children = classDescription.Children.ToList();

            var pivot = ParserHelper.GetPivot(ParserHelper.TreeNodeTypeToPivot[classDescription.ModelElementType]);

            foreach (var property in pivot.GetAllCommonProperties())
            {
                var propertyToken = value[property];
                if (propertyToken != null)
                {
                    if (propertyToken.Type == JTokenType.Null)
                    {
                        continue;
                    }

                    path.AddArgument(
                        x => x.ArgumentSubjectQuery  = SingleQuery.InitiateQuery().AddProperty(property),
                        x => x.ArgumentValueConstant = propertyToken.ToPrimitiveObject());
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Vx))
            {
                var propertyToken = value[propertyDescription.DisplayText];
                if (propertyToken != null && propertyToken.Type != JTokenType.Null)
                {
                    //todo: composite vx

                    var vxTypeDescription = allClassDescriptions.FirstOrDefault(x => x.ModelDefinitionId == propertyDescription.LinkedModelDefinitionId);

                    if (vxTypeDescription != null)
                    {
                        throw new InvalidOperationException("Vx must not be a complex object for addition");
                    }

                    path.AddArgument(
                        x => x.ArgumentSubjectQuery = SingleQuery.InitiateQuery()
                                                      .AddProperty("vx")
                                                      .SetPivot(PivotType.Value, propertyDescription.Code),
                        x => x.ArgumentValueConstant = propertyToken.ToPrimitiveObject());
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Md))
            {
                var arrayPropertyToken = value[propertyDescription.DisplayText] as JArray;

                if (arrayPropertyToken != null)
                {
                    foreach (var propertyToken in arrayPropertyToken)
                    {
                        var add = SingleQuery.InitiateQuery()
                                  .AddCollection("md")
                                  .SetPivot(PivotType.MasterData, propertyDescription.Code, (string)propertyToken["capacity"])
                                  .MethodAdd()
                                  .AddArgument(
                            x => x.ArgumentSubjectQuery  = SingleQuery.InitiateQuery().AddProperty("id"),
                            x => x.ArgumentValueConstant = (string)propertyToken["id"]);

                        path.AddArgument(x => x.ArgumentValueQuery = add);
                    }
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Ae))
            {
                var aeTypeDescription  = allClassDescriptions.FirstOrDefault(x => x.ModelDefinitionId == propertyDescription.LinkedViewModelId);
                var arrayPropertyToken = value[propertyDescription.DisplayText] as JArray;

                if (aeTypeDescription != null && arrayPropertyToken != null)
                {
                    foreach (var propertyToken in arrayPropertyToken)
                    {
                        var add = SingleQuery.InitiateQuery()
                                  .AddCollection("ae")
                                  .SetPivot(PivotType.Attributes, propertyDescription.Code)
                                  .MethodAdd();

                        aeTypeDescription = new ModelElementObjectBase(aeTypeDescription);
                        aeTypeDescription.ModelElementType = TreeNodeType.Ae;

                        FillAddQuery(add, propertyToken, aeTypeDescription, allClassDescriptions);

                        path.AddArgument(x => x.ArgumentValueQuery = add);
                    }
                }
            }

            foreach (var propertyDescription in children.Where(x => x.ModelElementType == TreeNodeType.Ts))
            {
                var eeTypeDescription = allClassDescriptions.FirstOrDefault(x => x.ModelDefinitionId == propertyDescription.LinkedModelDefinitionId);
                var propertyToken     = value[propertyDescription.DisplayText];

                if (eeTypeDescription != null && propertyToken != null)
                {
                    var add = path.MakeCopy()
                              .MethodAdd()
                              .SetPivot(PivotType.Task, propertyDescription.Code, (string)propertyToken["code"]);

                    FillSetQuery(add, propertyToken, eeTypeDescription, allClassDescriptions, false);

                    path.AddArgument(x => x.ArgumentValueQuery = add);
                }
            }
        }
コード例 #15
0
 public static bool IsIzvratProperty(this ModelElementObjectBase node)
 {
     return
         (DynamicApiHelper.IzvratPropertiesPivots.Contains(ParserHelper.TreeNodeTypeToPivot[node.ModelElementType]));
 }
コード例 #16
0
 public static ModelElementObjectBase FindByPath(this ModelElementObjectBase element, string path, bool useDots)
 {
     return(element.FindByPathInternal(path, "", useDots));
 }