Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SourceGraph.cs
2using System.Threading.Tasks;
9
11{
16 {
17 private readonly IDataSource source;
18
23 public SourceGraph(IDataSource Source)
24 {
25 this.source = Source;
26 }
27
35 {
36 return GenerateGraph(Result, Language, this.source);
37 }
38
45 public static async Task GenerateGraph(InMemorySemanticCube Result, Language Language,
46 IDataSource Source)
47 {
48 UriNode SourceGraphUriNode = new UriNode(DataSourceGraph.GetSourceUri(Source.SourceID));
49
50 Result.Add(SourceGraphUriNode, Rdf.type, IoTConcentrator.DataSource);
51 Result.Add(SourceGraphUriNode, IoTConcentrator.sourceId, Source.SourceID);
52 Result.Add(SourceGraphUriNode, RdfSchema.label, await Source.GetNameAsync(Language));
53 Result.Add(SourceGraphUriNode, DublinCoreTerms.updated, Source.LastChanged);
54 Result.Add(SourceGraphUriNode, IoTConcentrator.hasChildSources, Source.HasChildren);
55
57
58 if (Source.HasChildren)
59 {
60 foreach (IDataSource ChildSource in Source.ChildSources)
61 Items.Add(new UriNode(DataSourceGraph.GetSourceUri(ChildSource.SourceID)));
62
63 Result.AddContainer(SourceGraphUriNode, Rdf.Bag, IoTConcentrator.childSources,
64 Items);
65
66 Items.Clear();
67 }
68
69 IEnumerable<INode> RootNodes = Source.RootNodes;
70
71 if (!(RootNodes is null))
72 {
73 foreach (INode RootNode in RootNodes)
74 Items.Add(new UriNode(DataSourceGraph.GetNodeUri(RootNode)));
75
76 Result.AddContainer(SourceGraphUriNode, Rdf.Bag, IoTConcentrator.rootNodes, Items);
77 }
78 }
79 }
80}
override void Add(ISemanticTriple Triple)
Adds a triple to the cube.
void AddContainer(ISemanticElement Subject, Uri Type, Uri Predicate, params object[] Items)
Adds a linked list of items to the graph.
static readonly Uri updated
http://purl.org/dc/terms/updated
static readonly Uri Bag
URI representing rdf:Bag, an unordered container.
Definition: Rdf.cs:96
static readonly Uri type
URI representing rdf:type
Definition: Rdf.cs:51
static readonly Uri label
http://www.w3.org/2000/01/rdf-schema#label
Definition: RdfSchema.cs:51
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
void Clear()
Clears the collection.
Definition: ChunkedList.cs:306
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
Contains information about a language.
Definition: Language.cs:17
Tokens available in request.
Definition: RequestOrigin.cs:9
static readonly Uri sourceId
urn:nf:iot:concentrator:1.0:sourceId
static readonly Uri childSources
urn:nf:iot:concentrator:1.0:childSources
static readonly Uri rootNodes
urn:nf:iot:concentrator:1.0:rootNodes
static readonly Uri hasChildSources
urn:nf:iot:concentrator:1.0:hasChildSources
static readonly Uri DataSource
urn:nf:iot:concentrator:1.0:DataSource
Makes harmonized data sources and nodes available as semantic information.
static Uri GetNodeUri(INode Node)
Gets the Graph URI for a node.
static Uri GetSourceUri(string SourceID)
Gets the Graph URI for a data source.
Dynamic graph of a data source on the Neuron.
Definition: SourceGraph.cs:16
Task GenerateGraph(InMemorySemanticCube Result, Language Language, RequestOrigin Caller)
Generates the semantic graph.
Definition: SourceGraph.cs:34
static async Task GenerateGraph(InMemorySemanticCube Result, Language Language, IDataSource Source)
Generates a semantic graph of a data source.
Definition: SourceGraph.cs:45
SourceGraph(IDataSource Source)
Dynamic graph of a data source on the Neuron.
Definition: SourceGraph.cs:23
Interface for datasources that are published through the concentrator interface.
Definition: IDataSource.cs:14
IEnumerable< INode > RootNodes
Root node references. If no root nodes are available, null is returned.
Definition: IDataSource.cs:65
Task< string > GetNameAsync(Language Language)
Gets the name of data source.
bool HasChildren
If the source has any child sources.
Definition: IDataSource.cs:34
DateTime LastChanged
When the source was last updated.
Definition: IDataSource.cs:42
IEnumerable< IDataSource > ChildSources
Child sources. If no child sources are available, null is returned.
Definition: IDataSource.cs:50
string SourceID
ID of data source.
Definition: IDataSource.cs:19
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Interface for dynamic graphs.