Author Topic: change code generation to PHP?  (Read 5448 times)

Arjen van Haren

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
change code generation to PHP?
« on: July 28, 2008, 08:01:21 pm »
I have a class diagram with > 40 packages and > 190 classes and want to generate the source code in PHP. However as a default everything is generated for Java.

I changed the default source generation to PHP and changed all packages to PHP, but I still need to change some classes to PHP in their properties setting.

Is there a faster way to select all classes and set their code generation to PHP?
« Last Edit: July 28, 2008, 08:03:47 pm by Arjen256 »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: change code generation to PHP?
« Reply #1 on: July 28, 2008, 09:35:18 pm »
Hi,

You've actually got two problems: how to correct your current project, and how to prevent this from happening in future. Let's look at them in reverse order (which will provide some context).

EA stores programming language information - and the default setting for some unknown reason - as part of each project. This includes the EABase project that is installed with the EA application, which is used as the default 'seed' project when you create a new file.

You can edit EABase - remembering that you'll have to do this again if you install a new 'full' EA kit in future (perhaps as an upgrade) - to change the default language setting. Now all your new projects will default to your new setting.

You can also use a different seed project - perhaps an empty project created from EABase but set to a preferred language - by clicking the Copy a Base Project link on the EA Start page (it's near the top left). You can have as many of these alternate projects as required.

Now the other problem...

[edit]Please see the post below. My opinion was out of date. Sparx has changed things for the better, and the situation has greatly improved.

David[/edit]
The news is not as good here. There's no simple way to go back through and change all the settings (that I know of). But don't panic yet. Try exporting your package tree to XMI. Take a look at the structure - it will seem daunting at first, but see the notes below - and find the language settings. With a good editor you can switch the settings in an instant (or a quantity thereof). Then import the package tree back into the project, overwriting the old one.

NOTES:
  • Do this on a copy of your project - at least the import part.
  • Using a copy of your project, change one of the packages (perhaps an otherwise empty one) to your preferred language. Export just that package and compare the XMI with a similar export from your (unaltered) current project. You will find it easy to locate the language settings - there might be more than one, but your preferred language will show up as a string. Now you've got the correct position and syntax for changing the XMI stream (for a package).
  • Do the above XMI trick for classes, and perhaps for attributes and parameters if you need to. [These last might only be a case of tweaking the data type names, some of which might be the same.]
  • If you get to this point but have not solved the problem, search the forum for the past few months. There are some threads that deal with this, and there might be other suggestions for a (somewhat) quick fix that will work in your case.
HTH, David
« Last Edit: July 29, 2008, 09:59:47 am by Midnight »
No, you can't have it!

Arjen van Haren

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: change code generation to PHP?
« Reply #2 on: July 29, 2008, 12:24:15 am »
The import export to an xml file did the trick. I replaced all java codes to php and imported the xml, all classes files where set to PHP code generation :)

Thanks for your help!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: change code generation to PHP?
« Reply #3 on: July 29, 2008, 08:43:12 am »
To reset the language within EA:

1. Select the package containing all of your classes.
2a. Click the arrow next to the second icon above the project browser.
3a. Select 'Reset source code language'.

OR

2b. Right click on package.
3b. Select 'Code Engineering' | 'Reset Options for this Package'


Arjen van Haren

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: change code generation to PHP?
« Reply #4 on: July 29, 2008, 04:35:18 pm »
Great! that's even better!

Thanks for the help

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: change code generation to PHP?
« Reply #5 on: July 30, 2008, 08:13:43 am »
David, that's an impressively out of date opinion.  That function was available in EA 3.51.619 (I can't easily check back further than that).  ;)  Or maybe it's just one of those features that can be a little hard to find.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: change code generation to PHP?
« Reply #6 on: July 30, 2008, 11:15:07 pm »
Point taken Simon.

To say the least, it must have been difficult to find. I'm not the only poster that's be unaware of it in the intervening time.

That said, I've certainly not looked for the feature - in EA or the documentation - for quite some time. [Not having needed to do so.] The visibility might well have improved along the way.

Regardless, no disrespect was intended.

David
No, you can't have it!

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: change code generation to PHP?
« Reply #7 on: July 31, 2008, 09:50:15 am »
But point also taken David. If you searched the index with a little lateral thinking, you would have found the appropriate Help topic. I have made the index entries more direct, so you no longer need to be Edward De Bono to get to the topic. I hope!
Best Regards, Roy