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/OSLC4JAnnotations"

< Lyo
Line 1: Line 1:
 +
== Service Description Documents ==
 +
 
OSLC4J will generate an OSLC service description document for you if you've properly annotated your code. You should have an @OslcService annotation on every JAX-RS resource you want to use with OSLC4J, even if you only have one service description document.
 
OSLC4J will generate an OSLC service description document for you if you've properly annotated your code. You should have an @OslcService annotation on every JAX-RS resource you want to use with OSLC4J, even if you only have one service description document.
  
'''Query Capabilities and Creation Factories'''
+
=== Query Capabilities and Creation Factories ===
  
 
To use @OslcQueryCapability and @OslcCreationFactory, simply add those annotations to the @GET and @POST methods for each resource that handles those requests. The URIs are added to the service description document calculated from the JAX-RS @Path annotation.
 
To use @OslcQueryCapability and @OslcCreationFactory, simply add those annotations to the @GET and @POST methods for each resource that handles those requests. The URIs are added to the service description document calculated from the JAX-RS @Path annotation.
Line 47: Line 49:
 
</code>
 
</code>
  
'''Dialogs'''
+
=== Dialogs ===
  
 
* For selection dialogs, the @OslcDialogs or @OslcDialog annotation has to be on a @GET method, usually the query capability.
 
* For selection dialogs, the @OslcDialogs or @OslcDialog annotation has to be on a @GET method, usually the query capability.
Line 67: Line 69:
 
</code>
 
</code>
  
'''Creating the ServiceProvider'''
+
=== Creating the ServiceProvider ===
  
 
To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.
 
To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.

Revision as of 19:03, 7 March 2014

Service Description Documents

OSLC4J will generate an OSLC service description document for you if you've properly annotated your code. You should have an @OslcService annotation on every JAX-RS resource you want to use with OSLC4J, even if you only have one service description document.

Query Capabilities and Creation Factories

To use @OslcQueryCapability and @OslcCreationFactory, simply add those annotations to the @GET and @POST methods for each resource that handles those requests. The URIs are added to the service description document calculated from the JAX-RS @Path annotation.

Here is an example @OslcQueryCapability:

   @OslcQueryCapability
   (
       title = "Change Request Query Capability",
       label = "Change Request Catalog Query",
       resourceShape = OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST,
       resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
       usages = {OslcConstants.OSLC_USAGE_DEFAULT}
   )
   @GET
   @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   		   OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   public ChangeRequest[] getChangeRequests(@QueryParam("oslc.where") final String where)
   {
      // ... implementation here ...
   }

Here is an example @OslcCreationFactory:

   @OslcCreationFactory
   (
        title = "Change Request Creation Factory",
        label = "Change Request Creation",
        resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + Constants.PATH_CHANGE_REQUEST},
        resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
        usages = {OslcConstants.OSLC_USAGE_DEFAULT}
   )
   @POST
   @Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   	       OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   @Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML,
   	       OslcMediaType.APPLICATION_JSON, OslcMediaType.TEXT_TURTLE})
   public Response addChangeRequest(ChangeRequest changeRequest)
   {
      // ... implementation here ...
   }

Dialogs

  • For selection dialogs, the @OslcDialogs or @OslcDialog annotation has to be on a @GET method, usually the query capability.
  • For creation dialogs, the annotation has to be on an @POST method, usually the creation factory.

The @OslcDialog "uri" determines the URI for the dialog, and you can use path parameters. For instance, the Bugzilla adapter has this selection dialog:

       @OslcDialog
       (
            title = "Change Request Selection Dialog",
            label = "Change Request Selection Dialog",
            uri = "/{productId}/changeRequests/selector",
            hintWidth = "525px",
            hintHeight = "325px",
            resourceTypes = {Constants.TYPE_CHANGE_REQUEST},
            usages = {OslcConstants.OSLC_USAGE_DEFAULT}
       )

Creating the ServiceProvider

To create the ServiceProvider, call org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory.createServiceProvider(). You might need to set a few properties manually, such as the details URI and prefix definitions.

Back to the top