Esempio n. 1
0
        protected override void UpdateItemVersionLinks(Item item, ItemLink[] links)
        {
            Assert.ArgumentNotNull((object)item, "item");
            Assert.ArgumentNotNull((object)links, "links");

            foreach (var itemLink in links)
            {
                LinkedDataManager.AddLink(item, itemLink);
            }

            //Now remove removed links
            var oldLinks    = GetReferences(item);
            var removeLinks = new List <ItemLink>();

            foreach (var link in oldLinks)
            {
                if (!links.ToList().Where(x => x.TargetItemID.Guid == link.TargetItemID.Guid).Any())
                {
                    removeLinks.Add(link);
                }
            }

            foreach (var removeLink in removeLinks)
            {
                LinkedDataManager.RemoveLinksForItem(item, removeLink);
            }
        }
Esempio n. 2
0
        public override ItemLink[] GetReferrers(Item item)
        {
            Assert.ArgumentNotNull((object)item, "item");

            var list = new List <ItemLink>();

            lock (this.locks.GetLock((object)item.ID))
            {
                var g = LinkedDataManager.ReadGraph();

                var literalNode = g.GetLiteralNode(LinkedDataManager.ItemToUri(item));

                if (literalNode != null)
                {
                    var items = g.GetTriplesWithObject(literalNode);

                    foreach (var triple in items)
                    {
                        var sourceItem = LinkedDataManager.UriToItem(triple.Subject.ToString());
                        var targetItem = LinkedDataManager.UriToItem(triple.Object.ToString());
                        //TODO: Need to hold somewhere in the triple the fieldId
                        list.Add(new ItemLink(sourceItem.Database.Name, sourceItem.ID, new ID("{A60ACD61-A6DB-4182-8329-C957982CEC74}"), targetItem.Database.Name, targetItem.ID, targetItem.Paths.FullPath));
                    }
                }
            }
            return(list.ToArray());
        }
Esempio n. 3
0
        public static IEnumerable <Triple> GetItemTriples(Item item)
        {
            var g = LinkedDataManager.ReadGraph();

            var items = g.GetTriplesWithSubject(g.CreateUriNode(LinkedDataManager.ItemToUri(item)));

            return(items);
        }
Esempio n. 4
0
        protected override void UpdateLinks(Item item, ItemLink[] links)
        {
            Assert.ArgumentNotNull((object)item, "item");
            Assert.ArgumentNotNull((object)links, "links");

            foreach (var itemLink in links)
            {
                LinkedDataManager.AddLink(item, itemLink);
            }
        }
Esempio n. 5
0
        protected virtual void AddLink(Item item, ItemLink link)
        {
            Assert.ArgumentNotNull((object)item, "item");
            Assert.ArgumentNotNull((object)link, "link");

            lock (this.locks.GetLock((object)"rdflock"))
            {
                LinkedDataManager.AddLink(item, link);
            }
        }
Esempio n. 6
0
        public static void RemoveLinksForItem(Item item, ItemLink link)
        {
            var g = LinkedDataManager.ReadGraph();

            var items = g.GetTriplesWithSubjectObject(
                g.CreateUriNode(LinkedDataManager.ItemToUri(item)),
                g.CreateLiteralNode(LinkedDataManager.ItemToUri(link.GetTargetItem())));

            if (items != null && items.Any())
            {
                g.Retract(items.First());
                WriteGraph(g);
            }
        }
Esempio n. 7
0
        public override int GetReferrerCount(Item item)
        {
            Assert.ArgumentNotNull((object)item, "item");

            var g = LinkedDataManager.ReadGraph();

            var items = g.GetTriplesWithObject(g.CreateUriNode(LinkedDataManager.ItemToUri(item)));

            if (items != null)
            {
                return(items.Count());
            }
            return(0);
        }
Esempio n. 8
0
        protected virtual void RemoveItemVersionLinks(Item item)
        {
            Assert.ArgumentNotNull((object)item, "item");

            var g = LinkedDataManager.ReadGraph();

            var items = g.GetTriplesWithSubject(g.CreateUriNode(LinkedDataManager.ItemToUri(item)));

            foreach (var triple in items)
            {
                g.Retract(triple);
            }
            LinkedDataManager.WriteGraph(g);
        }
Esempio n. 9
0
        public override void RemoveReferences(Item item)
        {
            Assert.ArgumentNotNull((object)item, "item");

            var g = LinkedDataManager.ReadGraph();

            var items = g.GetTriplesWithObject(g.CreateUriNode(LinkedDataManager.ItemToUri(item)));

            foreach (var triple in items)
            {
                g.Retract(triple);
            }
            LinkedDataManager.WriteGraph(g);

            LinkCounters.DataUpdated.Increment();
        }
Esempio n. 10
0
        public static void AddLink(Item item, ItemLink link)
        {
            var g = LinkedDataManager.ReadGraph();

            LinkedDataManager.WriteTriple(g, LinkedDataManager.ToTriple(g, item, link));
        }