RDF (Resource Description Framework)¶
Purpose¶
The GridLab.Abp.Rdf package provides a robust, extensible framework for managing, querying, and manipulating RDF (Resource Description Framework) data within .NET applications.
It is designed to support advanced data integration scenarios, including Common Information Model (CIM) and other semantic web standards, leveraging the ABP modular architecture and dotNetRDF library.
Key Features¶
- Graph Context Management Centralized lifecycle management for multiple named RDF graphs, supporting creation, loading, querying, and disposal.
- Flexible Data Loading
Load RDF data from files, URIs, strings, and streams with automatic format detection (RDF/XML, Turtle, N-Triples). - Thread-Safe Operations
Concurrent access and modification of graphs using thread-safe collections and async locking. - Dependency Injection Ready
All core services and extension points are registered via DI, supporting ABP and Microsoft.Extensions.DependencyInjection. - Customizable Graph Initialization
Plug-in initializers for namespace registration, default data seeding, and domain-specific configuration. - Entity Mapping
Extensible mapping infrastructure for converting between domain entities and RDF resources. - Repository Pattern
Repositories abstract high-level CRUD operations over RDF graphs, enabling clean separation of concerns. - Advanced Configuration
Rich options for memory management, error handling, HTTP loading, and base URI resolution.
RDF Triple Structure¶
RDF (Resource Description Framework) represents data as triples, which consist of three components: Subject, Predicate, and Object.
Every RDF statement follows the pattern:
Subject → Predicate → Object
graph LR
A[Subject] -- Predicate --> B[Object] Why RDF for Power Systems?¶
- Interconnectedness: Power systems are naturally graph-like
- Flexibility: Easy to add new properties/relationships
- Standardization: CIM provides a common vocabulary
- Semantics: Meaning is encoded in the structure
The entire file forms a knowledge graph where every power system component is a node, and the predicates define both properties (attributes) and relationships (edges) between components
Example 1: Base Voltage Definition¶
<cim:BaseVoltage rdf:ID="_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192">
<cim:BaseVoltage.nominalVoltage>500</cim:BaseVoltage.nominalVoltage>
<cim:IdentifiedObject.name>500.0</cim:IdentifiedObject.name>
</cim:BaseVoltage>
Triples:
| Subject (Resource) | Predicate (Property) | Object (Value) | Meaning |
|---|---|---|---|
_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192 | cim:BaseVoltage.nominalVoltage | 500 | The base voltage is 500 kV. |
_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192 | cim:IdentifiedObject.name | "500.0" | Named "500.0" |
_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192 | rdf:type | cim:BaseVoltage | Type is BaseVoltage |
Example 2: Transmission Line with Relationships¶
<cim:ACLineSegment rdf:ID="_72cb1d28-c3ce-11f0-988b-f8edfcb6b192">
<cim:ACLineSegment.r>6.5</cim:ACLineSegment.r>
<cim:ACLineSegment.x>115</cim:ACLineSegment.x>
<cim:ConductingEquipment.BaseVoltage rdf:resource="#_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192"/>
<cim:IdentifiedObject.name>151_152_1</cim:IdentifiedObject.name>
</cim:ACLineSegment>
Triples:
| Subject (Resource) | Predicate (Property) | Object (Value) | Meaning |
|---|---|---|---|
_72cb1d28-c3ce-11f0-988b-f8edfcb6b192 | cim:ACLineSegment.r | 6.5 | The resistance is 6.5 ohms. |
_72cb1d28-c3ce-11f0-988b-f8edfcb6b192 | cim:ACLineSegment.x | 115 | The reactance is 115 ohms. |
_72cb1d28-c3ce-11f0-988b-f8edfcb6b192 | cim:ConductingEquipment.BaseVoltage | #_72cb1bc9-c3ce-11f0-988b-f8edfcb6b192 | Links to the BaseVoltage defined earlier. |
_72cb1d28-c3ce-11f0-988b-f8edfcb6b192 | cim:IdentifiedObject.name | "151_152_1" | Named "151_152_1" |
_72cb1d28-c3ce-11f0-988b-f8edfcb6b192 | rdf:type | cim:ACLineSegment | Type is ACLineSegment |
Relationship Examples (Graph Edges)¶
<cim:Substation rdf:ID="_72cb1ba5-c3ce-11f0-988b-f8edfcb6b192">
<cim:Substation.Region rdf:resource="#_72cb1bac-c3ce-11f0-988b-f8edfcb6b192"/>
<cim:IdentifiedObject.name>NUC-A</cim:IdentifiedObject.name>
</cim:Substation>
<cim:SubGeographicalRegion rdf:ID="_72cb1bac-c3ce-11f0-988b-f8edfcb6b192">
<cim:SubGeographicalRegion.Region rdf:resource="#_72cb1baa-c3ce-11f0-988b-f8edfcb6b192"/>
<cim:IdentifiedObject.name>PLANT</cim:IdentifiedObject.name>
</cim:SubGeographicalRegion>
Resulting Graph:
graph BT
A["GeographicalRegion: FLAPCO<br/>(_72cb1baa-c3ce-11f0-988b-f8edfcb6b192)"]
B["SubGeographicalRegion: PLANT<br/>(_72cb1bac-c3ce-11f0-988b-f8edfcb6b192)"]
C["Substation: NUC-A<br/>(_72cb1ba5-c3ce-11f0-988b-f8edfcb6b192)"]
B -- "cim:SubGeographicalRegion.Region" --> A
C -- "cim:Substation.Region" --> B Main Components¶
- Graph Context
RdfGraphContextBase(abstract): Core graph management and data loading logic.IRdfGraphContext: Interface for context operations.RdfGraphContextOptions: Configuration for graph context behavior.
- Parsers & Resolvers
IRdfValueParser,IRdfIdentifierParser,IRdfNodeResolver: Interfaces for parsing and resolving RDF values and nodes.
- Factories & Mappers
IRdfNodeFactory: Creates RDF nodes with namespace resolution.IRdfEntityMapperFactory: Provides entity-to-RDF mapping services.
- Repositories
RdfGraphRepository: High-level repository for entity operations over RDF graphs.
- Initializers
IRdfGraphInitializer: Custom logic for graph setup and namespace registration.
Installation¶
If you want to install resource description framework module;
-
Add the GridLab.Abp.Rdf NuGet package to your project:
Install-Package GridLab.Abp.Rdf -
Add the
AbpGridLabRdfModuleto the dependency list of your module:[DependsOn( //...other dependencies typeof(AbpGridLabRdfModule) // <-- Add module dependency like that )] public class YourModule : AbpModule { }