Author Topic: Database Builder, MySQL, INT, unsigned as default attribute  (Read 10437 times)

Henrik Raböse

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Database Builder, MySQL, INT, unsigned as default attribute
« 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?





regards
Henrik


Henrik Raböse

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #2 on: January 08, 2018, 08:49:41 pm »
Hi,

sorry, but I don't see: How to set this property as DEAFULT-Value for "UNSIGNED".

regards
Henrik

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #3 on: January 09, 2018, 12:26:04 am »
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
Nabil

Henrik Raböse

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #4 on: January 09, 2018, 02:01:58 am »
Ok, this attribute table is in the project.mdb?
How can I change this?


regards
Henrik

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #5 on: January 09, 2018, 09:52:58 am »
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.

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #6 on: January 09, 2018, 06:03:59 pm »
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
Nabil

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #7 on: January 09, 2018, 07:14:04 pm »
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

Henrik Raböse

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #8 on: January 09, 2018, 07:33:24 pm »
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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #9 on: January 09, 2018, 07:51:41 pm »
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

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #10 on: January 09, 2018, 08:19:57 pm »
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
Nabil

Henrik Raböse

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #11 on: January 09, 2018, 09:34:42 pm »
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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #12 on: January 09, 2018, 11:33:30 pm »
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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #13 on: January 10, 2018, 12:07:54 am »
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
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/

Another option is to use one of my add-ins called 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

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Database Builder, MySQL, INT, unsigned as default attribute
« Reply #14 on: January 10, 2018, 01:12:55 am »
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
Nabil