Browse Source

incidents are now stored in database

pull/1/head
Nicolas Massé 3 years ago
parent
commit
7e6beaadd3
  1. 2
      .gitignore
  2. 18
      .mvn/wrapper/maven-wrapper.properties
  3. 4
      pom.xml
  4. 29
      src/main/java/org/sebi/incident/IncidentStartup.java
  5. 9
      src/main/resources/application.properties
  6. 8
      src/main/resources/dataset.sql

2
.gitignore

@ -0,0 +1,2 @@
target
.mvn/wrapper/*.jar

18
.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

4
pom.xml

@ -74,6 +74,10 @@
<artifactId>rest-assured</artifactId> <artifactId>rest-assured</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

29
src/main/java/org/sebi/incident/IncidentStartup.java

@ -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();
}
}

9
src/main/resources/application.properties

@ -1,8 +1,13 @@
quarkus.swagger-ui.always-include=true quarkus.swagger-ui.always-include=true
apikey=mysecret apikey=mysecret
quarkus.container-image.group=sebastienblanc0 quarkus.container-image.group=redhat_sa_france
quarkus.container-image.registry=quay.io 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 quarkus.hibernate-orm.database.generation=update
%dev.quarkus.hibernate-orm.database.generation=drop-and-create
%dev.quarkus.http.port=8081 %dev.quarkus.http.port=8081
version=2 version=2
quarkus.hibernate-orm.sql-load-script=dataset.sql

8
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);
Loading…
Cancel
Save