Skip to content

Commit

Permalink
Release 0.1.04
Browse files Browse the repository at this point in the history
  • Loading branch information
labra committed Aug 20, 2018
1 parent e43cf7c commit 4189961
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import es.weso.rdf.operations.Comparisons._
* This validator is implemented directly in Scala using cats library
*/

case class Validator(schema: Schema) extends MyLogging {
case class Validator(schema: Schema) extends LazyLogging {

/**
* Return all targetNode declarations which are pairs (n,s) where
Expand Down
2 changes: 2 additions & 0 deletions modules/shacl/src/test/resources/shacl/imports/import.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ prefix owl: <http://www.w3.org/2002/07/owl#>
sh:property :hasName .

:Person sh:targetNode :alice .
:Person sh:targetNode :bob .

:alice :name "Alice" .
:bob :age 23 . # Has no name
18 changes: 18 additions & 0 deletions modules/shacl/src/test/resources/shacl/imports/importWithLoop.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
prefix : <http://example.org/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix schema: <http://schema.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix owl: <http://www.w3.org/2002/07/owl#>

<> owl:imports <loop.ttl> .

:Person a sh:NodeShape ;
sh:property :hasName .

:Person sh:targetNode :alice .
:Person sh:targetNode :bob .

:alice :name "Alice" .
:bob :age 23 . # Has no name
14 changes: 14 additions & 0 deletions modules/shacl/src/test/resources/shacl/imports/loop.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
prefix : <http://example.org/>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix schema: <http://schema.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix owl: <http://www.w3.org/2002/07/owl#>

# An infinite loop as it imports itself...
<> owl:imports <loop.ttl> .

:hasName a sh:PropertyShape ;
sh:path :name ;
sh:minCount 1 .
60 changes: 60 additions & 0 deletions modules/shacl/src/test/scala/es/weso/shacl/ImportTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package es.weso.shacl

import java.nio.file.Paths

import com.typesafe.config.{Config, ConfigFactory}
import es.weso.rdf.jena.RDFAsJenaModel
import es.weso.rdf.nodes.IRI
import es.weso.shacl.converter.RDF2Shacl
import es.weso.shacl.validator.Validator
import org.scalatest._

class ImportTest extends FunSpec with Matchers with TryValues with OptionValues
with SchemaMatchers {

val conf: Config = ConfigFactory.load()
val shaclFolderStr = conf.getString("shaclTests")
val shaclFolder = IRI(Paths.get(shaclFolderStr).normalize.toUri.toString)

describe("import") {
it(s"Validates a shape that imports another one") {
val r = for {
rdf <- RDFAsJenaModel.fromIRI(shaclFolder + "imports/import.ttl")
schema <- RDF2Shacl.getShacl(rdf)
result <- Validator.validate(schema, rdf)
} yield result

r.fold(
e => fail(s"Error reading: $e"),
pair => {
val (typing, ok) = pair
val alice = IRI("http://example.org/alice")
val bob = IRI("http://example.org/bob")
val person = IRI("http://example.org/Person")
val hasName = IRI("http://example.org/hasName")
typing.getFailedValues(alice).map(_.id) should contain theSameElementsAs(List())
typing.getFailedValues(bob).map(_.id) should contain theSameElementsAs(List(person,hasName))
})
}

it(s"Validates a shape that imports another one with a loop") {
val r = for {
rdf <- RDFAsJenaModel.fromIRI(shaclFolder + "imports/importWithLoop.ttl")
schema <- RDF2Shacl.getShacl(rdf)
result <- Validator.validate(schema, rdf)
} yield result

r.fold(
e => fail(s"Error reading: $e"),
pair => {
val (typing, ok) = pair
val alice = IRI("http://example.org/alice")
val bob = IRI("http://example.org/bob")
val person = IRI("http://example.org/Person")
val hasName = IRI("http://example.org/hasName")
typing.getFailedValues(alice).map(_.id) should contain theSameElementsAs(List())
typing.getFailedValues(bob).map(_.id) should contain theSameElementsAs(List(person,hasName))
})
}
}
}
16 changes: 16 additions & 0 deletions notes/0.1.04.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# New features

- Added support for owl:imports in SHACL

TODOs
-----

- ShEx: Complete semantic actions implementation [Issue 116](https://github.com/labra/shaclex/issues/116)

- ShEx: test-suite with shape maps and update report [Issue 115](https://github.com/labra/shaclex/issues/115)

- Shaclex: Conversion from ShEx to SHACL [Issue 114](https://github.com/labra/shaclex/issues/114)

- Shaclex: Conversion from SHACL to ShEx [Issue 113](https://github.com/labra/shaclex/issues/113)

- Shacl: Implement SHACL-Sparql [Issue 112](https://github.com/labra/shaclex/issues/112)
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.1.03"
version in ThisBuild := "0.1.04"

0 comments on commit 4189961

Please sign in to comment.