oslc-op / sysml-oslc-server

Sample code to demonstrate how to use Lyo Designer to create an OSLC server for the SysML v2 REST API.
Apache License 2.0
10 stars 2 forks source link

SysML OSLC Server

CI Discourse users

Sample code to demonstrate how to use Lyo Designer to create an OSLC server for the SysML v2 REST API.

Prerequisites

Run Fuseki triplestore using Docker:

docker run --rm -p 3030:3030 atomgraph/fuseki --mem /ds

Alternatively, do a manual install:

  1. Install Apache Jena Fuseki https://jena.apache.org/download/index.cgi
  2. Run Fuseki http://localhost:3030/dataset.html
  3. Create a dataset named "ds"

Running the server

  1. run mvn install on the project org.oasis.oslcop.sysml.oslc-domain: mvn -f org.oasis.oslcop.sysml.oslc-domain/pom.xml clean install
    1. this is necessary if changes are made to the classes in the sysml-domain, which the sysml-server depends on.
    2. This is also necessary when running for the first time.
  2. run mvn jetty:run-war on the project org.oasis.oslcop.sysml.oslc-server
  3. If the first time you are running the server, you need to populate the database with some data. You have 2 alternatives:
    1. Populate the data from a Json server (as defined in the properties-file org.oasis.oslcop.sysml.oslc-server\src\main\resources\jsonServer.properties)
      1. Call http://localhost:8085/sysml_oslc_server/oslc/populate
      2. 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).
    2. Populate the data from a triplestore backup file data\SysML2data.nq
      1. Unzip the file data\SysML2data.nq
      2. 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.
  4. Browse the data starting with the catalog http://localhost:8085/sysml_oslc_server/oslc/catalog/singleton

Query

Example queries we can execute (if you chose version 11609e2b-a4df-4a64-9e61-a45660c28542):

http://localhost:8085/sysml_oslc_server/oslc/projects/23561420-ef88-4249-bf99-651670ff438f/service6/features/query

Info

The domain-classes are based on the ecore file, located under:

The Swagger Docs for the REST server has base: http://sysml2-dev.intercax.com:9000/

Developer Info - Manual steps when re-generating model and code

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.

1.

Before generating the java classes, the generated Lyo model is manually modified to:

  1. Make Element a subclass of oslc_am:Resource.
  2. Configure the generator to NOT generate the AM classes (since these are already included as a maven dependency)

2.

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.

3.

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()

License

This work is licensed under the terms of Apache License 2.0.