Skip to content

asinghal/Play-ScalaGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scala code generators for the Play! framework
--------------------------------------------------------------------------

This module can be used to generate Scala code. It can generate JPA based models, CRUD and associated test cases.

--------------------------------------------------------------------------
Options:
--------------------------------------------------------------------------

--scaffold-jpa [entity name] [attribute1:type1]*     Generates the JPA based model and associated CRUD code.
--model-jpa [entity name] [attribute1:type1]*         Generates the JPA based model.
--scaffold-siena [entity name] [attribute1:type1]*     Generates the Siena based model and associated CRUD code.

Note: --scaffold and --model are shortcuts to generate JPA

These generators can only be used from inside a Scala Play! project. To create a new project, use the following commands:
play new myproject --with scala
cd myproject
play scalagen:generate --scaffold <provide details of the scaffold you need to create>

==========================================================================================================
Installation:
==========================================================================================================
1. Extract the contents of /dist/scalagen-0.1.zip into a local directory on the server.
2. Add the following to dependencies.yml
    - customModules -> scalagen

repositories:
    - playCustomModules:
        type: local
        artifact: "/full/path/to/scalagen/directory"
        contains:
            - customModules -> *
3. Run "play deps" on the project

That's it!

--------------------------------------------------------------------------
Usage Examples: 
--------------------------------------------------------------------------

*Note*: As a prerequisite, you must install the jquery grid files before a generated scaffold can be used. It is a one time activity per project. Please run the following for the same:

play scalagen:jquery


1. Generating a CRUD scaffold:
--------------------------------------------------------------------------

play scalagen:generate --scaffold User name:String login:String role:Role

For the lazy, the following does the same: play scalagen:g --s User name:String login:String role:Role

The Siena equivalent is :
play scalagen:g --ss User name:String login:String role:Role

This will create a controller, view files for CRUD, model, unit tests for the model and selenium tests for CRUD operations.

*Note*: The generated controllers use JQGrid for the index/ listing page and provide pagination, search and sorting of data. If you would rather use a plain HTML show all view, please pass flatHTML=true in the URL parameters.

2. Generating a JPA model:
--------------------------------------------------------------------------

play scalagen:generate --model User name:String login:String role:Role

For the lazy, the following does the same: play scalagen:g --m User name:String login:String role:Role

This will create a JPA model and associated unit tests.

--------------------------------------------------------------------------
Known Limitations: 
--------------------------------------------------------------------------
1. This module can only create models for basic data types. All other data types are assumed to be many-to-one relationships.
2. The parameters passed on command line can not have space between attribute name and type.
3. The module only supports JPA via Hibernate at the moment.

About

Scala Code generators for Play! framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published