Author Topic: Observation and Issues with Transformation  (Read 7045 times)

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Observation and Issues with Transformation
« on: February 28, 2006, 02:52:50 pm »
I haven't noticed mention of these two issues with the transformations in any of the threads so thought I would bring them up to see if anyone else has seen this or found a fix.


1) When generating PSM for a project (in my case both C# and C++ at the same time) I have noticed that when I try and do my whole project the packages get screwed up and in some cases I have seen packages get named according to a class, etc.  Now in the case I am playing with the project is not too big yet.  Only about 120 classes (most of which are empty as I just started dropping them in) with about 35 packages nested to 6 layers deep.  This is a real pain as I have to go and completely reorder stuff and even rename some things.  This looks like an issue with the parser.


2) I have noted that the Common Types are different for Code Types Versus Database Types.  As such, creating a single UML model and then generating Code as DDL results in at best one being generated correctly but guarentees that it is not possible to get both correct.  Now I have tried defining new language data types and even a new fake database type where I mapped the Common UML Code Types to the database types.  It still generates the wrong DLL when the existing DLL transform is used.  I suspect it has to do with the language type specified in the DDL transform being set to genOptDefaultDatabase for which I can find no definition.  Also I have no idea what to change this to in order to get a different behaviour.

Any insight, help or corrected transformation code, greatly appreciated as this is going to be a pain once this project gets bigger.


Paul Michaud

thomaskilian

  • Guest
Re: Observation and Issues with Transformation
« Reply #1 on: March 01, 2006, 06:01:22 am »
Paul,
I can't tell anything about 1) except you should contact Sparx support if you suppose this being a bug.

For 2) the genOptDefaultDatabase is the one you set under Tools/Options/Code Editors/Default Database. This controls how datatypes are transformed. Refer to the file ddl_datatypes.xml in EA's program directory.

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #2 on: March 01, 2006, 08:13:50 am »
Thanks Thomas,

Actually I had spent a fair bit of time playing with this stuff yesterday and here is what I found.

1) I actually tried modifying the DDL_DataTypes.xml file.  None of the changes I made appeared to have any effect on the generated tables or in the way the DDL transform generated stuff.

2) I was actually able to get somewhat proper DDL (for things one would expect the system to understand, not nested classes, etc)  to be generated.

Caveat:  I still can't seem to get it to include attributes from parent classes in the table schema.  Anyone have any luck with this.

You will always have to go back and manually create the Primary Keys and modify columns which associate with other complex class types.

To get it to work I did the following:


1) I created a new language in the Code Datatypes and called it in my case MDCDatabase
1.1) I specified the database types I would be using for my columns and mapped them to the generic type names used in the code types not the database types.  for example String, Double, Ulong, etc.  instead of varchar,float, bigint.

2) I made a new transformation type which I again called MDC_DDL.  I patterned it on the current DDL tranform with some changes to gegt the type conversion better.

I have included it here incase anyone else finds this useful.

FILE:
Package
{
 name="MDC_DDL"
 namespaceroot="true"
%list="Namespace" @separator="\n\n" @indent="  "%
}

NAMESPACE:
%list="Namespace" @separator="\n\n"%
%list="Class" @separator="\n\n"%


CLASS:
Table
{
 %TRANSFORM_REFERENCE("Table")%
 %TRANSFORM_CURRENT("language")%
 language=%qt%%MDCDatabase%%qt%

%list="Attribute" @separator="\n" @indent="  "%
 PrimaryKey
 {
   Column
   {
     name=%qt%%CONVERT_NAME(className, "Pascal Case","Pascal Case")%ID%qt%
     type=%qt%%CONVERT_TYPE("MDCDatabase","ULong")%%qt%
   }
 }
}
%list="Connector" @separator="\n"%


ATTRIBUTE:
Column
{
 name=%qt%%attName%%qt%
 type=%qt%%CONVERT_TYPE("MDCDatabase",attType)%%qt%
}


I removed any Foreign Key stuff as I personally don't like using them.

Anyhow this works better.  Note the language setting are set to point to the new language I defined, which maps the UML Code Types to the database types I want them to be.

This way I can get some of the database stuff to come out right.


Now if I could just figure out how to get the attributes of the parent class included in the child classes corresponding table,  I think this would be about the best I can do with this.

Hope this is of help to others.

Paul




thomaskilian

  • Guest
Re: Observation and Issues with Transformation
« Reply #3 on: March 01, 2006, 12:35:21 pm »
Ask Simon at Sparx for the current DDL transformation template which pulls out the inherited attributes.

Regarding the ddl-xml: this is not meant to be subject of change - just for reference.

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #4 on: March 01, 2006, 12:43:50 pm »
Will do re the template.


Yeah I figured that the xml, was simply a dump of the database structure for this.  It is clear that the app is not using the file directly.


Paul

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Observation and Issues with Transformation
« Reply #5 on: March 01, 2006, 01:51:50 pm »
Quote
1) When generating PSM for a project (in my case both C# and C++ at the same time) I have noticed that when I try and do my whole project the packages get screwed up and in some cases I have seen packages get named according to a class, etc.  Now in the case I am playing with the project is not too big yet.  Only about 120 classes (most of which are empty as I just started dropping them in) with about 35 packages nested to 6 layers deep.  This is a real pain as I have to go and completely reorder stuff and even rename some things.  This looks like an issue with the parser.

I have a feeling, that this is related to a bug fixed in build 788.  (Which isn't far away)  Are the packages correct in the intermediary file?  If they are then I'm wrong in my guess.

You can edit the DDL datatypes by selecting Settings | Database Datatypes.  Changing the common types for your target database in here will change the way datatypes are transformed.

Finally, getting inherited attributes into a table can't be done without calling an addin at the moment.  Not without some improvements to a template language that are still in development.  Sorry, the templates that I have for this currently aren't of use to anyone else.   :( The best I can do is creating a foreign key to the parent.

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #6 on: March 01, 2006, 02:15:24 pm »
I have checked the intermediary file and it is wrong there.

So does it look like the fix will deal with this?


As for the DDL, is there anything I can get that someone needs testing, etc that will bring in the parent class attribute.  I am willing to be a guinea pig for this, or even do some code mods myself if someone can point me in the right direction.

I have limited time, but since this is going to impact me on over 400 classes it is worth some effort on my part.


Right now my alternative is to generate the stuff and then hand modify the resulting DDL files.


Thanks


Paul

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #7 on: March 02, 2006, 06:01:27 pm »
Hi Simon,

FYI, 788 did not fix the tranformation problem which was resulting in the packages being screwed up and some packages being named for classes,  etc.


Paul

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Observation and Issues with Transformation
« Reply #8 on: March 02, 2006, 09:03:12 pm »
Thanks Paul,

I actually found that there was still a problem earlier.

The one that should have been fixed to my knowledge only caused the packages from objects error.

The one that I have found today appears to mess up the package heirarchy, but should never cause anything like the first error.

Finally, there is always potential for a bug that I haven't found yet.

Could you please confirm what bugs you are seeing and what categories (they appear to) fit in?

pmichaud

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #9 on: March 03, 2006, 02:11:55 am »
Hi Simon,
I just looked again,  and you are right.  I think the issue with packages being named for classes is now fixed.  the issue seems to be only with package structure itself.


Paul

cnj_mike

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #10 on: June 22, 2006, 07:03:36 pm »
Folks - a somewhat related problem.

I've defined a class model using ActionScript as a base.  I want object IDs in the class model, so I defined attrs of type Number named <class>_id, with a PK stereotype. I also have a number of associations between classes.

When I transform to a DDL, the associations are treated as FKs, which I want, but the FK generation doesn't seem to recognize that I've already defined a PK in the class and creates a new one.  It also seems to not translate the type of the class attr with a PK stereotype.

I would just delete my class PKs and let them be generated, but then if I generate ActionScript from the model it's missing the PKs cuz they only appear in the DDL.

Can anyone offer help?  Am I going to have to hack all the code in this app to make it do what it's advertised to do?

Thx

thomaskilian

  • Guest
Re: Observation and Issues with Transformation
« Reply #11 on: June 22, 2006, 11:33:57 pm »
That was actually one of the reasons why I did the coding all by myself. I now can control that using Tags for those attributes being a primary key. The current solution by Sparx is nice for straight transformations. But as you encounter more sophisticated rules, you are at a stage where ax programmatic approach (throug automation) is unavoidable.

Maybe Simon has a clever solution, though.

cnj_mike

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #12 on: June 23, 2006, 09:48:14 am »
OK... I was grumpy last night. =)  It's actually very easy to update the transforms to do what I want.

These changes I'm making to transformation rules are in the project file, right, not common across all projects?  I'd have to export and import them?

Thanks
M

thomaskilian

  • Guest
Re: Observation and Issues with Transformation
« Reply #13 on: June 24, 2006, 05:33:03 am »
Right. Go through Ex-/Import Refernce Data.

cnj_mike

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Observation and Issues with Transformation
« Reply #14 on: June 26, 2006, 12:07:27 pm »
OK, here's another question. =)

I'd like to auto generate some stored procs for classes.  I have an operation like Get_By_Folder_Owner(folder_id: INTGER) defined in the class model, and I want to be able to write the transform that generates a stored proc for service prototyping that looks like

create procedure sp_Folder_Get_By_Folder_Owner(
  @folder_id INTEGER
) as

select %list=attributes...

blah blah blah

I can figure out how to use the code generation rules to do this... except... i'm also generating action script code from the PIM for the actual classes.  If I define my own target language to create the procs, then I get hosed up moving back and forth between generating AS and my SP_DDL.

I can't find any way to modify the DDL generation process, tho that would be ideal.

Any suggestions on how to tackle this?

Thx