static IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> PromoteRegistrationKey(IDictionary <string, IGraph> newItems)
        {
            IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> promoted = new Dictionary <RegistrationEntryKey, RegistrationCatalogEntry>();

            foreach (var newItem in newItems)
            {
                promoted.Add(RegistrationCatalogEntry.Promote(newItem.Key, newItem.Value));
            }
            return(promoted);
        }
Esempio n. 2
0
        static void AddExistingItem(IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> resources, TripleStore store, Uri catalogEntry)
        {
            SparqlParameterizedString sparql = new SparqlParameterizedString();

            sparql.CommandText = Utils.GetResource("sparql.ConstructCatalogEntryGraph.rq");
            sparql.SetUri("catalogEntry", catalogEntry);

            IGraph graph = SparqlHelpers.Construct(store, sparql.ToString());

            resources.Add(RegistrationCatalogEntry.Promote(catalogEntry.AbsoluteUri, graph));
        }
Esempio n. 3
0
        public static KeyValuePair <RegistrationEntryKey, RegistrationCatalogEntry> Promote(string resourceUri, IGraph graph)
        {
            INode  subject = graph.CreateUriNode(new Uri(resourceUri));
            string version = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version)).First().Object.ToString();

            RegistrationEntryKey registrationEntryKey = new RegistrationEntryKey(RegistrationKey.Promote(resourceUri, graph), version);

            RegistrationCatalogEntry registrationCatalogEntry = IsDelete(subject, graph) ? null : new RegistrationCatalogEntry(resourceUri, graph);

            return(new KeyValuePair <RegistrationEntryKey, RegistrationCatalogEntry>(registrationEntryKey, registrationCatalogEntry));
        }
Esempio n. 4
0
        private static void AddExistingItem(IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> resources, TripleStore store, Uri catalogEntry)
        {
            Trace.TraceInformation("RegistrationPersistence.AddExistingItem: catalogEntry = {0}", catalogEntry);

            SparqlParameterizedString sparql = new SparqlParameterizedString();

            sparql.CommandText = Utils.GetResource("sparql.ConstructCatalogEntryGraph.rq");
            sparql.SetUri("catalogEntry", catalogEntry);

            IGraph graph = SparqlHelpers.Construct(store, sparql.ToString());

            resources.Add(RegistrationCatalogEntry.Promote(
                              catalogEntry.AbsoluteUri,
                              graph,
                              shouldInclude: (k, u, g) => true,
                              isExistingItem: true));
        }
        private static IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> PromoteRegistrationKey(
            IReadOnlyDictionary <string, IGraph> newItems,
            ShouldIncludeRegistrationPackage shouldInclude)
        {
            IDictionary <RegistrationEntryKey, RegistrationCatalogEntry> promoted = new Dictionary <RegistrationEntryKey, RegistrationCatalogEntry>();

            foreach (var newItem in newItems)
            {
                var promotedEntry = RegistrationCatalogEntry.Promote(
                    newItem.Key,
                    newItem.Value,
                    shouldInclude,
                    isExistingItem: false);

                promoted[promotedEntry.Key] = promotedEntry.Value;
            }

            return(promoted);
        }
        public static KeyValuePair <RegistrationEntryKey, RegistrationCatalogEntry> Promote(
            string resourceUri,
            IGraph graph,
            ShouldIncludeRegistrationPackage shouldInclude,
            bool isExistingItem)
        {
            INode  subject = graph.CreateUriNode(new Uri(resourceUri));
            var    triples = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version));
            string version = triples.First().Object.ToString();

            var registrationEntryKey = new RegistrationEntryKey(RegistrationKey.Promote(resourceUri, graph), version);

            RegistrationCatalogEntry registrationCatalogEntry = null;

            if (!IsDelete(subject, graph) && shouldInclude(registrationEntryKey, resourceUri, graph))
            {
                registrationCatalogEntry = new RegistrationCatalogEntry(resourceUri, graph, isExistingItem);
            }

            return(new KeyValuePair <RegistrationEntryKey, RegistrationCatalogEntry>(registrationEntryKey, registrationCatalogEntry));
        }