Skip to content

Commit

Permalink
feat: update to latest parent
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras committed Jan 25, 2024
1 parent 8ce500e commit 0106f2f
Show file tree
Hide file tree
Showing 14 changed files with 362 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ on:

jobs:
build:
uses: onecx/ci-quarkus/.github/workflows/build.yml@v1
uses: onecx/ci-quarkus/.github/workflows/build.yml@feat/check
secrets: inherit
9 changes: 9 additions & 0 deletions .github/workflows/create-new-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Create new build

on:
workflow_dispatch:

jobs:
build:
uses: onecx/ci-common/.github/workflows/create-new-build.yml@v1
secrets: inherit
117 changes: 112 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<parent>
<groupId>io.github.onecx</groupId>
<artifactId>onecx-quarkus2-parent</artifactId>
<version>0.17.0</version>
<artifactId>onecx-quarkus3-parent</artifactId>
<version>0.27.0</version>
</parent>

<groupId>org.tkit.quarkus</groupId>
Expand All @@ -17,20 +17,127 @@
<name>ping-quarkus</name>

<dependencies>
<dependency>
<groupId>io.github.onecx.quarkus</groupId>
<artifactId>onecx-core</artifactId>
</dependency>
<dependency>
<groupId>io.github.onecx.quarkus</groupId>
<artifactId>onecx-tenant</artifactId>
</dependency>
<!-- 1000kit -->
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-rest-context</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-jpa-tenant</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-data-import</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-log-cdi</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-log-rs</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-log-json</artifactId>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-rest</artifactId>
</dependency>

<!-- Quarkus -->
<!-- QUARKUS -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-liquibase</artifactId>
</dependency>
<dependency>
<groupId>com.github.blagerweij</groupId>
<artifactId>liquibase-sessionlock</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-context-propagation</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>

<!-- OTHER -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>

<!-- TEST -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
17 changes: 8 additions & 9 deletions src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM registry.access.redhat.com/ubi9/openjdk-17:1.14
FROM registry.access.redhat.com/ubi9/openjdk-17:1.15

ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
ENV LANGUAGE='en_US:en'

# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 1001
USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
11 changes: 11 additions & 0 deletions src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.2
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
10 changes: 3 additions & 7 deletions src/main/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
app:
image:
repository: "1000kit/${project.artifactId}"
tag: 999-SNAPSHOT
repository: "onecx/ping-quarkus"
db:
enabled: false
livenessProbe:
url: /health
readinessProbe:
url: /health
enabled: true

88 changes: 88 additions & 0 deletions src/main/java/org/tkit/quarkus/hello/domain/daos/ThemeDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.tkit.quarkus.hello.domain.daos;

import java.util.Set;
import java.util.stream.Stream;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.persistence.NoResultException;
import jakarta.transaction.Transactional;

import org.tkit.quarkus.hello.domain.models.Theme;
import org.tkit.quarkus.hello.domain.models.Theme_;
import org.tkit.quarkus.jpa.daos.AbstractDAO;
import org.tkit.quarkus.jpa.daos.Page;
import org.tkit.quarkus.jpa.daos.PageResult;
import org.tkit.quarkus.jpa.exceptions.DAOException;
import org.tkit.quarkus.jpa.models.TraceableEntity_;

@ApplicationScoped
public class ThemeDAO extends AbstractDAO<Theme> {

// https://hibernate.atlassian.net/browse/HHH-16830#icft=HHH-16830
@Override
public Theme findById(Object id) throws DAOException {
try {
var cb = this.getEntityManager().getCriteriaBuilder();
var cq = cb.createQuery(Theme.class);
var root = cq.from(Theme.class);
cq.where(cb.equal(root.get(TraceableEntity_.ID), id));
return this.getEntityManager().createQuery(cq).getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (Exception e) {
throw new DAOException(ErrorKeys.FIND_ENTITY_BY_ID_FAILED, e, entityName, id);
}
}

@Transactional(Transactional.TxType.SUPPORTS)
public Stream<Theme> findThemeByNames(Set<String> themeNames) {
try {
var cb = this.getEntityManager().getCriteriaBuilder();
var cq = cb.createQuery(Theme.class);
var root = cq.from(Theme.class);

if (themeNames != null && !themeNames.isEmpty()) {
cq.where(root.get(Theme_.name).in(themeNames));
}
return this.getEntityManager().createQuery(cq).getResultStream();

} catch (Exception ex) {
throw new DAOException(ErrorKeys.ERROR_FIND_THEME_BY_NAMES, ex);
}
}

public PageResult<Theme> findAll(Integer pageNumber, Integer pageSize) {
try {
var cb = this.getEntityManager().getCriteriaBuilder();
var cq = cb.createQuery(Theme.class);
cq.from(Theme.class);
return createPageQuery(cq, Page.of(pageNumber, pageSize)).getPageResult();
} catch (Exception ex) {
throw new DAOException(ErrorKeys.ERROR_FIND_ALL_THEME_PAGE, ex);
}
}

public Theme findThemeByName(String themeName) {
try {
var cb = this.getEntityManager().getCriteriaBuilder();
var cq = cb.createQuery(Theme.class);
var root = cq.from(Theme.class);
cq.where(cb.equal(root.get(Theme_.name), themeName));

return this.getEntityManager().createQuery(cq).getSingleResult();

} catch (NoResultException nre) {
return null;
} catch (Exception ex) {
throw new DAOException(ErrorKeys.ERROR_FIND_THEME_BY_NAME, ex);
}
}

public enum ErrorKeys {

FIND_ENTITY_BY_ID_FAILED,
ERROR_FIND_ALL_THEME_PAGE,
ERROR_FIND_THEME_BY_NAMES,
ERROR_FIND_THEME_BY_NAME,
}
}
52 changes: 52 additions & 0 deletions src/main/java/org/tkit/quarkus/hello/domain/models/Theme.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.tkit.quarkus.hello.domain.models;

import java.time.LocalDateTime;

import jakarta.persistence.*;

import org.hibernate.annotations.TenantId;
import org.tkit.quarkus.jpa.models.TraceableEntity;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "THEME", uniqueConstraints = {
@UniqueConstraint(name = "THEME_NAME", columnNames = { "NAME", "TENANT_ID" })
})
@SuppressWarnings("java:S2160")
public class Theme extends TraceableEntity {

@Column(name = "NAME")
private String name;

@TenantId
@Column(name = "TENANT_ID")
private String tenantId;

@Column(name = "CSS_FILE")
private String cssFile;

@Column(name = "DESCRIPTION")
private String description;

@Column(name = "ASSETS_URL")
private String assetsUrl;

@Column(name = "LOGO_URL")
private String logoUrl;

@Column(name = "FAVICON_URL")
private String faviconUrl;

@Column(name = "PREVIEW_IMAGE_URL")
private String previewImageUrl;

@Column(name = "ASSETS_UPDATE_DATE")
private LocalDateTime assetsUpdateDate;

@Column(name = "PROPERTIES", columnDefinition = "TEXT")
private String properties;
}
12 changes: 6 additions & 6 deletions src/main/java/org/tkit/quarkus/hello/rs/HelloRestController.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.tkit.quarkus.hello.rs;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

@Path("hello")
@Consumes(MediaType.APPLICATION_JSON)
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# container image for local dev
quarkus.container-image.group=localhost

tkit.dataimport.enabled=false
9 changes: 9 additions & 0 deletions src/main/resources/db/changeLog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

<include relativeToChangelogFile="true" file="v1/2023-11-09-create-tables.xml"/>
<include relativeToChangelogFile="true" file="v1/2023-11-09-data-import-log.xml"/>

</databaseChangeLog>
Loading

0 comments on commit 0106f2f

Please sign in to comment.