https://github.com/adminfaces/admin-addon
JBoss Forge Addon to generate CRUD pages (scaffolding from entities) using AdminFaces
https://github.com/adminfaces/admin-addon
Last synced: 3 months ago
JSON representation
JBoss Forge Addon to generate CRUD pages (scaffolding from entities) using AdminFaces
- Host: GitHub
- URL: https://github.com/adminfaces/admin-addon
- Owner: adminfaces
- Created: 2017-08-05T14:07:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-09-01T23:01:31.000Z (over 3 years ago)
- Last Synced: 2025-04-30T21:08:29.298Z (8 months ago)
- Language: Java
- Homepage:
- Size: 2.84 MB
- Stars: 3
- Watchers: 1
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.asciidoc
Awesome Lists containing this project
README
= AdminFaces Addon
:page-layout: base
:toc: preamble
:source-language: java
:icons: font
:linkattrs:
:sectanchors:
:sectlink:
:numbered:
:doctype: book
:tip-caption: :bulb:
:note-caption: :information_source:
:important-caption: :heavy_exclamation_mark:
:caution-caption: :fire:
:warning-caption: :warning:
image:https://travis-ci.org/adminfaces/admin-addon.svg[Build Status (Travis CI), link=https://travis-ci.org/adminfaces/admin-addon]
image:https://coveralls.io/repos/adminfaces/admin-addon/badge.svg?branch=master&service=github[Coverage, link=https://coveralls.io/r/adminfaces/admin-addon]
This forge addon enables http://github.com/adminfaces/[AdminFaces^] `setup`, `scaffold from JPA entities`, `test-setup`, `new service tests` and `scaffold config` commands.
image::img/admin-addon.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-addon.png?raw=true"]
== Installation
Use install addon from git command:
----
addon-install-from-git --url https://github.com/adminfaces/admin-addon.git
----
`or` install from catalog:
image::img/install-from-catalog.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/install-from-catalog.png?raw=true"]
== Commands
=== *AdminFaces: Setup*
====
It will install AdminFaces dependencies, resources and initial configuration.
====
=== *AdminFaces: Scaffold*
====
In order to enable *scaffold generate* command you first need to execute *Scaffold setup* command, see images below.
====
image::img/scaffold-setup.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/scaffold-setup.png?raw=true"]
image::img/scaffold-generate01.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/scaffold-generate01.png?raw=true"]
image::img/scaffold-generate02.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/scaffold-generate02.png?raw=true"]
`Scaffold generate` will create crud, including list, form pages and menu entry, on top of selected entities. The generated crud is based on http://github.com/adminfaces/admin-persistence/[admin-persistence^] framework.
==== Scaffold limitations
To get most of scaffold command and to not generate invalid code, follow these two rules:
. Use *field based access* on your JPA entities, more https://thoughts-on-java.org/access-strategies-in-jpa-and-hibernate/[details here^]. The scaffold command *doesn't support* method (property) based access.
. Use bidirectional relationships, https://thoughts-on-java.org/hibernate-tips-map-bidirectional-many-one-association/[see here^]
==== Generate entities from database
The recommended way to generate JPA entities from database is to use NetBeans, https://www.javacodegeeks.com/2016/02/netbeans-java-ee-tip-1-entity-classes-database.html[see here^].
It will use field based access and depending on your database schema it will use bidirectional associations.
=== *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.
====
image::img/admin-scaffold-config01.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-scaffold-config01.png?raw=true"]
image::img/admin-scaffold-config02.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-scaffold-config02.png?raw=true"]
image::img/admin-scaffold-config03.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-scaffold-config03.png?raw=true"]
image::img/admin-scaffold-config04.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-scaffold-config04.png?raw=true"]
=== *AdminFaces: Test harness setup*
====
It will setup `integration tests` dependencies and resource files such as https://deltaspike.apache.org/documentation/test-control.html[DeltaSpike test control^] and https://github.com/database-rider/database-rider[Database Rider^].
====
image::img/test-harness-setup.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/test-harness-setup.png?raw=true"]
=== *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.
====
image::img/admin-new-service-test.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-new-service-test.png?raw=true"]
image::img/admin-new-service-test02.png[link="https://github.com/adminfaces/admin-addon/blob/master/img/admin-new-service-test02.png?raw=true"]
TIP: Use https://github.com/database-rider/dbunit-addon[dbunit-addon] to `generate test datasets`.
== Demo video
image::http://i3.ytimg.com/vi/_uZXXnvJp_E/hqdefault.jpg[Demo, link=https://www.youtube.com/watch?v=_uZXXnvJp_E, window="_blank", height="350", width="600"]
== 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 ;
;
----
TIP: https://www.youtube.com/watch?v=_uZXXnvJp_E[See this video^] which shows the execution of above commands.