Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Henrik Raböse on January 08, 2018, 02:06:48 am
-
Hi,
how can I set the attribute UNSIGNED for the data type INT (on MySQL) as default?
(http://it-raboese.de/ea/mysql_datatype_int_unsigned.png)
regards
Henrik
-
Database Builder | Columns...
http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_domains/dbexplorer.html (http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_domains/dbexplorer.html)
Column Properties...
http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_domains/createcolumns.html (http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_domains/createcolumns.html)
-
Hi,
sorry, but I don't see: How to set this property as DEAFULT-Value for "UNSIGNED".
regards
Henrik
-
Hello Henrik,
I not sure do we able to set a default value.
But we can run script to update column unassigned to True.
All these will be stored under t_attributetag table.
HTH
Nabil
-
Ok, this attribute table is in the project.mdb?
How can I change this?
regards
Henrik
-
Actually you can get this from EAAttribute.Type via the API. No need to tinker directly with the database. However, setting the default would need to write an add-in that subscribes to EA_OnPre/PostNewAttribute to modify the default. And it will likely end up in quite some blood, sweat and tears. I short: it's not really(/easily) possible to change a default like you want it. You might send a feature request, but in this case you should have a very long breath.
q.
-
Yes It is always good to go with API but for accessing Attribute Unsigned value I'm not sure will we be able to do it via API. To update the table you can try Repository.Execute()
you will get many sample out there in forum.
Cheers
Nabil
-
Yes It is always good to go with API but for accessing Attribute Unsigned value I'm not sure will we be able to do it via API. To update the table you can try Repository.Execute()
you will get many sample out there in forum.
Cheers
Nabil
If this information is stored as a tagged value then you can access it using the API.
Repository.Execute is the nuclear option, only to be used by expert users who know what they are doing as it is undocumented and unsupported.
There is a real risk of completely destroying your model if you are not careful
Geert
-
Thank you.
But playing with the API its to much for this little feature.
@Geert
Unfortunately, it is not a Tagged-Value, shown in the picture on the first post.
This is an option (attribute/property) for the table column type INT - in the Database Builder.
--
regards
Henrik
-
Henrik,
There a possibility that this information is nonetheless stored as a tagged value (suggested by Nibal -> stored in t_attributeTag), even if this particular tagged value is hidden in the GUI.
Geert
-
Yes It is a Tag Value hidden from GUI. My fault you can do it via API using this syntax
for ( var i = 0 ; i < attributes.Count ; i++ )
{
var currentAttribute as EA.Attribute;
currentAttribute = attributes.GetAt( i );
// Delete the attribute we just added
if ( currentAttribute.Type == "INT" )
{
var AttTV as EA.Collection;
AttTV = currentAttribute.TaggedValues;
for ( var j = 0 ; j < AttTV.Count ; j++ )
{
var currentAttTV as EA.TaggedValue;
currentAttTV = AttTV.GetAt( j );
Session.Output(currentAttTV.Name);
}
//Session.Output( "To Change: " + currentAttribute.Name );
}
}
Cheers
Nabil
-
Hi,
thanks, people.
@Geert
But how can that help me now? I have no background knowledge of how the EA works.
What should I do with that:
- run script to update
- stored in t_attributeTag
- hidden tagged value from GUI
@Nabil
The same Problem. I do not know what to do with the code.
I did not read any API documentation and I just wanted to change that setting EASILY.
--
regards
Henrik
-
Actually you can get this from EAAttribute.Type via the API. No need to tinker directly with the database. However, setting the default would need to write an add-in that subscribes to EA_OnPre/PostNewAttribute to modify the default. And it will likely end up in quite some blood, sweat and tears. In short: it's not really(/easily) possible to change a default like you want it. You might send a feature request, but in this case you should have a very long breath.
q.
-
Hi Henrik,
Als qwerty indicated there is no very easy way.
The somewhat harder way is to write a script that changes the value. You can probably use the snippet provided by Nabil.
In the help there is some information about scripting, and I have a fairly large open source library with all kinds of scripts for EA: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library)
The script will update the fields at the moment it is executed.
The somewhat harder option is to write an add-in. The add-in can react to the event of creating a new attribute and react accordingly, setting the value as default value.
For information on add-ins see https://bellekens.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/ (https://bellekens.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/)
Another option is to use one of my add-ins called EA-Matic (https://bellekens.com/ea-matic/) That add-in can forward the attribute creation event to a script. That allows you to define in the script what needs to happen when a new attribute is created.
Geert
A
-
Hello Henrik,
Not so tough as you think.
Here we are using API which is safer to handle things
To start with goto scripting tab, you will find a local scripts category here you can find many scripts to start with. For this specific case you can refer JScript Manage Attributtes and Methods example the same available in VB Script as well
Also you can refer geerts github library for more samples.
Cheers
Nabil
-
Thanks, people.
I'll test it.
--
regards
Henrik