Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: jepessen on October 31, 2016, 05:03:19 am

Title: Change language of all elements of a package
Post by: jepessen on October 31, 2016, 05:03:19 am
Hi.

I've a project where there are many uml classes inside a package. The problem is that the language is wrong for all of them. I have to change classes language from Java to C++ for all of them. How can I automate this task without changing every class manually (they are almost 500)?
Title: Re: Change language of all elements of a package
Post by: qwerty on October 31, 2016, 06:33:10 am
You can do that either with a SQL or a script (executing the SQL or using the API):
Code: [Select]
UPDATE t_object SET genType="C++" WHERE genType='Java
I you want to do that for a single package you could add a WHERE clause for the packageId or extract the package with XMI and change it either in the XMI with an editor or imported in a dummy repo.

q.
Title: Re: Change language of all elements of a package
Post by: jepessen on October 31, 2016, 07:28:39 am
Thanks I'll try it.
Title: Re: Change language of all elements of a package
Post by: skiwi on March 29, 2017, 09:20:00 am
A low tech way is to export the package, make the change with an editor (I use Notepad++) and import it.
Title: Re: Change language of all elements of a package
Post by: KP on March 29, 2017, 09:25:02 am
I missed this first time around or I would have mentioned that you can do it with the UI: Right-click package in Project Browser > Code Engineering > Reset Options for this Package.
Title: Re: Change language of all elements of a package
Post by: Paolo F Cantoni on March 29, 2017, 10:57:42 am
I missed this first time around or I would have mentioned that you can do it with the UI: Right-click package in Project Browser > Code Engineering > Reset Options for this Package.
This is the way IU do it, but recently, I've noticed that new items don't seem to get the language defined for the package - they get "<none>".  Should they?  I get EA to reset all the defaults and looking at the package it has the correct language.  BTW, the language is a non-standard one ("Conceptual")

Paolo
Title: Re: Change language of all elements of a package
Post by: Eve on March 29, 2017, 01:27:35 pm
Paolo, there is no option to propagate the language from a package to the elements created within it. A diagram type can specify a language, but not a package.
Title: Re: Change language of all elements of a package
Post by: Paolo F Cantoni on March 29, 2017, 06:19:05 pm
Paolo, there is no option to propagate the language from a package to the elements created within it. A diagram type can specify a language, but not a package.
Learn something new every day!

You can specify it on each individual diagram.

However, there seems to be a bug.  If I set the language to <none> in the Diagram | Elements dialog I don't get "<none>" on a new element.  A specific language seems to work OK.

Paolo
Title: Re: Change language of all elements of a package
Post by: Eve on March 30, 2017, 08:22:29 am
Selecting '<none>' is the only way to specify that this diagram doesn't specify a language (and that the model default should be used.)
Title: Re: Change language of all elements of a package
Post by: qwerty on March 30, 2017, 09:46:12 am
Out of curiosity: why is it, that a diagram is related to a certain language? Seems like a coincidental choice.

q.
Title: Re: Change language of all elements of a package
Post by: Paolo F Cantoni on March 30, 2017, 10:57:45 am
Selecting '<none>' is the only way to specify that this diagram doesn't specify a language (and that the model default should be used.)
That's what I suspected, Simon.  But I couldn't find, in the new UI, where to set the Repository default.  Can you please enlighten me?  Also, since I can't see it, I can't check if "<none>" is an available option for the reposiotory default.  I believe it should be.

Paolo
Title: Re: Change language of all elements of a package
Post by: Aaron B on March 30, 2017, 12:15:42 pm
In EA 13 - Configure > Model > Options > Source Code Engineering : Default Language for Code Generation.
http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_domains/code_generation_options.html
Title: Re: Change language of all elements of a package
Post by: Eve on March 30, 2017, 02:02:37 pm
Out of curiosity: why is it, that a diagram is related to a certain language? Seems like a coincidental choice.
In EA a diagram specifies a profile being used by specifying the default toolbox. As a result it made sense when adding profiles for different programming languages that the same mechanism used to control the elements and stereotypes available controlled the language.
Title: Re: Change language of all elements of a package
Post by: Paolo F Cantoni on March 30, 2017, 03:17:10 pm
In EA 13 - Configure > Model > Options > Source Code Engineering : Default Language for Code Generation.
http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_domains/code_generation_options.html
Ahh...  EAUI!   I was using the old Ctrl+F9 dialog and couldn't find it under Source Code Engineering!

The new UI puts up a similar looking, BUT DIFFERENT dialog.

Paolo
Title: Re: Change language of all elements of a package
Post by: qwerty on March 30, 2017, 06:51:07 pm
Thanks Simon. that seems to make sense.

q.
Title: Re: Change language of all elements of a package
Post by: Eve on March 31, 2017, 08:26:31 am
The new UI puts up a similar looking, BUT DIFFERENT dialog.
The two dialogs were split some time before 13 into user preferences and model configuration. Prior to that you didn't know what the option applied to and it caused a lot of confusion.
Title: Re: Change language of all elements of a package
Post by: Paolo F Cantoni on March 31, 2017, 10:51:45 am
The new UI puts up a similar looking, BUT DIFFERENT dialog.
The two dialogs were split some time before 13 into user preferences and model configuration. Prior to that you didn't know what the option applied to and it caused a lot of confusion.
Yes, I agree, it's better this way, but it would be helpful to set them more apart visually.  It really does look like one is a "mini-Me" of the other.

Paolo