2016-07-05

‎Browsing the generated code

← Older revision

Revision as of 12:22, 5 July 2016

(2 intermediate revisions by the same user not shown)

Line 116:

Line 116:

== Define the adaptor model ==

== Define the adaptor model ==



You can now specify the desired functionality of your OSLC Adaptor through the graphical
EMF
model.

+

You can now specify the desired functionality of your OSLC Adaptor through the graphical model.



The adaptor metal-model
being instantiated is
illustrated below.
It consists of 2 main branches:

+

The adaptor
model is an instance of the
metal-model illustrated below
(For clarity, not all properties are illustrated in the diagram). We will refer to this meta-model to explain how to define your adaptor model instance
.



*
The
left side of the meta-model is a model of the OSLC resources - and their corresponding services - to be exposed by the adaptor.

+

The model
consists
of
3 main parts
:



* The right side of the meta-model is a
model of
a typical OSLC domain specification, as defined in [http
:
//open-services.net/bin/view/Main/OslcCoreSpecification?sortcol=table;up=#Service_Provider_Resources the OSLC Core Specification].

+



[
[File
:
OSLCToolAdaptorMetalModel
.
png]
]

+

* '''Domain Specification''' - Modelling the OSLC domain specification(s) to be exposed and/or consumed by the adaptor, as defined in
[
http
:
//open-services
.
net/bin/view/Main/OslcCoreSpecification?sortcol=table;up=#Service_Provider_Resources the OSLC Core Specification
]
.

+

* '''Server''' - modelling the OSLC resources - and their corresponding services - to be exposed by the adaptor.

+

* '''Client''' - modelling the interactions - as a client - that the adaptor might have with other OSLC servers.



We will refer to this meta-model to explain how to define your adaptor model instance
.

+

[[File:OSLCToolAdaptorMetalModel
.
png]]



=== Define
right-side of adaptor model
===

+

=== Define
the Domain Specifications
===

# In the EMF editor, expand the model to view the '''AdaptorInterface''' instance.

# In the EMF editor, expand the model to view the '''AdaptorInterface''' instance.



# Right-click on '''AdaptorInterface(1)''' instance and select '''New Child -->''' '''Specification(
5
)'''

+

# Right-click on '''AdaptorInterface(1)''' instance and select '''New Child -->''' '''Specification(
2
)'''

## This instance is a simple container of domain specifications and namespaces. No properties defined.

## This instance is a simple container of domain specifications and namespaces. No properties defined.

# Define any number of additional domain specifications. (For example, the OSLC RM domain specification defines the namespace URI of ''http://open-services.net/ns/rm#'' with a preferred namespace prefix of ''oslc_rm''. You can here define your own specific domains.) For each such domain specification:

# Define any number of additional domain specifications. (For example, the OSLC RM domain specification defines the namespace URI of ''http://open-services.net/ns/rm#'' with a preferred namespace prefix of ''oslc_rm''. You can here define your own specific domains.) For each such domain specification:



## Right-click on the '''Specification(
5
)''' instance and select '''New Child -->''' '''NamespacePrefix(6)'''

+

## Right-click on the '''Specification(
2
)''' instance and select '''New Child -->''' '''NamespacePrefix(6)'''

### For the newly-created NamespacePrefix, simply provide the prefix for the new domain specification (Note: To view and change properties of a model element, you can (a) right-click on the EMF instance, and select "Show Properties View" or (b) double-click on the instance.)

### For the newly-created NamespacePrefix, simply provide the prefix for the new domain specification (Note: To view and change properties of a model element, you can (a) right-click on the EMF instance, and select "Show Properties View" or (b) double-click on the instance.)



## Right-click on the '''Specification(
5
)''' instance and select '''New Child -->''' '''DomainSpecification(
7
)'''

+

## Right-click on the '''Specification(
2
)''' instance and select '''New Child -->''' '''DomainSpecification(
5
)'''

### For the newly created DomainSpecification instance, fill-in its properties. (Note that the namespacePrefix property refers to an instance of NamespacePrefix(6))

### For the newly created DomainSpecification instance, fill-in its properties. (Note that the namespacePrefix property refers to an instance of NamespacePrefix(6))



### Define '''Resource(
9
)''' and/or '''ResourceProperty(
8
)''' instances as desired.

+

### Define '''Resource(
8
)''' and/or '''ResourceProperty(
7
)''' instances as desired.

### Note that a Resource instance can refer to ResourceProperties from any other domainSpecification in the model.

### Note that a Resource instance can refer to ResourceProperties from any other domainSpecification in the model.



=== Define
left-side of adaptor model
===

+

=== Define
the Server
===

# Select the '''AdaptorInterface(1)''' EMF instance and configure its Properties.

# Select the '''AdaptorInterface(1)''' EMF instance and configure its Properties.

## The properties’ meaning is as follows:

## The properties’ meaning is as follows:

Line 148:

Line 149:

### ''Javascript Files Base Path'': The path of where javascript files will be generated. (for example, ''/WebContent'')

### ''Javascript Files Base Path'': The path of where javascript files will be generated. (for example, ''/WebContent'')

### ''Jsp Files Base Path'': The path of where the Jsp files will be generated. (for example, ''/WebContent'')

### ''Jsp Files Base Path'': The path of where the Jsp files will be generated. (for example, ''/WebContent'')



# Right-click on AdaptorInterface instance and select '''New Child -->ServiceProviderCatalog(
2
)'''

+

# Right-click on AdaptorInterface instance and select '''New Child -->ServiceProviderCatalog(
3
)'''

## For the newly created catalog, fill-in all its properties as defined according to OSLC.

## For the newly created catalog, fill-in all its properties as defined according to OSLC.

## Note that you can only define 1 catalogue in an adaptor.

## Note that you can only define 1 catalogue in an adaptor.



# Right-click on the ServiceProviderCatalog instance and select '''New Child -->Publisher(
4
)'''

+

# Right-click on the ServiceProviderCatalog instance and select '''New Child -->Publisher(
9
)'''

## For the newly created Publisher, fill-in all the Publisher properties as defined according to OSLC.

## For the newly created Publisher, fill-in all the Publisher properties as defined according to OSLC.

## Note that you can only define 1 Publisher for a catalog.

## Note that you can only define 1 Publisher for a catalog.



# Right-click on the ServiceProviderCatalogue instance and select '''New Child -->ServiceProvider(
3
)'''

+

# Right-click on the ServiceProviderCatalogue instance and select '''New Child -->ServiceProvider(
10
)'''

## For the newly created ServiceProvider, fill-in the ServiceProvider properties (Title, Description) as defined according to OSLC.

## For the newly created ServiceProvider, fill-in the ServiceProvider properties (Title, Description) as defined according to OSLC.

## (optional) To control the relative URLs used in the ServiceProvider web service, specify the following optional properties:

## (optional) To control the relative URLs used in the ServiceProvider web service, specify the following optional properties:

Line 160:

Line 161:

### instanceID - specifies the relative URL of a single service provider, including the parameter variables necessary to identify a specific service provider. For example, "{projectId}" leads to the url "http://localhost:8080/YourAdaptor/services/projects/1" mapping the value 1 to the projectId parameter in the java code. Other IDs can be "collectionName/{collectionName}/project/{projectName}". The default is "{serviceProviderId}".

### instanceID - specifies the relative URL of a single service provider, including the parameter variables necessary to identify a specific service provider. For example, "{projectId}" leads to the url "http://localhost:8080/YourAdaptor/services/projects/1" mapping the value 1 to the projectId parameter in the java code. Other IDs can be "collectionName/{collectionName}/project/{projectName}". The default is "{serviceProviderId}".

## Note that you can define one-or-many ServiceProviders for a ServiceProviderCatalogue.

## Note that you can define one-or-many ServiceProviders for a ServiceProviderCatalogue.



# From each of the defined ServiceProviders,  proceed down to create and define '''Services(
10
)''' & '''Capabilities(
11,
12
,13
)'''.

+

# From each of the defined ServiceProviders,  proceed down to create and define '''Services(
11
)''' & '''Capabilities(12)'''.

## Make sure you fill-in all properties of each EMF instance you create.

## Make sure you fill-in all properties of each EMF instance you create.

## Make sure you satisfy the cardinality of each of the containment relationships as illustrated in the figure above.

## Make sure you satisfy the cardinality of each of the containment relationships as illustrated in the figure above.



## When defining the properties of '''Capabilities(
11,
12
,13
)''', make sure you define each of their Resource Types property. (Which are defined either under the '''Specifiation(
5
)''' EMF instance (see section [[Lyo/AdaptorCodeGeneratorWorkshop#Define_right-side_of_adaptor_model | Define right-side of adaptor model]]), or exist as part of a loaded domain specification (see section [[Lyo/AdaptorCodeGeneratorWorkshop#Load_existing_domain_specifications | Load existing domain specifications]]).)

+

## When defining the properties of '''Capabilities(12)''', make sure you define each of their Resource Types property. (Which are defined either under the '''Specifiation(
2
)''' EMF instance (see section [[Lyo/AdaptorCodeGeneratorWorkshop#Define_right-side_of_adaptor_model | Define right-side of adaptor model]]), or exist as part of a loaded domain specification (see section [[Lyo/AdaptorCodeGeneratorWorkshop#Load_existing_domain_specifications | Load existing domain specifications]]).)

## (optional) To control the relative URLs used in the web service handling a particular resource, create a BasicCapability with the following properties:

## (optional) To control the relative URLs used in the web service handling a particular resource, create a BasicCapability with the following properties:

### serviceNamespace - specifies whether the relative URL of the resource web service should include the URL of its managing service provider (relativeToServiceProvider), or it should be standalone (independantOfServiceProvider).

### serviceNamespace - specifies whether the relative URL of the resource web service should include the URL of its managing service provider (relativeToServiceProvider), or it should be standalone (independantOfServiceProvider).

### instanceID - specifies the relative URL of a single resource, including the parameter variables necessary to identify a specific resource. For example, "{changeRequestId}" leads to the url "http://localhost:8080/YourAdaptor/services/changeRequests/1" mapping the value 1 to the changeRequestId parameter in the java code.

### instanceID - specifies the relative URL of a single resource, including the parameter variables necessary to identify a specific resource. For example, "{changeRequestId}" leads to the url "http://localhost:8080/YourAdaptor/services/changeRequests/1" mapping the value 1 to the changeRequestId parameter in the java code.

+

+

=== Define the Client(s) Interactions ===

+

Currently, the model supports a simple definition of client interactions, by either linking

+

to another adaptorInterface model, or simply listing the set of resources the adaptor expects from its required server.

+

+

To define a client interaction with an adaptor for which a model already exists:

+

# right-click on '''AdaptorInterface(1)''' instance and select '''New Child -->Modelled Required Adaptor(14)'''

+

# For the newly created Required Adaptor instance, fill-in its properties.

+

## Define the URI of the Service Provider Catalog

+

## Define the AdaptorInterface that this client represents.

+

##* Tips: Instead of modelling all adaptors in a single model, you can instead link to an adaptorInterface defined in another model: (a) right-click in an empty are of the diagram and select the context menu '''Load Resource...''' (b) Select '''Browse Workspace...''' (c) Select the desired adaptorInterface model that you intend to use. Elements of the loaded model can now be referenced in the adaptor model you are creating.

+

+

To define a client interaction with an adaptor that is simply modelled by the set of resources it exposes:

+

# right-click on '''AdaptorInterface(1)''' instance and select '''New Child -->Generic Required Adaptor(14)'''

+

# For the newly created Required Adaptor instance, fill-in its properties.

+

## Define a name of the server

+

## Define the URI of the Service Provider Catalog

+

## Define the set of '''Resources(9)''' that the client expects the server to expose.

== Validate the adaptor model ==

== Validate the adaptor model ==

Line 202:

Line 221:

# Package: '''''your.basepackage.name''.servlet'''

# Package: '''''your.basepackage.name''.servlet'''

#* Contains necessary classes for the project such as ServiceProviderFactory, ServletListener, etc.

#* Contains necessary classes for the project such as ServiceProviderFactory, ServletListener, etc.

+

# Package: '''''your.basepackage.name''.clients'''

+

#* for each required adaptor, a corresponding Java class is defined.

+

#* Currently, the class simply provides a GET method for each resource provided by the required server. This class is a starting point to explore the remaining functionality provided by the OslcClient class, and its methods will be expanded in the future.

#Package: '''''your.basepackage.name'''''

#Package: '''''your.basepackage.name'''''

#* The '''AdaptorManager''' class contains the set of methods that will ultimately communicate with the source tool to access its internal data, and eventually expose information as OSLC resources.

#* The '''AdaptorManager''' class contains the set of methods that will ultimately communicate with the source tool to access its internal data, and eventually expose information as OSLC resources.

Show more