Introduction

Openxava is an opensource framework based on JPA entities + framework specific annotation to dynamical generate web based application.

MinuteProject 4 Openxava is a generator based on the data model that generates JPA entities annotation + Openxava specific presentation annotations and artifacts. The JPA2 generated artifacts are in java or in groovy.

Openxava distribution is shipped with a eclipse based development structure that helps you build an new OX projects.

This pages explains how to create an OpenXava project and generate the OpenXava artifacts based on an existing database.

Live demo can be found on cloudbees PaaS at http://petshopox.minuteproject.cloudbees.net/xava/homeMenu.jspdone by minuteproject reverse engineering only.
For a quick try goes to Demo.

Enriching your database with properties, concepts can generated added-value quality artifacts. To know more how to add this information please read Openxava smart reverse engineering.

Steps

This part will show you how to have an OpenXava application reversed-engineered from a DB structure.
It works with tables and views (although in this case you need to add some enrichment in MP to indicate with field will serve as primary key).
The number of steps have been reduced to two. One is the generation based on a DB model and additional enrichments. The second performs all the tasks up to deployement and starting a browser to view the delivered application. It is performed.

Prequisites

Download OpenXava version 4.8
Download minuteproject last version.
Ant and Java 1.6 setup.
Have a DB up and jdbc connection parameters.
Set up system variable <OX_HOME> that points to OpenXava 4.5 home. This is mandatory to run the script on the second step.
Set up system variable <MP_HOME> that points to MinuteProject home. This is mandatory to run the script on the second step.

Step 1: MinuteProject generation

This step will explain how to create a MinuteProject configuration holding your model information and enrichment, as well as the execution of it.
Basically the user needs two things: a configuration file and a command line to execute it.

Configuration

In <OX_HOME>/demo/config create an xml file called <mp-config-filename>.xml
Edit it to be compliant with MP main configuration structure. (The xsd is for soon). See configuration.
Here is a example of configuration
<!DOCTYPE root>
<generator-config>
    <configuration>
        <model name="petshop" version="1.0" package-root="sf.net.mp.demo.ox">
            <data-model>
                <dataSource>
                    <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
                    <url>jdbc:hsqldb:hsql://127.0.0.1:9001/petshop</url>
                    <username>sa</username>
                    <password></password>
                </dataSource>
                <!-- for Oracle and DB2 please set the schema
                <schema> </schema>
                 -->
                <primaryKeyPolicy oneGlobal="true" oneForEachTable="false">
                    <primaryKeyPolicyPattern prefix="" suffix="" name="sequencePattern" sequenceName="hibernate_sequence"></primaryKeyPolicyPattern>
                    <!-- for autogenerated pk (mysql)
                    <primaryKeyPolicyPattern name="autoincrementPattern" ></primaryKeyPolicyPattern>
                    -->
                </primaryKeyPolicy>
            </data-model>
            <business-model>
                <generation-condition>
                    <condition type="exclude" startsWith="DUAL"></condition>
                    <condition type="exclude" startsWith="ID_GEN"></condition>
                </generation-condition>
                <business-package default="pet">
                </business-package>
            </business-model>
        </model>
        <targets catalog-entry="OpenXava"/>
    </configuration>
</generator-config>
To have the JPA2 artifacts in groovy
        <targets catalog-entry="OpenXava">
          <property name="groovify" value="true"/>
        </targets>

You can also get inspiration from the demo file <MP_HOME>/demo/config/mp-config-openxava-last-features.xml.

On <MP_HOME>/demo/config copy demo-last-features-openxava.cmd into <myModel>.(sh/cmd) and edit the last line accordingly.
%JAVA_HOME%\bin\java” %CP% net.sf.minuteProject.application.ModelViewGenerator <mp-config-filename>.xml

Execution

On <MP_HOME>/demo/config execute:
<myModel>.cmd for Windows
./<myModel>.sh for Linux

Generation

MinuteProject generate a number of files OpenXava compliant.
For more information about the generated artifacts go here.

Step 2: All the rest

All the rest means: execution of the following tasks:
  • create an OX eclipse project;
  • copy the generated artifact in it;
  • copy mp-openxava-x.y.z.jar in it;
  • build web application;
  • copy connection pool to tomcat context.xml (Note it replaces your current context.xml)
  • start tomcat;
  • deploy;
  • build portlets;
  • start browser that points to the deployed application
The only step that is not done (and in some case to be done manually) is to copy the jdbc driver jar into tomcat classpath.
MinuteProject provides an artifact that does 'all the rest' for you.

Execution

On the main generated directory execute
build-<myModel>.cmd on Windows
./build-<myModel>.sh on Linux

Remark:
For Linux, you may need to refresh the URL proposed by the browser since the deployment of <myModel> application may not be finished on Tomcat.

Demo

MinuteProject is shipped with demos. This demo shows a sample minuteProject 4 OpenXava generation for the petshop database.
This part shows the setup to delivery steps to run the demo of the distribution.

Prequisites

Download OpenXava version 4.0.
Download minuteproject last version.
Ant and Java 1.6 setup.
Have a DB up and jdbc connection parameters.
Set up system variable <OX_HOME> that points to OpenXava 4.5 home. This is mandatory to run the script on the second step.
Set up system variable <MP_HOME> that points to MinuteProject home. This is mandatory to run the script on the second step.

Step 1: MinuteProject generation

On <MP_HOME>/sample
>start-petshop-database.bat (soon the .sh version)

On <MP_HOME>/demo/config
>demo-last-features-openxava.cmd
The generated artifacts go in <MP_HOME>/demo/output/openxava/petshopOpenXava

Step 2: All the rest

Go to <MP_HOME>/demo/output/openxava/petshopOpenXava
Execute build-Petshop.cmd (soon the .sh version)

Remark: if you want to reset your actions execute reset-Petshop.cmd

If everything goes well the last step should open a browser to the following page http://localhost:8080/petshop/xava/homeMenu.jsp
Remark:
For Linux, you may need to refresh the URL proposed by the browser since the deployment of <myModel> application may not be finished on Tomcat.

You will have an application for that performs all the CRUD UC for the Petshop entities (Address, Category, Item, Product, SellerContactInfo, Tag, ZipLocation) compatible with OpenXava framework.

Screenshoots

Here are some screenshoots (target OX 4.m4) for OX 4.m5+ there are the both and helper (fr, en) functionalities available.

Menu

mp-openxava-petshop-menu.jpg

Address list

mp-openxava-petshop-address-list.jpg

Address detail

mp-openxava-petshop-address-detail.jpg

Add an address

mp-openxava-petshop-address-add.jpg