Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Monsieur on November 28, 2014, 01:12:02 am
-
Hello all!
I have created my own profile, toolbox, diagram (as now encouraged in the new EA). [smiley=beer.gif] [smiley=beer.gif]
My profile is composed of a few elements (my packages, my elements, my connectors) by extending the correspondent metaclass.
Today i can create the links however I want whatever I want, where ever i want, and that’s my problem!!
Does anyone know how to restrain one link to 2 object types (or stereotype?)
One solution seems to be to use OCL (at is now done in the EA11.1) to do it, as it is used by the "Model Validation" (MRxxxxx)
I don’t know if I made myself clear :-[ . but I can give more explication s :D
ps: i also want to restrain the type of object that i can put under a package (for example only requirement under a "requirement" typed package)
ps2: Today I work on EA9.3 (booooooooo) and i am testing EA11.1 (corporate) in order to upgrade (maybe?) if the new feature has a real interest.
ps3: I am a newbie at customizing EA. Please be as detailed as you can be!
-
OCL wont help you further since EA does not interpret it but only checks the syntax. The only way I see for you is to create an add-in and subscribe to the EA_On... events.
q.
-
If you are creating an MDG then you can add Quicklinker "rules" for your diagram(s) element(s)
It's a little tedious and will need some fine tuning to get it perfect, but it can be made to work
Details are in the Help or User Guide
Of course the use of a Quicklinker just populates a menu with what is valid, it cannot enforce a correct link.
For that, as has been posted previously you need a script (which can monitor the event of the connector being created and take appropriate action, or a script / add-in that validates the model after it has been corrected.
Cheers
Phil
-
OCL wont help you further since EA does not interpret it but only checks the syntax. The only way I see for you is to create an add-in and subscribe to the EA_On... events.
q.
It should be a way (maybe an other than OCL).
I'll give you an example of what i want (scenario in EA11.1):
If i place myself in a requirement diagram and I create 2 objects from different types (could be from different toolboxes) and I try to create a link whose not compliant with the 2 objects EA propose me as a pop up a compliant link. if i click on the diagram (as the compliant links doesn't suit me) then a pop up inform me "The requested connection is not UML compliant"
I tried between a requirement and a package with a link from "metatmodel relationship" on a requirement diagram (all default EA).
I wish to have that kind of restriction on my custom diagram/elements/packages/....
This kind of restriction is needfull to keep the user to respect the metamodel, that's why i need it.
-
If you are creating an MDG then you can add Quicklinker "rules" for your diagram(s) element(s)
It's a little tedious and will need some fine tuning to get it perfect, but it can be made to work
Details are in the Help or User Guide
Of course the use of a Quicklinker just populates a menu with what is valid, it cannot enforce a correct link.
For that, as has been posted previously you need a script (which can monitor the event of the connector being created and take appropriate action, or a script / add-in that validates the model after it has been corrected.
Cheers
Phil
Thanks Phil, I’ll look into the quicklinker rules ASAP hoping that will block incorrect moves of the user (for example wrong use of the link, or wrong direction or ...)
-
The quick linker will not really constrain possible links. It just offers the most convenient ones in a context. To actually constraint things you need to write an add-in.
q.
-
The quick linker will not really constrain possible links. It just offers the most convenient ones in a context. To actually constraint things you need to write an add-in.
q.
Is there a way to constrain possible link the way at is in the little scenario of my previous post? [smiley=rolleyes.gif] :question :question
Is it mandatory to use an Add in?
If so, do someone have a few website to recommend in order for me to make my first add in (something easy :-/) ? [smiley=vrolijk_26.gif]
-
Addins are the only way to go in your case. Refer to Geert Bellekens blog post about writing an add-in (and my Scripting book if you want to get a quick start with the API).
q.
-
The quick linker will not really constrain possible links. It just offers the most convenient ones in a context. To actually constraint things you need to write an add-in.
q.
Is there a way to constrain possible link the way at is in the little scenario of my previous post? [smiley=rolleyes.gif] :question :question
Is it mandatory to use an Add in?
If so, do someone have a few website to recommend in order for me to make my first add in (something easy :-/) ? [smiley=vrolijk_26.gif]
This page: Writing EA Addins (http://bellekens.com/writing-ea-add-ins/) lists all you need to know to get started.
Geert
-
The quick linker will not really constrain possible links. It just offers the most convenient ones in a context. To actually constraint things you need to write an add-in.
q.
Is there a way to constrain possible link the way at is in the little scenario of my previous post? [smiley=rolleyes.gif] :question :question
Is it mandatory to use an Add in?
If so, do someone have a few website to recommend in order for me to make my first add in (something easy :-/) ? [smiley=vrolijk_26.gif]
This page: Writing EA Addins (http://bellekens.com/writing-ea-add-ins/) lists all you need to know to get started.
Geert
Ty Geert
-
LITTLE UP (or down?)
I never made the quicklinker work... I must be really bad :-[ .
Here are my columns... i don't know if they are the right ones:
Source Element Type Source ST filter Target Element Type Target ST Filter Diagram Filter New Element Type New Element ST New Link Type New Link ST New Link Direction New Link Caption New Link & Element Caption Create Link Create Element Disallow Self connector Exclusiveto ST Filter + No inherit from metatype Menu Group Complexity Level Target Must Be Parent Embed element Preceeds Separator LEAF Preceeds Separator GROUP
Can some one send me his xls, so i try?
Or maybe give a little help on the process (like a step by step tutorial)?
I know i am asking a lot, but that be very helpfull... i am a bit desperate about this :'( :-/
Ps: Querty, i am reading your books, what is the t_connectorconstraint table? Could it help me to restrain the link to 2 objecttype? using sourceelement(or better sourceStereotype) and destelement (DestStereotype)?
-
Yep, the QL is a PITA. It took me ages to get it work. Start with a single connector and vary the parameters. Takes a lot of time.
The table you're asking for is likely heritage. Even in the Example Model provided by Sparx it contains nothing.
q.
-
t_connectorcontstraint = Constraints page of connector properties.
-
t_connectorcontstraint = Constraints page of connector properties.
Hmm. That leads to the question: where is this page? I just searched a looong moment for the settings menu (yes, this is the "where is my menu in the new EA release"-question). But could not find a related entry.
q.
-
Connector properties - double-click on a connector and select the Constraints page or tab.
-
Thanks. That made be a bit wiser today :D Still so many places in EA where I have almost never been.
q.
-
t_connectorcontstraint = Constraints page of connector properties.
Can I use this to only create links that verifies certain condition?
Using something like this?:
sourceElement = "Need"
destElement = "Need"
NB
I had a thought of our 2 favorites EA admins : Simon and Roy <=> Tweedledum et Tweedledee :-* :-* :-* ;D
-
Well, this constraint is implicit. All connectors have source and target. You can add things like "only exists if" or "multiplicity depends on" etc. But as my above comment suggests I never in my life have ever used a connector constraint. I'm quite sure its use is more or less academic.
q.
-
Well, this constraint is implicit. All connectors have source and target. You can add things like "only exists if" or "multiplicity depends on" etc. But as my above comment suggests I never in my life have ever used a connector constraint. I'm quite sure its use is more or less academic.
q.
Tried this :
(http://snag.gy/OkOKK.jpg)
Does not seem to do anything...
NB : Need is my own stereotype defined by extending requirement with MDG.
Tried with "Requirement", does not seem to do much more... :'(
-
Any constraint is always meant to be read by a human. An OCL constraint can be read by a machine, but EA does only check the syntax of the OCL statement and does not execute it.
What you can do is to write an add-in that checks constraints on a programmatically basis.
q.
-
Any constraint is always meant to be read by a human. An OCL constraint can be read by a machine, but EA does only check the syntax of the OCL statement and does not execute it.
What you can do is to write an add-in that checks constraints on a programmatically basis.
q.
So your advice is to take your book (and it's interesting even i whished it to go a little deeper) and create a script that for every link check if source / typeoflink / destination match. And if not, delete the link.
Not really dynamic.
Can we log what we delete? (create a .txt somewhere, and buffer>txt)
-
Rather you should take a look at Geerts blog about writing an add-in in 10 minutes ;)
You could turn on the audit log. That logs such changes.
I have done something similar in the past. It's not that difficult.
q.
-
Back to the beginning question about connectors.
I wrote an add-in to do exactly what you want to do. Mine stops modellers from using Realize between requirements.
Use Geerts tutorial (thanks Geert very useful) to create an add-in. The method you want to put your code in is "EA_OnPreNewConnector". The following is the code i wrote:
/*
EA.EventProperties Info Contains the following EventProperty objects for the connector
to be created:
(0)Type: Astring value corresponding to Connector.Type
(1)Subtype: Astring value corresponding to Connector.Subtype
(2)Stereotype: Astring value corresponding to Connector.Stereotype
(3)ClientID: Along value corresponding to Connector.ClientID
(4)SupplierID: Along value corresponding to Connector.SupplierID
(5)DiagramID: Along value corresponding to Connector.DiagramID
*/
bool result = true;
//create objects to hold the diagram,client and supplier
EA.IDualDiagram diag = Repository.GetDiagramByID(Info.Get("DiagramID").Value);
EA.Element client = Repository.GetElementByID(Info.Get("ClientID").Value);
EA.Element supplier = Repository.GetElementByID(Info.Get("SupplierID").Value);
/*this rule checks relisation is only used between a class and an interface
*or between interfaces on a block or class diagram*/
if (Info.Get(0).Value == "Realisation" || Info.Get(0).Value == "Realization")
{
// Check that connection is only between a block/class and an interface or interface to interface
if ("Logical" == diag.Type && ("Class" == client.Type || "Interface" == client.Type) && "Interface" == supplier.Type)
{
result = true;
}
else
{
MessageBox.Show("Connecor only valid between a block/class and an interface \n or interface to interface", "Invalid Connector Usage",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
result = false;
}
}
Hope this helps
Gary
-
If you are a bit weary to write your own add-in, or you have too many hurdles to overcome to get that approved, you can achieve the same thing with EA-Matic (http://bellekens.com/ea-matic/) and the built-in scripting feature.
EA-Matic forwards the EA_OnPreNewConnector event to the scripting environment, where you can write your own validation.
Geert
PS. Yes I'm selling a commercial add-in now :D