From 7e6beaadd39de6775bcac018881bac523ecb8f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Fri, 21 Oct 2022 15:32:14 +0200 Subject: [PATCH] incidents are now stored in database --- .gitignore | 2 ++ .mvn/wrapper/maven-wrapper.properties | 18 ++++++++++++ pom.xml | 4 +++ .../org/sebi/incident/IncidentStartup.java | 29 ------------------- src/main/resources/application.properties | 11 +++++-- src/main/resources/dataset.sql | 8 +++++ 6 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 .gitignore create mode 100644 .mvn/wrapper/maven-wrapper.properties delete mode 100644 src/main/java/org/sebi/incident/IncidentStartup.java create mode 100644 src/main/resources/dataset.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f8e87b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target +.mvn/wrapper/*.jar diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..3005215 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/pom.xml b/pom.xml index 33661a6..41e6b6a 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,10 @@ rest-assured test + + io.quarkus + quarkus-jdbc-mysql + diff --git a/src/main/java/org/sebi/incident/IncidentStartup.java b/src/main/java/org/sebi/incident/IncidentStartup.java deleted file mode 100644 index 6eff978..0000000 --- a/src/main/java/org/sebi/incident/IncidentStartup.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.sebi.incident; - -import java.util.Date; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; -import javax.transaction.Transactional; - -import io.quarkus.runtime.StartupEvent; - -@ApplicationScoped -public class IncidentStartup { - - @Transactional - void onStart(@Observes StartupEvent ev) { - Incident incident = new Incident(); - incident.date = new Date(); - incident.description = "coupure fibre, remote"; - incident.status = false; - incident.persist(); - - Incident incident1 = new Incident(); - incident1.date = new Date(); - incident1.description = "Panne émetteur"; - incident1.status = true; - incident1.persist(); - } - -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d1efbce..d95c007 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,8 +1,13 @@ quarkus.swagger-ui.always-include=true apikey=mysecret -quarkus.container-image.group=sebastienblanc0 +quarkus.container-image.group=redhat_sa_france quarkus.container-image.registry=quay.io -quarkus.datasource.jdbc.url=jdbc:h2:mem:myDB +quarkus.datasource.db-kind=mysql +%dev.quarkus.datasource.username=antennas +%dev.quarkus.datasource.password=antennas +%dev.quarkus.datasource.jdbc.url=jdbc:mysql://localhost:3306/antennas quarkus.hibernate-orm.database.generation=update +%dev.quarkus.hibernate-orm.database.generation=drop-and-create %dev.quarkus.http.port=8081 -version=2 \ No newline at end of file +version=2 +quarkus.hibernate-orm.sql-load-script=dataset.sql diff --git a/src/main/resources/dataset.sql b/src/main/resources/dataset.sql new file mode 100644 index 0000000..3af1706 --- /dev/null +++ b/src/main/resources/dataset.sql @@ -0,0 +1,8 @@ +INSERT IGNORE INTO Incident + ( + id, date, description, status + ) +VALUES + (1, "2022-10-21", "coupure fibre", 0), + (2, "2022-10-22", "panne émetteur", 0), + (3, "2022-10-22", "le datacenter a grillé", 0);