-- $Id$ module Accessors; create OUT : UML refining IN : UML, MERGE : UML; uses Java; uses MergeHelpers; -- ====================================================================== -- -- Begin model merging section -- -- ====================================================================== -- From: MergeModel.atl 3150 2006-01-16 13:32:57Z dwagelaa -- ====================================================================== -- merge helper variables begin -- ====================================================================== helper def : inElements : Set(UML!Element) = UML!Element.allInstancesFrom('IN'); helper def : mergeElements : Set(UML!Element) = UML!Element.allInstancesFrom('MERGE'); helper def : newElements : Sequence(UML!Element) = Sequence{ UML!Classifier.allInstancesFrom('MERGE')->select(c|c.notInSourceModel()), UML!Package.allInstancesFrom('MERGE')->select(p|p.notInSourceModel()), UML!TagDefinition.allInstancesFrom('MERGE')->select(t|t.notInSourceModel()), UML!Stereotype.allInstancesFrom('MERGE')->select(s|s.notInSourceModel()), UML!Association.allInstancesFrom('MERGE')->select(a|a.notInSourceModel()), UML!Dependency.allInstancesFrom('MERGE')->select(d|d.notInSourceModel()), UML!Generalization.allInstancesFrom('MERGE')->select(g|g.notInSourceModel()) }->flatten(); -- ====================================================================== -- merge helper variables end -- ====================================================================== -- ====================================================================== -- model merge begin -- ====================================================================== rule MergeAssociation { from s : UML!Association ( if thisModule.newElements->includes(s) then s.oclIsTypeOf(UML!Association) else false endif) to t : UML!Association mapsTo s ( isRoot <- s.isRoot, isAbstract <- s.isAbstract, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeTaggedValue { from s : UML!TaggedValue ( if thisModule.mergeElements->includes(s) then s.notInSourceModel() else false endif) to t : UML!TaggedValue mapsTo s ( dataValue <- s.dataValue, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, referenceValue <- s.referenceValue, modelElement <- s.modelElement, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), clientDependency <- s.clientDependency, type <- if thisModule.newElements->includes(s.type) then s.type else s.type.fromSourceModel() endif) } rule MergeOperation { from s : UML!Operation ( if thisModule.mergeElements->includes(s) then s.notInSourceModel() else false endif) to t : UML!Operation mapsTo s ( owner <- if thisModule.newElements->includes(s.owner) then s.owner else s.owner.fromSourceModel() endif, parameter <- s.parameter, ownerScope <- s.ownerScope, visibility <- s.visibility, isQuery <- s.isQuery, isAbstract <- s.isAbstract, concurrency <- s.concurrency, name <- s.name, isSpecification <- s.isSpecification, isRoot <- s.isRoot, isLeaf <- s.isLeaf, specification <- s.specification, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif)) } rule MergeAbstraction { from s : UML!Abstraction ( thisModule.newElements->includes(s)) to t : UML!Abstraction mapsTo s ( mapping <- s.mapping, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, comment <- s.comment, client <- s.client->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), supplier <- s.supplier->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeParameter { from s : UML!Parameter ( if thisModule.mergeElements->includes(s) then s.notInSourceModel() else false endif) to t : UML!Parameter mapsTo s ( kind <- s.kind, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, defaultValue <- s.defaultValue, comment <- s.comment, type <- if thisModule.newElements->includes(s.type) then s.type else s.type.fromSourceModel() endif, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif)) } rule MergeClass { from s : UML!Class ( if thisModule.newElements->includes(s) then s.oclIsTypeOf(UML!Class) else false endif) to t : UML!Class mapsTo s ( isRoot <- s.isRoot, isActive <- s.isActive, isAbstract <- s.isAbstract, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeInterface { from s : UML!Interface ( thisModule.newElements->includes(s)) to t : UML!Interface mapsTo s ( isRoot <- s.isRoot, isAbstract <- s.isAbstract, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeDataType { from s : UML!DataType ( if thisModule.newElements->includes(s) then s.oclIsTypeOf(UML!DataType) else false endif) to t : UML!DataType mapsTo s ( isRoot <- s.isRoot, isAbstract <- s.isAbstract, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeComponent { from s : UML!Component( thisModule.newElements->includes(s)) to t : UML!Component mapsTo s ( isSpecification <- s.isSpecification, visibility <- s.visibility, name <- s.name, isAbstract <- s.isAbstract, isLeaf <- s.isLeaf, isRoot <- s.isRoot, constraint <- s.constraint, comment <- s.comment, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergePackage { from s : UML!Package ( if thisModule.newElements->includes(s) then s.oclIsTypeOf(UML!Package) else false endif) to t : UML!Package mapsTo s ( isRoot <- s.isRoot, isAbstract <- s.isAbstract, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeAssociationEnd { from s : UML!AssociationEnd ( if thisModule.mergeElements->includes(s) then if s.oclIsTypeOf(UML!AssociationEnd) then s.notInSourceModel() else false endif else false endif) to t : UML!AssociationEnd mapsTo s ( association <- s.association, targetScope <- s.targetScope, isNavigable <- s.isNavigable, ordering <- s.ordering, changeability <- s.changeability, multiplicity <- s.multiplicity, aggregation <- s.aggregation, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, qualifier <- s.qualifier, participant <- if thisModule.newElements->includes(s.participant) then s.participant else s.participant.fromSourceModel() endif, comment <- s.comment, constraint <- s.constraint, specification <- s.specification->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif)) } rule MergeAttribute { from s : UML!Attribute ( if thisModule.mergeElements->includes(s) then s.notInSourceModel() else false endif) to t : UML!Attribute mapsTo s ( owner <- if thisModule.newElements->includes(s.owner) then s.owner else s.owner.fromSourceModel() endif, targetScope <- s.targetScope, initialValue <- s.initialValue, ownerScope <- s.ownerScope, visibility <- s.visibility, changeability <- s.changeability, ordering <- s.ordering, name <- s.name, isSpecification <- s.isSpecification, multiplicity <- s.multiplicity, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), type <- if thisModule.newElements->includes(s.type) then s.type else s.type.fromSourceModel() endif) } rule MergeGeneralization { from s : UML!Generalization ( thisModule.newElements->includes(s)) to t : UML!Generalization mapsTo s ( discriminator <- s.discriminator, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, templateParameter <- s.templateParameter, comment <- s.comment, powertype <- if s.powertype.oclIsUndefined() then s.powertype else if thisModule.newElements->includes(s.powertype) then s.powertype else s.powertype.fromSourceModel() endif endif, parent <- if thisModule.newElements->includes(s.parent) then s.parent else s.parent.fromSourceModel() endif, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), child <- if thisModule.newElements->includes(s.child) then s.child else s.child.fromSourceModel() endif, namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeDependency { from s : UML!Dependency ( if thisModule.newElements->includes(s) then s.oclIsTypeOf(UML!Dependency) else false endif) to t : UML!Dependency mapsTo s ( visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, comment <- s.comment, client <- s.client->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), supplier <- s.supplier->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeTagDefinition { from s : UML!TagDefinition ( thisModule.newElements->includes(s)) to t : UML!TagDefinition mapsTo s ( owner <- if thisModule.newElements->includes(s.owner) then s.owner else s.owner.fromSourceModel() endif, tagType <- s.tagType, multiplicity <- s.multiplicity, visibility <- s.visibility, name <- s.name, isSpecification <- s.isSpecification, templateParameter <- s.templateParameter, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeStereotype { from s : UML!Stereotype ( thisModule.newElements->includes(s)) to t : UML!Stereotype mapsTo s ( isRoot <- s.isRoot, isAbstract <- s.isAbstract, baseClass <- s.baseClass, visibility <- s.visibility, name <- s.name, icon <- s.icon, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, comment <- s.comment, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), stereotypeConstraint <- s.stereotypeConstraint, namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } rule MergeMethod { from s : UML!Method ( if thisModule.mergeElements->includes(s) then s.notInSourceModel() else false endif) to t : UML!Method mapsTo s ( owner <- if thisModule.newElements->includes(s.owner) then s.owner else s.owner.fromSourceModel() endif, body <- s.body, ownerScope <- s.ownerScope, visibility <- s.visibility, isQuery <- s.isQuery, name <- s.name, isSpecification <- s.isSpecification, comment <- s.comment, specification <- s.specification, constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif)) } rule MergeException { from s : UML!Exception ( thisModule.newElements->includes(s)) to t : UML!Exception mapsTo s ( isRoot <- s.isRoot, name <- s.name, isAbstract <- s.isAbstract, visibility <- s.visibility, isSpecification <- s.isSpecification, isLeaf <- s.isLeaf, "context" <- s."context"->collect(e|if e.notInSourceModel() then e else e.fromSourceModel() endif), constraint <- s.constraint, stereotype <- s.stereotype->collect(e|if thisModule.newElements->includes(e) then e else e.fromSourceModel() endif), comment <- s.comment, namespace <- if thisModule.newElements->includes(s.namespace) then s.namespace else s.namespace.fromSourceModel() endif) } -- ====================================================================== -- model merge end -- ====================================================================== -- ====================================================================== -- -- End model merging section -- -- ====================================================================== -- ====================================================================== -- model-specific helpers begin -- ====================================================================== helper def : accessor : Set(UML!Stereotype) = 'accessor'.stereotype(); helper def : oclInteger : UML!DataType = 'Integer'.dataType(); helper context String def : dataType() : UML!DataType = UML!DataType.allInstances()->select(c|c.name=self)->select(d| thisModule.inElements->includes(d) or thisModule.newElements->includes(d))->first(); helper context String def : stereotype() : Set(UML!Stereotype) = UML!Stereotype.allInstances()->select(s|s.name=self)->select(d| thisModule.inElements->includes(d) or thisModule.newElements->includes(d)); helper context UML!AssociationEnd def : isSingle() : Boolean = self.multiplicity.range->select(r|r.upper<>1)->isEmpty(); helper context UML!AssociationEnd def : otherEnd() : UML!AssociationEnd = self.association.connection->select(x|x<>self)->first(); helper context UML!AssociationEnd def : navigableFrom() : UML!Classifier = self.otherEnd().participant; helper context UML!Attribute def : hasAssociationEnd() : Boolean = not UML!AssociationEnd.allInstances()->select(a| a.name=self.name and a.navigableFrom()=self.owner)->isEmpty(); helper context UML!Attribute def : associationEnd() : UML!AssociationEnd = UML!AssociationEnd.allInstances()->select(a| a.name=self.name and a.navigableFrom()=self.owner)->first(); helper context UML!Attribute def : originalType() : UML!Classifier = if self.hasAssociationEnd() then self.associationEnd().participant else self.type endif; helper context UML!Attribute def : dualSetter() : String = if not self.associationEnd().otherEnd().isNavigable then self.name.javaSetter() else if self.associationEnd().otherEnd().isSingle() then self.name.javaDualSetter(self.associationEnd().otherEnd().name.firstToUpper()) else self.name.javaAddRemoveSetter(self.associationEnd().otherEnd().name.firstToUpper()) endif endif; helper context UML!Attribute def : setter() : String = if self.hasAssociationEnd() then self.dualSetter() else self.name.javaSetter() endif; helper context UML!Attribute def : dualAdder() : String = if not self.associationEnd().otherEnd().isNavigable then self.name.javaAdder() else if self.associationEnd().otherEnd().isSingle() then self.name.javaSetterAdder(self.associationEnd().otherEnd().name.firstToUpper()) else self.name.javaDualAdder(self.associationEnd().otherEnd().name.firstToUpper()) endif endif; helper context UML!Attribute def : dualInsert() : String = if not self.associationEnd().otherEnd().isNavigable then self.name.javaInsert() else if self.associationEnd().otherEnd().isSingle() then self.name.javaSetterInsert(self.associationEnd().otherEnd().name.firstToUpper()) else self.name.javaDualInsert(self.associationEnd().otherEnd().name.firstToUpper()) endif endif; helper context UML!Attribute def : adder() : String = if self.hasAssociationEnd() then self.dualAdder() else self.name.javaAdder() endif; helper context UML!Attribute def : insert() : String = if self.hasAssociationEnd() then self.dualInsert() else self.name.javaInsert() endif; helper context UML!Attribute def : dualRemover() : String = if not self.associationEnd().otherEnd().isNavigable then self.name.javaRemover() else if self.associationEnd().otherEnd().isSingle() then self.name.javaSetterRemover(self.associationEnd().otherEnd().name.firstToUpper()) else self.name.javaDualRemover(self.associationEnd().otherEnd().name.firstToUpper()) endif endif; helper context UML!Attribute def : remover() : String = if self.hasAssociationEnd() then self.dualRemover() else self.name.javaRemover() endif; -- ====================================================================== -- model-specific helpers end -- ====================================================================== -- ====================================================================== -- transformation rules begin -- ====================================================================== rule PublicAttributeSingle { from s : UML!Attribute ( if thisModule.inElements->includes(s) then s.visibility = #vk_public and not s.type.name.isCollection() else false endif) using { vis : UML!VisibilityKind = if s.visibility = #vk_public then #vk_private else s.visibility endif; baseName : String = s.name.firstToUpper(); endS : String = s.type.name.s(); } to t : UML!Attribute mapsTo s ( owner <- s.owner, multiplicity <- s.multiplicity, initialValue <- s.initialValue, changeability <- s.changeability, name <- s.name, ordering <- s.ordering, visibility <- vis, isSpecification <- s.isSpecification, targetScope <- s.targetScope, ownerScope <- s.ownerScope, stereotype <- s.stereotype, templateParameter <- s.templateParameter, comment <- s.comment, constraint <- s.constraint, targetFlow <- s.targetFlow, taggedValue <- s.taggedValue, clientDependency <- s.clientDependency, type <- s.type, sourceFlow <- s.sourceFlow), -- Set -- setOp : UML!Operation ( name <- 'set' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), setPar : UML!Parameter ( name <- s.name, behavioralFeature <- setOp, type <- s.type, kind <- #pdk_in), setMbody : UML!ProcedureExpression ( language <- 'java', body <- s.setter()), setMeth : UML!Method ( owner <- s.owner, body <- setMbody, specification <- setOp), setDep : UML!Dependency ( name <- 'accessor ' + 'set' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- setOp, supplier <- s), -- Get -- getOp : UML!Operation ( name <- 'get' + baseName + endS, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), getPar : UML!Parameter ( name <- 'return', behavioralFeature <- getOp, type <- s.type, kind <- #pdk_return), getMbody : UML!ProcedureExpression ( language <- 'java', body <- s.name.javaGetter()), getMeth : UML!Method ( owner <- s.owner, body <- getMbody, specification <- getOp), getDep : UML!Dependency ( name <- 'accessor ' + 'get' + baseName + endS + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- getOp, supplier <- s) } rule PublicAttributeSequence { from s : UML!Attribute ( if thisModule.inElements->includes(s) then s.visibility = #vk_public and s.type.name.isSequence() else false endif) using { vis : UML!VisibilityKind = if s.visibility = #vk_public then #vk_private else s.visibility endif; baseName : String = s.name.firstToUpper(); endS : String = s.type.name.s(); originalType : UML!Classifier = s.originalType(); } to t : UML!Attribute mapsTo s ( owner <- s.owner, multiplicity <- s.multiplicity, initialValue <- s.initialValue, changeability <- s.changeability, name <- s.name, ordering <- s.ordering, visibility <- vis, isSpecification <- s.isSpecification, targetScope <- s.targetScope, ownerScope <- s.ownerScope, stereotype <- s.stereotype, templateParameter <- s.templateParameter, comment <- s.comment, constraint <- s.constraint, targetFlow <- s.targetFlow, taggedValue <- s.taggedValue, clientDependency <- s.clientDependency, type <- s.type, sourceFlow <- s.sourceFlow), -- Get -- getOp : UML!Operation ( name <- 'get' + baseName + endS, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), getPar : UML!Parameter ( name <- 'return', behavioralFeature <- getOp, type <- s.type, kind <- #pdk_return), getMbody : UML!ProcedureExpression ( language <- 'java', body <- s.name.javaGetter()), getMeth : UML!Method ( owner <- s.owner, body <- getMbody, specification <- getOp), getDep : UML!Dependency ( name <- 'accessor ' + 'get' + baseName + endS + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- getOp, supplier <- s), -- Add -- addOp : UML!Operation ( name <- 'add' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), addPar : UML!Parameter ( name <- s.name, behavioralFeature <- addOp, type <- originalType, kind <- #pdk_in), addMbody : UML!ProcedureExpression ( language <- 'java', body <- s.adder()), addMeth : UML!Method ( owner <- s.owner, body <- addMbody, specification <- addOp), addDep : UML!Dependency ( name <- 'accessor ' + 'add' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- addOp, supplier <- s), -- Remove -- removeOp : UML!Operation ( name <- 'remove' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), removePar : UML!Parameter ( name <- s.name, behavioralFeature <- removeOp, type <- originalType, kind <- #pdk_in), removeMbody : UML!ProcedureExpression ( language <- 'java', body <- s.remover()), removeMeth : UML!Method ( owner <- s.owner, body <- removeMbody, specification <- removeOp), removeDep : UML!Dependency ( name <- 'accessor ' + 'remove' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- removeOp, supplier <- s), -- GetAt -- getAtOp : UML!Operation ( name <- 'get' + baseName + 'At', owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), getAtPar1 : UML!Parameter ( name <- 'index', behavioralFeature <- getAtOp, type <- thisModule.oclInteger, kind <- #pdk_in), getAtPar2 : UML!Parameter ( name <- 'return', behavioralFeature <- getAtOp, type <- originalType, kind <- #pdk_return), getAtMbody : UML!ProcedureExpression ( language <- 'java', body <- s.name.javaGetAt(originalType.qName())), getAtMeth : UML!Method ( owner <- s.owner, body <- getAtMbody, specification <- getAtOp), getAtDep : UML!Dependency ( name <- 'accessor ' + 'get' + baseName + 'At()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- getAtOp, supplier <- s), -- Insert -- insertOp : UML!Operation ( name <- 'insert' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), insertPar1 : UML!Parameter ( name <- s.name, behavioralFeature <- insertOp, type <- originalType, kind <- #pdk_in), insertPar2 : UML!Parameter ( name <- 'index', behavioralFeature <- insertOp, type <- thisModule.oclInteger, kind <- #pdk_in), insertMbody : UML!ProcedureExpression ( language <- 'java', body <- s.insert()), insertMeth : UML!Method ( owner <- s.owner, body <- insertMbody, specification <- insertOp), insertDep : UML!Dependency ( name <- 'accessor ' + 'insert' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- insertOp, supplier <- s) } rule PublicAttributeCollection { from s : UML!Attribute ( if thisModule.inElements->includes(s) then s.visibility = #vk_public and s.type.name.isCollection() and not s.type.name.isSequence() else false endif) using { vis : UML!VisibilityKind = if s.visibility = #vk_public then #vk_private else s.visibility endif; baseName : String = s.name.firstToUpper(); endS : String = s.type.name.s(); originalType : UML!Classifier = s.originalType(); } to t : UML!Attribute mapsTo s ( owner <- s.owner, multiplicity <- s.multiplicity, initialValue <- s.initialValue, changeability <- s.changeability, name <- s.name, ordering <- s.ordering, visibility <- vis, isSpecification <- s.isSpecification, targetScope <- s.targetScope, ownerScope <- s.ownerScope, stereotype <- s.stereotype, templateParameter <- s.templateParameter, comment <- s.comment, constraint <- s.constraint, targetFlow <- s.targetFlow, taggedValue <- s.taggedValue, clientDependency <- s.clientDependency, type <- s.type, sourceFlow <- s.sourceFlow), -- Get -- getOp : UML!Operation ( name <- 'get' + baseName + endS, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), getPar : UML!Parameter ( name <- 'return', behavioralFeature <- getOp, type <- s.type, kind <- #pdk_return), getMbody : UML!ProcedureExpression ( language <- 'java', body <- s.name.javaGetter()), getMeth : UML!Method ( owner <- s.owner, body <- getMbody, specification <- getOp), getDep : UML!Dependency ( name <- 'accessor ' + 'get' + baseName + endS + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- getOp, supplier <- s), -- Add -- addOp : UML!Operation ( name <- 'add' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), addPar : UML!Parameter ( name <- s.name, behavioralFeature <- addOp, type <- originalType, kind <- #pdk_in), addMbody : UML!ProcedureExpression ( language <- 'java', body <- s.adder()), addMeth : UML!Method ( owner <- s.owner, body <- addMbody, specification <- addOp), addDep : UML!Dependency ( name <- 'accessor ' + 'add' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- addOp, supplier <- s), -- Remove -- removeOp : UML!Operation ( name <- 'remove' + baseName, owner <- s.owner, visibility <- s.visibility, ownerScope <- s.ownerScope, isAbstract <- false, concurrency <- #cck_sequential), removePar : UML!Parameter ( name <- s.name, behavioralFeature <- removeOp, type <- originalType, kind <- #pdk_in), removeMbody : UML!ProcedureExpression ( language <- 'java', body <- s.remover()), removeMeth : UML!Method ( owner <- s.owner, body <- removeMbody, specification <- removeOp), removeDep : UML!Dependency ( name <- 'accessor ' + 'remove' + baseName + '()', namespace <- s.owner.namespace, stereotype <- thisModule.accessor, client <- removeOp, supplier <- s) } rule NonPublicAttribute { from s : UML!Attribute ( if thisModule.inElements->includes(s) then not (s.visibility = #vk_public) else false endif) to t : UML!Attribute mapsTo s ( owner <- s.owner, multiplicity <- s.multiplicity, initialValue <- s.initialValue, changeability <- s.changeability, name <- s.name, ordering <- s.ordering, visibility <- s.visibility, isSpecification <- s.isSpecification, targetScope <- s.targetScope, ownerScope <- s.ownerScope, stereotype <- s.stereotype, templateParameter <- s.templateParameter, comment <- s.comment, constraint <- s.constraint, targetFlow <- s.targetFlow, taggedValue <- s.taggedValue, clientDependency <- s.clientDependency, type <- s.type, sourceFlow <- s.sourceFlow) } -- ====================================================================== -- transformation rules end -- ======================================================================