An interactive, hands-on workshop for learning how to work with CIM (Common Information Model) and CGMES (Common Grid Model Exchange Standard) files using Apache Jena, SPARQL, and SHACL.
This workshop teaches power system developers how to:
- Import and manage CIM/CGMES files in graph databases
- Query power grid data using SPARQL
- Validate data quality using SHACL
- Create custom validation rules
Total Duration: 2 hours 30 minutes
- Introduction: 8 minutes
- Task 1: Data Import (15 min)
- Task 2: Data Export (30 min)
- Break: 5 minutes
- Task 3: SPARQL Queries (45 min)
- Break: 5 minutes
- Task 4: SHACL Validation (30 min)
- Wrap-up: 7 minutes
- Buffer: 15 minutes
Scaffolded hands-on - Implement 3 methods with provided structure and hints. One complete method provided as reference.
Scaffolded hands-on - Implement 2 core methods for listing graphs and downloading from Fuseki. Optional bonus methods available.
Scaffolded hands-on - Write 4 SPARQL queries with progressive difficulty. Queries scaffolded from simple pattern filling to complex multi-hop paths.
Scaffolded hands-on - Implement 4 core validation methods with structured guidance. Focus on loading shapes and parsing validation reports.
BONUS MATERIAL - Advanced content for self-study after the workshop. Not included in the 2h 30min timeline.
- Docker and Docker Compose (to run Fuseki and Java environment)
- Git (to clone the repository)
- Basic understanding of:
- Power system concepts (optional but helpful)
- RDF/XML format basics
- Command line usage
Note: No Java installation needed on your machine - everything runs in Docker!
git clone <repository-url>
cd cim-technical-workshopdocker-compose up -dThis will start:
- Apache Jena Fuseki (graph database) on
http://localhost:3030 - Java workshop container with all dependencies
docker-compose exec workshop-java bashYou're now in the workshop environment!
# View the workshop menu
mvn exec:java -Dexec.mainClass="com.cim.workshop.WorkshopRunner"
# Start Task 1
mvn test -Dtest=Task1TestScaffolded Exercise:
- One complete method provided:
extractModelId()- study this to learn Jena API - Implement 3 methods with structure and hints provided
File to complete: src/main/java/com/cim/workshop/exercises/Task1_DataImport.java
What you'll learn:
- How CIM files are structured (RDF/XML)
- Extracting Model IDs (mRIDs) from CIM files
- Loading files into Apache Jena models
- Uploading to Fuseki as named graphs
Run tests:
mvn test -Dtest=Task1TestExpected output:
- ✓ Extract Model ID from CIM file
- ✓ Load CIM file into Jena Model
- ✓ Upload model to Fuseki
- ✓ Import entire directory
Scaffolded Exercise:
- Implement 2 core methods with query and HTTP structures provided
- 6 optional bonus methods available for extra practice
File to complete: src/main/java/com/cim/workshop/exercises/Task2_DataExport.java
What you'll learn:
- Listing named graphs with SPARQL
- Downloading graphs via HTTP GET
- Graph Store Protocol for data export
- Working with RDF/XML format
Run tests:
mvn test -Dtest=Task2TestExpected output:
- ✓ List all named graphs
- ✓ Download graph from Fuseki
- Optional bonus methods for advanced export features
Scaffolded Exercise:
- Write 4 SPARQL queries with progressive difficulty
- Query 1: Fill in 2 triple patterns
- Query 2: Write complete WHERE clause with hints
- Query 3: Apply FILTER NOT EXISTS pattern
- Query 4: Complex multi-hop connectivity path
File to complete: src/main/java/com/cim/workshop/exercises/Task3_SparqlQueries.java
What you'll learn:
- SPARQL query language basics
- Finding resources by type
- Following relationships in the graph
- Identifying data errors with queries
Key Concepts:
SELECTqueries to retrieve data- Triple patterns for graph navigation
FILTER NOT EXISTSto find missing data- Multi-hop paths through connectivity nodes
Run tests:
mvn test -Dtest=Task3TestExpected output:
- ✓ Query all ACLineSegments
- ✓ Find terminals for ACLineSegments
- ✓ Identify ACLineSegments without terminals
- ✓ Find connected switches
Scaffolded Exercise:
- Implement 4 core validation methods with structured guidance
- Load SHACL shapes, run validation, parse results
- Optional bonus methods for advanced validation features
File to complete: src/main/java/com/cim/workshop/exercises/Task4_ShaclValidation.java
What you'll learn:
- SHACL (Shapes Constraint Language) basics
- Loading SHACL validation rules
- Running validation against CIM data
- Analyzing validation reports
Key Concepts:
- SHACL shapes define constraints
- Validation produces reports with violations
- ENTSO-E provides official CGMES SHACL rules
- Violations indicate data quality issues
Run tests:
mvn test -Dtest=Task4TestExpected output:
- ✓ Load SHACL shapes
- ✓ Validate CIM data
- ✓ Extract violation details
- ✓ Parse validation reports
BONUS MATERIAL - Self-study content, not included in 2h 30min workshop
File to complete: src/main/java/com/cim/workshop/exercises/Task5_CustomShacl.java
What you'll learn:
- Creating SHACL shapes programmatically
- Building property constraints
- SHACL-SPARQL constraints
- Connection between SHACL and SPARQL
Key Concepts:
sh:NodeShape- defines a shapesh:targetClass- specifies target classsh:property- defines property constraintssh:sparql- SPARQL-based validation
Run tests:
mvn test -Dtest=Task5TestExpected output:
- ✓ Create basic SHACL shape
- ✓ Create connectivity validation
- ✓ Create SHACL-SPARQL constraint
- ✓ Compare SHACL and SPARQL
Located in assets/grid_model_cgmes/:
- PowerFlow/ - Small dataset for testing
- FullGrid/ - Complete grid model
Located in assets/shacl_cgmes/:
- ENTSO-E official CGMES validation rules
- Multiple profiles (Equipment, Topology, StateVariables, etc.)
mvn testmvn test -Dtest=Task1Test
mvn test -Dtest=Task2Test
mvn test -Dtest=Task3Test
mvn test -Dtest=Task4Testmvn compilemvn clean compileOpen browser: http://localhost:3030
- Username:
admin - Password:
admin
# Restart Fuseki
docker-compose restart fuseki
# Check Fuseki logs
docker-compose logs fuseki# Clean and rebuild
mvn clean install
# Update dependencies
mvn dependency:resolve# Restart all services
docker-compose down
docker-compose up -d
# View logs
docker-compose logs┌─────────────────────────────────────────────────────────┐
│ Workshop Container │
│ ┌────────────────────────────────────────────────┐ │
│ │ Java Application (Maven) │ │
│ │ - Exercise files (Task1-4) │ │
│ │ - Test suites │ │
│ │ - Apache Jena libraries │ │
│ └────────────────────────────────────────────────┘ │
│ │ │
│ ↓ │
│ ┌────────────────────────────────────────────────┐ │
│ │ Apache Jena Fuseki (Graph DB) │ │
│ │ - Stores RDF graphs │ │
│ │ - SPARQL endpoint │ │
│ │ - Web UI (port 3030) │ │
│ └────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
│
↓
┌──────────────────────┐
│ CIM/CGMES Files │
│ SHACL Rules │
│ (assets directory) │
└──────────────────────┘
Each task has a test file that:
- Checks if you've implemented methods - throws error if method not implemented
- Validates your implementation - tests correctness with assertions
- Provides feedback - clear success/failure messages
- Guides to next step - tells you what to do next
1. Run test → Method not implemented error
2. Complete method in exercises/ file
3. Run test → Passes with ✓
4. Move to next method
Solution files are provided in the src/main/java/com/cim/workshop/solutions/ directory. Try to complete tasks yourself first!
To view a solution:
cat src/main/java/com/cim/workshop/solutions/Task1_DataImport.javacim-technical-workshop/
├── src/
│ ├── main/java/com/cim/workshop/
│ │ ├── exercises/ # YOUR WORK HERE
│ │ │ ├── Task1_DataImport.java
│ │ │ ├── Task2_SparqlQueries.java
│ │ │ ├── Task3_ShaclValidation.java
│ │ │ └── Task4_CustomShacl.java
│ │ │
│ │ ├── solutions/ # Reference solutions
│ │ │ └── (same files as exercises/)
│ │ │
│ │ ├── WorkshopRunner.java # Main menu
│ │ └── utils/
│ │ └── FusekiClient.java # Fuseki helper
│ │
│ └── test/java/com/cim/workshop/
│ ├── Task1Test.java # Test suites
│ ├── Task2Test.java
│ ├── Task3Test.java
│ └── Task4Test.java
│
├── assets/ # Data files
│ ├── grid_model_cgmes/ # CIM files
│ └── shacl_cgmes/ # SHACL rules
│
├── docker-compose.yml # Docker setup
├── Dockerfile
└── pom.xml # Maven config
PREFIX cim: <http://iec.ch/TC57/CIM100#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?variable
WHERE {
?variable rdf:type cim:ClassName .
}SELECT ?line ?name
WHERE {
?line rdf:type cim:ACLineSegment .
?line cim:IdentifiedObject.name ?name .
}SELECT ?line ?terminal ?node
WHERE {
?line rdf:type cim:ACLineSegment .
?terminal cim:Terminal.ConductingEquipment ?line .
?terminal cim:Terminal.ConnectivityNode ?node .
}SELECT ?line ?name
WHERE {
?line rdf:type cim:ACLineSegment .
?line cim:IdentifiedObject.name ?name .
FILTER NOT EXISTS {
?terminal cim:Terminal.ConductingEquipment ?line .
}
}@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix cim: <http://iec.ch/TC57/CIM100#> .
shapes:ACLineSegmentShape
a sh:NodeShape ;
sh:targetClass cim:ACLineSegment ;
sh:property [
sh:path cim:Equipment.Terminal ;
sh:minCount 2 ;
sh:message "ACLineSegment must have at least 2 terminals" ;
] .sh:minCount- Minimum number of valuessh:maxCount- Maximum number of valuessh:class- Expected typesh:datatype- Expected datatypesh:pattern- Regex patternsh:sparql- SPARQL constraint
cim:ACLineSegment- Power line segmentcim:Switch- Switching devicecim:PowerTransformer- Transformer
cim:Terminal- Connection point of equipmentcim:ConnectivityNode- Node where terminals meetcim:TopologicalNode- Simplified connectivity
Terminal.ConductingEquipment- Terminal → EquipmentTerminal.ConnectivityNode- Terminal → NodeEquipment.EquipmentContainer- Equipment → Container
- Read the comments - Exercise files have detailed hints
- Run tests frequently - Get immediate feedback
- Use the solutions - Learn from examples when stuck
- Explore Fuseki UI - Visualize your data at http://localhost:3030
- Ask questions - Discuss with instructors and peers
After completing all tasks, you will be able to:
- ✅ Import and manage CIM files in graph databases
- ✅ Write SPARQL queries to analyze power grid data
- ✅ Validate data quality with SHACL
- ✅ Create custom validation rules
- ✅ Understand the relationship between SHACL and SPARQL
When finished with the workshop:
# Stop containers
docker-compose down
# Remove volumes (deletes database data)
docker-compose down -v
# Remove images
docker-compose down --rmi allIf you encounter issues:
- Check the Troubleshooting section
- Review test output carefully
- Consult solution files
- Ask workshop instructors
This workshop is created for educational purposes.
CIM/CGMES test data is provided by ENTSO-E.
Ready to start?
docker-compose up -d
docker-compose exec workshop-java bash
mvn test -Dtest=Task1TestGood luck and enjoy the workshop! 🚀