async Task ProcessStore(TripleStore store) { try { string baseAddress = _storage.BaseAddress + _storage.Container + "/resolver/"; SparqlResultSet registrationDeletes = SparqlHelpers.Select(store, Utils.GetResource("sparql.SelectDeleteRegistration.rq")); foreach (SparqlResult row in registrationDeletes) { string id = row["id"].ToString(); Uri resourceUri = new Uri(baseAddress + id + ".json"); await _storage.Delete(resourceUri); } SparqlResultSet packageDeletes = SparqlHelpers.Select(store, Utils.GetResource("sparql.SelectDeletePackage.rq")); foreach (SparqlResult row in packageDeletes) { string id = row["id"].ToString(); string version = row["version"].ToString(); Uri resourceUri = new Uri(baseAddress + id + ".json"); await DeletePackage(resourceUri, version); } } finally { store.Dispose(); } }
protected override async Task ProcessStore(TripleStore store) { ResolverCollectorEventSource.Log.ProcessingBatch(BatchCount); try { SparqlResultSet distinctIds = SparqlHelpers.Select(store, Utils.GetResource("sparql.SelectDistinctPackage.rq")); IDictionary<Uri, IGraph> resolverResources = new Dictionary<Uri, IGraph>(); foreach (SparqlResult row in distinctIds) { string id = row["id"].ToString(); SparqlParameterizedString sparql = new SparqlParameterizedString(); sparql.CommandText = Utils.GetResource("sparql.ConstructResolverGraph.rq"); string baseAddress = _storage.BaseAddress.ToString(); sparql.SetLiteral("id", id); sparql.SetLiteral("base", baseAddress); sparql.SetLiteral("extension", ".json"); sparql.SetLiteral("galleryBase", GalleryBaseAddress); sparql.SetLiteral("contentBase", ContentBaseAddress); IGraph packageRegistration = SparqlHelpers.Construct(store, sparql.ToString()); if (packageRegistration.Triples.Count == 0) { throw new Exception("packageRegistration.Triples.Count == 0"); } Uri registrationUri = new Uri(baseAddress + id.ToLowerInvariant() + ".json"); resolverResources.Add(registrationUri, packageRegistration); } if (resolverResources.Count != distinctIds.Count) { throw new Exception("resolverResources.Count != distinctIds.Count"); } await MergeAll(resolverResources); } finally { ResolverCollectorEventSource.Log.ProcessedBatch(BatchCount); store.Dispose(); } }
async Task ProcessStore(TripleStore store) { try { SparqlResultSet distinctIds = SparqlHelpers.Select(store, Utils.GetResource("sparql.SelectDistinctPackage.rq")); IDictionary<Uri, IGraph> resolverResources = new Dictionary<Uri, IGraph>(); foreach (SparqlResult row in distinctIds) { string id = row["id"].ToString(); SparqlParameterizedString sparql = new SparqlParameterizedString(); sparql.CommandText = Utils.GetResource("sparql.ConstructResolverGraph.rq"); string baseAddress = _storage.BaseAddress + _storage.Container + "/resolver/"; sparql.SetLiteral("id", id); sparql.SetLiteral("base", baseAddress); sparql.SetLiteral("extension", ".json"); IGraph packageRegistration = SparqlHelpers.Construct(store, sparql.ToString()); Uri registrationUri = new Uri(baseAddress + id.ToLowerInvariant() + ".json"); resolverResources.Add(registrationUri, packageRegistration); } if (resolverResources.Count != distinctIds.Count) { throw new Exception("resolverResources.Count != distinctIds.Count"); } await MergeAll(resolverResources); } finally { store.Dispose(); } }