Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.5.3 #194

Merged
merged 5 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lazy val shexml = project
.in(file("."))
.settings(
name := "ShExML",
version := "0.5.2",
version := "0.5.3",
scalaVersion := "3.2.0",
crossScalaVersions := Seq("2.12.17", "2.13.9", "3.2.0"),
libraryDependencies ++= Seq(
Expand Down
179 changes: 179 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"@context" : {
"@vocab" : "https://w3id.org/codemeta/3.0/",
"identifier" : {
"@type" : "@id"
},
"codeRepository" : {
"@type" : "@id"
},
"issueTracker" : {
"@type" : "@id"
},
"downloadUrl" : {
"@type" : "@id"
},
"license" : {
"@type" : "@id"
}
},
"@id" : "https://github.com/herminiogg/ShExML",
"@type" : "SoftwareSourceCode",
"applicationCategory" : "Computer Science",
"author" : {
"@id" : "https://herminiogarcia.com/#me",
"@type" : "Person",
"affiliation" : {
"@id" : "https://kazernedossin.eu/en",
"@type" : "Organization",
"name" : "Kazerne Dossin"
},
"email" : "[email protected]",
"familyName" : "García González",
"givenName" : "Herminio",
"identifier" : "https://orcid.org/0000-0001-5590-4857"
},
"codeRepository" : "https://github.com/herminiogg/ShExML",
"dateCreated" : "2018-02-22",
"dateModified" : "2024-04-04",
"description" : "A heterogeneous data mapping language based on Shape Expressions",
"developmentStatus" : "active",
"identifier" : "https://doi.org/10.5281/zenodo.11577339",
"license" : "https://api.github.com/licenses/mit",
"name" : "ShExML",
"programmingLanguage" : "Scala",
"releaseNotes" : "<h2>Whats Changed</h2>\n<ul>\n<li>Fixed a problem affecting pushed values</li>\n<li>Fixed some syntax limitations</li>\n<li>JOIN instruction now becomes SUBSTITUTING</li>\n<li>New JOIN instruction performing a classical join between two sets based on a condition</li>\n<li>New IMPORT instruction that allows to import parts of a ShExML script from external files</li>\n</ul>",
"runtimePlatform" : "JVM",
"softwareRequirements" : [ {
"@id" : "http://example.org/shex_3",
"@type" : "SoftwareSourceCode",
"name" : "es.weso:shex_3",
"version" : "0.1.97"
}, {
"@id" : "http://example.org/postgresql",
"@type" : "SoftwareSourceCode",
"name" : "org.postgresql:postgresql",
"version" : "42.5.0"
}, {
"@id" : "http://example.org/picocli",
"@type" : "SoftwareSourceCode",
"name" : "info.picocli:picocli",
"version" : "4.0.4"
}, {
"@id" : "http://example.org/srdf4j_3",
"@type" : "SoftwareSourceCode",
"name" : "es.weso:srdf4j_3",
"version" : "0.1.104"
}, {
"@id" : "http://example.org/rmlmapper",
"@type" : "SoftwareSourceCode",
"name" : "be.ugent.rml:rmlmapper",
"version" : "4.9.0"
}, {
"@id" : "http://example.org/scala-logging_3",
"@type" : "SoftwareSourceCode",
"name" : "com.typesafe.scala-logging:scala-logging_3",
"version" : "3.9.5"
}, {
"@id" : "http://example.org/stringdistance_2.13",
"@type" : "SoftwareSourceCode",
"name" : "com.github.vickumar1981:stringdistance_2.13",
"version" : "1.2.6"
}, {
"@id" : "http://example.org/srdf_3",
"@type" : "SoftwareSourceCode",
"name" : "es.weso:srdf_3",
"version" : "0.1.104"
}, {
"@id" : "http://example.org/jena-arq",
"@type" : "SoftwareSourceCode",
"name" : "org.apache.jena:jena-arq",
"version" : "3.17.0"
}, {
"@id" : "http://example.org/jena-shacl",
"@type" : "SoftwareSourceCode",
"name" : "org.apache.jena:jena-shacl",
"version" : "3.17.0"
}, {
"@id" : "http://example.org/scalatest_3",
"@type" : "SoftwareSourceCode",
"name" : "org.scalatest:scalatest_3",
"version" : "3.2.9"
}, {
"@id" : "http://example.org/mariadb-java-client",
"@type" : "SoftwareSourceCode",
"name" : "org.mariadb.jdbc:mariadb-java-client",
"version" : "2.6.2"
}, {
"@id" : "http://example.org/slf4j-nop",
"@type" : "SoftwareSourceCode",
"name" : "org.slf4j:slf4j-nop",
"version" : "1.7.27"
}, {
"@id" : "http://example.org/logback-classic",
"@type" : "SoftwareSourceCode",
"name" : "ch.qos.logback:logback-classic",
"version" : "1.3.5"
}, {
"@id" : "http://example.org/scala3-library_3",
"@type" : "SoftwareSourceCode",
"name" : "org.scala-lang:scala3-library_3",
"version" : "3.2.0"
}, {
"@id" : "http://example.org/Saxon-HE",
"@type" : "SoftwareSourceCode",
"name" : "net.sf.saxon:Saxon-HE",
"version" : "12.4"
}, {
"@id" : "http://example.org/sqlite-jdbc",
"@type" : "SoftwareSourceCode",
"name" : "org.xerial:sqlite-jdbc",
"version" : "3.32.3.2"
}, {
"@id" : "http://example.org/scala-reflect",
"@type" : "SoftwareSourceCode",
"name" : "org.scala-lang:scala-reflect",
"version" : "2.13.9"
}, {
"@id" : "http://example.org/scala-csv_2.13",
"@type" : "SoftwareSourceCode",
"name" : "com.github.tototoshi:scala-csv_2.13",
"version" : "1.3.6"
}, {
"@id" : "http://example.org/antlr4",
"@type" : "SoftwareSourceCode",
"name" : "org.antlr:antlr4",
"version" : "4.9.2"
}, {
"@id" : "http://example.org/json-path",
"@type" : "SoftwareSourceCode",
"name" : "com.jayway.jsonpath:json-path",
"version" : "2.8.0"
}, {
"@id" : "http://example.org/jena-core",
"@type" : "SoftwareSourceCode",
"name" : "org.apache.jena:jena-core",
"version" : "3.17.0"
}, {
"@id" : "http://example.org/jena-base",
"@type" : "SoftwareSourceCode",
"name" : "org.apache.jena:jena-base",
"version" : "3.17.0"
}, {
"@id" : "http://example.org/mysql-connector-java",
"@type" : "SoftwareSourceCode",
"name" : "mysql:mysql-connector-java",
"version" : "8.0.21"
}, {
"@id" : "http://example.org/scala-compiler",
"@type" : "SoftwareSourceCode",
"name" : "org.scala-lang:scala-compiler",
"version" : "2.13.9"
}, {
"@id" : "http://example.org/mssql-jdbc",
"@type" : "SoftwareSourceCode",
"name" : "com.microsoft.sqlserver:mssql-jdbc",
"version" : "8.4.1.jre8"
} ],
"version" : "0.5.3"
}
2 changes: 1 addition & 1 deletion src/main/scala/com/herminiogarcia/shexml/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Main {

}

@Command(name = "ShExML", version = Array("v0.5.2"),
@Command(name = "ShExML", version = Array("v0.5.3"),
mixinStandardHelpOptions = true,
description = Array("Map and merge heterogeneous data sources with a Shape Expressions based syntax"))
class Main extends Callable[Int] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ import scala.reflect.runtime.universe._

class FunctionHubExecuter(val pathToFile: String) {

private val functionsCode = new SourceHelper().getURLContent(pathToFile).fileContent
private val cm = universe.runtimeMirror(getClass.getClassLoader)
private val toolBox = cm.mkToolBox()
private val tree = toolBox.parse(functionsCode)
private val symbol = toolBox.define(tree.asInstanceOf[toolBox.u.ImplDef])
private val theClass = toolBox.eval(toolBox.parse(functionsCode + s"\nscala.reflect.classTag[${symbol.name}].runtimeClass")).asInstanceOf[Class[_]]

private val logger = Logger[FunctionHubExecuter]

def callFunction(name: String, args: String*): List[String] = {
logger.debug(s"Executing function $name in source code $pathToFile")
val functionsCode = new SourceHelper().getURLContent(pathToFile).fileContent
val cm = universe.runtimeMirror(getClass.getClassLoader)
val toolBox = cm.mkToolBox()
val tree = toolBox.parse(functionsCode)
val symbol = toolBox.define(tree.asInstanceOf[toolBox.u.ImplDef])
val theClass = toolBox.eval(toolBox.parse(functionsCode + s"\nscala.reflect.classTag[${symbol.name}].runtimeClass")).asInstanceOf[Class[_]]
val instance = theClass.getConstructors()(0).newInstance().asInstanceOf[AnyRef]
val method = theClass.getMethods.toList.filter(_.getName.matches(".*" + name + ".*"))
.sortWith((a, b) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class RDFGeneratorVisitor(dataset: Dataset, varTable: mutable.HashMap[Variable,
protected val jsonObjectMapperCache = new JsonObjectMapperCache()
protected val xpathQueryResultsCache = new XpathQueryResultsCache(pushedOrPoppedFieldsPresent)
protected val xmlDocumentCache = new XMLDocumentCache()
protected val functionHubExecuterCache = new FunctionHubExecuterCache()
protected val defaultModel = dataset.getDefaultModel

private val xmlProcessor = new Processor(false)
Expand Down Expand Up @@ -379,7 +380,13 @@ class RDFGeneratorVisitor(dataset: Dataset, varTable: mutable.HashMap[Variable,

case f: FunctionCalling => {
val functionsURL = varTable(f.functionHub).asInstanceOf[URL]
val functionHub = new FunctionHubExecuter(functionsURL.url)
val functionHub = functionHubExecuterCache.search(functionsURL.url) match {
case Some(executer) => executer
case None =>
val executer = new FunctionHubExecuter(functionsURL.url)
functionHubExecuterCache.save(functionsURL.url, executer)
executer
}
val argumentsResults = f.arguments.arguments.map(doVisit(_, optionalArgument).asInstanceOf[List[Result]])
val arguments = for (i <- argumentsResults.head.indices) yield {
for (j <- argumentsResults.indices) yield {
Expand Down Expand Up @@ -1242,6 +1249,18 @@ class XpathQueryResultsCache(pushedValues: Boolean) {
}
}

class FunctionHubExecuterCache() {
private val table = mutable.HashMap[String, FunctionHubExecuter]()

def search(url: String): Option[FunctionHubExecuter] = {
table.get(url)
}

def save(url: String, functionHubExecuter: FunctionHubExecuter): Unit = {
table += ((url, functionHubExecuter))
}
}

sealed trait Resultable {
def results: List[String]
}
Expand Down
Loading