Closed thewillyhuman closed 4 years ago
@othub I assigned it to you but don't be too worried about it, I don't expect it to be finished till monday, it is the last task of the week.
@thewilly i have a little doubt, and i need your help. I'm doing the merge part using RDF2ShEx and ShEx2RDF, on a branch named shex, but the result schema is always empty knowing that the resulting rdf model has data and the code i use is the following :
def mergeShExModels(sourceFiles: List[Source], sourcePath: String,
exceptionMessage : String): Either[Exception, Schema] = {
// If the source directory does not exist
if (!Files.exists(Paths.get(sourcePath))) {
// throwing IOException
Left(fromString(exceptionMessage))
} else {
//the list of shex files in the sources folder is empty, so we return an empty model
if (sourceFiles.isEmpty) {
Right(emptySchema)
} else {
val builder = RDFAsRDF4jModel.empty.unsafeRunSync()
//transforming shex file to rdf in order to do the merge
val finalModel = ShEx2RDF.apply(Schema.fromString(sourceFiles.head.getLines().mkString).unsafeRunSync(),
None, builder).unsafeRunSync()
//looping through the files in the directory and merging with the finalModel
if (sourceFiles.size > 1) {
for (fileSource <- sourceFiles.tail) {
val schemaAsModel = ShEx2RDF.apply(Schema.fromString(fileSource.getLines().mkString).unsafeRunSync()
, None, builder)
finalModel.merge(schemaAsModel.unsafeRunSync())
}
}
//rdf model to schema
val finalSchema = RDF2ShEx.rdf2Schema(finalModel).value.unsafeRunSync()
Right(finalSchema.getOrElse(emptySchema))
}
}
}
Okay will take a look to it later, wait news.
@othub could you please initiate a PR to ci-dev with your actual work so I can work from there? Just add the word WIP
at the beginning of the PR and that way we all will now is not ready to merge yet but at the same time will be able to test and try your code easily.
Please add a default implementation and corresponding tests to the following trait: https://github.com/weso/hercules-ontology/blob/162a416e61ca2b9330825eb31cb58b89321228f5/ci/src/main/scala/es/weso/asio/ci/SchemaProcessor.scala#L1-L23
Remember to fork, make a new branch for the feature and initiate a PR to this branch.