From 611e8896aed75aeaa4ebb5466ce4aef3eb169da6 Mon Sep 17 00:00:00 2001 From: Jose Labra Date: Wed, 28 Oct 2020 23:14:14 +0100 Subject: [PATCH] Updates --- .../es/weso/shacl/converter/Shacl2ShEx.scala | 22 ++++++++++++++++--- .../main/scala/es/weso/schema/JenaShacl.scala | 2 +- version.sbt | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala b/modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala index d6d766df7..9ca3a0699 100644 --- a/modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala +++ b/modules/converter/src/main/scala/es/weso/shacl/converter/Shacl2ShEx.scala @@ -9,14 +9,18 @@ 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) @@ -24,7 +28,19 @@ object Shacl2ShEx { 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 = { diff --git a/modules/schema/src/main/scala/es/weso/schema/JenaShacl.scala b/modules/schema/src/main/scala/es/weso/schema/JenaShacl.scala index 49bd745b2..9563c79d0 100644 --- a/modules/schema/src/main/scala/es/weso/schema/JenaShacl.scala +++ b/modules/schema/src/main/scala/es/weso/schema/JenaShacl.scala @@ -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() diff --git a/version.sbt b/version.sbt index e473520c0..05d2f3580 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.1.67" \ No newline at end of file +version in ThisBuild := "0.1.69" \ No newline at end of file