Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
labra committed Oct 28, 2020
1 parent c73893d commit 611e889
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ import es.weso.rdf.path.{InversePath, PredicatePath, SHACLPath}
import es.weso.shex.implicits.showShEx._
import es.weso.shex.linter.ShExLinter
import es.weso.{shacl, _}
import es.weso.shacl.TargetClass
import es.weso.shacl.TargetNode
import es.weso.shacl.TargetObjectsOf
import es.weso.shacl.TargetSubjectsOf

object Shacl2ShEx {

def shacl2ShEx(schema: shacl.Schema): Either[String, (shex.Schema, shapeMaps.QueryShapeMap)] = {
val (state, eitherSchema) = cnvSchema(schema).value.run(initialState)
val e = for {
schema <- eitherSchema
schema1 = schema.addTripleExprMap(state.tripleExprMap)
shexSchema <- eitherSchema
schema1 = shexSchema.addTripleExprMap(state.tripleExprMap)
queryMap <- cnvShapeMap(schema)
lintedSchema <- ShExLinter.inlineInclusions(schema1)
} yield (lintedSchema,queryMap)
// println(s"Result of conversion: \n$e")
e
}

def cnvShapeMap(schema: shex.Schema): Either[String,shapeMaps.QueryShapeMap] = Right(shapeMaps.QueryShapeMap(List(), PrefixMap.empty, PrefixMap.empty))
def cnvShapeMap(schema: shacl.Schema): Either[String,shapeMaps.QueryShapeMap] = {
val associations: List[Association] = schema.shapesMap.values.map(shape2Associations)
Right(shapeMaps.QueryShapeMap(List(), PrefixMap.empty, PrefixMap.empty))
}

private def shape2Associations(shape: shacl.Shape): List[Association] = shape.targets.map(target2Association)

private def target2Association(target: shacl.Target): Association = target match {
case TargetClass(node) => ???
case TargetNode(node) => ???
case TargetObjectsOf(pred) => ???
case TargetSubjectsOf(pred) => ???
}

case class State(tripleExprMap: TEMap) {
def addLabelTripleExpr(lbl: shex.ShapeLabel, te: shex.TripleExpr): State = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ case class JenaShacl(shapesGraph: Model) extends Schema {
else
IO.raiseError(JenaShaclException(s"Format $format not supported to serialize $name. Supported formats=$formats"))

override def empty: Schema = ShaclexSchema.empty
override def empty: Schema = JenaShacl.empty

override def shapes: List[String] = {
List()
Expand Down
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.67"
version in ThisBuild := "0.1.69"

0 comments on commit 611e889

Please sign in to comment.