KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager...
Transcript of KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager...
![Page 2: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/2.jpg)
© Fraunhofer IWU
World Wide Web (1991)
Linked Documents
Document Documenthref
Document
href href
Document
href
WW
W (
1991
)
![Page 3: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/3.jpg)
© Fraunhofer IWU
Semantic Web (2001)
Document Documenthref
Document
href href
Document
href
WW
W (
1991
)
Person Documentcreated
Document
has vita href
Chemnitz
lives in
Document Vitais aSem
antic
Web Web Pageis a
Linked Documents
Linked things with types and relationships
![Page 4: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/4.jpg)
© Fraunhofer IWU
Semantic Web (2001)
Source: Wikipedia
Document Documenthref
Document
href href
Document
href
WW
W (
1991
)
Person Documentcreated
Document
has vita href
Chemnitz
lives in
Document Vitais aSem
antic
Web Web Pageis a
Semantic Web Stack
![Page 5: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/5.jpg)
© Fraunhofer IWU
Source: Wikipedia
Semantic Web – Problems
misunderstood as “intelligent web”
too much focus on logic and automated reasoning
complex ontologies with (too) many classes and restrictions
Semantic Web Stack
![Page 6: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/6.jpg)
© Fraunhofer IWU
Linked Data (2006)
Tim Berners-Lee (2006):
1) Use URIs to name (identify) things.2) Use HTTP URIs so that these things can be looked up
(interpreted, "dereferenced").3) Provide useful information about what a name identifies
when it's looked up, using open standards such as RDF, SPARQL, etc.
4) Refer to other things using their HTTP URIs when publishing data on the Web.
Source: Wikipedia
Source: bnode.org
![Page 7: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/7.jpg)
© Fraunhofer IWU
RDFResource Description Framework
Data model
Triple (subject, predicate, object): :Maria foaf:knows Paul .:Maria rdf:type Female .:Female rdf:type owl:Class .:Female rdfs:subClassOf Person .:Maria foaf:age 32 .
URIs for objects and predicates Literals for scalar values: 20.4
Vocabulary
integrated: types (rdf:type), lists (rdf:List, rdf:first, rdf:rest) extendable by ontologies (RDF Schema, OWL)
Queries with SPARQL
select ?friend where { :Maria foaf:knows ?friend }
Updates with SPARQL
insert { :Paul foaf:knows ?friend }where { ?friend foaf:knows :Paul}
![Page 8: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/8.jpg)
© Fraunhofer IWU
KOMMAmodules
KOMMA – RDF mapper and editing framework
Entitymanager
Data manager
Adapters
Models + ModelSets
Eclipse RDF4J
- Manage data from multiple sources (files, URLs, ...)
- Manage display components and interaction
- Support different RDF frameworks(RDF4J, Jena, …)
- Default RDF framework used by KOMMA- Interface to storage backends- Like JDBC+SQL
- Map between Java classes and RDF resources- Transactions, change tracking, caching- Like JPA
http://komma.enilink.net
![Page 9: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/9.jpg)
© Fraunhofer IWU
KOMMAmodules
Typical operations on each layer
Entitymanager
Data manager
Adapters
Models + ModelSets
Eclipse RDF4J
getText(), getImage(), createCommand(), ...
Models: load(), save(), addImport(), getManager(), …Model sets: createModel(), getModel(), ...
Entity manager: create(), remove(), find(), createQuery(), ...
add(), remove(), match(), createQuery(), …(triple oriented)
![Page 10: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/10.jpg)
© Fraunhofer IWU
Example: Simple smart home application
Source: FreeImages.com
Source: FreeImages.com
![Page 11: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/11.jpg)
© Fraunhofer IWU
Example: Simple smart home application
![Page 12: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/12.jpg)
© Fraunhofer IWU
Data model
controls
House
Floor
Room
Switch Lampon:boolean on:boolean
Model
controls
![Page 13: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/13.jpg)
© Fraunhofer IWU
Features
controls
House
Floor
Room
Switch Lampon:boolean on:boolean
Model
controls
Edit structure
Drag and drop
Undo/Redo
Labels + Icons
Custom actions
Features
![Page 14: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/14.jpg)
© Fraunhofer IWU
Vocabulary (Meta-models)
Source: Designed by Freepik
![Page 15: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/15.jpg)
© Fraunhofer IWU
Create ontology file for smart home vocabulary
file, format and URI/URL
![Page 16: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/16.jpg)
© Fraunhofer IWU
Edit ontology directy in Eclipse (OWL editor)
Properties:contains,controls
Classes:House, Floor, Room etc.
Attributes and restrictions:Houses contain only floors
![Page 17: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/17.jpg)
© Fraunhofer IWU
Reuse vocabulary with imports (owl:imports)
Import KOMMA vocabulary with predefined properties Link to komma:child and komma:containsto trigger default visualisation and editing
![Page 18: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/18.jpg)
© Fraunhofer IWU
Turtle file for the OWL ontology (smarthome.ttl)
Turtle files are plain text files that can be modified with any text editor.
![Page 19: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/19.jpg)
© Fraunhofer IWU
Instantly edit instance data with generic components
List, tree andtable views
“New” actions arepopulated fromontology
“New” actions arepopulated fromontology
Generic iconsand labels
![Page 20: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/20.jpg)
© Fraunhofer IWU
Work with RDF in Java
Object-oriented:● classes● single inheritance● static
Triples:● statements about
objects● multiple types● multiple inheritance● dynamic
![Page 21: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/21.jpg)
© Fraunhofer IWU
Java interfaces represent RDF types
With @Iri: ● Mapped to RDF properties● Implemented by KOMMA● Literals are mapped to Java types
With @Iri: ● Mapped to RDF properties● Implemented by KOMMA● Literals are mapped to Java types
Note: IRI = Internationalized Resource Identifier
![Page 22: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/22.jpg)
© Fraunhofer IWU
Java interfaces represent RDF types
Without @Iri: ● Implemented by you
Without @Iri: ● Implemented by you
Note: IRI = Internationalized Resource Identifier
![Page 23: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/23.jpg)
© Fraunhofer IWU
Java classes implement behaviour
Compute customlabel from controlsproperty Method chaining:
Change value of mapped “on” property andswitch “controlled” components
SwitchToggles controlled components
![Page 24: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/24.jpg)
© Fraunhofer IWU
Use SPARQL for complex queries and updates
Find all switches in any room on the
same floor
FloorSwitchIntelligent floor switch
Compute label
Switch components
![Page 25: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/25.jpg)
© Fraunhofer IWU
Use SPARQL for complex queries and updates
Find all switches in any room on the
same floor
FloorSwitchIntelligent floor switch
Compute label
Switch components
![Page 26: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/26.jpg)
© Fraunhofer IWU
Use SPARQL for complex queries and updates
select ?target where {?floor a sh:Floor; sh:contains+ ?this; sh:contains ?target .?target a [rdfs:subClassOf* sh:Switch] filter not exists { ?target a sh:FloorSwitch }
}
Retrieveswitches
select (count(distinct ?target) as ?count) where {?floor a sh:Floor; sh:contains+ ?this; sh:contains ?target .?target a [rdfs:subClassOf* sh:Switch] filter not exists { ?target a sh:FloorSwitch }
}
Countswitches
![Page 27: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/27.jpg)
© Fraunhofer IWU
KOMMA modules package interfaces and behaviours
1) Register via plugin.xml
2) Use it programmatically:
IEntityManager em =Guice.createInjector(
new MyEntityManagerModule(new SmartHomeModule()
)).getInstance(IEntityManagerFactory.class).get();
em.create(Lamp.class).on(true);
![Page 28: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/28.jpg)
© Fraunhofer IWU
Object composition at runtime (simplified)
URI
Retrieve rdf:typestatements
Match interfaces and classes according
to @Iri annotations
Create bean class withone field per interface and
behaviour
Bean class for rdf:type smarthome:Switch
1
2
3
<URI> a ?typesmarthome:Switchsmarthome:Switchableowl:Thing
SwitchSwitchSupport
![Page 29: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/29.jpg)
© Fraunhofer IWU
Display and edit data with SWT and JFace
![Page 30: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/30.jpg)
© Fraunhofer IWU
Adapters control presentation and interaction
1) Compute icons, labels, colors, …
2) Provide children for tree structures
3) React on changes of underlying data
4) Control editing actions (add, remove, DnD, …)
5) Support search in tree-like structures
![Page 31: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/31.jpg)
© Fraunhofer IWU
Adapter factories create adapters for RDF resources
Use label() method for instances of type SwitchUse label() method for instances of type Switch
Presentation of classes and properties fromthis adapter's namespace can also be modifiedPresentation of classes and properties fromthis adapter's namespace can also be modified
Specify this adapter factory's namespace:<http://komma.github.io/komma-examples/vocab/smarthome.ttl#>
Specify this adapter factory's namespace:<http://komma.github.io/komma-examples/vocab/smarthome.ttl#>
![Page 32: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/32.jpg)
© Fraunhofer IWU
Register modules, adapters and URI resolution rules as extensions
![Page 33: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/33.jpg)
© Fraunhofer IWU
Final application
https://github.com/komma/komma-examples
● 11 Java files● ca. 300 lines of code
![Page 34: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/34.jpg)
© Fraunhofer IWU
Final application
![Page 35: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/35.jpg)
© Fraunhofer IWU
Final application
Switch action
Edit elementstructure
Edit objectproperties
Select elementtype
Custom iconsand labels
Updates onmodel changes
![Page 36: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/36.jpg)
© Fraunhofer IWU
Conclusion
RDF/OWL editor for Eclipse
Object-triple mapping with object composition (multiple types and behaviours per object)
Use SPARQL everywhere to query and update the domain models
Editing framework for RDF data (like EMF.Edit)
Based on Eclipse RDF4J
Works with AND without OSGi
https://github.com/komma/kommahttp://komma.enilink.net
![Page 37: KOMMA - EclipseCon 2020 · KOMMA modules KOMMA – RDF mapper and editing framework Entity manager Data manager Adapters Models + ModelSets Eclipse RDF4J-Manage data from multiple](https://reader034.fdocuments.in/reader034/viewer/2022050116/5f4cb3d609b5fa18f7093cad/html5/thumbnails/37.jpg)
© Fraunhofer IWU