blob: ee52fb0f6031312444f27be616d4f380c4a2b8c9 [file] [log] [blame]
[comment encoding = UTF-8 /]
[comment
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
*
* Russell Boykin - initial API and implementation
* Alberto Giammaria - initial API and implementation
* Chris Peters - initial API and implementation
* Gianluca Bernardini - initial API and implementation
* Michael Fiedler - Bugzilla adpater implementations
* Jad El-khoury - initial implementation of code generator (https://bugs.eclipse.org/bugs/show_bug.cgi?id=422448)
*******************************************************************************/
/]
[module generateDomainSpecificationConstants('http://org.eclipse.lyo/oslc4j/adaptorInterface', 'http://org.eclipse.lyo/oslc4j/vocabulary')]
[import org::eclipse::lyo::oslc4j::codegenerator::services::services/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::serviceServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::resourceServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::adaptorInterfaceServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::domainSpecificationServices/]
[import org::eclipse::lyo::oslc4j::codegenerator::services::vocabularyServices/]
[query public resourceTypeNamespace(aResource: Resource) : String =
(if (aResource.describes.oclIsUndefined()) then
domainSpecificationNamespaceConstantName(aResource.definingDomainSpecification())
else
javaInterfaceNameForConstants(aResource.describes.definingVocabulary()).concat('.').concat(vocabularyNamespaceConstantName(aResource.describes.definingVocabulary()))
endif)
/]
[query public resourceTypeLocalName(aResource: Resource) : String =
(if (aResource.describes.oclIsUndefined()) then
'"'.concat(aResource.javaName(true)).concat('"')
else
'"'.concat(aResource.describes.javaName(true)).concat('"')
endif)
/]
[template public generateResourceConstants(aResource : Resource)]
public static String [resourcePathConstantName(aResource)/] = "[aResource.javaName(false)/]";
public static String [resourceTypeNamespaceConstantName(aResource)/] = [resourceTypeNamespace(aResource)/]; //namespace of the rdfs:class the resource describes
public static String [resourceTypeLocalNameConstantName(aResource)/] = [resourceTypeLocalName(aResource)/]; //localName of the rdfs:class the resource describes
public static String [resourceTypeConstantName(aResource)/] = [resourceTypeNamespaceConstantName(aResource)/] + [resourceTypeLocalNameConstantName(aResource)/]; //fullname of the rdfs:class the resource describes
[/template]
[template public generateDomainSpecificationConstants(aDomainSpecification: DomainSpecification, anAdaptorInterface : AdaptorInterface, defaultJavaFilesPath : String, defaultJavaClassPackageName : String)]
[file (javaInterfaceFullFileNameForConstants(aDomainSpecification, anAdaptorInterface, defaultJavaFilesPath, defaultJavaClassPackageName), false, 'UTF-8')]
// [protected ('Copyright')]
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
*
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
*
* Russell Boykin - initial API and implementation
* Alberto Giammaria - initial API and implementation
* Chris Peters - initial API and implementation
* Gianluca Bernardini - initial API and implementation
* Michael Fiedler - Bugzilla adpater implementations
* Jad El-khoury - initial implementation of code generator (https://bugs.eclipse.org/bugs/show_bug.cgi?id=422448)
*
* This file is generated by org.eclipse.lyo.oslc4j.codegenerator
*******************************************************************************/
// [/protected]
package [javaInterfacePackageNameForConstants(aDomainSpecification, anAdaptorInterface, defaultJavaClassPackageName) /];
import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
[for (aVocabulary: Vocabulary | relevantVocabularies(aDomainSpecification)->sortedBy(label)) separator(lineSeparator())]import [javaInterfaceFullNameForConstants(aVocabulary, anAdaptorInterface, defaultJavaClassPackageName) /];[/for]
// [protected ('imports')]
// [/protected]
public interface [javaInterfaceNameForConstants(aDomainSpecification) /]
{
// [protected ('user constants')]
// [/protected]
public static String [domainSpecificationConstantName(aDomainSpecification)/] = "[aDomainSpecification.namespaceURI/]";
public static String [domainSpecificationNamespaceConstantName(aDomainSpecification)/] = "[aDomainSpecification.namespaceURI/]";
public static String [domainSpecificationNamespacePrefixConstantName(aDomainSpecification)/] = "[aDomainSpecification.namespacePrefix.name/]";
[for (aResource: Resource | aDomainSpecification.resources->sortedBy(name))]
[generateResourceConstants(aResource) /]
[/for]
}
[/file]
[/template]