Skip to content

Wellcome to my College API with Java Quarkus Framework. This is a project related to Programming Subject. This project encompasses all the concepts and learnings from Quarkus guide, OpenWebinars and Concepts of Programming's Subject. Enjoy it!!!

Notifications You must be signed in to change notification settings

matdevcoder/College-API-Rest-Quarkus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

College API REST Quarkus

About this Project

Wellcome to my Project College API Rest with DAO Pattern and Quarkus FrameWork related to Java. This project is a API related to College System where you will find and get data of: Students, Universities, Tuition, Enrollments and Courses. Things to consider:

  1. This project has branches which are related with "Programming" asignature where are basically related with:
  • This API's using MySQL, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/MySQL

  • This API's using MariaDB, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/MariaDB

  • This API's using PostGreSQL, it's the default Database that I use, you can find it here:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/master

  • This API's using PostGreSQL with Active Record Pattern:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/active-record

  • This API's using name of the University as ID and using mappedBy with this:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/mappedby-name

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/mappedby-name/src/main/java/org/acme/rest/json/entities/University.java

  • This API's using ID type Long of the Student as ID and using mappedBy with this:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/tree/feature/students

In this branch you can see in the Scripts SQL, Entities and enpoints how I use by ID

  1. This Project use all type of Relations: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany. With bidirectional and unidirectional form. All these relations are adaptared with the Entities and Tables.
  • Relation @OneToOne using a Brigde Table "Enrollment":

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/Enrollment.java

  • Relation @ManyToOne and @OneToMany bidirectional -> Student -> University:

@ManyToOne https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/Student.java

@OneToMany https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/java/org/acme/rest/json/entities/University.java

  • Relation @ManyToMany using a Bridge Table "Classes" using @ManyToOne unidirectional(It's a way to do it in replace of to do @ManyToMany with @JoinTable which it's inneficient because we cannot add more field in this Brigde Entity in a JPA context):
  1. You can find the Definition of SQL tables here:

PostGreSQL:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/students/src/main/resources/import-dev.sql

MySQL and MariaDB:

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/MySQL/src/main/resources/import-dev.sql

https://github.com/MateoGarciaG/College-API-Rest-Quarkus/blob/feature/MariaDB/src/main/resources/import-dev.sql


Important: If you want more details about why there are a lot of branches and my process you can go to Reflections's section


status application





Tabla de Contenidos

  1. Tecnologías Usadas
  2. Relational Entity Diagram
  3. Apuntes
  4. Data API Rest JSON
  5. Licencia

Tecnologías Usadas

  • Java JDK 11
  • Maven
  • Visual Studio Code
  • IntelliJ
  • Git
  • Docker
  • Quarkus
  • Panache
  • TestContainers

⬆ back to top


RELATIONAL ENTITY DIAGRAM

Relational Entity Diagram

⬆ back to top


Data API Rest JSON

Example with Students:

// GET All http://localhost:8080/api/students/all

[
    {
        "name": "Mateo",
        "surname": "Alvarez",
        "dateBirth": "2005-06-05",
        "phone": "+34 666666666",
        "id": 1050
    },
    {
        "name": "Will",
        "surname": "Smith",
        "dateBirth": "1999-06-17",
        "phone": "+34 677878997",
        "id": 2050
    }
]


// POST : http://localhost:8080/api/students/add
{
    "name": "Pedro",
    "surname": "Gimenez",
    "dateBirth": "1990-12-17",
    "phone": "+34 687687878",
    "university": {
        "id": 1
    }
}
// GET by name : http://localhost:8080/api/students/Mateo

{
    "name": "Mateo",
    "surname": "Alvarez",
    "dateBirth": "2005-06-05",
    "phone": "+34 666666666",
    "id": 1050
}

// PUT : http://localhost:8080/api/students/put

{
    "name": "Pedro",
    "surname": "Gomez",
    "dateBirth": "2010-12-17",
    "phone": "+34 677777777",
    "university": {
        "id": 50
    }
}

// DELETE : http://localhost:8080/api/students/delete/1050
[
    {
        "name": "Will",
        "surname": "Smith",
        "dateBirth": "1999-06-17",
        "phone": "+34 677878997",
        "id": 2050
    }
]

⬆ back to top



Reflexiones

Que has mejorado con este proyecto?

This Project has let me to learn how to create an API REST using DAO Pattern and using all type of Relationals JPA and SQL: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany

This project let me to understand better all concepts trying to create a Real Simulation of a API with I was trying to test different DataTypes of SQL with DataTypes of Java and test if it's works

I prefer DAO pattern because let me to separate more the Layers in the API and because The Entity doesn't have to managed by itself like in the Active Pattern where through PanacheEntity, the Entity use the methods like a EntityManager. So this pattern let me to separate the EntityManager from the Entity itself with a new layer called: RESPOSITORY

⬆ back to top


Licencia

MIT License

Copyright (c) 2021 Mateo Garcia Gonzalez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

⬆ back to top


Autor

Mateo Garcia Gonzalez


About

Wellcome to my College API with Java Quarkus Framework. This is a project related to Programming Subject. This project encompasses all the concepts and learnings from Quarkus guide, OpenWebinars and Concepts of Programming's Subject. Enjoy it!!!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published