Skip to content

Commit

Permalink
Fixed minor bug that occurred when the 'ontFilePath' (file path of th…
Browse files Browse the repository at this point in the history
…e transformed AML-to-OWL file) does not exist.
  • Loading branch information
MatthiasEckhart committed Sep 28, 2020
1 parent e6533f3 commit 4997f3e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions amlsec/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ reasonerUri = "http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner"

aml {
filePath = ${user.home}"/amlsec/case-study/CaseStudy_A.aml"
# Deprecated now, since AML-to-OWL transformation is directly embedded
ontFilePath = ${user.home}"/amlsec/engineering_data_representation_aml.ttl"
# Deprecated now, since AML-to-OWL transformation is directly embedded into the method execution
# However, this setting can still be activated for debugging purposes (e.g., to run the method without Akka)
# ontFilePath = ${user.home}"/amlsec/engineering_data_representation_aml.ttl"
nsOnt = "http://www.ipr.kit.edu/aml_ontology"
nsImp = "http://www.ipr.kit.edu/aml_importer"
}
Expand Down
4 changes: 2 additions & 2 deletions amlsec/src/main/scala/org/sba_research/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case class Config(baseDir: String,
outputPathSecValReport: String,
agConfig: AGConfig)

case class AmlConfig(filePath: String, ontFilePath: String, nsOnt: String, nsImp: String)
case class AmlConfig(filePath: String, ontFilePath: Option[String], nsOnt: String, nsImp: String)

case class OntConfig(filePath: String, ns: String)

Expand Down Expand Up @@ -49,7 +49,7 @@ object Config {
val outputPathPerformanceReport = conf.getString("debug.performance.outputPathPerformanceReport")

val amlFilePath = conf.getString("aml.filePath")
val amlOntFilePath = conf.getString("aml.ontFilePath")
val amlOntFilePath = if (conf.hasPath("aml.ontFilePath")) Some(conf.getString("aml.ontFilePath")) else None
val amlNsOnt = conf.getString("aml.nsOnt")
val amlNsImp = conf.getString("aml.nsImp")

Expand Down
4 changes: 2 additions & 2 deletions amlsec/src/main/scala/org/sba_research/model/OntModels.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import org.apache.jena.ontology.OntModel
import org.sba_research.Config
import org.sba_research.utils.OntModelUtils

case class OntModels(aml: OntModel, sec: OntModel, icssec: OntModel, ag: OntModel)
case class OntModels(aml: Option[OntModel], sec: OntModel, icssec: OntModel, ag: OntModel)

object OntModels {

def apply(config: Config): OntModels = {

OntModelUtils.setupLocationMappings(config)

val amlOntModel = OntModelUtils.createModel(config.amlConfig.ontFilePath, "aml", Some("Turtle"))
val amlOntModel = config.amlConfig.ontFilePath.map(p => OntModelUtils.createModel(p, "aml", Some("Turtle")))
val secOntModel = OntModelUtils.createModel(config.secOntConfig.filePath, "sec")
val icsSecOntModel = OntModelUtils.createModel(config.icsSecOntConfig.filePath, "icssec")
val agOntModel = OntModelUtils.createModel(config.agOnt.filePath, "ag")
Expand Down
6 changes: 3 additions & 3 deletions amlsec/src/main/scala/org/sba_research/utils/Validator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ object Validator {

val logger = Logger(getClass)

// var classesCache: Option[ClassesCache] = None

@Deprecated
def validate(ontModels: OntModels, shapesModelPath: String, reportPath: Option[String], reasonerUri: String): ValidationReport = {
val infModel = OntModelUtils.getInfModel(ontModels.aml, reasonerUri)
val amlModel = ontModels.aml.getOrElse(throw new IllegalStateException("Could not obtain AutomationML model. Path to corresponding OWL file may be wrong."))
val infModel = OntModelUtils.getInfModel(amlModel, reasonerUri)
validateUsingValidationUtil(infModel = infModel, shapesModelPath = shapesModelPath, reportPath)
}

Expand Down

0 comments on commit 4997f3e

Please sign in to comment.