Skip to content

Commit eba51b9

Browse files
committed
Merge branch 'main' into extend-aspect-to-aas-output-file-path-description
2 parents 8686d5d + 6af618f commit eba51b9

File tree

47 files changed

+876
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+876
-179
lines changed

core/esmf-aspect-meta-model-interface/src/main/java/org/eclipse/esmf/metamodel/vocabulary/RdfNamespace.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static Map<String, String> createPrefixMap( final KnownVersion metaModelVersion
5656
result.put( samm.getShortForm(), samm.getNamespace() );
5757
final SAMMC sammc = new SAMMC( metaModelVersion );
5858
result.put( sammc.getShortForm(), sammc.getNamespace() );
59-
result.put( "samm-e", new SAMME( metaModelVersion, samm ).getNamespace() );
59+
final SAMME samme = new SAMME( metaModelVersion, samm );
60+
result.put( samme.getShortForm(), samme.getNamespace() );
6061
final UNIT unit = new UNIT( metaModelVersion, samm );
6162
result.put( unit.getShortForm(), unit.getNamespace() );
6263
result.put( "rdf", RDF.getURI() );

core/esmf-aspect-meta-model-interface/src/main/java/org/eclipse/esmf/metamodel/vocabulary/SammNs.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package org.eclipse.esmf.metamodel.vocabulary;
1515

16+
import java.util.stream.Stream;
17+
1618
import org.eclipse.esmf.samm.KnownVersion;
1719

1820
/**
@@ -23,4 +25,13 @@ public class SammNs {
2325
public static final SAMMC SAMMC = new SAMMC( KnownVersion.getLatest() );
2426
public static final SAMME SAMME = new SAMME( KnownVersion.getLatest(), SAMM );
2527
public static final UNIT UNIT = new UNIT( KnownVersion.getLatest(), SAMM );
28+
29+
/**
30+
* All SAMM-specific metamodel RDF namespaces
31+
*
32+
* @return the namespaces
33+
*/
34+
public static Stream<RdfNamespace> sammNamespaces() {
35+
return Stream.of( SAMM, SAMMC, SAMME, UNIT );
36+
}
2637
}

core/esmf-aspect-meta-model-java/pom.xml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
<name>ESMF Aspect Meta Model Java</name>
2929
<packaging>jar</packaging>
3030

31+
<properties>
32+
<!-- Necessary so that properties-maven-plugin writes it into app.properties -->
33+
<project-version>${project.version}</project-version>
34+
</properties>
35+
3136
<dependencies>
3237
<dependency>
3338
<groupId>org.eclipse.esmf</groupId>
@@ -79,12 +84,30 @@
7984

8085
<build>
8186
<plugins>
87+
<plugin>
88+
<groupId>org.codehaus.mojo</groupId>
89+
<artifactId>properties-maven-plugin</artifactId>
90+
<executions>
91+
<execution>
92+
<phase>initialize</phase>
93+
<goals>
94+
<goal>write-project-properties</goal>
95+
</goals>
96+
<configuration>
97+
<outputFile>
98+
${project.build.outputDirectory}/app.properties
99+
</outputFile>
100+
</configuration>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
82105
<plugin>
83106
<groupId>org.codehaus.mojo</groupId>
84107
<artifactId>build-helper-maven-plugin</artifactId>
85108
<executions>
86109
<execution>
87-
<id>add-shared-test-source</id>
110+
<id>add-shared-test-sources</id>
88111
<phase>initialize</phase>
89112
<goals>
90113
<goal>add-test-source</goal>
@@ -96,7 +119,7 @@
96119
</configuration>
97120
</execution>
98121
<execution>
99-
<id>add-source</id>
122+
<id>add-generated-sources</id>
100123
<phase>initialize</phase>
101124
<goals>
102125
<goal>add-source</goal>
@@ -108,7 +131,7 @@
108131
</configuration>
109132
</execution>
110133
<execution>
111-
<id>add-src-buildtime-source</id>
134+
<id>add-buildtime-sources</id>
112135
<phase>initialize</phase>
113136
<goals>
114137
<goal>add-source</goal>

core/esmf-aspect-meta-model-java/src-buildtime/main/java/org/eclipse/esmf/buildtime/GenerateBuildtimeCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public static void main( final String[] args ) {
3131

3232
Stream.of(
3333
new GenerateUnits( srcBuildtimePath, srcGenPath ),
34-
new GenerateQuantityKinds( srcBuildtimePath, srcGenPath )
34+
new GenerateQuantityKinds( srcBuildtimePath, srcGenPath ),
35+
new GenerateVersionInfo( srcBuildtimePath, srcGenPath )
3536
).forEach( BuildtimeCodeGenerator::writeGeneratedFile );
3637
}
3738
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
3+
*
4+
* See the AUTHORS file(s) distributed with this work for additional
5+
* information regarding authorship.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
*
11+
* SPDX-License-Identifier: MPL-2.0
12+
*/
13+
14+
package org.eclipse.esmf.buildtime;
15+
16+
import java.io.InputStream;
17+
import java.nio.file.Path;
18+
import java.util.Properties;
19+
20+
/**
21+
* Generates the static version info class
22+
*/
23+
public class GenerateVersionInfo extends BuildtimeCodeGenerator {
24+
private final Properties properties;
25+
26+
protected GenerateVersionInfo( final Path srcBuildTimePath, final Path srcGenPath ) {
27+
super( srcBuildTimePath, srcGenPath, "VersionInfo", "org.eclipse.esmf.aspectmodel" );
28+
29+
try ( final InputStream stream = GenerateVersionInfo.class.getClassLoader().getResourceAsStream( "app.properties" ) ) {
30+
if ( stream == null ) {
31+
throw new RuntimeException();
32+
}
33+
properties = new Properties();
34+
properties.load( stream );
35+
} catch ( final Exception exception ) {
36+
throw new RuntimeException( "Could not load app.properties" );
37+
}
38+
}
39+
40+
@Override
41+
protected String interpolateVariable( final String variableName ) {
42+
return switch ( variableName ) {
43+
case "esmfSdkVersion" -> properties.getProperty( "project-version" );
44+
case "aspectMetaModelVersion" -> properties.getProperty( "aspect-meta-model-version" );
45+
case "generator" -> getClass().getCanonicalName();
46+
default -> throw new RuntimeException( "Unexpected variable in template: " + variableName );
47+
};
48+
}
49+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2025 Robert Bosch Manufacturing Solutions GmbH
3+
*
4+
* See the AUTHORS file(s) distributed with this work for additional
5+
* information regarding authorship.
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
10+
*
11+
* SPDX-License-Identifier: MPL-2.0
12+
*/
13+
14+
package org.eclipse.esmf.buildtime.template;
15+
16+
import javax.annotation.processing.Generated;
17+
18+
@Generated( "${generator}" )
19+
public class VersionInfo {
20+
public static final String ESMF_SDK_VERSION = "${esmfSdkVersion}";
21+
public static final String ASPECT_META_MODEL_VERSION = "${aspectMetaModelVersion}";
22+
}

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/edit/AspectChangeManager.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.slf4j.LoggerFactory;
4040

4141
/**
42-
* The AspectChangeManager is the central place to to changes/edits/refactorings of an {@link AspectModel}. The AspectChangeManager
42+
* The AspectChangeManager is the central place to perform changes/edits/refactorings of an {@link AspectModel}. The AspectChangeManager
4343
* wraps an AspectModel and allows applying instances of the {@link Change} class using the {@link #applyChange(Change)} method.
4444
* Calling this method returns a {@link ChangeReport} that describes the performed changes in a structured way. Use the
4545
* {@link ChangeReportFormatter} to render the ChangeReport to a structured string representation.
@@ -67,6 +67,12 @@ private enum FileState {
6767
CREATED, CHANGED, REMOVED
6868
}
6969

70+
/**
71+
* Apply the change manager using an explicit configuration and the target Aspect Model to perform changes on
72+
*
73+
* @param config the configuration
74+
* @param aspectModel the target Aspect Model
75+
*/
7076
public AspectChangeManager( final AspectChangeManagerConfig config, final AspectModel aspectModel ) {
7177
this.config = config;
7278
resetFileStates();
@@ -77,10 +83,31 @@ public AspectChangeManager( final AspectChangeManagerConfig config, final Aspect
7783
}
7884
}
7985

86+
/**
87+
* Apply the change manager to a given target Aspect Model, using the default configuration
88+
*
89+
* @param aspectModel the target Aspect Model
90+
*/
8091
public AspectChangeManager( final AspectModel aspectModel ) {
8192
this( AspectChangeManagerConfigBuilder.builder().build(), aspectModel );
8293
}
8394

95+
/**
96+
* Apply the change manager to a new, empty Aspect Model using the given configuration
97+
*
98+
* @param config the configuration
99+
*/
100+
public AspectChangeManager( final AspectChangeManagerConfig config ) {
101+
this( config, new AspectModelLoader().emptyModel() );
102+
}
103+
104+
/**
105+
* Apply the change manager to a new, empty Aspect Model using the default configuration
106+
*/
107+
public AspectChangeManager() {
108+
this( AspectChangeManagerConfigBuilder.builder().build() );
109+
}
110+
84111
public synchronized ChangeReport applyChange( final Change change ) {
85112
resetFileStates();
86113
final ChangeReport result = change.fire( this );

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/edit/ChangeGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.List;
1919

2020
/**
21-
* A Change that groups other changes
21+
* A {@link Change} that groups other changes
2222
*/
2323
public class ChangeGroup implements Change {
2424
private final String summary;

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/DefaultPropertyWrapper.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
import org.eclipse.esmf.metamodel.impl.DefaultProperty;
2222

2323
public class DefaultPropertyWrapper extends DefaultProperty {
24-
private DefaultProperty property;
24+
private Property property;
25+
private String payloadName;
2526

26-
public DefaultPropertyWrapper( MetaModelBaseAttributes metaModelBaseAttributes ) {
27+
public DefaultPropertyWrapper( final MetaModelBaseAttributes metaModelBaseAttributes ) {
2728
super( metaModelBaseAttributes, null, null, false, false, null, false, null );
2829
}
2930

3031
@Override
3132
public String getPayloadName() {
32-
return property.getPayloadName();
33+
return payloadName != null ? payloadName : property.getPayloadName();
3334
}
3435

3536
@Override
@@ -75,7 +76,11 @@ public int hashCode() {
7576
return property.hashCode();
7677
}
7778

78-
public void setProperty( DefaultProperty property ) {
79+
public void setProperty( final Property property ) {
7980
this.property = property;
8081
}
82+
83+
public void setPayloadName( String payloadName ) {
84+
this.payloadName = payloadName;
85+
}
8186
}

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/MetaModelBaseAttributes.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ public static class Builder {
127127
private boolean isAnonymous = true;
128128
private AspectModelFile sourceFile;
129129

130+
public Builder fromModelElement( final ModelElement modelElement ) {
131+
if ( !modelElement.isAnonymous() ) {
132+
withUrn( modelElement.urn() );
133+
}
134+
isAnonymous( modelElement.isAnonymous() );
135+
withPreferredNames( modelElement.getPreferredNames() );
136+
withDescriptions( modelElement.getDescriptions() );
137+
withSee( modelElement.getSee() );
138+
withSourceFile( modelElement.getSourceFile() );
139+
return this;
140+
}
141+
130142
public Builder withUrn( final String urn ) {
131143
return withUrn( AspectModelUrn.fromUrn( urn ) );
132144
}

0 commit comments

Comments
 (0)