Carlos Ble

Carlos Ble

I am a professional software developer, I solve problems.

I also teach and mentor developers to build better software.

Working as an independent professional since 2009.

Can I help you?

  • Do you need high quality tailor-made software?
  • Need training on TDD, clean code or refactoring?
  • Is it risky? do you need advise?
  • May I pair with you to write better code?

Events

Upcoming public training courses:

  1. [in English] May 5, 6 & 7
    TDD - Train the Trainers (iSQI)
    Potsdam, Berlin
  2. [en Español] 23, 24 y 25 de Abril.
    Curso de TDD con examen de certificacion iSQI
    Madrid
  3. [en Español] 29, 30 y 31 de Octubre.
    Curso de TDD con examen de certificacion iSQI
    Madrid

Conferences:

  1. I'll be at SocratesUK 2014
  2. I'll be at the London Test Gathering Workshops.

Autogenerating a Castle Web application from UML

Update (9 March 2009): Broken links fixed

My favourite rapid web development framework is MonoRail with ActiveRecord (CastleProject). Castle works fine with Mono on
GNU/Linux, and we are using Castle for several projects, so we are working in several tools to increase development speed.
The following tools works on Mono/Linux with the latest CastleProject (net 1.1) binary version from daily build.
With this tools you can generate a Castle web application from an UML diagram.
There are two parts; the ActiveRecord Models generator wich is a Perl script (ARgenerator.pl) and the Scaffold generator wich is part of NProject (generate.exe). To create the diagrams, you must use Umbrello.
There is a syntax to design classes in Umbrello to generate the Models (relations and methos) properly. At the first, ensure that the "Active Language" is C++. At the moment Umbrello doesnt support C# but this is not a problem. Please, see the screenshots into this zip package for a visual example. Then you can use basic types for your objects' members (int ,string, float...). You can also define models relations easily:

  • For a HasAndBelongsToMany relation you only need to define the relation in one side. This is the syntax:
    IList|ISet - Many2Many(Class, table)
  • For a BelongsTo relation you only need to define the type of an attribute like a class:
    Membername: ClassName
  • For a HasMany relation you need a HasMany on one side and a BelongsTo in the other side:
    IList|ISet - HasMany(Class)

Id, Name and Code properties are added to all classes automaticly, with a ToString method. You can avoid this editing ARgenerator, its easy. Hierarchy (JoinedKey) is also supported.Please, see the screenshots to undertand the relations.
Once you finish the diagram, go to Code menu and use the "Code Generation Wizard". ARgenerator only understands the Umbrello generated files when these are sql files, so choose SQL language.
Then go to bash and generate the models:

carlosble@laptop1:~/tmp$ ./ARgenerator.pl -namespace=MyNamespace.Models -base=ValidationBase *sql
Ignoring file: -namespace=MyNamespace. Not a regular file
Ignoring file: -base=ValidationBase. Not a regular file
Ignoring file: DateTime.sql. It is not a class
Ignoring file: IList_-_HasMany(Module).sql. It is not a class
Ignoring file: ISet_-_Many2Many(Module,_developer_module).sql. It is not a class
WARN: Developer.DeveloperCollection: adding DeveloperCollection property to class Module

Remove all *sql files, create a Models directory into your application skeleton directory and place the generated
.cs models inside.
Now Controllers, Views and Test will be generator with NProject's Generator:

svn co https://svn.sourceforge.net/svnroot/nproject nproject

Build the generator:

cd nproject/Generator
nant

Then copy the exe file and dll to you bin directory:

cd ../../
cp nproject/Generator/bin/* bin

and copy the Generators directory too:

cp -r nproject/Generator/Generators/ .

Now edit Generators/Config.boo:
Change "GeneratorDemo" to MyNamespace
And change "aspx" to "rails" if you are working in Mono/Linux:

public static ActionExtension = "aspx"

Finally, generate the scaffold:

bin/generate.exe Scaffold Application
bin/generate.exe Scaffold Bar
bin/generate.exe Scaffold Developer
bin/generate.exe Scaffold Foo
bin/generate.exe Scaffold Module

In the zip package there is a skeleton including a Makefile to run the application with XSP. And also includes the
Generators directory from NProject, but i recommend to get the latest code from svn.
Before start the application, create the database schema with "make dbgenerator" (notice that you need a database and to configure the activeRecord.xml).

Enjoyed reading this post?
Subscribe to the RSS feed and have all new posts delivered straight to you.
  • Pingback: El blog de Carlos Ble » Why to choose CastleProject, Mono and related technologies

  • RL
  • http://carlosble.com Carlos
  • http://www.sellwinterboots.com boots

    In Case B it tries to lock the files in the Bin-directory, which then leads to the locking-conflict described above.

  • http://www.associationez.com vikram

    Thanks!

    Great help. It seems this is working now.

  • http://myforexspot.info Maricela Molone

    I’ve been exploring for a little for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this site. Reading this information So i’m happy to convey that I have a very good uncanny feeling I discovered exactly what I needed. I most certainly will make certain to do not forget this website and give it a look regularly.

  • http://www.seosolutions.com.pl pozycjonowanie stron ?ód?

    Great – I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs as well as related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your client to communicate. Nice task..

  • http://fahadalmfarag.com/vb/member.php?u=686 Leslie Parrotte

    I’m happy I found this blog, I couldnt learn any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if achievable feel free to let me know, i’m always appear for people to check out my site. Please stop by and leave a comment sometime!

  • http://data-ch.com/images/guest/index.php?showforum=1 karen

    This really answered my drawback, thank you!