-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to trigger internal Jena consistency checks during loading (…
…#29) There are cases where the loaded RDF graph is obviously against the OWL constraints that have been used to define a class: for instance, if someone says "Computers are things that have one motherboard" and then the graph has something said to be a Computer with two motherboards. This commit adds a checkbox in the model configuration dialog which triggers Jena's internal consistency checks, and will raise an error during model loading if an inconsistency is found. --------- Co-authored-by: Antonio Garcia-Dominguez <a.garcia-dominguez@york.ac.uk>
- Loading branch information
1 parent
099cfcc
commit 8635167
Showing
8 changed files
with
183 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/org.eclipse.epsilon.emc.rdf.tests/resources/OWL/owlDemoData_valid.ttl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@prefix : <urn:x-hp:eg/> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
|
||
:alienBox51 a :GamingComputer . | ||
|
||
:bigName42 a :Computer ; | ||
:bundle :binNameSpecialBundle ; | ||
:motherBoard :bigNameSpecialMB . | ||
|
||
:whiteBoxZX a :Computer ; | ||
:bundle :actionPack ; | ||
:motherBoard :nForce . | ||
|
||
:actionPack a :GameBundle . | ||
|
||
:bigNameSpecialMB owl:differentFrom :nForce2 . | ||
|
||
:unknownMB :hasGraphics :gamingGraphics . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...eclipse.epsilon.emc.rdf.tests/src/org/eclipse/epsilon/emc/rdf/RDFModelValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 University of York | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Antonio Garcia-Dominguez - initial API and implementation | ||
********************************************************************************/ | ||
package org.eclipse.epsilon.emc.rdf; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import org.eclipse.epsilon.common.util.StringProperties; | ||
import org.eclipse.epsilon.eol.exceptions.models.EolModelLoadingException; | ||
import org.junit.Test; | ||
|
||
public class RDFModelValidationTest { | ||
|
||
private static final String OWL_DEMO_DATAMODEL_INVALID = "resources/OWL/owlDemoData.ttl"; | ||
private static final String OWL_DEMO_DATAMODEL_VALID = "resources/OWL/owlDemoData_valid.ttl"; | ||
private static final String OWL_DEMO_SCHEMAMODEL = "resources/OWL/owlDemoSchema.ttl"; | ||
|
||
private static final String LANGUAGE_PREFERENCE_EN_STRING = "en"; | ||
|
||
private RDFModel model; | ||
|
||
@Test | ||
public void loadInvalidModel() { | ||
|
||
try { | ||
loadModel(OWL_DEMO_DATAMODEL_INVALID); | ||
fail("An exception was expected"); | ||
} catch (EolModelLoadingException e) { | ||
String sErrors = e.getMessage(); | ||
assertTrue("The model loaded should FAIL validation (6 errors relating to BigName42 having 2 motherboards)", | ||
sErrors.contains("not valid")); | ||
} | ||
} | ||
|
||
@Test | ||
public void loadValidModel() throws EolModelLoadingException { | ||
loadModel(OWL_DEMO_DATAMODEL_VALID); | ||
} | ||
|
||
// Functions not tests | ||
|
||
protected void loadModel(String dataModelUri) throws EolModelLoadingException { | ||
this.model = new RDFModel(); | ||
StringProperties props = new StringProperties(); | ||
props.put(RDFModel.PROPERTY_DATA_URIS, dataModelUri); | ||
props.put(RDFModel.PROPERTY_SCHEMA_URIS, OWL_DEMO_SCHEMAMODEL); | ||
props.put(RDFModel.PROPERTY_LANGUAGE_PREFERENCE, LANGUAGE_PREFERENCE_EN_STRING); | ||
props.put(RDFModel.PROPERTY_VALIDATE_MODEL, RDFModel.VALIDATION_SELECTION_JENA); | ||
model.load(props); | ||
} | ||
|
||
} |