aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjad2014-03-18 09:06:59 (EDT)
committerjad2014-03-18 09:57:24 (EDT)
commitf01155c91fb1b5e33f0699fe860c9c53eeab790e (patch)
treefecefa4d1507ebbdb896b852ac705cf5f6abaa22
parent2e5498951813f96548633940133e09d4d5356c7e (diff)
downloadorg.eclipse.lyo.core-f01155c91fb1b5e33f0699fe860c9c53eeab790e.zip
org.eclipse.lyo.core-f01155c91fb1b5e33f0699fe860c9c53eeab790e.tar.gz
org.eclipse.lyo.core-f01155c91fb1b5e33f0699fe860c9c53eeab790e.tar.bz2
Bug 430604 - The code generator wrongly implements a JAX-RS resource perrefs/changes/41/23541/1
OSLC service. Update code generator such that a JAX-RS resource is created per Resource instead of per OSLC service. Also, added a domain model for the AM specs. Change-Id: I2da0ac8104c3b480ed550ffda87b0fd62d8175a9 Signed-off-by: jad <jad@kth.se>
-rw-r--r--org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCArchitectureManagementSpecification.xmi31
-rw-r--r--org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCCoreSpecificationsSet.xmi3
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl5
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorManager.mtl32
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorServiceProviderFactory.mtl10
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateResourceService.mtl (renamed from org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateService.mtl)178
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/main/generate.mtl12
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl6
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/resourceServices.mtl34
-rw-r--r--org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/serviceServices.mtl21
10 files changed, 186 insertions, 146 deletions
diff --git a/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCArchitectureManagementSpecification.xmi b/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCArchitectureManagementSpecification.xmi
new file mode 100644
index 0000000..8a74fda
--- /dev/null
+++ b/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCArchitectureManagementSpecification.xmi
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<oslc4j_ai:Specification xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oslc4j_ai="http://org.eclipse.lyo/oslc4j/adaptorInterface" xsi:schemaLocation="http://org.eclipse.lyo/oslc4j/adaptorInterface adaptorInterface.ecore">
+ <domainSpecifications name="Architecture_Management" namespaceURI="http://open-services.net/ns/am#" namespacePrefix="//@domainPrefixes.0">
+ <resources name="ArchitectureManagementResource">
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.8"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.2"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.6"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.5"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.3/@resourceProperties.0"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.9"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.1"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.0"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.4"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.7"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.0/@resourceProperties.2"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.0/@resourceProperties.1"/>
+ </resources>
+ <resources name="LinkTypeResource">
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.3/@resourceProperties.1"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.3/@resourceProperties.2"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.6"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.1"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.0"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.4"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.2/@resourceProperties.7"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.0/@resourceProperties.2"/>
+ <resourceProperties href="OSLCCoreSpecificationsSet.xmi#//@domainSpecifications.0/@resourceProperties.1"/>
+ </resources>
+ </domainSpecifications>
+ <domainPrefixes name="oslc_am"/>
+</oslc4j_ai:Specification>
diff --git a/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCCoreSpecificationsSet.xmi b/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCCoreSpecificationsSet.xmi
index 3837d24..642324b 100644
--- a/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCCoreSpecificationsSet.xmi
+++ b/org.eclipse.lyo.oslc4j.adaptormodel/model/OSLCCoreSpecificationsSet.xmi
@@ -23,9 +23,12 @@
<resourceProperties title="" name="identifier" readOnly="true" valueType="String" description="A unique identifier for a resource. Typically read-only and assigned by the service provider when a resource is created. Not typically intended for end-user display."/>
<resourceProperties title="" name="modified" occurs="zeroOrOne" readOnly="true" valueType="DateTime" description="Timestamp last latest resource modification"/>
<resourceProperties title="" name="title" valueType="XMLLiteral" description="Title of the resource represented as rich text in XHTML content. SHOULD include only content that is valid inside an XHTML &lt;span> element. "/>
+ <resourceProperties title="" name="source" occurs="zeroOrOne" valueType="Resource" representation="reference" description="A related resource from which the described resource is derived. "/>
</domainSpecifications>
<domainSpecifications name="RDF" namespaceURI="http://www.w3.org/1999/02/22-rdf-syntax-ns" namespacePrefix="//@domainPrefixes.3">
<resourceProperties title="" name="type" occurs="zeroOrMany" valueType="URI" description="The resource type URIs."/>
+ <resourceProperties title="" name="label" valueType="String" description=" Is an instance of rdf:Property that may be used to provide a human-readable version of a resource's name"/>
+ <resourceProperties name="comment" occurs="zeroOrOne" valueType="String" description="A description of the subject resource"/>
</domainSpecifications>
<domainSpecifications name="RDFS" namespaceURI="http://www.w3.org/2000/01/rdf-schema" namespacePrefix="//@domainPrefixes.4"/>
<domainPrefixes name="oslc"/>
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl
index f615e86..6fe7c1d 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl
@@ -87,7 +87,8 @@ import [javaClassFullNameForService(anAdaptorInterface.serviceProviderCatalog) /
[for (aResource: Resource | relevantResources(anAdaptorInterface)->sortedBy(name)) separator(lineSeparator())]import [javaClassFullName(aResource, anAdaptorInterface) /];[/for]
import [javaInterfaceFullNameForAdaptorConstants(anAdaptorInterface) /];
-[for (aService: Service | anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->sortedBy(x: Service | javaClassFullName(x))) separator(lineSeparator())]import [javaClassFullName(aService) /];[/for]
+[for (aResource: Resource | servicedResources(anAdaptorInterface)->sortedBy(name)) separator(lineSeparator())]import [javaClassFullNameForService(aResource, anAdaptorInterface) /];[/for]
+
public class [javaClassNameForAdaptorApplication(anAdaptorInterface) /] extends OslcWinkApplication {
@@ -100,7 +101,7 @@ public class [javaClassNameForAdaptorApplication(anAdaptorInterface) /] extends
{
RESOURCE_CLASSES.addAll(JenaProvidersRegistry.getProviders());
RESOURCE_CLASSES.addAll(Json4JProvidersRegistry.getProviders());
- [for (aService: Service | anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->sortedBy(x: Service | javaClassName(x))) separator(lineSeparator())]RESOURCE_CLASSES.add([javaClassName(aService)/].class);[/for]
+ [for (aResource: Resource | servicedResources(anAdaptorInterface)->sortedBy(name)) separator(lineSeparator())]RESOURCE_CLASSES.add([javaClassNameForService(aResource, anAdaptorInterface)/].class);[/for]
[for (aResource: Resource | relevantResources(anAdaptorInterface)->sortedBy(name)) separator(lineSeparator())]RESOURCE_CLASSES.add([javaClassName(aResource)/].class);[/for]
RESOURCE_CLASSES.add(Class.forName("org.eclipse.lyo.server.oauth.webapp.services.ConsumersService"));
RESOURCE_CLASSES.add(Class.forName("org.eclipse.lyo.server.oauth.webapp.services.OAuthService"));
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorManager.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorManager.mtl
index c19edab..d7aa9fa 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorManager.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorManager.mtl
@@ -115,43 +115,37 @@ public class [javaClassNameForAdaptorManager(anAdaptorInterface) /] {
return serviceProviderInfos;
}
- [for (aService: Service | anAdaptorInterface.serviceProviderCatalog.serviceProviders.services)]
- [comment TODO: I am looping through services. This code will cause problems if 2 services have the same coveredResource
- since I will be producing the same functions twice.
- Fix, so that I first work out the set of coveredResources of all services, and then
- produce the functions for them.
- The reason I don't loop through all resources, is that I only want to produce functions for the resources
- that are needed in the services. Resources with no rol in a service should not be produced. /]
- public static [javaClassName(coveredResource(aService)) /] get[coveredResource(aService).name.toUpperFirst() /](HttpServletRequest httpServletRequest, String [coveredResource(aService).name.toLowerFirst() /]Id, String serviceProviderId)
+ [for (aResource: Resource | servicedResources(anAdaptorInterface))]
+ public static [javaClassName(aResource) /] get[aResource.name.toUpperFirst() /](HttpServletRequest httpServletRequest, String [aResource.name.toLowerFirst() /]Id, String serviceProviderId)
{
- [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /] = null;
+ [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /] = null;
// [protected ('(MUST_FILL_IN) getResource userCode')]
// [/protected]
- return a[coveredResource(aService).name.toUpperFirst() /];
+ return a[aResource.name.toUpperFirst() /];
}
- public static List<[javaClassName(coveredResource(aService)) /]> get[coveredResource(aService).name.toUpperFirst() /]s(HttpServletRequest httpServletRequest, String serviceProviderId, int page, int limit)
+ public static List<[javaClassName(aResource) /]> get[aResource.name.toUpperFirst() /]s(HttpServletRequest httpServletRequest, String serviceProviderId, int page, int limit)
{
- List<[javaClassName(coveredResource(aService)) /]> [coveredResource(aService).name.toLowerFirst() /]s = null;
+ List<[javaClassName(aResource) /]> [aResource.name.toLowerFirst() /]s = null;
// [protected ('(MUST_FILL_IN) getResources userCode')]
// [/protected]
- return [coveredResource(aService).name.toLowerFirst() /]s;
+ return [aResource.name.toLowerFirst() /]s;
}
- public static List<[javaClassName(coveredResource(aService)) /]> search[coveredResource(aService).name.toUpperFirst() /]s(HttpServletRequest httpServletRequest, String serviceProviderId, String terms)
+ public static List<[javaClassName(aResource) /]> search[aResource.name.toUpperFirst() /]s(HttpServletRequest httpServletRequest, String serviceProviderId, String terms)
{
- List<[javaClassName(coveredResource(aService)) /]> [coveredResource(aService).name.toLowerFirst() /]s = null;
+ List<[javaClassName(aResource) /]> [aResource.name.toLowerFirst() /]s = null;
// [protected ('(MUST_FILL_IN) searchResources userCode')]
// [/protected]
- return [coveredResource(aService).name.toLowerFirst() /]s;
+ return [aResource.name.toLowerFirst() /]s;
}
- public static [javaClassName(coveredResource(aService)) /] create[coveredResource(aService).name.toUpperFirst() /](HttpServletRequest httpServletRequest, final [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /], final String serviceProviderId)
+ public static [javaClassName(aResource) /] create[aResource.name.toUpperFirst() /](HttpServletRequest httpServletRequest, final [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /], final String serviceProviderId)
{
- [javaClassName(coveredResource(aService)) /] new[coveredResource(aService).name.toUpperFirst() /] = null;
+ [javaClassName(aResource) /] new[aResource.name.toUpperFirst() /] = null;
// [protected ('(MUST_FILL_IN) createResource userCode')]
// [/protected]
- return new[coveredResource(aService).name.toUpperFirst() /];
+ return new[aResource.name.toUpperFirst() /];
}
[/for]
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorServiceProviderFactory.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorServiceProviderFactory.mtl
index 99b5390..9aec8c9 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorServiceProviderFactory.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorServiceProviderFactory.mtl
@@ -27,6 +27,7 @@
[import org::eclipse::lyo::oslc4j::codegenerator::services::services/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::adaptorInterfaceServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::serviceServices/]
+[import org::eclipse::lyo::oslc4j::codegenerator::services::resourceServices/]
[template public generateAdaptorServiceProviderFactory(anAdaptorInterface : AdaptorInterface)]
[file (javaClassFullFileNameForServiceProviderFactory(anAdaptorInterface), false, 'UTF-8')]
@@ -69,10 +70,7 @@ import org.eclipse.lyo.oslc4j.core.model.ServiceProvider;
import org.eclipse.lyo.oslc4j.core.model.ServiceProviderFactory;
import [javaInterfaceFullNameForAdaptorConstants(anAdaptorInterface) /];
-[for (aService: Service | anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->sortedBy(x: Service | javaClassFullName(x)))]
-import [javaClassFullName(aService) /];
-[/for]
-
+[for (aResource: Resource | servicedResources(anAdaptorInterface)->sortedBy(name)) separator(lineSeparator())]import [javaClassFullNameForService(aResource, anAdaptorInterface) /];[/for]
// [protected ('imports')]
// [/protected]
@@ -81,9 +79,7 @@ public class [javaClassNameForServiceProviderFactory(anAdaptorInterface) /]
{
private static Class<?>[ '[' ']' /] RESOURCE_CLASSES =
{
- [for (aService: Service | anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->sortedBy(x: Service | javaClassName(x))) separator(', ')]
- [javaClassName(aService)/].class
- [/for]
+ [for (aResource: Resource | servicedResources(anAdaptorInterface)->sortedBy(name)) separator(', ')][javaClassNameForService(aResource, anAdaptorInterface)/].class[/for]
};
private [javaClassNameForServiceProviderFactory(anAdaptorInterface) /]()
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateService.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateResourceService.mtl
index 4a81ec6..ad0c57f 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateService.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateResourceService.mtl
@@ -19,7 +19,7 @@
*******************************************************************************/
/]
-[module generateService('http://org.eclipse.lyo/oslc4j/adaptorInterface')]
+[module generateResourceService('http://org.eclipse.lyo/oslc4j/adaptorInterface')]
[import org::eclipse::lyo::oslc4j::codegenerator::services::services/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::jspServices/]
@@ -28,6 +28,7 @@
[import org::eclipse::lyo::oslc4j::codegenerator::services::resourcePropertyServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::adaptorInterfaceServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::serviceProviderCatalogServices/]
+[import org::eclipse::lyo::oslc4j::codegenerator::services::domainSpecificationServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateResourceCollectionJsp/]
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateFilteredResourceCollectionJsp/]
@@ -35,8 +36,8 @@
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateResourceCreatorJsp/]
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateResourceSelectorJsp/]
-[template public generateService(aService : Service, anAdaptorInterface : AdaptorInterface)]
-[file (javaClassFullFileName(aService), false, 'UTF-8')]
+[template public generateResourceService(aResource : Resource, anAdaptorInterface : AdaptorInterface)]
+[file (javaClassFullFileNameForService(aResource, anAdaptorInterface), false, 'UTF-8')]
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
*
@@ -56,7 +57,7 @@
* This file is generated by org.eclipse.lyo.oslc4j.codegenerator
*******************************************************************************/
-package [javaClassPackageName(aService) /];
+package [javaClassPackageNameForService(aResource, anAdaptorInterface) /];
import java.io.IOException;
@@ -105,12 +106,12 @@ import org.eclipse.lyo.oslc4j.core.model.Preview;
import org.eclipse.lyo.oslc4j.core.model.ServiceProvider;
import org.eclipse.lyo.oslc4j.core.model.Link;
-import [javaClassFullNameForAdaptorManager(containingAdaptorInterface(aService)) /];
-import [javaInterfaceFullNameForAdaptorConstants(containingAdaptorInterface(aService)) /];
-import [javaClassFullNameForSingleton(containingServiceProviderCatalog(aService)) /];
-import [javaClassFullName(coveredResource(aService), anAdaptorInterface) /];
+import [javaClassFullNameForAdaptorManager(anAdaptorInterface) /];
+import [javaInterfaceFullNameForAdaptorConstants(anAdaptorInterface) /];
+import [javaClassFullNameForSingleton(anAdaptorInterface.serviceProviderCatalog) /];
+import [javaClassFullName(aResource, anAdaptorInterface) /];
-[for (aProperty: ResourceProperty | allProperties(coveredResource(aService))->sortedBy(name))]
+[for (aProperty: ResourceProperty | allProperties(aResource)->sortedBy(name))]
[if(Sequence{'Resource', 'LocalResource'}->includes(aProperty.valueType.toString())) ]
[if (not aProperty.range.oclIsUndefined())]
@@ -124,9 +125,9 @@ import [javaClassFullName(aProperty.range, anAdaptorInterface) /];
// [/protected]
-@OslcService([javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[domainSpecificationConstantName(aService.domainSpecification) /])
-@Path("{serviceProviderId}/[coveredResource(aService).name.toLowerFirst() /]s")
-public class [javaClassName(aService) /]
+@OslcService([javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[domainSpecificationConstantName(aResource.definingDomainSpecification()) /])
+@Path("{serviceProviderId}/[aResource.name.toLowerFirst() /]s")
+public class [javaClassNameForService(aResource, anAdaptorInterface) /]
{
@@ -134,7 +135,7 @@ public class [javaClassName(aService) /]
@Context private HttpServletResponse httpServletResponse;
@Context private UriInfo uriInfo;
- public [javaClassName(aService) /]()
+ public [javaClassNameForService(aResource, anAdaptorInterface) /]()
{
super();
}
@@ -152,9 +153,9 @@ public class [javaClassName(aService) /]
* @throws ServletException
*/
- @OslcDialogs(
+ @OslcDialogs(
{
- [for (aSelectionDialog: Dialog | aService.selectionDialogs)]
+ [for (aSelectionDialog: Dialog | selectionDialogs(aResource, anAdaptorInterface)) separator(','.concat(lineSeparator()))]
@OslcDialog
(
title = "[aSelectionDialog.title /]",
@@ -163,26 +164,24 @@ public class [javaClassName(aService) /]
uri = "[aSelectionDialog.dialogURI /]",
hintWidth = "[aSelectionDialog.hintWidth /]px",
hintHeight = "[aSelectionDialog.hintHeight /]px",
- resourceTypes = {[for (aResource: Resource | aSelectionDialog.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourceTypeConstantName(aResource) /][/for]},
+ resourceTypes = {[for (aResource: Resource | aSelectionDialog.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourceTypeConstantName(aResource) /][/for]},
usages = {OslcConstants.OSLC_USAGE_DEFAULT}
)
- [/for]
+ [/for]
})
-
- [for (aQueryCapability: QueryCapability | aService.queryCapabilities)]
- @OslcQueryCapability
- (
- title = "[aQueryCapability.title /]",
- label = "[aQueryCapability.label /]",
- resourceShape = OslcConstants.PATH_RESOURCE_SHAPES + "/" + [javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourcePathConstantName(coveredResource(aService)) /],
- resourceTypes = {[for (aResource: Resource | aQueryCapability.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourceTypeConstantName(aResource) /][/for]},
- usages = {OslcConstants.OSLC_USAGE_DEFAULT}
- )
+ [for (aQueryCapability: QueryCapability | queryCapabilities(aResource, anAdaptorInterface))]
+ @OslcQueryCapability
+ (
+ title = "[aQueryCapability.title /]",
+ label = "[aQueryCapability.label /]",
+ resourceShape = OslcConstants.PATH_RESOURCE_SHAPES + "/" + [javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourcePathConstantName(aResource) /],
+ resourceTypes = {[for (aResource: Resource | aQueryCapability.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourceTypeConstantName(aResource) /][/for]},
+ usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+ )
[/for]
-
@GET
@Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
- public [javaClassName(coveredResource(aService)) /] [ '[]' /] get[coveredResource(aService).name.toUpperFirst() /]s(@PathParam("serviceProviderId") final String serviceProviderId,
+ public [javaClassName(aResource) /] [ '[]' /] get[aResource.name.toUpperFirst() /]s(@PathParam("serviceProviderId") final String serviceProviderId,
@QueryParam("oslc.where") final String where,
@QueryParam("page") final String pageString) throws IOException, ServletException
{
@@ -192,8 +191,8 @@ public class [javaClassName(aService) /]
// [protected ('(MUST_FILL_IN) getResourceCollection_init')]
// [/protected]
- final List<[javaClassName(coveredResource(aService)) /]> resources = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].get[coveredResource(aService).name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, page, limit);
- return resources.toArray(new [javaClassName(coveredResource(aService)) /] [ '[' /]resources.size()[ ']' /]);
+ final List<[javaClassName(aResource) /]> resources = [javaClassNameForAdaptorManager(anAdaptorInterface) /].get[aResource.name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, page, limit);
+ return resources.toArray(new [javaClassName(aResource) /] [ '[' /]resources.size()[ ']' /]);
}
@@ -215,8 +214,8 @@ public class [javaClassName(aService) /]
@GET
@Produces({ MediaType.TEXT_HTML })
- public Response get[coveredResource(aService).name.toUpperFirst() /]sAsHtml(@PathParam("serviceProviderId") final String serviceProviderId,
- @PathParam("[coveredResource(aService).name.toLowerFirst() /]Id") final String [coveredResource(aService).name.toLowerFirst() /]Id,
+ public Response get[aResource.name.toUpperFirst() /]sAsHtml(@PathParam("serviceProviderId") final String serviceProviderId,
+ @PathParam("[aResource.name.toLowerFirst() /]Id") final String [aResource.name.toLowerFirst() /]Id,
@QueryParam("page") final String pageString) throws ServletException, IOException
{
int page=0;
@@ -229,7 +228,7 @@ public class [javaClassName(aService) /]
// [protected ('(MUST_FILL_IN) getResourceCollectionAsHTML_init')]
// [/protected]
- final List<[javaClassName(coveredResource(aService)) /]> resources = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].get[coveredResource(aService).name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, page, limit);
+ final List<[javaClassName(aResource) /]> resources = [javaClassNameForAdaptorManager(anAdaptorInterface) /].get[aResource.name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, page, limit);
if (resources!= null) {
httpServletRequest.setAttribute("resources", resources);
@@ -244,11 +243,11 @@ public class [javaClassName(aService) /]
uriInfo.getAbsolutePath().toString() + "?oslc.paging=true&amp;page=" + (page + 1));
}
- ServiceProvider serviceProvider = [javaClassNameForSingleton(containingServiceProviderCatalog(aService)) /].getServiceProvider(httpServletRequest, serviceProviderId);
+ ServiceProvider serviceProvider = [javaClassNameForSingleton(anAdaptorInterface.serviceProviderCatalog) /].getServiceProvider(httpServletRequest, serviceProviderId);
httpServletRequest.setAttribute("serviceProvider", serviceProvider);
- RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceCollectionJspRelativeFileName(coveredResource(aService), anAdaptorInterface) /]");
- [coveredResource(aService).generateResourceCollectionJsp(anAdaptorInterface) /]
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceCollectionJspRelativeFileName(aResource, anAdaptorInterface) /]");
+ [aResource.generateResourceCollectionJsp(anAdaptorInterface) /]
rd.forward(httpServletRequest,httpServletResponse);
}
@@ -271,22 +270,22 @@ public class [javaClassName(aService) /]
@GET
- @Path("{[coveredResource(aService).name.toLowerFirst() /]Id}")
+ @Path("{[aResource.name.toLowerFirst() /]Id}")
@Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
- public [javaClassName(coveredResource(aService)) /] get[coveredResource(aService).name.toUpperFirst() /](@PathParam("serviceProviderId") final String serviceProviderId,
- @PathParam("[coveredResource(aService).name.toLowerFirst() /]Id") final String [coveredResource(aService).name.toLowerFirst() /]Id) throws IOException, ServletException, URISyntaxException
+ public [javaClassName(aResource) /] get[aResource.name.toUpperFirst() /](@PathParam("serviceProviderId") final String serviceProviderId,
+ @PathParam("[aResource.name.toLowerFirst() /]Id") final String [aResource.name.toLowerFirst() /]Id) throws IOException, ServletException, URISyntaxException
{
// [protected ('(MUST_FILL_IN) getResource_init')]
// [/protected]
- final [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /] = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].get[coveredResource(aService).name.toUpperFirst() /](httpServletRequest, [coveredResource(aService).name.toLowerFirst() /]Id, serviceProviderId);
+ final [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /] = [javaClassNameForAdaptorManager(anAdaptorInterface) /].get[aResource.name.toUpperFirst() /](httpServletRequest, [aResource.name.toLowerFirst() /]Id, serviceProviderId);
- if (a[coveredResource(aService).name.toUpperFirst() /] != null) {
+ if (a[aResource.name.toUpperFirst() /] != null) {
// [protected ('(RECOMMENDED) getResource_body')]
// [/protected]
- return a[coveredResource(aService).name.toUpperFirst() /];
+ return a[aResource.name.toUpperFirst() /];
}
throw new WebApplicationException(Status.NOT_FOUND);
@@ -309,26 +308,26 @@ public class [javaClassName(aService) /]
@GET
- @Path("{[coveredResource(aService).name.toLowerFirst() /]Id}")
+ @Path("{[aResource.name.toLowerFirst() /]Id}")
@Produces({ MediaType.TEXT_HTML })
- public Response get[coveredResource(aService).name.toUpperFirst() /]AsHtml(@PathParam("serviceProviderId") final String serviceProviderId,
- @PathParam("[coveredResource(aService).name.toLowerFirst() /]Id") final String [coveredResource(aService).name.toLowerFirst() /]Id) throws ServletException, IOException, URISyntaxException
+ public Response get[aResource.name.toUpperFirst() /]AsHtml(@PathParam("serviceProviderId") final String serviceProviderId,
+ @PathParam("[aResource.name.toLowerFirst() /]Id") final String [aResource.name.toLowerFirst() /]Id) throws ServletException, IOException, URISyntaxException
{
// [protected ('(MUST_FILL_IN) getResourceAsHTML_init')]
// [/protected]
- final [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /] = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].get[coveredResource(aService).name.toUpperFirst() /](httpServletRequest, [coveredResource(aService).name.toLowerFirst() /]Id, serviceProviderId);
+ final [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /] = [javaClassNameForAdaptorManager(anAdaptorInterface) /].get[aResource.name.toUpperFirst() /](httpServletRequest, [aResource.name.toLowerFirst() /]Id, serviceProviderId);
- if (a[coveredResource(aService).name.toUpperFirst() /] != null) {
- httpServletRequest.setAttribute("a[coveredResource(aService).name.toUpperFirst() /]", a[coveredResource(aService).name.toUpperFirst() /]);
+ if (a[aResource.name.toUpperFirst() /] != null) {
+ httpServletRequest.setAttribute("a[aResource.name.toUpperFirst() /]", a[aResource.name.toUpperFirst() /]);
// [protected ('getResourceAsHTML_setAttributes')]
// [/protected]
- ServiceProvider serviceProvider = [javaClassNameForSingleton(containingServiceProviderCatalog(aService)) /].getServiceProvider(httpServletRequest, serviceProviderId);
+ ServiceProvider serviceProvider = [javaClassNameForSingleton(anAdaptorInterface.serviceProviderCatalog) /].getServiceProvider(httpServletRequest, serviceProviderId);
httpServletRequest.setAttribute("serviceProvider", serviceProvider);
- RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[getResourceJspRelativeFileName(coveredResource(aService), anAdaptorInterface) /]");
- [coveredResource(aService).generateGetResourceJsp(anAdaptorInterface) /]
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[getResourceJspRelativeFileName(aResource, anAdaptorInterface) /]");
+ [aResource.generateGetResourceJsp(anAdaptorInterface) /]
rd.forward(httpServletRequest,httpServletResponse);
@@ -357,14 +356,14 @@ public class [javaClassName(aService) /]
@GET
@Path("selector")
@Consumes({ MediaType.TEXT_HTML, MediaType.WILDCARD })
- public void [coveredResource(aService).name.toLowerFirst() /]Selector(@QueryParam("terms") final String terms,
+ public void [aResource.name.toLowerFirst() /]Selector(@QueryParam("terms") final String terms,
@PathParam("serviceProviderId") final String serviceProviderId) throws ServletException, IOException
{
try {
// [protected ('(MUST_FILL_IN) resourceSelector_init')]
// [/protected]
- ServiceProvider serviceProvider = [javaClassNameForSingleton(containingServiceProviderCatalog(aService)) /].getServiceProvider(httpServletRequest, serviceProviderId);
+ ServiceProvider serviceProvider = [javaClassNameForSingleton(anAdaptorInterface.serviceProviderCatalog) /].getServiceProvider(httpServletRequest, serviceProviderId);
httpServletRequest.setAttribute("serviceProvider", serviceProvider);
httpServletRequest.setAttribute("selectionUri",uriInfo.getAbsolutePath().toString());
// [protected ('(RECOMMENDED) resourceSelector_setAttributes')]
@@ -372,11 +371,11 @@ public class [javaClassName(aService) /]
if (terms != null ) {
httpServletRequest.setAttribute("terms", terms);
- final List<[javaClassName(coveredResource(aService)) /]> resources = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].search[coveredResource(aService).name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, terms);
+ final List<[javaClassName(aResource) /]> resources = [javaClassNameForAdaptorManager(anAdaptorInterface) /].search[aResource.name.toUpperFirst() /]s(httpServletRequest, serviceProviderId, terms);
if (resources!= null) {
httpServletRequest.setAttribute("resources", resources);
- RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[filteredResourceCollectionJspRelativeFileName(coveredResource(aService), anAdaptorInterface) /]");
- [coveredResource(aService).generateFilteredResourceCollectionJsp(anAdaptorInterface) /]
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[filteredResourceCollectionJspRelativeFileName(aResource, anAdaptorInterface) /]");
+ [aResource.generateFilteredResourceCollectionJsp(anAdaptorInterface) /]
rd.forward(httpServletRequest, httpServletResponse);
}
//a empty search should return an empty list and not NULL!
@@ -384,8 +383,8 @@ public class [javaClassName(aService) /]
} else {
try {
- RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceSelectorJspRelativeFileName(coveredResource(aService), anAdaptorInterface) /]");
- [coveredResource(aService).generateResourceSelectorJsp(anAdaptorInterface) /]
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceSelectorJspRelativeFileName(aResource, anAdaptorInterface) /]");
+ [aResource.generateResourceSelectorJsp(anAdaptorInterface) /]
rd.forward(httpServletRequest, httpServletResponse);
} catch (Exception e) {
@@ -412,16 +411,16 @@ public class [javaClassName(aService) /]
@GET
@Path("creator")
@Consumes({MediaType.WILDCARD})
- public void [coveredResource(aService).name.toLowerFirst() /]CreatorAsHtml(@PathParam("serviceProviderId") final String serviceProviderId) throws IOException, ServletException
+ public void [aResource.name.toLowerFirst() /]CreatorAsHtml(@PathParam("serviceProviderId") final String serviceProviderId) throws IOException, ServletException
{
// [protected ('(MUST_FILL_IN) resourceCreatorAsHTML_init')]
// [/protected]
- ServiceProvider serviceProvider = [javaClassNameForSingleton(containingServiceProviderCatalog(aService)) /].getServiceProvider(httpServletRequest, serviceProviderId);
+ ServiceProvider serviceProvider = [javaClassNameForSingleton(anAdaptorInterface.serviceProviderCatalog) /].getServiceProvider(httpServletRequest, serviceProviderId);
httpServletRequest.setAttribute("serviceProvider", serviceProvider);
- RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceCreatorJspRelativeFileName(coveredResource(aService), anAdaptorInterface) /]");
- [coveredResource(aService).generateResourceCreatorJsp(anAdaptorInterface) /]
+ RequestDispatcher rd = httpServletRequest.getRequestDispatcher("[resourceCreatorJspRelativeFileName(aResource, anAdaptorInterface) /]");
+ [aResource.generateResourceCreatorJsp(anAdaptorInterface) /]
rd.forward(httpServletRequest, httpServletResponse);
}
@@ -442,27 +441,27 @@ public class [javaClassName(aService) /]
@POST
@Path("creator")
@Consumes({ MediaType.APPLICATION_FORM_URLENCODED})
- public void create[coveredResource(aService).name.toUpperFirst() /](@PathParam("serviceProviderId") final String serviceProviderId)
+ public void create[aResource.name.toUpperFirst() /](@PathParam("serviceProviderId") final String serviceProviderId)
{
try {
- [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /] = new [javaClassName(coveredResource(aService)) /]();
+ [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /] = new [javaClassName(aResource) /]();
String['[]'/] paramValues;
[comment TODO: Check for valid parameters (1) that the oneOrMore, or oneOrMany are set. (2) things have right format. (3) Allow end_user to also add own checks
In the Resource class, automtiacally generate a "propertyValidValue" (similar to propertyAsHtmlForCreation) for each of the properties.
There you can add all automatic checks, as well as allow for end-user ones./]
- [for (aProperty: ResourceProperty | allProperties(coveredResource(aService)))]
+ [for (aProperty: ResourceProperty | allProperties(aResource))]
paramValues = httpServletRequest.getParameterValues("[aProperty.name /]");
if (paramValues != null) {
[if (Sequence{'zeroOrMany', 'oneOrMany'}->includes(aProperty.occurs.toString()))]
for(int i=0; i<paramValues.length; i++) {
- a[coveredResource(aService).name.toUpperFirst() /].add[aProperty.name.toUpperFirst() /]([javaAttributeBaseTypeCastFromString(aProperty, 'paramValues[i]') /]);
+ a[aResource.name.toUpperFirst() /].add[aProperty.name.toUpperFirst() /]([javaAttributeBaseTypeCastFromString(aProperty, 'paramValues[i]') /]);
}
[else]
if (paramValues.length == 1) {
if (paramValues['[0]'/].length() != 0)
- a[coveredResource(aService).name.toUpperFirst() /].set[javaAttributeName(aProperty, coveredResource(aService)).toUpperFirst() /]([javaAttributeBaseTypeCastFromString(aProperty, 'paramValues[0]') /]);
+ a[aResource.name.toUpperFirst() /].set[javaAttributeName(aProperty, aResource).toUpperFirst() /]([javaAttributeBaseTypeCastFromString(aProperty, 'paramValues[0]') /]);
// else, there is an empty value for that parameter, and hence ignore since the parameter is not actually set.
}
@@ -471,18 +470,18 @@ public class [javaClassName(aService) /]
[/for]
- final [javaClassName(coveredResource(aService)) /] new[coveredResource(aService).name.toUpperFirst() /] = [javaClassNameForAdaptorManager(containingAdaptorInterface(aService)) /].create[coveredResource(aService).name.toUpperFirst() /](httpServletRequest, a[coveredResource(aService).name.toUpperFirst() /], serviceProviderId);
+ final [javaClassName(aResource) /] new[aResource.name.toUpperFirst() /] = [javaClassNameForAdaptorManager(anAdaptorInterface) /].create[aResource.name.toUpperFirst() /](httpServletRequest, a[aResource.name.toUpperFirst() /], serviceProviderId);
- httpServletRequest.setAttribute("newResource", new[coveredResource(aService).name.toUpperFirst() /]);
- httpServletRequest.setAttribute("newResourceUri", new[coveredResource(aService).name.toUpperFirst() /].getAbout().toString());
+ httpServletRequest.setAttribute("newResource", new[aResource.name.toUpperFirst() /]);
+ httpServletRequest.setAttribute("newResourceUri", new[aResource.name.toUpperFirst() /].getAbout().toString());
// Send back to the form a small JSON response
httpServletResponse.setContentType("application/json");
httpServletResponse.setStatus(Status.CREATED.getStatusCode());
- httpServletResponse.addHeader("Location", new[coveredResource(aService).name.toUpperFirst() /].getAbout().toString());
+ httpServletResponse.addHeader("Location", new[aResource.name.toUpperFirst() /].getAbout().toString());
PrintWriter out = httpServletResponse.getWriter();
[comment TODO: What should be outputed as a result? Is this even necessary? /]
- out.print("{" + "\"resource\" : \"" + new[coveredResource(aService).name.toUpperFirst() /].getAbout().toString() + "\"}");
+ out.print("{" + "\"resource\" : \"" + new[aResource.name.toUpperFirst() /].getAbout().toString() + "\"}");
out.close();
} catch (Exception e) {
e.printStackTrace();
@@ -500,8 +499,10 @@ public class [javaClassName(aService) /]
* @throws ServletException
*/
- [for (aCreationDialog: Dialog | aService.creationDialogs)]
- @OslcDialog
+ @OslcDialogs(
+ {
+ [for (aCreationDialog: Dialog | creationDialogs(aResource, anAdaptorInterface)) separator(','.concat(lineSeparator()))]
+ @OslcDialog
(
title = "[aCreationDialog.title /]",
label = "[aCreationDialog.label /]",
@@ -509,27 +510,26 @@ public class [javaClassName(aService) /]
uri = "[aCreationDialog.dialogURI /]",
hintWidth = "[aCreationDialog.hintWidth /]px",
hintHeight = "[aCreationDialog.hintHeight /]px",
- resourceTypes = {[for (aResource: Resource | aCreationDialog.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourceTypeConstantName(aResource) /][/for]},
+ resourceTypes = {[for (aResource: Resource | aCreationDialog.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourceTypeConstantName(aResource) /][/for]},
usages = {OslcConstants.OSLC_USAGE_DEFAULT}
)
+ [/for]
+ })
+ [for (aCreationFactory: CreationFactory | creationFactories(aResource, anAdaptorInterface))]
+ @OslcCreationFactory
+ (
+ title = "[aCreationFactory.title /]",
+ label = "[aCreationFactory.label /]",
+ resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + [javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourcePathConstantName(aResource) /]},
+ resourceTypes = {[for (aResource: Resource | aCreationFactory.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(anAdaptorInterface) /].[resourceTypeConstantName(aResource) /][/for]},
+ usages = {OslcConstants.OSLC_USAGE_DEFAULT}
+ )
[/for]
-
- [for (aCreationFactory: CreationFactory | aService.creationFactories)]
- @OslcCreationFactory
- (
- title = "[aCreationFactory.title /]",
- label = "[aCreationFactory.label /]",
- resourceShapes = {OslcConstants.PATH_RESOURCE_SHAPES + "/" + [javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourcePathConstantName(coveredResource(aService)) /]},
- resourceTypes = {[for (aResource: Resource | aCreationFactory.resourceTypes) separator(', ') ][javaInterfaceNameForAdaptorConstants(containingAdaptorInterface(aService)) /].[resourceTypeConstantName(aResource) /][/for]},
- usages = {OslcConstants.OSLC_USAGE_DEFAULT}
- )
- [/for]
-
@POST
@Consumes({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
@Produces({OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_XML, OslcMediaType.APPLICATION_JSON})
public Response addChangeRequest(@PathParam("productId") final String productId,
- final [javaClassName(coveredResource(aService)) /] a[coveredResource(aService).name.toUpperFirst() /]) throws IOException, ServletException
+ final [javaClassName(aResource) /] a[aResource.name.toUpperFirst() /]) throws IOException, ServletException
{
return null; // See LAB 5 of the Lyo workshop for implementation
}
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/main/generate.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/main/generate.mtl
index 946ce81..c77139c 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/main/generate.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/main/generate.mtl
@@ -39,7 +39,7 @@
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateServiceProviderService/]
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateServiceProviderInfo/]
[import org::eclipse::lyo::oslc4j::codegenerator::files::generateResource/]
-[import org::eclipse::lyo::oslc4j::codegenerator::files::generateService/]
+[import org::eclipse::lyo::oslc4j::codegenerator::files::generateResourceService/]
[import org::eclipse::lyo::oslc4j::codegenerator::staticFiles::generateLicenseFiles/]
[template public generate(anAdaptorInterface : AdaptorInterface)]
@@ -65,15 +65,13 @@
[aResource.generateResource(anAdaptorInterface) /]
[/for]
+[for (aResource: Resource | servicedResources(anAdaptorInterface))]
+ [aResource.generateResourceService(anAdaptorInterface) /]
+[/for]
+
[for (aServiceProvider: ServiceProvider | anAdaptorInterface.serviceProviderCatalog.serviceProviders)]
[aServiceProvider.generateServiceProviderService(anAdaptorInterface)/]
[aServiceProvider.generateServiceProviderHTML(anAdaptorInterface) /]
- [for (aService: Service | aServiceProvider.services)]
- [aService.generateService(anAdaptorInterface)/]
- [/for]
-
[/for]
-
-
[/template]
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl
index 7eaf447..e0c8fc1 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl
@@ -32,6 +32,12 @@ You should also question any other use of "eContainer" in this whole project /]
obj.eContainer(AdaptorInterface)
/]
+[query public servicedResources(anAdaptorInterface : AdaptorInterface) : Set(Resource) =
+anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->collectNested(aService : Service |
+ managedResources(aService)
+)->flatten()->asSet()
+/]
+
[query public relevantResources(anAdaptorInterface : AdaptorInterface) : Set(Resource) =
anAdaptorInterface.serviceProviderCatalog.serviceProviders.services->collectNested(aService : Service |
managedResources(aService)
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/resourceServices.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/resourceServices.mtl
index c9b934f..d42f9ed 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/resourceServices.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/resourceServices.mtl
@@ -23,6 +23,22 @@
[import org::eclipse::lyo::oslc4j::codegenerator::services::services/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::domainSpecificationServices/]
+[query public queryCapabilities(aResource: Resource, anAdaptorInterface : AdaptorInterface) : Set(QueryCapability) =
+anAdaptorInterface.serviceProviderCatalog.serviceProviders.services.queryCapabilities->select(aQueryCapability : QueryCapability | aQueryCapability.resourceTypes->includes(aResource))->asSet()
+/]
+
+[query public creationFactories(aResource: Resource, anAdaptorInterface : AdaptorInterface) : Set(CreationFactory) =
+anAdaptorInterface.serviceProviderCatalog.serviceProviders.services.creationFactories->select(aCreationFactory : CreationFactory | aCreationFactory.resourceTypes->includes(aResource))->asSet()
+/]
+
+[query public selectionDialogs(aResource: Resource, anAdaptorInterface : AdaptorInterface) : Set(Dialog) =
+anAdaptorInterface.serviceProviderCatalog.serviceProviders.services.selectionDialogs->select(aDialog : Dialog | aDialog.resourceTypes->includes(aResource))->asSet()
+/]
+
+[query public creationDialogs(aResource: Resource, anAdaptorInterface : AdaptorInterface) : Set(Dialog) =
+anAdaptorInterface.serviceProviderCatalog.serviceProviders.services.creationDialogs->select(aDialog : Dialog | aDialog.resourceTypes->includes(aResource))->asSet()
+/]
+
[query public allProperties(aResource: Resource) : Set(ResourceProperty) =
aResource.resourceProperties->union(inheritedProperties(aResource))
/]
@@ -50,7 +66,7 @@ javaClassBaseNamespace(anAdaptorInterface).concat('.resources')
/]
[query public javaClassName(aResource: Resource) : String =
-aResource.name.toUpperFirst()
+aResource.name.substituteAll(' ', '').toUpperFirst()
/]
[query public javaClassFullName(aResource: Resource, anAdaptorInterface : AdaptorInterface) : String =
@@ -61,6 +77,22 @@ javaClassPackageName(aResource, anAdaptorInterface).concat('.').concat(javaClass
javaFilesBasePath(anAdaptorInterface).concat(javaClassPackageName(aResource, anAdaptorInterface).substituteAll('.', '/')).concat('/').concat(javaClassName(aResource)).concat('.java')
/]
+[query public javaClassPackageNameForService(aResource: Resource, anAdaptorInterface : AdaptorInterface) : String =
+javaClassBaseNamespace(anAdaptorInterface).concat('.services')
+/]
+
+[query public javaClassNameForService(aResource: Resource, anAdaptorInterface : AdaptorInterface) : String =
+aResource.name.substituteAll(' ', '').toUpperFirst().concat('Service')
+/]
+
+[query public javaClassFullNameForService(aResource: Resource, anAdaptorInterface : AdaptorInterface) : String =
+javaClassPackageNameForService(aResource, anAdaptorInterface).concat('.').concat(javaClassNameForService(aResource, anAdaptorInterface))
+/]
+
+[query public javaClassFullFileNameForService(aResource: Resource, anAdaptorInterface : AdaptorInterface) : String =
+javaFilesBasePath(anAdaptorInterface).concat(javaClassPackageNameForService(aResource, anAdaptorInterface).substituteAll('.', '/')).concat('/').concat(javaClassNameForService(aResource, anAdaptorInterface)).concat('.java')
+/]
+
[template public parentJavaClassName(aResource: Resource)]
[if (aResource.extends.oclIsUndefined())]AbstractResource[else][javaClassName(aResource.extends) /][/if]
diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/serviceServices.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/serviceServices.mtl
index 9640842..25d9199 100644
--- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/serviceServices.mtl
+++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/serviceServices.mtl
@@ -35,25 +35,4 @@ aService.creationFactories.resourceTypes->asSet()
->union(aService.selectionDialogs.resourceTypes->asSet())
/]
-[comment TODO: this service code-generation assumes that all ResourceTypes of all factories/queries/dialogs in the same are the same, and there is a single resourceType.
-Change, so that a service class is generated for each resourceType value specified. Of course, Only factories/queries/dialogs that specify that particular resourceType get generated./]
-[query public coveredResource(aService: Service) : Resource =
-managedResources(aService)->any(true)
-/]
-
-[query public javaClassPackageName(aService : Service) : String =
-javaClassBaseNamespace(containingAdaptorInterface(aService)).concat('.services')
-/]
-
-[query public javaClassName(aService : Service) : String =
-coveredResource(aService).name.toUpperFirst().concat('Service')
-/]
-
-[query public javaClassFullName(aService : Service) : String =
-javaClassPackageName(aService).concat('.').concat(javaClassName(aService))
-/]
-
-[query public javaClassFullFileName(aService : Service) : String =
-javaFilesBasePath(containingAdaptorInterface(aService)).concat(javaClassPackageName(aService).substituteAll('.', '/')).concat('/').concat(javaClassName(aService)).concat('.java')
-/]