OCl to check whether link is coming form source feature defined(Please Help)) [message #220849] |
Tue, 10 March 2009 07:56 |
|
Hi All
I have many link mappings defined
1. LinkMapping <LINK{LINK.Asource:A->LINK.Adestination:A}/LINK>
Element EClass LINK
SourceFeature :ERefrenceAsource
TargetFeature :ERefrenceAdestination
DIagram Link Connection LINK
2. LinkMapping <LINK{LINK.Bsource:B->LINK.Bdestination:B}/LINK>
Element EClass LINK
SourceFeature :ERefrenceBsource
TargetFeature :ERefrenceBdestination
DIagram Link Connection LINK
how can i add a constraint to check that the link created is always from
Asource to Adestination when i connect Asource to Adestination . similarly
link create is from BSource to BDestination when i connect Bsource to
Bdestination
Since same class LINK is used to connect.
Without constraint it always ececutes first link mapping.
Please help.
Thanks and Regards
Govind
|
|
|
|
Re: OCl to check whether link is coming form source feature defined(Please Help) [message #221106 is a reply to message #221098] |
Tue, 10 March 2009 16:46 |
|
Hi Alex,
Thanks for the suggestion.
This i had thought that i have specify the OCL.
This the same Linking Mapping Issue which i had posted which is working
now with below code.
I added some constraints and checks
if (XXXPackage.eINSTANCE.getLink().isSuperTypeOf(
domainElement.eClass())&& (domainElement == null ||
isLinkWithClassLink_3001((LINK) domainElement))) {
return LINKEditPart.VISUAL_ID;
}
I added && condition check as it was always checking in first if-block
,now with && the condition its working.
private static boolean isLinkWithClassLINK_3001(LINK element) {
if(element.getAsrc()!= null&& element.getBdest()!=null){
return true;
}else{
return false;
}
}
For the all the links in
public static int getLinkWithClassVisualID(EObject domainElement) method
of XXXVisualIDRegistry.
Now All the link are working properly.
Is it the right approach
Regards
Govind R
|
|
|
Powered by
FUDForum. Page generated in 0.03241 seconds