Exemplo n.º 1
0
        private void RemoveNameProperty(Root root)
        {
            var pm = Owner as ItemModel;
            var tx = pm.GetItem();

            pm.ChildDelta++;
            ItemUnLinked.Record(root, root.Get <Relation_Store_NameProperty>(), tx, Item);
        }
        private void RemoveSummaryProperty(Root root)
        {
            var pm = Owner as LineModel;
            var tx = pm.Item;

            pm.ChildDelta++;
            ItemUnLinked.Record(root, root.Get <Relation_Store_SummaryProperty>(), tx, Item);
        }
Exemplo n.º 3
0
        internal static bool Record(Root root, Relation rel, Item item1, Item item2)
        {
            (int parentIndex, int childIndex) = rel.GetIndex(item1, item2);
            if (parentIndex < 0 || childIndex < 0)
            {
                return(false);                                   //appearently the relationship doesn't exists
            }
            var nam1 = item1.GetDoubleNameId(root);
            var nam2 = item2.GetDoubleNameId(root);
            var rnam = rel.GetNameId(root);

            var name = $" [{rnam}]   ({nam1}) --> ({nam2})";

            var ci = new ItemUnLinked(root.Get <ChangeRoot>().ChangeSet, rel, item1, item2, parentIndex, childIndex, name);

            ci.DoNow();

            return(true);
        }
Exemplo n.º 4
0
        internal void RemoveItem(Item target)
        {
            var root      = Owner;
            var hitList   = new List <Item>();                                           //======================== dependant items that also need to be killed off
            var stoCRels  = root.Get <Relation_Store_ChildRelation>();                   //==== souce1 of relational integrity
            var stoPRels  = root.Get <Relation_Store_ParentRelation>();                  //==== souce2 of relational integrity
            var stoXCRels = root.Get <Relation_StoreX_ChildRelation>();                  //==== souce1 of relational integrity
            var stoXPRels = root.Get <Relation_StoreX_ParentRelation>();                 //==== souce2 of relational integrity

            _ = root.Get <Relation_Store_ColumnX>();                                     //======= reference to user created columns
            var history = new Dictionary <Relation, Dictionary <Item, List <Item> > >(); //history of unlinked relationships

            FindDependents(target, hitList, stoCRels, stoXCRels);
            hitList.Reverse();

            foreach (var item in hitList)
            {
                if (item is Relation r)
                {
                    var N = r.GetLinks(out List <Item> parents, out List <Item> children);

                    for (int i = 0; i < N; i++)
                    {
                        ItemUnLinked.Record(ChangeSet, root, r, parents[i], children[i], history);
                    }
                }
                if (TryGetParentRelations(item, out IList <Relation> relations, stoPRels, stoXPRels))
                {
                    foreach (var rel in relations)
                    {
                        if (!rel.TryGetParents(item, out List <Item> parents))
                        {
                            continue;
                        }

                        foreach (var parent in parents)
                        {
                            ItemUnLinked.Record(ChangeSet, root, rel, parent, item, history);
                        }
                    }
                }
                if (TryGetChildRelations(item, out relations, stoCRels, stoXCRels))
                {
                    foreach (var rel in relations)
                    {
                        if (!rel.TryGetChildren(item, out List <Item> children))
                        {
                            continue;
                        }

                        foreach (var child in children)
                        {
                            ItemUnLinked.Record(ChangeSet, root, rel, item, child, history);
                        }
                    }
                }
            }

            foreach (var item in hitList)
            {
                ItemRemoved.Record(ChangeSet, root, item);
            }

            ChangeSet.Redo(); //now finally do all changes in the correct order
        }
Exemplo n.º 5
0
 private void RemoveSummaryProperty(Root root)
 {
     Owner.ChildDelta++;
     ItemUnLinked.Record(root, root.Get <Relation_Store_SummaryProperty>(), Owner.GetItem(), Item);
 }