Skip to content

Commit 2c20cb1

Browse files
authored
Merge pull request #290 from bci-oss/282-update-validation-documentation
Update Java tooling documentation
2 parents cb3f6fb + 8e9a582 commit 2c20cb1

File tree

42 files changed

+1676
-634
lines changed

Some content is hidden

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

42 files changed

+1676
-634
lines changed

core/sds-aspect-meta-model-interface/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
<groupId>io.openmanufacturing</groupId>
4141
<artifactId>sds-aspect-model-urn</artifactId>
4242
</dependency>
43-
43+
<dependency>
44+
<groupId>io.openmanufacturing</groupId>
45+
<artifactId>sds-aspect-meta-model</artifactId>
46+
</dependency>
4447

4548
<dependency>
4649
<groupId>org.junit.jupiter</groupId>

core/sds-aspect-meta-model-interface/src/main/java/io/openmanufacturing/sds/aspectmodel/resolver/AspectMetaModelResourceResolver.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
33
*
44
* See the AUTHORS file(s) distributed with this work for additional
5-
* information regarding authorship.
5+
* information regarding authorship.
66
*
77
* This Source Code Form is subject to the terms of the Mozilla Public
88
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -19,13 +19,12 @@
1919
import org.apache.jena.rdf.model.Model;
2020
import org.apache.jena.rdf.model.Statement;
2121

22+
import io.openmanufacturing.sds.aspectmetamodel.KnownVersion;
2223
import io.openmanufacturing.sds.aspectmodel.MissingMetaModelVersionException;
2324
import io.openmanufacturing.sds.aspectmodel.MultipleMetaModelVersionsException;
2425
import io.openmanufacturing.sds.aspectmodel.UnsupportedVersionException;
2526
import io.openmanufacturing.sds.aspectmodel.VersionNumber;
2627
import io.openmanufacturing.sds.aspectmodel.resolver.services.VersionedModel;
27-
import io.openmanufacturing.sds.aspectmodel.urn.AspectModelUrn;
28-
import io.openmanufacturing.sds.aspectmodel.urn.UrnSyntaxException;
2928
import io.vavr.control.Try;
3029

3130
/**
@@ -43,6 +42,10 @@ public interface AspectMetaModelResourceResolver {
4342
*/
4443
Try<VersionedModel> mergeMetaModelIntoRawModel( final Model rawModel, final VersionNumber version );
4544

45+
default Try<VersionedModel> mergeMetaModelIntoRawModel( final Model rawModel, final KnownVersion version ) {
46+
return mergeMetaModelIntoRawModel( rawModel, VersionNumber.parse( version.toVersionString() ) );
47+
}
48+
4649
/**
4750
* Retrieves the meta model version an Aspect model uses
4851
*

core/sds-aspect-meta-model-interface/src/main/java/io/openmanufacturing/sds/aspectmodel/resolver/services/VersionedModel.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
33
*
44
* See the AUTHORS file(s) distributed with this work for additional
5-
* information regarding authorship.
5+
* information regarding authorship.
66
*
77
* This Source Code Form is subject to the terms of the Mozilla Public
88
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -15,6 +15,7 @@
1515

1616
import org.apache.jena.rdf.model.Model;
1717

18+
import io.openmanufacturing.sds.aspectmetamodel.KnownVersion;
1819
import io.openmanufacturing.sds.aspectmodel.VersionNumber;
1920

2021
/**
@@ -42,6 +43,10 @@ public VersionedModel( final Model model, final VersionNumber version, final Mod
4243
this.rawModel = rawModel;
4344
}
4445

46+
public VersionedModel( final Model model, final KnownVersion version, final Model rawModel ) {
47+
this( model, VersionNumber.parse( version.toVersionString() ), rawModel );
48+
}
49+
4550
public Model getModel() {
4651
return model;
4752
}

core/sds-aspect-model-serializer/src/main/java/io/openmanufacturing/sds/aspectmodel/serializer/PrettyPrinter.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.apache.jena.graph.impl.LiteralLabel;
4646
import org.apache.jena.rdf.model.Literal;
4747
import org.apache.jena.rdf.model.Model;
48+
import org.apache.jena.rdf.model.ModelFactory;
4849
import org.apache.jena.rdf.model.Property;
4950
import org.apache.jena.rdf.model.RDFList;
5051
import org.apache.jena.rdf.model.RDFNode;
@@ -87,11 +88,23 @@ public class PrettyPrinter {
8788
private final PrintVisitor printVisitor;
8889

8990
/**
90-
* Constructor.
91+
* Constructor that takes a raw RDF {@link Model}
9192
*
92-
* @param versionedModel The model to write
93-
* @param rootElementUrn The URN of the root model element
94-
* @param writer The writer to write to.
93+
* @param model the Aspect Model to write
94+
* @param metaModelVersion the meta model version
95+
* @param rootElementUrn the URN of the root model element
96+
* @param writer the writer to write to
97+
*/
98+
public PrettyPrinter( final Model model, final KnownVersion metaModelVersion, final AspectModelUrn rootElementUrn, final PrintWriter writer ) {
99+
this( new VersionedModel( ModelFactory.createDefaultModel(), metaModelVersion, model ), rootElementUrn, writer );
100+
}
101+
102+
/**
103+
* Constructor that takes a {@link VersionedModel}
104+
*
105+
* @param versionedModel the Aspect Model to write
106+
* @param rootElementUrn the URN of the root model element
107+
* @param writer the writer to write to
95108
*/
96109
public PrettyPrinter( final VersionedModel versionedModel, final AspectModelUrn rootElementUrn, final PrintWriter writer ) {
97110
model = versionedModel.getRawModel();
@@ -415,7 +428,7 @@ private String print( final RDFNode node ) {
415428
}
416429

417430
record PrintVisitor(Model model) implements NodeVisitor {
418-
431+
419432
@Override
420433
public Object visitAny( final Node_ANY it ) {
421434
return "*";

core/sds-aspect-model-serializer/src/test/java/io/openmanufacturing/sds/aspectmodel/serializer/PrettyPrinterTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ public void testPrettyPrinter( final TestAspect testAspect ) {
4747

4848
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
4949
final PrintWriter writer = new PrintWriter( buffer, false, StandardCharsets.UTF_8 );
50-
new PrettyPrinter( new VersionedModel( ModelFactory.createDefaultModel(),
51-
VersionNumber.parse( metaModelVersion.toVersionString() ), originalModel ),
52-
testAspect.getUrn(), writer )
53-
.print();
50+
new PrettyPrinter( new VersionedModel( ModelFactory.createDefaultModel(), metaModelVersion, originalModel ),
51+
testAspect.getUrn(), writer ).print();
5452
writer.flush();
5553

5654
final InputStream bufferInput = new ByteArrayInputStream( buffer.toByteArray() );

documentation/developer-guide/modules/ROOT/examples/Battery.ttl

Lines changed: 0 additions & 66 deletions
This file was deleted.

documentation/developer-guide/modules/ROOT/examples/Movement.ttl

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)