Exemple #1
0
 private bool TryGetQueryItems(QueryX query, out List <Item> items, Item key = null)
 {
     items = null;
     if (query != null)
     {
         if (key == null)
         {
             if (Get <Relation_Store_QueryX>().TryGetParent(query, out Store sto))
             {
                 items = sto.GetItems();
             }
         }
         else
         {
             if (Get <Relation_Relation_QueryX>().TryGetParent(query, out Relation rel))
             {
                 if (query.IsReversed)
                 {
                     rel.TryGetParents(key, out items);
                 }
                 else
                 {
                     rel.TryGetChildren(key, out items);
                 }
             }
         }
         if (query.HasWhere)
         {
             items = ApplyFilter(query, items);
         }
     }
     return(items != null && items.Count > 0);
 }
Exemple #2
0
        private bool CanDropQueryXRelation(QueryX qx, Relation re)
        {
            GetHeadTail(qx, out Store p1, out Store c1);
            GetHeadTail(re, out Store p2, out Store c2);

            return(p1 == p2 || c1 == c2 || p1 == c2 || c1 == p2);
        }
Exemple #3
0
        private void ValidateQueryDependants(QueryX qx)
        {
            var QueryX_QueryX   = Get <Relation_QueryX_QueryX>();
            var ComputeX_QueryX = Get <Relation_ComputeX_QueryX>();
            var GraphX_QueryX   = Get <Relation_GraphX_QueryX>();
            var SymbolX_QueryX  = Get <Relation_SymbolX_QueryX>();
            var QueryXDomain    = Get <QueryXRoot>();

            while (QueryX_QueryX.TryGetParent(qx, out QueryX qp))
            {
                qx = qp;
            }

            if (ComputeX_QueryX.TryGetParent(qx, out ComputeX cx))
            {
                ValidateComputeQuery(cx, true);
            }
            else if (GraphX_QueryX.TryGetParent(qx, out GraphX gx))
            {
                ValidateGraphQuery(gx, true);
            }
            else if (SymbolX_QueryX.TryGetParent(qx, out SymbolX sx))
            {
                ValidateWhere(qx, qx, Get <Property_QueryX_Where>(), true);
            }
        }
Exemple #4
0
        internal Query(QueryX qx, Query parent, Item item, Item[] items)
        {
            Owner = qx;

            Item   = item;
            Items  = items;
            Parent = parent;

            SetState(qx.GetState()); // copy the queryX state flags
        }
Exemple #5
0
        internal void AddNewComputeX(Model_666_ComputeList m)
        {
            var st = m.Item;
            var cx = new ComputeX(_computeXManager, true);
            var qx = new QueryX(_queryXManager, QueryType.Value, true, true);

            // the data root implements undo/redo functionality
            ItemCreated.Record(Owner, cx);
            ItemCreated.Record(Owner, qx);
            ItemLinked.Record(Owner, _relation_Store_QueryX, st, qx);
            ItemLinked.Record(Owner, _relation_Store_ComputeX, st, cx);
            ItemLinked.Record(Owner, _relation_ComputeX_QueryX, cx, qx);
        }
Exemple #6
0
 internal void GetHeadTail(QueryX sx, out Store head, out Store tail)
 {
     if (Get <Relation_Relation_QueryX>().TryGetParent(sx, out Relation re))
     {
         GetHeadTail(re, out head, out tail);
         if (sx.IsReversed)
         {
             var temp = head; head = tail; tail = temp;
         }
     }
     else
     {
         Get <Relation_Store_QueryX>().TryGetParent(sx, out head);
         tail = head;
     }
 }
Exemple #7
0
        internal Store  GetQueryXTarget(QueryX qx)
        {
            Store target = null;

            if (Get <Relation_Relation_QueryX>().TryGetParent(qx, out Relation re))
            {
                GetHeadTail(re, out Store head, out target);
                if (qx.IsReversed)
                {
                    target = head;
                }
            }
            else
            {
                Get <Relation_Store_QueryX>().TryGetParent(qx, out target);
            }

            return(target);
        }
Exemple #8
0
        internal bool RefreshGraphX(QueryX qx)
        {
            var GraphX_QueryX = Get <Relation_GraphX_QueryX>();
            var QueryX_QueryX = Get <Relation_QueryX_QueryX>();

            var qr = qx;

            while (QueryX_QueryX.TryGetParent(qr, out qx))
            {
                qr = qx;
            }

            if (GraphX_QueryX.TryGetParent(qr, out GraphX gx))
            {
                RefreshGraphX(gx);
            }

            return(true);
        }
Exemple #9
0
        internal void SetComputeTypeProperty(ComputeX cx, CompuType type)
        {
            QueryX qh;

            if (!_relation_ComputeX_QueryX.TryGetChild(cx, out qh))
            {
                qh = new QueryX(_queryXManager, QueryType.Value);
                _relation_ComputeX_QueryX.SetLink(cx, qh);
            }
            if (cx.CompuType != type)
            {
                cx.CompuType = type;
                cx.Value.Clear();

                switch (type)
                {
                case CompuType.RowValue:
                    if (_relation_QueryX_QueryX.TryGetChildren(qh, out IList <QueryX> qxList))
                    {
                        foreach (var qx in qxList.ToArray())
                        {
                            _changeManager.RemoveItem(qx);
                        }
                        cx.ChildDelta++;
                        cx.AutoExpandRight = true;
                    }
                    break;

                case CompuType.RelatedValue:
                    break;

                case CompuType.CompositeString:
                    break;

                case CompuType.CompositeReversed:
                    break;
                }

                AllocateValueCache(cx);
            }
        }
Exemple #10
0
        bool ValidateSelect(QueryX qx, Item item, Property prop, bool clearError)
        {
            if (clearError)
            {
                ClearError(item, prop);
            }

            var sto = GetQueryXTarget(qx);

            if (qx.Select != null)
            {
                qx.ModelDelta++;
                if (qx.Select.TryValidate(sto))
                {
                    qx.Select.TryResolve();
                    if (qx.Select.AnyUnresolved)
                    {
                        var error = TryAddErrorMany(item, prop, IdKey.QueryUnresolvedSelectError);
                        if (error != null)
                        {
                            qx.Select.GetTree(error.List);
                        }
                        return(false);
                    }
                }
                else
                {
                    var error = TryAddErrorMany(item, prop, IdKey.QueryInvalidSelectError);
                    if (error != null)
                    {
                        qx.Select.GetTree(error.List);
                    }
                    return(false);
                }
            }
            return(true);
        }
Exemple #11
0
 internal int GetValueType(QueryX qx) => qx.Select is null ? (int)ValType.IsUnknown : (int)qx.Select.ValueType;
Exemple #12
0
        private (int L1, IList <Property> PropertyList, int L2, IList <QueryX> QueryList, int L3, IList <ViewX> ViewList) GetQueryXChildren(QueryX qx)
        {
            int L1 = Get <Relation_QueryX_Property>().TryGetChildren(qx, out IList <Property> ls1) ? ls1.Count : 0;
            int L2 = Get <Relation_QueryX_QueryX>().TryGetChildren(qx, out IList <QueryX> ls2) ? ls2.Count : 0;
            int L3 = Get <Relation_QueryX_ViewX>().TryGetChildren(qx, out IList <ViewX> ls3) ? ls3.Count : 0;

            return(L1, ls1, L2, ls2, L3, ls3);
        }
Exemple #13
0
 internal string GetWhereName(QueryX sx)
 {
     GetHeadTail(sx, out Store head, out Store tail);
     return(tail.GetNameId());
 }
Exemple #14
0
 internal string GetSelectName(QueryX vx)
 {
     GetHeadTail(vx, out Store head, out Store tail);
     return(tail.GetNameId());
 }
Exemple #15
0
 string GetRelationName(QueryX sd)
 {
     return(Get <Relation_Relation_QueryX>().TryGetParent(sd, out Relation rel) ? GetRelationName(rel) : null);
 }