-- @atlcompiler emftvm -- @nsURI UML2 http://www.eclipse.org/uml2/3.0.0/UML -- @nsURI OWL http:///org/eclipse/owl.ecore -- $Id$ -- Transforms a UML2 model to an API OWL ontology containing all the packages module UML2ToPackageAPIOntology; --extends UML2ToAPIOntology create OUT : OWL from IN : UML2, PLATFORM : OWL, ISA : OWL, JAVA : OWL; uses UML2ToAPIOntology; -- ====================================================================== -- helper attributes begin -- ====================================================================== helper def : UML2ToPackageAPIOntologyVersionString : String = '$Id$'; helper def : CreatorString : String = 'Dennis Wagelaar <dennis.wagelaar@vub.ac.be>'; helper def : RightsString : String = '© 2010, Vrije Universiteit Brussel. All rights reserved.'; -- ====================================================================== -- helper attributes end -- ====================================================================== -- ====================================================================== -- helper methods begin -- ====================================================================== helper def : versionString() : String = 'Generated by ' + thisModule.UML2ToPackageAPIOntologyVersionString + ', ' + thisModule.UML2ToAPIOntologyVersionString + ', and ' + thisModule.UML2ComparisonVersionString; helper def : formattedVersionString() : String = thisModule.versionString() .regexReplaceAll('\\$Id: ', '[').regexReplaceAll(' \\$', ']'); -- ====================================================================== -- helper methods end -- ====================================================================== -- ====================================================================== -- transformation rules begin -- ====================================================================== rule Model { from s : UML2!"uml::Model" (thisModule.inElements->includes(s)) using { prevNotEmpty : Boolean = thisModule.prevModels->select(m|m.packagedElement->notEmpty())->notEmpty(); jar2uml : UML2!"ecore::EAnnotation" = s.getEAnnotation('Jar2UML'); majorVersion : Integer = jar2uml.details->any(d|d.key='majorBytecodeFormatVersion').value; minorVersion : Integer = jar2uml.details->any(d|d.key='minorBytecodeFormatVersion').value; preverified : Boolean = (jar2uml.details->any(d|d.key='preverified').value = 'true'); } to n : OWL!"rdfs::Namespace" ( URI <- 'http://soft.vub.ac.be/platformkit/2010/1/' + s.name.legalOntName + '.owl#', name <- s.name.legalOntName), xsd : OWL!"rdfs::Namespace" ( URI <- 'http://www.w3.org/2001/XMLSchema#', name <- 'xsd'), platform : OWL!"rdfs::Namespace" ( URI <- 'http://localhost/~dennis/platformkit/2010_1/platform.owl#', name <- 'platform'), isa : OWL!"rdfs::Namespace" ( URI <- 'http://localhost/~dennis/platformkit/2010_1/isa.owl#', name <- 'isa'), java : OWL!"rdfs::Namespace" ( URI <- 'http://localhost/~dennis/platformkit/2010_1/java.owl#', name <- 'java'), integer : OWL!"rdfs::RDFSDatatype" ( localName <- 'integer', namespace <- xsd), boolean : OWL!"rdfs::RDFSDatatype" ( localName <- 'boolean', namespace <- xsd), string : OWL!"rdfs::RDFSDatatype" ( localName <- 'string', namespace <- xsd), ont : OWL!"owl::OWLOntology" ( localName <- '', namespace <- n, RDFSLabel <- Sequence{label}, RDFSComment <- Sequence{comment, creatorLiteral, rightsLiteral}, OWLVersionInfo <- Sequence{versionInfo}, ownedNamespace <- Set{n, xsd, platform, isa, java}->union( if prevNotEmpty then thisModule.importedOntologies->collect(o|thisModule.PrevNamespace(o)) else Set{} endif), -- !!! OWLImports generates bogus namespace !!! OWLImports <- thisModule.platformOntology->union(thisModule.javaOntology)->union( if prevNotEmpty then thisModule.importedOntologies else Set{} endif), contains <- thisModule.LibraryClass(s, thisModule.APIClass(s)) ->union(thisModule.BytecodeClass(s, integer, boolean)) ->union(Sequence{integer, boolean, string, apiInstance, vmClass, jreClass}) ->union(thisModule.includedPackages) ->union(thisModule.includedPackages->collect(p|thisModule.resolveTemp(p, 'apiClass'))) ->union(thisModule.includedPackages->collect(p|thisModule.resolveTemp(p, 'apiPart'))) ->union(thisModule.includedPackages->collect(p|thisModule.resolveTemp(p, 'libraryClass'))) ), label : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- s.name), comment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- thisModule.formattedVersionString()), versionInfo : OWL!"rdfs::PlainLiteral" ( lexicalForm <- '$Id$'), creatorLiteral : OWL!"rdfs::PlainLiteral" ( lexicalForm <- thisModule.CreatorString), -- Instantiation of OWL annotation properties is not possible rightsLiteral : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- thisModule.RightsString), -- Instantiation of OWL annotation properties is not possible apiInstance : OWL!"owl::Individual" ( localName <- 'the' + ont.contains->at(1).localName, RDFType <- ont.contains->at(1), objectSlot <- thisModule.includedPackages ->collect(p|thisModule.APISlot(p)), namespace <- s), vmClass : OWL!"owl::OWLClass" ( localName <- s.name.legalOntClassName + 'VM', RDFSSubClassOf <- Sequence{thisModule.javaVM}, OWLEquivalentClass <- Sequence{vmRestriction}, RDFSComment <- Sequence{vmComment}, namespace <- s), vmComment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- s.name + ' virtual machine'), vmRestriction : OWL!"owl::SomeValuesFromRestriction" ( OWLOnProperty <- thisModule.implementsInterface, OWLSomeValuesFrom <- ont.contains->at(3), namespace <- s), jreClass : OWL!"owl::OWLClass" ( localName <- s.name.legalOntClassName + 'JRE', RDFSSubClassOf <- Sequence{thisModule.javaJRE}, OWLEquivalentClass <- Sequence{jreIntersection}, RDFSComment <- Sequence{jreComment}, namespace <- s), jreComment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- s.name + ' Java Runtime Environment'), jreIntersection : OWL!"owl::IntersectionClass" ( OWLIntersectionOf <- Sequence{jreLibraryRestriction, jreVMRestriction}, namespace <- s), jreLibraryRestriction : OWL!"owl::SomeValuesFromRestriction" ( OWLOnProperty <- thisModule.providesFeature, OWLSomeValuesFrom <- ont.contains->at(2), namespace <- s), jreVMRestriction : OWL!"owl::SomeValuesFromRestriction" ( OWLOnProperty <- thisModule.providesFeature, OWLSomeValuesFrom <- vmClass, namespace <- s) } rule Package { from s : UML2!"uml::Package" (thisModule.includedPackages->includes(s)) using { superClasses : Sequence(OWL!"owl::OWLClass") = s.compatibleClasses->select(c|s.equivalentClasses->excludes(c)); } to apiPartClass : OWL!"owl::OWLClass" ( localName <- (s.ontClassName).debug(thisModule.modelName.prefix + 'Package'), RDFSSubClassOf <- if superClasses->isEmpty() then thisModule.javaAPIPart else superClasses endif, OWLEquivalentClass <- s.equivalentClasses, RDFSComment <- Sequence{apiPartComment}, RDFSSeeAlso <- s.references, namespace <- s.getModel()), apiPartComment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- 'Java API part implementing the ' + s.javaQualifiedName + ' package for ' + thisModule.modelName), apiClass : OWL!"owl::OWLClass" ( localName <- s.ontClassName + 'API', RDFSSubClassOf <- Sequence{thisModule.javaAPI}, OWLEquivalentClass <- Sequence{apiRestriction}, RDFSComment <- Sequence{apiComment}, namespace <- s.getModel()), apiComment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- 'JavaLibrary implementing the ' + s.javaQualifiedName + ' package for ' + thisModule.modelName), apiRestriction : OWL!"owl::SomeValuesFromRestriction" ( OWLOnProperty <- thisModule.comprisesInterfacePart, OWLSomeValuesFrom <- apiPartClass, namespace <- s.getModel()), apiPart : OWL!"owl::Individual" ( localName <- 'the' + s.ontClassName + 'Part', RDFType <- apiPartClass, namespace <- s.getModel()), libraryClass : OWL!"owl::OWLClass" ( localName <- s.ontClassName + 'ClassLibrary', RDFSSubClassOf <- Sequence{thisModule.javaLibrary}, OWLEquivalentClass <- Sequence{libraryRestriction}, RDFSComment <- Sequence{libraryComment}, namespace <- s.getModel()), libraryComment : OWL!"rdfs::PlainLiteral" ( language <- 'en', lexicalForm <- 'JavaLibrary implementing the ' + s.javaQualifiedName + ' package for ' + thisModule.modelName), libraryRestriction : OWL!"owl::SomeValuesFromRestriction" ( OWLOnProperty <- thisModule.implementsInterface, OWLSomeValuesFrom <- apiClass, namespace <- s.getModel()) } -- ====================================================================== -- transformation rules end -- ======================================================================