|
13 | 13 |
|
14 | 14 | package io.openmanufacturing.sds.aspectmodel.serializer;
|
15 | 15 |
|
| 16 | +import java.io.IOException; |
| 17 | +import java.io.InputStream; |
16 | 18 | import java.io.PrintWriter;
|
17 | 19 | import java.util.ArrayDeque;
|
18 | 20 | import java.util.ArrayList;
|
|
22 | 24 | import java.util.List;
|
23 | 25 | import java.util.Map;
|
24 | 26 | import java.util.Optional;
|
| 27 | +import java.util.Properties; |
25 | 28 | import java.util.Queue;
|
26 | 29 | import java.util.Set;
|
27 | 30 | import java.util.stream.Collectors;
|
@@ -159,10 +162,33 @@ private Comparator<Map.Entry<String, String>> createPredefinedPrefixOrder() {
|
159 | 162 | .thenComparing( Map.Entry::getKey );
|
160 | 163 | }
|
161 | 164 |
|
| 165 | + private Properties loadProperties( final String filename ) { |
| 166 | + final Properties properties = new Properties(); |
| 167 | + final InputStream propertiesResource = PrettyPrinter.class.getClassLoader().getResourceAsStream( filename ); |
| 168 | + try { |
| 169 | + properties.load( propertiesResource ); |
| 170 | + } catch ( final IOException exception ) { |
| 171 | + throw new RuntimeException( "Failed to load Properties: " + filename ); |
| 172 | + } |
| 173 | + return properties; |
| 174 | + } |
| 175 | + |
| 176 | + private void showMilestoneBanner() { |
| 177 | + // property file generated by properties-maven-plugin at build time |
| 178 | + final Properties applicationProperties = loadProperties( "pom.properties" ); |
| 179 | + final String version = applicationProperties.get( "aspect-meta-model-version" ).toString(); |
| 180 | + if ( version.contains( "-M" ) ) { |
| 181 | + writer.println( "# This model has been created by SDS SDK Version " + version + " and is not intended for productive usage." ); |
| 182 | + writer.println(); |
| 183 | + } |
| 184 | + } |
| 185 | + |
162 | 186 | /**
|
163 | 187 | * Print to the PrintWriter given in the constructor. This method does not close the PrintWriter.
|
164 | 188 | */
|
165 | 189 | public void print() {
|
| 190 | + showMilestoneBanner(); |
| 191 | + |
166 | 192 | prefixMap.entrySet().stream().sorted( prefixOrder ).forEach( entry -> writer.format( "@prefix %s: <%s> .%n", entry.getKey(), entry.getValue() ) );
|
167 | 193 | writer.println();
|
168 | 194 |
|
|
0 commit comments