A set of .NET components creating cube.link conform datasets.
This repository gives an overview on the different components to publish cube.link conform datasets.
Both libraries are based on https://github.com/dotnetrdf/dotnetrdf
Register your namespaces on the graph.
var graph = new Graph();
graph.NamespaceMap.AddNamespace("ex", new Uri("https://example.com/"));This library supports the creation of "dimensions" (see: https://cube.link/#dimensions-0).
dotnet add package FCh.Cube.Dimension
Register the library's services using the extension method on IServiceCollection.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDimesionService();Then inject Swiss.FCh.Cube.Dimension.Contract.IDimensionService into your class.
First, create your dimension entries using Swiss.FCh.Cube.Dimension.Model.DimensionItem.
Provide a key, a name and (if needed) additional properties.
new DimensionItem(
person.Id,
new LingualLiteral($"{person.Surname} {person.GivenName}", "en"),
[
new AdditionalLingualProperty("schema:givenName", new LingualLiteral(person.GivenName)),
new AdditionalLingualProperty("schema:familyName", new LingualLiteral(person.Surname))
]);Finally, use the IDimensionService to create the triples defining your dimension.
var personTriples =
_dimensionService.CreateDimension(
personDimensionItems,
graph,
"ex:person",
[new LingualLiteral("Name your dimension here", "en")],
rdfTypes: ["http://schema.org/Person"]);Note: FCh.Cube.Dimension will not push the triples triples to an RDF store. This has to be done using dotnetRdf. See https://dotnetrdf.org/docs/3.4.x/user_guide/writing_rdf.html for more information about dotnetRdf.
This library supports the creation of observations (https://cube.link/#Observation) building up your cube. These observations can link to previously created dimensions values.
dotnet add package FCh.Cube.RawData
Register the library's services using the extension method on IServiceCollection.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCubeRawData();Then inject Swiss.FCh.Cube.RawData.Contract.ICubeRawDataService into your class.
A new data row can be created using Swiss.FCh.Cube.RawData.Model.ObservationDataRow.
var dataRow = new ObservationDataRow
{
KeyUri = "ex:myObservation/459",
ValidFrom = new DateTime(2000, 1, 1),
ValidTo = new DateTime(2025, 12, 31)
};Links to dimension value can be added like this.
dataRow.KeyDimensionLinks.Add(new KeyDimensionLink { PredicateUri = "ex:hasSomeDimension", Uri = "ex:dimension/2354" });Additionally, raw values can be added as well.
dataRow.Values.Add(new DimensionValue { Predicate = "schema:description", Value = "some text", LanguageTag = "en" });Finally, the data can be transformed to triples using the ICubeRawDataService.
var rawDataTriples =
_cubeRawDataService.CreateTriples(
graph,
"ex:myCube",
"ex:myCube/observationSet",
new List<ObservationDataRow> {});Note: FCh.Cube.RawData will not push the triples triples to an RDF store. This has to be done using dotnetRdf. See https://dotnetrdf.org/docs/3.4.x/user_guide/writing_rdf.html for more information about dotnetRdf.