Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fugerit-org/fj-daogen-quickstart
Quick start for Fugerit DaoGen framework
https://github.com/fugerit-org/fj-daogen-quickstart
Last synced: 13 days ago
JSON representation
Quick start for Fugerit DaoGen framework
- Host: GitHub
- URL: https://github.com/fugerit-org/fj-daogen-quickstart
- Owner: fugerit-org
- License: apache-2.0
- Created: 2019-08-25T21:08:25.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-12-24T00:28:57.000Z (14 days ago)
- Last Synced: 2024-12-24T01:27:53.531Z (14 days ago)
- Language: Java
- Size: 299 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Mars - Fugerit DAOGEN A.P.I. Quickstart
[![Keep a Changelog v1.1.0 badge](https://img.shields.io/badge/changelog-Keep%20a%20Changelog%20v1.1.0-%23E05735)](https://github.com/fugerit-org/fj-daogen-quickstart/blob/main/CHANGELOG.md)
[![license](https://img.shields.io/badge/License-Apache%20License%202.0-teal.svg)](https://opensource.org/licenses/Apache-2.0)
[![code of conduct](https://img.shields.io/badge/conduct-Contributor%20Covenant-purple.svg)](https://github.com/fugerit-org/fj-universe/blob/main/CODE_OF_CONDUCT.md)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=fugerit-org_fj-daogen-quickstart&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=fugerit-org_fj-daogen-quickstart)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=fugerit-org_fj-daogen-quickstart&metric=coverage)](https://sonarcloud.io/summary/new_code?id=fugerit-org_fj-daogen-quickstart)
[![Docker images](https://img.shields.io/badge/dockerhub-images-important.svg?logo=Docker)](https://hub.docker.com/repository/docker/fugeritorg/fj-daogen-quickstart/general)Sample applications to learn usage of DaoGen framework.
Index :
1. Run the project
2. Configuration notes
3. DaoGen tutorial## 1. Run the project ##
1. Minimum java 17 is required
2. mvn spring-boot:run
3. Open one of the rest URL http://localhost:8080/fj-daogen-quickstart/jax-rs/person/load/deep/id/3Tested with :
* Amazon Corretto 17.07.7.1
* Maven 3.9.0NOTE: index page fj-daogen-quickstart contains a few api links
## 2. Configuration notes ##
The project use an hqsldb in memory DB, so it doesn't require any further configuration.
*2.1 Data base sample configuration*
DB configuration is in folder:
src/main/resources/quickstart_db
+quickstart-db-conn.properties [contains database jdbc connection properties]
+hsqldb [contains database init script to work in (all files in this folder will be loaded to init db at startup]
+100_db_setup.sql [contains create schema, sequences etc]
+200_sample_db.sql [contains starting entity and relations, plus some records]*2.2 DaoGen configuration file
DaoGen configuration is in path :
src/main/resources/daogen/daogen-config.xml
The root element contains all the basic properties of generation.
They are all set for this project, but you need to update some of them if you need to configure for another project (especially package name and source folder).## 3. DaoGen tutorial ##
Quick tutorial to add one entity to the project.
All the files of this tutorial are, as an example, in folder src/test/resources/tutorial### 3.1 Add entity configuration script
For instance we will add an equipment table (src/main/resources/quickstart_db/hsqldb/300_equipment.sql) :
```
CREATE TABLE daogen_quickstart.equipment (
id BIGINT NOT NULL,
id_owner BIGINT,
id_creator BIGINT,
creation_date TIMESTAMP NOT NULL,
update_date TIMESTAMP NOT NULL,
description VARCHAR(1024) NOT NULL,
state BIGINT NOT NULL
);ALTER TABLE daogen_quickstart.equipment ADD CONSTRAINT equipment_pk PRIMARY KEY ( id );
ALTER TABLE daogen_quickstart.equipment ADD CONSTRAINT equipment_fk1 FOREIGN KEY ( id_owner ) REFERENCES person ( id );
ALTER TABLE daogen_quickstart.equipment ADD CONSTRAINT equipment_fk2 FOREIGN KEY ( id_creator ) REFERENCES person ( id );COMMENT ON TABLE daogen_quickstart.equipment IS 'equipments meta informations';
COMMENT ON COLUMN daogen_quickstart.equipment.id_owner IS 'Reference to owner';
COMMENT ON COLUMN daogen_quickstart.equipment.id_creator IS 'Reference to creator';
COMMENT ON COLUMN daogen_quickstart.equipment.creation_date IS 'equipment creation time';
COMMENT ON COLUMN daogen_quickstart.equipment.update_date IS 'equipment update time';
COMMENT ON COLUMN daogen_quickstart.equipment.description IS 'equipments description';
COMMENT ON COLUMN daogen_quickstart.equipment.state IS 'equipment state';INSERT INTO daogen_quickstart.equipment VALUES ( 20, 1, 3, '2019-03-01', '2019-03-02', 'First Silmaril', 1 );
INSERT INTO daogen_quickstart.equipment VALUES ( 21, 2, 3, '2019-03-01', '2019-03-02', 'First Silmaril', 1 );
INSERT INTO daogen_quickstart.equipment VALUES ( 22, 3, 3, '2019-03-01', '2019-03-02', 'First Silmaril', 1 );
```### 3.2 Dump the configuration
Run the main class src/main/test :
`test.org.fugerit.java.daogen.quickstart.tools.DaogenDump`
This will dump the configuration, you can then copy paste from output the configuration of the new entity ( src/main/resources/daogen/daogen-config.xml from section 2.2 ) :
```
```### 3.3 Code generation
Update the file [daogen-config.xml](src/main/daogen/daogen-config.xml), then run :
`mvn fj-daogen:generate`
to regenerate the resources. (see the [fj-daogen-maven-plugin](https://docs.fugerit.org/data/java/site/fj-daogen-maven-plugin/generate-mojo.html) reference and [documentation](https://marsdocs.fugerit.org/src/docs/maven-plugin/generate.html) for more information)
For example, if this test link is accessed :
`http://localhost:8080/fj-daogen-quickstart/jax-rs/person/load/id/3`
output will be :
`{"id":3,"surname":"Noldor","name":"Feanor","birthDate":"1999-12-31","note":"Great smith","idMother":1,"idFather":2,"mother":null,"father":null,"owndocuments":null,"empty":false}`
If the line 67 is removed :
``
The new output will be :
`{"id":3,"surname":"Noldor","name":"Feanor","birthDate":"1999-12-31","idMother":1,"idFather":2,"mother":null,"father":null,"owndocuments":null,"empty":false}`
### 3.4 Add rest service configuration
Add the newly built REST service LoadEquipment to jaxrs application :
org.fugerit.java.daogen.quickstart.config.DaogenQuickstart
```
public class DaogenQuickstart extends javax.ws.rs.core.Application {public Set> getClasses() {
Set> s = new HashSet>();
s.add(org.fugerit.java.daogen.quickstart.impl.rest.load.LoadPerson.class);
s.add(org.fugerit.java.daogen.quickstart.impl.rest.load.LoadDocument.class);
s.add(org.fugerit.java.daogen.quickstart.impl.rest.load.LoadEquipment.class);
return s;
}
}
```### 3.5 Test result
Start the application and test the service :
[test page](http://localhost:8080/fj-daogen-quickstart/)