Skip to content

Commit b393bd7

Browse files
committed
Incorporate PR suggestions
1 parent 2bcc520 commit b393bd7

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

core/esmf-aspect-model-validator/src/main/java/org/eclipse/esmf/aspectmodel/shacl/RustLikeFormatter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@
4343

4444
/**
4545
* Rust-like message formatter. Formatted messages look something like the following example:
46-
*
46+
* <br/><br/>
47+
* <pre>
4748
* ---> Error at line 11 column 20
4849
* |
4950
* 11 | :testProperty [ a :SomethingElse ]
5051
* | ^^^^^^^^^^^^^^ Property ':testProperty' on ':Foo' has type ':SomethingElse', but only ':TestClass2' is allowed.
5152
* |
53+
* </pre>
5254
*/
5355
public class RustLikeFormatter {
5456

@@ -228,13 +230,13 @@ private boolean formatNode( final RDFNode node ) {
228230
final SmartToken nodePosition = extractToken( node );
229231
if ( null == nodePosition ) {
230232
// ugly special case: Jena internally replaces the RDF keyword 'a' with 'rdf:type' without position information
231-
if ( node.asNode().equals( NodeConst.nodeRDFType ) ) {
233+
if ( NodeConst.nodeRDFType.equals( node.asNode() ) ) {
232234
spacedIfPossible( "a " );
233235
}
234-
if ( node.asNode().equals( NodeConst.nodeTrue ) ) {
236+
if ( NodeConst.nodeTrue.equals( node.asNode() ) ) {
235237
spacedIfPossible( "true" );
236238
}
237-
if ( node.asNode().equals( NodeConst.nodeFalse ) ) {
239+
if ( NodeConst.nodeFalse.equals( node.asNode() ) ) {
238240
spacedIfPossible( "false" );
239241
}
240242
return true;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2023 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.aspectmodel.shacl;
15+
16+
import java.io.Serial;
17+
18+
/**
19+
* This exception is thrown when the validation process fails
20+
*/
21+
public class ShaclValidationException extends RuntimeException {
22+
@Serial
23+
private static final long serialVersionUID = 7771592676699681415L;
24+
25+
public ShaclValidationException( final String message ) {
26+
super( message );
27+
}
28+
}

core/esmf-aspect-model-validator/src/main/java/org/eclipse/esmf/aspectmodel/shacl/ShaclValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private Map<Resource, List<Shape.Node>> findSparqlTargets( final Model model ) {
126126
final Map<Resource, List<Shape.Node>> resourceShapes = new HashMap<>();
127127
for ( final Shape.Node shape : targetSparqlShapes() ) {
128128
final List<Resource> shapeTargets = querySparqlTargets( model, shape.attributes().targetSparql().orElseThrow( () ->
129-
new RuntimeException( "SPARQL node shape is missing a target SPARQL expression" ) ) );
129+
new ShaclValidationException( "SPARQL node shape is missing a target SPARQL expression" ) ) );
130130
for ( final Resource node : shapeTargets ) {
131131
addResourceShape( resourceShapes, node, shape );
132132
}

0 commit comments

Comments
 (0)