Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Lyo/Store"

< Lyo
(Replaced content with "= Lyo Store = This page has moved to the [https://github.com/eclipse/lyo-store Lyo Store repository on Github].")
 
Line 1: Line 1:
 
= Lyo Store =
 
= Lyo Store =
  
''Lyo Store'' is a library that provides a simple interface for working with a triplestore via Java objects representing OSLC Resources.
+
This page has moved to the [https://github.com/eclipse/lyo-store Lyo Store repository on Github].
 
+
== Introduction ==
+
 
+
Lyo Store makes use of the Jena Framework API (through the Eclipse Lyo Jena helper) to interact with any RDF Triplestore that can provide a SPARQL endpoint over HTTP.
+
 
+
An OSLC Server interacts with Lyo Store using on instances of OSLC4J-annotated classes, which are expected to represent the business objects of the underlying lifecycle tool. ''This allows the Server components to work generically with any tool Controller, while at the same time being able to handle tool-specific domain objects.'' When interacting with the RDF TripleStore, Lyo Store eventually marshals/unmarshals such instances into an RDF graph, through the available OSLC4J helper methods.
+
 
+
So naturally, all components of this architecture need to share the common set of OSLC4J-annotated classes. To facilitate this effort, the adaptor developer can take advantage of the [https://wiki.eclipse.org/Lyo/ToolchainModellingAndCodeGenerationWorkshop OSLC Lyo Modelling tool] in order to graphically model the business objects to be exposed, as well as the services of the OSLC Server component. From such a model, the classes and services can be generated.
+
 
+
[[File:lyo_store-architecture.png|center|800px]]
+
 
+
== Getting started ==
+
 
+
Lyo uses Maven as a primary choice for the build system. Make sure your POM file includes Eclipse Maven repositories (see the [https://wiki.eclipse.org/Lyo/LyoOSLC4J#Using_in_Maven OSLC4J instructions]).
+
 
+
Add the following dependency:
+
 
+
<source lang="xml"><dependency>
+
    <groupId>org.eclipse.lyo.store</groupId>
+
    <artifactId>store-core</artifactId>
+
    <version>2.2.0</version>
+
</dependency></source>
+
<p></p>
+
'''NOTE!''' If you are using the older versions of Lyo (2.1.2 and lower), Maven might decide to use an incompatible version of Jena (eg you get the <code>java.lang.NoClassDefFoundError: com/hp/hpl/jena/graph/NodeFactory</code>). In order to prevent this, enforce the Jena version used by <code>lyo-store</code> by adding the following tag to the <code>pom.xml</code>:
+
 
+
<source lang="xml"><dependencyManagement>
+
    <dependencies>
+
        <dependency>
+
            <groupId>org.apache.jena</groupId>
+
            <artifactId>jena-core</artifactId>
+
            <version>2.13.0</version>
+
        </dependency>
+
    </dependencies>
+
</dependencyManagement></source>
+
<p></p>
+
 
+
Now you are all set to start using the library. If you encounter any API questions along the way, consult the [http://download.eclipse.org/lyo/docs/store/latest/overview-summary.html Javadoc] or ask a question on the [https://www.eclipse.org/forums/index.php/f/228/ Lyo forum].
+
 
+
== Using Lyo Store ==
+
 
+
Assuming you have initialised an array of resource class instances in variable <code>resourceArray</code>, in order to add the new resources and overwrite the existing ones you can use the following flow:
+
 
+
<source lang="java">try {
+
    store.updateResources(GRAPH_NAME, // URI of the named graph
+
            resourceArray);          // an array of OSLC Resources
+
} catch (StoreAccessException e) {
+
    logger.error("Error executing a query on a triplestore");
+
}</source>
+
<p></p>
+
 
+
In order to retrieve the resources of type <code>Requirement</code> from the triplestore in batches of 200:
+
 
+
<source lang="java">if (store.namedGraphExists(GRAPH_NAME)) {
+
    try {
+
        final int limit = 200; // fetch 200 resources
+
        final int offset = 0;  // start with the first page
+
        // 'limit+1' is a technique that allows you to determine if there are
+
        // more results on the next page
+
        List<Requirement> requirements = store.getResources(GRAPH_NAME,
+
                Requirement.class, // resources of this class will be fetched and unmarshalled
+
                limit + 1,        // resource limit
+
                offset));          // how many resources to skip, use for paging
+
    } catch (StoreAccessException e) {
+
        logger.error("Error executing a query on a triplestore");
+
    } catch ( ModelUnmarshallingException e) {
+
        logger.error("Error unmarshalling the RDF from triplestore into Requirement class instances");
+
    }
+
}</source>
+
<p></p>
+
 
+
See [http://download.eclipse.org/lyo/docs/store/latest/org/eclipse/lyo/store/Store.html Store javadoc] for all available methods.
+
 
+
== Links ==
+
 
+
* '''[http://download.eclipse.org/lyo/docs/store/latest/overview-summary.html Lyo Store Javadoc]'''
+
* [https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Lyo&component=Tools File a new Lyo Tools bug]
+
* [https://www.eclipse.org/forums/index.php/f/228/ Ask a question on Eclipse Lyo forum]
+
* '''[https://wiki.eclipse.org/Lyo#Contributing_to_Lyo Contribute to Eclipse Lyo!]'''
+

Latest revision as of 16:56, 10 April 2018

Lyo Store

This page has moved to the Lyo Store repository on Github.

Back to the top