Introduction


Roo is an opensource framework of springsource that encourages RAD approach to get front end on top of spring technologies.

MinuteProject will offer from release 0.5+ a set of templates that matches the Roo target architecture.
The goal is to have Roo-compliant artifacts generated from an enriched data model.
Those artifacts (.roo file or others) can later be managed by the Roo Console.

MinuteProject 4 Roo


MinuteProject 4 Roo is in incubator mode.
Roo proposes a console interface where the user can insert roo-syntax command. Roo then processes this information to generate the corresponding spring-roo compliant artifacts.
The DB reverse engineering towards Roo oriented development can then be to offer the corresponding set of Roo commands deduced from the database structure bundled in a '.roo' file.

MinuteProject proposes 2 generation approaches:
  • generating the Roo console input commands.
  • generating the Roo framework output results.

Generation of the input command

Example

Below is the petstore schema in hsqldb
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE SEQUENCE SAMPLE_SEQ AS INTEGER START WITH 1516
CREATE SEQUENCE HIBERNATE_SEQUENCE AS INTEGER START WITH 102
CREATE MEMORY TABLE DUAL(DUMMY VARCHAR)
CREATE MEMORY TABLE DUAL_HIBERNATE_SEQUENCE(DUMMY VARCHAR)
CREATE MEMORY TABLE CATEGORY(CATEGORYID VARCHAR(10) NOT NULL PRIMARY KEY,NAME VARCHAR(25) NOT NULL,DESCRIPTION VARCHAR(255) NOT NULL,IMAGEURL VARCHAR(55))
CREATE MEMORY TABLE PRODUCT(PRODUCTID VARCHAR(10) NOT NULL PRIMARY KEY,CATEGORYID VARCHAR(10) NOT NULL,NAME VARCHAR(25) NOT NULL,DESCRIPTION VARCHAR(255) NOT NULL,IMAGEURL VARCHAR(55),CONSTRAINT SYS_FK_49 FOREIGN KEY(CATEGORYID) REFERENCES CATEGORY(CATEGORYID))
CREATE MEMORY TABLE ADDRESS(ADDRESSID INTEGER NOT NULL PRIMARY KEY,STREET1 VARCHAR(55) NOT NULL,STREET2 VARCHAR(55),CITY VARCHAR(55) NOT NULL,STATE VARCHAR(25) NOT NULL,ZIP VARCHAR(5) NOT NULL,LATITUDE DECIMAL(14,10) NOT NULL,LONGITUDE DECIMAL(14,10) NOT NULL)
CREATE MEMORY TABLE SELLERCONTACTINFO(CONTACTINFOID INTEGER NOT NULL PRIMARY KEY,LASTNAME VARCHAR(24) NOT NULL,FIRSTNAME VARCHAR(24) NOT NULL,EMAIL VARCHAR(24) NOT NULL)
CREATE MEMORY TABLE ITEM(ITEMID INTEGER NOT NULL PRIMARY KEY,PRODUCTID VARCHAR(10) NOT NULL,NAME VARCHAR(30) NOT NULL,DESCRIPTION VARCHAR(500) NOT NULL,IMAGEURL VARCHAR(55),IMAGETHUMBURL VARCHAR(55),PRICE DECIMAL(14,2) NOT NULL,ADDRESS_ADDRESSID INTEGER NOT NULL,CONTACTINFO_CONTACTINFOID INTEGER NOT NULL,TOTALSCORE INTEGER NOT NULL,NUMBEROFVOTES INTEGER NOT NULL,DISABLED INTEGER NOT NULL,CONSTRAINT SYS_FK_58 FOREIGN KEY(ADDRESS_ADDRESSID) REFERENCES ADDRESS(ADDRESSID),CONSTRAINT SYS_FK_59 FOREIGN KEY(PRODUCTID) REFERENCES PRODUCT(PRODUCTID),CONSTRAINT SYS_FK_60 FOREIGN KEY(CONTACTINFO_CONTACTINFOID) REFERENCES SELLERCONTACTINFO(CONTACTINFOID))
CREATE MEMORY TABLE ID_GEN(GEN_KEY VARCHAR(20) NOT NULL PRIMARY KEY,GEN_VALUE INTEGER NOT NULL)
CREATE MEMORY TABLE ZIPLOCATION(ZIPCODE INTEGER NOT NULL PRIMARY KEY,CITY VARCHAR(30) NOT NULL,STATE VARCHAR(2) NOT NULL)
CREATE MEMORY TABLE TAG(TAGID INTEGER NOT NULL PRIMARY KEY,TAG VARCHAR(30) NOT NULL,REFCOUNT INTEGER NOT NULL,CONSTRAINT SYS_CT_73 UNIQUE(TAG))
CREATE MEMORY TABLE TAG_ITEM(TAGID INTEGER NOT NULL,ITEMID INTEGER NOT NULL,PRIMARY KEY(TAGID,ITEMID),CONSTRAINT SYS_CT_77 UNIQUE(TAGID,ITEMID),CONSTRAINT SYS_FK_78 FOREIGN KEY(ITEMID) REFERENCES ITEM(ITEMID),CONSTRAINT SYS_FK_79 FOREIGN KEY(TAGID) REFERENCES TAG(TAGID))
 

MP 4 Roo generate the following input command

project --topLevelPackage net.sf.mp.demo.roo.petshop
 
persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
database properties set --key database.url --value jdbc:hsqldb:hsql://127.0.0.1:9001/petshop
database properties set --key database.username --value sa
database properties list
 
entity --class ~.domain.Address --identifierField addressid --identifierColumn ADDRESSID --identifierType java.lang.Integer --testAutomatically
entity --class ~.domain.Category --identifierField categoryid --identifierColumn CATEGORYID --identifierType java.lang.String --testAutomatically
entity --class ~.domain.Item --identifierField itemid --identifierColumn ITEMID --identifierType java.lang.Integer --testAutomatically
entity --class ~.domain.Product --identifierField productid --identifierColumn PRODUCTID --identifierType java.lang.String --testAutomatically
entity --class ~.domain.Sellercontactinfo --identifierField contactinfoid --identifierColumn CONTACTINFOID --identifierType java.lang.Integer --testAutomatically
entity --class ~.domain.Tag --identifierField tagid --identifierColumn TAGID --identifierType java.lang.Integer --testAutomatically
entity --class ~.domain.Ziplocation --identifierField zipcode --identifierColumn ZIPCODE --identifierType java.lang.Integer --testAutomatically
 
 
field string --fieldName street1 --column STREET1   --notNull --sizeMax 55 --class ~.domain.Address
field string --fieldName street2 --column STREET2    --sizeMax 55 --class ~.domain.Address
field string --fieldName city --column CITY   --notNull --sizeMax 55 --class ~.domain.Address
field string --fieldName state_ --column STATE   --notNull --sizeMax 25 --class ~.domain.Address
field string --fieldName zip --column ZIP   --notNull --sizeMax 5 --class ~.domain.Address
field number --fieldName latitude --column LATITUDE --type java.lang.Double  --notNull  --class ~.domain.Address
field number --fieldName longitude --column LONGITUDE --type java.lang.Double  --notNull  --class ~.domain.Address
 
field string --fieldName name --column NAME   --notNull --sizeMax 25 --class ~.domain.Category
field string --fieldName description --column DESCRIPTION   --notNull --sizeMax 255 --class ~.domain.Category
field string --fieldName imageurl --column IMAGEURL    --sizeMax 55 --class ~.domain.Category
 
field reference --fieldName productid --column PRODUCTID --notNull --type ~.domain.Product --class ~.domain.Item
field string --fieldName name --column NAME   --notNull --sizeMax 30 --class ~.domain.Item
field string --fieldName description --column DESCRIPTION   --notNull --sizeMax 500 --class ~.domain.Item
field string --fieldName imageurl --column IMAGEURL    --sizeMax 55 --class ~.domain.Item
field string --fieldName imagethumburl --column IMAGETHUMBURL    --sizeMax 55 --class ~.domain.Item
field number --fieldName price --column PRICE --type java.lang.Double  --notNull  --class ~.domain.Item
field reference --fieldName addressAddressid --column ADDRESS_ADDRESSID --notNull --type ~.domain.Address --class ~.domain.Item
field reference --fieldName contactinfoContactinfoid --column CONTACTINFO_CONTACTINFOID --notNull --type ~.domain.Sellercontactinfo --class ~.domain.Item
field number --fieldName totalscore --column TOTALSCORE --type java.lang.Integer  --notNull  --class ~.domain.Item
field number --fieldName numberofvotes --column NUMBEROFVOTES --type java.lang.Integer  --notNull  --class ~.domain.Item
field number --fieldName disabled --column DISABLED --type java.lang.Integer  --notNull  --class ~.domain.Item
 
field reference --fieldName categoryid --column CATEGORYID --notNull --type ~.domain.Category --class ~.domain.Product
field string --fieldName name --column NAME   --notNull --sizeMax 25 --class ~.domain.Product
field string --fieldName description --column DESCRIPTION   --notNull --sizeMax 255 --class ~.domain.Product
field string --fieldName imageurl --column IMAGEURL    --sizeMax 55 --class ~.domain.Product
 
field string --fieldName lastname --column LASTNAME   --notNull --sizeMax 24 --class ~.domain.Sellercontactinfo
field string --fieldName firstname --column FIRSTNAME   --notNull --sizeMax 24 --class ~.domain.Sellercontactinfo
field string --fieldName email --column EMAIL   --notNull --sizeMax 24 --class ~.domain.Sellercontactinfo
 
field string --fieldName tag --column TAG   --notNull --sizeMax 30 --class ~.domain.Tag
field number --fieldName refcount --column REFCOUNT --type java.lang.Integer  --notNull  --class ~.domain.Tag
 
 
field string --fieldName city --column CITY   --notNull --sizeMax 30 --class ~.domain.Ziplocation
field string --fieldName state_ --column STATE   --notNull --sizeMax 2 --class ~.domain.Ziplocation
 
field set --class ~.domain.Address --fieldName itemAddressAddressids --element ~.domain.Item --mappedBy addressAddressid --notNull --cardinality ONE_TO_MANY
field set --class ~.domain.Category --fieldName productCategoryids --element ~.domain.Product --mappedBy categoryid --notNull --cardinality ONE_TO_MANY
field set --class ~.domain.Product --fieldName itemProductids --element ~.domain.Item --mappedBy productid --notNull --cardinality ONE_TO_MANY
field set --class ~.domain.Sellercontactinfo --fieldName itemContactinfoContactinfoids --element ~.domain.Item --mappedBy contactinfoContactinfoid --notNull --cardinality ONE_TO_MANY
 
perform eclipse
 

Limitations

By generating console only input, we face limitation/convention of the Roo framework.
This is the case when executing the script to create a Roo Application.
The limitations found are:
  • Primary key policy not correct
  • Add of a version attribute
So there are still artifacts to override.
  • <domainObject>_Roo_Entity.aj
  • <domainObject>_Roo_ToString.aj
  • <domainObject>IntegrationTest_Roo_IntegrationTest.aj
MP generates those artifacts.

MP Generation limitations
  • generation of enum is not handled

Generation of all Roo artifacts


Work under progress