UMLtoGraphDB presentation at ER2016. Related article available online at https://hal.archives-ouvertes.fr/hal-01344015/document
Related post on modeling-languages.com: http://modeling-languages.com/uml-to-nosql-graph-database/
2. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 2
Introduction
● NoSQL
– Scalability
– Availability
– Performance
● Graph Databases
– Store highly interconnected data
● Vertices, edges, properties
– Expressive query language
● Gremlin, Cypher
– Social networks, data provenance analysis
3. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 3
Introduction
● Schemaless
Flexible
● Non-uniform data
● Schema evolutions
Implicit schema defined by data
● Need to acquire this knowledge
● Specific to each database
● Not formally described
4. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 4
Introduction
Hard to integrate in code-generation architectures
– Few options for mapping ER/UML to NoSQL
– Data consistency challenge
– Lack of support for integrity constraints
→ Goal: create a code generation framework
– Map conceptual schemas to graph databases
– Input: UML + OCL
– Output: graph database + graph queries
5. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 5
UMLtoGraphDB
● MDA methodology
– Platform Independent Model (PIM)
● Conceptual schema
– Platform Specific Model (PSM)
● Refines PIM for a specific implementation
– Code generation from PSM
6. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 6
UMLtoGraphDB – Starting Point
● Conceptual Schema
– UML class diagram
● Concepts
● Data structure
– OCL
● Business rules
● Invariants / Constraints
19. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 19
Gremlin Metamodel
● Gremlin language
– Graph traversal DSL
– Based on the Blueprints API
– Generic query language for graph databases
20. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 20
Gremlin Metamodel
GremlinScript
InstructionTraversalElementStep
OutEStep
+ label : String
InEStep
+ label : String
OutVStep
InVStep
FilterStep
. . .
EdgesStep
+ label : String
VerticesStep
+ id : String
instructions
*
next
0..1
21. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 21
OCL2Gremlin
● Adaptation of the Mogwaï* query framework
– Gremlin metamodel definition
– Map OCL expressions to Gremlin steps
– Merge created steps into traversals
– Generate query code from Gremlin AST
* G. Daniel, G. Sunyé, and J. Cabot. Mogwaï: a Framework to Handle Complex Queries on Large
Models. In RCIS 2016, Grenoble, FR,June 2016
25. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 25
Graph2Code
● Generate Java beans
– Adapter pattern
● Delegate to database objects
● Lightweight implementation
– Bean factory
● Create new elements
● Reifies database objects
26. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 26
Graph2Code – Client Class
public class Client extends BlueprintsBean {
public Client(Vertex v, Graph graph, UMLModelFactory factory) {
super(v,graph,factory);
}
public String getName() {
return (String) this.vertex.property(''name'').value();
}
public void setName(String newName) {
this.vertex.property(''name'', newName);
}
public List<Order> getOrders() {
Iterator<Vertex> otherEnd = this.vertex.vertices(Direction.OUT,"orders");
return new GremlinIterator<Order>(otherEnd, factory);
}
public void addOrder(Order newOrder) {
this.vertex.addEdge(“orders”, newOrder.getVertex());
}
27. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 27
Graph2Code – Client Class
[...]
public boolean checkMaxUnpaidOrders() {
return this.graph.traversal().V(this.vertex).out(''orders'').filter(
v -> v.get().<Boolean>property(''paid'').value())
.count().is(P.lt(3)).hasNext();
}
}
28. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 28
Tooling
● Set of open-source eclipse plugins
– ATL: Model-to-model transformations
● ~ 110 rules / helpers
– XTend: Code generation
● Full stack execution: less than 5 seconds
29. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 29
Conclusion
● Chain of model transformations
– UML (class diagram) to GraphDB
– OCL to Gremlin
– Graph to code transformation
● GraphDB metamodel
● Future Work
– Refactoring operations at the PSM level
– Cover multiple database types
– Reverse engineering
30. 17/11/2016 UMLtoGraphDB: Mapping Conceptual Schemas to Graph Databases - G. Daniel 30
Questions?
Websites / Repositories
UMLtoGraphDB: https://github.com/atlanmod/UML2NoSQL
Mogwaï: https://github.com/atlanmod/Mogwai
https://github.com/atlanmod
Thank you for your attention!
https://github.com/SOM-Research