From: Alejandro I. <ai...@ya...> - 2011-03-03 12:50:51
|
Hi folks, First of all let me say that I really appreciate and would like to publicly "THANK YOU!" for having made dia2code possible. I know how ungrateful user communities tend to be, so I just wanted to let you know we are a happy user and use dia2code on a daily basis for a real-world business and profit from it. Having said that, I have had a to-do in my agenda for many years now to contribute to this project but getting my small company off the ground has been so hard that we merely had enough budget to pay salaries for the past 4 years. But things are finally getting off the ground so I can start crossing-out some of these pending items, and my debt to this project is one of these items. A little introduction and background on my use of dia2code... I have been playing around with DIA since I discovered it in Debian packages, I'm pretty sure it was Debian Hamm (2.0) stable or perhaps unstable-almost-Woody but honestly I can't remember back that far. What I do remember is that all the way back in 2001 I had chosen DIA and dia2code as my basic UML modeling tools that I would use "someday" when I had the guts to leave my job and create a fully Open source company. That finally happened in late 2006 and in 2007 I had finally formed it with an old friend, and officially started using these tools for real production work. When 0.83 was first distributed on Debian, I believe it was Etch (4.0) our "old way" of doing things broke, so out of desperation we simply took a source version and patched it for our specific needs (basically commenting out the bulk of the PK stuff) and never touched it since. But I promised myself that when we had a little oxygen I would put an effort to understand what you guys were trying to do with associations, aggregations, compositions and such, and how those things mapped to SQL for the common mortal. So here we are in 2011 I have finally sat down to hack at it.... OK so here's what I've done so far and would like your take and possibly continue my contribution to SQL generation from UML class models. 1) In parse_diagram.c I think you are expecting/using an old version of the DIA XML because the deep level of nesting for the first UML -Association loop simply does not resemble anything I'm looking at in the DIA 0.97 XMLs. Also, I could not find an attribute named "ends" _anywhere_ in the DIA UML objects, so after a lot of head banging trying to understand that bit, I decided to leave it alone and focus on the second attribute iteration that you use for connections. 2) So, regardless of (1) when you get to the second loop for the connections, the "name" is always null. I _supposed_ that you were meaning to set the name in the first loop but when I see you are also determining "direction" in the second loop I am not quite sure of that, that is, that the loops are actually related or they are 2 separate cases? Anyway, I made a small hack to capture the association name in the second loop and make sure it gets set. 3) In generate_code_sql.c you are assuming that the FK columns have the same name on both sides (which is not very common), and with with the advent and ever-popular use of ORM technologies such as Propel (PHP) and DBIx::Class (Perl) the current naming convention/trend is to work with simple serial "surrogate keys", and FKs are 'standardized' to the form xxx_id where xxx is the FK table and the FK is _always_ "id". So in the attached patch, I check for this convention and warn if not being used. http://en.wikipedia.org/wiki/Surrogate_key I think these 2 patches are quite harmless to the current 0.83 and maybe to more current versions of dia2code. I have seen a couple of postings regarding the "unnamed association bug" like this one: https://bugs.launchpad.net/ubuntu/+source/dia2code/+bug/442295 If you think I'm on the right track please let me know as I could continue to work and contribute to the associations in general, though mainly targeted to SQL generation. I would like to continue to work on many-to-many, primary key and additional indexes creations... as well as trying some experiments with roles or another naming convention for the assoc to make the FK stuff more general (to support real old-school FKs and multi-columns PKs as well). I am admittedly a bit rusty in C but *I love it* and used to be quite proficient, though I currently work mostly in Perl so I am spoiled ;-) I do have a lot of experience however with the libxml2 API through XML::LibXML which is a simple wrapper to C's libxml2 that you are using. Anyway, I'd appreciate your comments and the possibility of actively contributing to this project for a while. The patches are attached but you can check out my up-to-date work anonymously at: svn://svn.yabarana.com/dia2code-0.8.3-corcaribe /trunk is the my old 2007 version where I just commented all the FK stuff and expanded th 80 char limit because of my literal declaration of FK directly on the UML Class attributes. In /branches you will find a vanilla 0.83 and my new work in the dia2code-0.8.3 and dia2code-0.8.3_yabafixes directories respectively. In the root of branches you will also find the latest versions of the attached patches to this mail. Best, -- Alejandro Imass P.S. I don't work much with CVS but I'm quite proficient with SVN, have you ever considered migrating to SVN? |