/// <summary> /// Returns all metadata and the stored instances as graph. /// There are some adjustments to the data to make the metadata compatible with the Shacl validator. /// </summary> /// <returns></returns> private IGraph GetShapesGraph() { var shapes = _cacheService.GetOrAdd($"shapes-graph", () => { var store = new TripleStore(); var data = _metadataService.GetAllShaclAsGraph(); store.Add(data); ModifiyShapesForTargetClass(store); ModifyShapesForShaclClass(store); var dataGraph = store.Graphs.FirstOrDefault(t => t.BaseUri?.OriginalString == data.BaseUri.OriginalString); if (dataGraph == null) { throw new ArgumentNullException("Shapes graph is null"); } NTriplesWriter writer = new NTriplesWriter(NTriplesSyntax.Original); var shapes = VDS.RDF.Writing.StringWriter.Write(dataGraph, writer); return(shapes); }); var shapesGraph = new VDS.RDF.Graph(true); var reader = new StringReader(shapes); var nTriplesParser = new NTriplesParser(); nTriplesParser.Load(shapesGraph, reader); return(shapesGraph); }