diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index db6191d..69c5e18 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -11,6 +11,8 @@ + + @@ -24,8 +26,10 @@ + + diff --git a/src/main/scala/org/uml2semantics/model/UMLClassDiagram.scala b/src/main/scala/org/uml2semantics/model/UMLClassDiagram.scala index 7501f27..1e26198 100644 --- a/src/main/scala/org/uml2semantics/model/UMLClassDiagram.scala +++ b/src/main/scala/org/uml2semantics/model/UMLClassDiagram.scala @@ -601,7 +601,7 @@ case class UMLClassAttribute(attributeIdentity: UMLClassAttributeIdentity, case class UMLEnumerationDefinition(definition: String = "") -case class UMLEnumeration(enumeratonIdentity: UMLEnumerationIdentity, +case class UMLEnumeration(enumerationIdentity: UMLEnumerationIdentity, definition: UMLEnumerationDefinition = UMLEnumerationDefinition()) extends UMLClassDiagramElement @@ -613,6 +613,7 @@ object UMLEnumeration: mutable.HashMap[UMLEnumerationIdentity, mutable.Set[UMLEnumerationValueIdentity]]() def cache(enumerationIdentity: UMLEnumerationIdentity, enumerationValueIdentity: UMLEnumerationValueIdentity): UMLEnumerationIRI = + logger.debug(s"enumerationIdentity=$enumerationIdentity, enumerationValueIdentity=$enumerationValueIdentity ${Code.source}") val enumerationValues: mutable.Set[UMLEnumerationValueIdentity] = enumerationsWithEnumerationValues.getOrElse(enumerationIdentity, mutable.HashSet[UMLEnumerationValueIdentity]()) enumerationValues += enumerationValueIdentity diff --git a/src/main/scala/org/uml2semantics/owl/UML2OWLWriter.scala b/src/main/scala/org/uml2semantics/owl/UML2OWLWriter.scala index 8de4644..08bfc7e 100644 --- a/src/main/scala/org/uml2semantics/owl/UML2OWLWriter.scala +++ b/src/main/scala/org/uml2semantics/owl/UML2OWLWriter.scala @@ -59,11 +59,11 @@ class UML2OWLWriter(val umlClassDiagram: UMLClassDiagram): private def createAndAnnotateOWLClass(umlEnumeration: UMLEnumeration, errorMessages: mutable.Seq[String]): OWLClass = logger.debug(s"createAndAnnotateOWLEnumeration: umlEnumeration=$umlEnumeration, errorMessages=$errorMessages ${Code.source}") - val owlClass = dataFactory.getOWLClass(umlEnumeration.enumeratonIdentity.enumerationIRI.iri) + val owlClass = dataFactory.getOWLClass(umlEnumeration.enumerationIdentity.enumerationIRI.iri) if manager.addAxiom(ontology, dataFactory.getOWLSubClassOfAxiom(owlClass, dataFactory.getOWLThing)) != SUCCESSFULLY then errorMessages :+ s"Could not add axiom ${owlClass.getIRI} subClassOf owl:Thing" createDefinitionAnnotation(owlClass, umlEnumeration.definition.definition, errorMessages) - createLabelAnnotation(owlClass, umlEnumeration.enumeratonIdentity.enumerationLabel, errorMessages) + createLabelAnnotation(owlClass, umlEnumeration.enumerationIdentity.enumerationLabel, errorMessages) owlClass /** @@ -377,7 +377,7 @@ class UML2OWLWriter(val umlClassDiagram: UMLClassDiagram): val owlClass = createAndAnnotateOWLClass(umlEnumeration, errorMessages) if manager.addAxiom(ontology, dataFactory.getOWLSubClassOfAxiom(owlClass, dataFactory.getOWLThing)) != SUCCESSFULLY then errorMessages :+ s"Could not add axiom ${owlClass.getIRI} subClassOf owl:Thing" - val umlEnumerationValueIdentitiesOption = UMLEnumeration.find(umlEnumeration.enumeratonIdentity) + val umlEnumerationValueIdentitiesOption = UMLEnumeration.find(umlEnumeration.enumerationIdentity) if umlEnumerationValueIdentitiesOption.isDefined then val individuals: mutable.Set[OWLIndividual] = new mutable.HashSet[OWLIndividual]() umlEnumerationValueIdentitiesOption.get.foreach(v => { diff --git a/src/main/scala/org/uml2semantics/reader/TSVReader.scala b/src/main/scala/org/uml2semantics/reader/TSVReader.scala index 0c309ee..d793e04 100644 --- a/src/main/scala/org/uml2semantics/reader/TSVReader.scala +++ b/src/main/scala/org/uml2semantics/reader/TSVReader.scala @@ -23,7 +23,7 @@ enum EnumerationValuesHeader: def parseClasses(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace): UMLClasses = import ClassesHeader.* - val logger = Logger("TsvReader: parseClasses") + val logger = Logger("parseClasses") logger.info("Start") implicit object TsvFormat extends TSVFormat {} @@ -108,7 +108,7 @@ end parseAttributes def parseEnumerations(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace): UMLEnumerations = import EnumerationsHeader.* - val logger = Logger("TsvReader: parseEnumerations") + val logger = Logger("parseEnumerations") logger.info("Start") implicit object TsvFormat extends TSVFormat {} @@ -139,7 +139,7 @@ def parseEnumerations(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespac reader.close() val umlEnumerationByNamedElement = umlEnumerations.map( - umlEnumeration => (umlEnumeration.enumeratonIdentity.enumerationNamedElement, umlEnumeration)).toMap + umlEnumeration => (umlEnumeration.enumerationIdentity.enumerationNamedElement, umlEnumeration)).toMap logger.trace(s"umlEnumerationByNamedElement = $umlEnumerationByNamedElement") logger.info("Done") UMLEnumerations(umlEnumerationByNamedElement) @@ -147,10 +147,10 @@ end parseEnumerations def parseEnumerationValues(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace): UMLEnumerationValues = import EnumerationValuesHeader.* - val logger = Logger("TsvReader: parseEnumerationValues") + val logger = Logger("parseEnumerationValues") implicit object TsvFormat extends TSVFormat {} - if maybeTsvFile.isDefined then + if maybeTsvFile.isDefined then { val reader = CSVReader.open(maybeTsvFile.get) val umlEnumerationValues = mutable.Set[UMLEnumerationValue]() @@ -160,30 +160,32 @@ def parseEnumerationValues(maybeTsvFile: Option[File], ontologyPrefix: PrefixNam val enumerationIdentityOption = UMLEnumerationIdentity.findEnumerationNamedElement( m(EnumerationValuesHeader.EnumerationName.toString)) - logger.trace(s"enumerationNamedElement = $enumerationIdentityOption") + logger.trace(s"--------------- enumerationIdentityOption = $enumerationIdentityOption") if enumerationIdentityOption.isDefined then val enumerationIdentity = enumerationIdentityOption.get val curieOption: Option[Curie] = if m(Curie.toString).contains(":") then Some(org.uml2semantics.model.Curie(m(Curie.toString))) else None - val enumerationValueIdentity = UMLEnumerationValueIdentity(enumerationIdentity.enumerationNamedElement, UMLEnumerationValueName(m(Name.toString)), UMLEnumerationValueCurie(curieOption), ontologyPrefix ) + logger.trace(s"enumerationValueIdentity = $enumerationValueIdentity") val umlEnumerationValue = UMLEnumerationValue(enumerationValueIdentity, UMLEnumerationValueDefinition(m(Definition.toString)) ) + logger.trace(s"About to cache enumerationIdentity=$enumerationIdentity and enumerationValueIdentity=$enumerationValueIdentity") UMLEnumeration.cache(enumerationIdentity, enumerationValueIdentity) umlEnumerationValues += umlEnumerationValue - }) + }) reader.close() val umlEnumerationValuesById = umlEnumerationValues.map(umlEnumerationValue => (umlEnumerationValue.valueIdentity.valueNamedElement, umlEnumerationValue)).toMap logger.trace(s"umlEnumerationValuesById = $umlEnumerationValuesById") logger.info("Done") UMLEnumerationValues(umlEnumerationValuesById) + } else UMLEnumerationValues(scala.collection.immutable.HashMap[UMLEnumerationValueNamedElement, UMLEnumerationValue]()) end parseEnumerationValues diff --git a/src/test/resources/Employer - EnumerationNamedValues.tsv b/src/test/resources/Employer - EnumerationNamedValues.tsv index 9d12c7a..1e4834f 100644 --- a/src/test/resources/Employer - EnumerationNamedValues.tsv +++ b/src/test/resources/Employer - EnumerationNamedValues.tsv @@ -1,4 +1,4 @@ EnumerationName Curie Name Definition emp:SalarySchedule emp:Daily Employee gets paid at the end of each day -SalarySchedule Weekly Employee gets paid at the end of each week on a Friday +PaymentSchedule Weekly Employee gets paid at the end of each week on a Friday emp:SalarySchedule emp:Monthly Employee gets paid at the last day of the month \ No newline at end of file