Select the features to be transformed using if else statements in rules [message #1831167] |
Wed, 12 August 2020 21:18 |
Burak Karaduman Messages: 84 Registered: July 2018 |
Member |
|
|
Dear All,
rule SystemToIoTSystem {
from
pim: PIM!System
to
iot: PSM!IoTSystem (
Name <- 'DesignIoTSystem',
platformR <- pim.direct,
logman <- pim.logger,
gateway <- pim.datacollector,
[b]platform <- if pim.indirect->size() >0 then
pim.indirect
else
OclUndefined
endif[/b]
)
}
I already implemented using not a modular implementation.
It transforms pim.indirect to platform if the size of the usage is above 0 and else is OclUndefined, this rule works well Hoverwever, what I am trying to achieve is to make it more modular and functional as well as eliminating code repetition.
rule SystemToIoTSystem {
from
pim: PIM!System
to
iot: PSM!IoTSystem (
Name <- 'DesignIoTSystem',
logman <- pim.logger,
gateway <- pim.datacollector,
[b] if pim.indirect->size() >0 then
platform <- pim.indirect
else
platformR <- pim.direct,
endif
[/b]
)
}
How can I make something like this, It gives errors. I also tried to do in "do { }". However it did not let me to use any feature mapping like " platformR <- pim.direct ".
|
|
|
Re: Select the features to be transformed using if else statements in rules [message #1831325 is a reply to message #1831167] |
Mon, 17 August 2020 12:57 |
|
You can implement both scenarios in a separate rule, and use filter expressions in the "from" part to trigger the correct rule. To eliminate duplicate code, you can use rule inheritance:
-- @atlcompiler emftvm
module SystemToIoTSystem;
create OUT: PSM from IN: PIM;
abstract rule SystemToIoTSystem {
from
pim: PIM!System
to
iot: PSM!IoTSystem (
name <- 'DesignIoTSystem',
logman <- pim.logger,
gateway <- pim.datacollector
)
}
rule SystemToIoTSystemDirect extends SystemToIoTSystem {
from
pim: PIM!System (
pim.indirect->isEmpty()
)
to
iot: PSM!IoTSystem (
platformR <- pim.direct
)
}
rule SystemToIoTSystemIndirect extends SystemToIoTSystem {
from
pim: PIM!System (
pim.indirect->notEmpty()
)
to
iot: PSM!IoTSystem (
platform <- pim.indirect
)
}
Cheers,
Dennis
|
|
|
Powered by
FUDForum. Page generated in 0.01977 seconds