Home » Modeling » Epsilon » EVL: Checking the existence of a relationship between two classifier
EVL: Checking the existence of a relationship between two classifier [message #1717385] |
Sat, 12 December 2015 15:05 |
Alireza Rouhi Messages: 148 Registered: December 2015 |
Senior Member |
|
|
Hi,
I like to check the existence of a relationship like an association between two classifiers in a UML model. For example, if a model had two classes named c1 and c2 which must be related by an association relationship, how to check this relationship in the EVL code?
I write the associates operation just as follows but its function is not correct!
operation Classifier associates (c: Classifier) : Boolean {
return self.ownedElements.exists(a: Association | a.associationEnds.includes(c));
}
[Updated on: Wed, 20 January 2016 16:53] Report message to a moderator
|
|
| | | | | | |
Re: EVL: Checking the existence of a relationship between two classifier [message #1720766 is a reply to message #1720737] |
Wed, 20 January 2016 19:38 |
Leandro Alexandre Messages: 5 Registered: January 2016 |
Junior Member |
|
|
Hi Dimitius! Off course!
@namespace(uri="twosml", prefix="twosml")
package Twosml;
@gmf.diagram
class ControlSchema {
val SmartSpace[1] csSmartSpace;
val UbiquitousApplication[*] csUbiApplication;
val UserRole[*] csUserRole;
val BehavioralPolicy[*] csPolicy;
val SmartObject[*] csSmartObject;
val Feature[*] csFeature;
val BehavioralAction[*] csBehAction;
val BehavioralCondition[*] csBehCondition;
val BehavioralEvent[*] csBehEvent;
val Service[*] csService;
val ModelingPolicy[*] csBehPolicy;
val ModelingEvent[*] csModEvent;
val ModelingCondition[*] csModCondition;
val ModelingAction[*] csModAction;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/smartSpace.svg", size="100,100")
class SmartSpace {
attr String name = "";
val HostsUserRole[*] hUR_SS;
val HasBehPolSS[*] hpBehPo_SS;
val HostsSmartObject[*] hSO_SS;
val HostsService[*] hSer_SS;
val HostsUbiApp[*] hUA_SS;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/ubiApp.svg", size="70,70")
class UbiquitousApplication {
attr String name;
attr String progLanguage;
val HasBehPolUbiApp[*] hpBehPo_UbiApp;
attr String category;
attr String superType;
attr String operatingSystem;
transient attr String ubiAppFeatures;
val HasModPolUbiApp[*] hpModPo_UbiApp;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class CanUseUbiApp {
ref UbiquitousApplication[*] fromUR_UA;
ref UserRole source;
ref UbiquitousApplication target;
attr Multiplicity ubiAppMult;
attr Multiplicity uRoleMult;
attr String name="canUse";
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/userRole.svg", size="70,70")
class UserRole {
attr String name;
val HasBehPolUserRole[*] hpBehPo_UR;
val CanUseSO[*] cuSO_UR;
val CanUseUbiApp[*] cuUA_UR;
val CanUseService[*] cuSe_UR;
attr String superType;
val HasModPolUserRole[*] hpModPo_UR;
val IsOwnerOfSO[*] isoSO_UR;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class HostsUserRole {
ref UserRole[*] fromSS_UR;
ref SmartSpace source;
ref UserRole target;
attr Multiplicity uRoleMult;
attr Multiplicity sSpaceMult;
attr String name="hosts";
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/behPolicy.svg", size="70,70")
class BehavioralPolicy {
attr String name;
val HasBehAct[*] hasBehAct_Po;
val HasBehCond[*] hasBehCon_Po;
val HasBehEv[*] hasPol_BehEv;
attr boolean overwrite;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasBehPolSS {
ref BehavioralPolicy[*] fromSS_BehPol;
ref SmartSpace source;
ref BehavioralPolicy target;
attr String name="has";
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/smartObject.svg", size="90,90")
class SmartObject {
attr String name;
val CanUseOtherSO[*] cuSO_SO;
val IsComposedOf[*] icoFeat_SO;
val HasBehPolSO[*] hpBehPo_SO;
attr String superType;
val HasModPolSO[*] hpModPo_SO;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class HostsSmartObject {
ref SmartObject[*] fromSS_SO;
ref SmartSpace source;
ref SmartObject target;
attr Multiplicity sObjectMult;
attr Multiplicity sSpaceMult;
attr String name="hosts";
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/service.svg", size="70,70")
class Service {
attr String name;
val HasBehPolSer[*] hpPo_Ser;
attr String superType = "";
transient attr String serviceFeatures;
val HasModPolSer[*] hpModPol_Ser;
}
class CanUseService {
ref Service[*] fromUR_Se;
attr Multiplicity serMult;
attr Multiplicity userRole;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/feature.svg", size="40,40")
class Feature {
attr String name;
attr FeatureCategory featureCategory;
attr FeatureType featureType;
attr String featureDescription;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="filledrhomb", style="dash")
class IsComposedOf {
ref Feature[*] fromSO_Feat;
ref SmartObject source;
ref Feature target;
attr Multiplicity sObjectMult;
attr Multiplicity featureMult;
attr String name="isComposedOf";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class CanUseOtherSO {
ref SmartObject[*] fromSO_SO;
ref SmartObject source;
ref SmartObject target;
attr Multiplicity sObjectMult1;
attr Multiplicity sObjectMult2;
attr String name="canUse";
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/behPolicyEvent.svg", size="50,50")
class BehavioralEvent {
attr String name;
attr String description;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/behPolicyAction.svg", size="50,50")
class BehavioralAction {
attr String name;
attr String description;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/behPolicyCondition.svg", size="50,50")
class BehavioralCondition {
attr String name;
attr String description;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasBehAct {
ref BehavioralAction[*] fromPol_BehAct;
ref BehavioralPolicy source;
ref BehavioralAction target;
attr String name="has";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasBehCond {
ref BehavioralCondition[*] fromPol_BehCon;
ref BehavioralPolicy source;
ref BehavioralCondition target;
attr String name="has";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasBehEv {
ref BehavioralEvent[*] fromPol_BehEv;
ref BehavioralPolicy source;
ref BehavioralEvent target;
attr String name="has";
}
class HasBehPolSer {
ref BehavioralPolicy[*] fromSer_Pol;
}
class HasBehPolUbiApp {
ref BehavioralPolicy[*] fromUbiApp_BehPol;
}
class HasBehPolUserRole {
ref BehavioralPolicy[*] fromUR_BehPol;
}
class HasBehPolSO {
ref BehavioralPolicy[*] fromSO_BehPol;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class CanUseSO {
ref SmartObject[*] fromUR_SO_CU;
ref UserRole source;
ref SmartObject target;
attr Multiplicity uRoleMult;
attr Multiplicity sObjectMult;
attr String name="canUse";
}
enum FeatureType {
SOFTWARE = 0;
HARDWARE = 1;
}
enum FeatureCategory {
IO_RESOURCE = 0;
SENSOR = 1;
ACTUATOR = 2;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class HostsService {
ref Service[*] fromSS_Ser;
ref SmartSpace source;
ref Service target;
attr Multiplicity sSpaceMult;
attr Multiplicity serMult;
attr String name="hosts";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class HostsUbiApp {
ref UbiquitousApplication[*] fromUA_SS;
ref SmartSpace source;
ref UbiquitousApplication target;
attr Multiplicity ubiAppMult;
attr Multiplicity sSpaceMult;
attr String name="hosts";
}
enum Multiplicity {
ZERO = 0;
ONE = 1;
TWO = 2;
THREE = 3;
FOUR = 4;
FIVE = 5;
TEN = 10;
TWENTY_FIVE = 25;
FIFTY = 50;
HUNDRED = 100;
FIVE_HUNDRED = 500;
THOUSAND = 1000;
ASTERISK = 10000;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/modPolicy.svg", size="70,70")
class ModelingPolicy {
attr String name;
attr Boolean overwrite;
val HasModAct[*] hasModAct_Po;
val HasModCond[*] hasModCond_Po;
val HasModEv[*] hasModEv_Po;
}
class HasModPolSer {
ref ModelingPolicy[*] fromSer_ModPol;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/modPolicyCondition.svg", size="50,50")
class ModelingCondition {
attr String name;
attr String description;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/modPolicyEvent.svg", size="50,50")
class ModelingEvent {
attr String name;
attr String description;
}
@gmf.node(figure="svg", label.icon="false", label="name", label.pattern="{0}", label.placement="external",
svg.uri="platform:/plugin/Language/icons/modPolicyAction.svg", size="50,50")
class ModelingAction {
attr String name;
attr String description;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasModCond {
ref ModelingCondition[*] fromPol_ModCond;
ref ModelingPolicy source;
ref ModelingCondition target;
attr String name="has";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasModEv {
ref ModelingEvent[*] fromPol_ModEv;
ref ModelingPolicy source;
ref ModelingEvent target;
attr String name="has";
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="dot")
class HasModAct {
ref ModelingAction[*] fromPol_ModAct;
ref ModelingPolicy source;
ref ModelingAction target;
attr String name="has";
}
class HasModPolUbiApp {
ref ModelingPolicy[*] fromUbiApp_ModPol;
}
class HasModPolSO {
ref ModelingPolicy[*] fromSO_ModPol;
}
class HasModPolUserRole {
ref ModelingPolicy[*] fromUR_ModPol;
}
@gmf.link(source="source", target="target", label="name", label.readOnly="true",
target.decoration="arrow", source.decoration="none", style="solid")
class IsOwnerOfSO {
ref SmartObject[*] fromUR_SO_ISO;
ref UserRole source;
ref SmartObject target;
attr Multiplicity uRoleMultiplicity;
attr Multiplicity sObject;
attr String name="isOwnerOf";
}
-
Attachment: twosml.emf
(Size: 11.27KB, Downloaded 70 times)
|
|
|
Re: EVL: Checking the existence of a relationship between two classifier [message #1720767 is a reply to message #1720766] |
Wed, 20 January 2016 19:42 |
Leandro Alexandre Messages: 5 Registered: January 2016 |
Junior Member |
|
|
Dimitrius,
I need to check whether a UserRole, for example, "father" (M1 level), is associated with a set of SmartObjects, for example, "smartphone", "tablet", and "smartTV" (level M1). In other works, I want to force the UserRole "father" to associate the "smartphone", "tablet", and "smartTV".
[Updated on: Wed, 20 January 2016 19:44] Report message to a moderator
|
|
| | |
Re: EVL: Checking the existence of a relationship between two classifier [message #1720854 is a reply to message #1720841] |
Thu, 21 January 2016 13:00 |
|
Hi Leandro,
In this case, you'd need a constraint like the one below.
context UserRole {
constraint FatherHasParticularSmartObjects {
guard : self.name = "father"
check {
var samsungTv = SmartObject.all.selectOne(o|o.name = "samsungTV");
var galaxy = ...;
var smartObjects = Sequence{samsungTv, galaxy};
return self.isoSO_UR.from_UR_SO_ISO.flatten().includesAll(smartObjects);
}
}
}
Cheers,
Dimitris
|
|
| |
Goto Forum:
Current Time: Sat Apr 20 02:41:52 GMT 2024
Powered by FUDForum. Page generated in 0.03202 seconds
|