Sample code to demonstrate how to use Lyo Designer to create an OSLC server for the SysML v2 REST API.
Run Fuseki triplestore using Docker:
docker run --rm -p 3030:3030 atomgraph/fuseki --mem /ds
Alternatively, do a manual install:
- Install Apache Jena Fuseki https://jena.apache.org/download/index.cgi
- Run Fuseki http://localhost:3030/dataset.html
- Create a dataset named "ds"
- run
mvn install
on the projectorg.oasis.oslcop.sysml.oslc-domain
:mvn -f org.oasis.oslcop.sysml.oslc-domain/pom.xml clean install
- this is necessary if changes are made to the classes in the sysml-domain, which the sysml-server depends on.
- This is also necessary when running for the first time.
- run
mvn jetty:run-war
on the projectorg.oasis.oslcop.sysml.oslc-server
- If the first time you are running the server, you need to populate the database with some data. You have 2 alternatives:
- Populate the data from a Json server (as defined in the properties-file
org.oasis.oslcop.sysml.oslc-server\src\main\resources\jsonServer.properties
)- Call http://localhost:8085/sysml_oslc_server/oslc/populate
- If you already have the data in the triplestore, make sure to select active version via http://localhost:8085/sysml_oslc_server/oslc/store/projectCommits (WARN: the page will take quite a long time to load).
- Populate the data from a triplestore backup file
data\SysML2data.nq
- Unzip the file
data\SysML2data.nq
- Use Postman to make a POST request to http://localhost:3030/ds/data. Set the request body to be "binary", and select the file
data\SysML2data.nq
as the body.
- Unzip the file
- Populate the data from a Json server (as defined in the properties-file
- Browse the data starting with the catalog http://localhost:8085/sysml_oslc_server/oslc/catalog/singleton
Example queries we can execute (if you chose version 11609e2b-a4df-4a64-9e61-a45660c28542
):
oslc.where sysml:identifier="5bc41f66-4d42-41da-b7a3-92af54dab320"
oslc.prefix sysml=<http://omg.org/ns/sysml#>
The domain-classes are based on the ecore file, located under:
- Repo: https://github.com/ModelDriven/SysML-v2-Pilot-Implementation.git
- filePath: org.omg.sysml\model\SysML.ecore
The Swagger Docs for the REST server has base: http://sysml2-dev.intercax.com:9000/
The SysML domain classes are generated, based on a Lyo model that is itself transformed from the Sysml EMF model.
There are currently 3 manual steps that need to be handled when re-generating the code.
- The first can be automated in the future.
- The second is due to a limitation in LyoDesigner.
- The third is due to a bug that will hopefully be fixed in the future.
Before generating the java classes, the generated Lyo model is manually modified to:
- Make Element a subclass of
oslc_am:Resource
. - Configure the generator to NOT generate the AM classes (since these are already included as a maven dependency)
After generating the domain classes, we need to change the toString()
method on each resource to make it print the resources better.
Tips: Use Notepad++ to search/replace on all *.java
files.
- Find:
// Start of user code toString_finalize\n // End of user code
- Replace:
// Start of user code toString_finalize\n result = getShortTitle();\n // End of user code
In the generated JSP pages, there are calls to getDctermsType()
, getDctermsIdentifier()
and getDctermsSource()
, but these methods do not exist.
They would have existed if the OSLC AM resources were generated. But because we are including the library as it is previously generated, the methods should be really getType()
, getIdentifier()
and getSource()
This work is licensed under the terms of Apache License 2.0.