Author Topic: Change language of all elements of a package  (Read 1500 times)

jepessen

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Change language of all elements of a package
« 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)?

qwerty

  • EA Guru
  • *****
  • Posts: 9021
  • Karma: +137/-126
  • I'm no guru at all
    • View Profile
Re: Change language of all elements of a package
« Reply #1 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.

jepessen

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: Change language of all elements of a package
« Reply #2 on: October 31, 2016, 07:28:39 am »
Thanks I'll try it.

skiwi

  • EA Practitioner
  • ***
  • Posts: 1727
  • Karma: +23/-49
    • View Profile
Re: Change language of all elements of a package
« Reply #3 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.
Orthogonality rules
Using EA12.1 (1229) on Windows 10 Enterprise/64 bit. Repositories in SQLServer2014 R2 & Access2003/JET4.0

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2441
  • Karma: +29/-2
    • View Profile
Re: Change language of all elements of a package
« Reply #4 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.
The Sparx Team
support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 5905
  • Karma: +71/-80
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Change language of all elements of a package
« Reply #5 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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6215
  • Karma: +49/-5
    • View Profile
Re: Change language of all elements of a package
« Reply #6 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.
Simon

support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 5905
  • Karma: +71/-80
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Change language of all elements of a package
« Reply #7 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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6215
  • Karma: +49/-5
    • View Profile
Re: Change language of all elements of a package
« Reply #8 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.)
Simon

support@sparxsystems.com

qwerty

  • EA Guru
  • *****
  • Posts: 9021
  • Karma: +137/-126
  • I'm no guru at all
    • View Profile
Re: Change language of all elements of a package
« Reply #9 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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 5905
  • Karma: +71/-80
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Change language of all elements of a package
« Reply #10 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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 868
  • Karma: +11/-0
    • View Profile
Re: Change language of all elements of a package
« Reply #11 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

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6215
  • Karma: +49/-5
    • View Profile
Re: Change language of all elements of a package
« Reply #12 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.
Simon

support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 5905
  • Karma: +71/-80
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Change language of all elements of a package
« Reply #13 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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 9021
  • Karma: +137/-126
  • I'm no guru at all
    • View Profile
Re: Change language of all elements of a package
« Reply #14 on: March 30, 2017, 06:51:07 pm »
Thanks Simon. that seems to make sense.

q.