├── customer ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── panache-archive.marker │ │ ├── docker │ │ │ └── customer-db-mariadb.yaml │ │ └── java │ │ │ └── org │ │ │ └── agoncal │ │ │ └── quarkus │ │ │ └── jpa │ │ │ └── Customer.java │ └── test │ │ ├── java │ │ └── org │ │ │ └── agoncal │ │ │ └── quarkus │ │ │ └── jpa │ │ │ ├── CustomerRepository.java │ │ │ └── CustomerRepositoryTest.java │ │ └── resources │ │ └── application.properties ├── .dockerignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── README.md ├── pom.xml └── mvnw.cmd ├── .dockerignore ├── artist ├── .dockerignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── docker │ │ │ └── artist-db-mysql.yaml │ │ └── java │ │ │ └── org │ │ │ └── agoncal │ │ │ └── quarkus │ │ │ └── jdbc │ │ │ └── Artist.java │ └── test │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── org │ │ └── agoncal │ │ └── quarkus │ │ └── jdbc │ │ ├── ArtistRepositoryTest.java │ │ └── ArtistRepository.java ├── .gitignore ├── README.md ├── pom.xml └── mvnw.cmd ├── docs ├── images │ └── qute.jpg └── plantuml │ ├── model-publisher.puml │ ├── model-publisher-entity.puml │ ├── model-vintage-repository.puml │ ├── model-vintage-page.puml │ ├── model-vintage-resource.puml │ ├── model-artist.puml │ ├── model-publisher-repository.puml │ ├── model-customer.puml │ ├── style.iuml │ ├── panache-entity.puml │ ├── panache-repository-artist.puml │ ├── panache-repository.puml │ ├── model-vintage.puml │ ├── panache-repository-vs-active-rec.puml │ └── panache-entity-managing.puml ├── vintage-store ├── .dockerignore ├── src │ ├── main │ │ ├── resources │ │ │ ├── META-INF │ │ │ │ ├── resources │ │ │ │ │ └── index.html │ │ │ │ └── orm.xml │ │ │ ├── templates │ │ │ │ ├── ArtistPage │ │ │ │ │ ├── artists.html │ │ │ │ │ └── artist.html │ │ │ │ ├── PublisherPage │ │ │ │ │ ├── publishers.html │ │ │ │ │ └── publisher.html │ │ │ │ ├── CustomerPage │ │ │ │ │ ├── customers.html │ │ │ │ │ └── customer.html │ │ │ │ ├── PurchaseOrderPage │ │ │ │ │ ├── purchaseOrders.html │ │ │ │ │ └── purchaseOrder.html │ │ │ │ ├── ItemPage │ │ │ │ │ ├── cds.html │ │ │ │ │ ├── books.html │ │ │ │ │ ├── cd.html │ │ │ │ │ └── book.html │ │ │ │ └── base.html │ │ │ └── application.properties │ │ ├── java │ │ │ └── org │ │ │ │ └── agoncal │ │ │ │ └── quarkus │ │ │ │ └── panache │ │ │ │ ├── model │ │ │ │ ├── Language.java │ │ │ │ ├── OrderLine.java │ │ │ │ ├── Item.java │ │ │ │ ├── CD.java │ │ │ │ ├── PurchaseOrder.java │ │ │ │ ├── Book.java │ │ │ │ ├── Publisher.java │ │ │ │ └── Track.java │ │ │ │ ├── repository │ │ │ │ ├── ArtistRepository.java │ │ │ │ └── CustomerRepository.java │ │ │ │ ├── page │ │ │ │ ├── PublisherPage.java │ │ │ │ ├── PurchaseOrderPage.java │ │ │ │ ├── ArtistPage.java │ │ │ │ ├── CustomerPage.java │ │ │ │ └── ItemPage.java │ │ │ │ └── resource │ │ │ │ ├── PurchaseOrderResource.java │ │ │ │ ├── CustomerResource.java │ │ │ │ ├── PublisherResource.java │ │ │ │ ├── ArtistResource.java │ │ │ │ └── ItemResource.java │ │ └── docker │ │ │ └── vintage-store-db-postgresql.yaml │ └── test │ │ └── java │ │ └── org │ │ └── agoncal │ │ └── quarkus │ │ └── panache │ │ ├── PanacheActiveRecordTest.java │ │ ├── repository │ │ ├── TrackRepositoryTest.java │ │ ├── ArtistRepositoryTest.java │ │ ├── CustomerRepositoryTest.java │ │ ├── PublisherRepositoryTest.java │ │ ├── CDRepositoryTest.java │ │ ├── BookRepositoryTest.java │ │ └── PurchaseOrderRepositoryTest.java │ │ ├── EntityManagerTest.java │ │ ├── PanacheRepositoryTest.java │ │ └── resource │ │ ├── ArtistResourceTest.java │ │ ├── PublisherResourceTest.java │ │ ├── CustomerResourceTest.java │ │ └── PurchaseOrderResourceTest.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── README.md ├── pom.xml └── mvnw.cmd ├── database-generator ├── .dockerignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ └── main │ │ └── java │ │ └── org │ │ └── agoncal │ │ └── quarkus │ │ └── Language.java ├── .gitignore ├── README.md ├── pom.xml └── mvnw.cmd ├── curl.sh ├── .mvn └── wrapper │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── bootstrap-artist.sh ├── bootstrap-customer.sh ├── bootstrap-vintage-store.sh ├── .editorconfig ├── pom.xml ├── .gitignore ├── README.md ├── pom-copy.xml └── mvnw.cmd /customer/src/main/resources/META-INF/panache-archive.marker: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /artist/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /customer/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /docs/images/qute.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agoncal/agoncal-course-quarkus-jpa-panache/HEAD/docs/images/qute.jpg -------------------------------------------------------------------------------- /vintage-store/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /database-generator/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /curl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Vintage Store 3 | curl -H "Content-Type: application/json" -X POST http://localhost:8080/api/publishers -d '{"name": "Lorem"}' -v 4 | curl http://localhost:8080/api/artists/2 5 | -------------------------------------------------------------------------------- /docs/plantuml/model-publisher.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | class PanacheEntity { 5 | } 6 | class Publisher <> { 7 | + name: String 8 | + createdDate: Instant 9 | } 10 | PanacheEntity <|-- Publisher 11 | @enduml 12 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /artist/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /customer/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /vintage-store/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /database-generator/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /bootstrap-artist.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | mvn -U io.quarkus:quarkus-maven-plugin:create \ 3 | -DprojectGroupId=org.agoncal.course.quarkus.orm \ 4 | -DprojectArtifactId=artist \ 5 | -DpackageName="org.agoncal.quarkus.jdbc" \ 6 | -Dextensions="jdbc-mysql, quarkus-agroal" 7 | -------------------------------------------------------------------------------- /docs/plantuml/model-publisher-entity.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | class PanacheEntity { 5 | + id: Long <> <> 6 | } 7 | class Publisher <> { 8 | + name: String 9 | + createdDate: Instant 10 | } 11 | PanacheEntity <|-- Publisher 12 | @enduml 13 | -------------------------------------------------------------------------------- /docs/plantuml/model-vintage-repository.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | hide methods 4 | hide fields 5 | 6 | class ArtistRepository <> {} 7 | class CustomerRepository <> { } 8 | 9 | CustomerRepository-[hidden]- ArtistRepository 10 | @enduml 11 | -------------------------------------------------------------------------------- /bootstrap-customer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | mvn -U io.quarkus:quarkus-maven-plugin:create \ 3 | -DprojectGroupId=org.agoncal.course.quarkus.orm \ 4 | -DprojectArtifactId=customer \ 5 | -DpackageName="org.agoncal.quarkus.jpa" \ 6 | -Dextensions="jdbc-mariadb, hibernate-orm" 7 | -------------------------------------------------------------------------------- /database-generator/src/main/java/org/agoncal/quarkus/Language.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus; 2 | 3 | /** 4 | * @author Antonio Goncalves 5 | * http://www.antoniogoncalves.org 6 | * -- 7 | */ 8 | public enum Language { 9 | ENGLISH, FRENCH, SPANISH, PORTUGUESE, RUSSIAN, CHINESE, INDIAN, GERMAN, JAPANESE 10 | } 11 | -------------------------------------------------------------------------------- /docs/plantuml/model-vintage-page.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | left to right direction 4 | hide methods 5 | hide fields 6 | 7 | class ArtistPage <> 8 | class CustomerPage <> 9 | class ItemPage <> 10 | class PublisherPage <> 11 | class PurchaseOrderPage <> 12 | 13 | @enduml 14 | -------------------------------------------------------------------------------- /bootstrap-vintage-store.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | mvn -U io.quarkus:quarkus-maven-plugin:create \ 3 | -DprojectGroupId=org.agoncal.course.quarkus.orm \ 4 | -DprojectArtifactId=vintage-store \ 5 | -DpackageName="org.agoncal.quarkus.panache" \ 6 | -Dextensions="jdbc-postgresql, hibernate-orm-panache" 7 | -------------------------------------------------------------------------------- /docs/plantuml/model-vintage-resource.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | left to right direction 4 | hide methods 5 | hide fields 6 | 7 | class ArtistResource <> 8 | class CustomerResource <> 9 | class ItemResource <> 10 | class PublisherResource <> 11 | class PurchaseOrderResource <> 12 | 13 | @enduml 14 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/Language.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | /** 4 | * @author Antonio Goncalves 5 | * http://www.antoniogoncalves.org 6 | * -- 7 | */ 8 | public enum Language { 9 | ENGLISH, FRENCH, SPANISH, PORTUGUESE, RUSSIAN, CHINESE, INDIAN, GERMAN, JAPANESE 10 | } 11 | -------------------------------------------------------------------------------- /vintage-store/src/main/docker/vintage-store-db-postgresql.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | vintagestore_database: 4 | image: "postgres:13.3" 5 | container_name: "vintagestore_database" 6 | ports: 7 | - "5432:5432" 8 | environment: 9 | - POSTGRES_DB=vintagestore_database 10 | - POSTGRES_USER=vintageuser 11 | - POSTGRES_PASSWORD=vintagepwd 12 | -------------------------------------------------------------------------------- /artist/src/main/docker/artist-db-mysql.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | artists_database: 4 | image: "mysql:8.0.25" 5 | container_name: "artists_database" 6 | ports: 7 | - "3306:3306" 8 | environment: 9 | - MYSQL_ROOT_PASSWORD=root_artistspwd 10 | - MYSQL_DATABASE=artists_database 11 | - MYSQL_USER=artistsuser 12 | - MYSQL_PASSWORD=artistspwd 13 | -------------------------------------------------------------------------------- /customer/src/main/docker/customer-db-mariadb.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | customers_database: 4 | image: "mariadb:10.6.0" 5 | container_name: "customers_database" 6 | ports: 7 | - "3306:3306" 8 | environment: 9 | - MYSQL_ROOT_PASSWORD=root_customerspwd 10 | - MYSQL_DATABASE=customers_database 11 | - MYSQL_USER=customersuser 12 | - MYSQL_PASSWORD=customerspwd 13 | -------------------------------------------------------------------------------- /docs/plantuml/model-artist.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | 5 | class Artist <>{ 6 | - id: Long 7 | - name: String 8 | - bio: String 9 | - createdDate: Instant 10 | + getId(): Long 11 | + setId(Long): void 12 | + getName(): String 13 | + setName(String): void 14 | + getBio(): String 15 | + setBio(String): void 16 | + getCreatedDate(): Instant 17 | + setCreatedDate(Instant): void 18 | } 19 | @enduml 20 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 2 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /artist/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | -------------------------------------------------------------------------------- /docs/plantuml/model-publisher-repository.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | abstract class PanacheEntityBase { 5 | + getEntityManager(): EntityManager 6 | + {static} persist(Object): void 7 | + {static} findById(Object): 8 | } 9 | class PanacheEntity { 10 | + id: Long <> <> 11 | } 12 | class Publisher <> { 13 | + name: String 14 | + createdDate: Instant 15 | } 16 | PanacheEntityBase <|-- PanacheEntity 17 | PanacheEntity <|-- Publisher 18 | @enduml 19 | -------------------------------------------------------------------------------- /customer/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | -------------------------------------------------------------------------------- /vintage-store/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | -------------------------------------------------------------------------------- /database-generator/.gitignore: -------------------------------------------------------------------------------- 1 | #Maven 2 | target/ 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | release.properties 7 | 8 | # Eclipse 9 | .project 10 | .classpath 11 | .settings/ 12 | bin/ 13 | 14 | # IntelliJ 15 | .idea 16 | *.ipr 17 | *.iml 18 | *.iws 19 | 20 | # NetBeans 21 | nb-configuration.xml 22 | 23 | # Visual Studio Code 24 | .vscode 25 | .factorypath 26 | 27 | # OSX 28 | .DS_Store 29 | 30 | # Vim 31 | *.swp 32 | *.swo 33 | 34 | # patch 35 | *.orig 36 | *.rej 37 | 38 | # Local environment 39 | .env 40 | -------------------------------------------------------------------------------- /customer/src/test/java/org/agoncal/quarkus/jpa/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jpa; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import javax.persistence.EntityManager; 6 | 7 | @ApplicationScoped 8 | public class CustomerRepository { 9 | 10 | @Inject 11 | EntityManager em; 12 | 13 | public void persist(Customer customer) { 14 | em.persist(customer); 15 | } 16 | 17 | public Customer findById(Long id) { 18 | return em.find(Customer.class, id); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/plantuml/model-customer.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | hide methods 4 | hide fields 5 | 6 | class Customer <> { 7 | - id: Long <> <> 8 | - firstName: String 9 | - lastName: String 10 | - email: String 11 | - createdDate: Instant 12 | + getId(): Long 13 | + getFirstName(): String 14 | + setFirstName(String): void 15 | + getLastName(): String 16 | + setLastName(String): void 17 | + getEmail(): String 18 | + setEmail(String): void 19 | + getCreatedDate(): Instant 20 | } 21 | @enduml 22 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ArtistPage/artists.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{artists.size} Artists{/title} 3 | {#body} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {#for artist in artists} 13 | 14 | 15 | 16 | 17 | {/for} 18 | 19 |
#Name
{artist.id}{artist.name}
20 | {/body} 21 | {/include} 22 | 23 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/PublisherPage/publishers.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{publishers.size} Publishers{/title} 3 | {#body} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {#for publisher in publishers} 13 | 14 | 15 | 16 | 17 | {/for} 18 | 19 |
#Name
{publisher.id}{publisher.name}
20 | {/body} 21 | {/include} 22 | 23 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/repository/ArtistRepository.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import io.quarkus.panache.common.Sort; 5 | import org.agoncal.quarkus.jdbc.Artist; 6 | 7 | import javax.enterprise.context.ApplicationScoped; 8 | import java.util.List; 9 | 10 | @ApplicationScoped 11 | public class ArtistRepository implements PanacheRepository { 12 | 13 | public List listAllArtistsSorted() { 14 | return listAll(Sort.descending("name")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheRepository; 4 | import io.quarkus.panache.common.Sort; 5 | import org.agoncal.quarkus.jpa.Customer; 6 | 7 | import javax.enterprise.context.ApplicationScoped; 8 | import java.util.List; 9 | 10 | @ApplicationScoped 11 | public class CustomerRepository implements PanacheRepository { 12 | 13 | public List listAllDans() { 14 | return list("firstName = 'Dan'", Sort.by("lastName")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus.orm 6 | parent 7 | 1.0.0-SNAPSHOT 8 | pom 9 | 10 | artist 11 | customer 12 | vintage-store 13 | database-generator 14 | 15 | 16 | -------------------------------------------------------------------------------- /customer/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Without DevServices - You need MariaDB to be up and running (see the customer-db-mariadb.yaml Docker file) 2 | #quarkus.datasource.db-kind=mariadb 3 | #quarkus.datasource.username=customersuser 4 | #quarkus.datasource.password=customerspwd 5 | #quarkus.datasource.jdbc.url=jdbc:mariadb://localhost:3306/customers_database 6 | #quarkus.hibernate-orm.database.generation=drop-and-create 7 | # With DevServices - You need Docker to be up and running (uses TestContainers) 8 | #quarkus.datasource.devservices.port=3306 9 | #quarkus.datasource.devservices.image-name=mariadb:10.6.0 10 | quarkus.hibernate-orm.database.generation=create 11 | -------------------------------------------------------------------------------- /artist/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.datasource.jdbc.new-connection-sql=CREATE TABLE IF NOT EXISTS t_artists (id BIGINT NOT NULL, name VARCHAR(255), bio VARCHAR(255), created_date TIMESTAMP, PRIMARY KEY ( id )) 2 | # Without DevServices - You need My SQL to be up and running (see the artist-db-mysql.yaml Docker file) 3 | #quarkus.datasource.db-kind=mysql 4 | #quarkus.datasource.username=artistsuser 5 | #quarkus.datasource.password=artistspwd 6 | #quarkus.datasource.jdbc.url=jdbc:mysql://localhost:3306/artists_database 7 | # With DevServices - You need Docker to be up and running (uses TestContainers) 8 | #quarkus.datasource.devservices.port=3306 9 | #quarkus.datasource.devservices.image-name=mysql:8.0.25 10 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/CustomerPage/customers.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{customers.size} Customers{/title} 3 | {#body} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {#for customer in customers} 15 | 16 | 17 | 18 | 19 | 20 | 21 | {/for} 22 | 23 |
#First NameLast NameEmail
{customer.id}{customer.firstName}{customer.lastName}{customer.email}
24 | {/body} 25 | {/include} 26 | -------------------------------------------------------------------------------- /docs/plantuml/style.iuml: -------------------------------------------------------------------------------- 1 | skinparam dpi 300 2 | skinparam BackgroundColor transparent 3 | skinparam DefaultFontColor #262626 4 | skinparam DefaultFontSize 20 5 | 6 | skinparam CircledCharacterFontColor #262626 7 | 8 | skinparam ClassArrowColor #262626 9 | skinparam ClassBorderColor #262626 10 | skinparam ClassHeaderBackgroundColor #747F83 11 | skinparam ClassFontColor #F2F2F2 12 | skinparam ClassStereotypeFontColor #F2F2F2 13 | skinparam ClassBackgroundColor #ECECED 14 | 15 | skinparam IconPublicBackgroundColor #ACD0CA 16 | skinparam IconPublicColor #ACD0CA 17 | skinparam IconPrivateBackgroundColor #ACD0C0 18 | skinparam IconPrivateColor #ACD0C0 19 | 20 | skinparam StereotypeABackgroundColor #B6AF9D 21 | skinparam StereotypeCBackgroundColor #B6AF9D 22 | skinparam StereotypeIBackgroundColor #D6CEB5 23 | -------------------------------------------------------------------------------- /docs/plantuml/panache-entity.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | class Publisher <> { 5 | + name: String 6 | } 7 | 8 | abstract class PanacheEntity <> { 9 | + id: Long <> <> 10 | } 11 | 12 | abstract class PanacheEntityBase { 13 | + delete(): void 14 | + flush(): void 15 | + isPersistent(): boolean 16 | + persist(): void 17 | + {static} deleteAll(): long 18 | + {static} deleteById(Object id): boolean 19 | + {static} findById(Object id): PanacheEntityBase 20 | + {static} findByIdOptional(Object id): Optional 21 | + {static} persist(Iterable entities): void 22 | + {static} persist(Stream entities): void 23 | {method} ... 24 | } 25 | 26 | PanacheEntityBase <|-- PanacheEntity 27 | PanacheEntity <|-- Publisher 28 | 29 | @enduml 30 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/PurchaseOrderPage/purchaseOrders.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{purchaseOrders.size} Purchase Orders{/title} 3 | {#body} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {#for purchaseOrder in purchaseOrders} 14 | 15 | 16 | 17 | 18 | 19 | {/for} 20 | 21 |
#DateCustomer
{purchaseOrder.id}{purchaseOrder.date}{purchaseOrder.customer.firstName} {purchaseOrder.customer.lastName}
22 | {/body} 23 | {/include} 24 | 25 | -------------------------------------------------------------------------------- /docs/plantuml/panache-repository-artist.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | class Artist { 5 | } 6 | 7 | class ArtistRepository { 8 | } 9 | 10 | interface PanacheRepository { 11 | } 12 | 13 | interface PanacheRepositoryBase { 14 | + default delete(Entity entity): void 15 | + default flush(): void 16 | + default isPersistent(Entity entity): boolean 17 | + default persist(Entity entity): void 18 | + default deleteAll(): long 19 | + default deleteById(Id id): boolean 20 | + default findById(Id id): Entity 21 | + default findByIdOptional(Id id): Entity 22 | + default persist(Iterable entities): void 23 | + default persist(Stream entities): void 24 | {method} ... 25 | } 26 | 27 | PanacheRepository <|-- ArtistRepository 28 | PanacheRepositoryBase <|-- PanacheRepository 29 | ArtistRepository -> Artist 30 | @enduml 31 | -------------------------------------------------------------------------------- /artist/src/test/java/org/agoncal/quarkus/jdbc/ArtistRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jdbc; 2 | 3 | import io.quarkus.test.junit.QuarkusTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import javax.inject.Inject; 7 | import java.sql.SQLException; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | 12 | @QuarkusTest 13 | public class ArtistRepositoryTest { 14 | 15 | @Inject 16 | ArtistRepository repository; 17 | 18 | @Test 19 | public void shouldCreateAndFindAnArtist() throws SQLException { 20 | Artist artist = new Artist("name", "bio"); 21 | 22 | repository.persist(artist); 23 | assertNotNull(artist.getId()); 24 | 25 | artist = repository.findById(artist.getId()); 26 | assertEquals("name", artist.getName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ItemPage/cds.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{cds.size} CDs{/title} 3 | {#body} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | {#for cd in cds} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | {/for} 26 | 27 |
#TitleGenrePriceMusic CompanyArtist
{cd.id}{cd.title}{cd.genre}{cd.price}{cd.musicCompany}{cd.artist.name}
28 | {/body} 29 | {/include} 30 | -------------------------------------------------------------------------------- /docs/plantuml/panache-repository.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | class PublisherRepository <<@ApplicationScoped>> { 5 | + findByName(String name): Optional 6 | + deleteByName(String name): long 7 | } 8 | 9 | interface PanacheRepository { 10 | } 11 | 12 | interface PanacheRepositoryBase { 13 | + default delete(Entity entity): void 14 | + default flush(): void 15 | + default isPersistent(Entity entity): boolean 16 | + default persist(Entity entity): void 17 | + default deleteAll(): long 18 | + default deleteById(Id id): boolean 19 | + default findById(Id id): Entity 20 | + default findByIdOptional(Id id): Entity 21 | + default persist(Iterable entities): void 22 | + default persist(Stream entities): void 23 | {method} ... 24 | } 25 | 26 | PanacheRepository <|-- PublisherRepository 27 | PanacheRepositoryBase <|-- PanacheRepository 28 | 29 | @enduml 30 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Prod 2 | %prod.quarkus.datasource.db-kind=postgresql 3 | %prod.quarkus.datasource.username=vintageuser 4 | %prod.quarkus.datasource.password=vintagepwd 5 | %prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/vintagestore_database 6 | %prod.quarkus.hibernate-orm.sql-load-script=import.sql 7 | # Dev 8 | %dev.quarkus.datasource.devservices.image-name=postgres:13.3 9 | %dev.quarkus.datasource.devservices.port=5432 10 | %dev.quarkus.hibernate-orm.log.sql=true 11 | # Test 12 | %test.quarkus.datasource.db-kind=h2 13 | %test.quarkus.datasource.jdbc.url=jdbc:h2:mem:vintagestore_database 14 | # Common 15 | quarkus.hibernate-orm.database.generation=drop-and-create 16 | quarkus.hibernate-orm.scripts.generation=drop-and-create 17 | quarkus.hibernate-orm.scripts.generation.create-target=create.sql 18 | quarkus.hibernate-orm.scripts.generation.drop-target=drop.sql 19 | -------------------------------------------------------------------------------- /customer/src/test/java/org/agoncal/quarkus/jpa/CustomerRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jpa; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import javax.inject.Inject; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | 12 | @QuarkusTest 13 | public class CustomerRepositoryTest { 14 | 15 | @Inject 16 | CustomerRepository repository; 17 | 18 | @Test 19 | @TestTransaction 20 | public void shouldCreateAndFindACustomer() { 21 | Customer customer = new Customer("first name", "last name", "email"); 22 | 23 | repository.persist(customer); 24 | assertNotNull(customer.getId()); 25 | 26 | customer = repository.findById(customer.getId()); 27 | assertEquals("last name", customer.getLastName()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/META-INF/orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | *dummy* 5 | dummy/ 6 | dist/ 7 | tmp/ 8 | target/ 9 | maven-wrapper.jar 10 | book-*.json 11 | 12 | # dependencies 13 | node/ 14 | node_modules/ 15 | ui-vintagestore/src/main/resources/META-INF/resources/ui-vintagestore/* 16 | 17 | # profiling files 18 | chrome-profiler-events*.json 19 | speed-measure-plugin*.json 20 | 21 | # IDEs and editors 22 | *.iml 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | .history/* 38 | 39 | # misc 40 | /.sass-cache 41 | /connect.lock 42 | /coverage 43 | /libpeerconnection.log 44 | npm-debug.log 45 | yarn-error.log 46 | testem.log 47 | /typings 48 | 49 | # System Files 50 | .DS_Store 51 | Thumbs.db 52 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ItemPage/books.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}{books.size} Books{/title} 3 | {#body} 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {#for book in books} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | {/for} 28 | 29 |
#TitleIsbnn° PagesPriceLanguageArtist
{book.id}{book.title}{book.isbn}{book.nbOfPages}{book.price}{book.language}{book.artist.name}
30 | {/body} 31 | {/include} 32 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/PublisherPage/publisher.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}Publisher {publisher.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 | Back to Publishers 23 | {/body} 24 | {/include} 25 | 26 | -------------------------------------------------------------------------------- /docs/plantuml/model-vintage.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | hide methods 4 | hide fields 5 | 6 | class Publisher <> { 7 | + name: String 8 | + createdDate: Instant 9 | } 10 | class Item <> { 11 | + title: String 12 | + description: String 13 | + price: BigDecimal 14 | + createdDate: Instant 15 | } 16 | class Book { 17 | + isbn: String 18 | + nbOfPages: Integer 19 | + publicationDate: LocalDate 20 | } 21 | class CD { 22 | + musicCompany: String 23 | + genre: String 24 | } 25 | class Track <> { 26 | + title: String 27 | + duration: Duration 28 | + createdDate: Instant 29 | } 30 | enum Language {} 31 | class PurchaseOrder <> { 32 | + date: LocalDate 33 | + createdDate: Instant 34 | } 35 | class OrderLine <> { 36 | + quantity: Integer 37 | + createdDate: Instant 38 | } 39 | 40 | Item <|-- Book 41 | Item <|-- CD 42 | Book --> "1" Publisher 43 | Book --> "1" Language 44 | CD "1" *-- "*" Track 45 | PurchaseOrder "1 " *- " *" OrderLine 46 | OrderLine -> "1" Item 47 | @enduml 48 | -------------------------------------------------------------------------------- /docs/plantuml/panache-repository-vs-active-rec.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | interface PanacheRepositoryBase { 5 | + default delete(Entity entity): void 6 | + default flush(): void 7 | + default isPersistent(Entity entity): boolean 8 | + default persist(Entity entity): void 9 | + default deleteAll(): long 10 | + default deleteById(Id id): boolean 11 | + default findById(Id id): Entity 12 | + default findByIdOptional(Id id): Entity 13 | + default persist(Iterable entities): void 14 | + default persist(Stream entities): void 15 | {method} ... 16 | } 17 | 18 | abstract class PanacheEntityBase { 19 | + delete(): void 20 | + flush(): void 21 | + isPersistent(): boolean 22 | + persist(): void 23 | + {static} deleteAll(): long 24 | + {static} deleteById(Object id): boolean 25 | + {static} findById(Object id): PanacheEntityBase 26 | + {static} findByIdOptional(Object id): Optional 27 | + {static} persist(Iterable entities): void 28 | + {static} persist(Stream entities): void 29 | {method} ... 30 | } 31 | @enduml 32 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ArtistPage/artist.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}Artist {artist.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 | Back to Artists 29 | {/body} 30 | {/include} 31 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/PanacheActiveRecordTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.panache.model.Publisher; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import static org.junit.jupiter.api.Assertions.assertEquals; 9 | import static org.junit.jupiter.api.Assertions.assertFalse; 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | @QuarkusTest 14 | public class PanacheActiveRecordTest { 15 | 16 | @Test 17 | @TestTransaction 18 | public void shouldCreateAndFindAPublisher() { 19 | Publisher publisher = new Publisher("name"); 20 | 21 | assertFalse(publisher.isPersistent()); 22 | Publisher.persist(publisher); 23 | assertTrue(publisher.isPersistent()); 24 | assertNotNull(publisher.id); 25 | 26 | publisher = Publisher.findById(publisher.id); 27 | assertEquals("name", publisher.name); 28 | 29 | Publisher.deleteById(publisher.id); 30 | assertFalse(publisher.isPersistent()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/OrderLine.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | 5 | import javax.json.bind.annotation.JsonbTransient; 6 | import javax.persistence.CascadeType; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.FetchType; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | import java.time.Instant; 14 | 15 | /** 16 | * @author Antonio Goncalves 17 | * http://www.antoniogoncalves.org 18 | * -- 19 | */ 20 | @Entity 21 | @Table(name = "t_purchase_order_lines") 22 | public class OrderLine extends PanacheEntity { 23 | 24 | @ManyToOne(cascade = CascadeType.PERSIST) 25 | @JoinColumn(name = "item_fk") 26 | public Item item; 27 | 28 | @Column(nullable = false) 29 | public Integer quantity; 30 | 31 | @ManyToOne(fetch = FetchType.EAGER) 32 | @JoinColumn(name = "purchase_order_fk") 33 | @JsonbTransient 34 | public PurchaseOrder purchaseOrder; 35 | 36 | @Column(name = "created_date", nullable = false) 37 | public Instant createdDate = Instant.now(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/TrackRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.panache.model.Track; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import java.time.Duration; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | import static org.junit.jupiter.api.Assertions.assertNotNull; 12 | 13 | @QuarkusTest 14 | public class TrackRepositoryTest { 15 | 16 | @Test 17 | @TestTransaction 18 | public void shouldCreateAndFindATrack() { 19 | long countTracks = Track.count(); 20 | 21 | // Creates a Track 22 | Track track = new Track(); 23 | track.title = "title"; 24 | track.duration = Duration.ofSeconds(1_000); 25 | 26 | // Persists the Track 27 | Track.persist(track); 28 | assertNotNull(track.id); 29 | 30 | assertEquals(countTracks + 1, Track.count()); 31 | 32 | // Gets the Track 33 | track = Track.findById(track.id); 34 | assertEquals("title", track.title); 35 | 36 | // Deletes the Track 37 | Track.deleteById(track.id); 38 | assertEquals(countTracks, Track.count()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/EntityManagerTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jpa.Customer; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import javax.inject.Inject; 9 | import javax.persistence.EntityManager; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertEquals; 12 | import static org.junit.jupiter.api.Assertions.assertFalse; 13 | import static org.junit.jupiter.api.Assertions.assertNotNull; 14 | import static org.wildfly.common.Assert.assertTrue; 15 | 16 | @QuarkusTest 17 | public class EntityManagerTest { 18 | 19 | @Inject 20 | EntityManager em; 21 | 22 | @Test 23 | @TestTransaction 24 | public void shouldCreateAndFindACustomer() { 25 | Customer customer = new Customer("first name", "last name", "email"); 26 | 27 | assertFalse(em.contains(customer)); 28 | em.persist(customer); 29 | assertTrue(em.contains(customer)); 30 | assertNotNull(customer.getId()); 31 | 32 | customer = em.find(Customer.class, customer.getId()); 33 | assertEquals("last name", customer.getLastName()); 34 | 35 | em.remove(customer); 36 | assertFalse(em.contains(customer)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/PanacheRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jdbc.Artist; 6 | import org.agoncal.quarkus.panache.repository.ArtistRepository; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import javax.inject.Inject; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertEquals; 12 | import static org.junit.jupiter.api.Assertions.assertFalse; 13 | import static org.junit.jupiter.api.Assertions.assertNotNull; 14 | import static org.junit.jupiter.api.Assertions.assertTrue; 15 | 16 | @QuarkusTest 17 | public class PanacheRepositoryTest { 18 | 19 | @Inject 20 | ArtistRepository repository; 21 | 22 | @Test 23 | @TestTransaction 24 | public void shouldCreateAndFindAArtist() { 25 | Artist artist = new Artist("name"); 26 | 27 | assertFalse(repository.isPersistent(artist)); 28 | repository.persist(artist); 29 | assertTrue(repository.isPersistent(artist)); 30 | assertNotNull(artist.getId()); 31 | 32 | artist = repository.findById(artist.getId()); 33 | assertEquals("name", artist.getName()); 34 | 35 | repository.deleteById(artist.getId()); 36 | assertFalse(repository.isPersistent(artist)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/CustomerPage/customer.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}Customer {customer.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 | Back to Customers 35 | {/body} 36 | {/include} 37 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/Item.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | import org.agoncal.quarkus.jdbc.Artist; 5 | 6 | import javax.persistence.CascadeType; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.Inheritance; 10 | import javax.persistence.InheritanceType; 11 | import javax.persistence.JoinColumn; 12 | import javax.persistence.ManyToOne; 13 | import javax.persistence.Table; 14 | import java.math.BigDecimal; 15 | import java.time.Instant; 16 | 17 | /** 18 | * @author Antonio Goncalves 19 | * http://www.antoniogoncalves.org 20 | * -- 21 | */ 22 | @Entity 23 | @Table(name = "t_items") 24 | @Inheritance(strategy = InheritanceType.SINGLE_TABLE) 25 | public class Item extends PanacheEntity { 26 | 27 | // ====================================== 28 | // = Attributes = 29 | // ====================================== 30 | 31 | @Column(length = 100, nullable = false) 32 | public String title; 33 | 34 | @Column(length = 3000) 35 | public String description; 36 | 37 | @Column(nullable = false) 38 | public BigDecimal price; 39 | 40 | @ManyToOne(cascade = CascadeType.PERSIST) 41 | @JoinColumn(name = "artist_fk") 42 | public Artist artist; 43 | 44 | @Column(name = "created_date", nullable = false) 45 | public Instant createdDate = Instant.now(); 46 | } 47 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/ArtistRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jdbc.Artist; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import javax.inject.Inject; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | import static org.junit.jupiter.api.Assertions.assertNotNull; 12 | 13 | @QuarkusTest 14 | public class ArtistRepositoryTest { 15 | 16 | @Inject 17 | ArtistRepository repository; 18 | 19 | @Test 20 | @TestTransaction 21 | public void shouldCreateAndFindAnArtist() { 22 | long count = repository.count(); 23 | int listAll = repository.listAll().size(); 24 | assertEquals(count, listAll); 25 | assertEquals(repository.listAllArtistsSorted().size(), listAll); 26 | 27 | // Creates an Artist 28 | Artist artist = new Artist(); 29 | artist.setName("name"); 30 | artist.setBio("bio"); 31 | 32 | // Persists the Artist 33 | repository.persist(artist); 34 | assertNotNull(artist.getId()); 35 | 36 | assertEquals(count + 1, repository.count()); 37 | 38 | // Gets the Artists 39 | artist = repository.findById(artist.getId()); 40 | assertEquals("name", artist.getName()); 41 | 42 | // Deletes the Artist 43 | repository.deleteById(artist.getId()); 44 | assertEquals(count, repository.count()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | {#insert title}Default Title{/} 8 | 9 | 10 | find({data:query}, Sort.by({data:sort})).page({data:pageIndex}, {data:pageSize}).list() 11 | 26 |
27 |

{#insert title}Default Title{/}

28 | {#insert body}Default body!{/} 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ItemPage/cd.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}CD {cd.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 | Back to Books 41 | {/body} 42 | {/include} 43 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/CD.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import javax.persistence.CascadeType; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.OneToMany; 7 | import java.math.BigDecimal; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * @author Antonio Goncalves 13 | * http://www.antoniogoncalves.org 14 | * -- 15 | */ 16 | @Entity 17 | public class CD extends Item { 18 | 19 | // ====================================== 20 | // = Attributes = 21 | // ====================================== 22 | 23 | @Column(name = "music_company") 24 | public String musicCompany; 25 | 26 | @Column(length = 100) 27 | public String genre; 28 | 29 | @OneToMany(mappedBy = "cd", cascade = {CascadeType.REMOVE, CascadeType.PERSIST}, orphanRemoval = true) 30 | public List tracks = new ArrayList<>(); 31 | 32 | public void addTrack(Track track) { 33 | tracks.add(track); 34 | track.cd = this; 35 | } 36 | 37 | public void removeTrack(Track track) { 38 | tracks.remove(track); 39 | track.cd = null; 40 | } 41 | 42 | // ====================================== 43 | // = Constructors = 44 | // ====================================== 45 | 46 | public CD() { 47 | } 48 | 49 | public CD(String title, String description, BigDecimal price, String genre) { 50 | this.title = title; 51 | this.description = description; 52 | this.price = price; 53 | this.genre = genre; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/CustomerRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jpa.Customer; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import javax.inject.Inject; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | import static org.junit.jupiter.api.Assertions.assertNotNull; 12 | import static org.junit.jupiter.api.Assertions.assertTrue; 13 | 14 | @QuarkusTest 15 | public class CustomerRepositoryTest { 16 | 17 | @Inject 18 | CustomerRepository repository; 19 | 20 | @Test 21 | @TestTransaction 22 | public void shouldCreateAndFindACustomer() { 23 | long count = repository.count(); 24 | int listAll = repository.listAll().size(); 25 | assertEquals(count, listAll); 26 | assertTrue(repository.listAllDans().size() <= listAll); 27 | 28 | // Creates a Customer 29 | Customer customer = new Customer(); 30 | customer.setFirstName("first name"); 31 | customer.setLastName("last name"); 32 | customer.setEmail("email"); 33 | 34 | // Persists the Customer 35 | repository.persist(customer); 36 | assertNotNull(customer.getId()); 37 | 38 | assertEquals(count + 1, repository.count()); 39 | 40 | // Gets the Customer 41 | customer = repository.findById(customer.getId()); 42 | assertEquals("first name", customer.getFirstName()); 43 | 44 | // Deletes the Customer 45 | repository.deleteById(customer.getId()); 46 | assertEquals(count, repository.count()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/PurchaseOrder.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | import org.agoncal.quarkus.jpa.Customer; 5 | 6 | import javax.persistence.CascadeType; 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToOne; 11 | import javax.persistence.OneToMany; 12 | import javax.persistence.Table; 13 | import java.time.Instant; 14 | import java.time.LocalDate; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * @author Antonio Goncalves 20 | * http://www.antoniogoncalves.org 21 | * -- 22 | */ 23 | @Entity 24 | @Table(name = "t_purchase_orders") 25 | public class PurchaseOrder extends PanacheEntity { 26 | 27 | @Column(name = "purchase_order_date", nullable = false) 28 | public LocalDate date = LocalDate.now(); 29 | 30 | @OneToMany(mappedBy = "purchaseOrder", cascade = {CascadeType.REMOVE, CascadeType.PERSIST}, orphanRemoval = true) 31 | public List orderLines = new ArrayList<>(); 32 | 33 | @ManyToOne(cascade = CascadeType.PERSIST) 34 | @JoinColumn(name = "customer_fk") 35 | public Customer customer; 36 | 37 | @Column(name = "created_date", nullable = false) 38 | public Instant createdDate = Instant.now(); 39 | 40 | public void addOrderLine(OrderLine orderLine) { 41 | orderLines.add(orderLine); 42 | orderLine.purchaseOrder = this; 43 | } 44 | 45 | public void removeOrderLine(OrderLine orderLine) { 46 | orderLines.remove(orderLine); 47 | orderLine.purchaseOrder = null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/Book.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import javax.persistence.CascadeType; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.EnumType; 7 | import javax.persistence.Enumerated; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import java.time.LocalDate; 11 | 12 | /** 13 | * @author Antonio Goncalves 14 | * http://www.antoniogoncalves.org 15 | * -- 16 | */ 17 | @Entity 18 | public class Book extends Item { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Column(length = 15) 25 | public String isbn; 26 | 27 | @Column(name = "nb_of_pages") 28 | public Integer nbOfPages; 29 | 30 | @Column(name = "publication_date") 31 | public LocalDate publicationDate; 32 | 33 | @Column(length = 20) 34 | @Enumerated(EnumType.STRING) 35 | public Language language; 36 | 37 | @ManyToOne(cascade = CascadeType.PERSIST) 38 | @JoinColumn(name = "publisher_fk") 39 | public Publisher publisher; 40 | 41 | @Override 42 | public String toString() { 43 | return "Book{" + 44 | "isbn='" + isbn + '\'' + 45 | ", nbOfPages=" + nbOfPages + 46 | ", publicationDate=" + publicationDate + 47 | ", language=" + language + 48 | ", publisher=" + publisher + 49 | ", title='" + title + '\'' + 50 | ", description='" + description + '\'' + 51 | ", price=" + price + 52 | ", createdDate=" + createdDate + 53 | ", id=" + id + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/PublisherRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.panache.model.Publisher; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import javax.persistence.EntityNotFoundException; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | import static org.junit.jupiter.api.Assertions.assertNotNull; 12 | import static org.junit.jupiter.api.Assertions.assertTrue; 13 | 14 | @QuarkusTest 15 | public class PublisherRepositoryTest { 16 | 17 | @Test 18 | @TestTransaction 19 | public void shouldCreateAndFindAPublisher() { 20 | long count = Publisher.count(); 21 | int listAll = Publisher.listAll().size(); 22 | assertEquals(count, listAll); 23 | 24 | // Creates a Publisher 25 | Publisher publisher = new Publisher(); 26 | publisher.name = "name"; 27 | 28 | // Persists the Publisher 29 | Publisher.persist(publisher); 30 | assertNotNull(publisher.id); 31 | 32 | assertEquals(count + 1, Publisher.count()); 33 | 34 | // Gets the Publisher 35 | publisher = Publisher.findById(publisher.id); 36 | assertEquals("name", publisher.name); 37 | 38 | // Gets the Publisher by name 39 | publisher = Publisher.findByName(publisher.name).orElseThrow(EntityNotFoundException::new); 40 | assertEquals("name", publisher.name); 41 | assertTrue(Publisher.findContainingName("name").size() >= 1); 42 | 43 | // Deletes the Artist 44 | Publisher.deleteById(publisher.id); 45 | assertEquals(count, Publisher.count()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/page/PublisherPage.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.page; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.qute.CheckedTemplate; 5 | import io.quarkus.qute.TemplateInstance; 6 | import org.agoncal.quarkus.panache.model.Publisher; 7 | 8 | import javax.enterprise.context.ApplicationScoped; 9 | import javax.ws.rs.DefaultValue; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.Path; 12 | import javax.ws.rs.PathParam; 13 | import javax.ws.rs.Produces; 14 | import javax.ws.rs.QueryParam; 15 | import javax.ws.rs.core.MediaType; 16 | import java.util.List; 17 | 18 | @Path("/page/publishers") 19 | @Produces(MediaType.TEXT_HTML) 20 | @ApplicationScoped 21 | public class PublisherPage { 22 | 23 | @CheckedTemplate 24 | public static class Templates { 25 | public static native TemplateInstance publisher(Publisher publisher); 26 | 27 | public static native TemplateInstance publishers(List publishers); 28 | } 29 | 30 | @GET 31 | @Path("{id}") 32 | public TemplateInstance showPublisherById(@PathParam("id") Long id) { 33 | return Templates.publisher(Publisher.findById(id)); 34 | } 35 | 36 | @GET 37 | public TemplateInstance showAllPublishers(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 38 | return Templates.publishers(Publisher.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 39 | .data("query", query) 40 | .data("sort", sort) 41 | .data("page", pageIndex) 42 | .data("size", pageSize); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/page/PurchaseOrderPage.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.page; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.qute.CheckedTemplate; 5 | import io.quarkus.qute.TemplateInstance; 6 | import org.agoncal.quarkus.panache.model.PurchaseOrder; 7 | 8 | import javax.enterprise.context.ApplicationScoped; 9 | import javax.ws.rs.DefaultValue; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.Path; 12 | import javax.ws.rs.PathParam; 13 | import javax.ws.rs.Produces; 14 | import javax.ws.rs.QueryParam; 15 | import javax.ws.rs.core.MediaType; 16 | import java.util.List; 17 | 18 | @Path("/page/purchase-orders") 19 | @Produces(MediaType.TEXT_HTML) 20 | @ApplicationScoped 21 | public class PurchaseOrderPage { 22 | 23 | @CheckedTemplate 24 | public static class Templates { 25 | public static native TemplateInstance purchaseOrder(PurchaseOrder purchaseOrder); 26 | 27 | public static native TemplateInstance purchaseOrders(List purchaseOrders); 28 | } 29 | 30 | @GET 31 | @Path("{id}") 32 | public TemplateInstance showPurchaseOrderById(@PathParam("id") Long id) { 33 | return Templates.purchaseOrder(PurchaseOrder.findById(id)); 34 | } 35 | 36 | @GET 37 | public TemplateInstance showAllPurchaseOrders(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 38 | return Templates.purchaseOrders(PurchaseOrder.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 39 | .data("query", query) 40 | .data("sort", sort) 41 | .data("pageIndex", pageIndex) 42 | .data("pageSize", pageSize); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/page/ArtistPage.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.page; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.qute.CheckedTemplate; 5 | import io.quarkus.qute.TemplateInstance; 6 | import org.agoncal.quarkus.jdbc.Artist; 7 | import org.agoncal.quarkus.panache.repository.ArtistRepository; 8 | 9 | import javax.enterprise.context.ApplicationScoped; 10 | import javax.inject.Inject; 11 | import javax.ws.rs.DefaultValue; 12 | import javax.ws.rs.GET; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.QueryParam; 17 | import javax.ws.rs.core.MediaType; 18 | import java.util.List; 19 | 20 | @Path("/page/artists") 21 | @Produces(MediaType.TEXT_HTML) 22 | @ApplicationScoped 23 | public class ArtistPage { 24 | 25 | @Inject 26 | ArtistRepository repository; 27 | 28 | @CheckedTemplate 29 | public static class Templates { 30 | public static native TemplateInstance artist(Artist artist); 31 | 32 | public static native TemplateInstance artists(List artists); 33 | } 34 | 35 | @GET 36 | @Path("{id}") 37 | public TemplateInstance showArtistById(@PathParam("id") Long id) { 38 | return Templates.artist(repository.findById(id)); 39 | } 40 | 41 | @GET 42 | public TemplateInstance showAllArtists(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 43 | return Templates.artists(repository.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 44 | .data("query", query) 45 | .data("sort", sort) 46 | .data("pageIndex", pageIndex) 47 | .data("pageSize", pageSize); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/PurchaseOrderPage/purchaseOrder.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}Purchase Order {purchaseOrder.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |

Order Lines

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | {#for orderLine in purchaseOrder.orderLines} 40 | 41 | 42 | 43 | 44 | 45 | 46 | {/for} 47 | 48 |
#ItemPriceQuantity
{orderLine.id}{orderLine.item.title}{orderLine.item.price}{orderLine.quantity}
49 | Back to Purchase Orders 50 | {/body} 51 | {/include} 52 | 53 | -------------------------------------------------------------------------------- /artist/src/test/java/org/agoncal/quarkus/jdbc/ArtistRepository.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jdbc; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import javax.sql.DataSource; 6 | import java.sql.Connection; 7 | import java.sql.PreparedStatement; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.sql.Timestamp; 11 | import java.util.Random; 12 | 13 | @ApplicationScoped 14 | public class ArtistRepository { 15 | 16 | @Inject 17 | DataSource dataSource; 18 | 19 | public void persist(Artist artist) throws SQLException { 20 | Connection conn = dataSource.getConnection(); 21 | String sql = "INSERT INTO t_artists (id, name, bio, created_date) VALUES (?, ?, ?, ?)"; 22 | artist.setId(Math.abs(new Random().nextLong())); 23 | 24 | try (PreparedStatement ps = conn.prepareStatement(sql)) { 25 | ps.setLong(1, artist.getId()); 26 | ps.setString(2, artist.getName()); 27 | ps.setString(3, artist.getBio()); 28 | ps.setTimestamp(4, Timestamp.from(artist.getCreatedDate())); 29 | ps.executeUpdate(); 30 | } 31 | conn.close(); 32 | } 33 | 34 | public Artist findById(Long id) throws SQLException { 35 | Connection conn = dataSource.getConnection(); 36 | String sql = "SELECT id, name, bio, created_date FROM t_artists WHERE id = ?"; 37 | Artist artist = new Artist(); 38 | 39 | try (PreparedStatement ps = conn.prepareStatement(sql)) { 40 | ps.setLong(1, id); 41 | ResultSet rs = ps.executeQuery(); 42 | if (rs.next()) { 43 | artist.setId(rs.getLong(1)); 44 | artist.setName(rs.getString(2)); 45 | artist.setBio(rs.getString(3)); 46 | artist.setCreatedDate(rs.getTimestamp(4).toInstant()); 47 | } 48 | } 49 | conn.close(); 50 | return artist; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/Publisher.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.Table; 8 | import java.time.Instant; 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | /** 13 | * @author Antonio Goncalves 14 | * http://www.antoniogoncalves.org 15 | * -- 16 | */ 17 | @Entity 18 | @Table(name = "t_publishers") 19 | public class Publisher extends PanacheEntity { 20 | 21 | // ====================================== 22 | // = Attributes = 23 | // ====================================== 24 | 25 | @Column(length = 50, nullable = false) 26 | public String name; 27 | 28 | @Column(name = "created_date", nullable = false) 29 | public Instant createdDate = Instant.now(); 30 | 31 | // ====================================== 32 | // = Constructors = 33 | // ====================================== 34 | 35 | public Publisher(String name) { 36 | this.name = name; 37 | } 38 | 39 | public Publisher() { 40 | } 41 | 42 | // ====================================== 43 | // = Methods = 44 | // ====================================== 45 | 46 | public static List findContainingName(String name) { 47 | return Publisher.list("name like ?1", "%" + name + "%"); 48 | } 49 | 50 | public static Optional findByName(String name) { 51 | return Publisher.find("name", name).firstResultOptional(); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return "Publisher{" + 57 | "name='" + name + '\'' + 58 | ", createdDate=" + createdDate + 59 | ", id=" + id + 60 | '}'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/page/CustomerPage.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.page; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.qute.CheckedTemplate; 5 | import io.quarkus.qute.TemplateInstance; 6 | import org.agoncal.quarkus.jpa.Customer; 7 | import org.agoncal.quarkus.panache.repository.CustomerRepository; 8 | 9 | import javax.enterprise.context.ApplicationScoped; 10 | import javax.inject.Inject; 11 | import javax.ws.rs.DefaultValue; 12 | import javax.ws.rs.GET; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.QueryParam; 17 | import javax.ws.rs.core.MediaType; 18 | import java.util.List; 19 | 20 | @Path("/page/customers") 21 | @Produces(MediaType.TEXT_HTML) 22 | @ApplicationScoped 23 | public class CustomerPage { 24 | 25 | @Inject 26 | CustomerRepository repository; 27 | 28 | @CheckedTemplate 29 | public static class Templates { 30 | public static native TemplateInstance customer(Customer customer); 31 | 32 | public static native TemplateInstance customers(List customers); 33 | } 34 | 35 | @GET 36 | @Path("{id}") 37 | public TemplateInstance showCustomerById(@PathParam("id") Long id) { 38 | return Templates.customer(repository.findById(id)); 39 | } 40 | 41 | @GET 42 | public TemplateInstance showAllCustomers(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 43 | return Templates.customers(repository.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 44 | .data("query", query) 45 | .data("sort", sort) 46 | .data("pageIndex", pageIndex) 47 | .data("pageSize", pageSize); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /artist/README.md: -------------------------------------------------------------------------------- 1 | # jpa Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | If you want to build an _über-jar_, execute the following command: 26 | ```shell script 27 | ./mvnw package -Dquarkus.package.type=uber-jar 28 | ``` 29 | 30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 31 | 32 | ## Creating a native executable 33 | 34 | You can create a native executable using: 35 | ```shell script 36 | ./mvnw package -Pnative 37 | ``` 38 | 39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 40 | ```shell script 41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 42 | ``` 43 | 44 | You can then execute your native executable with: `./target/jpa-1.0.0-SNAPSHOT-runner` 45 | 46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 47 | 48 | ## Provided Code 49 | 50 | ### RESTEasy JAX-RS 51 | 52 | Easily start your RESTful Web Services 53 | 54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 55 | -------------------------------------------------------------------------------- /customer/README.md: -------------------------------------------------------------------------------- 1 | # jdbc Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | If you want to build an _über-jar_, execute the following command: 26 | ```shell script 27 | ./mvnw package -Dquarkus.package.type=uber-jar 28 | ``` 29 | 30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 31 | 32 | ## Creating a native executable 33 | 34 | You can create a native executable using: 35 | ```shell script 36 | ./mvnw package -Pnative 37 | ``` 38 | 39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 40 | ```shell script 41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 42 | ``` 43 | 44 | You can then execute your native executable with: `./target/jdbc-1.0.0-SNAPSHOT-runner` 45 | 46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 47 | 48 | ## Provided Code 49 | 50 | ### RESTEasy JAX-RS 51 | 52 | Easily start your RESTful Web Services 53 | 54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jpa-panache Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | If you want to build an _über-jar_, execute the following command: 26 | ```shell script 27 | ./mvnw package -Dquarkus.package.type=uber-jar 28 | ``` 29 | 30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 31 | 32 | ## Creating a native executable 33 | 34 | You can create a native executable using: 35 | ```shell script 36 | ./mvnw package -Pnative 37 | ``` 38 | 39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 40 | ```shell script 41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 42 | ``` 43 | 44 | You can then execute your native executable with: `./target/jpa-panache-1.0.0-SNAPSHOT-runner` 45 | 46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 47 | 48 | ## Provided Code 49 | 50 | ### RESTEasy JAX-RS 51 | 52 | Easily start your RESTful Web Services 53 | 54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 55 | -------------------------------------------------------------------------------- /database-generator/README.md: -------------------------------------------------------------------------------- 1 | # jpa Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | If you want to build an _über-jar_, execute the following command: 26 | ```shell script 27 | ./mvnw package -Dquarkus.package.type=uber-jar 28 | ``` 29 | 30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 31 | 32 | ## Creating a native executable 33 | 34 | You can create a native executable using: 35 | ```shell script 36 | ./mvnw package -Pnative 37 | ``` 38 | 39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 40 | ```shell script 41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 42 | ``` 43 | 44 | You can then execute your native executable with: `./target/jpa-1.0.0-SNAPSHOT-runner` 45 | 46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 47 | 48 | ## Provided Code 49 | 50 | ### RESTEasy JAX-RS 51 | 52 | Easily start your RESTful Web Services 53 | 54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 55 | -------------------------------------------------------------------------------- /docs/plantuml/panache-entity-managing.puml: -------------------------------------------------------------------------------- 1 | @startuml 2 | !include style.iuml 3 | 4 | abstract class PanacheEntityBase { 5 | {static} + find(String query, Sort sort, Parameters params): PanacheQuery 6 | {static} + findAll(): PanacheQuery 7 | {static} + findAll(Sort sort): PanacheQuery 8 | {static} + list(String query, Sort sort, Parameters params): List 9 | {static} + listAll(): List 10 | {static} + listAll(Sort sort): List 11 | {static} + stream(String query, Sort sort, Parameters params): Stream 12 | {static} + streamAll(): Stream 13 | {static} + streamAll(Sort sort): Stream 14 | {static} + count(): long 15 | {static} + count(String query, Parameters params): long 16 | {static} + delete(String query, Parameters params): long 17 | {static} + update(String query, Parameters params): int 18 | } 19 | 20 | interface PanacheQuery { 21 | + page(): Page 22 | + filter(String filterName, Parameters parameters): PanacheQuery 23 | + list(): List 24 | + stream(): Stream 25 | + firstResult(): Entity 26 | + firstResultOptional(): Optional 27 | + singleResult(): Entity 28 | } 29 | 30 | class Page { 31 | - index: int 32 | - size: int 33 | + next(): Page 34 | + previous(): Page 35 | + first(): Page 36 | + index(int newIndex): Page 37 | } 38 | 39 | class Sort { 40 | - columns: List 41 | + direction(): Direction 42 | + column(): Column 43 | 44 | } 45 | 46 | class Parameters { 47 | - values: Map 48 | + and(String name, Object value): Parameters 49 | + map(): Map 50 | {static} + with(String name, Object value): Parameters 51 | } 52 | 53 | PanacheEntityBase .down.> PanacheQuery 54 | PanacheEntityBase .right.> Sort 55 | PanacheQuery .right.> Parameters 56 | PanacheQuery .down.> Page 57 | 58 | @enduml 59 | -------------------------------------------------------------------------------- /vintage-store/README.md: -------------------------------------------------------------------------------- 1 | # panache Project 2 | 3 | This project uses Quarkus, the Supersonic Subatomic Java Framework. 4 | 5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . 6 | 7 | ## Running the application in dev mode 8 | 9 | You can run your application in dev mode that enables live coding using: 10 | ```shell script 11 | ./mvnw compile quarkus:dev 12 | ``` 13 | 14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. 15 | 16 | ## Packaging and running the application 17 | 18 | The application can be packaged using: 19 | ```shell script 20 | ./mvnw package 21 | ``` 22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. 23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. 24 | 25 | If you want to build an _über-jar_, execute the following command: 26 | ```shell script 27 | ./mvnw package -Dquarkus.package.type=uber-jar 28 | ``` 29 | 30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 31 | 32 | ## Creating a native executable 33 | 34 | You can create a native executable using: 35 | ```shell script 36 | ./mvnw package -Pnative 37 | ``` 38 | 39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 40 | ```shell script 41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 42 | ``` 43 | 44 | You can then execute your native executable with: `./target/panache-1.0.0-SNAPSHOT-runner` 45 | 46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html. 47 | 48 | ## Provided Code 49 | 50 | ### RESTEasy JAX-RS 51 | 52 | Easily start your RESTful Web Services 53 | 54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 55 | -------------------------------------------------------------------------------- /database-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus.orm 6 | database-generator 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | 3.0.0 11 | true 12 | 11 13 | 11 14 | UTF-8 15 | UTF-8 16 | 1.0.2 17 | 18 | 19 | 20 | com.github.javafaker 21 | javafaker 22 | ${javafaker.version} 23 | 24 | 25 | 26 | 27 | 28 | maven-compiler-plugin 29 | ${compiler-plugin.version} 30 | 31 | ${maven.compiler.parameters} 32 | 33 | 34 | 35 | org.codehaus.mojo 36 | exec-maven-plugin 37 | ${exec-plugin.version} 38 | 39 | org.agoncal.quarkus.FillUpDatabase 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /artist/src/main/java/org/agoncal/quarkus/jdbc/Artist.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jdbc; 2 | 3 | import java.time.Instant; 4 | 5 | /** 6 | * @author Antonio Goncalves 7 | * http://www.antoniogoncalves.org 8 | * -- 9 | */ 10 | public class Artist { 11 | 12 | // ====================================== 13 | // = Attributes = 14 | // ====================================== 15 | 16 | private Long id; 17 | private String name; 18 | private String bio; 19 | private Instant createdDate = Instant.now(); 20 | 21 | // ====================================== 22 | // = Constructors = 23 | // ====================================== 24 | 25 | public Artist() { 26 | } 27 | 28 | public Artist(String name, String bio) { 29 | this.name = name; 30 | this.bio = bio; 31 | } 32 | 33 | public Artist(String name) { 34 | this.name = name; 35 | } 36 | 37 | // ====================================== 38 | // = Getters & Setters = 39 | // ====================================== 40 | 41 | public Long getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getBio() { 58 | return bio; 59 | } 60 | 61 | public void setBio(String bio) { 62 | this.bio = bio; 63 | } 64 | 65 | public Instant getCreatedDate() { 66 | return createdDate; 67 | } 68 | 69 | public void setCreatedDate(Instant createdDate) { 70 | this.createdDate = createdDate; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "Artist{" + 76 | "id=" + id + 77 | ", name='" + name + '\'' + 78 | ", bio='" + bio + '\'' + 79 | ", createdDate=" + createdDate + 80 | '}'; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/resource/PurchaseOrderResource.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | 3 | 4 | import org.agoncal.quarkus.panache.model.PurchaseOrder; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.transaction.Transactional; 8 | import javax.ws.rs.Consumes; 9 | import javax.ws.rs.DELETE; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.NotFoundException; 12 | import javax.ws.rs.POST; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.core.Context; 17 | import javax.ws.rs.core.MediaType; 18 | import javax.ws.rs.core.Response; 19 | import javax.ws.rs.core.UriBuilder; 20 | import javax.ws.rs.core.UriInfo; 21 | import java.util.List; 22 | 23 | import static javax.transaction.Transactional.TxType.SUPPORTS; 24 | 25 | @Path("/api/purchase-orders") 26 | @Produces(MediaType.APPLICATION_JSON) 27 | @Consumes(MediaType.APPLICATION_JSON) 28 | @ApplicationScoped 29 | @Transactional(SUPPORTS) 30 | public class PurchaseOrderResource { 31 | 32 | @GET 33 | @Path("{id}") 34 | public PurchaseOrder findPurchaseOrderById(@PathParam("id") Long id) { 35 | return (PurchaseOrder) PurchaseOrder.findByIdOptional(id).orElseThrow(NotFoundException::new); 36 | } 37 | 38 | @GET 39 | public List listAllPurchaseOrders() { 40 | return PurchaseOrder.listAll(); 41 | } 42 | 43 | @POST 44 | @Transactional 45 | public Response persistPurchaseOrder(PurchaseOrder purchaseOrder, @Context UriInfo uriInfo) { 46 | PurchaseOrder.persist(purchaseOrder); 47 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(purchaseOrder.id)); 48 | return Response.created(builder.build()).build(); 49 | } 50 | 51 | @DELETE 52 | @Transactional 53 | @Path("/{id}") 54 | public void deletePurchaseOrder(@PathParam("id") Long id) { 55 | PurchaseOrder.deleteById(id); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/resource/CustomerResource.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | 3 | import org.agoncal.quarkus.jpa.Customer; 4 | import org.agoncal.quarkus.panache.repository.CustomerRepository; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.inject.Inject; 8 | import javax.transaction.Transactional; 9 | import javax.ws.rs.Consumes; 10 | import javax.ws.rs.DELETE; 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.NotFoundException; 13 | import javax.ws.rs.POST; 14 | import javax.ws.rs.Path; 15 | import javax.ws.rs.PathParam; 16 | import javax.ws.rs.Produces; 17 | import javax.ws.rs.core.Context; 18 | import javax.ws.rs.core.MediaType; 19 | import javax.ws.rs.core.Response; 20 | import javax.ws.rs.core.UriBuilder; 21 | import javax.ws.rs.core.UriInfo; 22 | import java.util.List; 23 | 24 | import static javax.transaction.Transactional.TxType.SUPPORTS; 25 | 26 | @Path("/api/customers") 27 | @Produces(MediaType.APPLICATION_JSON) 28 | @Consumes(MediaType.APPLICATION_JSON) 29 | @ApplicationScoped 30 | @Transactional(SUPPORTS) 31 | public class CustomerResource { 32 | 33 | @Inject 34 | CustomerRepository repository; 35 | 36 | @GET 37 | @Path("{id}") 38 | public Customer findCustomerById(@PathParam("id") Long id) { 39 | return repository.findByIdOptional(id).orElseThrow(NotFoundException::new); 40 | } 41 | 42 | @GET 43 | public List listAllCustomers() { 44 | return repository.listAll(); 45 | } 46 | 47 | @POST 48 | @Transactional 49 | public Response persistCustomer(Customer customer, @Context UriInfo uriInfo) { 50 | repository.persist(customer); 51 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(customer.getId())); 52 | return Response.created(builder.build()).build(); 53 | } 54 | 55 | @DELETE 56 | @Transactional 57 | @Path("/{id}") 58 | public void deleteCustomer(@PathParam("id") Long id) { 59 | repository.deleteById(id); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/model/Track.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.model; 2 | 3 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 4 | 5 | import javax.json.bind.annotation.JsonbTransient; 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.FetchType; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToOne; 11 | import javax.persistence.Table; 12 | import java.time.Duration; 13 | import java.time.Instant; 14 | import java.util.Objects; 15 | 16 | @Entity 17 | @Table(name = "t_tracks") 18 | public class Track extends PanacheEntity { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Column(nullable = false) 25 | public String title; 26 | 27 | @Column(nullable = false) 28 | public Duration duration; 29 | 30 | @JoinColumn(name = "cd_fk") 31 | @ManyToOne(fetch = FetchType.LAZY) 32 | @JsonbTransient 33 | public CD cd; 34 | 35 | @Column(name = "created_date", nullable = false) 36 | public Instant createdDate = Instant.now(); 37 | 38 | // ====================================== 39 | // = Constructors = 40 | // ====================================== 41 | 42 | public Track() { 43 | } 44 | 45 | public Track(String title, Duration duration) { 46 | this.title = title; 47 | this.duration = duration; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Track{" + 53 | "title='" + title + '\'' + 54 | ", duration=" + duration + 55 | ", createdDate=" + createdDate + 56 | ", id=" + id + 57 | '}'; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object o) { 62 | if (this == o) return true; 63 | if (o == null || getClass() != o.getClass()) return false; 64 | Track track = (Track) o; 65 | return id.equals(track.id); 66 | } 67 | 68 | @Override 69 | public int hashCode() { 70 | return Objects.hash(id); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/resource/PublisherResource.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | 3 | 4 | import org.agoncal.quarkus.panache.model.Publisher; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.transaction.Transactional; 8 | import javax.ws.rs.Consumes; 9 | import javax.ws.rs.DELETE; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.NotFoundException; 12 | import javax.ws.rs.POST; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.core.Context; 17 | import javax.ws.rs.core.MediaType; 18 | import javax.ws.rs.core.Response; 19 | import javax.ws.rs.core.UriBuilder; 20 | import javax.ws.rs.core.UriInfo; 21 | import java.util.List; 22 | 23 | import static javax.transaction.Transactional.TxType.SUPPORTS; 24 | 25 | @Path("/api/publishers") 26 | @Produces(MediaType.APPLICATION_JSON) 27 | @Consumes(MediaType.APPLICATION_JSON) 28 | @ApplicationScoped 29 | @Transactional(SUPPORTS) 30 | public class PublisherResource { 31 | 32 | @GET 33 | @Path("/{id: \\d+}") 34 | public Publisher findPublisherById(@PathParam("id") Long id) { 35 | return (Publisher) Publisher.findByIdOptional(id).orElseThrow(NotFoundException::new); 36 | } 37 | 38 | @GET 39 | @Path("/{name: \\D+}") 40 | public Publisher findPublisherByName(@PathParam("name") String name) { 41 | return Publisher.findByName(name).orElseThrow(NotFoundException::new); 42 | } 43 | 44 | @GET 45 | @Path("/like/{name}") 46 | public List findPublisherContainingName(@PathParam("name") String name) { 47 | return Publisher.findContainingName(name); 48 | } 49 | 50 | @GET 51 | public List listAllPublishers() { 52 | return Publisher.listAll(); 53 | } 54 | 55 | @POST 56 | @Transactional 57 | public Response persistPublisher(Publisher publisher, @Context UriInfo uriInfo) { 58 | Publisher.persist(publisher); 59 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(publisher.id)); 60 | return Response.created(builder.build()).build(); 61 | } 62 | 63 | @DELETE 64 | @Path("/{id}") 65 | @Transactional 66 | public void deletePublisher(@PathParam("id") Long id) { 67 | Publisher.deleteById(id); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/resource/ArtistResource.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | 3 | import org.agoncal.quarkus.jdbc.Artist; 4 | import org.agoncal.quarkus.panache.repository.ArtistRepository; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.inject.Inject; 8 | import javax.transaction.Transactional; 9 | import javax.ws.rs.Consumes; 10 | import javax.ws.rs.DELETE; 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.NotFoundException; 13 | import javax.ws.rs.POST; 14 | import javax.ws.rs.Path; 15 | import javax.ws.rs.PathParam; 16 | import javax.ws.rs.Produces; 17 | import javax.ws.rs.core.Context; 18 | import javax.ws.rs.core.MediaType; 19 | import javax.ws.rs.core.Response; 20 | import javax.ws.rs.core.UriBuilder; 21 | import javax.ws.rs.core.UriInfo; 22 | import java.util.List; 23 | 24 | import static javax.transaction.Transactional.TxType.SUPPORTS; 25 | 26 | @Path("/api/artists") 27 | @Produces(MediaType.APPLICATION_JSON) 28 | @Consumes(MediaType.APPLICATION_JSON) 29 | @ApplicationScoped 30 | @Transactional(SUPPORTS) 31 | public class ArtistResource { 32 | 33 | @Inject 34 | ArtistRepository repository; 35 | 36 | /** 37 | * curl http://localhost:8080/api/artists/1 38 | */ 39 | @GET 40 | @Path("{id}") 41 | public Artist findArtistById(@PathParam("id") Long id) { 42 | return repository.findByIdOptional(id).orElseThrow(NotFoundException::new); 43 | } 44 | 45 | /** 46 | * curl http://localhost:8080/api/artists 47 | */ 48 | @GET 49 | public List listAllArtists() { 50 | return repository.listAllArtistsSorted(); 51 | } 52 | 53 | /** 54 | * curl -X POST http://localhost:8080/api/artists -H 'Content-Type: application/json' -d '{ "bio": "artist bi", "name": "artist name" }' -v 55 | */ 56 | @POST 57 | @Transactional 58 | public Response persistArtist(Artist artist, @Context UriInfo uriInfo) { 59 | repository.persist(artist); 60 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(artist.getId())); 61 | return Response.created(builder.build()).build(); 62 | } 63 | 64 | /** 65 | * curl -X DELETE http://localhost:8080/api/artists/1 66 | */ 67 | @DELETE 68 | @Transactional 69 | @Path("/{id}") 70 | public void deleteArtist(@PathParam("id") Long id) { 71 | repository.deleteById(id); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/CDRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jdbc.Artist; 6 | import org.agoncal.quarkus.panache.model.CD; 7 | import org.agoncal.quarkus.panache.model.Track; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import javax.inject.Inject; 11 | import java.math.BigDecimal; 12 | import java.time.Duration; 13 | 14 | import static org.junit.jupiter.api.Assertions.assertEquals; 15 | import static org.junit.jupiter.api.Assertions.assertNotNull; 16 | 17 | @QuarkusTest 18 | public class CDRepositoryTest { 19 | 20 | @Inject 21 | ArtistRepository artistRepository; 22 | 23 | @Test 24 | @TestTransaction 25 | public void shouldCreateAndFindACD() { 26 | long countArtists = artistRepository.count(); 27 | long countTracks = Track.count(); 28 | long count = CD.count(); 29 | 30 | // Creates an Artist 31 | Artist artist = new Artist(); 32 | artist.setName("name"); 33 | artist.setBio("bio"); 34 | // Creates two Tracks 35 | Track first = new Track(); 36 | first.title = "title 1"; 37 | first.duration = Duration.ofSeconds(1_000); 38 | Track second = new Track(); 39 | second.title = "title 2"; 40 | second.duration = Duration.ofSeconds(500); 41 | // Creates a CD 42 | CD cd = new CD(); 43 | cd.title = "title"; 44 | cd.description = "description"; 45 | cd.price = new BigDecimal(10); 46 | cd.musicCompany = "music company"; 47 | cd.genre = "genre"; 48 | // Sets the two Tracks and Artist to the CD 49 | cd.artist = artist; 50 | cd.addTrack(first); 51 | cd.addTrack(second); 52 | 53 | // Persists the CD with two Tracks and one Artist 54 | CD.persist(cd); 55 | assertNotNull(cd.id); 56 | assertEquals(2, cd.tracks.size()); 57 | assertNotNull(cd.artist.getId()); 58 | 59 | assertEquals(countArtists + 1, artistRepository.count()); 60 | assertEquals(countTracks + 2, Track.count()); 61 | assertEquals(count + 1, CD.count()); 62 | 63 | // Gets the CD 64 | cd = CD.findById(cd.id); 65 | assertEquals("title", cd.title); 66 | 67 | // Deletes the CD 68 | CD.deleteById(cd.id); 69 | assertEquals(countArtists + 1, artistRepository.count()); 70 | assertEquals(countTracks, Track.count()); 71 | assertEquals(count, CD.count()); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/resource/ItemResource.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | 3 | import org.agoncal.quarkus.panache.model.Book; 4 | import org.agoncal.quarkus.panache.model.CD; 5 | 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.transaction.Transactional; 8 | import javax.ws.rs.Consumes; 9 | import javax.ws.rs.DELETE; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.POST; 12 | import javax.ws.rs.Path; 13 | import javax.ws.rs.PathParam; 14 | import javax.ws.rs.Produces; 15 | import javax.ws.rs.core.Context; 16 | import javax.ws.rs.core.MediaType; 17 | import javax.ws.rs.core.Response; 18 | import javax.ws.rs.core.UriBuilder; 19 | import javax.ws.rs.core.UriInfo; 20 | import java.util.List; 21 | 22 | import static javax.transaction.Transactional.TxType.SUPPORTS; 23 | 24 | @Path("/api/items") 25 | @Produces(MediaType.APPLICATION_JSON) 26 | @Consumes(MediaType.APPLICATION_JSON) 27 | @ApplicationScoped 28 | @Transactional(SUPPORTS) 29 | public class ItemResource { 30 | 31 | @GET 32 | @Path("/books/{id}") 33 | public Book findBookById(@PathParam("id") Long id) { 34 | return Book.findById(id); 35 | } 36 | 37 | @GET 38 | @Path("/books") 39 | public List listAllBooks() { 40 | return Book.listAll(); 41 | } 42 | 43 | @POST 44 | @Path("/books") 45 | @Transactional 46 | public Response persistBook(Book book, @Context UriInfo uriInfo) { 47 | Book.persist(book); 48 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(book.id)); 49 | return Response.created(builder.build()).build(); 50 | } 51 | 52 | @DELETE 53 | @Transactional 54 | @Path("/books/{id}") 55 | public void deleteBook(@PathParam("id") Long id) { 56 | Book.deleteById(id); 57 | } 58 | 59 | @GET 60 | @Path("/cds/{id}") 61 | public CD findCDById(@PathParam("id") Long id) { 62 | return CD.findById(id); 63 | } 64 | 65 | @GET 66 | @Path("/cds") 67 | public List listAllCDs() { 68 | return CD.listAll(); 69 | } 70 | 71 | @POST 72 | @Path("/cds") 73 | @Transactional 74 | public Response persistCD(CD cd, @Context UriInfo uriInfo) { 75 | CD.persist(cd); 76 | UriBuilder builder = uriInfo.getAbsolutePathBuilder().path(Long.toString(cd.id)); 77 | return Response.created(builder.build()).build(); 78 | } 79 | 80 | @DELETE 81 | @Transactional 82 | @Path("/cds/{id}") 83 | public void deleteCD(@PathParam("id") Long id) { 84 | CD.deleteById(id); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /vintage-store/src/main/java/org/agoncal/quarkus/panache/page/ItemPage.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.page; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.qute.CheckedTemplate; 5 | import io.quarkus.qute.TemplateInstance; 6 | import org.agoncal.quarkus.panache.model.Book; 7 | import org.agoncal.quarkus.panache.model.CD; 8 | 9 | import javax.enterprise.context.ApplicationScoped; 10 | import javax.ws.rs.DefaultValue; 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.Path; 13 | import javax.ws.rs.PathParam; 14 | import javax.ws.rs.Produces; 15 | import javax.ws.rs.QueryParam; 16 | import javax.ws.rs.core.MediaType; 17 | import java.util.List; 18 | 19 | @Path("/page/items") 20 | @Produces(MediaType.TEXT_HTML) 21 | @ApplicationScoped 22 | public class ItemPage { 23 | 24 | @CheckedTemplate 25 | public static class Templates { 26 | public static native TemplateInstance book(Book book); 27 | 28 | public static native TemplateInstance books(List books); 29 | 30 | public static native TemplateInstance cd(CD cd); 31 | 32 | public static native TemplateInstance cds(List cds); 33 | } 34 | 35 | @GET 36 | @Path("/books/{id}") 37 | public TemplateInstance showBookById(@PathParam("id") Long id) { 38 | return Templates.book(Book.findById(id)); 39 | } 40 | 41 | @GET 42 | @Path("/books") 43 | public TemplateInstance showAllBooks(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 44 | return Templates.books(Book.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 45 | .data("query", query) 46 | .data("sort", sort) 47 | .data("pageIndex", pageIndex) 48 | .data("pageSize", pageSize); 49 | } 50 | 51 | @GET 52 | @Path("/cds/{id}") 53 | public TemplateInstance showCDById(@PathParam("id") Long id) { 54 | return Templates.cd(CD.findById(id)); 55 | } 56 | 57 | @GET 58 | @Path("/cds") 59 | public TemplateInstance showAllCDs(@QueryParam("query") String query, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("page") @DefaultValue("0") Integer pageIndex, @QueryParam("size") @DefaultValue("1000") Integer pageSize) { 60 | return Templates.cds(CD.find(query, Sort.by(sort)).page(pageIndex, pageSize).list()) 61 | .data("query", query) 62 | .data("sort", sort) 63 | .data("pageIndex", pageIndex) 64 | .data("pageSize", pageSize); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vintage-store/src/main/resources/templates/ItemPage/book.html: -------------------------------------------------------------------------------- 1 | {#include base.html} 2 | {#title}Book {book.id}{/title} 3 | {#body} 4 |
5 | 6 |
7 | 8 |
9 |
10 |
11 | 12 |
13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 | 60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 | 68 |
69 |
70 | Back to Books 71 | {/body} 72 | {/include} 73 | -------------------------------------------------------------------------------- /customer/src/main/java/org/agoncal/quarkus/jpa/Customer.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.jpa; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import java.time.Instant; 10 | 11 | /** 12 | * @author Antonio Goncalves 13 | * http://www.antoniogoncalves.org 14 | * -- 15 | */ 16 | @Entity 17 | @Table(name = "t_customers") 18 | public class Customer { 19 | 20 | // ====================================== 21 | // = Attributes = 22 | // ====================================== 23 | 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.AUTO) 26 | private Long id; 27 | 28 | @Column(name = "first_name", length = 50, nullable = false) 29 | private String firstName; 30 | 31 | @Column(name = "last_name", length = 50, nullable = false) 32 | private String lastName; 33 | 34 | @Column(name = "e_mail", nullable = false) 35 | private String email; 36 | 37 | @Column(name = "created_date", nullable = false) 38 | private Instant createdDate = Instant.now(); 39 | 40 | // ====================================== 41 | // = Constructors = 42 | // ====================================== 43 | 44 | public Customer() { 45 | } 46 | 47 | public Customer(String firstName, String lastName, String email) { 48 | this.firstName = firstName; 49 | this.lastName = lastName; 50 | this.email = email; 51 | } 52 | 53 | // ====================================== 54 | // = Getters & Setters = 55 | // ====================================== 56 | 57 | public Long getId() { 58 | return id; 59 | } 60 | 61 | public String getFirstName() { 62 | return firstName; 63 | } 64 | 65 | public void setFirstName(String firstName) { 66 | this.firstName = firstName; 67 | } 68 | 69 | public String getLastName() { 70 | return lastName; 71 | } 72 | 73 | public void setLastName(String lastName) { 74 | this.lastName = lastName; 75 | } 76 | 77 | public String getEmail() { 78 | return email; 79 | } 80 | 81 | public void setEmail(String email) { 82 | this.email = email; 83 | } 84 | 85 | public Instant getCreatedDate() { 86 | return createdDate; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "Customer{" + 92 | "id=" + id + 93 | ", firstName='" + firstName + '\'' + 94 | ", lastName='" + lastName + '\'' + 95 | ", email='" + email + '\'' + 96 | ", createdDate=" + createdDate + 97 | '}'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/BookRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.panache.common.Sort; 4 | import io.quarkus.test.TestTransaction; 5 | import io.quarkus.test.junit.QuarkusTest; 6 | import org.agoncal.quarkus.jdbc.Artist; 7 | import org.agoncal.quarkus.panache.model.Book; 8 | import org.agoncal.quarkus.panache.model.Language; 9 | import org.agoncal.quarkus.panache.model.Publisher; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import javax.inject.Inject; 13 | import java.math.BigDecimal; 14 | import java.time.LocalDate; 15 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals; 17 | import static org.junit.jupiter.api.Assertions.assertNotNull; 18 | import static org.junit.jupiter.api.Assertions.assertTrue; 19 | 20 | @QuarkusTest 21 | public class BookRepositoryTest { 22 | 23 | @Inject 24 | ArtistRepository artistRepository; 25 | 26 | @Test 27 | @TestTransaction 28 | public void shouldCreateAndFindABook() { 29 | long countArtists = artistRepository.count(); 30 | long countPublishers = Publisher.count(); 31 | long count = Book.count(); 32 | 33 | // Creates an Artist 34 | Artist artist = new Artist(); 35 | artist.setName("name"); 36 | artist.setBio("bio"); 37 | // Creates a Publisher 38 | Publisher publisher = new Publisher(); 39 | publisher.name = "name"; 40 | // Creates a Book 41 | Book book = new Book(); 42 | book.title = "title"; 43 | book.description = "description"; 44 | book.price = new BigDecimal(10); 45 | book.isbn = "ISBN"; 46 | book.nbOfPages = 500; 47 | book.publicationDate = LocalDate.now().minusDays(100); 48 | book.language = Language.ENGLISH; 49 | // Sets the Publisher and Artist to the Book 50 | book.publisher = publisher; 51 | book.artist = artist; 52 | 53 | // Persists the Book with one Publisher and one Artist 54 | Book.persist(book); 55 | assertNotNull(book.id); 56 | assertNotNull(book.publisher.id); 57 | assertNotNull(book.artist.getId()); 58 | 59 | assertEquals(countArtists + 1, artistRepository.count()); 60 | assertEquals(countPublishers + 1, Publisher.count()); 61 | assertEquals(count + 1, Book.count()); 62 | 63 | // Gets the Book 64 | book = Book.findById(book.id); 65 | assertEquals("title", book.title); 66 | 67 | // Deletes the Book 68 | Book.deleteById(book.id); 69 | assertEquals(countArtists + 1, artistRepository.count()); 70 | assertEquals(countPublishers + 1, Publisher.count()); 71 | assertEquals(count, Book.count()); 72 | } 73 | 74 | @Test 75 | @TestTransaction 76 | public void shouldCheckAdvancedQueries() { 77 | long findAll = Book.find(null, Sort.by("id")).page(0, 1000).count(); 78 | assertEquals(findAll, Book.find(null, Sort.by("isbn")).page(0, 1000).count()); 79 | assertEquals(findAll, Book.find(null).page(0, 1000).count()); 80 | assertEquals(findAll, Book.find(null).count()); 81 | assertTrue(Book.find("nbOfPages < 100").count() < findAll); 82 | assertTrue(Book.find("nbOfPages < 100", Sort.by("nbOfPages")).count() < findAll); 83 | assertTrue(Book.find("nbOfPages < 100", Sort.by("nbOfPages")).page(0, 1000).count() < findAll); 84 | assertTrue(Book.find("nbOfPages < 100 and price > 10", Sort.by("price")).page(0, 1000).count() < findAll); 85 | assertTrue(Book.find("nbOfPages < 100 and price > 10", Sort.by("price")).page(0, 5).count() < findAll); 86 | assertTrue(Book.find("nbOfPages < 100 and price > 10", Sort.by("price")).page(1, 5).count() < findAll); 87 | assertTrue(Book.find("nbOfPages < 100 and price > 10", Sort.by("price")).page(2, 5).count() < findAll); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/repository/PurchaseOrderRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.repository; 2 | 3 | import io.quarkus.test.TestTransaction; 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import org.agoncal.quarkus.jdbc.Artist; 6 | import org.agoncal.quarkus.jpa.Customer; 7 | import org.agoncal.quarkus.panache.model.Book; 8 | import org.agoncal.quarkus.panache.model.Language; 9 | import org.agoncal.quarkus.panache.model.OrderLine; 10 | import org.agoncal.quarkus.panache.model.Publisher; 11 | import org.agoncal.quarkus.panache.model.PurchaseOrder; 12 | import org.junit.jupiter.api.Test; 13 | 14 | import javax.inject.Inject; 15 | import java.math.BigDecimal; 16 | import java.time.LocalDate; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | import static org.junit.jupiter.api.Assertions.assertNotNull; 20 | 21 | @QuarkusTest 22 | public class PurchaseOrderRepositoryTest { 23 | 24 | @Inject 25 | CustomerRepository customerRepository; 26 | @Inject 27 | ArtistRepository artistRepository; 28 | 29 | @Test 30 | @TestTransaction 31 | public void shouldCreateAndFindAPurchaseOrder() { 32 | long countCustomers = customerRepository.count(); 33 | long countArtists = artistRepository.count(); 34 | long countPublishers = Publisher.count(); 35 | long countBooks = Book.count(); 36 | long countPurchaseOrders = PurchaseOrder.count(); 37 | long countOrderLines = OrderLine.count(); 38 | 39 | // Creates a Customer 40 | Customer customer = new Customer(); 41 | customer.setFirstName("first name"); 42 | customer.setLastName("last name"); 43 | customer.setEmail("email"); 44 | // Creates an Artist 45 | Artist artist = new Artist(); 46 | artist.setName("name"); 47 | artist.setBio("bio"); 48 | // Creates a Publisher 49 | Publisher publisher = new Publisher(); 50 | publisher.name = "name"; 51 | // Creates a Book 52 | Book book = new Book(); 53 | book.title = "title"; 54 | book.description = "description"; 55 | book.price = new BigDecimal(10); 56 | book.isbn = "ISBN"; 57 | book.nbOfPages = 500; 58 | book.publicationDate = LocalDate.now().minusDays(100); 59 | book.language = Language.ENGLISH; 60 | // Sets the Publisher and Artist to the Book 61 | book.publisher = publisher; 62 | book.artist = artist; 63 | // Persists the Book with one Publisher and one Artist 64 | Book.persist(book); 65 | 66 | // Creates a PurchaseOrder with an OrderLine 67 | OrderLine orderLine = new OrderLine(); 68 | orderLine.item = book; 69 | orderLine.quantity = 2; 70 | PurchaseOrder purchaseOrder = new PurchaseOrder(); 71 | // Sets the Customer, Publisher, Artist and Book to the Purchase Order 72 | purchaseOrder.customer = customer; 73 | purchaseOrder.addOrderLine(orderLine); 74 | 75 | // Persists the PurchaseOrder and one OrderLine 76 | PurchaseOrder.persist(purchaseOrder); 77 | assertNotNull(purchaseOrder.id); 78 | assertEquals(1, purchaseOrder.orderLines.size()); 79 | 80 | assertEquals(countCustomers + 1, customerRepository.count()); 81 | assertEquals(countArtists + 1, artistRepository.count()); 82 | assertEquals(countPublishers + 1, Publisher.count()); 83 | assertEquals(countBooks + 1, Book.count()); 84 | assertEquals(countPurchaseOrders + 1, PurchaseOrder.count()); 85 | assertEquals(countOrderLines + 1, OrderLine.count()); 86 | 87 | // Gets the PurchaseOrder 88 | purchaseOrder = PurchaseOrder.findById(purchaseOrder.id); 89 | 90 | // Deletes the PurchaseOrder 91 | PurchaseOrder.deleteById(purchaseOrder.id); 92 | assertEquals(countCustomers + 1, customerRepository.count()); 93 | assertEquals(countArtists + 1, artistRepository.count()); 94 | assertEquals(countPublishers + 1, Publisher.count()); 95 | assertEquals(countBooks + 1, Book.count()); 96 | assertEquals(countPurchaseOrders, PurchaseOrder.count()); 97 | assertEquals(countOrderLines, OrderLine.count()); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/resource/ArtistResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | //@formatter:off 3 | 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import io.restassured.mapper.ObjectMapperType; 6 | import org.agoncal.quarkus.jdbc.Artist; 7 | import org.junit.jupiter.api.MethodOrderer; 8 | import org.junit.jupiter.api.Order; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.TestMethodOrder; 11 | 12 | import java.util.List; 13 | import java.util.Random; 14 | 15 | import static io.restassured.RestAssured.given; 16 | import static javax.ws.rs.core.HttpHeaders.ACCEPT; 17 | import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; 18 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 19 | import static javax.ws.rs.core.Response.Status.CREATED; 20 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 21 | import static javax.ws.rs.core.Response.Status.NO_CONTENT; 22 | import static javax.ws.rs.core.Response.Status.OK; 23 | import static org.hamcrest.Matchers.hasKey; 24 | import static org.hamcrest.core.Is.is; 25 | import static org.junit.jupiter.api.Assertions.assertEquals; 26 | import static org.junit.jupiter.api.Assertions.assertNotNull; 27 | import static org.junit.jupiter.api.Assertions.assertTrue; 28 | 29 | @QuarkusTest 30 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 31 | class ArtistResourceTest { 32 | 33 | private static int nbArtists; 34 | private static String artistId; 35 | 36 | @Test 37 | void shouldNotGetUnknownArtist() { 38 | Long randomId = new Random().nextLong(); 39 | given() 40 | .header(ACCEPT, APPLICATION_JSON) 41 | .pathParam("id", randomId). 42 | when() 43 | .get("/api/artists/{id}"). 44 | then() 45 | .statusCode(NOT_FOUND.getStatusCode()); 46 | } 47 | 48 | @Test 49 | @Order(1) 50 | void shouldGetInitialArtists() { 51 | nbArtists = 52 | given() 53 | .header(ACCEPT, APPLICATION_JSON). 54 | when() 55 | .get("/api/artists"). 56 | then() 57 | .statusCode(OK.getStatusCode()) 58 | .header(CONTENT_TYPE, APPLICATION_JSON) 59 | .extract().body().as(List.class).size(); 60 | } 61 | 62 | @Test 63 | @Order(2) 64 | void shouldCreateANewArtist() { 65 | Artist artist = new Artist(); 66 | artist.setName("name"); 67 | artist.setBio("bio"); 68 | 69 | String location = 70 | given() 71 | .body(artist, ObjectMapperType.JSONB) 72 | .header(CONTENT_TYPE, APPLICATION_JSON) 73 | .header(ACCEPT, APPLICATION_JSON). 74 | when() 75 | .post("/api/artists"). 76 | then() 77 | .statusCode(CREATED.getStatusCode()) 78 | .extract().header("Location"); 79 | 80 | // Extracts the Location and stores the id 81 | assertTrue(location.contains("/api/artists")); 82 | String[] segments = location.split("/"); 83 | artistId = segments[segments.length - 1]; 84 | assertNotNull(artistId); 85 | } 86 | 87 | @Test 88 | @Order(3) 89 | void shouldGetAnExtraArtist() { 90 | int artists = 91 | given() 92 | .header(ACCEPT, APPLICATION_JSON). 93 | when() 94 | .get("/api/artists"). 95 | then() 96 | .statusCode(OK.getStatusCode()) 97 | .header(CONTENT_TYPE, APPLICATION_JSON) 98 | .extract().body().as(List.class).size(); 99 | 100 | assertEquals(nbArtists + 1, artists); 101 | } 102 | 103 | @Test 104 | @Order(4) 105 | void shouldCheckTheExtraArtist() { 106 | given() 107 | .header(ACCEPT, APPLICATION_JSON) 108 | .pathParam("id", artistId). 109 | when() 110 | .get("/api/artists/{id}"). 111 | then() 112 | .statusCode(OK.getStatusCode()) 113 | .header(CONTENT_TYPE, APPLICATION_JSON) 114 | .body("name", is("name")) 115 | .body("bio", is("bio")) 116 | .body("$", hasKey("id")) 117 | .body("$", hasKey("createdDate")); 118 | } 119 | 120 | @Test 121 | @Order(5) 122 | void shouldDeleteTheExtraArtist() { 123 | given() 124 | .header(ACCEPT, APPLICATION_JSON) 125 | .pathParam("id", artistId). 126 | when() 127 | .delete("/api/artists/{id}"). 128 | then() 129 | .statusCode(NO_CONTENT.getStatusCode()); 130 | } 131 | 132 | @Test 133 | @Order(6) 134 | void shouldGetLessAnArtist() { 135 | int artists = 136 | given() 137 | .header(ACCEPT, APPLICATION_JSON). 138 | when() 139 | .get("/api/artists"). 140 | then() 141 | .statusCode(OK.getStatusCode()) 142 | .header(CONTENT_TYPE, APPLICATION_JSON) 143 | .extract().body().as(List.class).size(); 144 | 145 | assertEquals(nbArtists, artists); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/resource/PublisherResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | //@formatter:off 3 | 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import io.restassured.mapper.ObjectMapperType; 6 | import org.agoncal.quarkus.panache.model.Publisher; 7 | import org.junit.jupiter.api.Disabled; 8 | import org.junit.jupiter.api.MethodOrderer; 9 | import org.junit.jupiter.api.Order; 10 | import org.junit.jupiter.api.Test; 11 | import org.junit.jupiter.api.TestMethodOrder; 12 | 13 | import java.util.List; 14 | import java.util.Random; 15 | 16 | import static io.restassured.RestAssured.given; 17 | import static javax.ws.rs.core.HttpHeaders.ACCEPT; 18 | import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; 19 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 20 | import static javax.ws.rs.core.Response.Status.CREATED; 21 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 22 | import static javax.ws.rs.core.Response.Status.NO_CONTENT; 23 | import static javax.ws.rs.core.Response.Status.OK; 24 | import static org.hamcrest.Matchers.hasKey;import static org.hamcrest.core.Is.is; 25 | import static org.junit.jupiter.api.Assertions.assertEquals; 26 | import static org.junit.jupiter.api.Assertions.assertNotNull; 27 | import static org.junit.jupiter.api.Assertions.assertTrue; 28 | 29 | @QuarkusTest 30 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 31 | class PublisherResourceTest { 32 | 33 | private static int nbPublishers; 34 | private static String publisherId; 35 | 36 | @Test @Disabled 37 | void shouldNotGetUnknownPublisher() { 38 | Long randomId = new Random().nextLong(); 39 | given() 40 | .header(ACCEPT, APPLICATION_JSON) 41 | .pathParam("id", randomId). 42 | when() 43 | .get("/api/publishers/{id}"). 44 | then() 45 | .statusCode(NOT_FOUND.getStatusCode()); 46 | } 47 | 48 | @Test 49 | @Order(1) 50 | void shouldGetInitialPublishers() { 51 | nbPublishers = 52 | given() 53 | .header(ACCEPT, APPLICATION_JSON). 54 | when() 55 | .get("/api/publishers"). 56 | then() 57 | .statusCode(OK.getStatusCode()) 58 | .header(CONTENT_TYPE, APPLICATION_JSON) 59 | .extract().body().as(List.class).size(); 60 | } 61 | 62 | @Test 63 | @Order(2) 64 | void shouldCreateANewPublisher() { 65 | Publisher publisher = new Publisher(); 66 | publisher.name = "name"; 67 | 68 | String location = 69 | given() 70 | .body(publisher, ObjectMapperType.JSONB) 71 | .header(CONTENT_TYPE, APPLICATION_JSON) 72 | .header(ACCEPT, APPLICATION_JSON). 73 | when() 74 | .post("/api/publishers"). 75 | then() 76 | .statusCode(CREATED.getStatusCode()) 77 | .extract().header("Location"); 78 | 79 | // Extracts the Location and stores the id 80 | assertTrue(location.contains("/api/publishers")); 81 | String[] segments = location.split("/"); 82 | publisherId = segments[segments.length - 1]; 83 | assertNotNull(publisherId); 84 | } 85 | 86 | @Test 87 | @Order(3) 88 | void shouldGetAnExtraPublisher() { 89 | int publishers = 90 | given() 91 | .header(ACCEPT, APPLICATION_JSON). 92 | when() 93 | .get("/api/publishers"). 94 | then() 95 | .statusCode(OK.getStatusCode()) 96 | .header(CONTENT_TYPE, APPLICATION_JSON) 97 | .extract().body().as(List.class).size(); 98 | 99 | assertEquals(nbPublishers + 1, publishers); 100 | } 101 | 102 | @Test 103 | @Order(4) 104 | void shouldCheckTheExtraPublisher() { 105 | given() 106 | .header(ACCEPT, APPLICATION_JSON) 107 | .pathParam("id", publisherId). 108 | when() 109 | .get("/api/publishers/{id}"). 110 | then() 111 | .statusCode(OK.getStatusCode()) 112 | .header(CONTENT_TYPE, APPLICATION_JSON) 113 | .body("name", is("name")) 114 | .body("$", hasKey("id")) 115 | .body("$", hasKey("createdDate")); 116 | } 117 | 118 | @Test 119 | @Order(5) 120 | void shouldDeleteTheExtraPublisher() { 121 | given() 122 | .header(ACCEPT, APPLICATION_JSON) 123 | .pathParam("id", publisherId). 124 | when() 125 | .delete("/api/publishers/{id}"). 126 | then() 127 | .statusCode(NO_CONTENT.getStatusCode()); 128 | } 129 | 130 | @Test 131 | @Order(6) 132 | void shouldGetLessAnPublisher() { 133 | int publishers = 134 | given() 135 | .header(ACCEPT, APPLICATION_JSON). 136 | when() 137 | .get("/api/publishers"). 138 | then() 139 | .statusCode(OK.getStatusCode()) 140 | .header(CONTENT_TYPE, APPLICATION_JSON) 141 | .extract().body().as(List.class).size(); 142 | 143 | assertEquals(nbPublishers, publishers); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/resource/CustomerResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | //@formatter:off 3 | 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import io.restassured.mapper.ObjectMapperType; 6 | import org.agoncal.quarkus.jpa.Customer; 7 | import org.junit.jupiter.api.MethodOrderer; 8 | import org.junit.jupiter.api.Order; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.TestMethodOrder; 11 | 12 | import java.util.List; 13 | import java.util.Random; 14 | 15 | import static io.restassured.RestAssured.given; 16 | import static javax.ws.rs.core.HttpHeaders.ACCEPT; 17 | import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; 18 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 19 | import static javax.ws.rs.core.Response.Status.CREATED; 20 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 21 | import static javax.ws.rs.core.Response.Status.NO_CONTENT; 22 | import static javax.ws.rs.core.Response.Status.OK; 23 | import static org.hamcrest.Matchers.hasKey;import static org.hamcrest.core.Is.is; 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | import static org.junit.jupiter.api.Assertions.assertNotNull; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | @QuarkusTest 29 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 30 | class CustomerResourceTest { 31 | 32 | private static int nbCustomers; 33 | private static String customerId; 34 | 35 | @Test 36 | void shouldNotGetUnknownCustomer() { 37 | Long randomId = new Random().nextLong(); 38 | given() 39 | .header(ACCEPT, APPLICATION_JSON) 40 | .pathParam("id", randomId). 41 | when() 42 | .get("/api/customers/{id}"). 43 | then() 44 | .statusCode(NOT_FOUND.getStatusCode()); 45 | } 46 | 47 | @Test 48 | @Order(1) 49 | void shouldGetInitialCustomers() { 50 | nbCustomers = 51 | given() 52 | .header(ACCEPT, APPLICATION_JSON). 53 | when() 54 | .get("/api/customers"). 55 | then() 56 | .statusCode(OK.getStatusCode()) 57 | .header(CONTENT_TYPE, APPLICATION_JSON) 58 | .extract().body().as(List.class).size(); 59 | } 60 | 61 | @Test 62 | @Order(2) 63 | void shouldCreateANewCustomer() { 64 | Customer customer = new Customer(); 65 | customer.setFirstName("first name"); 66 | customer.setLastName("last name"); 67 | customer.setEmail("email"); 68 | 69 | String location = 70 | given() 71 | .body(customer, ObjectMapperType.JSONB) 72 | .header(CONTENT_TYPE, APPLICATION_JSON) 73 | .header(ACCEPT, APPLICATION_JSON). 74 | when() 75 | .post("/api/customers"). 76 | then() 77 | .statusCode(CREATED.getStatusCode()) 78 | .extract().header("Location"); 79 | 80 | // Extracts the Location and stores the id 81 | assertTrue(location.contains("/api/customers")); 82 | String[] segments = location.split("/"); 83 | customerId = segments[segments.length - 1]; 84 | assertNotNull(customerId); 85 | } 86 | 87 | @Test 88 | @Order(3) 89 | void shouldGetAnExtraCustomer() { 90 | int customers = 91 | given() 92 | .header(ACCEPT, APPLICATION_JSON). 93 | when() 94 | .get("/api/customers"). 95 | then() 96 | .statusCode(OK.getStatusCode()) 97 | .header(CONTENT_TYPE, APPLICATION_JSON) 98 | .extract().body().as(List.class).size(); 99 | 100 | assertEquals(nbCustomers + 1, customers); 101 | } 102 | 103 | @Test 104 | @Order(4) 105 | void shouldCheckTheExtraCustomer() { 106 | given() 107 | .header(ACCEPT, APPLICATION_JSON) 108 | .pathParam("id", customerId). 109 | when() 110 | .get("/api/customers/{id}"). 111 | then() 112 | .statusCode(OK.getStatusCode()) 113 | .header(CONTENT_TYPE, APPLICATION_JSON) 114 | .body("firstName", is("first name")) 115 | .body("lastName", is("last name")) 116 | .body("email", is("email")) 117 | .body("$", hasKey("id")) 118 | .body("$", hasKey("createdDate")); } 119 | 120 | @Test 121 | @Order(5) 122 | void shouldDeleteTheExtraCustomer() { 123 | given() 124 | .header(ACCEPT, APPLICATION_JSON) 125 | .pathParam("id", customerId). 126 | when() 127 | .delete("/api/customers/{id}"). 128 | then() 129 | .statusCode(NO_CONTENT.getStatusCode()); 130 | } 131 | 132 | @Test 133 | @Order(6) 134 | void shouldGetLessAnCustomer() { 135 | int customers = 136 | given() 137 | .header(ACCEPT, APPLICATION_JSON). 138 | when() 139 | .get("/api/customers"). 140 | then() 141 | .statusCode(OK.getStatusCode()) 142 | .header(CONTENT_TYPE, APPLICATION_JSON) 143 | .extract().body().as(List.class).size(); 144 | 145 | assertEquals(nbCustomers, customers); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /vintage-store/src/test/java/org/agoncal/quarkus/panache/resource/PurchaseOrderResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.agoncal.quarkus.panache.resource; 2 | //@formatter:off 3 | 4 | import io.quarkus.test.junit.QuarkusTest; 5 | import io.restassured.mapper.ObjectMapperType; 6 | import org.agoncal.quarkus.panache.model.PurchaseOrder; 7 | import org.junit.jupiter.api.MethodOrderer; 8 | import org.junit.jupiter.api.Order; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.TestMethodOrder; 11 | 12 | import java.time.LocalDate; 13 | import java.util.List; 14 | import java.util.Random; 15 | 16 | import static io.restassured.RestAssured.given; 17 | import static javax.ws.rs.core.HttpHeaders.ACCEPT; 18 | import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; 19 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 20 | import static javax.ws.rs.core.Response.Status.CREATED; 21 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 22 | import static javax.ws.rs.core.Response.Status.NO_CONTENT; 23 | import static javax.ws.rs.core.Response.Status.OK; 24 | import static org.hamcrest.Matchers.hasKey; 25 | import static org.junit.jupiter.api.Assertions.assertEquals; 26 | import static org.junit.jupiter.api.Assertions.assertNotNull; 27 | import static org.junit.jupiter.api.Assertions.assertTrue; 28 | 29 | @QuarkusTest 30 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 31 | class PurchaseOrderResourceTest { 32 | 33 | private static int nbPurchaseOrders; 34 | private static String purchaseOrderId; 35 | 36 | @Test 37 | void shouldNotGetUnknownPurchaseOrder() { 38 | Long randomId = new Random().nextLong(); 39 | given() 40 | .header(ACCEPT, APPLICATION_JSON) 41 | .pathParam("id", randomId). 42 | when() 43 | .get("/api/purchase-orders/{id}"). 44 | then() 45 | .statusCode(NOT_FOUND.getStatusCode()); 46 | } 47 | 48 | @Test 49 | @Order(1) 50 | void shouldGetInitialPurchaseOrders() { 51 | nbPurchaseOrders = 52 | given() 53 | .header(ACCEPT, APPLICATION_JSON). 54 | when() 55 | .get("/api/purchase-orders"). 56 | then() 57 | .statusCode(OK.getStatusCode()) 58 | .header(CONTENT_TYPE, APPLICATION_JSON) 59 | .extract().body().as(List.class).size(); 60 | } 61 | 62 | @Test 63 | @Order(2) 64 | void shouldCreateANewPurchaseOrder() { 65 | PurchaseOrder purchaseOrder = new PurchaseOrder(); 66 | purchaseOrder.date = LocalDate.now(); 67 | 68 | String location = 69 | given() 70 | .body(purchaseOrder, ObjectMapperType.JSONB) 71 | .header(CONTENT_TYPE, APPLICATION_JSON) 72 | .header(ACCEPT, APPLICATION_JSON). 73 | when() 74 | .post("/api/purchase-orders"). 75 | then() 76 | .statusCode(CREATED.getStatusCode()) 77 | .extract().header("Location"); 78 | 79 | // Extracts the Location and stores the id 80 | assertTrue(location.contains("/api/purchase-orders")); 81 | String[] segments = location.split("/"); 82 | purchaseOrderId = segments[segments.length - 1]; 83 | assertNotNull(purchaseOrderId); 84 | } 85 | 86 | @Test 87 | @Order(3) 88 | void shouldGetAnExtraPurchaseOrder() { 89 | int purchaseOrders = 90 | given() 91 | .header(ACCEPT, APPLICATION_JSON). 92 | when() 93 | .get("/api/purchase-orders"). 94 | then() 95 | .statusCode(OK.getStatusCode()) 96 | .header(CONTENT_TYPE, APPLICATION_JSON) 97 | .extract().body().as(List.class).size(); 98 | 99 | assertEquals(nbPurchaseOrders + 1, purchaseOrders); 100 | } 101 | 102 | @Test 103 | @Order(4) 104 | void shouldCheckTheExtraPurchaseOrder() { 105 | given() 106 | .header(ACCEPT, APPLICATION_JSON) 107 | .pathParam("id", purchaseOrderId). 108 | when() 109 | .get("/api/purchase-orders/{id}"). 110 | then() 111 | .statusCode(OK.getStatusCode()) 112 | .header(CONTENT_TYPE, APPLICATION_JSON) 113 | .body("$", hasKey("id")) 114 | .body("$", hasKey("date")) 115 | .body("$", hasKey("createdDate")); 116 | } 117 | 118 | @Test 119 | @Order(5) 120 | void shouldDeleteTheExtraPurchaseOrder() { 121 | given() 122 | .header(ACCEPT, APPLICATION_JSON) 123 | .pathParam("id", purchaseOrderId). 124 | when() 125 | .delete("/api/purchase-orders/{id}"). 126 | then() 127 | .statusCode(NO_CONTENT.getStatusCode()); 128 | } 129 | 130 | @Test 131 | @Order(6) 132 | void shouldGetLessAnPurchaseOrder() { 133 | int purchaseOrders = 134 | given() 135 | .header(ACCEPT, APPLICATION_JSON). 136 | when() 137 | .get("/api/purchase-orders"). 138 | then() 139 | .statusCode(OK.getStatusCode()) 140 | .header(CONTENT_TYPE, APPLICATION_JSON) 141 | .extract().body().as(List.class).size(); 142 | 143 | assertEquals(nbPurchaseOrders, purchaseOrders); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /artist/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus.orm 6 | artist 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 11 12 | 11 13 | UTF-8 14 | UTF-8 15 | 2.0.0.Final 16 | quarkus-bom 17 | io.quarkus 18 | 2.0.0.Final 19 | 3.0.0-M5 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | io.quarkus 35 | quarkus-jdbc-mysql 36 | 37 | 38 | io.quarkus 39 | quarkus-agroal 40 | 41 | 42 | io.quarkus 43 | quarkus-arc 44 | 45 | 46 | io.quarkus 47 | quarkus-junit5 48 | test 49 | 50 | 51 | 52 | 53 | 54 | io.quarkus 55 | quarkus-maven-plugin 56 | ${quarkus-plugin.version} 57 | true 58 | 59 | 60 | 61 | build 62 | generate-code 63 | generate-code-tests 64 | 65 | 66 | 67 | 68 | 69 | maven-compiler-plugin 70 | ${compiler-plugin.version} 71 | 72 | ${maven.compiler.parameters} 73 | 74 | 75 | 76 | maven-surefire-plugin 77 | ${surefire-plugin.version} 78 | 79 | 80 | org.jboss.logmanager.LogManager 81 | ${maven.home} 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | native 90 | 91 | 92 | native 93 | 94 | 95 | 96 | 97 | 98 | maven-failsafe-plugin 99 | ${surefire-plugin.version} 100 | 101 | 102 | 103 | integration-test 104 | verify 105 | 106 | 107 | 108 | ${project.build.directory}/${project.build.finalName}-runner 109 | org.jboss.logmanager.LogManager 110 | ${maven.home} 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | native 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /customer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus.orm 6 | customer 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 11 12 | 11 13 | UTF-8 14 | UTF-8 15 | 2.0.0.Final 16 | quarkus-bom 17 | io.quarkus 18 | 2.0.0.Final 19 | 3.0.0-M5 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | io.quarkus 35 | quarkus-jdbc-mariadb 36 | 37 | 38 | io.quarkus 39 | quarkus-hibernate-orm 40 | 41 | 42 | io.quarkus 43 | quarkus-hibernate-validator 44 | 45 | 46 | io.quarkus 47 | quarkus-arc 48 | 49 | 50 | io.quarkus 51 | quarkus-junit5 52 | test 53 | 54 | 55 | 56 | 57 | 58 | io.quarkus 59 | quarkus-maven-plugin 60 | ${quarkus-plugin.version} 61 | true 62 | 63 | 64 | 65 | build 66 | generate-code 67 | generate-code-tests 68 | 69 | 70 | 71 | 72 | 73 | maven-compiler-plugin 74 | ${compiler-plugin.version} 75 | 76 | ${maven.compiler.parameters} 77 | 78 | 79 | 80 | maven-surefire-plugin 81 | ${surefire-plugin.version} 82 | 83 | 84 | org.jboss.logmanager.LogManager 85 | ${maven.home} 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | native 94 | 95 | 96 | native 97 | 98 | 99 | 100 | 101 | 102 | maven-failsafe-plugin 103 | ${surefire-plugin.version} 104 | 105 | 106 | 107 | integration-test 108 | verify 109 | 110 | 111 | 112 | ${project.build.directory}/${project.build.finalName}-runner 113 | org.jboss.logmanager.LogManager 114 | ${maven.home} 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | native 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /artist/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /customer/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /vintage-store/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /database-generator/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /pom-copy.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus 6 | jpa-panache 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 11 12 | 11 13 | UTF-8 14 | UTF-8 15 | 2.0.0.Alpha2 16 | quarkus-bom 17 | io.quarkus 18 | 2.0.0.Alpha2 19 | 3.0.0-M5 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | 35 | io.quarkus 36 | quarkus-resteasy-jsonb 37 | 38 | 39 | io.quarkus 40 | quarkus-arc 41 | 42 | 43 | io.quarkus 44 | quarkus-resteasy 45 | 46 | 47 | 48 | io.quarkus 49 | quarkus-hibernate-orm-panache 50 | 51 | 52 | io.quarkus 53 | quarkus-hibernate-orm 54 | 55 | 56 | 57 | io.quarkus 58 | quarkus-jdbc-mariadb 59 | 60 | 61 | io.quarkus 62 | quarkus-jdbc-mysql 63 | 64 | 65 | io.quarkus 66 | quarkus-jdbc-postgresql 67 | 68 | 69 | 70 | io.quarkus 71 | quarkus-junit5 72 | test 73 | 74 | 75 | io.rest-assured 76 | rest-assured 77 | test 78 | 79 | 80 | com.github.javafaker 81 | javafaker 82 | 1.0.2 83 | test 84 | 85 | 86 | 87 | 88 | 89 | io.quarkus 90 | quarkus-maven-plugin 91 | ${quarkus-plugin.version} 92 | true 93 | 94 | 95 | 96 | build 97 | generate-code 98 | generate-code-tests 99 | 100 | 101 | 102 | 103 | 104 | maven-compiler-plugin 105 | ${compiler-plugin.version} 106 | 107 | ${maven.compiler.parameters} 108 | 109 | 110 | 111 | maven-surefire-plugin 112 | ${surefire-plugin.version} 113 | 114 | 115 | org.jboss.logmanager.LogManager 116 | ${maven.home} 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | native 125 | 126 | 127 | native 128 | 129 | 130 | 131 | 132 | 133 | maven-failsafe-plugin 134 | ${surefire-plugin.version} 135 | 136 | 137 | 138 | integration-test 139 | verify 140 | 141 | 142 | 143 | ${project.build.directory}/${project.build.finalName}-runner 144 | org.jboss.logmanager.LogManager 145 | ${maven.home} 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | native 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /vintage-store/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.agoncal.course.quarkus.orm 6 | vintage-store 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 11 12 | 11 13 | UTF-8 14 | UTF-8 15 | 2.0.0.Final 16 | quarkus-bom 17 | io.quarkus 18 | 2.0.0.Final 19 | 3.0.0-M5 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | org.agoncal.course.quarkus.orm 35 | artist 36 | 1.0.0-SNAPSHOT 37 | 38 | 39 | io.quarkus 40 | quarkus-jdbc-mysql 41 | 42 | 43 | 44 | 45 | org.agoncal.course.quarkus.orm 46 | customer 47 | 1.0.0-SNAPSHOT 48 | 49 | 50 | io.quarkus 51 | quarkus-jdbc-mariadb 52 | 53 | 54 | 55 | 56 | io.quarkus 57 | quarkus-hibernate-orm-panache 58 | 59 | 60 | io.quarkus 61 | quarkus-jdbc-postgresql 62 | 63 | 64 | io.quarkus 65 | quarkus-smallrye-openapi 66 | 67 | 68 | io.quarkus 69 | quarkus-jdbc-h2 70 | test 71 | 72 | 73 | io.quarkus 74 | quarkus-arc 75 | 76 | 77 | io.quarkus 78 | quarkus-resteasy 79 | 80 | 81 | io.quarkus 82 | quarkus-resteasy-jsonb 83 | 84 | 85 | io.quarkus 86 | quarkus-resteasy-qute 87 | 88 | 89 | io.quarkus 90 | quarkus-junit5 91 | test 92 | 93 | 94 | io.quarkus 95 | quarkus-junit5-mockito 96 | test 97 | 98 | 99 | io.rest-assured 100 | rest-assured 101 | test 102 | 103 | 104 | 105 | 106 | 107 | io.quarkus 108 | quarkus-maven-plugin 109 | ${quarkus-plugin.version} 110 | true 111 | 112 | 113 | 114 | build 115 | generate-code 116 | generate-code-tests 117 | 118 | 119 | 120 | 121 | 122 | maven-compiler-plugin 123 | ${compiler-plugin.version} 124 | 125 | ${maven.compiler.parameters} 126 | 127 | 128 | 129 | maven-surefire-plugin 130 | ${surefire-plugin.version} 131 | 132 | 133 | org.jboss.logmanager.LogManager 134 | ${maven.home} 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | native 143 | 144 | 145 | native 146 | 147 | 148 | 149 | 150 | 151 | maven-failsafe-plugin 152 | ${surefire-plugin.version} 153 | 154 | 155 | 156 | integration-test 157 | verify 158 | 159 | 160 | 161 | ${project.build.directory}/${project.build.finalName}-runner 162 | org.jboss.logmanager.LogManager 163 | ${maven.home} 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | native 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /artist/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /customer/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /vintage-store/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /database-generator/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | --------------------------------------------------------------------------------