Example #1
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());
        }
Example #2
0
        public static IEnumerable <Triple> GetItemTriples(Item item)
        {
            var g = LinkedDataManager.ReadGraph();

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

            return(items);
        }
Example #3
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);
            }
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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();
        }
Example #7
0
        public static void AddLink(Item item, ItemLink link)
        {
            var g = LinkedDataManager.ReadGraph();

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