Skip to content

Commit 867acb4

Browse files
author
Marco De Salvo
committed
Added helper method ToEntity<T>
1 parent 0e25830 commit 867acb4

File tree

13 files changed

+117
-75
lines changed

13 files changed

+117
-75
lines changed

OWLSharp.Test/Validator/OWLValidatorTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public async Task ShouldAnalyzeTopBottomAsync()
208208

209209
Assert.IsNotNull(issues);
210210
Assert.HasCount(1, issues);
211-
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Warning));
211+
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Error));
212212
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.RuleName, OWLTopBottomAnalysisRule.rulename)));
213213
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Description, "Detected object property axioms causing reserved owl:topObjectProperty property to not be the root object property of the ontology")));
214214
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Suggestion, OWLTopBottomAnalysisRule.rulesuggT1)));

OWLSharp.Test/Validator/RuleSet/OWLTopBottomAnalysisRuleTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ShouldAnalyzeTopBottomT1Case()
4848

4949
Assert.IsNotNull(issues);
5050
Assert.HasCount(1, issues);
51-
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Warning));
51+
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Error));
5252
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.RuleName, OWLTopBottomAnalysisRule.rulename)));
5353
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Description, "Detected object property axioms causing reserved owl:topObjectProperty property to not be the root object property of the ontology")));
5454
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Suggestion, OWLTopBottomAnalysisRule.rulesuggT1)));
@@ -79,7 +79,7 @@ public void ShouldAnalyzeTopBottomT2Case()
7979

8080
Assert.IsNotNull(issues);
8181
Assert.HasCount(1, issues);
82-
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Warning));
82+
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Error));
8383
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.RuleName, OWLTopBottomAnalysisRule.rulename)));
8484
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Description, "Detected data property axioms causing reserved owl:topDataProperty property to not be the root data property of the ontology")));
8585
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Suggestion, OWLTopBottomAnalysisRule.rulesuggT2)));
@@ -110,7 +110,7 @@ public void ShouldAnalyzeTopBottomB1Case()
110110

111111
Assert.IsNotNull(issues);
112112
Assert.HasCount(1, issues);
113-
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Warning));
113+
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Error));
114114
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.RuleName, OWLTopBottomAnalysisRule.rulename)));
115115
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Description, "Detected object property axioms causing reserved owl:bottomObjectProperty property to not be the bottom object property of the ontology")));
116116
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Suggestion, OWLTopBottomAnalysisRule.rulesuggB1)));
@@ -141,7 +141,7 @@ public void ShouldAnalyzeTopBottomB2Case()
141141

142142
Assert.IsNotNull(issues);
143143
Assert.HasCount(1, issues);
144-
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Warning));
144+
Assert.IsTrue(issues.TrueForAll(iss => iss.Severity == OWLEnums.OWLIssueSeverity.Error));
145145
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.RuleName, OWLTopBottomAnalysisRule.rulename)));
146146
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Description, "Detected data property axioms causing reserved owl:bottomDataProperty property to not be the bottom data property of the ontology")));
147147
Assert.IsTrue(issues.TrueForAll(iss => string.Equals(iss.Suggestion, OWLTopBottomAnalysisRule.rulesuggB2)));

OWLSharp/Ontology/Helpers/OWLExpressionHelper.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,47 @@ You may obtain a copy of the License at
1414
limitations under the License.
1515
*/
1616

17+
using RDFSharp.Model;
1718
using System.Collections.Generic;
1819

1920
namespace OWLSharp.Ontology
2021
{
2122
/// <summary>
2223
/// OWLExpressionHelper simplifies expression modeling with a set of facilities
2324
/// </summary>
24-
internal static class OWLExpressionHelper
25+
public static class OWLExpressionHelper
2526
{
2627
#region Methods
28+
/// <summary>
29+
/// Gets an entity of the given type from the given RDF resource
30+
/// </summary>
31+
public static T ToEntity<T>(this RDFResource iri) where T : IOWLEntity
32+
{
33+
object entity = null;
34+
switch (typeof(T).Name)
35+
{
36+
case nameof(OWLClass):
37+
entity = new OWLClass(iri);
38+
break;
39+
case nameof(OWLDatatype):
40+
entity = new OWLDatatype(iri);
41+
break;
42+
case nameof(OWLNamedIndividual):
43+
entity = new OWLNamedIndividual(iri);
44+
break;
45+
case nameof(OWLAnnotationProperty):
46+
entity = new OWLAnnotationProperty(iri);
47+
break;
48+
case nameof(OWLDataProperty):
49+
entity = new OWLDataProperty(iri);
50+
break;
51+
case nameof(OWLObjectProperty):
52+
entity = new OWLObjectProperty(iri);
53+
break;
54+
}
55+
return (T)entity;
56+
}
57+
2758
/// <summary>
2859
/// Removes the duplicate expressions from the given list
2960
/// </summary>

0 commit comments

Comments
 (0)