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).