-- @path PLAOVgraph=/MaRiPLAM2M/Metamodels/PLAOVgraph.ecore
-- @path PLAspectualACME=/MaRiPLAM2M/Metamodels/PLAspectualACME.ecore module Arq2Req;
create plaovgraph : PLAOVgraph from plaspectualacme : PLAspectualACME; uses Helpers;
-- 01 -- Regra que transforma Family em GoalModel rule root {
from
fam : PLAspectualACME!Family to
goal : PLAOVgraph!Aspect_Oriented_Model (
goalmodel <- fam.systems->collect(s | thisMo- dule.sys2goal(s))
) }
-- 02 -- Regra que transforma System filho da Family em Goal Model lazy rule sys2goal {
from sys : PLAspectua- lACME!System(sys.refImmediateComposite().oclIsTypeOf(PLAspectualACME!Family )) to goal : PLAOVgraph!Goal_Model ( name <- sys.name, element <- sys.component,
relationship <- sys.anExc.asOrderedSet()-> collect(a |
thisModule.anExc2corr(a)),
relationship <- sys.anReq.asOrderedSet()-> collect(a |
thisModule.anReq2corr(a)),
relationship <- sys.component -> collect(e |
e.property.asOrderedSet()->select(p | p.key.startsWith('correlation'))- >collect(c | thisModule.prop2correlation(c))),
property <- sys.property.asOrderedSet()->select(p | p.key='is feature')->collect(c | thisModule.prop2isfeat(c)),
property <- sys.property.asOrderedSet()->select(p | p.key='cardinality')->collect(c | thisModule.prop2card(c)),
property <- sys.property.asOrderedSet()->select(p | p.key='group feature')->collect(c | thisModule.prop2group(c)),
property <- sys.property.asOrderedSet()->select(p | not (p.key='group feature'or p.key='cardinality' or p.key='is feature' or p.key.startsWith('correlation') or p.key='elementType' or
p.key='variants'))->collect(c | thisModule.property(c)),
relationship <- sys.connector.asOrderedSet()->collect(con
| thisModule.conn2Cross(con))
) }
-- 03 -- Component pra Task primeiro nivel 'and' com ou sem filhos rule comp2task {
from
comp : PLAspectua-
ypeOf(PLAspectualACME!Family) and not comp.hasElementType()) to elem : PLAOVgraph!Element ( name <- comp.name, type <- 'task', relationship <- valContribution, element <- comp.representation, property <- comp.property.asOrderedSet()->select(p | p.key='is feature')->collect(c | thisModule.prop2isfeat(c)),
property <- comp.property.asOrderedSet()->select(p | p.key='cardinality')->collect(c | thisModule.prop2card(c)),
property <- comp.property.asOrderedSet()->select(p | p.key='group feature')->collect(c | thisModule.prop2group(c)),
property <- comp.property.asOrderedSet()->select(p | not (p.key='group feature'or p.key='cardinality' or p.key='is feature' or p.key.startsWith('correlation') or p.key='elementType' or
p.key='variants'))->collect(c | thisModule.property(c)) ), valContribution : PLAOVgraph!Contribution ( source <- elem.refImmediateComposite(), target <- elem, label <- if comp.oclIsTypeOf(PLAspectualACME!OptionalT) then 'or' else if
comp.oclIsTypeOf(PLAspectualACME!AlternativeT) then 'xor' else
if
comp.oclIsTypeOf(PLAspectualACME!InclusiveOrT) then 'inc-or' else 'and' en- dif
endif endif )
}
-- 04 -- Component pra Element primeiro nivel 'and' com ou sem filhos rule comp2element {
from
comp : PLAspectua-
lACME!Component(comp.refImmediateComposite().refImmediateComposite().oclIsT ypeOf(PLAspectualACME!Family) and comp.hasElementType())
to elem : PLAOVgraph!Element ( name <- comp.name, type <- comp.getElementType(), relationship <- valContribution, element <- comp.representation, property <- comp.property.asOrderedSet()->select(p | p.key='is feature')->collect(c | thisModule.prop2isfeat(c)),
property <- comp.property.asOrderedSet()->select(p | p.key='cardinality')->collect(c | thisModule.prop2card(c)),
property <- comp.property.asOrderedSet()->select(p | p.key='group feature')->collect(c | thisModule.prop2group(c)),
property <- comp.property.asOrderedSet()->select(p | not (p.key='group feature'or p.key='cardinality' or p.key='is feature' or p.key.startsWith('correlation') or p.key='elementType' or
p.key='variants'))->collect(c | thisModule.property(c)) ),
valContribution : PLAOVgraph!Contribution ( source <- elem.refImmediateComposite(), target <- elem,
label <- if comp.oclIsTypeOf(PLAspectualACME!OptionalT) then 'or'
else if
comp.oclIsTypeOf(PLAspectualACME!AlternativeT) then 'xor' else
if
comp.oclIsTypeOf(PLAspectualACME!InclusiveOrT) then 'inc-or' else 'and' en- dif
endif endif )
}
-- 05 - Representation para element rule rep2task { from rep : PLAspectualACME!Representation to elem : PLAOVgraph!Element ( name <- rep.name,
element <- rep.system.component -> collect(a | a.representation),
type <- if rep.system.component->collect(c | c.hasElementType()) then rep.system.component->collect(c | c.getElementType()) else 'task' endif,
relationship <- valContribution,
property <- rep.system.component -> collect(comp | comp.property.asOrderedSet()->select(p | p.key='is feature')->collect(c |
thisModule.prop2isfeat(c))),
property <- rep.system.component -> col-
lect(comp|comp.property.asOrderedSet()->select(p | p.key='cardinality')- >collect(c | thisModule.prop2card(c))),
property <- rep.system.component -> col-
lect(comp|comp.property.asOrderedSet()->select(p | p.key='group feature')- >collect(c | thisModule.prop2group(c))),
property <- rep.system.component ->
collect(comp|comp.property.asOrderedSet()->select(p | not (p.key='group feature'or p.key='cardinality' or p.key='is feature' or
p.key.startsWith('correlation') or p.key='elementType' or p.key='variants'))->collect(c | thisModule.property(c)))
), valContribution : PLAOVgraph!Contribution ( source <- elem.refImmediateComposite(), target <- elem, label <- if (rep.system.component.first().oclIsTypeOf(PLAspectualACME!OptionalT)) then 'or' else if (rep.system.component.first().oclIsTypeOf(PLAspectualACME!AlternativeT)) then 'xor' else if (rep.system.component.first().oclIsTypeOf(PLAspectualACME!InclusiveOrT)) then 'inc-or' else 'and' endif endif endif )
}
-- 06 - Analysis Excludes pra correlation break lazy rule anExc2corr {
from anExc : PLAspectualACME!AnalysisExcludes to corr : PLAOVgraph!Correlation ( label <- 'break', source <- if
anExc.source.oclIsTypeOf(PLAspectualACME!Representation) then anExc.source else anExc.source.refImmediateComposite().refImmediateComposite() endif,
target <- if
anExc.target.oclIsTypeOf(PLAspectualACME!Representation) then anExc.target else anExc.target.refImmediateComposite().refImmediateComposite() endif
) }
-- 07 - Analysis Requires pra correlation make lazy rule anReq2corr {
from anReq : PLAspectualACME!AnalysisRequires to corr : PLAOVgraph!Correlation ( label <- 'make', source <- if an-
Req.source.oclIsTypeOf(PLAspectualACME!Representation) then anReq.source else anReq.source.refImmediateComposite().refImmediateComposite() endif,
target <- if an-
Req.target.oclIsTypeOf(PLAspectualACME!Representation) then anReq.target else anReq.target.refImmediateComposite().refImmediateComposite() endif
) }
-- 08 - Regra que transforma property correlation de PLAspectualACME em Re- lationship Correlation de PLAOVgraph
lazy rule prop2correlation { from
prop : PLAspectua-
lACME!Property(prop.key.startsWith('correlation')) to
corr : PLAOVgraph!Correlation (
label <- prop.key.substring(13, prop.key.size()), source <- prop.refImmediateComposite(),
target <- prop.type )
}
-- 09 -- Regra que transforma property isfeature de PLAspectualACME em pro- perty isfeature de PLAOVgraph
lazy rule prop2isfeat { from
prop : PLAspectualACME!Property (prop.key='is feature') to
isfeat : PLAOVgraph!IsFeature ( label <- prop.value
) }
-- 10 -- Regra que transforma property cardinality de PLAspectualACME em property cardinality de PLAOVgraph
from
prop : PLAspectualACME!Property (prop.key='cardinality') to card : PLAOVgraph!Cardinality ( cardinalityMin <- prop.value.substring(5, 6), cardinalityMax <- prop.value.substring(11, prop.value.size()) ) }
-- 11 -- Regra que transforma property groupfeature de PLAspectualACME em property groupfeature de PLAOVgraph
lazy rule prop2group { from
prop : PLAspectualACME!Property (prop.key='group feature') to group : PLAOVgraph!GroupFeature ( cardinalityGroupMin <- prop.value.substring(12, 13), cardinalityGroupMax <- prop.value.substring(25, prop.value.size()), source <- prop.type ) }
-- 12 -- Regra que transforma property de PLAspectualACME em generic prop- erty de PLAOVgraph
lazy rule property { from
prop : PLAspectualACME!Property (not (prop.key='group feature'
or prop.key='cardinality' or prop.key='is feature' or prop.key.startsWith('correlation')
or
prop.key='operand' or prop.key='operator' or prop.key='elementType' or prop.key='variants')) to gen : PLAOVgraph!Generic_Property ( name <- prop.key, value <- prop.value ) }
-- 13 -- Regra que transforma aspectual connector de PLAspectualACME em crosscutting relationship de PLAOVgraph
lazy rule conn2Cross { from conn : PLAspectualACME!Connector to cross : PLAOVgraph!Crosscutting ( advice <- advice, intertype <- conn.property.asOrderedSet()->select(p | p.key='Intertype Declaration')->asOrderedSet(),
pointcut <- pointcut, source <- conn.role->select(r | r.oclIsTypeOf(PLAspectualACME!CrosscuttingRole))->collect(cr | cr.refPort) ), advice : PLAOVgraph!Advice ( idPointcut <- pointcut, joinpointAdvice <- conn.role->select(r | r.oclIsTypeOf(PLAspectualACME!CrosscuttingRole))->collect(cr | cr.refPort), type <- conn.glue -> collect(g | g.glueType)
), pointcut : PLAOVgraph!Pointcut( name <- conn.name.concat('Pc'), operand <- operand ), operand : PLAOVgraph!Operand(
joinpointPointcut <- conn.role -> select(r | r.oclIsTypeOf(PLAspectualACME!BaseRole))->collect(br | br.refPort),
operator <- operator,
primitive <- conn.role -> select(r | r.oclIsTypeOf(PLAspectualACME!BaseRole))->collect(br |
br.property.asOrderedSet()->select(p | p.key='operand')->collect(op | op.value))
),
operator : PLAOVgraph!Operator(
operator <- conn.role -> select(r | r.oclIsTypeOf(PLAspectualACME!BaseRole))->collect(br |
br.property.asOrderedSet()->select(p | p.key='operator')->collect(op | op.value))
) }