Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce LF line endings for Acceleo MTL templates
*.mtl text eol=lf
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
java = "temurin-17"
maven = "3.9.6"
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,17 @@ endif)
<!-- General dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>runtime</scope>
<artifactId>slf4j-api</artifactId>
</dependency>
[/template]

[template private servletDependencies(traceabilityContext : OclAny) post (trim())]
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Servlet dependencies -->
<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/]
[module generateDomainSpecificationConstants('http://org.eclipse.lyo/oslc4j/adaptorInterface', 'http://org.eclipse.lyo/oslc4j/vocabulary')]
Expand All @@ -24,10 +24,17 @@
[import org::eclipse::lyo::oslc4j::codegenerator::services::vocabularyServices/]

[template public generateResourceConstants(aResource : Resource)]
public static String [resourcePathConstantName(aResource)/] = "[javaString(aResource.name, '', false)/]"; //the relative path of the resource shape URL.
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
// the relative path of the resource shape URL.
public static String [resourcePathConstantName(aResource)/] = "[javaString(aResource.name, '', false)/]";

// namespace of the rdfs:class the resource describes
public static String [resourceTypeNamespaceConstantName(aResource)/] = [resourceTypeNamespace(aResource)/];

// localName of the rdfs:class the resource describes
public static String [resourceTypeLocalNameConstantName(aResource)/] = [resourceTypeLocalName(aResource)/];

// fullname of the rdfs:class the resource describes
public static String [resourceTypeConstantName(aResource)/] = [resourceTypeNamespaceConstantName(aResource)/] + [resourceTypeLocalNameConstantName(aResource)/];
[/template]

[template public generateDomainSpecificationConstants(aDomainSpecification: DomainSpecification, anAdaptorInterface : AdaptorInterface, defaultJavaFilesPath : String, defaultJavaClassPackageName : String)]
Expand All @@ -41,10 +48,11 @@ public static String [resourceTypeConstantName(aResource)/] = [resourceTypeNames
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
* This file is generated by Lyo Designer (https://www.eclipse.org/lyo/)
*/
Expand All @@ -71,8 +79,12 @@ public interface [javaInterfaceNameForConstants(aDomainSpecification) /]
@Deprecated(since = "5.0.1")
public static String [domainSpecificationDeprecatedConstantName(aDomainSpecification)/] = "[domainSpecificationImplicitVocabularyNamespaceValue(aDomainSpecification)/]";
public static String [domainSpecificationConstantName(aDomainSpecification)/] = "[aDomainSpecification.name/]";
public static String [domainSpecificationImplicitVocabularyNamespaceConstantName(aDomainSpecification)/] = "[domainSpecificationImplicitVocabularyNamespaceValue(aDomainSpecification)/]"; //Vocabulary namespace for the resources and resource properties, when no explicit vocabulary (describes, or propertyDefinition) is defined
public static String [domainSpecificationImplicitVocabularyNamespacePrefixConstantName(aDomainSpecification)/] = "[domainSpecificationImplicitVocabularyNamespacePrefixValue(aDomainSpecification)/]"; //Vocabulary prefix for the resources and resource properties, when no explicit vocabulary (describes, or propertyDefinition) is defined

//Vocabulary namespace for the resources and resource properties, when no explicit vocabulary (describes, or propertyDefinition) is defined
public static String [domainSpecificationImplicitVocabularyNamespaceConstantName(aDomainSpecification)/] = "[domainSpecificationImplicitVocabularyNamespaceValue(aDomainSpecification)/]";

//Vocabulary prefix for the resources and resource properties, when no explicit vocabulary (describes, or propertyDefinition) is defined
public static String [domainSpecificationImplicitVocabularyNamespacePrefixConstantName(aDomainSpecification)/] = "[domainSpecificationImplicitVocabularyNamespacePrefixValue(aDomainSpecification)/]";

[for (aResource: Resource | aDomainSpecification.resources->sortedBy(name))]
[generateResourceConstants(aResource) /]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
* This file is generated by Lyo Designer (https://www.eclipse.org/lyo/)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
* This file is generated by Lyo Designer (https://www.eclipse.org/lyo/)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/]
[module generateVocabularyConstants('http://org.eclipse.lyo/oslc4j/adaptorInterface', 'http://org.eclipse.lyo/oslc4j/vocabulary')]
Expand All @@ -23,25 +23,37 @@
[import org::eclipse::lyo::oslc4j::codegenerator::services::vocabularyServices/]

[template public generateClassConstants(aClass : Class)]
public static String [classConstantName(aClass)/] = "[aClass.javaName(true)/]";
public static String [classTypeConstantName(aClass)/] = [vocabularyNamespaceConstantName(aClass.definingVocabulary())/] + [classConstantName(aClass)/];
public static final String [classLocalNameConstantName(aClass)/] = "[aClass.javaName(true)/]";
[if (aClass.comment = 'archaic')]
/**
* @deprecated RDF model attribute is marked 'archaic'
*/
@Deprecated
[/if]
[if ((not aClass.comment.oclIsUndefined()) and aClass.comment <> 'archaic')]
/**
* [aClass.comment/]
*/
[/if]
public static final String [classConstantName(aClass)/] = NS + [classLocalNameConstantName(aClass)/];
[/template]

[template public generateVocabularyConstants(aVocabulary: Vocabulary, anAdaptorInterface : AdaptorInterface, defaultJavaFilesPath : String, defaultJavaClassPackageName : String)]
[if (not aVocabulary.doNotGenerate())]
[file (javaInterfaceFullFileNameForConstants(aVocabulary, anAdaptorInterface, defaultJavaFilesPath, defaultJavaClassPackageName), false, 'UTF-8')]
// [protected ('Copyright')]
/*
* Copyright (c) 2020 Contributors to the Eclipse Foundation
* Copyright (c) 2025 Contributors to the Eclipse Foundation
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026 :D

*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License 1.0
* which is available at http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Simple
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*
* This file is generated by Lyo Designer (https://www.eclipse.org/lyo/)
*/
Expand All @@ -51,22 +63,77 @@ package [javaInterfacePackageNameForConstants(aVocabulary, anAdaptorInterface, d

// spotless:off
import org.eclipse.lyo.oslc4j.core.model.OslcConstants;
import javax.xml.namespace.QName;
import java.util.concurrent.ConcurrentHashMap;

// [protected ('imports')]
// [/protected]
// spotless:on

public interface [javaInterfaceNameForConstants(aVocabulary) /]
public class [javaInterfaceNameForConstants(aVocabulary) /]
{
// [protected ('user constants')]
// [/protected]

public static String [vocabularyNamespaceConstantName(aVocabulary)/] = "[aVocabulary.namespaceURI/]";
public static String [vocabularyPreferredNamespacePrefixConstantName(aVocabulary)/] = "[aVocabulary.preferredNamespacePrefix/]";
private static final ConcurrentHashMap<String, QName> CACHE = new ConcurrentHashMap<>();

/**
* @deprecated Use {@link #NS} instead.
*/
@Deprecated
public static final String [vocabularyNamespaceConstantName(aVocabulary)/] = "[aVocabulary.namespaceURI/]";

/**
* @deprecated Use {@link #PREFIX} instead.
*/
@Deprecated
public static final String [vocabularyPreferredNamespacePrefixConstantName(aVocabulary)/] = "[aVocabulary.preferredNamespacePrefix/]";

public static final String NS = "[aVocabulary.namespaceURI/]";
public static final String PREFIX = "[aVocabulary.preferredNamespacePrefix/]";

// static class
private [javaInterfaceNameForConstants(aVocabulary) /]() {}

public static QName of(String local) { return get(local); }

[for (aClass: Class | aVocabulary.classes->sortedBy(name))]
[generateClassConstants(aClass) /]
[/for]

[for (aProperty: Property | aVocabulary.properties->sortedBy(name))]
[if (aProperty.comment = 'archaic')]
/**
* @deprecated RDF model attribute is marked 'archaic'
*/
@Deprecated
[/if]
[if ((not aProperty.comment.oclIsUndefined()) and aProperty.comment <> 'archaic')]
/**
* [aProperty.comment/]
*/
[/if]
public static final String [propertyConstantName(aProperty)/] = NS + "[aProperty.name/]";
[/for]

[for (aProperty: Property | aVocabulary.properties->sortedBy(name))]
[if (aProperty.comment = 'archaic')]
/**
* @deprecated RDF model attribute is marked 'archaic'
*/
@Deprecated
[/if]
[if ((not aProperty.comment.oclIsUndefined()) and aProperty.comment <> 'archaic')]
/**
* [aProperty.comment/]
*/
[/if]
public static QName [aProperty.javaName(false)/]() { return get("[aProperty.name/]"); }
[/for]

private static QName get(String local) {
return CACHE.computeIfAbsent(local, l -> new QName(NS, l, PREFIX));
}
}
[/file]
[/if]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ endif)
(if (aResource.describes.oclIsUndefined()) then
javaInterfaceNameForConstants(aResource.definingDomainSpecification()).concat('.').concat(domainSpecificationImplicitVocabularyNamespaceConstantName(aResource.definingDomainSpecification()))
else
javaInterfaceNameForConstants(aResource.describes.definingVocabulary()).concat('.').concat(vocabularyNamespaceConstantName(aResource.describes.definingVocabulary()))
javaInterfaceNameForConstants(aResource.describes.definingVocabulary()).concat('.').concat('NS')
endif)
/]

Expand All @@ -548,7 +548,7 @@ endif)
(if (aResource.describes.oclIsUndefined()) then
'"'.concat(aResource.name).concat('"')
else
javaInterfaceNameForConstants(aResource.describes.definingVocabulary()).concat('.').concat(classConstantName(aResource.describes))
javaInterfaceNameForConstants(aResource.describes.definingVocabulary()).concat('.').concat(classLocalNameConstantName(aResource.describes))
endif)
/]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ not (Sequence{'URI'}->includes(aProperty.valueType.toString()))
(if (aResourceProperty.propertyDefinition.oclIsUndefined()) then
javaInterfaceNameForConstants(aResourceProperty.definingDomainSpecification()).concat('.').concat(domainSpecificationImplicitVocabularyNamespaceConstantName(aResourceProperty.definingDomainSpecification()))
else
javaInterfaceNameForConstants(aResourceProperty.propertyDefinition.definingVocabulary()).concat('.').concat(vocabularyNamespaceConstantName(aResourceProperty.propertyDefinition.definingVocabulary()))
javaInterfaceNameForConstants(aResourceProperty.propertyDefinition.definingVocabulary()).concat('.').concat('NS')
endif)
/]

Expand Down Expand Up @@ -228,7 +228,7 @@ Sequence{'zeroOrMany', 'oneOrMany'}->includes(aProperty.occurs.toString())
'new URI(' + variable + ')'
else
if(aProperty.valueType.toString() = 'Boolean') then
'new Boolean(' + variable + ')'
'Boolean.valueOf(' + variable + ')'
else
if(aProperty.valueType.toString() = 'Double') then
'Double.valueOf(' + variable + ')'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,20 @@ javaConstantName(aVocabulary).concat('_NAMSPACE')
javaConstantName(aVocabulary).concat('_NAMSPACE_PREFIX')
/]

[query public classLocalNameConstantName(aClass : Class) : String =
aClass.javaName(true).toUpperCase().concat('_LOCAL_NAME')
/]

[query public classConstantName(aClass : Class) : String =
aClass.javaName(true).toUpperCase()
aClass.javaName(true).toUpperCase().concat('_CLASS')
/]

[query public propertyConstantName(aProperty : Property) : String =
aProperty.javaName(true).toUpperCase().concat('_PROP')
/]

[query public classTypeConstantName(aClass : Class) : String =
'TYPE_'.concat(aClass.javaName(true).toUpperCase())
[query public propertyNameConstantName(aProperty : Property) : String =
aProperty.javaName(true).toUpperCase()
/]