示例#1
0
 private void ValidateComputeQuery(ComputeX cx, bool clearError = false)
 {
     cx.Value.Clear();
     cx.Value = ValuesUnknown;
     if (clearError)
     {
         ClearError(cx);
         ClearError(cx, Get <Property_ComputeX_Select>());
     }
     cx.ModelDelta++;
     if (!Get <Relation_ComputeX_QueryX>().TryGetChild(cx, out QueryX qx))
     {
         cx.Value = ValuesInvalid;
         TryAddErrorNone(cx, IdKey.ComputeMissingRootQueryError);
     }
     else
     {
         if (qx.Select == null)
         {
             if (cx.CompuType == CompuType.RowValue)
             {
                 TryAddErrorNone(cx, Get <Property_ComputeX_Select>(), IdKey.ComputeMissingSelectError);
             }
         }
         else
         {
             ValidateSelect(qx, cx, Get <Property_ComputeX_Select>(), clearError);
         }
     }
     if (Get <Relation_QueryX_QueryX>().TryGetChildren(qx, out IList <QueryX> children))
     {
         ValidateQueryHierarchy(children, clearError);
     }
     AllocateValueCache(cx);
 }
示例#2
0
        internal override bool LoadCache(ComputeX cx, Item key, List <Query> qList)
        {
            if (cx == null || qList == null || qList.Count == 0)
            {
                return(false);
            }

            var q = qList[0];

            if (q.Items == null || q.Items.Length == 0)
            {
                return(false);
            }

            var qx = q.QueryX;

            if (!qx.HasSelect)
            {
                return(false);
            }

            var k = q.Items[0];

            if (k == null)
            {
                return(false);
            }

            return((qx.Select.GetValue(k, out Int64 v)) ? SetValue(key, v) : false);
        }
示例#3
0
 private void ValidateComputeQuery(ComputeX cx, bool clearError = false)
 {
     cx.Value.Clear();
     cx.Value = Value.ValuesUnknown;
     if (clearError)
     {
         _errorManager.ClearError(cx);
         _errorManager.ClearError(cx, _property_ComputeX_Select);
     }
     cx.ModelDelta++;
     if (!_relation_ComputeX_QueryX.TryGetChild(cx, out QueryX qx))
     {
         cx.Value = Value.ValuesInvalid;
         _errorManager.TryAddErrorNone(cx, IdKey.Error_216_ComputeMissingRootQuery);
     }
     else
     {
         if (qx.Select == null)
         {
             if (cx.CompuType == CompuType.RowValue)
             {
                 _errorManager.TryAddErrorNone(cx, _property_ComputeX_Select, IdKey.Error_215_ComputeMissingSelect);
             }
         }
         else
         {
             ValidateSelect(qx, cx, _property_ComputeX_Select, clearError);
         }
     }
     if (_relation_QueryX_QueryX.TryGetChildren(qx, out IList <QueryX> children))
     {
         ValidateQueryHierarchy(children, clearError);
     }
     _computeXManager.AllocateValueCache(cx);
 }
示例#4
0
        private void AddNewComputeX(Root root)
        {
            var cx = new ComputeX(root.Get <ComputeXRoot>(), true);

            // the data root implements undo/redo functionality
            ItemCreated.Record(root, cx);
            ItemLinked.Record(root, root.Get <Relation_Store_ComputeX>(), TX, cx);
        }
示例#5
0
        internal bool TrySetSelectProperty(ComputeX cx, string value)
        {
            if (!Get <Relation_ComputeX_QueryX>().TryGetChild(cx, out QueryX qx))
            {
                return(false);
            }

            return(TrySetSelectProperty(qx, value));
        }
示例#6
0
        internal string GetSelectProperty(ComputeX cx)
        {
            if (!Get <Relation_ComputeX_QueryX>().TryGetChild(cx, out QueryX qx))
            {
                return(InvalidItem);
            }

            return((qx.HasSelect) ? qx.SelectString : null);
        }
示例#7
0
        private QueryX CreateQueryX(ComputeX cx, Store st)
        {
            var qxNew = new QueryX(this, QueryType.Value, true);

            ItemCreated.Record(Owner, qxNew);
            ItemLinked.Record(Owner, _relation_ComputeX_QueryX, cx, qxNew);
            ItemLinked.Record(Owner, _relation_Store_QueryX, st, qxNew);
            return(qxNew);
        }
示例#8
0
        internal void AddComputeXQueryX(ComputeX cx, QueryX qx1, Relation rx, bool isReversed)
        {
            qx1.IsTail = false;
            var qx2 = new QueryX(this, QueryType.Value);

            qx2.IsReversed = isReversed;
            ItemCreated.Record(Owner, qx2);
            ItemLinked.Record(Owner, _relation_QueryX_QueryX, qx1, qx2);
            ItemLinked.Record(Owner, _relation_Relation_QueryX, rx, qx2);
        }
示例#9
0
        internal bool TrySetComputeTypeProperty(ComputeX cx, int val)
        {
            var type = (CompuType)val;

            if (cx.CompuType != type)
            {
                cx.CompuType = type;
                cx.Value.Clear();
                AllocateValueCache(cx);
            }
            return(true);
        }
示例#10
0
        internal override bool LoadCache(ComputeX cx, Item key, List <Query> qList)
        {
            if (cx == null || qList == null || qList.Count == 0)
            {
                return(false);
            }

            var N = 0;

            foreach (var q in qList)
            {
                if (q.Items == null)
                {
                    continue;
                }
                var qx = q.QueryX;
                if (!qx.HasSelect)
                {
                    continue;
                }
                foreach (var k in q.Items)
                {
                    if (k != null)
                    {
                        N++;
                    }
                }
            }
            var v = new Int64[N];
            var i = 0;

            foreach (var q in qList)
            {
                if (q.Items == null)
                {
                    continue;
                }
                var qx = q.QueryX;
                if (!qx.HasSelect)
                {
                    continue;
                }
                foreach (var k in q.Items)
                {
                    if (k != null)
                    {
                        qx.Select.GetValue(k, out v[i++]);
                    }
                }
            }
            return(SetValue(key, v));
        }
示例#11
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);
        }
示例#12
0
        internal bool TryGetComputedValue(ComputeX cx, Item key)
        {/*
          * This method is called by valueDictionary when a key-value-pair does
          * not exist for the callers key.
          */
            if (!Get <Relation_ComputeX_QueryX>().TryGetChild(cx, out QueryX qx) || cx.Value.IsEmpty)
            {
                return(false);
            }

            switch (cx.CompuType)
            {
            case CompuType.RowValue: return(TryGetRowValue());

            case CompuType.RelatedValue: return(TryGetRelated());

            case CompuType.CompositeString: return(TryGetCompositeString());

            case CompuType.CompositeReversed: return(TryGetCompositeReversed());
            }
            return(false);

            //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

            bool TryGetRowValue()
            {
                if (!qx.HasValidSelect)
                {
                    return(false);
                }
                if (!qx.Select.GetValue(key, out string val))
                {
                    return(false);
                }

                cx.Value.SetValue(key, val);
                return(true);
            }

            bool TryGetRelated()
            {
                var selectors = new List <Query>();

                if (!TryGetForest(cx, key, selectors, out Query[] forest) || selectors.Count == 0)
                {
                    return(false);
                }

                return(cx.Value.LoadCache(cx, key, selectors));
            }
示例#13
0
        //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
        // the following used to transfer query results to the computeX's cache value
        //= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

        internal virtual bool LoadCache(ComputeX cx, Item key, List <Query> q) => false;
示例#14
0
 public void SetOwner(ComputeX cx)
 {
 }
示例#15
0
 /// <summary>This should a manually initiated action</summary>
 /// <param name="cx"></param>
 internal void RevalidateComputeX(ComputeX cx)
 {
     ValidateComputeQuery(cx, true);
     ResetItemTriggeredRefresh();
 }
示例#16
0
 public void SetOwner(ComputeX cx) => _owner = cx;
示例#17
0
 public void Release()
 {
     _owner = null;
     Clear();
     _values = null;
 }
示例#18
0
 internal virtual void SetOwner(ComputeX cx)
 {
 }
示例#19
0
 internal override void SetOwner(ComputeX cx) => _valueStore.SetOwner(cx);