Skip to content

adminfaces/admin-addon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdminFaces Addon

Build Status (Travis CI) Coverage

This forge addon enables AdminFaces setup, scaffold from JPA entities, test-setup, new service tests and scaffold config commands.

admin addon

1. Installation

Use install addon from git command:

addon-install-from-git --url https://github.com/adminfaces/admin-addon.git

or install from catalog:

install from catalog

2. Commands

2.1. AdminFaces: Setup

It will install AdminFaces dependencies, resources and initial configuration.

2.2. AdminFaces: Scaffold

In order to enable scaffold generate command you first need to execute Scaffold setup command, see images below.

scaffold setup
scaffold generate01
scaffold generate02

Scaffold generate will create crud, including list, form pages and menu entry, on top of selected entities. The generated crud is based on admin-persistence framework.

2.2.1. Scaffold limitations

To get most of scaffold command and to not generate invalid code, follow these two rules:

  1. Use field based access on your JPA entities, more details here. The scaffold command doesn’t support method (property) based access.

  2. Use bidirectional relationships, see here

2.2.2. Generate entities from database

The recommended way to generate JPA entities from database is to use NetBeans, see here.

It will use field based access and depending on your database schema it will use bidirectional associations.

2.3. AdminFaces: Scaffold config

After scaffold generation the addon will create default scaffold configuration files under src/main/resources/scaffold for each entity and also a global-config.yml file. These configuration files default values are based on the entities provided on scaffold generation and the global file.

In order to change scaffold configuration for each entity or the global configuration you either can edit the files manually or use AdminFaces: Scaffold config command.

admin scaffold config01
admin scaffold config02
admin scaffold config03
admin scaffold config04

2.4. AdminFaces: Test harness setup

It will setup integration tests dependencies and resource files such as DeltaSpike test control and Database Rider.

test harness setup

2.5. AdminFaces: New service test

The Test harness setup command will enable the New service test which will generate integration tests based on service classes. The command will also generare dbunit yml datasets based on the service entity.

admin new service test
admin new service test02
💡
Use dbunit-addon to generate test datasets.

3. Demo video

Demo

4. Generated application

You can find the generated application by AdminFaces scaffold here: https://github.com/adminfaces/generated-scaffold-app/

It was generated using the following commands (you can paste all commands [at once] on the forge console in eclipse ide or using the forge on command line):

clear;

project-new --named admin-app --top-level-package com.github.adminfaces.app --type war --final-name admin-app --version 1.0 ;

javaee-setup --java-ee-version 7 ;

jpa-setup --persistence-unit-name adminPU --jpaVersion 2.1 --jpa-provider "Hibernate 4.x" --container WILDFLY --db-type H2 --data-source-name java:jboss/datasources/ExampleDS ;

adminfaces-setup ;


jpa-new-entity --named Talk ;

jpa-new-field --named title ;

jpa-new-field --named description --length 2000 ;

jpa-new-field --named date --type java.util.Date --temporal-type DATE ;

constraint-add --on-property title --constraint NotNull ;

constraint-add --on-property description --constraint Size --max 2000 ;

constraint-add --on-property date --constraint NotNull ;

jpa-new-entity --named Room ;

jpa-new-field --named name --length 20 ;

jpa-new-field --named capacity --type java.lang.Short ;

jpa-new-field --named hasWifi --type java.lang.Boolean ;

constraint-add --on-property name --constraint NotNull ;

constraint-add --on-property capacity --constraint NotNull ;

jpa-new-embeddable --named Address ;

jpa-new-field --named street --length 50 --not-nullable ;

jpa-new-field --named city  --length 50 --not-nullable ;

jpa-new-field --named zipcode --columnName --length 10 --not-nullable --type java.lang.Integer ;

jpa-new-field --named state ;

jpa-new-entity --named Speaker ;

jpa-new-field --named firstname ;

jpa-new-field --named surname ;

jpa-new-field --named bio --length 2000 ;

jpa-new-field --named twitter ;

jpa-new-field --named talks --type com.github.adminfaces.app.model.Talk --relationship-type One-to-Many --inverse-field-name speaker ;

jpa-new-field --named address --entity --type com.github.adminfaces.app.model.Address --relationship-type Embedded ;

constraint-add --on-property firstname --constraint NotNull ;

constraint-add --on-property surname --constraint NotNull ;

constraint-add --on-property bio --constraint Size --max 2000 ;

cd ../Talk.java

jpa-new-field --named room --type com.github.adminfaces.app.model.Room --relationship-type Many-to-One --inverse-field-name talks ;

constraint-add --on-property speaker --constraint NotNull ;

constraint-add --on-property room --constraint NotNull ;

scaffold-setup --provider AdminFaces ;

scaffold-generate --provider AdminFaces --entities com.github.adminfaces.app.model.* ;

adminfaces-test-harness-setup ;

adminfaces-new-service-test --target-services com.github.adminfaces.app.service.* ;

build test --profile it-tests ;

;
💡
See this video which shows the execution of above commands.

About

JBoss Forge Addon to generate CRUD pages (scaffolding from entities) using AdminFaces

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages