Skip to content

gouttegd/linkml-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkML-Java – LinkML runtime library for Java

LinkML-Java is an implementation of LinkML, the Linked Data Modeling Language, for the Java language.

Project aims

The project’s primary aim is to provide a runtime library to facilitate working with LinkML-defined instance data – that is conformant to a LinkML schema known at compile-time – from within a Java program, by offering classes and methods to load/write the data from/to various formats, and validate and manipulate said data.

Secondary aims will include:

  • Dynamic use of schemas: Supporting manipulation of data that is conformant to a schema that is only discovered at runtime.

  • Built-in Java code generation: Allowing the generation of the Java code representing a LinkML schema directly from the runtime library (instead of having to rely on LinkML-Py’s code generator), so that the code generation step can be easily integrated within the build process of a Java project (this will most likely take the form of a Maven plugin).

Implementation status

For now, the runtime supports loading and writing data from and to the YAML and JSON formats. Support for other formats, especially RDF, will be added later.

Probably the most important limitation for now is the complete lack of support for dynamic enums: only “static” enums, whose permissible values are fully known at compile-time, are supported.

Usage

Currently, using the runtime supposes that the Java code representing the LinkML-defined model is already available. Typically, it would have been generated by LinkML-Py’s tool (linkml generate java).

Importantly, for the runtime to work properly the code must satisfy specific requirements, as outlined in the documentation. LinkML-Py’s own code generator already meets some of those requirements; hopefully it will soon provide an option to also automatically meet all of them.

Assuming you have a LinkML-defined model with a root class named Foo, once you have generated the corresponding code, you can read an instance of Foo from a YAML file as follows:

YAMLLoader loader = new YAMLLoader();
Foo foo = loader.loadObject(new File("foo.yaml"), Foo.class);

To read a list of objects instead (if your LinkML schema does not define a top-level object, as for example with the KGCL schema):

List<Change> kgclChangeset = loader.loadObjects(new File("changes.kgcl"), Change.class);

Homepage and repository

The project is currently located at https://incenp.org/dvlpt/linkml-java/. The source code is available in a Git repository at https://github.com/gouttegd/linkml-java.

Copying

LinkML-Java is distributed under the terms of the 3-clause BSD license. The full license is included in the COPYING file of the source distribution.

About

LinkML runtime library for Java

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages